Mercurial > projects > dwt-addons
comparison dwtx/draw2d/PolygonDecoration.d @ 103:2d6540440fe6
Replace static ctors with lazy init.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 17:01:51 +0200 |
parents | 95307ad235d9 |
children |
comparison
equal
deleted
inserted
replaced
102:0de61c6f08ca | 103:2d6540440fe6 |
---|---|
31 : Polygon | 31 : Polygon |
32 , RotatableDecoration | 32 , RotatableDecoration |
33 { | 33 { |
34 | 34 |
35 /** Template for a triangle that points to the right when the rotation angle is 0 */ | 35 /** Template for a triangle that points to the right when the rotation angle is 0 */ |
36 public static const PointList TRIANGLE_TIP; | 36 private static bool initStaticConsts_done = false; |
37 private static PointList TRIANGLE_TIP_; | |
37 /** Template for a triangle that points to the left when the rotation angle is 0 */ | 38 /** Template for a triangle that points to the left when the rotation angle is 0 */ |
38 public static const PointList INVERTED_TRIANGLE_TIP; | 39 private static PointList INVERTED_TRIANGLE_TIP_; |
39 | 40 |
40 static this() { | 41 public static PointList TRIANGLE_TIP(){ |
41 TRIANGLE_TIP = new PointList(); | 42 if( !initStaticConsts_done ) initStaticConsts(); |
42 INVERTED_TRIANGLE_TIP = new PointList(); | 43 return TRIANGLE_TIP_; |
43 TRIANGLE_TIP.addPoint(0, 0); | 44 } |
44 TRIANGLE_TIP.addPoint(-1, 1); | 45 public static PointList INVERTED_TRIANGLE_TIP(){ |
45 TRIANGLE_TIP.addPoint(-1, -1); | 46 if( !initStaticConsts_done ) initStaticConsts(); |
47 return INVERTED_TRIANGLE_TIP_; | |
48 } | |
46 | 49 |
47 INVERTED_TRIANGLE_TIP.addPoint(0, 1); | 50 private static void initStaticConsts() { |
48 INVERTED_TRIANGLE_TIP.addPoint(0, -1); | 51 synchronized( PolygonDecoration.classinfo ){ |
49 INVERTED_TRIANGLE_TIP.addPoint(-1, 0); | 52 if( !initStaticConsts_done ){ |
53 TRIANGLE_TIP_ = new PointList(); | |
54 TRIANGLE_TIP_.addPoint(0, 0); | |
55 TRIANGLE_TIP_.addPoint(-1, 1); | |
56 TRIANGLE_TIP_.addPoint(-1, -1); | |
57 | |
58 INVERTED_TRIANGLE_TIP_ = new PointList(); | |
59 INVERTED_TRIANGLE_TIP_.addPoint(0, 1); | |
60 INVERTED_TRIANGLE_TIP_.addPoint(0, -1); | |
61 INVERTED_TRIANGLE_TIP_.addPoint(-1, 0); | |
62 | |
63 initStaticConsts_done = true; | |
64 } | |
65 } | |
50 } | 66 } |
51 | 67 |
52 private Point location; | 68 private Point location; |
53 private PointList template_; | 69 private PointList template_; |
54 private Transform transform; | 70 private Transform transform; |