Changeset 26503 in osm for applications/editors/josm/plugins/infomode/src/org
- Timestamp:
- 2011-08-09T18:06:03+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoMode.java
r26399 r26503 21 21 import java.awt.Cursor; 22 22 import java.awt.Graphics2D; 23 import java.awt.Shape;24 23 import java.awt.Stroke; 25 24 import java.awt.Toolkit; … … 30 29 import java.util.HashSet; 31 30 import java.util.Set; 31 import javax.swing.JOptionPane; 32 32 import javax.swing.Popup; 33 33 import javax.swing.PopupFactory; … … 38 38 import org.openstreetmap.josm.data.gpx.GpxTrack; 39 39 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 40 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 40 41 import org.openstreetmap.josm.gui.MapFrame; 41 42 import org.openstreetmap.josm.gui.MapView; … … 73 74 if (!isEnabled()) return; 74 75 super.enterMode(); 75 76 76 mv = Main.map.mapView; 77 77 Main.map.mapView.addMouseListener(this); 78 78 Main.map.mapView.addMouseMotionListener(this); 79 79 Main.map.mapView.addTemporaryLayer(this); 80 80 /*if (!(Main.main.getActiveLayer() instanceof GpxLayer)) { 81 boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog( 82 "scan_all_layers", Main.parent, 83 tr("Please select GPX layer to view only its trackpoint info. Do you want to scan all GPX layers?"), 84 tr("Select layer to scan"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_OPTION ); 85 if(!answer) return; 86 }*/ 87 88 Main.map.statusLine.setHelpText(tr("Move the mouse to show trackpoint info for current layer. Hold shift to highlight tracks")); 89 Main.map.statusLine.repaint(); 81 90 82 91 try { … … 115 124 @Override 116 125 public void paint(Graphics2D g, MapView mv, Bounds bbox) { 117 126 if (pos==null) return; 127 Layer curL= Main.main.getActiveLayer(); 128 if (curL instanceof GpxLayer) showLayerInfo(g,curL,mv); else { 129 for (Layer l:mv.getAllLayers()) { 130 if (l instanceof GpxLayer) { 131 if (showLayerInfo(g,l,mv)) return; 132 } 133 } 134 } 135 } 136 137 @Override 138 public void eventDispatched(AWTEvent event) { 139 updateKeyModifiers((InputEvent) event); 140 if (event.getID() == KeyEvent.KEY_PRESSED) { 141 doKeyEvent((KeyEvent) event); 142 } 143 // updateStatusLine(); 144 repaint(); 145 } 146 147 @Override 148 public void mousePressed(MouseEvent e) { 149 if (!isEnabled()) return; 150 if (e.getButton() != MouseEvent.BUTTON1) return; 151 //setStatusLine(tr("Please move the mouse to draw new way")); 152 repaint(); 153 154 } 155 156 @Override 157 public void mouseReleased(MouseEvent e) { 158 if (!isEnabled()) return; 159 if (e.getButton() != MouseEvent.BUTTON1) return; 160 if (oldPopup!=null) { 161 oldPopup.hide(); 162 oldPopup=null; wpOld=null; 163 } 164 repaint(); 165 } 166 167 @Override 168 public void mouseDragged(MouseEvent e) { 169 if (oldPopup!=null) { 170 oldPopup.hide(); 171 oldPopup=null; wpOld=null; 172 } 173 } 174 175 @Override 176 public void mouseMoved(MouseEvent e) { 177 if (!isEnabled()) return; 178 pos = mv.getEastNorth(e.getX(), e.getY()); 179 repaint(); 180 } 181 182 private void doKeyEvent(KeyEvent e) { 183 /// System.out.println(e); 184 if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { 185 filterTracks(); 186 repaint(); 187 } 188 if (e.getKeyCode() == KeyEvent.VK_BACK_SLASH || 189 e.getKeyCode() == KeyEvent.VK_ENTER || 190 e.getKeyCode() == KeyEvent.VK_ESCAPE) { 191 Main.map.selectSelectTool(false); 192 } 193 } 194 195 196 /** 197 * Updates shift and ctrl key states 198 */ 199 private void updateKeyModifiers(InputEvent e) { 200 oldCtrl = ctrl; 201 oldShift = shift; 202 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 203 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 204 } 205 206 @Override 207 protected void updateStatusLine() { 208 Main.map.statusLine.setHelpText(statusText); 209 Main.map.statusLine.repaint(); 210 } 211 // </editor-fold> 212 213 214 215 private void repaint() { 216 if (Main.map!=null) Main.map.mapView.repaint(); 217 } 218 private void setStatusLine(String tr) { 219 statusText=tr; 220 updateStatusLine(); 221 } 222 223 private synchronized void filterTracks() { 118 224 Layer l = Main.main.getActiveLayer(); 119 225 120 226 if (l instanceof GpxLayer && pos!=null) { 227 GpxLayer gpxL = (GpxLayer )l; 228 Set<GpxTrack> toRemove = new HashSet<GpxTrack>(); 229 for (GpxTrack track : gpxL.data.tracks) { 230 boolean f=true; 231 sg: for (GpxTrackSegment seg : track.getSegments()) { 232 for (WayPoint S : seg.getWayPoints()) { 233 if (S.time!=0) {f=false; break sg;} 234 } 235 } 236 if (f) toRemove.add(track); 237 } 238 gpxL.data.tracks.removeAll(toRemove); 239 240 241 } 242 } 243 244 private boolean showLayerInfo(Graphics2D g, Layer l, MapView mv) { 121 245 GpxLayer gpxL = (GpxLayer )l; 122 246 … … 179 303 oldPopup=pp; 180 304 } 305 return true; 181 306 } 182 183 } 184 } 185 186 @Override 187 public void eventDispatched(AWTEvent event) { 188 updateKeyModifiers((InputEvent) event); 189 if (event.getID() == KeyEvent.KEY_PRESSED) { 190 doKeyEvent((KeyEvent) event); 191 } 192 // updateStatusLine(); 193 repaint(); 194 } 195 196 @Override 197 public void mousePressed(MouseEvent e) { 198 if (!isEnabled()) return; 199 if (e.getButton() != MouseEvent.BUTTON1) return; 200 //setStatusLine(tr("Please move the mouse to draw new way")); 201 repaint(); 202 203 } 204 205 @Override 206 public void mouseReleased(MouseEvent e) { 207 if (!isEnabled()) return; 208 if (e.getButton() != MouseEvent.BUTTON1) return; 209 if (oldPopup!=null) { 210 oldPopup.hide(); 211 oldPopup=null; wpOld=null; 212 } 213 repaint(); 214 } 215 216 @Override 217 public void mouseDragged(MouseEvent e) { 218 if (oldPopup!=null) { 219 oldPopup.hide(); 220 oldPopup=null; wpOld=null; 221 } 222 } 223 224 @Override 225 public void mouseMoved(MouseEvent e) { 226 if (!isEnabled()) return; 227 pos = mv.getEastNorth(e.getX(), e.getY()); 228 repaint(); 229 } 230 231 private void doKeyEvent(KeyEvent e) { 232 /// System.out.println(e); 233 if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) { 234 filterTracks(); 235 repaint(); 236 } 237 if (e.getKeyCode() == KeyEvent.VK_BACK_SLASH || 238 e.getKeyCode() == KeyEvent.VK_ENTER || 239 e.getKeyCode() == KeyEvent.VK_ESCAPE) { 240 Main.map.selectSelectTool(false); 241 } 242 } 243 244 245 /** 246 * Updates shift and ctrl key states 247 */ 248 private void updateKeyModifiers(InputEvent e) { 249 oldCtrl = ctrl; 250 oldShift = shift; 251 ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0; 252 shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; 253 } 254 255 @Override 256 protected void updateStatusLine() { 257 Main.map.statusLine.setHelpText(statusText); 258 Main.map.statusLine.repaint(); 259 } 260 // </editor-fold> 261 262 263 264 private void repaint() { 265 if (Main.map!=null) Main.map.mapView.repaint(); 266 } 267 private void setStatusLine(String tr) { 268 statusText=tr; 269 updateStatusLine(); 270 } 271 272 private synchronized void filterTracks() { 273 Layer l = Main.main.getActiveLayer(); 274 275 if (l instanceof GpxLayer && pos!=null) { 276 GpxLayer gpxL = (GpxLayer )l; 277 Set<GpxTrack> toRemove = new HashSet<GpxTrack>(); 278 for (GpxTrack track : gpxL.data.tracks) { 279 boolean f=true; 280 sg: for (GpxTrackSegment seg : track.getSegments()) { 281 for (WayPoint S : seg.getWayPoints()) { 282 if (S.time!=0) {f=false; break sg;} 283 } 284 } 285 if (f) toRemove.add(track); 286 } 287 gpxL.data.tracks.removeAll(toRemove); 288 289 290 } 307 return false; 291 308 } 292 309 } -
applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoModePlugin.java
r26364 r26503 5 5 * Licence: GPL v2 or later 6 6 * Author: Alexei Kasatkin, 2011 7 * Ideas by siberiano, Ilis, chnav, Polarbear-j, 7 8 */ 8 9 -
applications/editors/josm/plugins/infomode/src/org/openstreetmap/josm/plugins/infomode/InfoPanel.java
r26397 r26503 22 22 import org.openstreetmap.josm.tools.GBC; 23 23 import org.openstreetmap.josm.tools.OpenBrowser; 24 import org.openstreetmap.josm.tools.UrlLabel;25 24 26 25 import static org.openstreetmap.josm.tools.I18n.tr; … … 118 117 if (trk.getAttributes().containsKey("url")) { 119 118 label6.setText(trk.getAttributes().get("url").toString()); 120 } 119 } else label6.setText(null); 121 120 } 122 121
Note:
See TracChangeset
for help on using the changeset viewer.