-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.implementations.geometry.AwtShapeCompatible,it.unibo.alchemist.model.interfaces.geometry.ConvexGeometricShape,it.unibo.alchemist.model.interfaces.geometry.GeometricShape,it.unibo.alchemist.model.interfaces.geometry.euclidean2d.ConvexPolygon,it.unibo.alchemist.model.interfaces.geometry.euclidean2d.MutableConvexPolygon,java.io.Serializable
public class AwtMutableConvexPolygon extends AbstractConvexPolygon implements MutableConvexPolygon
MutableConvexPolygon partly delegated to AwtEuclidean2DShape and java.awt.geom. Each modification operation on this object has a time complexity of O(n), where n is the number of vertices/edges. Collinear points are allowed.
-
-
Constructor Summary
Constructors Constructor Description AwtMutableConvexPolygon(List<Euclidean2DPosition> vertices)
-
Method Summary
Modifier and Type Method Description DoublegetDiameter()Euclidean2DPositiongetCentroid()DoublegetRadius()List<Euclidean2DPosition>vertices()Segment2DImpl<Euclidean2DPosition>getEdge(Integer index)List<Segment2D<Euclidean2DPosition>>edges()BooleanaddVertex(Integer index, Double x, Double y)Adds a vertex to the polygon. BooleanremoveVertex(Integer index)Removes a vertex from the polygon. BooleanmoveVertex(Integer index, Double newX, Double newY)Moves a vertex of the polygon to a new absolute position. BooleanreplaceEdge(Integer index, Segment2D<Euclidean2DPosition> newEdge)Replaces an edge of the polygon. Booleancontains(Euclidean2DPosition vector)Delegated to AwtEuclidean2DShape (adopts the definition of insideness used by java.awt.Shapes). Booleanintersects(Shape shape)Delegated to java.awt.geom.Area, this is accurate and does not consider adjacent shapes to be intersecting. Booleanintersects(GeometricShape<Euclidean2DPosition, Euclidean2DTransformation> other)Delegated to AwtEuclidean2DShape unless other is AwtShapeCompatible, in which case intersects is used so as to guarantee maximum accuracy. GeometricShape<Euclidean2DPosition, Euclidean2DTransformation>transformed(Function1<Euclidean2DTransformation, Unit> transformation)final ShapeasAwtShape()Booleanequals(Object other)IntegerhashCode()-
Methods inherited from class it.unibo.alchemist.model.implementations.geometry.euclidean2d.AwtMutableConvexPolygon
closestEdgeTo, contains, containsBoundaryExcluded, containsBoundaryIncluded, intersects, isAdjacentTo, liesOnBoundary, toString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AwtMutableConvexPolygon
AwtMutableConvexPolygon(List<Euclidean2DPosition> vertices)
-
-
Method Detail
-
getDiameter
Double getDiameter()
-
getCentroid
Euclidean2DPosition getCentroid()
-
vertices
List<Euclidean2DPosition> vertices()
-
getEdge
Segment2DImpl<Euclidean2DPosition> getEdge(Integer index)
- Parameters:
index- indicates which edge to get: edge i connects vertices i and i+1 (with respect to the ordering of vertices used in vertices)
-
edges
List<Segment2D<Euclidean2DPosition>> edges()
-
addVertex
Boolean addVertex(Integer index, Double x, Double y)
Adds a vertex to the polygon.
- Parameters:
index- the index in the list of vertices where to put the new vertexx- x coordinatey- y coordinate
-
removeVertex
Boolean removeVertex(Integer index)
Removes a vertex from the polygon.
- Parameters:
index- the index of the vertex to be removed in the list of vertices
-
moveVertex
Boolean moveVertex(Integer index, Double newX, Double newY)
Moves a vertex of the polygon to a new absolute position.
- Parameters:
index- the index of the vertex to movenewX- new absolute x coordinatenewY- new absolute y coordinate
-
replaceEdge
Boolean replaceEdge(Integer index, Segment2D<Euclidean2DPosition> newEdge)
Replaces an edge of the polygon.
- Parameters:
index- the index of the edge to replace (edge i connects vertices i and i+1)newEdge- the new edge
-
contains
Boolean contains(Euclidean2DPosition vector)
Delegated to AwtEuclidean2DShape (adopts the definition of insideness used by java.awt.Shapes).
- Parameters:
vector- the vector (= point)
-
intersects
Boolean intersects(Shape shape)
Delegated to java.awt.geom.Area, this is accurate and does not consider adjacent shapes to be intersecting.
- Parameters:
shape- the shape
-
intersects
Boolean intersects(GeometricShape<Euclidean2DPosition, Euclidean2DTransformation> other)
Delegated to AwtEuclidean2DShape unless other is AwtShapeCompatible, in which case intersects is used so as to guarantee maximum accuracy.
-
transformed
GeometricShape<Euclidean2DPosition, Euclidean2DTransformation> transformed(Function1<Euclidean2DTransformation, Unit> transformation)
-
asAwtShape
final Shape asAwtShape()
-
-
-
-