Mercurial > projects > dwt-addons
comparison dwtx/draw2d/ManhattanConnectionRouter.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 |
---|---|
44 reservedRows = new ArrayList(2); | 44 reservedRows = new ArrayList(2); |
45 reservedCols = new ArrayList(2); | 45 reservedCols = new ArrayList(2); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 private static Ray UP, DOWN, LEFT, RIGHT; | 49 private static Ray UP_, DOWN_, LEFT_, RIGHT_; |
50 | 50 private static Ray UP(){ |
51 | 51 if( !initStaticCtor_done ) initStaticCtor(); |
52 static this(){ | 52 assert(UP_); |
53 UP = new Ray(0, -1); | 53 return UP_; |
54 DOWN = new Ray(0, 1); | 54 } |
55 LEFT = new Ray(-1, 0); | 55 private static Ray DOWN(){ |
56 RIGHT = new Ray(1, 0); | 56 if( !initStaticCtor_done ) initStaticCtor(); |
57 } | 57 assert(DOWN_); |
58 return DOWN_; | |
59 } | |
60 private static Ray LEFT(){ | |
61 if( !initStaticCtor_done ) initStaticCtor(); | |
62 assert(LEFT_); | |
63 return LEFT_; | |
64 } | |
65 private static Ray RIGHT(){ | |
66 if( !initStaticCtor_done ) initStaticCtor(); | |
67 assert(RIGHT_); | |
68 return RIGHT_; | |
69 } | |
70 | |
71 private static bool initStaticCtor_done = false; | |
72 private static void initStaticCtor(){ | |
73 synchronized( ManhattanConnectionRouter.classinfo ){ | |
74 if( !initStaticCtor_done ){ | |
75 UP_ = new Ray(0, -1); | |
76 DOWN_ = new Ray(0, 1); | |
77 LEFT_ = new Ray(-1, 0); | |
78 RIGHT_ = new Ray(1, 0); | |
79 initStaticCtor_done = true; | |
80 } | |
81 } | |
82 } | |
83 | |
84 | |
58 | 85 |
59 public this(){ | 86 public this(){ |
60 rowsUsed = new HashMap(); | 87 rowsUsed = new HashMap(); |
61 colsUsed = new HashMap(); | 88 colsUsed = new HashMap(); |
62 reservedInfo = new HashMap(); | 89 reservedInfo = new HashMap(); |