Changeset 2986 in josm
- Timestamp:
- 2010-02-14T19:05:36+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r2759 r2986 47 47 if (Main.main == null || Main.main.getEditLayer() == null) return; 48 48 if (Main.map == null || Main.map.mapView == null) return; 49 Collection<OsmPrimitive> sel = new HashSet<OsmPrimitive>(); 50 sel = Main.main.getEditLayer().data.getSelected(); 49 Collection<OsmPrimitive> sel = Main.main.getEditLayer().data.getSelected(); 51 50 if (sel.isEmpty()) { 52 51 JOptionPane.showMessageDialog( -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r2985 r2986 348 348 if(currentMode.equals(c) || (!drawTargetCursor && currentMode.equals(DeleteMode.none))) 349 349 return; 350 try { 351 // We invoke this to prevent strange things from happening 352 EventQueue.invokeLater(new Runnable() { 353 public void run() { 354 // Don't change cursor when mode has changed already 355 if(!(Main.map.mapMode instanceof DeleteAction)) 356 return; 357 358 Main.map.mapView.setCursor(c.cursor()); 359 //System.out.println("Set cursor to: " + c.name()); 360 } 361 }); 362 currentMode = c; 363 } catch(Exception e) {} 350 // We invoke this to prevent strange things from happening 351 EventQueue.invokeLater(new Runnable() { 352 public void run() { 353 // Don't change cursor when mode has changed already 354 if(!(Main.map.mapMode instanceof DeleteAction)) 355 return; 356 357 Main.map.mapView.setCursor(c.cursor()); 358 //System.out.println("Set cursor to: " + c.name()); 359 } 360 }); 361 currentMode = c; 364 362 } 365 363 -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r2801 r2986 60 60 61 61 public void addChangesetCacheListener(ChangesetCacheListener listener) { 62 synchronized(listeners) { 63 if (listener != null && ! listeners.contains(listener)) { 64 listeners.add(listener); 65 } 66 } 62 listeners.addIfAbsent(listener); 67 63 } 68 64 69 65 public void removeChangesetCacheListener(ChangesetCacheListener listener) { 70 synchronized(listeners) { 71 if (listener != null && listeners.contains(listener)) { 72 listeners.remove(listener); 73 } 74 } 66 listeners.remove(listener); 75 67 } 76 68 -
trunk/src/org/openstreetmap/josm/data/osm/DataSource.java
r2013 r2986 4 4 import org.openstreetmap.josm.data.Bounds; 5 5 6 public class DataSource implements Cloneable{6 public class DataSource { 7 7 public final Bounds bounds; 8 8 public final String origin; … … 11 11 this.bounds = bounds; 12 12 this.origin = origin; 13 if (bounds == null) {13 if (bounds == null) 14 14 throw new NullPointerException(); 15 }16 }17 18 @Override protected Object clone() throws CloneNotSupportedException {19 return new DataSource(bounds, origin);20 15 } 21 16 } -
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 } -
trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
r1610 r2986 7 7 import java.io.FileInputStream; 8 8 import java.io.FileOutputStream; 9 import java.io.IOException; 9 10 import java.util.Date; 10 11 … … 124 125 */ 125 126 public byte[] getData() { 126 if(data == null) 127 if(data == null) { 127 128 loadFromDisk(); 129 } 128 130 return data; 129 131 } … … 146 148 input.read(this.data); 147 149 input.close(); 148 } catch( Exception e) {150 } catch(IOException e) { 149 151 this.data = updateForce(); 150 152 } … … 160 162 output.flush(); 161 163 output.close(); 162 } catch(Exception e) {} 164 } catch(Exception e) { 165 e.printStackTrace(); 166 } 163 167 } 164 168 -
trunk/src/org/openstreetmap/josm/io/CacheFiles.java
r2817 r2986 43 43 44 44 // If the cache is full, we don't want to delete just one file 45 private final int cleanUpThreshold = 20;45 private static final int cleanUpThreshold = 20; 46 46 // We don't want to clean after every file-write 47 private final int cleanUpInterval = 5;47 private static final int cleanUpInterval = 5; 48 48 // Stores how many files have been written 49 49 private int writes = 0; -
trunk/test/functional/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialogTest.java
r2690 r2986 3 3 4 4 import javax.swing.JFrame; 5 6 import org.openstreetmap.josm.fixtures.JOSMFixture;7 5 8 6 public class ChangesetQueryDialogTest extends JFrame { … … 14 12 15 13 public void start() { 16 JOSMFixture fixture = JOSMFixture.createFunctionalTestFixture();17 14 dialog = new ChangesetQueryDialog(this); 18 15 dialog.initForUserInput(); -
trunk/test/functional/org/openstreetmap/josm/io/UploadStrategySelectionPanelTest.java
r2641 r2986 12 12 import javax.swing.JTextField; 13 13 14 import org.openstreetmap.josm.fixtures.JOSMFixture;15 14 import org.openstreetmap.josm.gui.io.UploadStrategySelectionPanel; 16 15 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 56 55 57 56 public static void main(String args[]) throws OsmApiInitializationException, OsmTransferCancelledException{ 58 JOSMFixture josmFixture = JOSMFixture.createFunctionalTestFixture();59 57 OsmApi.getOsmApi().initialize(NullProgressMonitor.INSTANCE); 60 58 new UploadStrategySelectionPanelTest().setVisible(true);
Note:
See TracChangeset
for help on using the changeset viewer.