Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r10308 r10342 501 501 if (ctrl && Main.isPlatformOsx()) { 502 502 selectionManager.unregister(mv); 503 mv.requestClearRect();504 503 // Make sure correct cursor is displayed 505 504 mv.setNewCursor(Cursor.MOVE_CURSOR, this); -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r10234 r10342 3 3 4 4 import java.awt.Cursor; 5 import java.awt.Graphics;6 5 import java.awt.Point; 7 import java.awt.Polygon;8 6 import java.awt.Rectangle; 9 7 import java.awt.geom.AffineTransform; … … 44 42 import org.openstreetmap.josm.data.osm.WaySegment; 45 43 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 46 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;47 44 import org.openstreetmap.josm.data.preferences.BooleanProperty; 48 45 import org.openstreetmap.josm.data.preferences.DoubleProperty; … … 143 140 protected EastNorth center = calculateDefaultCenter(); 144 141 145 private final transient Object paintRequestLock = new Object();146 private Rectangle paintRect;147 private Polygon paintPoly;148 149 142 protected transient ViewportData initialViewport; 150 143 … … 299 292 public static String getDistText(final double dist, final NumberFormat format, final double threshold) { 300 293 return SystemOfMeasurement.getSystemOfMeasurement().getDistText(dist, format, threshold); 301 }302 303 /**304 * Returns the text describing the given area in the current system of measurement.305 * @param area The distance in square metres.306 * @return the text describing the given area in the current system of measurement.307 * @since 5560308 */309 public static String getAreaText(double area) {310 return SystemOfMeasurement.getSystemOfMeasurement().getAreaText(area);311 }312 313 /**314 * Returns the text describing the given area in the current system of measurement.315 * @param area The area in square metres316 * @param format A {@link NumberFormat} to format the area value317 * @param threshold Values lower than this {@code threshold} are displayed as {@code "< [threshold]"}318 * @return the text describing the given area in the current system of measurement.319 * @since 7135320 */321 public static String getAreaText(final double area, final NumberFormat format, final double threshold) {322 return SystemOfMeasurement.getSystemOfMeasurement().getAreaText(area, format, threshold);323 294 } 324 295 … … 607 578 public void zoomTo(LatLon newCenter) { 608 579 zoomTo(Projections.project(newCenter)); 609 }610 611 public void smoothScrollTo(LatLon newCenter) {612 smoothScrollTo(Projections.project(newCenter));613 580 } 614 581 … … 1402 1369 } 1403 1370 1404 public static double perDist(Point2D pt, Point2D a, Point2D b) {1405 if (pt != null && a != null && b != null) {1406 double pd =1407 (a.getX()-pt.getX())*(b.getX()-a.getX()) -1408 (a.getY()-pt.getY())*(b.getY()-a.getY());1409 return Math.abs(pd) / a.distance(b);1410 }1411 return 0d;1412 }1413 1414 /**1415 *1416 * @param pt point to project onto (ab)1417 * @param a root of vector1418 * @param b vector1419 * @return point of intersection of line given by (ab)1420 * with its orthogonal line running through pt1421 */1422 public static Point2D project(Point2D pt, Point2D a, Point2D b) {1423 if (pt != null && a != null && b != null) {1424 double r = (1425 (pt.getX()-a.getX())*(b.getX()-a.getX()) +1426 (pt.getY()-a.getY())*(b.getY()-a.getY()))1427 / a.distanceSq(b);1428 return project(r, a, b);1429 }1430 return null;1431 }1432 1433 1371 /** 1434 1372 * if r = 0 returns a, if r=1 returns b, … … 1572 1510 } 1573 1511 1574 @Override1575 public void paint(Graphics g) {1576 synchronized (paintRequestLock) {1577 if (paintRect != null) {1578 Graphics g2 = g.create();1579 g2.setColor(Utils.complement(PaintColors.getBackgroundColor()));1580 g2.drawRect(paintRect.x, paintRect.y, paintRect.width, paintRect.height);1581 g2.dispose();1582 }1583 if (paintPoly != null) {1584 Graphics g2 = g.create();1585 g2.setColor(Utils.complement(PaintColors.getBackgroundColor()));1586 g2.drawPolyline(paintPoly.xpoints, paintPoly.ypoints, paintPoly.npoints);1587 g2.dispose();1588 }1589 }1590 super.paint(g);1591 }1592 1593 /**1594 * Requests to paint the given {@code Rectangle}.1595 * @param r The Rectangle to draw1596 * @see #requestClearRect1597 * @since 55001598 */1599 public void requestPaintRect(Rectangle r) {1600 if (r != null) {1601 synchronized (paintRequestLock) {1602 paintRect = r;1603 }1604 repaint();1605 }1606 }1607 1608 /**1609 * Requests to paint the given {@code Polygon} as a polyline (unclosed polygon).1610 * @param p The Polygon to draw1611 * @see #requestClearPoly1612 * @since 55001613 */1614 public void requestPaintPoly(Polygon p) {1615 if (p != null) {1616 synchronized (paintRequestLock) {1617 paintPoly = p;1618 }1619 repaint();1620 }1621 }1622 1623 /**1624 * Requests to clear the rectangled previously drawn.1625 * @see #requestPaintRect1626 * @since 55001627 */1628 public void requestClearRect() {1629 synchronized (paintRequestLock) {1630 paintRect = null;1631 }1632 repaint();1633 }1634 1635 /**1636 * Requests to clear the polyline previously drawn.1637 * @see #requestPaintPoly1638 * @since 55001639 */1640 public void requestClearPoly() {1641 synchronized (paintRequestLock) {1642 paintPoly = null;1643 }1644 repaint();1645 }1646 1647 1512 /** 1648 1513 * Get a max scale for projection that describes world in 1/512 of the projection unit -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/MapViewMock.java
r10271 r10342 49 49 50 50 @Override 51 public void requestClearRect() {}52 53 @Override54 51 public Point2D getPoint2D(EastNorth p) { 55 52 return p != null ? new Point2D.Double(p.getX(), p.getY()) : null;
Note:
See TracChangeset
for help on using the changeset viewer.