Changeset 5391 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-08-04T16:33:49+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r5382 r5391 372 372 layer.addPropertyChangeListener(LayerListDialog.getInstance().getModel()); 373 373 } 374 layer.hookUpMapView(); 374 375 map.mapView.addLayer(layer); 375 376 } -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r5358 r5391 1288 1288 } 1289 1289 1290 p rivate<T> Map<String,String> serializeStruct(T struct, Class<T> klass) {1290 public static <T> Map<String,String> serializeStruct(T struct, Class<T> klass) { 1291 1291 T structPrototype; 1292 1292 try { … … 1321 1321 } 1322 1322 1323 p rivate<T> T deserializeStruct(Map<String,String> hash, Class<T> klass) {1323 public static <T> T deserializeStruct(Map<String,String> hash, Class<T> klass) { 1324 1324 T struct = null; 1325 1325 try { -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r5369 r5391 3 3 4 4 import java.awt.Image; 5 import java.util.ArrayList; 5 6 import java.util.Arrays; 6 import java.util.ArrayList;7 7 import java.util.Collection; 8 8 import java.util.Collections; … … 13 13 import javax.swing.ImageIcon; 14 14 15 import org.openstreetmap.gui.jmapviewer.Coordinate; 16 import org.openstreetmap.gui.jmapviewer.interfaces.Attributed; 17 import org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource; 18 import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource.Mapnik; 15 19 import org.openstreetmap.josm.Main; 16 20 import org.openstreetmap.josm.data.Bounds; … … 19 23 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 24 import org.openstreetmap.josm.tools.ImageProvider; 21 import org.openstreetmap.gui.jmapviewer.Coordinate;22 import org.openstreetmap.gui.jmapviewer.interfaces.Attributed;23 import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource.Mapnik;24 import org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource;25 import org.openstreetmap.josm.tools.CheckParameterUtil;26 25 27 26 /** -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r5390 r5391 83 83 icon = new ImageProvider(info.getIcon()).setOptional(true). 84 84 setMaxHeight(ICON_SIZE).setMaxWidth(ICON_SIZE).get(); 85 if (icon == null) {86 icon = ImageProvider.get("imagery_small");87 }85 } 86 if (icon == null) { 87 icon = ImageProvider.get("imagery_small"); 88 88 } 89 89 this.sharpenLevel = PROP_SHARPEN_LEVEL.get(); -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r5390 r5391 126 126 127 127 /** 128 * Initialization code, that depends on Main.map.mapView. 129 * 130 * It is always called in the event dispatching thread. 131 * Note that Main.map is null as long as no layer has been added, so do 132 * not execute code in the constructor, that assumes Main.map.mapView is 133 * not null. Instead override this method. 134 */ 135 public void hookUpMapView() { 136 } 137 138 /** 128 139 * Paint the dataset using the engine set. 129 140 * @param mv The object that can translate GeoPoints to screen coordinates. -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r5357 r5391 38 38 import javax.swing.JOptionPane; 39 39 import javax.swing.JPopupMenu; 40 import javax.swing.SwingUtilities;41 40 42 41 import org.openstreetmap.gui.jmapviewer.AttributionSupport; … … 471 470 throw new IllegalStateException("Cannot create TMSLayer with non-TMS ImageryInfo"); 472 471 initTileSource(source); 473 472 } 473 474 /** 475 * Adds a context menu to the mapView. 476 */ 477 @Override 478 public void hookUpMapView() { 474 479 tileOptionMenu = new JPopupMenu(); 475 480 … … 521 526 @Override 522 527 public void actionPerformed(ActionEvent ae) { 523 //Main.debug("info tile: " + clickedTile);524 528 if (clickedTile != null) { 525 529 showMetadataTile = clickedTile; … … 559 563 560 564 // increase and decrease commands 561 tileOptionMenu.add(new JMenuItem( 562 new AbstractAction(tr("Increase zoom")) { 565 tileOptionMenu.add(new JMenuItem(new AbstractAction( 566 tr("Increase zoom")) { 567 @Override 568 public void actionPerformed(ActionEvent ae) { 569 increaseZoomLevel(); 570 redraw(); 571 } 572 })); 573 574 tileOptionMenu.add(new JMenuItem(new AbstractAction( 575 tr("Decrease zoom")) { 576 @Override 577 public void actionPerformed(ActionEvent ae) { 578 decreaseZoomLevel(); 579 redraw(); 580 } 581 })); 582 583 tileOptionMenu.add(new JMenuItem(new AbstractAction( 584 tr("Snap to tile size")) { 585 @Override 586 public void actionPerformed(ActionEvent ae) { 587 double new_factor = Math.sqrt(getScaleFactor(currentZoomLevel)); 588 Main.map.mapView.zoomToFactor(new_factor); 589 redraw(); 590 } 591 })); 592 593 tileOptionMenu.add(new JMenuItem(new AbstractAction( 594 tr("Flush Tile Cache")) { 595 @Override 596 public void actionPerformed(ActionEvent ae) { 597 new PleaseWaitRunnable(tr("Flush Tile Cache")) { 563 598 @Override 564 p ublic void actionPerformed(ActionEvent ae) {565 increaseZoomLevel();566 redraw();599 protected void realRun() throws SAXException, IOException, 600 OsmTransferException { 601 clearTileCache(getProgressMonitor()); 567 602 } 568 })); 569 570 tileOptionMenu.add(new JMenuItem( 571 new AbstractAction(tr("Decrease zoom")) { 603 572 604 @Override 573 public void actionPerformed(ActionEvent ae) { 574 decreaseZoomLevel(); 575 redraw(); 605 protected void finish() { 576 606 } 577 })); 578 579 // FIXME: currently ran in errors 580 581 tileOptionMenu.add(new JMenuItem( 582 new AbstractAction(tr("Snap to tile size")) { 607 583 608 @Override 584 public void actionPerformed(ActionEvent ae) { 585 double new_factor = Math.sqrt(getScaleFactor(currentZoomLevel)); 586 Main.map.mapView.zoomToFactor(new_factor); 587 redraw(); 609 protected void cancel() { 588 610 } 589 })); 611 }.run(); 612 } 613 })); 590 614 // end of adding menu commands 591 615 592 tileOptionMenu.add(new JMenuItem( 593 new AbstractAction(tr("Flush Tile Cache")) { 594 @Override 595 public void actionPerformed(ActionEvent ae) { 596 new PleaseWaitRunnable(tr("Flush Tile Cache")) { 597 598 @Override 599 protected void realRun() throws SAXException, IOException, 600 OsmTransferException { 601 clearTileCache(getProgressMonitor()); 602 } 603 604 @Override 605 protected void finish() { 606 } 607 608 @Override 609 protected void cancel() { 610 } 611 }.run(); 612 613 } 614 })); 615 // end of adding menu commands 616 617 SwingUtilities.invokeLater(new Runnable() { 618 @Override 619 public void run() { 620 final MouseAdapter adapter = new MouseAdapter() { 621 @Override 622 public void mouseClicked(MouseEvent e) { 623 if (!isVisible()) return; 624 if (e.getButton() == MouseEvent.BUTTON3) { 625 clickedTile = getTileForPixelpos(e.getX(), e.getY()); 626 tileOptionMenu.show(e.getComponent(), e.getX(), e.getY()); 627 } else if (e.getButton() == MouseEvent.BUTTON1) { 628 attribution.handleAttribution(e.getPoint(), true); 629 } 630 } 631 }; 632 Main.map.mapView.addMouseListener(adapter); 633 634 MapView.addLayerChangeListener(new LayerChangeListener() { 635 @Override 636 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 637 // 638 } 639 640 @Override 641 public void layerAdded(Layer newLayer) { 642 // 643 } 644 645 @Override 646 public void layerRemoved(Layer oldLayer) { 647 if (oldLayer == TMSLayer.this) { 648 Main.map.mapView.removeMouseListener(adapter); 649 MapView.removeLayerChangeListener(this); 650 } 651 } 652 }); 616 final MouseAdapter adapter = new MouseAdapter() { 617 @Override 618 public void mouseClicked(MouseEvent e) { 619 if (!isVisible()) return; 620 if (e.getButton() == MouseEvent.BUTTON3) { 621 clickedTile = getTileForPixelpos(e.getX(), e.getY()); 622 tileOptionMenu.show(e.getComponent(), e.getX(), e.getY()); 623 } else if (e.getButton() == MouseEvent.BUTTON1) { 624 attribution.handleAttribution(e.getPoint(), true); 625 } 626 } 627 }; 628 Main.map.mapView.addMouseListener(adapter); 629 630 MapView.addLayerChangeListener(new LayerChangeListener() { 631 @Override 632 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 633 // 634 } 635 636 @Override 637 public void layerAdded(Layer newLayer) { 638 // 639 } 640 641 @Override 642 public void layerRemoved(Layer oldLayer) { 643 if (oldLayer == TMSLayer.this) { 644 Main.map.mapView.removeMouseListener(adapter); 645 MapView.removeLayerChangeListener(this); 646 } 653 647 } 654 648 }); -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r5389 r5391 121 121 protected boolean settingsChanged; 122 122 protected ImageryInfo info; 123 protected finalMapView mv;123 protected MapView mv; 124 124 public WmsCache cache; 125 125 private AttributionSupport attribution = new AttributionSupport(); … … 160 160 super(info); 161 161 imageSize = PROP_IMAGE_SIZE.get(); 162 mv = Main.map.mapView;163 162 setBackgroundLayer(true); /* set global background variable */ 164 163 initializeImages(); 164 this.info = new ImageryInfo(info); 165 166 attribution.initialize(this.info); 167 168 if(info.getUrl() != null) { 169 startGrabberThreads(); 170 } 171 172 Main.pref.addPreferenceChangeListener(this); 173 } 174 175 @Override 176 public void hookUpMapView() { 177 mv = Main.map.mapView; 165 178 if (info.getUrl() != null) { 166 179 for (WMSLayer layer: Main.map.mapView.getLayersOfType(WMSLayer.class)) { … … 175 188 } 176 189 } 177 this.info = new ImageryInfo(info);178 190 if(this.info.getPixelPerDegree() == 0.0) { 179 191 this.info.setPixelPerDegree(getPPD()); … … 181 193 resolution = mv.getDist100PixelText(); 182 194 183 attribution.initialize(this.info); 184 185 if(info.getUrl() != null) { 186 startGrabberThreads(); 187 } 188 189 190 Main.pref.addPreferenceChangeListener(this); 191 192 SwingUtilities.invokeLater(new Runnable() { 195 final MouseAdapter adapter = new MouseAdapter() { 193 196 @Override 194 public void run() { 195 final MouseAdapter adapter = new MouseAdapter() { 196 @Override 197 public void mouseClicked(MouseEvent e) { 198 if (!isVisible()) return; 199 if (e.getButton() == MouseEvent.BUTTON1) { 200 attribution.handleAttribution(e.getPoint(), true); 201 } 202 } 203 }; 204 Main.map.mapView.addMouseListener(adapter); 205 206 MapView.addLayerChangeListener(new LayerChangeListener() { 207 @Override 208 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 209 // 210 } 211 212 @Override 213 public void layerAdded(Layer newLayer) { 214 // 215 } 216 217 @Override 218 public void layerRemoved(Layer oldLayer) { 219 if (oldLayer == WMSLayer.this) { 220 Main.map.mapView.removeMouseListener(adapter); 221 MapView.removeLayerChangeListener(this); 222 } 223 } 224 }); 197 public void mouseClicked(MouseEvent e) { 198 if (!isVisible()) return; 199 if (e.getButton() == MouseEvent.BUTTON1) { 200 attribution.handleAttribution(e.getPoint(), true); 201 } 202 } 203 }; 204 Main.map.mapView.addMouseListener(adapter); 205 206 MapView.addLayerChangeListener(new LayerChangeListener() { 207 @Override 208 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 209 // 210 } 211 212 @Override 213 public void layerAdded(Layer newLayer) { 214 // 215 } 216 217 @Override 218 public void layerRemoved(Layer oldLayer) { 219 if (oldLayer == WMSLayer.this) { 220 Main.map.mapView.removeMouseListener(adapter); 221 MapView.removeLayerChangeListener(this); 222 } 225 223 } 226 224 }); -
trunk/src/org/openstreetmap/josm/io/session/SessionLayerExporter.java
r4685 r5391 42 42 43 43 /** 44 * Save meta data to the .jos file. Return a <layer>element.45 * Use supportto save files in the zip archive as needed.44 * Save meta data to the .jos file. Return a layer XML element. 45 * Use <code>support</code> to save files in the zip archive as needed. 46 46 */ 47 47 Element export(ExportSupport support) throws IOException; -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r4874 r5391 56 56 static { 57 57 registerSessionLayerImporter("osm-data", OsmDataSessionImporter.class); 58 registerSessionLayerImporter("imagery", ImagerySessionImporter.class); 58 59 } 59 60 … … 166 167 167 168 /** 168 * Return a File for a URI from a .jos file.169 * Return a File for a URI from a .jos/.joz file. 169 170 * 170 171 * Returns null if the URI points to a file inside the zip archive. -
trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java
r4685 r5391 34 34 import org.openstreetmap.josm.gui.layer.Layer; 35 35 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 36 import org.openstreetmap.josm.gui.layer.TMSLayer; 37 import org.openstreetmap.josm.gui.layer.WMSLayer; 36 38 import org.openstreetmap.josm.tools.MultiMap; 37 39 import org.openstreetmap.josm.tools.Utils; … … 43 45 static { 44 46 registerSessionLayerExporter(OsmDataLayer.class , OsmDataSessionExporter.class); 47 registerSessionLayerExporter(TMSLayer.class , ImagerySessionExporter.class); 48 registerSessionLayerExporter(WMSLayer.class , ImagerySessionExporter.class); 45 49 } 46 50
Note:
See TracChangeset
for help on using the changeset viewer.