Changeset 2986 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2010-02-14T19:05:36+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2985 r2986 552 552 DataSet.selListeners.remove(selectionTableModel); 553 553 getLayer().data.removeDataSetListener(memberTableModel); 554 getLayer().listenerDataChanged.remove(memberTableModel);555 554 memberTable.unlinkAsListener(); 556 555 dispose(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
r2621 r2986 44 44 */ 45 45 static private class DialogContext { 46 public Relation relation;47 public OsmDataLayer layer;46 public final Relation relation; 47 public final OsmDataLayer layer; 48 48 49 49 public DialogContext(OsmDataLayer layer, Relation relation) { … … 94 94 95 95 /** the map of open dialogs */ 96 private HashMap<DialogContext, RelationEditor> openDialogs;96 private final HashMap<DialogContext, RelationEditor> openDialogs; 97 97 98 98 /** -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2985 r2986 842 842 OsmDataLayer l = (OsmDataLayer)oldLayer; 843 843 l.data.removeDataSetListener(this); 844 l.listenerDataChanged.remove(this);845 844 } 846 845 if (newLayer == null || ! (newLayer instanceof OsmDataLayer)) { -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r2711 r2986 125 125 selectedRect = null; 126 126 127 if (image == null) { 128 return; 129 } 127 if (image == null) 128 return; 130 129 131 130 // Calculate the mouse cursor position in image coordinates, so that we can center the zoom … … 196 195 } 197 196 198 if (image == null) { 199 return; 200 } 201 202 if (e.getButton() != DRAG_BUTTON) { 203 return; 204 } 197 if (image == null) 198 return; 199 200 if (e.getButton() != DRAG_BUTTON) 201 return; 205 202 206 203 // Calculate the translation to set the clicked point the center of the view. … … 230 227 } 231 228 232 File file;233 229 Image image; 234 230 Rectangle visibleRect; 235 231 236 232 synchronized (ImageDisplay.this) { 237 file = ImageDisplay.this.file;238 233 image = ImageDisplay.this.image; 239 234 visibleRect = ImageDisplay.this.visibleRect; 240 235 } 241 236 242 if (image == null) { 243 return; 244 } 237 if (image == null) 238 return; 245 239 246 240 if (e.getButton() == DRAG_BUTTON) { … … 261 255 262 256 public void mouseDragged(MouseEvent e) { 263 if (! mouseIsDragging && selectedRect == null) { 264 return; 265 } 257 if (! mouseIsDragging && selectedRect == null) 258 return; 266 259 267 260 File file; … … 310 303 311 304 public void mouseReleased(MouseEvent e) { 312 if (! mouseIsDragging && selectedRect == null) { 313 return; 314 } 305 if (! mouseIsDragging && selectedRect == null) 306 return; 315 307 316 308 File file; 317 309 Image image; 318 Rectangle visibleRect;319 310 320 311 synchronized (ImageDisplay.this) { 321 312 file = ImageDisplay.this.file; 322 313 image = ImageDisplay.this.image; 323 visibleRect = ImageDisplay.this.visibleRect;324 314 } 325 315 … … 424 414 } 425 415 416 @Override 426 417 public void paintComponent(Graphics g) { 427 418 Image image; … … 443 434 Dimension size = getSize(); 444 435 g.drawString(noImageStr, 445 446 436 (int) ((size.width - noImageSize.getWidth()) / 2), 437 (int) ((size.height - noImageSize.getHeight()) / 2)); 447 438 } else if (image == null) { 448 439 g.setColor(Color.black); 449 440 String loadingStr; 450 441 if (! errorLoading) {; 451 442 loadingStr = tr("Loading {0}", file.getName()); 452 443 } else { 453 444 loadingStr = tr("Error on file {0}", file.getName()); … … 456 447 Dimension size = getSize(); 457 448 g.drawString(loadingStr, 458 459 449 (int) ((size.width - noImageSize.getWidth()) / 2), 450 (int) ((size.height - noImageSize.getHeight()) / 2)); 460 451 } else { 461 452 Rectangle target = calculateDrawImageRectangle(visibleRect); 462 453 g.drawImage(image, 463 464 465 454 target.x, target.y, target.x + target.width, target.y + target.height, 455 visibleRect.x, visibleRect.y, visibleRect.x + visibleRect.width, visibleRect.y + visibleRect.height, 456 null); 466 457 if (selectedRect != null) { 467 458 Point topLeft = img2compCoord(visibleRect, selectedRect.x, selectedRect.y); 468 459 Point bottomRight = img2compCoord(visibleRect, 469 470 460 selectedRect.x + selectedRect.width, 461 selectedRect.y + selectedRect.height); 471 462 g.setColor(new Color(128, 128, 128, 180)); 472 463 g.fillRect(target.x, target.y, target.width, topLeft.y - target.y); … … 482 473 Dimension size = getSize(); 483 474 g.drawString(loadingStr, 484 485 475 (int) ((size.width - noImageSize.getWidth()) / 2), 476 (int) ((size.height - noImageSize.getHeight()) / 2)); 486 477 } 487 478 if (osdText != null) { … … 519 510 Rectangle drawRect = calculateDrawImageRectangle(visibleRect); 520 511 return new Point(drawRect.x + ((xImg - visibleRect.x) * drawRect.width) / visibleRect.width, 521 512 drawRect.y + ((yImg - visibleRect.y) * drawRect.height) / visibleRect.height); 522 513 } 523 514 … … 525 516 Rectangle drawRect = calculateDrawImageRectangle(visibleRect); 526 517 return new Point(visibleRect.x + ((xComp - drawRect.x) * visibleRect.width) / drawRect.width, 527 528 } 529 530 private final Point getCenterImgCoord(Rectangle visibleRect) {518 visibleRect.y + ((yComp - drawRect.y) * visibleRect.height) / drawRect.height); 519 } 520 521 private final Point getCenterImgCoord(Rectangle visibleRect) { 531 522 return new Point(visibleRect.x + visibleRect.width / 2, 532 523 visibleRect.y + visibleRect.height / 2); 533 524 } 534 525 … … 576 567 } 577 568 578 if (image == null) {569 if (image == null) 579 570 return; 580 }581 571 582 572 if (visibleRect.width != image.getWidth(null) || visibleRect.height != image.getHeight(null)) { … … 588 578 Point center = getCenterImgCoord(visibleRect); 589 579 visibleRect = new Rectangle(center.x - getWidth() / 2, center.y - getHeight() / 2, 590 580 getWidth(), getHeight()); 591 581 checkVisibleRectPos(image, visibleRect); 592 582 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
r2931 r2986 2 2 3 3 package org.openstreetmap.josm.gui.layer.geoimage; 4 5 import static org.openstreetmap.josm.tools.I18n.tr;6 4 7 5 import java.awt.Graphics2D; … … 11 9 import java.awt.Toolkit; 12 10 import java.awt.image.BufferedImage; 13 import java.io.File;14 11 import java.util.ArrayList; 15 12 import java.util.List; 16 13 14 import org.openstreetmap.josm.Main; 17 15 import org.openstreetmap.josm.io.CacheFiles; 18 import org.openstreetmap.josm.Main;19 16 20 17 public class ThumbsLoader implements Runnable { 21 22 23 24 25 26 27 28 18 public static final int maxSize = 120; 19 public static final int minSize = 22; 20 volatile boolean stop = false; 21 List<ImageEntry> data; 22 GeoImageLayer layer; 23 MediaTracker tracker; 24 CacheFiles cache; 25 boolean cacheOff = Main.pref.getBoolean("geoimage.noThumbnailCache", false); 29 26 30 public ThumbsLoader(GeoImageLayer layer) { 31 this.layer = layer; 32 this.data = new ArrayList<ImageEntry>(layer.data); 33 if (!cacheOff) { 34 cache = new CacheFiles("geoimage-thumbnails", false); 35 cache.setExpire(CacheFiles.EXPIRE_NEVER, false); 36 cache.setMaxSize(120, false); 27 public ThumbsLoader(GeoImageLayer layer) { 28 this.layer = layer; 29 this.data = new ArrayList<ImageEntry>(layer.data); 30 if (!cacheOff) { 31 cache = new CacheFiles("geoimage-thumbnails", false); 32 cache.setExpire(CacheFiles.EXPIRE_NEVER, false); 33 cache.setMaxSize(120, false); 34 } 35 } 36 37 public void run() { 38 System.err.println("Load Thumbnails"); 39 tracker = new MediaTracker(Main.map.mapView); 40 for (int i = 0; i < data.size(); i++) { 41 if (stop) return; 42 43 System.err.print("fetching image "+i); 44 45 data.get(i).thumbnail = loadThumb(data.get(i)); 46 47 if (Main.map != null && Main.map.mapView != null) { 48 layer.updateOffscreenBuffer = true; 49 Main.map.mapView.repaint(); 50 } 51 } 52 try { 53 layer.updateOffscreenBuffer = true; 54 } catch (Exception e) {} 55 Main.map.mapView.repaint(); 56 (new Thread() { // clean up the garbage - shouldn't hurt 57 @Override 58 public void run() { 59 try { 60 Thread.sleep(200); 61 } 62 catch (InterruptedException ie) {} 63 System.gc(); 64 } 65 }).start(); 66 67 } 68 69 private BufferedImage loadThumb(ImageEntry entry) { 70 final String cacheIdent = entry.getFile().toString()+":"+maxSize; 71 72 if (!cacheOff) { 73 BufferedImage cached = cache.getImg(cacheIdent); 74 if(cached != null) { 75 System.err.println(" from cache"); 76 return cached; 37 77 } 38 78 } 39 79 40 public void run() { 41 System.err.println("Load Thumbnails"); 42 tracker = new MediaTracker(Main.map.mapView); 43 for (int i = 0; i < data.size(); i++) { 44 if (stop) return; 80 Image img = Toolkit.getDefaultToolkit().createImage(entry.getFile().getPath()); 81 tracker.addImage(img, 0); 82 try { 83 tracker.waitForID(0); 84 } catch (InterruptedException e) { 85 System.err.println(" InterruptedException"); 86 return null; 87 } 88 if (tracker.isErrorID(1) || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) { 89 System.err.println(" Invalid image"); 90 return null; 91 } 92 Rectangle targetSize = ImageDisplay.calculateDrawImageRectangle( 93 new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)), 94 new Rectangle(0, 0, maxSize, maxSize)); 95 BufferedImage scaledBI = new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB); 96 Graphics2D g = scaledBI.createGraphics(); 97 while (!g.drawImage(img, 0, 0, targetSize.width, targetSize.height, null)) 98 { 99 try { 100 Thread.sleep(10); 101 } catch(InterruptedException ie) {} 102 } 103 g.dispose(); 104 tracker.removeImage(img); 45 105 46 System.err.print("fetching image "+i); 47 48 data.get(i).thumbnail = loadThumb(data.get(i)); 49 50 if (Main.map != null && Main.map.mapView != null) { 51 try { 52 layer.updateOffscreenBuffer = true; 53 } catch (Exception e) {} 54 Main.map.mapView.repaint(); 55 } 56 } 57 try { 58 layer.updateOffscreenBuffer = true; 59 } catch (Exception e) {} 60 Main.map.mapView.repaint(); 61 (new Thread() { // clean up the garbage - shouldn't hurt 62 public void run() { 63 try { 64 Thread.sleep(200); 65 } 66 catch (InterruptedException ie) {} 67 System.gc(); 68 } 69 }).start(); 70 106 if (scaledBI.getWidth() <= 0 || scaledBI.getHeight() <= 0) { 107 System.err.println(" Invalid image"); 108 return null; 71 109 } 72 110 73 private BufferedImage loadThumb(ImageEntry entry) { 74 final String cacheIdent = entry.getFile().toString()+":"+maxSize; 75 76 if (!cacheOff) { 77 BufferedImage cached = cache.getImg(cacheIdent); 78 if(cached != null) { 79 System.err.println(" from cache"); 80 return cached; 81 } 82 } 83 84 Image img = Toolkit.getDefaultToolkit().createImage(entry.getFile().getPath()); 85 tracker.addImage(img, 0); 86 try { 87 tracker.waitForID(0); 88 } catch (InterruptedException e) { 89 System.err.println(" InterruptedException"); 90 return null; 91 } 92 if (tracker.isErrorID(1) || img.getWidth(null) <= 0 || img.getHeight(null) <= 0) { 93 System.err.println(" Invalid image"); 94 return null; 95 } 96 Rectangle targetSize = ImageDisplay.calculateDrawImageRectangle( 97 new Rectangle(0, 0, img.getWidth(null), img.getHeight(null)), 98 new Rectangle(0, 0, maxSize, maxSize)); 99 BufferedImage scaledBI = new BufferedImage(targetSize.width, targetSize.height, BufferedImage.TYPE_INT_RGB); 100 Graphics2D g = scaledBI.createGraphics(); 101 while (!g.drawImage(img, 0, 0, targetSize.width, targetSize.height, null)) 102 { 103 try { 104 Thread.sleep(10); 105 } catch(InterruptedException ie) {} 106 } 107 g.dispose(); 108 tracker.removeImage(img); 109 110 if (scaledBI == null || scaledBI.getWidth() <= 0 || scaledBI.getHeight() <= 0) { 111 System.err.println(" Invalid image"); 112 return null; 113 } 114 115 if (!cacheOff) { 116 cache.saveImg(cacheIdent, scaledBI); 117 } 118 119 System.err.println(""); 120 return scaledBI; 111 if (!cacheOff) { 112 cache.saveImg(cacheIdent, scaledBI); 121 113 } 122 114 115 System.err.println(""); 116 return scaledBI; 123 117 } 118 119 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r2817 r2986 39 39 displayedPlugins.clear(); 40 40 displayedPlugins.addAll(availablePlugins); 41 this.filterExpression = filter;41 this.filterExpression = null; 42 42 return; 43 43 }
Note:
See TracChangeset
for help on using the changeset viewer.