Changeset 33776 in osm for applications/editors/josm
- Timestamp:
- 2017-11-05T19:16:18+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/gpsblam
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/gpsblam/build.xml
r33257 r33776 5 5 <property name="commit.message" value="Commit message"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 1713"/>7 <property name="plugin.main.version" value="12636"/> 8 8 9 9 <!-- -
applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java
r32329 r33776 14 14 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 15 15 import org.openstreetmap.josm.data.gpx.WayPoint; 16 import org.openstreetmap.josm.data.projection.Projection; 17 import org.openstreetmap.josm.gui.MainApplication; 16 18 import org.openstreetmap.josm.gui.layer.GpxLayer; 17 19 import org.openstreetmap.josm.gui.layer.Layer; … … 27 29 // within given radius of line between given points 28 30 GPSBlamInputData(Point p1, Point p2, int radius) { 29 Collection<Layer> layers = Main.getLayerManager().getLayers(); 31 Collection<Layer> layers = MainApplication.getLayerManager().getLayers(); 32 Projection projection = Main.getProjection(); 30 33 for (Layer l : layers) { 31 34 if (l.isVisible() && l instanceof GpxLayer) { … … 33 36 for (GpxTrackSegment segment: track.getSegments()) { 34 37 for (WayPoint wayPoint : segment.getWayPoints()) { 35 36 38 if (p2.equals(p1)) { 37 39 // circular selection 38 40 CachedLatLon cll = new CachedLatLon(wayPoint.getCoor()); 39 Point p = Main .map.mapView.getPoint(cll.getEastNorth());41 Point p = MainApplication.getMap().mapView.getPoint(cll.getEastNorth(projection)); 40 42 if (p.distance(p1) < radius) { 41 43 this.add(cll, wayPoint); … … 51 53 52 54 CachedLatLon cll = new CachedLatLon(wayPoint.getCoor()); 53 Point p = Main .map.mapView.getPoint(cll.getEastNorth());55 Point p = MainApplication.getMap().mapView.getPoint(cll.getEastNorth(projection)); 54 56 double pX = p.x-p1.x, pY=p.y-p1.y; // vector from point clicked to waypoint 55 57 double pPar = pX*dirX + pY*dirY; // parallel component -
applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamMarker.java
r30761 r33776 25 25 /** construct a blammarker by analysis of selected GPS points */ 26 26 GPSBlamMarker(GPSBlamInputData inputData) { 27 Projection projection = Main.getProjection(); 27 28 // get mean east, north 28 29 double meanEast=0.0, meanNorth=0.0; 29 30 for (CachedLatLon cll : inputData) { 30 EastNorth en = cll.getEastNorth(); 31 EastNorth en = cll.getEastNorth(projection); 31 32 meanEast += en.east(); 32 33 meanNorth += en.north(); … … 40 41 double deast, dnorth; 41 42 for (CachedLatLon cll : inputData) { 42 EastNorth en = cll.getEastNorth(); 43 EastNorth en = cll.getEastNorth(projection); 43 44 deast = en.east()-meanEast; 44 45 dnorth = en.north()-meanNorth; … … 87 88 88 89 void paint(Graphics2D g, MapView mv) { 90 Projection projection = Main.getProjection(); 89 91 g.setColor(Color.GREEN); 90 92 g.setPaintMode(); 91 93 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 92 94 g.setStroke(new BasicStroke(2.0f)); 93 Point hair1Point1 = mv.getPoint(hair1Coord1.getEastNorth()); 94 Point hair1Point2 = mv.getPoint(hair1Coord2.getEastNorth()); 95 Point hair2Point1 = mv.getPoint(hair2Coord1.getEastNorth()); 96 Point hair2Point2 = mv.getPoint(hair2Coord2.getEastNorth()); 95 Point hair1Point1 = mv.getPoint(hair1Coord1.getEastNorth(projection)); 96 Point hair1Point2 = mv.getPoint(hair1Coord2.getEastNorth(projection)); 97 Point hair2Point1 = mv.getPoint(hair2Coord1.getEastNorth(projection)); 98 Point hair2Point2 = mv.getPoint(hair2Coord2.getEastNorth(projection)); 97 99 g.drawLine(hair1Point1.x, hair1Point1.y, hair1Point2.x, hair1Point2.y); 98 100 g.drawLine(hair2Point1.x, hair2Point1.y, hair2Point2.x, hair2Point2.y); 99 101 100 Point2D meanPoint = mv.getPoint2D(mean.getEastNorth()); 101 Point2D ellipsePoint1 = mv.getPoint2D(ellipseCoord1.getEastNorth()); 102 Point2D ellipsePoint2 = mv.getPoint2D(ellipseCoord2.getEastNorth()); 103 Point2D ellipsePoint3 = mv.getPoint2D(ellipseCoord3.getEastNorth()); 102 Point2D meanPoint = mv.getPoint2D(mean.getEastNorth(projection)); 103 Point2D ellipsePoint1 = mv.getPoint2D(ellipseCoord1.getEastNorth(projection)); 104 Point2D ellipsePoint2 = mv.getPoint2D(ellipseCoord2.getEastNorth(projection)); 105 Point2D ellipsePoint3 = mv.getPoint2D(ellipseCoord3.getEastNorth(projection)); 104 106 double majorAxis = ellipsePoint2.distance(ellipsePoint1); 105 107 double minorAxis = ellipsePoint3.distance(ellipsePoint1); -
applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamMode.java
r33258 r33776 22 22 import java.awt.geom.Path2D; 23 23 24 import org.openstreetmap.josm.Main;25 24 import org.openstreetmap.josm.actions.mapmode.MapMode; 25 import org.openstreetmap.josm.gui.MainApplication; 26 import org.openstreetmap.josm.gui.MapView; 26 27 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 27 28 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 28 29 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 29 30 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 31 import org.openstreetmap.josm.tools.Logging; 30 32 31 33 class GPSBlamMode extends MapMode implements LayerChangeListener, MouseWheelListener, AWTEventListener { … … 45 47 public void enterMode() { 46 48 super.enterMode(); 47 Main.map.mapView.addMouseListener(this); 48 Main.map.mapView.addMouseMotionListener(this); 49 Main.map.mapView.addMouseWheelListener(this); 49 MapView mapView = MainApplication.getMap().mapView; 50 mapView.addMouseListener(this); 51 mapView.addMouseMotionListener(this); 52 mapView.addMouseWheelListener(this); 50 53 try { 51 54 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 52 55 } catch (SecurityException ex) { 53 Main.error(ex);56 Logging.error(ex); 54 57 } 55 58 … … 72 75 super.exitMode(); 73 76 getLayerManager().removeLayerChangeListener(this); 74 Main .map.mapView.removeMouseListener(this);75 Main .map.mapView.removeMouseMotionListener(this);76 Main .map.mapView.removeMouseWheelListener(this);77 MainApplication.getMap().mapView.removeMouseListener(this); 78 MainApplication.getMap().mapView.removeMouseMotionListener(this); 79 MainApplication.getMap().mapView.removeMouseWheelListener(this); 77 80 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 78 81 } … … 83 86 pointPressed = new Point(e.getPoint()); 84 87 // gain exclusive use of mouse wheel for now 85 mapViewWheelListeners = Main .map.mapView.getMouseWheelListeners();88 mapViewWheelListeners = MainApplication.getMap().mapView.getMouseWheelListeners(); 86 89 for (MouseWheelListener l : mapViewWheelListeners) { 87 90 if (l != this) 88 Main .map.mapView.removeMouseWheelListener(l);91 MainApplication.getMap().mapView.removeMouseWheelListener(l); 89 92 } 90 93 paintBox(pointPressed, radius); … … 108 111 for (MouseWheelListener l : mapViewWheelListeners) { 109 112 if (l != this) 110 Main .map.mapView.addMouseWheelListener(l);113 MainApplication.getMap().mapView.addMouseWheelListener(l); 111 114 } 112 115 … … 120 123 } 121 124 currentBlamLayer.addBlamMarker(new GPSBlamMarker(inputData)); 122 Main .map.mapView.repaint();125 MainApplication.getMap().mapView.repaint(); 123 126 } 124 127 … … 144 147 145 148 private void xorDrawBox(Point p1, Point p2, int radius){ 146 if (Main .map!= null) {147 Graphics2D g = (Graphics2D) Main .map.mapView.getGraphics();149 if (MainApplication.getMap() != null) { 150 Graphics2D g = (Graphics2D) MainApplication.getMap().mapView.getGraphics(); 148 151 g.setXORMode(Color.BLACK); 149 152 g.setColor(Color.WHITE); … … 177 180 } catch (InternalError e) { 178 181 // Robustness against Java bug https://bugs.openjdk.java.net/browse/JDK-8041647 179 Main.error(e);180 Main.error("Java bug JDK-8041647 occured. To avoid this bug, please consult https://bugs.openjdk.java.net/browse/JDK-8041647."182 Logging.error(e); 183 Logging.error("Java bug JDK-8041647 occured. To avoid this bug, please consult https://bugs.openjdk.java.net/browse/JDK-8041647." 181 184 +" If the bug is fixed, please update your Java Runtime Environment."); 182 185 } … … 186 189 187 190 private void paintBox(Point p2, int newRadius) { 188 if (Main .map!= null) {191 if (MainApplication.getMap() != null) { 189 192 if (oldP2 != null) { 190 193 xorDrawBox(pointPressed, oldP2, radius); // clear old box … … 209 212 if (e.getRemovedLayer() instanceof GPSBlamLayer) { 210 213 currentBlamLayer = null; 211 if (Main .map.mapMode instanceof GPSBlamMode)212 Main .map.selectSelectTool(false);214 if (MainApplication.getMap().mapMode instanceof GPSBlamMode) 215 MainApplication.getMap().selectSelectTool(false); 213 216 } 214 217 }
Note:
See TracChangeset
for help on using the changeset viewer.