math.geom2d
Class ShapeArray2D<T extends Shape2D>
- java.lang.Object
-
- math.geom2d.ShapeArray2D<T>
-
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Iterable<T>, GeometricObject2D, Shape2D, ShapeSet2D<T>
- Direct Known Subclasses:
- DomainArray2D
public class ShapeArray2D<T extends Shape2D> extends java.lang.Object implements ShapeSet2D<T>, java.lang.Cloneable
Default Implementation of ShapeSet2D.
-
-
Constructor Summary
Constructors Constructor and Description ShapeArray2D()ShapeArray2D(java.util.Collection<? extends T> shapes)ShapeArray2D(int n)ShapeArray2D(T[] shapes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidadd(int index, T shape)Inserts the specified shape at the specified position in this set (optional operation).booleanadd(T shape)Adds the shape to the shape set, if it does not already belongs to the set.booleanalmostEquals(GeometricObject2D obj, double eps)Checks if the two objects are similar up to a given threshold value.Box2DboundingBox()Returns the bounding box of the shape.voidclear()Clears the inner shape collection.Shape2Dclip(Box2D box)Clip the shape with the given box, and returns a new shape.ShapeArray2D<? extends Shape2D>clone()Deprecated.use copy constructor instead (0.11.2)booleancontains(double x, double y)Checks if the shape contains the planar point defined by (x,y).booleancontains(Point2D p)Checks if the shape contains the given point.booleancontains(T shape)Checks if the shape set contains the given shape.static <T extends Shape2D>
ShapeArray2D<T>create(java.util.Collection<T> shapes)static <T extends Shape2D>
ShapeArray2D<T>create(T... shapes)doubledistance(double x, double y)Returns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e.doubledistance(Point2D p)Returns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.voiddraw(java.awt.Graphics2D g2)Draws the shape on the given graphics.booleanequals(java.lang.Object obj)Returns true if obj is a CurveSet2D with the same number of shapes, and such that each shape belongs to both objects.Tget(int index)Returns the inner shape corresponding to the given index.intindexOf(T shape)Returns the index of the shape in this set.booleanisBounded()Returns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape.booleanisEmpty()Returns true if the shape does not contain any point.java.util.Iterator<T>iterator()Tremove(int index)Removes the shape at the specified position in this set (optional operation).booleanremove(T shape)Removes the specified shape from the shape set.java.util.Collection<T>shapes()Returns the collection of shapesintsize()Returns the number of shapes stored in this set.ShapeSet2D<? extends Shape2D>transform(AffineTransform2D trans)Transforms the shape by an affine transform.
-
-
-
Constructor Detail
-
ShapeArray2D
public ShapeArray2D()
-
ShapeArray2D
public ShapeArray2D(int n)
-
ShapeArray2D
public ShapeArray2D(java.util.Collection<? extends T> shapes)
-
ShapeArray2D
public ShapeArray2D(T[] shapes)
-
-
Method Detail
-
create
public static <T extends Shape2D> ShapeArray2D<T> create(java.util.Collection<T> shapes)
-
create
public static <T extends Shape2D> ShapeArray2D<T> create(T... shapes)
-
add
public boolean add(T shape)
Adds the shape to the shape set, if it does not already belongs to the set.- Specified by:
addin interfaceShapeSet2D<T extends Shape2D>- Parameters:
shape- the shape to add
-
add
public void add(int index, T shape)Description copied from interface:ShapeSet2DInserts the specified shape at the specified position in this set (optional operation).- Specified by:
addin interfaceShapeSet2D<T extends Shape2D>
-
get
public T get(int index)
Returns the inner shape corresponding to the given index.- Specified by:
getin interfaceShapeSet2D<T extends Shape2D>- Parameters:
index- index of the shape- Returns:
- the i-th inner curve
-
remove
public boolean remove(T shape)
Removes the specified shape from the shape set.- Specified by:
removein interfaceShapeSet2D<T extends Shape2D>- Parameters:
shape- the shape to remove
-
remove
public T remove(int index)
Description copied from interface:ShapeSet2DRemoves the shape at the specified position in this set (optional operation).- Specified by:
removein interfaceShapeSet2D<T extends Shape2D>
-
contains
public boolean contains(T shape)
Checks if the shape set contains the given shape.- Specified by:
containsin interfaceShapeSet2D<T extends Shape2D>
-
indexOf
public int indexOf(T shape)
Description copied from interface:ShapeSet2DReturns the index of the shape in this set.- Specified by:
indexOfin interfaceShapeSet2D<T extends Shape2D>
-
clear
public void clear()
Clears the inner shape collection.- Specified by:
clearin interfaceShapeSet2D<T extends Shape2D>
-
size
public int size()
Description copied from interface:ShapeSet2DReturns the number of shapes stored in this set.- Specified by:
sizein interfaceShapeSet2D<T extends Shape2D>
-
shapes
public java.util.Collection<T> shapes()
Returns the collection of shapes- Returns:
- the inner collection of shapes
-
clip
public Shape2D clip(Box2D box)
Description copied from interface:Shape2DClip the shape with the given box, and returns a new shape. The box must be bounded.
-
contains
public boolean contains(double x, double y)Description copied from interface:Shape2DChecks if the shape contains the planar point defined by (x,y).
-
contains
public boolean contains(Point2D p)
Description copied from interface:Shape2DChecks if the shape contains the given point.
-
draw
public void draw(java.awt.Graphics2D g2)
Description copied from interface:Shape2DDraws the shape on the given graphics. If the shape is empty, nothing is drawn. If the shape is unbounded, an exception is thrown.
-
boundingBox
public Box2D boundingBox()
Description copied from interface:Shape2DReturns the bounding box of the shape.- Specified by:
boundingBoxin interfaceShape2D- Returns:
- the bounding box of the shape.
-
distance
public double distance(Point2D p)
Description copied from interface:Shape2DReturns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
-
distance
public double distance(double x, double y)Description copied from interface:Shape2DReturns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.
-
isBounded
public boolean isBounded()
Description copied from interface:Shape2DReturns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape. For example, a straight line or a parabola are not bounded.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Shape2DReturns true if the shape does not contain any point. This is the case for example for PointSet2D without any point.
-
transform
public ShapeSet2D<? extends Shape2D> transform(AffineTransform2D trans)
Description copied from interface:Shape2DTransforms the shape by an affine transform. Subclasses may override the type of returned shape.
-
almostEquals
public boolean almostEquals(GeometricObject2D obj, double eps)
Description copied from interface:GeometricObject2DChecks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.- Specified by:
almostEqualsin interfaceGeometricObject2D- Parameters:
obj- the object to compareeps- a threshold value, for example the minimal coordinate difference- Returns:
- true if both object have the same value up to the threshold
-
iterator
public java.util.Iterator<T> iterator()
-
equals
public boolean equals(java.lang.Object obj)
Returns true if obj is a CurveSet2D with the same number of shapes, and such that each shape belongs to both objects.- Overrides:
equalsin classjava.lang.Object
-
clone
@Deprecated public ShapeArray2D<? extends Shape2D> clone()
Deprecated. use copy constructor instead (0.11.2)- Overrides:
clonein classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG