math.geom2d
Interface Shape2D

Package class diagram package Shape2D
All Superinterfaces:
Serializable
All Known Subinterfaces:
Boundary2D, CircleLine2D, CircularShape2D, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearDomain2D, CirculinearElement2D, CirculinearRing2D, CirculinearShape2D, Conic2D, ContinuousBoundary2D, ContinuousCirculinearCurve2D, ContinuousCurve2D, ContinuousOrientedCurve2D, Curve2D, Domain2D, LinearShape2D, OrientedCurve2D, PointSet2D, PointShape2D, Polygon2D, SmoothBoundary2D, SmoothCurve2D, SmoothOrientedCurve2D
All Known Implementing Classes:
AbstractContinuousCurve2D, AbstractLine2D, AbstractSmoothCurve2D, BezierCurve2D, BoundaryPolyCirculinearCurve2D, BoundaryPolyCurve2D, BoundarySet2D, Circle2D, CircleArc2D, CirculinearBoundarySet2D, CirculinearCurveSet2D, ClosedPolyline2D, CubicBezierCurve2D, CurveArray2D, CurveSet2D, Ellipse2D, EllipseArc2D, GenericCirculinearDomain2D, GenericCirculinearRing2D, GenericDomain2D, HRectangle2D, Hyperbola2D, HyperbolaBranch2D, HyperbolaBranchArc2D, InvertedRay2D, Line2D, LineArc2D, LinearRing2D, LineObject2D, LineSegment2D, MultiPolygon2D, Parabola2D, ParabolaArc2D, Point2D, PointArray2D, PolyBezierCurve2D, PolyCirculinearCurve2D, PolyCubicBezierCurve2D, PolyCurve2D, Polyline2D, Polyline2D, PolyOrientedCurve2D, QuadBezier2D, QuadBezierCurve2D, Ray2D, Rectangle2D, Ring2D, SimplePolygon2D, StraightLine2D

public interface Shape2D
extends Serializable

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
 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.
 void draw(Graphics2D g2)
          Draw the shape on the given graphics.
 Box2D getBoundingBox()
          Returns the bounding box of the shape.
 double getDistance(double x, double y)
          get 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.
 double getDistance(Point2D p)
          get 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.
 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.
 

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.


getDistance

double getDistance(Point2D p)
get 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.


getDistance

double getDistance(double x,
                   double y)
get 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.

getBoundingBox

Box2D getBoundingBox()
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(Graphics2D g2)
Draw the shape on the given graphics. If the shape is empty, nothing is drawn. If the shape is unbounded, an exception is thrown.



Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.