Changeset 33534 in osm
- Timestamp:
- 2017-08-26T02:27:13+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/splinex
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/splinex/build.xml
r32680 r33534 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 0580"/>7 <property name="plugin.main.version" value="12663"/> 8 8 9 9 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/DrawSplineAction.java
r33140 r33534 29 29 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings; 30 30 import org.openstreetmap.josm.data.preferences.ColorProperty; 31 import org.openstreetmap.josm.gui.MainApplication; 31 32 import org.openstreetmap.josm.gui.MapFrame; 32 33 import org.openstreetmap.josm.gui.MapView; … … 41 42 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 42 43 import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; 43 import org.openstreetmap.josm.gui.util.Modifier Listener;44 import org.openstreetmap.josm.gui.util.ModifierExListener; 44 45 import org.openstreetmap.josm.plugins.Splinex.Spline.PointHandle; 45 46 import org.openstreetmap.josm.plugins.Splinex.Spline.SplinePoint; 46 47 import org.openstreetmap.josm.tools.ImageProvider; 48 import org.openstreetmap.josm.tools.Logging; 47 49 import org.openstreetmap.josm.tools.Shortcut; 48 50 49 51 @SuppressWarnings("serial") 50 public class DrawSplineAction extends MapMode implements MapViewPaintable, KeyPressReleaseListener, Modifier Listener,52 public class DrawSplineAction extends MapMode implements MapViewPaintable, KeyPressReleaseListener, ModifierExListener, 51 53 LayerChangeListener, ActiveLayerChangeListener { 52 54 private final Cursor cursorJoinNode; … … 64 66 "spline2", // icon name 65 67 tr("Draw a spline curve"), // tooltip 66 mapFrame,getCursor());68 getCursor()); 67 69 68 70 backspaceShortcut = Shortcut.registerShortcut("mapmode:backspace", tr("Backspace in Add mode"), … … 71 73 cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode"); 72 74 cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway"); 73 Main .getLayerManager().addLayerChangeListener(this);74 Main .getLayerManager().addActiveLayerChangeListener(this);75 MainApplication.getLayerManager().addLayerChangeListener(this); 76 MainApplication.getLayerManager().addActiveLayerChangeListener(this); 75 77 readPreferences(); 76 78 } … … 80 82 return ImageProvider.getCursor("crosshair", "spline"); 81 83 } catch (Exception e) { 82 Main.error(e);84 Logging.error(e); 83 85 } 84 86 return Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR); … … 91 93 super.enterMode(); 92 94 93 Main.registerActionShortcut(backspaceAction, backspaceShortcut); 94 95 Main.map.mapView.addMouseListener(this); 96 Main.map.mapView.addMouseMotionListener(this); 97 Main.map.mapView.addTemporaryLayer(this); 98 99 Main.map.keyDetector.addModifierListener(this); 100 Main.map.keyDetector.addKeyListener(this); 95 MainApplication.registerActionShortcut(backspaceAction, backspaceShortcut); 96 97 MapFrame map = MainApplication.getMap(); 98 map.mapView.addMouseListener(this); 99 map.mapView.addMouseMotionListener(this); 100 map.mapView.addTemporaryLayer(this); 101 102 map.keyDetector.addModifierExListener(this); 103 map.keyDetector.addKeyListener(this); 101 104 } 102 105 … … 115 118 public void exitMode() { 116 119 super.exitMode(); 117 Main.map.mapView.removeMouseListener(this); 118 Main.map.mapView.removeMouseMotionListener(this); 119 Main.map.mapView.removeTemporaryLayer(this); 120 Main.unregisterActionShortcut(backspaceAction, backspaceShortcut); 121 122 Main.map.statusLine.activateAnglePanel(false); 123 Main.map.keyDetector.removeModifierListener(this); 124 Main.map.keyDetector.removeKeyListener(this); 120 MapFrame map = MainApplication.getMap(); 121 map.mapView.removeMouseListener(this); 122 map.mapView.removeMouseMotionListener(this); 123 map.mapView.removeTemporaryLayer(this); 124 MainApplication.unregisterActionShortcut(backspaceAction, backspaceShortcut); 125 126 map.statusLine.activateAnglePanel(false); 127 map.keyDetector.removeModifierExListener(this); 128 map.keyDetector.removeKeyListener(this); 125 129 removeHighlighting(); 126 Main.map.mapView.repaint();127 } 128 129 @Override 130 public void modifiers Changed(int modifiers) {131 updateKeyModifiers (modifiers);130 map.mapView.repaint(); 131 } 132 133 @Override 134 public void modifiersExChanged(int modifiers) { 135 updateKeyModifiersEx(modifiers); 132 136 } 133 137 … … 150 154 return; 151 155 } 152 if (!Main .map.mapView.isActiveLayerDrawable()) return;156 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) return; 153 157 Spline spl = getSpline(); 154 158 if (spl == null) return; … … 157 161 dragSpline = false; 158 162 mouseDownTime = System.currentTimeMillis(); 159 ph = spl.getNearestPoint(Main .map.mapView, e.getPoint());163 ph = spl.getNearestPoint(MainApplication.getMap().mapView, e.getPoint()); 160 164 if (e.getClickCount() == 2) { 161 165 if (!spl.isClosed() && spl.nodeCount() > 1 && ph != null && ph.point == SplinePoint.ENDPOINT 162 166 && ((ph.idx == 0 && direction == 1) || (ph.idx == spl.nodeCount() - 1 && direction == -1))) { 163 Main .main.undoRedo.add(spl.new CloseSplineCommand());167 MainApplication.undoRedo.add(spl.new CloseSplineCommand()); 164 168 return; 165 169 } 166 170 spl.finishSpline(); 167 Main .map.repaint();171 MainApplication.getMap().repaint(); 168 172 return; 169 173 } … … 181 185 + ph.sn.cnext.north()) < EPSILON); 182 186 } 183 if (ph.point == SplinePoint.ENDPOINT && !Main .main.undoRedo.commands.isEmpty()) {184 Command cmd = Main .main.undoRedo.commands.getLast();187 if (ph.point == SplinePoint.ENDPOINT && !MainApplication.undoRedo.commands.isEmpty()) { 188 Command cmd = MainApplication.undoRedo.commands.getLast(); 185 189 if (cmd instanceof MoveCommand) { 186 190 mc = (MoveCommand) cmd; … … 192 196 } 193 197 } 194 if (ph.point != SplinePoint.ENDPOINT && !Main .main.undoRedo.commands.isEmpty()) {195 Command cmd = Main .main.undoRedo.commands.getLast();198 if (ph.point != SplinePoint.ENDPOINT && !MainApplication.undoRedo.commands.isEmpty()) { 199 Command cmd = MainApplication.undoRedo.commands.getLast(); 196 200 if (!(cmd instanceof Spline.EditSplineCommand && ((Spline.EditSplineCommand) cmd).sn == ph.sn)) 197 201 dragControl = true; … … 199 203 return; 200 204 } 201 if (!ctrl && spl.doesHit(e.getX(), e.getY(), Main .map.mapView)) {205 if (!ctrl && spl.doesHit(e.getX(), e.getY(), MainApplication.getMap().mapView)) { 202 206 dragSpline = true; 203 207 return; … … 212 216 boolean existing = false; 213 217 if (!ctrl) { 214 n = Main .map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable);218 n = MainApplication.getMap().mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable); 215 219 existing = true; 216 220 } 217 221 if (n == null) { 218 n = new Node(Main .map.mapView.getLatLon(e.getX(), e.getY()));222 n = new Node(MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY())); 219 223 existing = false; 220 224 } 221 225 int idx = direction == -1 ? 0 : spl.nodeCount(); 222 Main .main.undoRedo.add(spl.new AddSplineNodeCommand(new Spline.SNode(n), existing, idx));226 MainApplication.undoRedo.add(spl.new AddSplineNodeCommand(new Spline.SNode(n), existing, idx)); 223 227 ph = spl.new PointHandle(idx, direction == -1 ? SplinePoint.CONTROL_PREV : SplinePoint.CONTROL_NEXT); 224 228 lockCounterpart = true; 225 Main .map.repaint();229 MainApplication.getMap().repaint(); 226 230 } 227 231 … … 245 249 updateKeyModifiers(e); 246 250 if (mouseDownTime == null) return; 247 if (!Main .map.mapView.isActiveLayerDrawable()) return;251 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) return; 248 252 if (System.currentTimeMillis() - mouseDownTime < initialMoveDelay) return; 249 253 Spline spl = getSpline(); … … 252 256 if (clickPos != null && clickPos.distanceSq(e.getPoint()) < initialMoveThreshold) 253 257 return; 254 EastNorth en = Main .map.mapView.getEastNorth(e.getX(), e.getY());258 EastNorth en = MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()); 255 259 if (Main.getProjection().eastNorth2latlon(en).isOutSideWorld()) 256 260 return; 257 261 if (dragSpline) { 258 262 if (mc == null) { 259 mc = new MoveCommand(spl.getNodes(), Main .map.mapView.getEastNorth(clickPos.x, clickPos.y), en);260 Main .main.undoRedo.add(mc);263 mc = new MoveCommand(spl.getNodes(), MainApplication.getMap().mapView.getEastNorth(clickPos.x, clickPos.y), en); 264 MainApplication.undoRedo.add(mc); 261 265 clickPos = null; 262 266 } else 263 267 mc.applyVectorTo(en); 264 Main .map.repaint();268 MainApplication.getMap().repaint(); 265 269 return; 266 270 } … … 270 274 if (mc == null) { 271 275 mc = new MoveCommand(ph.sn.node, ph.sn.node.getEastNorth(), en); 272 Main .main.undoRedo.add(mc);276 MainApplication.undoRedo.add(mc); 273 277 } else 274 278 mc.applyVectorTo(en); 275 279 } else { 276 280 if (dragControl) { 277 Main .main.undoRedo.add(new Spline.EditSplineCommand(ph.sn));281 MainApplication.undoRedo.add(new Spline.EditSplineCommand(ph.sn)); 278 282 dragControl = false; 279 283 } … … 286 290 } 287 291 } 288 Main .map.repaint();292 MainApplication.getMap().repaint(); 289 293 } 290 294 … … 295 299 public void mouseMoved(MouseEvent e) { 296 300 updateKeyModifiers(e); 297 if (!Main .map.mapView.isActiveLayerDrawable()) return;301 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) return; 298 302 Spline spl = getSpline(); 299 303 if (spl == null) return; … … 301 305 PointHandle oldph = ph; 302 306 boolean redraw = false; 303 ph = spl.getNearestPoint(Main .map.mapView, e.getPoint());307 ph = spl.getNearestPoint(MainApplication.getMap().mapView, e.getPoint()); 304 308 if (ph == null) 305 if (!ctrl && spl.doesHit(e.getX(), e.getY(), Main .map.mapView)) {309 if (!ctrl && spl.doesHit(e.getX(), e.getY(), MainApplication.getMap().mapView)) { 306 310 helperEndpoint = null; 307 Main .map.mapView.setNewCursor(Cursor.MOVE_CURSOR, this);311 MainApplication.getMap().mapView.setNewCursor(Cursor.MOVE_CURSOR, this); 308 312 } else { 309 313 Node n = null; 310 314 if (!ctrl) 311 n = Main .map.mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable);315 n = MainApplication.getMap().mapView.getNearestNode(e.getPoint(), OsmPrimitive::isUsable); 312 316 if (n == null) { 313 317 redraw = removeHighlighting(); 314 318 helperEndpoint = e.getPoint(); 315 Main .map.mapView.setNewCursor(cursor, this);319 MainApplication.getMap().mapView.setNewCursor(cursor, this); 316 320 } else { 317 321 redraw = setHighlight(n); 318 Main .map.mapView.setNewCursor(cursorJoinNode, this);319 helperEndpoint = Main .map.mapView.getPoint(n);322 MainApplication.getMap().mapView.setNewCursor(cursorJoinNode, this); 323 helperEndpoint = MainApplication.getMap().mapView.getPoint(n); 320 324 } 321 325 } 322 326 else { 323 327 helperEndpoint = null; 324 Main .map.mapView.setNewCursor(cursorJoinWay, this);328 MainApplication.getMap().mapView.setNewCursor(cursorJoinWay, this); 325 329 if (ph.point == SplinePoint.ENDPOINT) 326 330 redraw = setHighlight(ph.sn.node); … … 333 337 if (redraw || oldHelperEndpoint != helperEndpoint || (oldph == null && ph != null) 334 338 || (oldph != null && !oldph.equals(ph))) 335 Main .map.repaint();339 MainApplication.getMap().repaint(); 336 340 } 337 341 … … 341 345 @Override 342 346 public void mouseExited(MouseEvent e) { 343 if (!Main .map.mapView.isActiveLayerDrawable())347 if (!MainApplication.getMap().mapView.isActiveLayerDrawable()) 344 348 return; 345 349 removeHighlighting(); 346 350 helperEndpoint = null; 347 Main .map.mapView.repaint();351 MainApplication.getMap().mapView.repaint(); 348 352 } 349 353 … … 396 400 @Override 397 401 public void actionPerformed(ActionEvent e) { 398 Main .main.undoRedo.undo();402 MainApplication.undoRedo.undo(); 399 403 } 400 404 } … … 417 421 @Override 418 422 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 419 splCached = layerSplines.get(Main .getLayerManager().getActiveLayer());423 splCached = layerSplines.get(MainApplication.getLayerManager().getActiveLayer()); 420 424 } 421 425 … … 444 448 if (spl.nodeCount() == 3 && spl.isClosed() && ph.idx == 1) 445 449 return; // Don't allow to delete node when it results with two-node closed spline 446 Main .main.undoRedo.add(spl.new DeleteSplineNodeCommand(ph.idx));450 MainApplication.undoRedo.add(spl.new DeleteSplineNodeCommand(ph.idx)); 447 451 e.consume(); 448 452 } 449 453 if (e.getKeyCode() == KeyEvent.VK_ESCAPE && direction != 0) { 450 454 direction = 0; 451 Main .map.mapView.repaint();455 MainApplication.getMap().mapView.repaint(); 452 456 e.consume(); 453 457 } -
applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/Spline.java
r32917 r33534 28 28 import org.openstreetmap.josm.command.SequenceCommand; 29 29 import org.openstreetmap.josm.data.coor.EastNorth; 30 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 30 31 import org.openstreetmap.josm.data.osm.Node; 31 32 import org.openstreetmap.josm.data.osm.OsmPrimitive; 32 33 import org.openstreetmap.josm.data.osm.Way; 33 34 import org.openstreetmap.josm.data.preferences.IntegerProperty; 34 import org.openstreetmap.josm.gui. DefaultNameFormatter;35 import org.openstreetmap.josm.gui.MainApplication; 35 36 import org.openstreetmap.josm.gui.MapView; 36 37 import org.openstreetmap.josm.gui.NavigatableComponent; … … 273 274 if (!cmds.isEmpty()) 274 275 cmds.add(new AddCommand(w)); 275 Main .main.undoRedo.add(new FinishSplineCommand(cmds));276 MainApplication.undoRedo.add(new FinishSplineCommand(cmds)); 276 277 } 277 278 -
applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/SplineHitTest.java
r33172 r33534 3 3 4 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.tools.Logging; 5 6 6 7 public class SplineHitTest { … … 29 30 } 30 31 public boolean checkCurve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, int depth) { 31 if ( Main.isDebugEnabled()) {32 Main.debug("checkCurve {0} {1} {2} {3} {4} {5} {6} {7}", x1, y1, x2, y2, x3, y3, x4, y4);32 if (Logging.isDebugEnabled()) { 33 Logging.debug("checkCurve {0} {1} {2} {3} {4} {5} {6} {7}", x1, y1, x2, y2, x3, y3, x4, y4); 33 34 } 34 35 //chkCnt++; -
applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/SplinexPlugin.java
r32547 r33534 2 2 package org.openstreetmap.josm.plugins.Splinex; 3 3 4 import org.openstreetmap.josm.Main;5 4 import org.openstreetmap.josm.gui.IconToggleButton; 5 import org.openstreetmap.josm.gui.MainApplication; 6 6 import org.openstreetmap.josm.gui.MapFrame; 7 7 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; … … 26 26 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 27 27 if (oldFrame == null && newFrame != null) { // map frame added 28 Main.map.addMapMode(new IconToggleButton(new DrawSplineAction(Main.map))); 28 MapFrame map = MainApplication.getMap(); 29 map.addMapMode(new IconToggleButton(new DrawSplineAction(map))); 29 30 } 30 31 } -
applications/editors/josm/plugins/splinex/src/org/openstreetmap/josm/plugins/Splinex/UndeleteNodeCommand.java
r33172 r33534 7 7 8 8 import org.openstreetmap.josm.command.Command; 9 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 9 10 import org.openstreetmap.josm.data.osm.Node; 10 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.gui.DefaultNameFormatter;12 12 13 13 class UndeleteNodeCommand extends Command {
Note:
See TracChangeset
for help on using the changeset viewer.