Changeset f893d48fe61df73547fa433cb8114324c3c76a00
- Timestamp:
- 02/25/07 10:55:17
(2 years ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1172397317 +0100
- git-parent:
[b0b7d550cde18a78889e74482730fa3519cf8c2d]
- git-author:
- Christopher Jung <bktheg@web.de> 1172397317 +0100
- Message:
Einie Warnungen gefixt
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re5910b8 |
rf893d48 |
|
| 48 | 48 | */ |
|---|
| 49 | 49 | public class JImageCache implements ImageObserver { |
|---|
| 50 | | private HashMap images; |
|---|
| 51 | | private HashMap imageNotifierList; |
|---|
| 52 | | private HashMap imageNotifierData; |
|---|
| 53 | | private Vector resizeTodo; |
|---|
| | 50 | protected Map<String,BufferedImage> images; |
|---|
| | 51 | protected Map<String,IImageStatusNotifier> imageNotifierList; |
|---|
| | 52 | protected Map<String,Object> imageNotifierData; |
|---|
| | 53 | protected Vector<Vector<Object>> resizeTodo; |
|---|
| 54 | 54 | private String datapath; |
|---|
| 55 | 55 | private final GraphicsConfiguration gc; |
|---|
| 56 | 56 | private BufferedImage unknownImage; |
|---|
| 57 | | private int loadercount; |
|---|
| 58 | | private int resizerCount; |
|---|
| 59 | | private Vector loadTodo; |
|---|
| 60 | | private IWindowManager wm; |
|---|
| | 57 | protected int loadercount; |
|---|
| | 58 | protected int resizerCount; |
|---|
| | 59 | protected Vector<String> loadTodo; |
|---|
| | 60 | protected IWindowManager wm; |
|---|
| 61 | 61 | |
|---|
| 62 | 62 | /** |
|---|
| … | … | |
| 67 | 67 | */ |
|---|
| 68 | 68 | public JImageCache( IWindowManager wm, String datapath ) { |
|---|
| 69 | | images = new HashMap(); |
|---|
| 70 | | imageNotifierList = new HashMap(); |
|---|
| 71 | | imageNotifierData = new HashMap(); |
|---|
| 72 | | loadTodo = new Vector(); |
|---|
| 73 | | resizeTodo = new Vector(); |
|---|
| | 69 | images = new HashMap<String,BufferedImage>(); |
|---|
| | 70 | imageNotifierList = new HashMap<String,IImageStatusNotifier>(); |
|---|
| | 71 | imageNotifierData = new HashMap<String,Object>(); |
|---|
| | 72 | loadTodo = new Vector<String>(); |
|---|
| | 73 | resizeTodo = new Vector<Vector<Object>>(); |
|---|
| 74 | 74 | resizerCount = 0; |
|---|
| 75 | 75 | this.wm = wm; |
|---|
| … | … | |
| 144 | 144 | */ |
|---|
| 145 | 145 | public BufferedImage getImage(final String myfile, boolean forceLoad ) { |
|---|
| 146 | | BufferedImage myimg = (BufferedImage)images.get(myfile); |
|---|
| | 146 | BufferedImage myimg = images.get(myfile); |
|---|
| 147 | 147 | |
|---|
| 148 | 148 | if( (myimg == null) && (myfile.indexOf('#') == -1) ) { |
|---|
| … | … | |
| 165 | 165 | String nextfile; |
|---|
| 166 | 166 | synchronized(loadTodo) { |
|---|
| 167 | | nextfile = (String)loadTodo.firstElement(); |
|---|
| | 167 | nextfile = loadTodo.firstElement(); |
|---|
| 168 | 168 | loadTodo.remove(0); |
|---|
| 169 | 169 | } |
|---|
| … | … | |
| 174 | 174 | if( imageNotifierList.get(nextfile) != null ) { |
|---|
| 175 | 175 | Object data = imageNotifierData.get(nextfile); |
|---|
| 176 | | ((IImageStatusNotifier)imageNotifierList.get(nextfile)).onImageLoaded(nextfile,data); |
|---|
| | 176 | imageNotifierList.get(nextfile).onImageLoaded(nextfile,data); |
|---|
| 177 | 177 | |
|---|
| 178 | 178 | imageNotifierData.remove(nextfile); |
|---|
| … | … | |
| 200 | 200 | String str = "interface/jstarmap/starmap_unknown.png" + myfile.substring(myfile.indexOf('#')); |
|---|
| 201 | 201 | |
|---|
| 202 | | myimg = (BufferedImage)images.get(str); |
|---|
| | 202 | myimg = images.get(str); |
|---|
| 203 | 203 | if( myimg == null ) { |
|---|
| 204 | 204 | myimg = this.unknownImage; |
|---|
| … | … | |
| 249 | 249 | */ |
|---|
| 250 | 250 | public boolean isLoaded( String myfile ) { |
|---|
| 251 | | BufferedImage myimg = (BufferedImage)images.get(myfile); |
|---|
| | 251 | BufferedImage myimg = images.get(myfile); |
|---|
| 252 | 252 | if( myimg == null ) { |
|---|
| 253 | 253 | return false; |
|---|
| 254 | 254 | } |
|---|
| 255 | | else { |
|---|
| 256 | | return true; |
|---|
| 257 | | } |
|---|
| | 255 | return true; |
|---|
| 258 | 256 | } |
|---|
| 259 | 257 | |
|---|
| … | … | |
| 301 | 299 | } |
|---|
| 302 | 300 | |
|---|
| 303 | | Vector todoentry = new Vector(); |
|---|
| | 301 | Vector<Object> todoentry = new Vector<Object>(); |
|---|
| 304 | 302 | todoentry.addElement(image); |
|---|
| 305 | 303 | todoentry.addElement(new Integer(width)); |
|---|
| … | … | |
| 324 | 322 | try { |
|---|
| 325 | 323 | while( !resizeTodo.isEmpty() ) { |
|---|
| 326 | | Vector nextfile; |
|---|
| | 324 | Vector<Object> nextfile; |
|---|
| 327 | 325 | synchronized(resizeTodo) { |
|---|
| 328 | | nextfile = (Vector)resizeTodo.firstElement(); |
|---|
| | 326 | nextfile = resizeTodo.firstElement(); |
|---|
| 329 | 327 | resizeTodo.remove(0); |
|---|
| 330 | 328 | } |
|---|
| … | … | |
| 359 | 357 | } |
|---|
| 360 | 358 | |
|---|
| 361 | | BufferedImage currentImage = (BufferedImage)images.get(filename); |
|---|
| | 359 | BufferedImage currentImage = images.get(filename); |
|---|
| 362 | 360 | |
|---|
| 363 | 361 | BufferedImage sizedImage = createImg( newwidth.intValue(), newheight.intValue(), currentImage.getColorModel().getTransparency() ); |
|---|
| … | … | |
| 392 | 390 | |
|---|
| 393 | 391 | public void dropImages( String filename ) { |
|---|
| 394 | | HashMap cloneMap = (HashMap)images.clone(); |
|---|
| | 392 | Map<String,BufferedImage> cloneMap = new HashMap<String,BufferedImage>(); |
|---|
| | 393 | cloneMap.putAll(images); |
|---|
| 395 | 394 | |
|---|
| 396 | 395 | Iterator itr = cloneMap.keySet().iterator(); |
|---|