Changeset 10458 in josm
- Timestamp:
- 2016-06-22T22:18:24+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r10440 r10458 26 26 import java.util.Collection; 27 27 import java.util.Collections; 28 import java.util.HashMap; 28 29 import java.util.LinkedHashSet; 29 30 import java.util.List; … … 51 52 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 52 53 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 54 import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle; 53 55 import org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable; 54 56 import org.openstreetmap.josm.gui.layer.GpxLayer; … … 62 64 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 63 65 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 66 import org.openstreetmap.josm.gui.layer.MapViewGraphics; 64 67 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 68 import org.openstreetmap.josm.gui.layer.MapViewPaintable.LayerPainter; 69 import org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent; 65 70 import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationEvent; 66 71 import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener; 67 import org.openstreetmap.josm.gui.layer.NativeScaleLayer;68 72 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 69 73 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 70 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;71 74 import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker; 72 import org.openstreetmap.josm.gui.util.GuiHelper;73 75 import org.openstreetmap.josm.tools.AudioPlayer; 74 76 import org.openstreetmap.josm.tools.Shortcut; … … 493 495 494 496 /** 497 * This is a map of all Layers that have been added to this view. 498 */ 499 private final HashMap<Layer, LayerPainter> registeredLayers = new HashMap<>(); 500 501 /** 495 502 * Constructs a new {@code MapView}. 496 503 * @param layerManager The layers to display. … … 594 601 @Override 595 602 public void layerAdded(LayerAddEvent e) { 596 Layer layer = e.getAddedLayer(); 597 if (layer instanceof MarkerLayer && playHeadMarker == null) { 598 playHeadMarker = PlayHeadMarker.create(); 599 } 600 if (layer instanceof NativeScaleLayer) { 601 setNativeScaleLayer((NativeScaleLayer) layer); 602 } 603 604 ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds(); 605 if (viewProjectionBounds != null) { 606 scheduleZoomTo(new ViewportData(viewProjectionBounds)); 607 } 608 609 layer.addPropertyChangeListener(this); 610 Main.addProjectionChangeListener(layer); 611 invalidatedListener.addTo(layer); 612 AudioPlayer.reset(); 613 614 repaint(); 603 try { 604 Layer layer = e.getAddedLayer(); 605 registeredLayers.put(layer, layer.attachToMapView(new MapViewEvent(this, false))); 606 607 ProjectionBounds viewProjectionBounds = layer.getViewProjectionBounds(); 608 if (viewProjectionBounds != null) { 609 scheduleZoomTo(new ViewportData(viewProjectionBounds)); 610 } 611 612 layer.addPropertyChangeListener(this); 613 Main.addProjectionChangeListener(layer); 614 invalidatedListener.addTo(layer); 615 AudioPlayer.reset(); 616 617 repaint(); 618 } catch (RuntimeException t) { 619 throw BugReport.intercept(t).put("layer", e.getAddedLayer()); 620 } 615 621 } 616 622 … … 690 696 Layer layer = e.getRemovedLayer(); 691 697 698 LayerPainter painter = registeredLayers.remove(layer); 699 if (painter == null) { 700 throw new IllegalArgumentException("The painter for layer " + layer + " was not registered."); 701 } 702 painter.detachFromMapView(new MapViewEvent(this, false)); 692 703 Main.removeProjectionChangeListener(layer); 693 704 layer.removePropertyChangeListener(this); … … 770 781 private void paintLayer(Layer layer, Graphics2D g, Bounds box) { 771 782 try { 783 LayerPainter painter = registeredLayers.get(layer); 784 if (painter == null) { 785 throw new IllegalArgumentException("Cannot paint layer, it is not registered."); 786 } 787 MapViewRectangle clipBounds = getState().getViewArea(g.getClipBounds()); 788 MapViewGraphics paintGraphics = new MapViewGraphics(this, g, clipBounds); 789 772 790 if (layer.getOpacity() < 1) { 773 791 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) layer.getOpacity())); 774 792 } 775 layer.paint(g, this, box);793 painter.paint(paintGraphics); 776 794 g.setPaintMode(); 777 795 } catch (RuntimeException t) { 796 //TODO: only display. 778 797 throw BugReport.intercept(t).put("layer", layer).put("bounds", box); 779 798 } … … 1075 1094 @Override 1076 1095 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 1077 /* This only makes the buttons look disabled. Disabling the actions as well requires 1078 * the user to re-select the tool after i.e. moving a layer. While testing I found 1079 * that I switch layers and actions at the same time and it was annoying to mind the 1080 * order. This way it works as visual clue for new users */ 1081 for (final AbstractButton b: Main.map.allMapModeButtons) { 1082 MapMode mode = (MapMode) b.getAction(); 1083 final boolean activeLayerSupported = mode.layerIsSupported(layerManager.getActiveLayer()); 1084 if (activeLayerSupported) { 1085 Main.registerActionShortcut(mode, mode.getShortcut()); //fix #6876 1086 } else { 1087 Main.unregisterShortcut(mode.getShortcut()); 1088 } 1089 GuiHelper.runInEDTAndWait(new Runnable() { 1090 @Override public void run() { 1091 b.setEnabled(activeLayerSupported); 1096 if (Main.map != null) { 1097 /* This only makes the buttons look disabled. Disabling the actions as well requires 1098 * the user to re-select the tool after i.e. moving a layer. While testing I found 1099 * that I switch layers and actions at the same time and it was annoying to mind the 1100 * order. This way it works as visual clue for new users */ 1101 // FIXME: This does not belong here. 1102 for (final AbstractButton b: Main.map.allMapModeButtons) { 1103 MapMode mode = (MapMode) b.getAction(); 1104 final boolean activeLayerSupported = mode.layerIsSupported(layerManager.getActiveLayer()); 1105 if (activeLayerSupported) { 1106 Main.registerActionShortcut(mode, mode.getShortcut()); //fix #6876 1107 } else { 1108 Main.unregisterShortcut(mode.getShortcut()); 1092 1109 } 1093 }); 1110 b.setEnabled(activeLayerSupported); 1111 } 1094 1112 } 1095 1113 AudioPlayer.reset(); -
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r10399 r10458 4 4 import java.awt.Container; 5 5 import java.awt.Point; 6 import java.awt.Rectangle; 6 7 import java.awt.geom.AffineTransform; 7 8 import java.awt.geom.Point2D; … … 135 136 136 137 /** 138 * Gets a rectangle of the view as map view area. 139 * @param rectangle The rectangle to get. 140 * @return The view area. 141 * @since 10458 142 */ 143 public MapViewRectangle getViewArea(Rectangle rectangle) { 144 return getForView(rectangle.getMinX(), rectangle.getMinY()).rectTo(getForView(rectangle.getMaxX(), rectangle.getMaxY())); 145 } 146 147 /** 137 148 * Gets the center of the view. 138 149 * @return The center position. … … 194 205 public MapViewState movedTo(MapViewPoint mapViewPoint, EastNorth newEastNorthThere) { 195 206 EastNorth delta = newEastNorthThere.subtract(mapViewPoint.getEastNorth()); 196 if (delta.distanceSq(0, 0) < . 000001) {207 if (delta.distanceSq(0, 0) < .1e-20) { 197 208 return this; 198 209 } else { … … 397 408 * Gets a rough estimate of the bounds by assuming lat/lon are parallel to x/y. 398 409 * @return The bounds computed by converting the corners of this rectangle. 410 * @see #getLatLonBoundsBox() 399 411 */ 400 412 public Bounds getCornerBounds() { … … 403 415 return b; 404 416 } 417 418 /** 419 * Gets the real bounds that enclose this rectangle. 420 * This is computed respecting that the borders of this rectangle may not be a straignt line in latlon coordinates. 421 * @return The bounds. 422 * @since 10458 423 */ 424 public Bounds getLatLonBoundsBox() { 425 return projection.getLatLonBoundsBox(getProjectionBounds()); 426 } 405 427 } 406 428 -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r10446 r10458 52 52 import org.openstreetmap.josm.data.projection.Projection; 53 53 import org.openstreetmap.josm.data.projection.Projections; 54 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;55 54 import org.openstreetmap.josm.gui.help.Helpful; 56 55 import org.openstreetmap.josm.gui.layer.NativeScaleLayer; … … 454 453 455 454 public ProjectionBounds getProjectionBounds(Rectangle r) { 456 MapViewState state = getState(); 457 MapViewPoint p1 = state.getForView(r.getMinX(), r.getMinY()); 458 MapViewPoint p2 = state.getForView(r.getMaxX(), r.getMaxY()); 459 return p1.rectTo(p2).getProjectionBounds(); 455 return getState().getViewArea(r).getProjectionBounds(); 460 456 } 461 457 … … 1511 1507 */ 1512 1508 public int getViewID() { 1513 String x = getCenter().east() + '_' + getCenter().north() + '_' + getScale() + '_' + 1514 getWidth() + '_' + getHeight() + '_' + getProjection().toString(); 1509 EastNorth center = getCenter(); 1510 String x = new StringBuilder().append(center.east()) 1511 .append('_').append(center.north()) 1512 .append('_').append(getScale()) 1513 .append('_').append(getWidth()) 1514 .append('_').append(getHeight()) 1515 .append('_').append(getProjection()).toString(); 1515 1516 CRC32 id = new CRC32(); 1516 1517 id.update(x.getBytes(StandardCharsets.UTF_8)); -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintable.java
r10031 r10458 5 5 6 6 /** 7 * This class implements the invalidation listener mechanism suggested by {@link MapViewPaintable} .7 * This class implements the invalidation listener mechanism suggested by {@link MapViewPaintable} and a default #atta 8 8 * 9 9 * @author Michael Zangl … … 13 13 14 14 /** 15 * This is the default implementation of the layer painter. 16 * <p> 17 * You should not use it. Write your own implementation and put your paint code into that class. 18 * <p> 19 * It propagates all calls to the 20 * {@link MapViewPaintable#paint(java.awt.Graphics2D, org.openstreetmap.josm.gui.MapView, org.openstreetmap.josm.data.Bounds)} method. 21 * @author Michael Zangl 22 * @since 10458 23 */ 24 protected class CompatibilityModeLayerPainter implements LayerPainter { 25 @Override 26 public void paint(MapViewGraphics graphics) { 27 AbstractMapViewPaintable.this.paint( 28 graphics.getDefaultGraphics(), 29 graphics.getMapView(), 30 graphics.getClipBounds().getLatLonBoundsBox()); 31 } 32 33 @Override 34 public void detachFromMapView(MapViewEvent event) { 35 // ignored in old implementation 36 } 37 } 38 39 /** 15 40 * A list of invalidation listeners to call when this layer is invalidated. 16 41 */ 17 42 private final CopyOnWriteArrayList<PaintableInvalidationListener> invalidationListeners = new CopyOnWriteArrayList<>(); 43 44 /** 45 * This method is called whenever this layer is added to a map view. 46 * <p> 47 * You need to return a painter here. 48 * The {@link MapViewPaintable.LayerPainter#detachFromMapView(MapViewEvent)} method is called when the layer is removed 49 * from that map view. You are free to reuse painters. 50 * <p> 51 * You should always call the super method. See {@link #createMapViewPainter} if you want to influence painter creation. 52 * <p> 53 * This replaces {@link Layer#hookUpMapView} in the long run. 54 * @param event the event. 55 * @return A layer painter. 56 * @since 10458 57 */ 58 public LayerPainter attachToMapView(MapViewEvent event) { 59 return createMapViewPainter(event); 60 } 61 62 /** 63 * Creates a new LayerPainter. 64 * @param event The event that triggered the creation. 65 * @return The painter. 66 * @since 10458 67 */ 68 protected LayerPainter createMapViewPainter(MapViewEvent event) { 69 return new CompatibilityModeLayerPainter(); 70 } 18 71 19 72 /** -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r10423 r10458 82 82 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 83 83 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 84 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;85 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;86 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;87 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;88 84 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 89 85 import org.openstreetmap.josm.gui.util.GuiHelper; … … 159 155 protected TileLoader tileLoader; 160 156 157 private final MouseAdapter adapter = new MouseAdapter() { 158 @Override 159 public void mouseClicked(MouseEvent e) { 160 if (!isVisible()) return; 161 if (e.getButton() == MouseEvent.BUTTON3) { 162 clickedTileHolder.setTile(getTileForPixelpos(e.getX(), e.getY())); 163 new TileSourceLayerPopup().show(e.getComponent(), e.getX(), e.getY()); 164 } else if (e.getButton() == MouseEvent.BUTTON1) { 165 attribution.handleAttribution(e.getPoint(), true); 166 } 167 } 168 }; 161 169 /** 162 170 * Creates Tile Source based Imagery Layer based on Imagery Info … … 607 615 // this needs to be here and not in constructor to allow empty TileSource class construction 608 616 // using SessionWriter 609 this.tileSource = getTileSource(info); 610 if (this.tileSource == null) { 611 throw new IllegalArgumentException(tr("Failed to create tile source")); 612 } 617 initializeIfRequired(); 613 618 614 619 super.hookUpMapView(); 615 projectionChanged(null, Main.getProjection()); // check if projection is supported 616 initTileSource(this.tileSource); 617 618 final MouseAdapter adapter = new MouseAdapter() { 619 @Override 620 public void mouseClicked(MouseEvent e) { 621 if (!isVisible()) return; 622 if (e.getButton() == MouseEvent.BUTTON3) { 623 clickedTileHolder.setTile(getTileForPixelpos(e.getX(), e.getY())); 624 new TileSourceLayerPopup().show(e.getComponent(), e.getX(), e.getY()); 625 } else if (e.getButton() == MouseEvent.BUTTON1) { 626 attribution.handleAttribution(e.getPoint(), true); 627 } 628 } 629 }; 630 Main.getLayerManager().addLayerChangeListener(new LayerChangeListener() { 631 632 @Override 633 public void layerRemoving(LayerRemoveEvent e) { 634 if (e.getRemovedLayer() == AbstractTileSourceLayer.this) { 635 Main.map.mapView.removeMouseListener(adapter); 636 e.getSource().removeLayerChangeListener(this); 637 MapView.removeZoomChangeListener(AbstractTileSourceLayer.this); 638 } 639 } 640 641 @Override 642 public void layerOrderChanged(LayerOrderChangeEvent e) { 643 // ignored 644 } 645 646 @Override 647 public void layerAdded(LayerAddEvent e) { 648 if (e.getAddedLayer() == AbstractTileSourceLayer.this) { 649 Main.map.mapView.addMouseListener(adapter); 650 MapView.addZoomChangeListener(AbstractTileSourceLayer.this); 651 } 652 } 653 }, true); 620 } 621 622 @Override 623 public LayerPainter attachToMapView(MapViewEvent event) { 624 initializeIfRequired(); 625 626 event.getMapView().addMouseListener(adapter); 627 MapView.addZoomChangeListener(AbstractTileSourceLayer.this); 628 629 if (this instanceof NativeScaleLayer) { 630 event.getMapView().setNativeScaleLayer((NativeScaleLayer) this); 631 } 632 654 633 // FIXME: why do we need this? Without this, if you add a WMS layer and do not move the mouse, sometimes, tiles do not 655 634 // start loading. 635 // FIXME: Check if this is still required. 656 636 Main.map.repaint(500); 637 638 return super.attachToMapView(event); 639 } 640 641 private void initializeIfRequired() { 642 if (tileSource == null) { 643 tileSource = getTileSource(info); 644 if (tileSource == null) { 645 throw new IllegalArgumentException(tr("Failed to create tile source")); 646 } 647 checkLayerMemoryDoesNotExceedMaximum(); 648 // check if projection is supported 649 projectionChanged(null, Main.getProjection()); 650 initTileSource(this.tileSource); 651 } 652 } 653 654 @Override 655 protected LayerPainter createMapViewPainter(MapViewEvent event) { 656 return new CompatibilityModeLayerPainter() { 657 @Override 658 public void detachFromMapView(MapViewEvent event) { 659 event.getMapView().removeMouseListener(adapter); 660 MapView.removeZoomChangeListener(AbstractTileSourceLayer.this); 661 super.detachFromMapView(event); 662 } 663 }; 657 664 } 658 665 -
trunk/src/org/openstreetmap/josm/gui/layer/Layer.java
r10378 r10458 17 17 import javax.swing.JOptionPane; 18 18 import javax.swing.JSeparator; 19 import javax.swing.SwingUtilities; 19 20 20 21 import org.openstreetmap.josm.Main; … … 169 170 */ 170 171 public void hookUpMapView() { 172 checkLayerMemoryDoesNotExceedMaximum(); 173 } 174 175 /** 176 * Checks that the memory required for the layers is no greather than the max memory. 177 */ 178 protected static void checkLayerMemoryDoesNotExceedMaximum() { 171 179 // calculate total memory needed for all layers 172 180 long memoryBytesRequired = 50L * 1024L * 1024L; // assumed minimum JOSM memory footprint 173 if (Main.map != null && Main.map.mapView != null) { 174 for (Layer layer: Main.getLayerManager().getLayers()) { 175 memoryBytesRequired += layer.estimateMemoryUsage(); 176 } 177 if (memoryBytesRequired > Runtime.getRuntime().maxMemory()) { 178 throw new IllegalArgumentException( 179 tr("To add another layer you need to allocate at least {0,number,#}MB memory to JOSM using -Xmx{0,number,#}M " 180 + "option (see http://forum.openstreetmap.org/viewtopic.php?id=25677).\n" 181 + "Currently you have {1,number,#}MB memory allocated for JOSM", 182 memoryBytesRequired / 1024 / 1024, Runtime.getRuntime().maxMemory() / 1024 / 1024)); 183 } 181 for (Layer layer: Main.getLayerManager().getLayers()) { 182 memoryBytesRequired += layer.estimateMemoryUsage(); 183 } 184 if (memoryBytesRequired > Runtime.getRuntime().maxMemory()) { 185 throw new IllegalArgumentException( 186 tr("To add another layer you need to allocate at least {0,number,#}MB memory to JOSM using -Xmx{0,number,#}M " 187 + "option (see http://forum.openstreetmap.org/viewtopic.php?id=25677).\n" 188 + "Currently you have {1,number,#}MB memory allocated for JOSM", 189 memoryBytesRequired / 1024 / 1024, Runtime.getRuntime().maxMemory() / 1024 / 1024)); 184 190 } 185 191 } … … 526 532 public void projectionChanged(Projection oldValue, Projection newValue) { 527 533 if (!isProjectionSupported(newValue)) { 528 String message = "<html><body><p>" +534 final String message = "<html><body><p>" + 529 535 tr("The layer {0} does not support the new projection {1}.", getName(), newValue.toCode()) + "</p>" + 530 536 "<p style='width: 450px;'>" + tr("Supported projections are: {0}", nameSupportedProjections()) + "</p>" + 531 537 tr("Change the projection again or remove the layer."); 532 538 533 JOptionPane.showMessageDialog(Main.parent, 534 message, 535 tr("Warning"), 536 JOptionPane.WARNING_MESSAGE); 539 // run later to not block loading the UI. 540 SwingUtilities.invokeLater(new Runnable() { 541 @Override 542 public void run() { 543 JOptionPane.showMessageDialog(Main.parent, 544 message, 545 tr("Warning"), 546 JOptionPane.WARNING_MESSAGE); 547 } 548 }); 537 549 } 538 550 } -
trunk/src/org/openstreetmap/josm/gui/layer/LayerManager.java
r10432 r10458 9 9 import org.openstreetmap.josm.gui.util.GuiHelper; 10 10 import org.openstreetmap.josm.tools.Utils; 11 import org.openstreetmap.josm.tools.bugreport.BugReport; 11 12 12 13 /** … … 82 83 return addedLayer; 83 84 } 85 86 @Override 87 public String toString() { 88 return "LayerAddEvent [addedLayer=" + addedLayer + ']'; 89 } 84 90 } 85 91 … … 114 120 return lastLayer; 115 121 } 122 123 @Override 124 public String toString() { 125 return "LayerRemoveEvent [removedLayer=" + removedLayer + ", lastLayer=" + lastLayer + ']'; 126 } 116 127 } 117 128 … … 127 138 } 128 139 140 @Override 141 public String toString() { 142 return "LayerOrderChangeEvent []"; 143 } 129 144 } 130 145 … … 339 354 LayerAddEvent e = new LayerAddEvent(this, layer); 340 355 for (LayerChangeListener l : layerChangeListeners) { 341 l.layerAdded(e); 356 try { 357 l.layerAdded(e); 358 } catch (RuntimeException t) { 359 throw BugReport.intercept(t).put("listener", l).put("event", e); 360 } 342 361 } 343 362 } … … 347 366 LayerRemoveEvent e = new LayerRemoveEvent(this, layer); 348 367 for (LayerChangeListener l : layerChangeListeners) { 349 l.layerRemoving(e); 368 try { 369 l.layerRemoving(e); 370 } catch (RuntimeException t) { 371 throw BugReport.intercept(t).put("listener", l).put("event", e); 372 } 350 373 } 351 374 } … … 355 378 LayerOrderChangeEvent e = new LayerOrderChangeEvent(this); 356 379 for (LayerChangeListener l : layerChangeListeners) { 357 l.layerOrderChanged(e); 380 try { 381 l.layerOrderChanged(e); 382 } catch (RuntimeException t) { 383 throw BugReport.intercept(t).put("listener", l).put("event", e); 384 } 358 385 } 359 386 } -
trunk/src/org/openstreetmap/josm/gui/layer/MapViewPaintable.java
r10300 r10458 61 61 62 62 /** 63 * Gets a new LayerPainter that paints this {@link MapViewPaintable} to the given map view. 64 * 65 * @author Michael Zangl 66 * @since 10458 67 */ 68 public interface LayerPainter { 69 70 /** 71 * Paints the given layer. 72 * <p> 73 * This can be called in any thread at any time. You will not receive parallel calls for the same map view but you can receive parallel 74 * calls if you use the same {@link LayerPainter} for different map views. 75 * @param graphics The graphics object of the map view you should use. 76 * It provides you with a content pane, the bounds and the view state. 77 */ 78 void paint(MapViewGraphics graphics); 79 80 /** 81 * Called when the layer is removed from the map view and this painter is not used any more. 82 * <p> 83 * This method is called once on the painter returned by {@link Layer#attachToMapView(MapViewEvent)} 84 * @param event The event. 85 */ 86 void detachFromMapView(MapViewEvent event); 87 } 88 89 /** 90 * A event that is fired whenever the map view is attached or detached from any layer. 91 * @author Michael Zangl 92 * @see Layer#attachToMapView(MapViewEvent) 93 * @since 10458 94 */ 95 class MapViewEvent { 96 private final MapView mapView; 97 private final boolean temporaryLayer; 98 99 /** 100 * Create a new {@link MapViewEvent} 101 * @param mapView The map view 102 * @param temporaryLayer <code>true</code> if this layer is in the temporary layer list of the view. 103 */ 104 public MapViewEvent(MapView mapView, boolean temporaryLayer) { 105 super(); 106 this.mapView = mapView; 107 this.temporaryLayer = temporaryLayer; 108 } 109 110 /** 111 * Gets the map view. 112 * @return The map view. 113 */ 114 public MapView getMapView() { 115 return mapView; 116 } 117 118 /** 119 * @return true if this {@link MapViewPaintable} is used as a temporary layer. 120 */ 121 public boolean isTemporaryLayer() { 122 return temporaryLayer; 123 } 124 125 @Override 126 public String toString() { 127 return "AttachToMapViewEvent [mapView=" + mapView + ", temporaryLayer=" + temporaryLayer + "]"; 128 } 129 } 130 131 /** 63 132 * Paint the dataset using the engine set. 64 133 * @param g Graphics -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r10378 r10458 139 139 140 140 @Override 141 public void hookUpMapView() {142 Main.map.mapView.addMouseListener(new MouseAdapter() {141 public LayerPainter attachToMapView(MapViewEvent event) { 142 event.getMapView().addMouseListener(new MouseAdapter() { 143 143 @Override 144 144 public void mousePressed(MouseEvent e) { … … 179 179 } 180 180 }); 181 182 if (event.getMapView().playHeadMarker == null) { 183 event.getMapView().playHeadMarker = PlayHeadMarker.create(); 184 } 185 186 return super.attachToMapView(event); 181 187 } 182 188
Note:
See TracChangeset
for help on using the changeset viewer.