Changeset 29453 in osm for applications/editors/josm/plugins/FastDraw
- Timestamp:
- 2013-04-01T18:02:44+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java
r29263 r29453 9 9 import java.util.Set; 10 10 import org.openstreetmap.josm.data.coor.LatLon; 11 import org.openstreetmap.josm.data.osm.OsmPrimitive;12 11 import org.openstreetmap.josm.gui.MapView; 13 12 … … 94 93 95 94 void addFixed(LatLon coor) { 96 95 addLast(coor); 97 96 fixed.add(coor); 98 97 } … … 100 99 if (closedFlag && lastIdx>points.size()-1) return; 101 100 if (lastIdx>=points.size()-1) { 102 //System.out.println("add last "+points.size()); 103 points.addLast(coor);if (points.size()>1) lastIdx++; 104 //System.out.println("lastIdx="+lastIdx); 105 } 106 else {points.add(lastIdx+1, coor); lastIdx++; 107 //System.out.println("add at "+lastIdx+"/"+points.size()); 101 // 102 if (points.isEmpty() || !coor.equals(points.getLast())) { 103 points.addLast(coor); 104 if (points.size()>1) lastIdx++; 105 } 106 } else { 107 // insert point into midlle of the line 108 if (points.isEmpty() || !coor.equals(points.get(lastIdx))) { 109 points.add(lastIdx+1, coor); 110 lastIdx++; 111 } 108 112 } 109 113 } -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FDSettings.java
r29303 r29453 50 50 //deltaLatLon = Main.pref.getDouble("fastdraw.deltasearch", 0.01); 51 51 minPixelsBetweenPoints = Main.pref.getDouble("fastdraw.mindelta", 20); 52 startingEps = Main.pref.getDouble("fastdraw.startingEps", 0.1);53 maxPointsPerKm = Main.pref.getDouble("fastdraw.maxpkm", 20);52 startingEps = Main.pref.getDouble("fastdraw.startingEps", 5); 53 maxPointsPerKm = Main.pref.getDouble("fastdraw.maxpkm", 150); 54 54 pkmBlockSize = Main.pref.getInteger("fastdraw.pkmblocksize", 10); 55 55 drawLastSegment = Main.pref.getBoolean("fastdraw.drawlastsegment", true); -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java
r29317 r29453 1 /*2 * To change this template, choose Tools | Templates3 * and open the template in the editor.4 */5 1 package org.openstreetmap.josm.plugins.fastdraw; 6 2 -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java
r29303 r29453 1 1 /* 2 * This file is part of ImproveWayAccuracy plugin for JOSM.3 * http://wiki.openstreetmap.org/wiki/JOSM/Plugins/ImproveWayAccuracy4 *5 2 * Licence: GPL v2 or later 6 3 * Author: Alexei Kasatkin, 2011 … … 13 10 import java.awt.BasicStroke; 14 11 import java.awt.Color; 15 import java.awt.Point;16 import java.awt.event.MouseEvent;17 import org.openstreetmap.josm.data.coor.LatLon;18 import org.openstreetmap.josm.data.osm.Tag;19 import static org.openstreetmap.josm.tools.I18n.tr;20 21 12 import java.awt.Cursor; 22 13 import java.awt.Graphics2D; 14 import java.awt.Point; 23 15 import java.awt.Stroke; 24 16 import java.awt.Toolkit; 25 import java.awt.event.AWTEventListener; 26 import java.awt.event.ActionEvent; 27 import java.awt.event.ActionListener; 28 import java.awt.event.InputEvent; 29 import java.awt.event.KeyEvent; 17 import java.awt.event.*; 30 18 import java.util.*; 31 19 import javax.swing.JOptionPane; … … 40 28 import org.openstreetmap.josm.command.SequenceCommand; 41 29 import org.openstreetmap.josm.data.Bounds; 30 import org.openstreetmap.josm.data.coor.LatLon; 31 import org.openstreetmap.josm.data.osm.Tag; 42 32 import org.openstreetmap.josm.data.osm.Node; 43 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 52 42 import org.openstreetmap.josm.tools.Shortcut; 53 43 import org.openstreetmap.josm.tools.TextTagParser; 44 45 import static org.openstreetmap.josm.tools.I18n.tr; 54 46 55 47 class FastDrawingMode extends MapMode implements MapViewPaintable, … … 91 83 private boolean lineWasSaved; 92 84 private boolean deltaChanged; 93 private final int mainKeyCode; 85 /** 86 * used for skipping keyboard AWTTevents while dialogs are active 87 */ 88 private boolean listenKeys = false; 94 89 95 90 FastDrawingMode(MapFrame mapFrame) { … … 105 100 cursorDrawing = ImageProvider.getCursor("crosshair", "mode"); 106 101 //loadPrefs(); 107 mainKeyCode = getShortcut().getKeyStroke().getKeyCode();108 102 } 109 103 … … 147 141 }); 148 142 143 listenKeys = true; 149 144 try { 150 145 Toolkit.getDefaultToolkit().addAWTEventListener(this, … … 265 260 @Override 266 261 public void eventDispatched(AWTEvent event) { 267 if ( Main.map == null || Main.map.mapView == null262 if (!listenKeys || Main.map == null || Main.map.mapView == null 268 263 || !Main.map.mapView.isActiveLayerDrawable()) { 269 264 return; … … 485 480 break; 486 481 case KeyEvent.VK_ESCAPE: 487 // less details488 482 e.consume(); 489 483 Point lastPoint = line.getLastPoint(); … … 491 485 if (lastPoint==null || lastPoint.equals(line.getLastPoint())) { 492 486 if (line.getPoints().size()>5) { 493 boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog( 494 "delete_drawn_line", Main.parent, 495 tr("Are you sure you do not want to save the line containing {0} points?", 496 line.getPoints().size()), tr("Delete confirmation"), 497 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_OPTION ); 498 if(!answer) break; 487 // no key events while the dialog is active! 488 listenKeys = false; 489 boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog( 490 "delete_drawn_line", Main.parent, 491 tr("Are you sure you do not want to save the line containing {0} points?", 492 line.getPoints().size()), tr("Delete confirmation"), 493 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_OPTION ); 494 listenKeys = true; 495 if(!answer) break; 499 496 } 500 497 newDrawing(); // stop drawing … … 505 502 506 503 case KeyEvent.VK_I: 504 listenKeys = false; 507 505 JOptionPane.showMessageDialog(Main.parent, 508 506 tr("{0} m - length of the line\n{1} nodes\n{2} points per km (maximum)\n{3} points per km (average)", … … 510 508 line.getNodesPerKm(1000000)), 511 509 tr("Line information"),JOptionPane.INFORMATION_MESSAGE); 510 listenKeys = true; 512 511 break; 513 512 case KeyEvent.VK_Q: … … 515 514 e.consume(); 516 515 try { 517 Toolkit.getDefaultToolkit().removeAWTEventListener(this);516 listenKeys = false; 518 517 new FastDrawConfigDialog(settings); 519 518 if (line.wasSimplified()) { … … 522 521 } 523 522 //System.out.println("final eps="+eps); 524 Toolkit.getDefaultToolkit().addAWTEventListener(this, 525 AWTEvent.KEY_EVENT_MASK); 523 listenKeys = true; 526 524 } catch (SecurityException ex) { } 527 525 repaint(); … … 560 558 // <editor-fold defaultstate="collapsed" desc="Different action helper methods"> 561 559 public void newDrawing() { 560 if (delCmd!=null) delCmd.undoCommand(); 562 561 delCmd=null; oldNodes=null; 563 562 eps=settings.startingEps; … … 580 579 for (LatLon p : pts) { 581 580 Node nd=null; 582 //if (line.isFixed(p)) {583 // there may be a node with same ccoords!584 nd = Main.map.mapView.getNearestNode(line.getPoint(p), OsmPrimitive.isSelectablePredicate);585 //}586 if (nd!=null ) if (p.greatCircleDistance(nd.getCoor())>0.01) nd=null;581 582 nd = Main.map.mapView.getNearestNode(line.getPoint(p), OsmPrimitive.isSelectablePredicate); 583 // there may be a node with the same coords! 584 585 if (nd!=null && p.greatCircleDistance(nd.getCoor())>0.01) nd=null; 587 586 if (nd==null) { 588 587 if (i>0 && p.equals(first)) nd=firstNode; else { … … 627 626 } 628 627 } 628 delCmd = null; // that is all with this command 629 629 cmds.add(new AddCommand(w)); 630 630 } else cmds.add(new AddCommand(w)); -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingPlugin.java
r26440 r29453 1 1 /* 2 * This file is part of ImproveWayAccuracy plugin for JOSM.3 * http://wiki.openstreetmap.org/wiki/JOSM/Plugins/ImproveWayAccuracy4 *5 2 * Licence: GPL v2 or later 6 3 * Author: Alexei Kasatkin, 2011
Note:
See TracChangeset
for help on using the changeset viewer.