Changeset 33583 in osm for applications
- Timestamp:
- 2017-08-28T14:53:38+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/FastDraw
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FastDraw/build.xml
r32738 r33583 4 4 <property name="commit.message" value="[josm_fastdraw] Fix incorrect settings saving-2"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 0657"/>6 <property name="plugin.main.version" value="12683"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java
r32738 r33583 22 22 import org.openstreetmap.josm.gui.ExtendedDialog; 23 23 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 24 import org.openstreetmap.josm.gui.datatransfer.importers.TextTagPaster; 24 25 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 25 26 import org.openstreetmap.josm.tools.GBC; … … 58 59 public void actionPerformed(ActionEvent e) { 59 60 String s = ClipboardUtils.getClipboardStringContent(); 60 if (TextTagParser.getValidatedTagsFromText(s ) != null) {61 if (TextTagParser.getValidatedTagsFromText(s, TextTagPaster::warning) != null) { 61 62 addTags.setText(s); 62 63 } -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java
r32938 r33583 33 33 import org.openstreetmap.josm.data.osm.Way; 34 34 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 35 import org.openstreetmap.josm.gui.MainApplication; 35 36 import org.openstreetmap.josm.gui.MapFrame; 36 37 import org.openstreetmap.josm.gui.MapView; … … 40 41 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 41 42 import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; 42 import org.openstreetmap.josm.gui.util.Modifier Listener;43 import org.openstreetmap.josm.gui.util.ModifierExListener; 43 44 import org.openstreetmap.josm.tools.ImageProvider; 44 45 import org.openstreetmap.josm.tools.Shortcut; 45 46 import org.openstreetmap.josm.tools.TextTagParser; 46 47 47 class FastDrawingMode extends MapMode implements MapViewPaintable, KeyPressReleaseListener, Modifier Listener {48 class FastDrawingMode extends MapMode implements MapViewPaintable, KeyPressReleaseListener, ModifierExListener { 48 49 // CHECKSTYLE.OFF: LineLength 49 50 private static final String SIMPLIFYMODE_MESSAGE = … … 79 80 super(tr("FastDrawing"), "turbopen.png", tr("Fast drawing mode"), 80 81 Shortcut.registerShortcut("mapmode:fastdraw", tr("Mode: {0}", tr("Fast drawing mode")), KeyEvent.VK_F, Shortcut.SHIFT), 81 mapFrame,Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));82 Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 82 83 line = new DrawnPolyLine(); 83 84 cursorDraw = ImageProvider.getCursor("crosshair", null); … … 100 101 settings.savePrefs(); 101 102 103 MapFrame map = MainApplication.getMap(); 102 104 eps = settings.startingEps; 103 mv = Main.map.mapView;105 mv = map.mapView; 104 106 line.setMv(mv); 105 107 106 108 if (getLayerManager().getEditDataSet() == null) return; 107 109 108 Main.map.mapView.addMouseListener(this);109 Main.map.mapView.addMouseMotionListener(this);110 Main.map.mapView.addTemporaryLayer(this);111 112 Main.map.keyDetector.addKeyListener(this);113 Main.map.keyDetector.addModifierListener(this);110 map.mapView.addMouseListener(this); 111 map.mapView.addMouseMotionListener(this); 112 map.mapView.addTemporaryLayer(this); 113 114 map.keyDetector.addKeyListener(this); 115 map.keyDetector.addModifierExListener(this); 114 116 } 115 117 … … 118 120 super.exitMode(); 119 121 if (line.wasSimplified() && !lineWasSaved) saveAsWay(false); 120 121 Main.map.mapView.removeMouseListener(this); 122 Main.map.mapView.removeMouseMotionListener(this); 123 124 Main.map.mapView.removeTemporaryLayer(this); 125 126 Main.map.keyDetector.removeKeyListener(this); 127 Main.map.keyDetector.removeModifierListener(this); 122 MapFrame map = MainApplication.getMap(); 123 124 map.mapView.removeMouseListener(this); 125 map.mapView.removeMouseMotionListener(this); 126 127 map.mapView.removeTemporaryLayer(this); 128 129 map.keyDetector.removeKeyListener(this); 130 map.keyDetector.removeModifierExListener(this); 128 131 129 132 settings.savePrefs(); 130 Main.map.mapView.setCursor(cursorDraw);133 map.mapView.setCursor(cursorDraw); 131 134 repaint(); 132 135 } … … 467 470 } 468 471 newDrawing(); // stop drawing 469 Main .map.selectSelectTool(false);472 MainApplication.getMap().selectSelectTool(false); 470 473 } 471 474 break; … … 491 494 e.consume(); 492 495 if (!drawing) { 493 Point p = Main .map.mapView.getMousePosition();496 Point p = MainApplication.getMap().mapView.getMousePosition(); 494 497 if (p != null) startDrawing(p, settings.fixedSpacebar); 495 498 } … … 506 509 507 510 @Override 508 public void modifiers Changed(int modifiers) {509 updateKeyModifiers (modifiers);511 public void modifiersExChanged(int modifiers) { 512 updateKeyModifiersEx(modifiers); 510 513 updateCursor(); 511 514 } … … 513 516 @Override 514 517 protected void updateStatusLine() { 515 Main .map.statusLine.setHelpText(statusText);516 Main .map.statusLine.repaint();518 MainApplication.getMap().statusLine.setHelpText(statusText); 519 MainApplication.getMap().statusLine.repaint(); 517 520 } 518 521 // </editor-fold> … … 547 550 548 551 for (LatLon p : pts) { 549 Node nd = Main .map.mapView.getNearestNode(line.getPoint(p), OsmPrimitive::isSelectable);552 Node nd = MainApplication.getMap().mapView.getNearestNode(line.getPoint(p), OsmPrimitive::isSelectable); 550 553 // there may be a node with the same coords! 551 554 … … 595 598 Command c = new SequenceCommand(tr("Draw the way by mouse"), cmds); 596 599 if (getLayerManager().getEditLayer() == null) return; 597 Main .main.undoRedo.add(c);600 MainApplication.undoRedo.add(c); 598 601 lineWasSaved = true; 599 602 newDrawing(); // stop drawing … … 601 604 // Select this way and switch drawing mode off 602 605 getLayerManager().getEditDataSet().setSelected(w); 603 Main .map.selectSelectTool(false);606 MainApplication.getMap().selectSelectTool(false); 604 607 } 605 608 } … … 676 679 677 680 private void updateCursor() { 678 if (shift) Main.map.mapView.setCursor(cursorShift); else 679 if (line.isClosed() || (nearestPointIndex == 0)) Main.map.mapView.setCursor(cursorReady); else 680 if (ctrl) Main.map.mapView.setCursor(cursorCtrl); else 681 if (nearSomeNode && settings.snapNodes) Main.map.mapView.setCursor(cursorCtrl); else 682 if (drawing) Main.map.mapView.setCursor(cursorDrawing); else 683 Main.map.mapView.setCursor(cursorDraw); 681 MapView mapView = MainApplication.getMap().mapView; 682 if (shift) mapView.setCursor(cursorShift); else 683 if (line.isClosed() || (nearestPointIndex == 0)) mapView.setCursor(cursorReady); else 684 if (ctrl) mapView.setCursor(cursorCtrl); else 685 if (nearSomeNode && settings.snapNodes) mapView.setCursor(cursorCtrl); else 686 if (drawing) mapView.setCursor(cursorDrawing); else 687 mapView.setCursor(cursorDraw); 684 688 } 685 689 686 690 private void repaint() { 687 Main .map.mapView.repaint();691 MainApplication.getMap().mapView.repaint(); 688 692 } 689 693 690 694 private void tryToLoadWay() { 691 695 updateCursor(); 692 Collection<Way> selectedWays = Main .getLayerManager().getEditDataSet().getSelectedWays();696 Collection<Way> selectedWays = MainApplication.getLayerManager().getEditDataSet().getSelectedWays(); 693 697 if (selectedWays != null // if there is a selection 694 698 && selectedWays.size() == 1 // and one way is selected … … 711 715 712 716 private Node getNearestNode(Point point, double maxDist) { 713 Node nd = Main .map.mapView.getNearestNode(point, OsmPrimitive::isSelectable);717 Node nd = MainApplication.getMap().mapView.getNearestNode(point, OsmPrimitive::isSelectable); 714 718 if (nd != null && line.getPoint(nd.getCoor()).distance(point) <= maxDist) return nd; 715 719 else return null; -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingPlugin.java
r32548 r33583 2 2 package org.openstreetmap.josm.plugins.fastdraw; 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.plugins.Plugin; … … 17 17 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 18 18 if (oldFrame == null && newFrame != null) { 19 Main .map.addMapMode(new IconToggleButton(new FastDrawingMode(Main.map)));19 MainApplication.getMap().addMapMode(new IconToggleButton(new FastDrawingMode(MainApplication.getMap()))); 20 20 } 21 21 }
Note:
See TracChangeset
for help on using the changeset viewer.