Mercurial > projects > dwt-addons
comparison dwtx/draw2d/ScaledGraphics.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 | c3583c6ec027 |
comparison
equal
deleted
inserted
replaced
102:0de61c6f08ca | 103:2d6540440fe6 |
---|---|
120 this.font = font; | 120 this.font = font; |
121 this.lineWidth = lineWidth; | 121 this.lineWidth = lineWidth; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 private static int[][] intArrayCache; | 125 private static int[][] intArrayCache_; |
126 private final Rectangle tempRECT; | 126 private static int[][] intArrayCache(){ |
127 | 127 if( intArrayCache_ is null ){ |
128 static this(){ | 128 synchronized( ScaledGraphics.classinfo ){ |
129 intArrayCache = new int[][](8); | 129 if( intArrayCache_ is null ){ |
130 for (int i = 0; i < intArrayCache.length; i++) | 130 intArrayCache_ = new int[][](8); |
131 intArrayCache[i] = new int[i + 1]; | 131 for (int i = 0; i < intArrayCache_.length; i++) |
132 } | 132 intArrayCache_[i] = new int[i + 1]; |
133 private void instanceInit(){ | 133 } |
134 tempRECT = new Rectangle(); | 134 } |
135 localCache = new FontHeightCache(); | 135 } |
136 targetCache = new FontHeightCache(); | 136 return intArrayCache_; |
137 stack = new ArrayList(); | 137 } |
138 fontKey = new FontKey(); | 138 private const Rectangle tempRECT; |
139 fontDataCache = new HashMap(); | 139 |
140 fontCache = new HashMap(); | |
141 } | |
142 private bool allowText = true; | 140 private bool allowText = true; |
143 //private static final Point PT = new Point(); | 141 //private static final Point PT = new Point(); |
144 private Map fontCache; | 142 private Map fontCache; |
145 private Map fontDataCache; | 143 private Map fontDataCache; |
146 private FontKey fontKey; | 144 private FontKey fontKey; |
159 /** | 157 /** |
160 * Constructs a new ScaledGraphics based on the given Graphics object. | 158 * Constructs a new ScaledGraphics based on the given Graphics object. |
161 * @param g the base graphics object | 159 * @param g the base graphics object |
162 */ | 160 */ |
163 public this(Graphics g) { | 161 public this(Graphics g) { |
164 instanceInit(); | 162 // instance init |
163 tempRECT = new Rectangle(); | |
164 localCache = new FontHeightCache(); | |
165 targetCache = new FontHeightCache(); | |
166 stack = new ArrayList(); | |
167 fontKey = new FontKey(); | |
168 fontDataCache = new HashMap(); | |
169 fontCache = new HashMap(); | |
170 | |
165 graphics = g; | 171 graphics = g; |
166 localFont = g.getFont(); | 172 localFont = g.getFont(); |
167 localLineWidth = g.getLineWidth(); | 173 localLineWidth = g.getLineWidth(); |
168 } | 174 } |
169 | 175 |