Mercurial > projects > dwt-addons
changeset 103:2d6540440fe6
Replace static ctors with lazy init.
line wrap: on
line diff
--- a/dwtx/draw2d/AbstractBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/AbstractBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -29,14 +29,29 @@ : Border { -private static const Dimension EMPTY; +private static Dimension EMPTY_; +private static Dimension EMPTY(){ + if( EMPTY_ is null ){ + synchronized( AbstractBorder.classinfo ){ + if( EMPTY_ is null ){ + EMPTY_ = new Dimension(); + } + } + } + return EMPTY_; +} /** A temporary Rectangle*/ -protected static Rectangle tempRect; - -static this(){ - EMPTY = new Dimension(); - tempRect = new Rectangle(); +private static Rectangle tempRect_; +protected static Rectangle tempRect(){ + if( tempRect_ is null ){ + synchronized( AbstractBorder.classinfo ){ + if( tempRect_ is null ){ + tempRect_ = new Rectangle(); + } + } + } + return tempRect_; } /**
--- a/dwtx/draw2d/AbstractRouter.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/AbstractRouter.d Sun Aug 03 17:01:51 2008 +0200 @@ -26,12 +26,29 @@ : ConnectionRouter { -private static const Point START; -private static const Point END; +private static Point START_; +private static Point END_; -static this(){ - START = new Point(); - END = new Point(); +private static Point START(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(START_); + return START_; +} +private static Point END(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(END_); + return END_; +} + +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( AbstractRouter.classinfo ){ + if( !initStaticCtor_done ){ + START_ = new Point(); + END_ = new Point(); + initStaticCtor_done = true; + } + } } /**
--- a/dwtx/draw2d/BendpointConnectionRouter.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/BendpointConnectionRouter.d Sun Aug 03 17:01:51 2008 +0200 @@ -30,10 +30,17 @@ { private Map constraints; -private static const PrecisionPoint A_POINT; -static this(){ - A_POINT = new PrecisionPoint(); +private static PrecisionPoint A_POINT_; +private static PrecisionPoint A_POINT(){ + if( A_POINT_ is null ){ + synchronized( BendpointConnectionRouter.classinfo ){ + if( A_POINT_ is null ){ + A_POINT_ = new PrecisionPoint(); + } + } + } + return A_POINT_; } public this(){
--- a/dwtx/draw2d/BorderLayout.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/BorderLayout.d Sun Aug 03 17:01:51 2008 +0200 @@ -31,30 +31,56 @@ /** * Constant to be used as a constraint for child figures */ -public static const Integer CENTER; +private static Integer CENTER_; +public static Integer CENTER(){ + if( !initStaticCtor_done ) initStaticCtor(); + return CENTER_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer TOP; +private static Integer TOP_; +public static Integer TOP(){ + if( !initStaticCtor_done ) initStaticCtor(); + return TOP_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer BOTTOM; +private static Integer BOTTOM_; +public static Integer BOTTOM(){ + if( !initStaticCtor_done ) initStaticCtor(); + return BOTTOM_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer LEFT; +private static Integer LEFT_; +public static Integer LEFT(){ + if( !initStaticCtor_done ) initStaticCtor(); + return LEFT_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer RIGHT; +private static Integer RIGHT_; +public static Integer RIGHT(){ + if( !initStaticCtor_done ) initStaticCtor(); + return RIGHT_; +} -static this(){ - CENTER = new Integer(PositionConstants.CENTER); - TOP = new Integer(PositionConstants.TOP); - BOTTOM = new Integer(PositionConstants.BOTTOM); - LEFT = new Integer(PositionConstants.LEFT); - RIGHT = new Integer(PositionConstants.RIGHT); +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( BorderLayout.classinfo ){ + if( !initStaticCtor_done ){ + CENTER_ = new Integer(PositionConstants.CENTER); + TOP_ = new Integer(PositionConstants.TOP); + BOTTOM_ = new Integer(PositionConstants.BOTTOM); + LEFT_ = new Integer(PositionConstants.LEFT); + RIGHT_ = new Integer(PositionConstants.RIGHT); + initStaticCtor_done = true; + } + } } private IFigure center, left, top, bottom, right;
--- a/dwtx/draw2d/ButtonBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/ButtonBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -44,8 +44,8 @@ * Default button border. * @see SCHEMES#BUTTON */ -private static const Border BUTTON_; -public static ButtonScheme BUTTON(){ +private static Border BUTTON_; +public static Border BUTTON(){ if( BUTTON_ is null ){ synchronized( ButtonScheme.classinfo ){ if( BUTTON_ is null ){ @@ -59,8 +59,8 @@ * Inverted hightlight colors from BUTTON. * @see SCHEMES#BUTTON_CONTRAST */ -private static const Border BUTTON_CONTRAST_; -public static ButtonScheme BUTTON_CONTRAST(){ +private static Border BUTTON_CONTRAST_; +public static Border BUTTON_CONTRAST(){ if( BUTTON_CONTRAST_ is null ){ synchronized( ButtonScheme.classinfo ){ if( BUTTON_CONTRAST_ is null ){ @@ -74,8 +74,8 @@ * Used for scrollbar buttons. * @see SCHEMES#BUTTON_SCROLLBAR */ -private static const Border BUTTON_SCROLLBAR_; -public static ButtonScheme BUTTON_SCROLLBAR(){ +private static Border BUTTON_SCROLLBAR_; +public static Border BUTTON_SCROLLBAR(){ if( BUTTON_SCROLLBAR_ is null ){ synchronized( ButtonScheme.classinfo ){ if( BUTTON_SCROLLBAR_ is null ){ @@ -89,8 +89,8 @@ * Used for toolbar buttons. * @see SCHEMES#TOOLBAR */ -private static const Border TOOLBAR_; -public static ButtonScheme TOOLBAR(){ +private static Border TOOLBAR_; +public static Border TOOLBAR(){ if( TOOLBAR_ is null ){ synchronized( ButtonScheme.classinfo ){ if( TOOLBAR_ is null ){ @@ -226,7 +226,7 @@ /** * Contrast button scheme */ - private static const ButtonScheme BUTTON_CONTRAST_; + private static ButtonScheme BUTTON_CONTRAST_; static ButtonScheme BUTTON_CONTRAST(){ if( BUTTON_CONTRAST_ is null ){ synchronized( ButtonScheme.classinfo ){ @@ -243,7 +243,7 @@ /** * Regular button scheme */ - private static const ButtonScheme BUTTON_; + private static ButtonScheme BUTTON_; static ButtonScheme BUTTON(){ if( BUTTON_ is null ){ synchronized( ButtonScheme.classinfo ){ @@ -260,7 +260,7 @@ /** * Toolbar button scheme */ - private static const ButtonScheme TOOLBAR_; + private static ButtonScheme TOOLBAR_; static ButtonScheme TOOLBAR(){ if( TOOLBAR_ is null ){ synchronized( ButtonScheme.classinfo ){ @@ -277,7 +277,7 @@ /** * Scrollbar button scheme */ - private static const ButtonScheme BUTTON_SCROLLBAR_; + private static ButtonScheme BUTTON_SCROLLBAR_; static ButtonScheme BUTTON_SCROLLBAR(){ if( BUTTON_SCROLLBAR_ is null ){ synchronized( ButtonScheme.classinfo ){
--- a/dwtx/draw2d/CheckBox.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/CheckBox.d Sun Aug 03 17:01:51 2008 +0200 @@ -33,13 +33,31 @@ private Label label = null; -static const Image - UNCHECKED, - CHECKED; +private static Image + UNCHECKED_, + CHECKED_; -static this(){ - UNCHECKED = createImage( getImportData!("dwtx.draw2d.checkboxenabledoff.gif")); //$NON-NLS-1$ - CHECKED = createImage( getImportData!("dwtx.draw2d.checkboxenabledon.gif")); //$NON-NLS-1$ +package static Image UNCHECKED(){ + if( UNCHECKED_ is null ){ + synchronized( CheckBox.classinfo ){ + if( UNCHECKED_ is null ){ + UNCHECKED_ = createImage( getImportData!("dwtx.draw2d.checkboxenabledoff.gif")); + } + } + } + assert( UNCHECKED_ ); + return UNCHECKED_; +} +package static Image CHECKED(){ + if( CHECKED_ is null ){ + synchronized( CheckBox.classinfo ){ + if( CHECKED_ is null ){ + CHECKED_ = createImage( getImportData!("dwtx.draw2d.checkboxenabledon.gif")); + } + } + } + assert( CHECKED_ ); + return CHECKED_; } private static Image createImage( ImportData importdata ) {
--- a/dwtx/draw2d/ColorConstants.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/ColorConstants.d Sun Aug 03 17:01:51 2008 +0200 @@ -48,7 +48,11 @@ private static Color buttonLightest_; public static Color buttonLightest(){ if( buttonLightest_ is null ){ - buttonLightest_ = getColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); + synchronized( Display.classinfo ){ + if( buttonLightest_ is null ){ + buttonLightest_ = getColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); + } + } } return buttonLightest_; } @@ -58,7 +62,11 @@ private static Color button_; public static Color button(){ if( button_ is null ){ - button_ = getColor(DWT.COLOR_WIDGET_BACKGROUND); + synchronized( Display.classinfo ){ + if( button_ is null ){ + button_ = getColor(DWT.COLOR_WIDGET_BACKGROUND); + } + } } return button_; } @@ -68,7 +76,11 @@ private static Color buttonDarker_; public static Color buttonDarker(){ if( buttonDarker_ is null ){ - buttonDarker_ = getColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); + synchronized( Display.classinfo ){ + if( buttonDarker_ is null ){ + buttonDarker_ = getColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); + } + } } return buttonDarker_; } @@ -78,7 +90,11 @@ private static Color buttonDarkest_; public static Color buttonDarkest(){ if( buttonDarkest_ is null ){ - buttonDarkest_ = getColor(DWT.COLOR_WIDGET_DARK_SHADOW); + synchronized( Display.classinfo ){ + if( buttonDarkest_ is null ){ + buttonDarkest_ = getColor(DWT.COLOR_WIDGET_DARK_SHADOW); + } + } } return buttonDarkest_; } @@ -89,7 +105,11 @@ private static Color listBackground_; public static Color listBackground(){ if( listBackground_ is null ){ - listBackground_ = getColor(DWT.COLOR_LIST_BACKGROUND); + synchronized( Display.classinfo ){ + if( listBackground_ is null ){ + listBackground_ = getColor(DWT.COLOR_LIST_BACKGROUND); + } + } } return listBackground_; } @@ -99,7 +119,11 @@ private static Color listForeground_; public static Color listForeground(){ if( listForeground_ is null ){ - listForeground_ = getColor(DWT.COLOR_LIST_FOREGROUND); + synchronized( Display.classinfo ){ + if( listForeground_ is null ){ + listForeground_ = getColor(DWT.COLOR_LIST_FOREGROUND); + } + } } return listForeground_; } @@ -110,7 +134,11 @@ private static Color menuBackground_; public static Color menuBackground(){ if( menuBackground_ is null ){ - menuBackground_ = getColor(DWT.COLOR_WIDGET_BACKGROUND); + synchronized( Display.classinfo ){ + if( menuBackground_ is null ){ + menuBackground_ = getColor(DWT.COLOR_WIDGET_BACKGROUND); + } + } } return menuBackground_; } @@ -120,7 +148,11 @@ private static Color menuForeground_; public static Color menuForeground(){ if( menuForeground_ is null ){ - menuForeground_ = getColor(DWT.COLOR_WIDGET_FOREGROUND); + synchronized( Display.classinfo ){ + if( menuForeground_ is null ){ + menuForeground_ = getColor(DWT.COLOR_WIDGET_FOREGROUND); + } + } } return menuForeground_; } @@ -130,7 +162,11 @@ private static Color menuBackgroundSelected_; public static Color menuBackgroundSelected(){ if( menuBackgroundSelected_ is null ){ - menuBackgroundSelected_ = getColor(DWT.COLOR_LIST_SELECTION); + synchronized( Display.classinfo ){ + if( menuBackgroundSelected_ is null ){ + menuBackgroundSelected_ = getColor(DWT.COLOR_LIST_SELECTION); + } + } } return menuBackgroundSelected_; } @@ -140,7 +176,11 @@ private static Color menuForegroundSelected_; public static Color menuForegroundSelected(){ if( menuForegroundSelected_ is null ){ - menuForegroundSelected_ = getColor(DWT.COLOR_LIST_SELECTION_TEXT); + synchronized( Display.classinfo ){ + if( menuForegroundSelected_ is null ){ + menuForegroundSelected_ = getColor(DWT.COLOR_LIST_SELECTION_TEXT); + } + } } return menuForegroundSelected_; } @@ -151,7 +191,11 @@ private static Color titleBackground_; public static Color titleBackground(){ if( titleBackground_ is null ){ - titleBackground_ = getColor(DWT.COLOR_TITLE_BACKGROUND); + synchronized( Display.classinfo ){ + if( titleBackground_ is null ){ + titleBackground_ = getColor(DWT.COLOR_TITLE_BACKGROUND); + } + } } return titleBackground_; } @@ -161,7 +205,11 @@ private static Color titleGradient_; public static Color titleGradient(){ if( titleGradient_ is null ){ - titleGradient_ = getColor(DWT.COLOR_TITLE_BACKGROUND_GRADIENT); + synchronized( Display.classinfo ){ + if( titleGradient_ is null ){ + titleGradient_ = getColor(DWT.COLOR_TITLE_BACKGROUND_GRADIENT); + } + } } return titleGradient_; } @@ -171,7 +219,11 @@ private static Color titleForeground_; public static Color titleForeground(){ if( titleForeground_ is null ){ - titleForeground_ = getColor(DWT.COLOR_TITLE_FOREGROUND); + synchronized( Display.classinfo ){ + if( titleForeground_ is null ){ + titleForeground_ = getColor(DWT.COLOR_TITLE_FOREGROUND); + } + } } return titleForeground_; } @@ -181,7 +233,11 @@ private static Color titleInactiveForeground_; public static Color titleInactiveForeground(){ if( titleInactiveForeground_ is null ){ - titleInactiveForeground_ = getColor(DWT.COLOR_TITLE_INACTIVE_FOREGROUND); + synchronized( Display.classinfo ){ + if( titleInactiveForeground_ is null ){ + titleInactiveForeground_ = getColor(DWT.COLOR_TITLE_INACTIVE_FOREGROUND); + } + } } return titleInactiveForeground_; } @@ -191,7 +247,11 @@ private static Color titleInactiveBackground_; public static Color titleInactiveBackground(){ if( titleInactiveBackground_ is null ){ - titleInactiveBackground_ = getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND); + synchronized( Display.classinfo ){ + if( titleInactiveBackground_ is null ){ + titleInactiveBackground_ = getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND); + } + } } return titleInactiveBackground_; } @@ -201,7 +261,11 @@ private static Color titleInactiveGradient_; public static Color titleInactiveGradient(){ if( titleInactiveGradient_ is null ){ - titleInactiveGradient_ = getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); + synchronized( Display.classinfo ){ + if( titleInactiveGradient_ is null ){ + titleInactiveGradient_ = getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); + } + } } return titleInactiveGradient_; } @@ -212,7 +276,11 @@ private static Color tooltipForeground_; public static Color tooltipForeground(){ if( tooltipForeground_ is null ){ - tooltipForeground_ = getColor(DWT.COLOR_INFO_FOREGROUND); + synchronized( Display.classinfo ){ + if( tooltipForeground_ is null ){ + tooltipForeground_ = getColor(DWT.COLOR_INFO_FOREGROUND); + } + } } return tooltipForeground_; } @@ -222,7 +290,11 @@ private static Color tooltipBackground_; public static Color tooltipBackground(){ if( tooltipBackground_ is null ){ - tooltipBackground_ = getColor(DWT.COLOR_INFO_BACKGROUND); + synchronized( Display.classinfo ){ + if( tooltipBackground_ is null ){ + tooltipBackground_ = getColor(DWT.COLOR_INFO_BACKGROUND); + } + } } return tooltipBackground_; } @@ -234,7 +306,11 @@ private static Color white_; public static Color white(){ if( white_ is null ){ - white_ = new Color(null, 255, 255, 255); + synchronized( Display.classinfo ){ + if( white_ is null ){ + white_ = new Color(null, 255, 255, 255); + } + } } return white_; } @@ -242,7 +318,11 @@ private static Color lightGray_; public static Color lightGray(){ if( lightGray_ is null ){ - lightGray_ = new Color(null, 192, 192, 192); + synchronized( Display.classinfo ){ + if( lightGray_ is null ){ + lightGray_ = new Color(null, 192, 192, 192); + } + } } return lightGray_; } @@ -250,7 +330,11 @@ private static Color gray_; public static Color gray(){ if( gray_ is null ){ - gray_ = new Color(null, 128, 128, 128); + synchronized( Display.classinfo ){ + if( gray_ is null ){ + gray_ = new Color(null, 128, 128, 128); + } + } } return gray_; } @@ -258,7 +342,11 @@ private static Color darkGray_; public static Color darkGray(){ if( darkGray_ is null ){ - darkGray_ = new Color(null, 64, 64, 64); + synchronized( Display.classinfo ){ + if( darkGray_ is null ){ + darkGray_ = new Color(null, 64, 64, 64); + } + } } return darkGray_; } @@ -266,7 +354,11 @@ private static Color black_; public static Color black(){ if( black_ is null ){ - black_ = new Color(null, 0, 0, 0); + synchronized( Display.classinfo ){ + if( black_ is null ){ + black_ = new Color(null, 0, 0, 0); + } + } } return black_; } @@ -274,7 +366,11 @@ private static Color red_; public static Color red(){ if( red_ is null ){ - red_ = new Color(null, 255, 0, 0); + synchronized( Display.classinfo ){ + if( red_ is null ){ + red_ = new Color(null, 255, 0, 0); + } + } } return red_; } @@ -282,7 +378,11 @@ private static Color orange_; public static Color orange(){ if( orange_ is null ){ - orange_ = new Color(null, 255, 196, 0); + synchronized( Display.classinfo ){ + if( orange_ is null ){ + orange_ = new Color(null, 255, 196, 0); + } + } } return orange_; } @@ -290,7 +390,11 @@ private static Color yellow_; public static Color yellow(){ if( yellow_ is null ){ - yellow_ = new Color(null, 255, 255, 0); + synchronized( Display.classinfo ){ + if( yellow_ is null ){ + yellow_ = new Color(null, 255, 255, 0); + } + } } return yellow_; } @@ -298,7 +402,11 @@ private static Color green_; public static Color green(){ if( green_ is null ){ - green_ = new Color(null, 0, 255, 0); + synchronized( Display.classinfo ){ + if( green_ is null ){ + green_ = new Color(null, 0, 255, 0); + } + } } return green_; } @@ -306,7 +414,11 @@ private static Color lightGreen_; public static Color lightGreen(){ if( lightGreen_ is null ){ - lightGreen_ = new Color(null, 96, 255, 96); + synchronized( Display.classinfo ){ + if( lightGreen_ is null ){ + lightGreen_ = new Color(null, 96, 255, 96); + } + } } return lightGreen_; } @@ -314,7 +426,11 @@ private static Color darkGreen_; public static Color darkGreen(){ if( darkGreen_ is null ){ - darkGreen_ = new Color(null, 0, 127, 0); + synchronized( Display.classinfo ){ + if( darkGreen_ is null ){ + darkGreen_ = new Color(null, 0, 127, 0); + } + } } return darkGreen_; } @@ -322,7 +438,11 @@ private static Color cyan_; public static Color cyan(){ if( cyan_ is null ){ - cyan_ = new Color(null, 0, 255, 255); + synchronized( Display.classinfo ){ + if( cyan_ is null ){ + cyan_ = new Color(null, 0, 255, 255); + } + } } return cyan_; } @@ -330,7 +450,11 @@ private static Color lightBlue_; public static Color lightBlue(){ if( lightBlue_ is null ){ - lightBlue_ = new Color(null, 127, 127, 255); + synchronized( Display.classinfo ){ + if( lightBlue_ is null ){ + lightBlue_ = new Color(null, 127, 127, 255); + } + } } return lightBlue_; } @@ -338,7 +462,11 @@ private static Color blue_; public static Color blue(){ if( blue_ is null ){ - blue_ = new Color(null, 0, 0, 255); + synchronized( Display.classinfo ){ + if( blue_ is null ){ + blue_ = new Color(null, 0, 0, 255); + } + } } return blue_; } @@ -346,7 +474,11 @@ private static Color darkBlue_; public static Color darkBlue(){ if( darkBlue_ is null ){ - darkBlue_ = new Color(null, 0, 0, 127); + synchronized( Display.classinfo ){ + if( darkBlue_ is null ){ + darkBlue_ = new Color(null, 0, 0, 127); + } + } } return darkBlue_; }
--- a/dwtx/draw2d/Cursors.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/Cursors.d Sun Aug 03 17:01:51 2008 +0200 @@ -85,115 +85,230 @@ /** * @see DWT#CURSOR_ARROW */ -public static const Cursor ARROW; +private static Cursor ARROW_; +public static Cursor ARROW(){ + if( !initStaticCtor_done ) initStaticCtor(); + return ARROW_; +} + /** * @see DWT#CURSOR_SIZEN */ -public static const Cursor SIZEN; +private static Cursor SIZEN_; +public static Cursor SIZEN(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZEN_; +} + /** * @see DWT#CURSOR_SIZENE */ -public static const Cursor SIZENE; +private static Cursor SIZENE_; +public static Cursor SIZENE(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZENE_; +} + /** * @see DWT#CURSOR_SIZEE */ -public static const Cursor SIZEE; +private static Cursor SIZEE_; +public static Cursor SIZEE(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZEE_; +} + /** * @see DWT#CURSOR_SIZESE */ -public static const Cursor SIZESE; +private static Cursor SIZESE_; +public static Cursor SIZESE(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZESE_; +} + /** * @see DWT#CURSOR_SIZES */ -public static const Cursor SIZES; +private static Cursor SIZES_; +public static Cursor SIZES(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZES_; +} + /** * @see DWT#CURSOR_SIZESW */ -public static const Cursor SIZESW; +private static Cursor SIZESW_; +public static Cursor SIZESW(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZESW_; +} + /** * @see DWT#CURSOR_SIZEW */ -public static const Cursor SIZEW; +private static Cursor SIZEW_; +public static Cursor SIZEW(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZEW_; +} + /** * @see DWT#CURSOR_SIZENW */ -public static const Cursor SIZENW; +private static Cursor SIZENW_; +public static Cursor SIZENW(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZENW_; +} + /** * @see DWT#CURSOR_APPSTARTING */ -public static const Cursor APPSTARTING; +private static Cursor APPSTARTING_; +public static Cursor APPSTARTING(){ + if( !initStaticCtor_done ) initStaticCtor(); + return APPSTARTING_; +} + /** * @see DWT#CURSOR_CROSS */ -public static const Cursor CROSS; +private static Cursor CROSS_; +public static Cursor CROSS(){ + if( !initStaticCtor_done ) initStaticCtor(); + return CROSS_; +} + /** * @see DWT#CURSOR_HAND */ -public static const Cursor HAND; +private static Cursor HAND_; +public static Cursor HAND(){ + if( !initStaticCtor_done ) initStaticCtor(); + return HAND_; +} + /** * @see DWT#CURSOR_HELP */ -public static const Cursor HELP; +private static Cursor HELP_; +public static Cursor HELP(){ + if( !initStaticCtor_done ) initStaticCtor(); + return HELP_; +} + /** * @see DWT#CURSOR_IBEAM */ -public static const Cursor IBEAM; +private static Cursor IBEAM_; +public static Cursor IBEAM(){ + if( !initStaticCtor_done ) initStaticCtor(); + return IBEAM_; +} + /** * @see DWT#CURSOR_NO */ -public static const Cursor NO; +private static Cursor NO_; +public static Cursor NO(){ + if( !initStaticCtor_done ) initStaticCtor(); + return NO_; +} + /** * @see DWT#CURSOR_SIZEALL */ -public static const Cursor SIZEALL; +private static Cursor SIZEALL_; +public static Cursor SIZEALL(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZEALL_; +} + /** * @see DWT#CURSOR_SIZENESW */ -public static const Cursor SIZENESW; +private static Cursor SIZENESW_; +public static Cursor SIZENESW(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZENESW_; +} + /** * @see DWT#CURSOR_SIZENWSE */ -public static const Cursor SIZENWSE; +private static Cursor SIZENWSE_; +public static Cursor SIZENWSE(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZENWSE_; +} + /** * @see DWT#CURSOR_SIZEWE */ -public static const Cursor SIZEWE; +private static Cursor SIZEWE_; +public static Cursor SIZEWE(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZEWE_; +} + /** * @see DWT#CURSOR_SIZENS */ -public static const Cursor SIZENS; +private static Cursor SIZENS_; +public static Cursor SIZENS(){ + if( !initStaticCtor_done ) initStaticCtor(); + return SIZENS_; +} + /** * @see DWT#CURSOR_UPARROW */ -public static const Cursor UPARROW; +private static Cursor UPARROW_; +public static Cursor UPARROW(){ + if( !initStaticCtor_done ) initStaticCtor(); + return UPARROW_; +} + /** * @see DWT#CURSOR_WAIT */ -public static const Cursor WAIT; +private static Cursor WAIT_; +public static Cursor WAIT(){ + if( !initStaticCtor_done ) initStaticCtor(); + return WAIT_; +} -static this() { - ARROW = new Cursor(null, DWT.CURSOR_ARROW); - SIZEN = new Cursor(null, DWT.CURSOR_SIZEN); - SIZENE = new Cursor(null, DWT.CURSOR_SIZENE); - SIZEE = new Cursor(null, DWT.CURSOR_SIZEE); - SIZESE = new Cursor(null, DWT.CURSOR_SIZESE); - SIZES = new Cursor(null, DWT.CURSOR_SIZES); - SIZESW = new Cursor(null, DWT.CURSOR_SIZESW); - SIZEW = new Cursor(null, DWT.CURSOR_SIZEW); - SIZENW = new Cursor(null, DWT.CURSOR_SIZENW); - SIZENS = new Cursor(null, DWT.CURSOR_SIZENS); - SIZEWE = new Cursor(null, DWT.CURSOR_SIZEWE); - APPSTARTING = new Cursor(null, DWT.CURSOR_APPSTARTING); - CROSS = new Cursor(null, DWT.CURSOR_CROSS); - HAND = new Cursor(null, DWT.CURSOR_HAND); - HELP = new Cursor(null, DWT.CURSOR_HELP); - IBEAM = new Cursor(null, DWT.CURSOR_IBEAM); - NO = new Cursor(null, DWT.CURSOR_NO); - SIZEALL = new Cursor(null, DWT.CURSOR_SIZEALL); - SIZENESW = new Cursor(null, DWT.CURSOR_SIZENESW); - SIZENWSE = new Cursor(null, DWT.CURSOR_SIZENWSE); - UPARROW = new Cursor(null, DWT.CURSOR_UPARROW); - WAIT = new Cursor(null, DWT.CURSOR_WAIT); +private static bool initStaticCtor_done = false; +private static void initStaticCtor() { + synchronized(Cursor.classinfo){ + if(!initStaticCtor_done){ + ARROW_ = new Cursor(null, DWT.CURSOR_ARROW); + SIZEN_ = new Cursor(null, DWT.CURSOR_SIZEN); + SIZENE_ = new Cursor(null, DWT.CURSOR_SIZENE); + SIZEE_ = new Cursor(null, DWT.CURSOR_SIZEE); + SIZESE_ = new Cursor(null, DWT.CURSOR_SIZESE); + SIZES_ = new Cursor(null, DWT.CURSOR_SIZES); + SIZESW_ = new Cursor(null, DWT.CURSOR_SIZESW); + SIZEW_ = new Cursor(null, DWT.CURSOR_SIZEW); + SIZENW_ = new Cursor(null, DWT.CURSOR_SIZENW); + SIZENS_ = new Cursor(null, DWT.CURSOR_SIZENS); + SIZEWE_ = new Cursor(null, DWT.CURSOR_SIZEWE); + APPSTARTING_ = new Cursor(null, DWT.CURSOR_APPSTARTING); + CROSS_ = new Cursor(null, DWT.CURSOR_CROSS); + HAND_ = new Cursor(null, DWT.CURSOR_HAND); + HELP_ = new Cursor(null, DWT.CURSOR_HELP); + IBEAM_ = new Cursor(null, DWT.CURSOR_IBEAM); + NO_ = new Cursor(null, DWT.CURSOR_NO); + SIZEALL_ = new Cursor(null, DWT.CURSOR_SIZEALL); + SIZENESW_ = new Cursor(null, DWT.CURSOR_SIZENESW); + SIZENWSE_ = new Cursor(null, DWT.CURSOR_SIZENWSE); + UPARROW_ = new Cursor(null, DWT.CURSOR_UPARROW); + WAIT_ = new Cursor(null, DWT.CURSOR_WAIT); + initStaticCtor_done = true; + } + } } }
--- a/dwtx/draw2d/FrameBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/FrameBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -36,23 +36,28 @@ * The border scheme that determines the border highlight and shadow colors, as well as * the border width (3). */ -protected static const SchemeBorder.Scheme - SCHEME_FRAME; -static this(){ - SCHEME_FRAME = new SchemeBorder.Scheme( - [ +private static SchemeBorder.Scheme SCHEME_FRAME_; +protected static SchemeBorder.Scheme SCHEME_FRAME(){ + if( SCHEME_FRAME_ is null ){ + synchronized( FrameBorder.classinfo ){ + if( SCHEME_FRAME_ is null ){ + SCHEME_FRAME_ = new SchemeBorder.Scheme( + [ ColorConstants.button, ColorConstants.buttonLightest, ColorConstants.button - ], - [ + ], + [ ColorConstants.buttonDarkest, ColorConstants.buttonDarker, ColorConstants.button - ] - ); + ] + ); + } + } + } + return SCHEME_FRAME_; } - private void instanceInit(){ createBorders(); }
--- a/dwtx/draw2d/IFigure.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/IFigure.d Sun Aug 03 17:01:51 2008 +0200 @@ -58,25 +58,43 @@ } } -static this(){ - IFigure_MAX_DIMENSION = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); - IFigure_MIN_DIMENSION = new Dimension(5, 5); - IFigure_NO_INSETS = new NoInsets(); +private static bool initStaticCtor_done = false; +private static void initStaticCtor (){ + synchronized( IFigure.classinfo ){ + if( !initStaticCtor_done ){ + IFigure_MAX_DIMENSION_ = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); + IFigure_MIN_DIMENSION_ = new Dimension(5, 5); + IFigure_NO_INSETS_ = new NoInsets(); + initStaticCtor_done = true; + } + } } /** * The maximum allowable dimension. ({@link Integer#MAX_VALUE},{@link Integer#MAX_VALUE}) */ -static const Dimension IFigure_MAX_DIMENSION; +private static Dimension IFigure_MAX_DIMENSION_; +static Dimension IFigure_MAX_DIMENSION(){ + if( !initStaticCtor_done ) initStaticCtor(); + return IFigure_MAX_DIMENSION_; +} /** * The minimum allowable dimension. (5,5) */ -static const Dimension IFigure_MIN_DIMENSION; +private static Dimension IFigure_MIN_DIMENSION_; +static Dimension IFigure_MIN_DIMENSION(){ + if( !initStaticCtor_done ) initStaticCtor(); + return IFigure_MIN_DIMENSION_; +} /** * Empty Insets. */ -static const Insets IFigure_NO_INSETS; +private static Insets IFigure_NO_INSETS_; +static Insets IFigure_NO_INSETS(){ + if( !initStaticCtor_done ) initStaticCtor(); + return IFigure_NO_INSETS_; +} /**
--- a/dwtx/draw2d/LayoutAnimator.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/LayoutAnimator.d Sun Aug 03 17:01:51 2008 +0200 @@ -42,11 +42,19 @@ */ public class LayoutAnimator : Animator , LayoutListener { -static const LayoutAnimator INSTANCE; +private static LayoutAnimator INSTANCE_; +static LayoutAnimator INSTANCE(){ + if( INSTANCE_ is null ){ + synchronized( LayoutAnimator.classinfo ){ + if( INSTANCE_ is null ){ + INSTANCE_ = new LayoutAnimator(); + } + } + } + assert(INSTANCE_); + return INSTANCE_; +} -static this(){ - INSTANCE = new LayoutAnimator(); -} /** * Constructs a new Animator. The default instance ({@link #getDefault()}) can be used on * all figures being animated.
--- a/dwtx/draw2d/ManhattanConnectionRouter.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/ManhattanConnectionRouter.d Sun Aug 03 17:01:51 2008 +0200 @@ -46,15 +46,42 @@ } } -private static Ray UP, DOWN, LEFT, RIGHT; +private static Ray UP_, DOWN_, LEFT_, RIGHT_; +private static Ray UP(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(UP_); + return UP_; +} +private static Ray DOWN(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(DOWN_); + return DOWN_; +} +private static Ray LEFT(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(LEFT_); + return LEFT_; +} +private static Ray RIGHT(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(RIGHT_); + return RIGHT_; +} + +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( ManhattanConnectionRouter.classinfo ){ + if( !initStaticCtor_done ){ + UP_ = new Ray(0, -1); + DOWN_ = new Ray(0, 1); + LEFT_ = new Ray(-1, 0); + RIGHT_ = new Ray(1, 0); + initStaticCtor_done = true; + } + } +} -static this(){ - UP = new Ray(0, -1); - DOWN = new Ray(0, 1); - LEFT = new Ray(-1, 0); - RIGHT = new Ray(1, 0); -} public this(){ rowsUsed = new HashMap();
--- a/dwtx/draw2d/PolygonDecoration.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/PolygonDecoration.d Sun Aug 03 17:01:51 2008 +0200 @@ -33,20 +33,36 @@ { /** Template for a triangle that points to the right when the rotation angle is 0 */ -public static const PointList TRIANGLE_TIP; +private static bool initStaticConsts_done = false; +private static PointList TRIANGLE_TIP_; /** Template for a triangle that points to the left when the rotation angle is 0 */ -public static const PointList INVERTED_TRIANGLE_TIP; +private static PointList INVERTED_TRIANGLE_TIP_; + +public static PointList TRIANGLE_TIP(){ + if( !initStaticConsts_done ) initStaticConsts(); + return TRIANGLE_TIP_; +} +public static PointList INVERTED_TRIANGLE_TIP(){ + if( !initStaticConsts_done ) initStaticConsts(); + return INVERTED_TRIANGLE_TIP_; +} -static this() { - TRIANGLE_TIP = new PointList(); - INVERTED_TRIANGLE_TIP = new PointList(); - TRIANGLE_TIP.addPoint(0, 0); - TRIANGLE_TIP.addPoint(-1, 1); - TRIANGLE_TIP.addPoint(-1, -1); +private static void initStaticConsts() { + synchronized( PolygonDecoration.classinfo ){ + if( !initStaticConsts_done ){ + TRIANGLE_TIP_ = new PointList(); + TRIANGLE_TIP_.addPoint(0, 0); + TRIANGLE_TIP_.addPoint(-1, 1); + TRIANGLE_TIP_.addPoint(-1, -1); - INVERTED_TRIANGLE_TIP.addPoint(0, 1); - INVERTED_TRIANGLE_TIP.addPoint(0, -1); - INVERTED_TRIANGLE_TIP.addPoint(-1, 0); + INVERTED_TRIANGLE_TIP_ = new PointList(); + INVERTED_TRIANGLE_TIP_.addPoint(0, 1); + INVERTED_TRIANGLE_TIP_.addPoint(0, -1); + INVERTED_TRIANGLE_TIP_.addPoint(-1, 0); + + initStaticConsts_done = true; + } + } } private Point location;
--- a/dwtx/draw2d/Polyline.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/Polyline.d Sun Aug 03 17:01:51 2008 +0200 @@ -38,11 +38,18 @@ PointList points; private int tolerance = 2; -private static const Rectangle LINEBOUNDS; -static this(){ - LINEBOUNDS = Rectangle.SINGLETON; - assert( LINEBOUNDS !is null ); +private static Rectangle LINEBOUNDS_; +private static Rectangle LINEBOUNDS(){ + if( LINEBOUNDS_ is null ){ + synchronized( Polyline.classinfo ){ + if( LINEBOUNDS_ is null ){ + LINEBOUNDS_ = Rectangle.SINGLETON; + assert( LINEBOUNDS !is null ); + } + } + } + return LINEBOUNDS_; } this(){
--- a/dwtx/draw2d/PolylineDecoration.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/PolylineDecoration.d Sun Aug 03 17:01:51 2008 +0200 @@ -31,13 +31,20 @@ { /** A triangle template_ */ -public static const PointList TRIANGLE_TIP; - -static this() { - TRIANGLE_TIP = new PointList(); - TRIANGLE_TIP.addPoint(-1, 1); - TRIANGLE_TIP.addPoint(0, 0); - TRIANGLE_TIP.addPoint(-1, -1); +private static PointList TRIANGLE_TIP_; +public static PointList TRIANGLE_TIP(){ + if( TRIANGLE_TIP_ is null ){ + synchronized( PolylineDecoration.classinfo ){ + if( TRIANGLE_TIP_ is null ){ + PointList tmp = new PointList(); + tmp.addPoint(-1, 1); + tmp.addPoint(0, 0); + tmp.addPoint(-1, -1); + TRIANGLE_TIP_ = tmp; + } + } + } + return TRIANGLE_TIP_; } private Point location;
--- a/dwtx/draw2d/RoutingAnimator.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/RoutingAnimator.d Sun Aug 03 17:01:51 2008 +0200 @@ -37,10 +37,18 @@ */ public class RoutingAnimator : Animator , RoutingListener { -static const RoutingAnimator INSTANCE; -static this(){ - INSTANCE = new RoutingAnimator(); +private static RoutingAnimator INSTANCE_; +static RoutingAnimator INSTANCE(){ + if( INSTANCE_ is null ){ + synchronized( RoutingAnimator.classinfo ){ + if( INSTANCE_ is null ){ + INSTANCE_ = new RoutingAnimator(); + } + } + } + return INSTANCE_; } + /** * Constructs a routing animator for use with one or more connections. The default * instance ({@link #getDefault()} can be used on any number of connections.
--- a/dwtx/draw2d/SWTGraphics.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/SWTGraphics.d Sun Aug 03 17:01:51 2008 +0200 @@ -211,55 +211,31 @@ } } -static const int AA_MASK; -static const int AA_SHIFT; +static const int AA_MASK = 3 << AA_SHIFT; +static const int AA_SHIFT = 8; static const int AA_WHOLE_NUMBER = 1; -static const int ADVANCED_GRAPHICS_MASK; -static const int ADVANCED_HINTS_DEFAULTS; -static const int ADVANCED_HINTS_MASK; -static const int ADVANCED_SHIFT; -static const int CAP_MASK; -static const int CAP_SHIFT; -static const int FILL_RULE_MASK; -static const int FILL_RULE_SHIFT; -static const int FILL_RULE_WHOLE_NUMBER = -1; -static const int INTERPOLATION_MASK; -static const int INTERPOLATION_SHIFT; -static const int INTERPOLATION_WHOLE_NUMBER = 1; -static const int JOIN_MASK; -static const int JOIN_SHIFT; -static const int LINE_STYLE_MASK; - -static const int TEXT_AA_MASK; -static const int TEXT_AA_SHIFT; -static const int XOR_MASK; -static const int XOR_SHIFT; - -static this() { - XOR_SHIFT = 3; - CAP_SHIFT = 4; - JOIN_SHIFT = 6; - AA_SHIFT = 8; - TEXT_AA_SHIFT = 10; - INTERPOLATION_SHIFT = 12; - FILL_RULE_SHIFT = 14; - ADVANCED_SHIFT = 15; - - LINE_STYLE_MASK = 7; - AA_MASK = 3 << AA_SHIFT; - CAP_MASK = 3 << CAP_SHIFT; - FILL_RULE_MASK = 1 << FILL_RULE_SHIFT; - INTERPOLATION_MASK = 3 << INTERPOLATION_SHIFT; - JOIN_MASK = 3 << JOIN_SHIFT; - TEXT_AA_MASK = 3 << TEXT_AA_SHIFT; - XOR_MASK = 1 << XOR_SHIFT; - ADVANCED_GRAPHICS_MASK = 1 << ADVANCED_SHIFT; - - ADVANCED_HINTS_MASK = TEXT_AA_MASK | AA_MASK | INTERPOLATION_MASK; - ADVANCED_HINTS_DEFAULTS = ((DWT.DEFAULT + AA_WHOLE_NUMBER) << TEXT_AA_SHIFT) +static const int ADVANCED_GRAPHICS_MASK = 1 << ADVANCED_SHIFT; +static const int ADVANCED_HINTS_DEFAULTS = ((DWT.DEFAULT + AA_WHOLE_NUMBER) << TEXT_AA_SHIFT) | ((DWT.DEFAULT + AA_WHOLE_NUMBER) << AA_SHIFT) | ((DWT.DEFAULT + INTERPOLATION_WHOLE_NUMBER) << INTERPOLATION_SHIFT); -} +static const int ADVANCED_HINTS_MASK = TEXT_AA_MASK | AA_MASK | INTERPOLATION_MASK; +static const int ADVANCED_SHIFT = 15; +static const int CAP_MASK = 3 << CAP_SHIFT; +static const int CAP_SHIFT = 4; +static const int FILL_RULE_MASK = 1 << FILL_RULE_SHIFT; +static const int FILL_RULE_SHIFT = 14; +static const int FILL_RULE_WHOLE_NUMBER = -1; +static const int INTERPOLATION_MASK = 3 << INTERPOLATION_SHIFT; +static const int INTERPOLATION_SHIFT = 12; +static const int INTERPOLATION_WHOLE_NUMBER = 1; +static const int JOIN_MASK = 3 << JOIN_SHIFT; +static const int JOIN_SHIFT = 6; +static const int LINE_STYLE_MASK = 7; + +static const int TEXT_AA_MASK = 3 << TEXT_AA_SHIFT; +static const int TEXT_AA_SHIFT = 10; +static const int XOR_MASK = 1 << XOR_SHIFT; +static const int XOR_SHIFT = 3; private const LazyState appliedState; private const State currentState;
--- a/dwtx/draw2d/ScaledGraphics.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/ScaledGraphics.d Sun Aug 03 17:01:51 2008 +0200 @@ -122,23 +122,21 @@ } } -private static int[][] intArrayCache; -private final Rectangle tempRECT; - -static this(){ - intArrayCache = new int[][](8); - for (int i = 0; i < intArrayCache.length; i++) - intArrayCache[i] = new int[i + 1]; +private static int[][] intArrayCache_; +private static int[][] intArrayCache(){ + if( intArrayCache_ is null ){ + synchronized( ScaledGraphics.classinfo ){ + if( intArrayCache_ is null ){ + intArrayCache_ = new int[][](8); + for (int i = 0; i < intArrayCache_.length; i++) + intArrayCache_[i] = new int[i + 1]; + } + } + } + return intArrayCache_; } -private void instanceInit(){ - tempRECT = new Rectangle(); - localCache = new FontHeightCache(); - targetCache = new FontHeightCache(); - stack = new ArrayList(); - fontKey = new FontKey(); - fontDataCache = new HashMap(); - fontCache = new HashMap(); -} +private const Rectangle tempRECT; + private bool allowText = true; //private static final Point PT = new Point(); private Map fontCache; @@ -161,7 +159,15 @@ * @param g the base graphics object */ public this(Graphics g) { - instanceInit(); + // instance init + tempRECT = new Rectangle(); + localCache = new FontHeightCache(); + targetCache = new FontHeightCache(); + stack = new ArrayList(); + fontKey = new FontKey(); + fontDataCache = new HashMap(); + fontCache = new HashMap(); + graphics = g; localFont = g.getFont(); localLineWidth = g.getLineWidth();
--- a/dwtx/draw2d/SchemeBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/SchemeBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -40,15 +40,35 @@ protected Scheme scheme = null; /** Arrays of Colors, used for shadow or highlight effects **/ -protected static const Color[] - DARKEST_DARKER, - LIGHTER_DARKER, - DARKER_LIGHTER; +private static bool initStaticConsts_done = false; +private static Color[] + DARKEST_DARKER_, + LIGHTER_DARKER_, + DARKER_LIGHTER_; -static this(){ - DARKEST_DARKER = [ColorConstants.buttonDarkest, ColorConstants.buttonDarker]; - LIGHTER_DARKER = [ColorConstants.buttonLightest, ColorConstants.buttonDarker]; - DARKER_LIGHTER = [ColorConstants.buttonDarker, ColorConstants.buttonLightest]; +protected static Color[] DARKEST_DARKER(){ + if( !initStaticConsts_done ) initStaticConsts(); + return DARKEST_DARKER_; +} +protected static Color[] LIGHTER_DARKER(){ + if( !initStaticConsts_done ) initStaticConsts(); + return LIGHTER_DARKER_; +} +protected static Color[] DARKER_LIGHTER(){ + if( !initStaticConsts_done ) initStaticConsts(); + return DARKER_LIGHTER_; +} + + +static void initStaticConsts(){ + synchronized( SchemeBorder.classinfo ){ + if( !initStaticConsts_done ) { + DARKEST_DARKER_ = [ColorConstants.buttonDarkest, ColorConstants.buttonDarker]; + LIGHTER_DARKER_ = [ColorConstants.buttonLightest, ColorConstants.buttonDarker]; + DARKER_LIGHTER_ = [ColorConstants.buttonDarker, ColorConstants.buttonLightest]; + initStaticConsts_done = true; + } + } } /** @@ -193,39 +213,76 @@ public struct SCHEMES { /** Schemes used for shadow and highlight effects **/ - public static Scheme - BUTTON_CONTRAST, - BUTTON_RAISED, - BUTTON_PRESSED, - RAISED, - LOWERED, - RIDGED, - ETCHED; + private static bool initStaticConsts_done = false; + private static Scheme + BUTTON_CONTRAST_, + BUTTON_RAISED_, + BUTTON_PRESSED_, + RAISED_, + LOWERED_, + RIDGED_, + ETCHED_; - static this(){ - BUTTON_CONTRAST = new Scheme( - [ColorConstants.button, ColorConstants.buttonLightest], - DARKEST_DARKER - ); - BUTTON_RAISED = new Scheme( - [ColorConstants.buttonLightest], - DARKEST_DARKER - ); - BUTTON_PRESSED = new Scheme( - DARKEST_DARKER, - [ColorConstants.buttonLightest] - ); - RAISED = new Scheme( - [ColorConstants.buttonLightest], - [ColorConstants.buttonDarkest] - ); - LOWERED = new Scheme( - [ColorConstants.buttonDarkest], - [ColorConstants.buttonLightest] - ); - RIDGED = new Scheme(LIGHTER_DARKER, DARKER_LIGHTER); - ETCHED = new Scheme(DARKER_LIGHTER, LIGHTER_DARKER); + public static Scheme BUTTON_CONTRAST(){ + if( !initStaticConsts_done ) initStaticConsts(); + return BUTTON_CONTRAST_; + } + public static Scheme BUTTON_RAISED(){ + if( !initStaticConsts_done ) initStaticConsts(); + return BUTTON_RAISED_; + } + public static Scheme BUTTON_PRESSED(){ + if( !initStaticConsts_done ) initStaticConsts(); + return BUTTON_PRESSED_; + } + public static Scheme RAISED(){ + if( !initStaticConsts_done ) initStaticConsts(); + return RAISED_; + } + public static Scheme LOWERED(){ + if( !initStaticConsts_done ) initStaticConsts(); + return LOWERED_; + } + public static Scheme RIDGED(){ + if( !initStaticConsts_done ) initStaticConsts(); + return RIDGED_; + } + public static Scheme ETCHED(){ + if( !initStaticConsts_done ) initStaticConsts(); + return ETCHED_; } + + + static void initStaticConsts(){ + synchronized( SchemeBorder.classinfo ){ + if( !initStaticConsts_done ) { + BUTTON_CONTRAST_ = new Scheme( + [ColorConstants.button, ColorConstants.buttonLightest], + DARKEST_DARKER + ); + BUTTON_RAISED_ = new Scheme( + [ColorConstants.buttonLightest], + DARKEST_DARKER + ); + BUTTON_PRESSED_ = new Scheme( + DARKEST_DARKER, + [ColorConstants.buttonLightest] + ); + RAISED_ = new Scheme( + [ColorConstants.buttonLightest], + [ColorConstants.buttonDarkest] + ); + LOWERED_ = new Scheme( + [ColorConstants.buttonDarkest], + [ColorConstants.buttonLightest] + ); + RIDGED_ = new Scheme(LIGHTER_DARKER, DARKER_LIGHTER); + ETCHED_ = new Scheme(DARKER_LIGHTER, LIGHTER_DARKER); + initStaticConsts_done = true; + } + } + } + } /**
--- a/dwtx/draw2d/ScrollBar.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/ScrollBar.d Sun Aug 03 17:01:51 2008 +0200 @@ -59,11 +59,18 @@ /** @see Figure#MAX_FLAG */ protected static const int MAX_FLAG = ORIENTATION_FLAG; -private static const Color COLOR_TRACK; -static this(){ - COLOR_TRACK = FigureUtilities.mixColors( - ColorConstants.white, - ColorConstants.button); +private static Color COLOR_TRACK_; +private static Color COLOR_TRACK(){ + if( COLOR_TRACK_ is null ){ + synchronized( ScrollBar.classinfo ){ + if( COLOR_TRACK_ is null ){ + COLOR_TRACK_ = FigureUtilities.mixColors( + ColorConstants.white, + ColorConstants.button); + } + } + } + return COLOR_TRACK_; } private RangeModel rangeModel = null;
--- a/dwtx/draw2d/SimpleEtchedBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/SimpleEtchedBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -30,15 +30,36 @@ { /** The singleton instance of this class */ -public static const Border singleton; +private static Border singleton_; /** The insets */ -protected static const Insets INSETS; +private static Insets INSETS_; + +public static Border singleton(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(singleton_); + return singleton_; +} +protected static Insets INSETS(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(INSETS_); + return INSETS_; +} -static this(){ - singleton = new SimpleEtchedBorder(); - INSETS = new Insets(2); +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( SimpleEtchedBorder.classinfo ){ + if( !initStaticCtor_done ){ + singleton_ = new SimpleEtchedBorder(); + INSETS_ = new Insets(2); + initStaticCtor_done = true; + } + } } + + + + /** * Constructs a default border having a two pixel wide border. *
--- a/dwtx/draw2d/SimpleLoweredBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/SimpleLoweredBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -25,13 +25,26 @@ : SchemeBorder { -private static const Scheme DOUBLE; +private static Scheme DOUBLE_; +private static Scheme DOUBLE(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(DOUBLE_); + return DOUBLE_; +} -static this(){ - DOUBLE = new Scheme( - [ColorConstants.buttonDarkest, ColorConstants.buttonDarker], - [ColorConstants.buttonLightest, ColorConstants.button] ); +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( SimpleLoweredBorder.classinfo ){ + if( !initStaticCtor_done ){ + DOUBLE_ = new Scheme( + [ColorConstants.buttonDarkest, ColorConstants.buttonDarker], + [ColorConstants.buttonLightest, ColorConstants.button] ); + initStaticCtor_done = true; + } + } } + + /** * Constructs a SimpleLoweredBorder with the predefined button-pressed Scheme set as * default.
--- a/dwtx/draw2d/SimpleRaisedBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/SimpleRaisedBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -25,14 +25,27 @@ : SchemeBorder { -private static const Scheme DOUBLE; -static this(){ - DOUBLE = new Scheme( - [ColorConstants.buttonLightest, ColorConstants.button], - [ColorConstants.buttonDarkest, ColorConstants.buttonDarker] - ); +private static Scheme DOUBLE_; +private static Scheme DOUBLE(){ + if( !initStaticCtor_done ) initStaticCtor(); + assert(DOUBLE_); + return DOUBLE_; } +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( SimpleRaisedBorder.classinfo ){ + if( !initStaticCtor_done ){ + DOUBLE_ = new Scheme( + [ColorConstants.buttonLightest, ColorConstants.button], + [ColorConstants.buttonDarkest, ColorConstants.buttonDarker] + ); + initStaticCtor_done = true; + } + } +} + + /** * Constructs a SimpleRaisedBorder with the predefined {@link SchemeBorder.SCHEMES#BUTTON_RAISED} * Scheme set as default.
--- a/dwtx/draw2d/TitleBarBorder.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/TitleBarBorder.d Sun Aug 03 17:01:51 2008 +0200 @@ -36,16 +36,22 @@ : AbstractLabeledBorder { -private static Color defaultColor; +private static Color defaultColor_; +private static Color defaultColor(){ + if( defaultColor_ is null ){ + synchronized( TitleBarBorder.classinfo ){ + if( defaultColor_ is null ){ + defaultColor_ = ColorConstants.menuBackgroundSelected; + } + } + } + return defaultColor_; +} private int textAlignment; private Insets padding; private Color fillColor; -static this(){ - defaultColor = ColorConstants.menuBackgroundSelected; -} - /** * Constructs a TitleBarBorder with its label set to the name of this class. *
--- a/dwtx/draw2d/graph/Path.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/graph/Path.d Sun Aug 03 17:01:51 2008 +0200 @@ -52,14 +52,24 @@ } -private static const Point CURRENT; +private static bool initStaticCtor_done = false; +private static Point CURRENT; private static const double EPSILON = 1.04; -private static const Point NEXT; +private static Point NEXT; private static const double OVAL_CONSTANT = 1.13; -static this(){ - CURRENT = new Point(); - NEXT = new Point(); +private static void initStaticCtor(){ + if( !initStaticCtor_done ){ + synchronized( Path.classinfo ){ + if( !initStaticCtor_done ){ + CURRENT = new Point(); + NEXT = new Point(); + initStaticCtor_done = true; + } + } + } + assert( CURRENT ); + assert( NEXT ); } /** @@ -101,6 +111,7 @@ * @since 3.0 */ public this() { + initStaticCtor(); segments = new ArrayList(); grownSegments = new ArrayList(); points = new PointList();
--- a/dwtx/draw2d/graph/Subgraph.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/graph/Subgraph.d Sun Aug 03 17:01:51 2008 +0200 @@ -65,10 +65,19 @@ */ public Insets innerPadding; -private static const Insets NO_INSETS; -static this(){ - NO_INSETS = new Insets(); +private static Insets NO_INSETS_; +private static Insets NO_INSETS(){ + if( NO_INSETS_ is null ){ + synchronized( Subgraph.classinfo ){ + if( NO_INSETS_ is null ){ + NO_INSETS_ = new Insets(); + } + } + } + assert( NO_INSETS_ ); + return NO_INSETS_; } + /** * Constructs a new subgraph with the given data object. * @see Node#Node(Object)
--- a/dwtx/draw2d/text/BidiProcessor.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/text/BidiProcessor.d Sun Aug 03 17:01:51 2008 +0200 @@ -42,10 +42,8 @@ * $TODO Workaround for Carbon. AWT DLL cannot start properly on carbon. * Waiting for bug 82104 */ -private static const bool isMacOS; -static this(){ - isMacOS = DWT.getPlatform().equals("carbon"); //$NON-NLS-1$ - INSTANCE = new BidiProcessor(); +private static bool isMacOS(){ + return DWT.getPlatform().equals("carbon"); //$NON-NLS-1$ } /** @@ -67,7 +65,18 @@ /** * A singleton instance. */ -public static const BidiProcessor INSTANCE; +private static BidiProcessor INSTANCE_; +public static BidiProcessor INSTANCE(){ + if( INSTANCE_ is null ){ + synchronized( BidiProcessor.classinfo ){ + if( INSTANCE_ is null ){ + INSTANCE_ = new BidiProcessor(); + } + } + } + return INSTANCE_; +} + private StringBuffer bidiText; private List list; private int orientation = DWT.LEFT_TO_RIGHT;
--- a/dwtx/draw2d/text/FlowUtilities.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/text/FlowUtilities.d Sun Aug 03 17:01:51 2008 +0200 @@ -46,17 +46,48 @@ /** * a singleton default instance */ -public static FlowUtilities INSTANCE; +private static FlowUtilities INSTANCE_; +public static FlowUtilities INSTANCE(){ + if( INSTANCE_ is null ){ + synchronized( FlowUtilities.classinfo ){ + if( INSTANCE_ is null ){ + INSTANCE_ = new FlowUtilities(); + } + } + } + return INSTANCE_; +} + + -private static const UBreakIterator INTERNAL_LINE_BREAK; +private static bool INTERNAL_LINE_BREAK_initialized = false; +private static UBreakIterator INTERNAL_LINE_BREAK_; +private static UBreakIterator INTERNAL_LINE_BREAK(){ + if( !INTERNAL_LINE_BREAK_initialized ){ + synchronized( FlowUtilities.classinfo ){ + if( !INTERNAL_LINE_BREAK_initialized ){ + INTERNAL_LINE_BREAK_ = UBreakIterator.openLineIterator( ULocale.Default ); + } + INTERNAL_LINE_BREAK_initialized = true; + } + } + return INTERNAL_LINE_BREAK_; +} + private static TextLayout layout; -static const UBreakIterator LINE_BREAK; - -static this(){ - INSTANCE = new FlowUtilities(); - INTERNAL_LINE_BREAK = UBreakIterator.openLineIterator( ULocale.Default ); - LINE_BREAK = UBreakIterator.openLineIterator( ULocale.Default ); +private static bool LINE_BREAK_initialized = false; +private static UBreakIterator LINE_BREAK_; +static UBreakIterator LINE_BREAK(){ + if( !LINE_BREAK_initialized ){ + synchronized( FlowUtilities.classinfo ){ + if( !LINE_BREAK_initialized ){ + LINE_BREAK_ = UBreakIterator.openLineIterator( ULocale.Default ); + } + LINE_BREAK_initialized = true; + } + } + return LINE_BREAK_; } static bool canBreakAfter(dchar c) {
--- a/dwtx/draw2d/widgets/MultiLineLabel.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/widgets/MultiLineLabel.d Sun Aug 03 17:01:51 2008 +0200 @@ -49,12 +49,19 @@ public final class MultiLineLabel : FigureCanvas { private TextFlow textFlow; -static const Border MARGIN; -private Image image; +private static Border MARGIN_; +static Border MARGIN(){ + if( MARGIN_ is null ){ + synchronized( MultiLineLabel.classinfo ){ + if( MARGIN_ is null ){ + MARGIN_ = new MarginBorder(2); + } + } + } + return MARGIN_; +} -static this(){ - MARGIN = new MarginBorder(2); -} +private Image image; class FocusableViewport : Viewport { this() {