Changeset 6069 in josm for trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
- Timestamp:
- 2013-07-17T00:01:07+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r6050 r6069 73 73 private Color mainColor; 74 74 private Stroke mainStroke; 75 75 76 76 /** 77 77 * drawing settings for helper lines … … 88 88 private List<ReferenceSegment> possibleMoveDirections; 89 89 90 90 91 91 /** 92 92 * Collection of nodes that is moved … … 238 238 if (e.getButton() != MouseEvent.BUTTON1) 239 239 return; 240 240 241 241 requestFocusInMapView(); 242 242 updateKeyModifiers(e); 243 243 244 244 selectedNode = Main.map.mapView.getNearestNode(e.getPoint(), OsmPrimitive.isSelectablePredicate); 245 245 selectedSegment = Main.map.mapView.getNearestWaySegment(e.getPoint(), OsmPrimitive.isSelectablePredicate); 246 246 247 247 // If nothing gets caught, stay in select mode 248 248 if (selectedSegment == null && selectedNode == null) return; 249 249 250 250 if (selectedNode != null) { 251 251 if (ctrl || nodeDragWithoutCtrl) { … … 253 253 movingNodeList.add(selectedNode); 254 254 calculatePossibleDirectionsByNode(); 255 if (possibleMoveDirections.isEmpty()) { 255 if (possibleMoveDirections.isEmpty()) { 256 256 // if no directions fould, do not enter dragging mode 257 257 return; … … 278 278 calculatePossibleDirectionsBySegment(); 279 279 } 280 280 281 281 // Signifies that nothing has happened yet 282 282 newN1en = null; … … 386 386 } 387 387 } 388 388 389 389 /** 390 390 * Insert node into nearby segment 391 * @param e - current mouse point 391 * @param e - current mouse point 392 392 */ 393 393 private void addNewNode(MouseEvent e) { … … 488 488 Main.main.undoRedo.add(c); 489 489 } 490 490 491 491 /** 492 492 * This method tests if a node has other ways apart from the given one. … … 502 502 return false; 503 503 } 504 504 505 505 /** 506 506 * Determine best movenemnt from initialMousePos to current position @param mouseEn, 507 507 * choosing one of the directions @field possibleMoveDirections 508 * @return movement vector 508 * @return movement vector 509 509 */ 510 510 private EastNorth calculateBestMovement(EastNorth mouseEn) { 511 511 512 512 EastNorth initialMouseEn = Main.map.mapView.getEastNorth(initialMousePos.x, initialMousePos.y); 513 513 EastNorth mouseMovement = initialMouseEn.sub(mouseEn); 514 514 515 515 double bestDistance = Double.POSITIVE_INFINITY; 516 516 EastNorth bestMovement = null; … … 565 565 initialN1en = selectedSegment.getFirstNode().getEastNorth(); 566 566 initialN2en = selectedSegment.getSecondNode().getEastNorth(); 567 567 568 568 //add direction perpendicular to the selected segment 569 569 possibleMoveDirections = new ArrayList<ReferenceSegment>(); … … 573 573 ), initialN1en, initialN2en, true)); 574 574 575 575 576 576 //add directions parallel to neighbor segments 577 577 Node prevNode = getPreviousNode(selectedSegment.lowerIndex); … … 593 593 } 594 594 } 595 595 596 596 /** 597 597 * Gather possible move directions - along all adjacent segments … … 609 609 initialN1en.getX() - en.getX(), 610 610 initialN1en.getY() - en.getY() 611 ), initialN1en, en, false)); 611 ), initialN1en, en, false)); 612 612 } 613 613 } 614 614 } 615 615 } 616 616 617 617 /** 618 618 * Gets a node from selected way before given index. … … 685 685 686 686 EastNorth normalUnitVector = getNormalUniVector(); 687 687 688 688 if (mode == Mode.extrude || mode == Mode.create_new) { 689 689 g2.setColor(mainColor); … … 722 722 if (p1.distance(p2) < 3) { 723 723 g2.setStroke(mainStroke); 724 g2.drawOval((int)(p1.x-symbolSize/2), (int)(p1.y-symbolSize/2), 724 g2.drawOval((int)(p1.x-symbolSize/2), (int)(p1.y-symbolSize/2), 725 725 (int)(symbolSize), (int)(symbolSize)); 726 726 } else { … … 752 752 } 753 753 } 754 754 755 755 private EastNorth getNormalUniVector() { 756 756 double fac = 1.0 / activeMoveDirection.en.distance(0,0); … … 770 770 return normalUnitVector; 771 771 } 772 772 773 773 private void drawAngleSymbol(Graphics2D g2, Point2D center, EastNorth normal, boolean mirror) { 774 774 // EastNorth units per pixel … … 776 776 double raoffsetx = symbolSize*factor*normal.getX(); 777 777 double raoffsety = symbolSize*factor*normal.getY(); 778 779 double cx = center.getX(), cy = center.getY(); 778 779 double cx = center.getX(), cy = center.getY(); 780 780 double k = (mirror ? -1 : 1); 781 781 Point2D ra1 = new Point2D.Double(cx + raoffsetx, cy + raoffsety); 782 782 Point2D ra3 = new Point2D.Double(cx - raoffsety*k, cy + raoffsetx*k); 783 783 Point2D ra2 = new Point2D.Double(ra1.getX() - raoffsety*k, ra1.getY() + raoffsetx*k); 784 784 785 785 GeneralPath ra = new GeneralPath(); 786 786 ra.moveTo((float)ra1.getX(), (float)ra1.getY());
Note:
See TracChangeset
for help on using the changeset viewer.
