Mercurial > projects > dwt-addons
comparison dwtx/ui/internal/forms/widgets/FormImages.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | 7ffeace6c47f |
children |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
19 import dwt.graphics.Image; | 19 import dwt.graphics.Image; |
20 import dwt.graphics.RGB; | 20 import dwt.graphics.RGB; |
21 import dwt.widgets.Display; | 21 import dwt.widgets.Display; |
22 | 22 |
23 import dwt.dwthelper.utils; | 23 import dwt.dwthelper.utils; |
24 import tango.util.collection.HashMap; | 24 import dwtx.dwtxhelper.Collection; |
25 | 25 |
26 public class FormImages { | 26 public class FormImages { |
27 private static FormImages instance; | 27 private static FormImages instance; |
28 | 28 |
29 public static FormImages getInstance() { | 29 public static FormImages getInstance() { |
30 if (instance is null) | 30 if (instance is null) |
31 instance = new FormImages(); | 31 instance = new FormImages(); |
32 return instance; | 32 return instance; |
33 } | 33 } |
34 | 34 |
35 private HashMap!(Object,Object) images; | 35 private HashMap images; |
36 private HashMap!(Object,Object) ids; | 36 private HashMap ids; |
37 | 37 |
38 private this() { | 38 private this() { |
39 } | 39 } |
40 | 40 |
41 private abstract class ImageIdentifier { | 41 private abstract class ImageIdentifier { |
177 if (result !is null && !result.getImage().isDisposed()) { | 177 if (result !is null && !result.getImage().isDisposed()) { |
178 result.incCount(); | 178 result.incCount(); |
179 return result.getImage(); | 179 return result.getImage(); |
180 } | 180 } |
181 Image image = createGradient(display, color1, color2, realtheight, theight, marginHeight); | 181 Image image = createGradient(display, color1, color2, realtheight, theight, marginHeight); |
182 images.add(id, new ImageReference(image)); | 182 images.put(id, new ImageReference(image)); |
183 ids.add(image, id); | 183 ids.put(image, id); |
184 return image; | 184 return image; |
185 } | 185 } |
186 | 186 |
187 public Image getGradient(Display display, Color[] colors, int[] percents, | 187 public Image getGradient(Display display, Color[] colors, int[] percents, |
188 int length, bool vertical, Color bg) { | 188 int length, bool vertical, Color bg) { |
192 if (result !is null && !result.getImage().isDisposed()) { | 192 if (result !is null && !result.getImage().isDisposed()) { |
193 result.incCount(); | 193 result.incCount(); |
194 return result.getImage(); | 194 return result.getImage(); |
195 } | 195 } |
196 Image image = createGradient(display, colors, percents, length, vertical, bg); | 196 Image image = createGradient(display, colors, percents, length, vertical, bg); |
197 images.add(id, new ImageReference(image)); | 197 images.put(id, new ImageReference(image)); |
198 ids.add(image, id); | 198 ids.put(image, id); |
199 return image; | 199 return image; |
200 } | 200 } |
201 | 201 |
202 public bool markFinished(Image image) { | 202 public bool markFinished(Image image) { |
203 checkHashMaps(); | 203 checkHashMaps(); |
219 return false; | 219 return false; |
220 } | 220 } |
221 | 221 |
222 private void checkHashMaps() { | 222 private void checkHashMaps() { |
223 if (images is null) | 223 if (images is null) |
224 images = new HashMap!(Object,Object); | 224 images = new HashMap(); |
225 if (ids is null) | 225 if (ids is null) |
226 ids = new HashMap!(Object,Object); | 226 ids = new HashMap(); |
227 } | 227 } |
228 | 228 |
229 private void validateHashMaps() { | 229 private void validateHashMaps() { |
230 if (images.size() is 0) | 230 if (images.size() is 0) |
231 images = null; | 231 images = null; |