001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.draw;
003
004import java.awt.geom.Path2D;
005
006import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
007
008/**
009 * An extension of {@link Path2D} with special methods for map positions.
010 * @author Michael Zangl
011 * @since 10875
012 */
013public class MapPath2D extends Path2D.Double {
014    /**
015     * Create a new, empty path.
016     */
017    public MapPath2D() {
018        // no default definitions
019    }
020
021    /**
022     * Move the path to the view position of given point
023     * @param p The point
024     * @return this for easy chaining.
025     */
026    public MapPath2D moveTo(MapViewPoint p) {
027        moveTo(p.getInViewX(), p.getInViewY());
028        return this;
029    }
030
031    /**
032     * Draw a line to the view position of given point
033     * @param p The point
034     * @return this for easy chaining.
035     */
036    public MapPath2D lineTo(MapViewPoint p) {
037        lineTo(p.getInViewX(), p.getInViewY());
038        return this;
039    }
040
041    /**
042     * Add the given shape centered around the given point
043     * @param p The point to draw around
044     * @param symbol The symbol type
045     * @param size The size of the symbol in pixel
046     * @return this for easy chaining.
047     */
048    public MapPath2D shapeAround(MapViewPoint p, SymbolShape symbol, double size) {
049        append(symbol.shapeAround(p.getInViewX(), p.getInViewY(), size), false);
050        return this;
051    }
052}