Changeset 26264 in osm
- Timestamp:
- 2011-07-05T19:52:57+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java
r26111 r26264 99 99 Point getPoint(LatLon p) { 100 100 return mv.getPoint(p); 101 } 102 103 int getSimplePointsCount() { 104 if (simplePoints!=null)return simplePoints.size(); else return -1; 101 105 } 102 106 -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java
r26163 r26264 57 57 tr("Click or Click&drag to continue, Ctrl-Click to add fixed node, Shift-Click to delete, Enter to simplify or save, Ctrl-Shift-Click to start new line"); 58 58 59 private Color COLOR_FIXED; 60 private Color COLOR_NORMAL; 61 private Color COLOR_DELETE; 62 private Color COLOR_SELECTEDFRAGMENT; 63 private Color COLOR_EDITEDFRAGMENT; 64 65 private double maxDist; 66 private double epsilonMult; 67 //private double deltaLatLon; 68 /// When drawing line, distance between points will be this 69 private double minPixelsBetweenPoints; 70 /// Initial tolerance for Douglas-Pecker algorithm 71 private double startingEps; 59 private FDSettings settings; 72 60 73 61 private DrawnPolyLine line; … … 96 84 FastDrawingMode(MapFrame mapFrame) { 97 85 super(tr("FastDrawing"), "turbopen.png", tr("Fast drawing mode"), Shortcut.registerShortcut( 98 "mapmode :FastDraw",86 "mapmode/building", 99 87 tr("Mode: {0}", tr("Fast drawing mode")), 100 88 KeyEvent.VK_T, Shortcut.GROUP_EDIT), mapFrame, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); … … 118 106 if (!isEnabled()) return; 119 107 super.enterMode(); 120 loadPrefs(); 108 settings=new FDSettings(); 109 settings.loadPrefs(); 110 settings.savePrefs(); 111 112 eps=settings.startingEps; 121 113 mv = Main.map.mapView; 122 114 line.setMv(mv); … … 150 142 } catch (SecurityException ex) { 151 143 } 152 s avePrefs();144 settings.savePrefs(); 153 145 Main.map.mapView.setCursor(cursorDraw); 154 146 repaint(); … … 182 174 LatLon pp1, pp2; 183 175 p1 = line.getPoint(pts.get(0)); 184 g.setColor( COLOR_FIXED);176 g.setColor(settings.COLOR_FIXED); 185 177 g.fillOval(p1.x - 3, p1.y - 3, 7, 7); 186 Color lineColor= COLOR_NORMAL;178 Color lineColor=settings.COLOR_NORMAL; 187 179 if (pts.size() > 1) { 188 180 Iterator<LatLon> it1,it2; … … 194 186 pp2 = it2.next(); 195 187 p2 = line.getPoint(pp2); 196 if (shift && highlighted==pp1 && nearestIdx<0) {lineColor= COLOR_SELECTEDFRAGMENT;}197 if (!shift && line.isLastPoint(i)) { lineColor= COLOR_EDITEDFRAGMENT; }188 if (shift && highlighted==pp1 && nearestIdx<0) {lineColor=settings.COLOR_SELECTEDFRAGMENT;} 189 if (!shift && line.isLastPoint(i)) { lineColor=settings.COLOR_EDITEDFRAGMENT; } 198 190 g.setColor(lineColor); 199 191 g.drawLine(p1.x, p1.y, p2.x, p2.y); 200 192 // g.fillOval(p2.x - 5, p2.y - 5, 11, 11); 201 193 if (line.isFixed(pp2)) { 202 lineColor= COLOR_NORMAL;203 g.setColor( COLOR_FIXED);194 lineColor=settings.COLOR_NORMAL; 195 g.setColor(settings.COLOR_FIXED); 204 196 g.fillOval(p2.x - 3, p2.y - 3, 7, 7); 205 197 } else { … … 210 202 // highlight node to delete 211 203 g.setStroke(strokeForDelete); 212 g.setColor( COLOR_DELETE);204 g.setColor(settings.COLOR_DELETE); 213 205 g.drawLine(p2.x - 5, p2.y - 5,p2.x + 5, p2.y + 5); 214 206 g.drawLine(p2.x - 5, p2.y + 5,p2.x + 5, p2.y - 5); … … 218 210 // highlight node to toggle fixation 219 211 g.setStroke(strokeForDelete); 220 g.setColor( line.isFixed(pp2) ? COLOR_NORMAL:COLOR_FIXED);212 g.setColor( line.isFixed(pp2) ? settings.COLOR_NORMAL: settings.COLOR_FIXED); 221 213 g.drawOval(p2.x - 5, p2.y - 5, 11, 11); 222 214 g.setStroke(strokeForOriginal); … … 248 240 249 241 250 int idx=line.findClosestPoint(e.getPoint(), maxDist);242 int idx=line.findClosestPoint(e.getPoint(),settings.maxDist); 251 243 if (idx==0 && !line.isClosed()) { 252 244 line.closeLine(); … … 258 250 } 259 251 260 if (ctrl && shift) newDrawing();252 if (ctrl && shift) {newDrawing();repaint();return;} 261 253 if (!ctrl && shift) { 262 254 if (idx>=0) {line.deleteNode(idx); nearestIdx=-1;} … … 278 270 279 271 LatLon p = getLatLon(e); 280 Node nd1 = getNearestNode(e.getPoint(), maxDist);272 Node nd1 = getNearestNode(e.getPoint(), settings.maxDist); 281 273 if (nd1!=null) { 282 274 // found node, make it fixed point of the line … … 314 306 public void mouseMoved(MouseEvent e) { 315 307 if (!isEnabled()) return; 316 Node nd1 = getNearestNode(e.getPoint(), maxDist);308 Node nd1 = getNearestNode(e.getPoint(), settings.maxDist); 317 309 boolean nearpoint2=nd1!=null; 318 310 if (nearpoint!=nearpoint2) {nearpoint=nearpoint2;updateCursor();} 319 311 320 nearestIdx=line.findClosestPoint(e.getPoint(), maxDist);312 nearestIdx=line.findClosestPoint(e.getPoint(),settings.maxDist); 321 313 322 314 if (!drawing) { … … 350 342 } 351 343 } else { 352 if (Math.hypot(e.getX() - lastP.x, e.getY() - lastP.y) > minPixelsBetweenPoints) {344 if (Math.hypot(e.getX() - lastP.x, e.getY() - lastP.y) > settings.minPixelsBetweenPoints) { 353 345 line.addLast(getLatLon(e)); // free mouse-drawing 354 346 repaint(); … … 365 357 line.clearSimplifiedVersion(); 366 358 repaint(); 367 eps=s tartingEps;359 eps=settings.startingEps; 368 360 } 369 361 back(); … … 373 365 if (!line.wasSimplified()) { 374 366 line.simplify(eps); 375 setStatusLine( SIMPLIFYMODE_MESSAGE);367 setStatusLine(tr("Eps={0}, {1} points", eps, line.getSimplePointsCount())+" "+SIMPLIFYMODE_MESSAGE); 376 368 } else saveAsWay(); 377 369 } … … 379 371 // more details 380 372 e.consume(); 381 changeEpsilon( epsilonMult);373 changeEpsilon(settings.epsilonMult); 382 374 } 383 375 if (e.getKeyCode() == KeyEvent.VK_UP) { 384 376 // less details 385 377 e.consume(); 386 changeEpsilon(1/ epsilonMult);378 changeEpsilon(1/settings.epsilonMult); 387 379 } 388 380 if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { … … 391 383 line.moveToTheEnd(); 392 384 } 393 394 385 if (e.getKeyCode() == KeyEvent.VK_Q) { 386 // less details 387 e.consume(); 388 try { 389 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 390 new FastDrawConfigDialog(settings); 391 Toolkit.getDefaultToolkit().addAWTEventListener(this, 392 AWTEvent.KEY_EVENT_MASK); 393 } catch (SecurityException ex) { } 394 eps=settings.startingEps; 395 } 395 396 } 396 397 … … 414 415 // <editor-fold defaultstate="collapsed" desc="Different action helper methods"> 415 416 public void newDrawing() { 416 eps=s tartingEps;417 eps=settings.startingEps; 417 418 line.clear(); 418 419 } … … 482 483 //System.out.println(tr("Eps={0}", eps)); 483 484 eps*=k; 484 /* I18N: Eps = Epsilon, the tolerance parameter */ setStatusLine(tr("Eps={0}", eps));485 485 line.simplify(eps); 486 /* I18N: Eps = Epsilon, the tolerance parameter */ 487 setStatusLine(tr("Eps={0}, {1} points", eps, line.getSimplePointsCount())); 486 488 repaint(); 487 489 } … … 510 512 511 513 512 void loadPrefs() { 513 COLOR_DELETE = Main.pref.getColor("fastdraw.color.delete", Color.red); 514 COLOR_EDITEDFRAGMENT = Main.pref.getColor("fastdraw.color.edit", Color.orange); 515 COLOR_FIXED = Main.pref.getColor("fastdraw.color.fixed", Color.green); 516 COLOR_NORMAL = Main.pref.getColor("fastdraw.color.normal", Color.red); 517 COLOR_SELECTEDFRAGMENT = Main.pref.getColor("fastdraw.color.select", Color.blue); 518 maxDist = Main.pref.getDouble("fastdraw.maxdist", 5); 519 epsilonMult = Main.pref.getDouble("fastdraw.epsilonmult", 1.1); 520 //deltaLatLon = Main.pref.getDouble("fastdraw.deltasearch", 0.01); 521 minPixelsBetweenPoints = Main.pref.getDouble("fastdraw.mindelta", 20); 522 startingEps = Main.pref.getDouble("fastdraw.startingEps", 20); 523 eps=startingEps; 524 } 525 526 void savePrefs() { 527 Main.pref.putColor("fastdraw.color.delete", COLOR_DELETE ); 528 Main.pref.putColor("fastdraw.color.edit", COLOR_EDITEDFRAGMENT); 529 Main.pref.putColor("fastdraw.color.fixed", COLOR_FIXED); 530 Main.pref.putColor("fastdraw.color.normal", COLOR_NORMAL); 531 Main.pref.putColor("fastdraw.color.select", COLOR_SELECTEDFRAGMENT); 532 Main.pref.putDouble("fastdraw.maxdist", maxDist); 533 Main.pref.putDouble("fastdraw.epsilonmult", epsilonMult); 534 //Main.pref.putDouble("fastdraw.deltasearch", deltaLatLon); 535 Main.pref.putDouble("fastdraw.mindelta",minPixelsBetweenPoints); 536 Main.pref.putDouble("fastdraw.startingEps",startingEps); 537 try {Main.pref.save();} catch (IOException e) { 538 System.err.println(tr("Can not save preferences")); 539 } 540 } 514 541 515 542 516 private void updateCursor() { -
applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/UtilsPlugin2.java
r26049 r26264 40 40 super(info); 41 41 42 JMenu toolsMenu = Main.main.menu.addMenu(marktr("More tools"), KeyEvent.VK_ M, 4, "help");42 JMenu toolsMenu = Main.main.menu.addMenu(marktr("More tools"), KeyEvent.VK_X, 4, "help"); 43 43 unglueRelation = MainMenu.add(toolsMenu, new UnGlueRelationAction()); 44 44 addIntersections = MainMenu.add(toolsMenu, new AddIntersectionsAction());
Note:
See TracChangeset
for help on using the changeset viewer.