Changeset 26397 in osm for applications/editors/josm/plugins/infomode/src/org
- Timestamp:
- 2011-07-25T13:17:41+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoMode.java
r26389 r26397 11 11 12 12 import java.awt.AWTEvent; 13 import java.awt.BasicStroke; 13 14 import java.awt.Color; 14 15 import java.awt.Point; … … 20 21 import java.awt.Cursor; 21 22 import java.awt.Graphics2D; 23 import java.awt.Shape; 24 import java.awt.Stroke; 22 25 import java.awt.Toolkit; 23 26 import java.awt.event.AWTEventListener; … … 68 71 @Override 69 72 public void enterMode() { 70 System.out.println("entering mode");71 73 if (!isEnabled()) return; 72 74 super.enterMode(); 73 System.out.println("enter mode");74 75 75 76 76 mv = Main.map.mapView; 77 78 77 Main.map.mapView.addMouseListener(this); 79 78 Main.map.mapView.addMouseMotionListener(this); … … 91 90 public void exitMode() { 92 91 super.exitMode(); 93 System.out.println("exit mode");94 92 Main.map.mapView.removeMouseListener(this); 95 93 Main.map.mapView.removeMouseMotionListener(this); … … 123 121 GpxLayer gpxL = (GpxLayer )l; 124 122 125 double minDist=1e9,d ,len=0;123 double minDist=1e9,d; 126 124 WayPoint wp=null,oldWp=null,prevWp=null; 127 125 GpxTrack trk=null; 126 double maxD = mv.getDist100Pixel()/3; 128 127 for (GpxTrack track : gpxL.data.tracks) { 129 128 for (GpxTrackSegment seg : track.getSegments()) { 129 oldWp=null;// next segment will have new previous point 130 130 for (WayPoint S : seg.getWayPoints()) { 131 131 d = S.getEastNorth().distance(pos); 132 if (d<minDist && d<100) { 132 133 if (d<minDist && d<maxD) { 133 134 minDist = d; 134 135 prevWp=oldWp; … … 136 137 trk=track; 137 138 } 138 oldWp= wp;139 oldWp=S; 139 140 } 140 141 } … … 145 146 g.setColor(Color.RED); 146 147 g.fillOval(p.x-10, p.y-10, 20, 20); // mark selected point 148 if (shift) { // highlight track 149 g.setColor(new Color(255,30,0,128)); 150 Stroke oldStroke = g.getStroke(); 151 g.setStroke( new BasicStroke(10) ); 152 for (GpxTrackSegment seg : trk.getSegments()) { 153 Point oldP=null,curP=null;// next segment will have new previous point 154 for (WayPoint S : seg.getWayPoints()) { 155 curP = mv.getPoint(S.getEastNorth()); 156 if (oldP!=null) g.drawLine(oldP.x, oldP.y, curP.x, curP.y); 157 oldP = curP; 158 } 159 } 160 g.setStroke(oldStroke); 161 } 162 Point s=mv.getLocationOnScreen(); 163 int pcx = s.x+p.x-40; 164 int pcy = s.y+p.y+30; 165 if (shift) {pcx+=40; pcy-=30;} 147 166 148 167 if (wp!=wpOld) { 149 if (oldPopup!=null) oldPopup.hide(); 150 double vel=-1; 151 if (prevWp!=null && wp.time!=prevWp.time) { 152 vel=wp.getCoor().greatCircleDistance(prevWp.getCoor())/ 153 (wp.time-prevWp.time)*3.6; 154 } 155 infoPanel.setData(wp,trk,vel,gpxL.data.tracks); 156 Point s=mv.getLocationOnScreen(); 157 Popup pp=PopupFactory.getSharedInstance().getPopup(mv, infoPanel, 158 s.x+p.x+10, s.y+p.y+10); 159 pp.show(); 160 wpOld=wp; 161 oldPopup=pp; 168 if (oldPopup!=null) oldPopup.hide(); 169 double vel=-1; 170 if (prevWp!=null && wp.time!=prevWp.time) { 171 vel=wp.getCoor().greatCircleDistance(prevWp.getCoor())/ 172 (wp.time-prevWp.time)*3.6; 173 } 174 infoPanel.setData(wp,trk,vel,gpxL.data.tracks); 175 Popup pp=PopupFactory.getSharedInstance().getPopup(mv, infoPanel, 176 pcx, pcy); 177 pp.show(); 178 wpOld=wp; 179 oldPopup=pp; 162 180 } 163 181 } … … 267 285 } 268 286 } 269 270 271 272 273 287 }
Note:
See TracChangeset
for help on using the changeset viewer.