de.erichseifert.gral.util
Class GeometryUtils
- java.lang.Object
-
- de.erichseifert.gral.util.GeometryUtils
-
public abstract class GeometryUtils extends java.lang.ObjectAbstract class that represents a collection of utility functions concerning geometry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classGeometryUtils.PathSegmentUtility data class for the values of the segments in a geometric shape.
-
Field Summary
Fields Modifier and Type Field and Description static doubleEPSILONPrecision.static doubleEPSILON_SQPrecision squared.
-
Method Summary
All Methods Static Methods Concrete Methods 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.ShapegetShape(java.util.List<GeometryUtils.PathSegment> segments, boolean isDouble)Constructs a geometric shape from a list of path segments.static java.awt.geom.Areagrow(java.awt.Shape s, double offset)Expand or shrink a shape in all directions by a defined offset.static java.awt.geom.Areagrow(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.Point2Dintersection(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.Areapunch(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.Shapereverse(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.
-
-
-
Field Detail
-
EPSILON
public static final double EPSILON
Precision.- See Also:
- Constant Field Values
-
EPSILON_SQ
public static final double EPSILON_SQ
Precision squared.- See Also:
- Constant Field Values
-
-
Method Detail
-
shapeToLines
public static java.awt.geom.Line2D[] shapeToLines(java.awt.Shape path, boolean swapped)Returns the line fragments of the specified Shape.- Parameters:
path- Shape to be divided.swapped- Invert segment direction.- Returns:
- Array of lines.
-
intersection
public static java.util.List<java.awt.geom.Point2D> intersection(java.awt.Shape s1, java.awt.Shape s2)Returns all intersection points of two shapes.- Parameters:
s1- First shapes2- Second shape- Returns:
- Intersection points, or empty array if no intersections were found
-
intersection
public static java.awt.geom.Point2D intersection(java.awt.geom.Line2D l1, java.awt.geom.Line2D l2)Returns the intersection point of two lines.- Parameters:
l1- First linel2- Second line- Returns:
- Intersection point, or
nullif no intersection was found
-
grow
public static java.awt.geom.Area grow(java.awt.Shape s, double offset)Expand or shrink a shape in all directions by a defined offset.- Parameters:
s- Shapeoffset- Offset- Returns:
- New shape that was expanded or shrunk by the specified amount
-
grow
public 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.- Parameters:
s- Shapeoffset- Offset to expand/shrinkjoin- Method for handling edges (see BasicStroke)miterlimit- Limit for miter joining method- Returns:
- New shape that is expanded or shrunk by the specified amount
-
punch
public 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.- Parameters:
shapeArea- Shape from which to subtract.gap- Size of the gap.rounded- Gap corners will be rounded iftrue.pointPos- Position of the data pointpointShape- Shape of the data point- Returns:
- Shape with punched holes
-
getSegments
public 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.- Parameters:
shape- Shape to be iterated.- Returns:
- A list of path segment objects.
-
getShape
public static java.awt.Shape getShape(java.util.List<GeometryUtils.PathSegment> segments, boolean isDouble)
Constructs a geometric shape from a list of path segments.- Parameters:
segments- List of path segments.isDouble-trueif the shape contents should be stored with double values,falseif they should be stored as float.- Returns:
- A geometric shape.
-
reverse
public 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.- Parameters:
shape- Original shape.- Returns:
- Shape with reversed direction.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG