public class GeometryRuler extends Object
Modifier and Type | Method and Description |
---|---|
float |
getArc2DArea(Arc2D arc)
Return an Arc2D area.
|
float |
getArc2DLength(Arc2D arc)
Return an Arc2D length.
|
float |
getEllipse2DArea(Ellipse2D el)
Return an Ellipse2D area.
|
float |
getEllipse2DLength(Ellipse2D el)
Return an Ellipse2D length (perimeter).
|
double |
getFlatness()
Return the flatness value.
|
float |
getPolygon2DArea(Polygon2D pol)
Return a Polygon area using the following formula:
area = 1/2 * (x1*y2 - x2*y1 + x2*y3 - x3*y2
|
float |
getPolygon2DLength(Polygon2D pol)
Return a Polygon2D length;
|
float |
getPolyline2DLength(Polyline2D pol)
Return a Polyline2D length;
|
static GeometryRuler |
getRuler()
Return the unique GeometryRuler instance.
|
float |
getShapeArea(Shape shape)
This method compute the area of a shape.
|
float |
getShapeArea(Shape shape,
double flatness)
Return the area of a Shape.
|
float |
getShapeLength(Shape shape)
This method compute the length (perimeter) of a shape.
|
float |
getShapeLength(Shape shape,
double flatness)
Return the length of a Shape.
|
void |
setFlatness(double flatness)
Set the flatness value (which will be used to compute CubicCurves areas and perimeters.
|
public static GeometryRuler getRuler()
public void setFlatness(double flatness)
flatness
- the flatness valuepublic double getFlatness()
public float getShapeArea(Shape shape, double flatness)
getShapeArea(Shape)
.shape
- the Shapeflatness
- the flatness value (see setFlatness(double)
)getShapeArea(Shape)
public float getShapeArea(Shape shape)
ShapeNormalizer
class. The area of the Shape is the
sum of the areas of all the sub-Shapes computed by this classgetPolygon2DArea(Polygon2D)
getArc2DArea(Arc2D)
getEllipse2DArea(Ellipse2D)
shape
- the shapepublic float getArc2DArea(Arc2D arc)
arc
- the Arc2Dpublic float getEllipse2DArea(Ellipse2D el)
el
- the Ellipse2Dpublic float getPolygon2DArea(Polygon2D pol)
area = 1/2 * (x1*y2 - x2*y1 + x2*y3 - x3*y2 ... + xn-1*yn - xn*yn-1 + xn*y1 - x1*yn)
pol
- the Polygon2Dpublic float getShapeLength(Shape shape, double flatness)
getShapeLength(Shape)
.shape
- the Shapeflatness
- the flatness value (see setFlatness(double)
)getShapeLength(Shape)
public float getShapeLength(Shape shape)
ShapeNormalizer
class. The legnth of the Shape is the
sum of the lengts of all the sub-Shapes computed by this classgetPolygon2DLength(Polygon2D)
getPolyline2DLength(Polyline2D)
getPolyline2DLength(Polyline2D)
, the Polyline2D
corresponding to the Line2D getArc2DLength(Arc2D)
getEllipse2DLength(Ellipse2D)
shape
- the Shapepublic float getArc2DLength(Arc2D arc)
arc
- the Arc2Dpublic float getEllipse2DLength(Ellipse2D el)
PI * sqrt(2*(a*a + b*b) - (a - b)*(a-b)/2)where a and be are the major radius and minor radius of he ellipsis.
el
- the Ellipse2Dpublic float getPolygon2DLength(Polygon2D pol)
pol
- the Polygon2Dpublic float getPolyline2DLength(Polyline2D pol)
pol
- the Polyline2D