Changeset 30737 in osm for applications/editors/josm/plugins/infomode
- Timestamp:
- 2014-10-18T23:07:52+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoMode.java
r30701 r30737 10 10 package org.openstreetmap.josm.plugins.infomode; 11 11 12 import static org.openstreetmap.josm.tools.I18n.tr; 13 12 14 import java.awt.AWTEvent; 13 15 import java.awt.BasicStroke; 14 16 import java.awt.Color; 15 import java.awt.Point;16 import java.awt.event.MouseEvent;17 import org.openstreetmap.josm.data.coor.EastNorth;18 import org.openstreetmap.josm.data.gpx.WayPoint;19 import static org.openstreetmap.josm.tools.I18n.tr;20 21 17 import java.awt.Cursor; 22 18 import java.awt.Graphics2D; 19 import java.awt.Point; 23 20 import java.awt.Stroke; 24 21 import java.awt.Toolkit; … … 27 24 import java.awt.event.InputEvent; 28 25 import java.awt.event.KeyEvent; 26 import java.awt.event.MouseEvent; 29 27 import java.util.HashSet; 30 28 import java.util.Set; 29 31 30 import javax.swing.Popup; 32 31 import javax.swing.PopupFactory; … … 35 34 import org.openstreetmap.josm.actions.mapmode.MapMode; 36 35 import org.openstreetmap.josm.data.Bounds; 36 import org.openstreetmap.josm.data.coor.EastNorth; 37 37 import org.openstreetmap.josm.data.gpx.GpxTrack; 38 38 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 39 import org.openstreetmap.josm.data.gpx.WayPoint; 39 40 import org.openstreetmap.josm.gui.MapFrame; 40 41 import org.openstreetmap.josm.gui.MapView; … … 58 59 59 60 InfoMode(MapFrame mapFrame) { 60 super(tr("InfoMode"), "infomode.png", tr("GPX info mode"), 61 super(tr("InfoMode"), "infomode.png", tr("GPX info mode"), 61 62 Shortcut.registerShortcut("mapmode:infomode", tr("Mode: {0}", tr("GPX info mode")), KeyEvent.VK_BACK_SLASH, Shortcut.DIRECT), mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 62 63 infoPanel=new InfoPanel(); 63 64 64 65 } 65 66 … … 105 106 } catch (SecurityException ex) { 106 107 } 107 108 108 109 repaint(); 109 110 } … … 122 123 if (pos==null) return; 123 124 Layer curL= Main.main.getActiveLayer(); 124 if (curL instanceof GpxLayer) showLayerInfo(g,curL,mv); else { 125 if (curL instanceof GpxLayer) showLayerInfo(g,curL,mv); else { 125 126 for (Layer l:mv.getAllLayers()) { 126 127 if (l instanceof GpxLayer) { … … 157 158 oldPopup.hide(); 158 159 oldPopup=null; wpOld=null; 159 } 160 } 160 161 repaint(); 161 162 } … … 188 189 } 189 190 } 190 191 191 192 192 193 /** … … 220 221 private synchronized void filterTracks() { 221 222 Layer l = Main.main.getActiveLayer(); 222 223 223 224 if (l instanceof GpxLayer && pos!=null) { 224 225 GpxLayer gpxL = (GpxLayer )l; 225 Set<GpxTrack> toRemove = new HashSet< GpxTrack>();226 Set<GpxTrack> toRemove = new HashSet<>(); 226 227 for (GpxTrack track : gpxL.data.tracks) { 227 228 boolean f=true; … … 234 235 } 235 236 gpxL.data.tracks.removeAll(toRemove); 236 237 237 238 238 239 } … … 241 242 private boolean showLayerInfo(Graphics2D g, Layer l, MapView mv) { 242 243 GpxLayer gpxL = (GpxLayer )l; 243 244 244 245 double minDist=1e9,d; 245 246 WayPoint wp=null,oldWp=null,prevWp=null; … … 251 252 for (WayPoint S : seg.getWayPoints()) { 252 253 d = S.getEastNorth().distance(pos); 253 254 254 255 if (d<minDist && d<maxD) { 255 256 minDist = d; … … 264 265 if (wp!=null) { 265 266 Point p = mv.getPoint(wp.getCoor()); 266 267 267 268 g.setColor(Color.RED); 268 269 g.fillOval(p.x-10, p.y-10, 20, 20); // mark selected point … … 285 286 int pcy = s.y+p.y+30; 286 287 if (shift) {pcx+=40; pcy-=30;} 287 288 288 289 if (wp!=wpOld) { 289 290 if (oldPopup!=null) oldPopup.hide(); … … 294 295 } 295 296 infoPanel.setData(wp,trk,vel,gpxL.data.tracks); 296 Popup pp=PopupFactory.getSharedInstance().getPopup(mv, infoPanel, 297 Popup pp=PopupFactory.getSharedInstance().getPopup(mv, infoPanel, 297 298 pcx, pcy); 298 299 pp.show(); -
applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoPanel.java
r30701 r30737 1 1 package org.openstreetmap.josm.plugins.infomode; 2 2 3 import java.awt.event.MouseEvent; 4 import java.util.HashSet; 5 import java.util.Set; 6 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 7 5 import java.awt.GridBagLayout; 8 6 import java.awt.event.ActionEvent; 9 7 import java.awt.event.ActionListener; 8 import java.awt.event.MouseEvent; 10 9 import java.awt.event.MouseListener; 11 10 import java.text.DateFormat; 12 11 import java.util.Collection; 12 import java.util.HashSet; 13 13 import java.util.Locale; 14 import java.util.Set; 15 14 16 import javax.swing.BorderFactory; 15 17 import javax.swing.JButton; 16 18 import javax.swing.JLabel; 17 19 import javax.swing.JPanel; 20 18 21 import org.openstreetmap.josm.Main; 19 22 import org.openstreetmap.josm.data.gpx.GpxTrack; 23 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 20 24 import org.openstreetmap.josm.data.gpx.WayPoint; 21 25 import org.openstreetmap.josm.tools.GBC; 22 26 import org.openstreetmap.josm.tools.OpenBrowser; 23 27 24 import static org.openstreetmap.josm.tools.I18n.tr; 28 class InfoPanel extends JPanel { 25 29 26 class InfoPanel extends JPanel {27 28 30 private Collection<GpxTrack> tracks; 29 31 private GpxTrack trk; … … 38 40 private JButton but1 = new JButton(tr("Delete this")); 39 41 private JButton but2 = new JButton(tr("Delete this&older")); 40 42 41 43 public InfoPanel() { 42 44 super(new GridBagLayout()); 43 df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT, Locale.getDefault()); 45 df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT, Locale.getDefault()); 44 46 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 45 47 add(label1, GBC.eol().insets(10,0,0,0)); … … 54 56 label6.addMouseListener(new MouseListener() { 55 57 @Override 56 public void mouseClicked(MouseEvent e) { 58 public void mouseClicked(MouseEvent e) { 57 59 String s = label6.getText(); 58 OpenBrowser.displayUrl( s.substring(9, s.length()-11) ); 60 OpenBrowser.displayUrl( s.substring(9, s.length()-11) ); 59 61 } 60 public void mousePressed(MouseEvent e) { } 61 public void mouseReleased(MouseEvent e) { } 62 public void mouseEntered(MouseEvent e) { } 63 public void mouseExited(MouseEvent e) { } 62 @Override 63 public void mousePressed(MouseEvent e) { } 64 @Override 65 public void mouseReleased(MouseEvent e) { } 66 @Override 67 public void mouseEntered(MouseEvent e) { } 68 @Override 69 public void mouseExited(MouseEvent e) { } 64 70 }); 65 71 but1.addActionListener(new ActionListener() { … … 74 80 public void actionPerformed(ActionEvent e) { 75 81 if (tracks==null) return; 76 Set<GpxTrack> toRemove = new HashSet< GpxTrack>();77 82 Set<GpxTrack> toRemove = new HashSet<>(); 83 78 84 double tm=-1; 79 85 for (GpxTrackSegment seg : trk.getSegments()) { … … 82 88 } 83 89 } 84 90 85 91 for (GpxTrack track : tracks) { 86 92 boolean f=true; … … 96 102 } 97 103 }); 98 104 99 105 100 106 } … … 112 118 else label2.setText(null); 113 119 String s = (String) trk.getAttributes().get("name"); 114 if (s!=null) label3.setText(tr("Track name: ")+s); 120 if (s!=null) label3.setText(tr("Track name: ")+s); 115 121 else label3.setText(null); 116 122 s = (String) trk.getAttributes().get("desc"); … … 125 131 } else label6.setText(null); 126 132 } 127 133 128 134 }
Note:
See TracChangeset
for help on using the changeset viewer.