Class Multipolygon.PolyData
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay
-
- org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData
-
- Enclosing class:
- Multipolygon
public static class Multipolygon.PolyData extends Multipolygon.JoinedWay
The polygon data for a multipolygon part. It contains the outline of this polygon in east/north space.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Multipolygon.PolyData.Intersection
The intersection type used forcontains(java.awt.geom.Path2D.Double)
-
Field Summary
Fields Modifier and Type Field Description private Rectangle2D
bounds
private List<Multipolygon.PolyData>
inners
private Path2D.Double
poly
-
Fields inherited from class org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay
nodes, selected, wayIds
-
-
Constructor Summary
Constructors Modifier Constructor Description private
PolyData(List<Node> nodes, boolean selected, Collection<Long> wayIds)
PolyData(Multipolygon.JoinedWay joinedWay)
Constructs a newPolyData
from aMultipolygon.JoinedWay
.PolyData(Multipolygon.PolyData copy)
Constructs a newPolyData
from an existingPolyData
.PolyData(Way closedWay)
Constructs a newPolyData
from a closed way.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInner(Multipolygon.PolyData inner)
Adds an inner polygonprivate void
appendInner(Path2D.Double inner)
private void
buildPoly()
Multipolygon.PolyData.Intersection
contains(Path2D.Double p)
Checks if this multipolygon contains or crosses an other polygon.Path2D.Double
get()
Gets the polygon outline and interior as java pathGeometry.AreaAndPerimeter
getAreaAndPerimeter(Projection projection)
Calculate area and perimeter length in the given projection.Rectangle2D
getBounds()
Gets the bounds asRectangle2D
in east/north space.List<Multipolygon.PolyData>
getInners()
Gets a list of all inner polygons.boolean
isClosed()
Determines if this joined way is closed.void
nodeMoved(NodeMovedEvent event)
Check if this polygon was changed by a node moveprivate void
resetNodes(DataSet dataSet)
private void
resetPoly()
void
wayNodesChanged(WayNodesChangedEvent event)
Check if this polygon was affected by a way change-
Methods inherited from class org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.JoinedWay
getFirstNode, getLastNode, getNodes, getWayIds, isSelected, setSelected
-
-
-
-
Field Detail
-
poly
private final Path2D.Double poly
-
bounds
private Rectangle2D bounds
-
inners
private final List<Multipolygon.PolyData> inners
-
-
Constructor Detail
-
PolyData
public PolyData(Way closedWay)
Constructs a newPolyData
from a closed way.- Parameters:
closedWay
- closed way
-
PolyData
public PolyData(Multipolygon.JoinedWay joinedWay)
Constructs a newPolyData
from aMultipolygon.JoinedWay
.- Parameters:
joinedWay
- joined way
-
PolyData
private PolyData(List<Node> nodes, boolean selected, Collection<Long> wayIds)
-
PolyData
public PolyData(Multipolygon.PolyData copy)
Constructs a newPolyData
from an existingPolyData
.- Parameters:
copy
- existing instance
-
-
Method Detail
-
buildPoly
private void buildPoly()
-
contains
public Multipolygon.PolyData.Intersection contains(Path2D.Double p)
Checks if this multipolygon contains or crosses an other polygon. This is a quick+lazy test which assumes that a polygon is inside when all points are inside. It will fail when the polygon encloses a hole or crosses the edges of poly so that both end points are inside poly (think of a square overlapping a U-shape).- Parameters:
p
- The path to check. Needs to be in east/north space.- Returns:
- a
Multipolygon.PolyData.Intersection
constant
-
addInner
public void addInner(Multipolygon.PolyData inner)
Adds an inner polygon- Parameters:
inner
- The polygon to add as inner polygon.
-
appendInner
private void appendInner(Path2D.Double inner)
-
get
public Path2D.Double get()
Gets the polygon outline and interior as java path- Returns:
- The path in east/north space.
-
getBounds
public Rectangle2D getBounds()
Gets the bounds asRectangle2D
in east/north space.- Returns:
- The bounds
-
getInners
public List<Multipolygon.PolyData> getInners()
Gets a list of all inner polygons.- Returns:
- The inner polygons.
-
resetNodes
private void resetNodes(DataSet dataSet)
-
resetPoly
private void resetPoly()
-
nodeMoved
public void nodeMoved(NodeMovedEvent event)
Check if this polygon was changed by a node move- Parameters:
event
- The node move event
-
wayNodesChanged
public void wayNodesChanged(WayNodesChangedEvent event)
Check if this polygon was affected by a way change- Parameters:
event
- The way event
-
isClosed
public boolean isClosed()
Description copied from class:Multipolygon.JoinedWay
Determines if this joined way is closed.- Overrides:
isClosed
in classMultipolygon.JoinedWay
- Returns:
true
if this joined way is closed
-
getAreaAndPerimeter
public Geometry.AreaAndPerimeter getAreaAndPerimeter(Projection projection)
Calculate area and perimeter length in the given projection.- Parameters:
projection
- the projection to use for the calculation,null
defaults toProjectionRegistry.getProjection()
- Returns:
- area and perimeter
-
-