de.erichseifert.gral.util
Class GeometryUtils

java.lang.Object
  extended by de.erichseifert.gral.util.GeometryUtils

public abstract class GeometryUtils
extends Object

Abstract class that represents a collection of utility functions concerning geometry.


Field Summary
static double EPSILON
          Precision
static double EPSILON_SQ
          Precision squared
 
Constructor Summary
GeometryUtils()
           
 
Method Summary
static Area grow(Shape s, double offset)
          Expand or shrink a shape in all directions by a defined offset.
static Area grow(Shape s, double offset, int join, float miterlimit)
          Expand or shrink a shape in all directions by a defined offset.
static Point2D intersection(Line2D l1, Line2D l2)
          Returns the intersection point of two lines.
static List<Point2D> intersection(Shape s1, Shape s2)
          Returns all intersection points of two shapes.
static Area punch(Shape shape, double gap, boolean rounded, Iterable<DataPoint> dataPoints)
          Subtract all shapes of data points from another shape to yield gaps.
static Line2D[] shapeToLines(Shape path, boolean swapped)
          Returns the line fragments of the specified Shape.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

GeometryUtils

public GeometryUtils()
Method Detail

shapeToLines

public static Line2D[] shapeToLines(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 List<Point2D> intersection(Shape s1,
                                         Shape s2)
Returns all intersection points of two shapes.

Parameters:
s1 - First shape
s2 - Second shape
Returns:
Intersection points, or empty array if no intersections were found

intersection

public static Point2D intersection(Line2D l1,
                                   Line2D l2)
Returns the intersection point of two lines.

Parameters:
l1 - First line
l2 - Second line
Returns:
Intersection point, or null if no intersection was found

grow

public static Area grow(Shape s,
                        double offset)
Expand or shrink a shape in all directions by a defined offset.

Parameters:
s - Shape
offset - Offset
Returns:
New shape that was expanded or shrunk by the specified amount

grow

public static Area grow(Shape s,
                        double offset,
                        int join,
                        float miterlimit)
Expand or shrink a shape in all directions by a defined offset.

Parameters:
s - Shape
offset - Offset to expand/shrink
join - 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 Area punch(Shape shape,
                         double gap,
                         boolean rounded,
                         Iterable<DataPoint> dataPoints)
Subtract all shapes of data points from another shape to yield gaps.

Parameters:
shape - Shape from which to subtract.
gap - Size of the gap.
rounded - Gap corners will be rounded if true.
dataPoints - Collection of data points
Returns:
Shape with punched holes


Copyright © 2009-2010. All Rights Reserved.