public abstract class GeometryUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GeometryUtils.PathSegment
Utility data class for the values of the segments in a geometric shape.
|
Modifier and Type | Field and Description |
---|---|
static double |
EPSILON
Precision.
|
static double |
EPSILON_SQ
Precision squared.
|
Modifier and Type | Method and Description |
---|---|
static java.util.List<GeometryUtils.PathSegment> |
getSegments(java.awt.Shape shape)
Returns a list of a shape's segments as they are returned by its path
iterator.
|
static java.awt.Shape |
getShape(java.util.List<GeometryUtils.PathSegment> segments,
boolean isDouble)
Constructs a geometric shape from a list of path segments.
|
static java.awt.geom.Area |
grow(java.awt.Shape s,
double offset)
Expand or shrink a shape in all directions by a defined offset.
|
static java.awt.geom.Area |
grow(java.awt.Shape s,
double offset,
int join,
float miterlimit)
Expand or shrink a shape in all directions by a defined offset.
|
static java.awt.geom.Point2D |
intersection(java.awt.geom.Line2D l1,
java.awt.geom.Line2D l2)
Returns the intersection point of two lines.
|
static java.util.List<java.awt.geom.Point2D> |
intersection(java.awt.Shape s1,
java.awt.Shape s2)
Returns all intersection points of two shapes.
|
static java.awt.geom.Area |
punch(java.awt.geom.Area shapeArea,
double gap,
boolean rounded,
java.awt.geom.Point2D pointPos,
java.awt.Shape pointShape)
Subtract a specified geometric area of data points from another shape to yield gaps.
|
static java.awt.Shape |
reverse(java.awt.Shape shape)
Returns a clone of a specified shape which has a reversed order of the
points, lines and curves.
|
static java.awt.geom.Line2D[] |
shapeToLines(java.awt.Shape path,
boolean swapped)
Returns the line fragments of the specified Shape.
|
public static final double EPSILON
public static final double EPSILON_SQ
public static java.awt.geom.Line2D[] shapeToLines(java.awt.Shape path, boolean swapped)
path
- Shape to be divided.swapped
- Invert segment direction.public static java.util.List<java.awt.geom.Point2D> intersection(java.awt.Shape s1, java.awt.Shape s2)
s1
- First shapes2
- Second shapepublic static java.awt.geom.Point2D intersection(java.awt.geom.Line2D l1, java.awt.geom.Line2D l2)
l1
- First linel2
- Second linenull
if
no intersection was foundpublic static java.awt.geom.Area grow(java.awt.Shape s, double offset)
s
- Shapeoffset
- Offsetpublic static java.awt.geom.Area grow(java.awt.Shape s, double offset, int join, float miterlimit)
s
- Shapeoffset
- Offset to expand/shrinkjoin
- Method for handling edges (see BasicStroke)miterlimit
- Limit for miter joining methodpublic static java.awt.geom.Area punch(java.awt.geom.Area shapeArea, double gap, boolean rounded, java.awt.geom.Point2D pointPos, java.awt.Shape pointShape)
shapeArea
- Shape from which to subtract.gap
- Size of the gap.rounded
- Gap corners will be rounded if true
.pointPos
- Position of the data pointpointShape
- Shape of the data pointpublic static java.util.List<GeometryUtils.PathSegment> getSegments(java.awt.Shape shape)
shape
- Shape to be iterated.public static java.awt.Shape getShape(java.util.List<GeometryUtils.PathSegment> segments, boolean isDouble)
segments
- List of path segments.isDouble
- true
if the shape contents should be stored with
double values, false
if they should be stored as float.public static java.awt.Shape reverse(java.awt.Shape shape)
shape
- Original shape.