1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.draw;
|
---|
3 |
|
---|
4 | import java.awt.geom.Path2D;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * An extension of {@link Path2D} with special methods for map positions.
|
---|
10 | * @author Michael Zangl
|
---|
11 | * @since 10875
|
---|
12 | */
|
---|
13 | public class MapPath2D extends Path2D.Double {
|
---|
14 | /**
|
---|
15 | * Create a new, empty path.
|
---|
16 | */
|
---|
17 | public MapPath2D() {
|
---|
18 | // no default definitions
|
---|
19 | }
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Move the path to the view position of given point
|
---|
23 | * @param p The point
|
---|
24 | * @return this for easy chaining.
|
---|
25 | */
|
---|
26 | public MapPath2D moveTo(MapViewPoint p) {
|
---|
27 | moveTo(p.getInViewX(), p.getInViewY());
|
---|
28 | return this;
|
---|
29 | }
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Draw a line to the view position of given point
|
---|
33 | * @param p The point
|
---|
34 | * @return this for easy chaining.
|
---|
35 | */
|
---|
36 | public MapPath2D lineTo(MapViewPoint p) {
|
---|
37 | lineTo(p.getInViewX(), p.getInViewY());
|
---|
38 | return this;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Add the given shape centered around the given point
|
---|
43 | * @param p The point to draw around
|
---|
44 | * @param symbol The symbol type
|
---|
45 | * @param size The size of the symbol in pixel
|
---|
46 | * @return this for easy chaining.
|
---|
47 | */
|
---|
48 | public MapPath2D shapeAround(MapViewPoint p, SymbolShape symbol, double size) {
|
---|
49 | append(symbol.shapeAround(p.getInViewX(), p.getInViewY(), size), false);
|
---|
50 | return this;
|
---|
51 | }
|
---|
52 | }
|
---|