math.geom2d
Interface Shape2D

All Superinterfaces:
GeometricObject2D
All Known Subinterfaces:
Boundary2D, CircleLine2D, CircularShape2D, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearCurveSet2D<T>, CirculinearDomain2D, CirculinearElement2D, CirculinearRing2D, CirculinearShape2D, Conic2D, ContinuousCurve2D, ContinuousOrientedCurve2D, Contour2D, Curve2D, CurveSet2D<T>, Domain2D, DomainSet2D<T>, EllipseArcShape2D, EllipseShape2D, LinearElement2D, LinearShape2D, OrientedCurve2D, PointSet2D, PointShape2D, Polygon2D, ShapeSet2D<T>, SmoothContour2D, SmoothCurve2D, SmoothOrientedCurve2D
All Known Implementing Classes:
AbstractContinuousCurve2D, AbstractLine2D, AbstractSmoothCurve2D, BoundaryPolyCirculinearCurve2D, BoundaryPolyCurve2D, Circle2D, CircleArc2D, CirculinearContourArray2D, CirculinearCurveArray2D, ContourArray2D, CubicBezierCurve2D, CurveArray2D, DomainArray2D, Ellipse2D, EllipseArc2D, GenericCirculinearDomain2D, GenericCirculinearRing2D, GenericDomain2D, HRectangle2D, Hyperbola2D, HyperbolaBranch2D, HyperbolaBranchArc2D, InvertedRay2D, Line2D, LineArc2D, LinearCurve2D, LinearRing2D, LineSegment2D, MultiPolygon2D, Parabola2D, ParabolaArc2D, Point2D, PointArray2D, PolyCirculinearCurve2D, PolyCubicBezierCurve2D, PolyCurve2D, Polyline2D, PolyOrientedCurve2D, QuadBezierCurve2D, Ray2D, Rectangle2D, ShapeArray2D, SimplePolygon2D, StraightLine2D

public interface Shape2D
extends GeometricObject2D

Main interface for all geometric objects, including points, lines, curves, or planar regions... Instances of Shape2D can be either bounded (a point, a line segment, a square...) or unbounded (a parabola, a half-plane...).

Shape2D implementations implements a more specialized interface depending on the shape inner dimension: Curve2D, Domain2D or PointShape2D.

Shape2D interface provide convenient method to check if the shape is empty, to transform or to clip the shape, get its bounding box, or its distance to a given point.


Field Summary
static double ACCURACY
          The constant used for testing results.
 
Method Summary
 Box2D boundingBox()
          Returns the bounding box of the shape.
 Shape2D clip(Box2D box)
          Clip the shape with the given box, and returns a new shape.
 boolean contains(double x, double y)
          Checks if the shape contains the planar point defined by (x,y).
 boolean contains(Point2D p)
          Checks if the shape contains the given point.
 double distance(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. fillable) shape.
 double distance(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.
 void draw(java.awt.Graphics2D g2)
          Draws the shape on the given graphics.
 boolean isBounded()
          Returns true if the shape is bounded, that is if we can draw a finite rectangle enclosing the shape.
 boolean isEmpty()
          Returns true if the shape does not contain any point.
 Shape2D transform(AffineTransform2D trans)
          Transforms the shape by an affine transform.
 
Methods inherited from interface math.geom2d.GeometricObject2D
almostEquals
 

Field Detail

ACCURACY

static final double ACCURACY
The constant used for testing results.

See Also:
Constant Field Values
Method Detail

contains

boolean contains(double x,
                 double y)
Checks if the shape contains the planar point defined by (x,y).


contains

boolean contains(Point2D p)
Checks if the shape contains the given point.


distance

double distance(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.


distance

double distance(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. fillable) shape.


isBounded

boolean isBounded()
Returns 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

boolean isEmpty()
Returns true if the shape does not contain any point. This is the case for example for PointSet2D without any point.

Returns:
true if the shape does not contain any point.

boundingBox

Box2D boundingBox()
Returns the bounding box of the shape.

Returns:
the bounding box of the shape.

clip

Shape2D clip(Box2D box)
Clip the shape with the given box, and returns a new shape. The box must be bounded.

Parameters:
box - the clipping box
Returns:
the clipped shape

transform

Shape2D transform(AffineTransform2D trans)
Transforms the shape by an affine transform. Subclasses may override the type of returned shape.

Parameters:
trans - an affine transform
Returns:
the transformed shape

draw

void draw(java.awt.Graphics2D g2)
Draws the shape on the given graphics. If the shape is empty, nothing is drawn. If the shape is unbounded, an exception is thrown.