Changeset 4710 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-12-26T12:57:26+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r4604 r4710 70 70 71 71 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer) { 72 72 this(indata, name, associatedFile, fromLayer, true); 73 } 74 75 public MarkerLayer(GpxData indata, String name, File associatedFile, GpxLayer fromLayer, boolean addMouseHandlerInConstructor) { 73 76 super(name); 74 77 this.setAssociatedFile(associatedFile); … … 88 91 } 89 92 90 SwingUtilities.invokeLater(new Runnable(){91 public void run(){92 Main.map.mapView.addMouseListener(new MouseAdapter() {93 @Override public void mousePressed(MouseEvent e) {94 if (e.getButton() != MouseEvent.BUTTON1)95 return;96 boolean mousePressedInButton = false;97 if (e.getPoint() != null) {98 for (Marker mkr : data) { 99 if (mkr.containsPoint(e.getPoint())) {100 mousePressedInButton = true;101 break;102 }103 }104 }105 if (! mousePressedInButton)106 return;107 mousePressed = true;108 if (isVisible()) {109 Main.map.mapView.repaint();93 if (addMouseHandlerInConstructor) { 94 SwingUtilities.invokeLater(new Runnable(){ 95 public void run() { 96 addMouseHandler(); 97 } 98 }); 99 } 100 } 101 102 public void addMouseHandler() { 103 Main.map.mapView.addMouseListener(new MouseAdapter() { 104 @Override public void mousePressed(MouseEvent e) { 105 if (e.getButton() != MouseEvent.BUTTON1) 106 return; 107 boolean mousePressedInButton = false; 108 if (e.getPoint() != null) { 109 for (Marker mkr : data) { 110 if (mkr.containsPoint(e.getPoint())) { 111 mousePressedInButton = true; 112 break; 110 113 } 111 114 } 112 @Override public void mouseReleased(MouseEvent ev) { 113 if (ev.getButton() != MouseEvent.BUTTON1 || ! mousePressed) 114 return; 115 mousePressed = false; 116 if (!isVisible()) 117 return; 118 if (ev.getPoint() != null) { 119 for (Marker mkr : data) { 120 if (mkr.containsPoint(ev.getPoint())) { 121 mkr.actionPerformed(new ActionEvent(this, 0, null)); 122 } 123 } 115 } 116 if (! mousePressedInButton) 117 return; 118 mousePressed = true; 119 if (isVisible()) { 120 Main.map.mapView.repaint(); 121 } 122 } 123 @Override public void mouseReleased(MouseEvent ev) { 124 if (ev.getButton() != MouseEvent.BUTTON1 || ! mousePressed) 125 return; 126 mousePressed = false; 127 if (!isVisible()) 128 return; 129 if (ev.getPoint() != null) { 130 for (Marker mkr : data) { 131 if (mkr.containsPoint(ev.getPoint())) { 132 mkr.actionPerformed(new ActionEvent(this, 0, null)); 124 133 } 125 Main.map.mapView.repaint();126 134 } 127 }); 135 } 136 Main.map.mapView.repaint(); 128 137 } 129 138 }); -
trunk/src/org/openstreetmap/josm/io/GpxImporter.java
r4695 r4710 66 66 } 67 67 if (Main.pref.getBoolean("marker.makeautomarkers", true) && !r.data.waypoints.isEmpty()) { 68 markerLayer = new MarkerLayer(r.data, markerLayerName, associatedFile, gpxLayer );68 markerLayer = new MarkerLayer(r.data, markerLayerName, associatedFile, gpxLayer, false); 69 69 if (markerLayer.data.size() == 0) { 70 70 markerLayer = null; … … 74 74 @Override 75 75 public void run() { 76 if (markerLayer != null) { 77 markerLayer.addMouseHandler(); 78 } 76 79 if (!parsedProperly) { 77 80 String msg;
Note:
See TracChangeset
for help on using the changeset viewer.