Changeset 26111 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-06-08T20:57:27+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java
r26106 r26111 20 20 21 21 private int lastIdx; 22 22 private boolean closedFlag; 23 24 public DrawnPolyLine() { 25 clear(); 26 } 23 27 public void setMv(MapView mv) { 24 28 this.mv = mv; … … 56 60 used=null; 57 61 lastIdx=0; 62 closedFlag=false; 58 63 fixed.clear(); 59 64 simplePoints=null; … … 66 71 lastIdx--; 67 72 } 68 69 73 } 70 74 … … 78 82 } 79 83 void addLast(LatLon coor) { 84 if (closedFlag && lastIdx>points.size()-1) return; 80 85 if (lastIdx>=points.size()-1) { 81 86 //System.out.println("add last "+points.size()); … … 177 182 void closeLine() { 178 183 points.add(points.getFirst()); 184 closedFlag=true; 185 } 186 boolean isClosed() { 187 return closedFlag; 179 188 } 180 189 … … 201 210 }if (f &&(!it.hasNext())) { 202 211 // if end of whole line reached 212 closedFlag=false; 203 213 it.remove(); 204 214 lastIdx=points.size()-1; … … 273 283 } 274 284 285 void moveNode(int dragNode, LatLon coor) { 286 LatLon dragged = points.get(dragNode); 287 // points.getLast().equals(points.getFirst() 288 if (closedFlag && points.getFirst().equals(dragged)) { 289 // move both ends 290 points.set(0, coor); 291 points.set(points.size()-1, coor); 292 } else { 293 points.set(dragNode, coor); 294 } 295 if (fixed.contains(dragged)) { 296 fixed.remove(dragged); 297 fixed.add(coor); 298 } 299 } 300 275 301 } -
applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java
r26106 r26111 82 82 private final Stroke strokeForSimplified; 83 83 private final Stroke strokeForOriginal; 84 private boolean ready;85 84 private final Cursor cursorDraw; 86 85 private final Cursor cursorCtrl; … … 92 91 private int nearestIdx; 93 92 private Stroke strokeForDelete; 93 private int dragNode=-1; 94 94 95 95 … … 195 195 p2 = line.getPoint(pp2); 196 196 if (shift && highlighted==pp1 && nearestIdx<0) {lineColor=COLOR_SELECTEDFRAGMENT;} 197 if ( line.isLastPoint(i)) { lineColor=COLOR_EDITEDFRAGMENT; }197 if (!shift && line.isLastPoint(i)) { lineColor=COLOR_EDITEDFRAGMENT; } 198 198 g.setColor(lineColor); 199 199 g.drawLine(p1.x, p1.y, p2.x, p2.y); … … 206 206 g.fillRect(p2.x - 1, p2.y - 1, 3, 3); 207 207 } 208 if (shift && !line.wasSimplified() && nearestIdx==i+1 ) { 209 // highlight node to delete 210 g.setStroke(strokeForDelete); 211 g.setColor(COLOR_DELETE); 212 g.drawLine(p2.x - 5, p2.y - 5,p2.x + 5, p2.y + 5); 213 g.drawLine(p2.x - 5, p2.y + 5,p2.x + 5, p2.y - 5); 214 g.setStroke(strokeForOriginal); 215 } 216 if (ctrl && !line.wasSimplified() && nearestIdx==i+1 ) { 217 // highlight node to toggle fixation 218 g.setStroke(strokeForDelete); 219 g.setColor( line.isFixed(pp2) ? COLOR_NORMAL: COLOR_FIXED); 220 g.drawOval(p2.x - 5, p2.y - 5, 11, 11); 221 g.setStroke(strokeForOriginal); 208 if (!drawing) { 209 if (shift && !line.wasSimplified() && nearestIdx==i+1 ) { 210 // highlight node to delete 211 g.setStroke(strokeForDelete); 212 g.setColor(COLOR_DELETE); 213 g.drawLine(p2.x - 5, p2.y - 5,p2.x + 5, p2.y + 5); 214 g.drawLine(p2.x - 5, p2.y + 5,p2.x + 5, p2.y - 5); 215 g.setStroke(strokeForOriginal); 216 } 217 if (ctrl && !line.wasSimplified() && nearestIdx==i+1 ) { 218 // highlight node to toggle fixation 219 g.setStroke(strokeForDelete); 220 g.setColor( line.isFixed(pp2) ? COLOR_NORMAL: COLOR_FIXED); 221 g.drawOval(p2.x - 5, p2.y - 5, 11, 11); 222 g.setStroke(strokeForOriginal); 223 } 222 224 } 223 225 } … … 247 249 248 250 int idx=line.findClosestPoint(e.getPoint(),maxDist); 249 if (idx==0 ) {251 if (idx==0 && !line.isClosed()) { 250 252 line.closeLine(); 251 253 // the way should become closed 252 254 drawing=false; 253 ready=true;255 dragNode=0; 254 256 updateCursor(); 255 257 return; … … 267 269 line.toggleFixed(idx); 268 270 } 271 // node dragging 272 dragNode=idx; 269 273 return; 270 274 } 271 272 if (ready) { setStatusLine(tr(SIMPLIFYMODE_MESSAGE));return; }275 276 //if (line.isClosed()) { setStatusLine(tr(SIMPLIFYMODE_MESSAGE));return; } 273 277 drawing = true; 274 278 … … 295 299 if (!isEnabled()) return; 296 300 if (e.getButton() != MouseEvent.BUTTON1) return; 301 dragNode = -1; 297 302 drawing = false; 298 303 highlighted=null; 299 if (! ready) setStatusLine(tr(DRAWINGMODE_MESSAGE));304 if (!line.isClosed()) setStatusLine(tr(DRAWINGMODE_MESSAGE)); 300 305 repaint(); 301 306 } … … 316 321 317 322 if (!drawing) { 323 if (dragNode>=0) { 324 line.moveNode(dragNode,getLatLon(e)); 325 repaint(); 326 return; 327 } 328 318 329 if (shift) { 319 330 // find line fragment to highlight … … 326 337 return; 327 338 } 328 if ( ready) setStatusLine(tr(SIMPLIFYMODE_MESSAGE));339 if (line.isClosed()) setStatusLine(tr(SIMPLIFYMODE_MESSAGE)); 329 340 330 341 // do not draw points close to existing points - we do not want self-intersections … … 404 415 public void newDrawing() { 405 416 eps=startingEps; 406 ready=false;407 417 line.clear(); 408 418 } … … 532 542 private void updateCursor() { 533 543 if (shift) Main.map.mapView.setCursor(cursorShift); else 534 if ( ready) Main.map.mapView.setCursor(cursorReady); else544 if (line.isClosed()) Main.map.mapView.setCursor(cursorReady); else 535 545 if (ctrl) Main.map.mapView.setCursor(cursorCtrl); else 536 546 if (nearpoint) Main.map.mapView.setCursor(cursorCtrl); else
Note:
See TracChangeset
for help on using the changeset viewer.