public final class ShapeClipper extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
BOTTOM |
private static int |
LEFT |
private static int |
RIGHT |
private static int |
TOP |
Modifier | Constructor and Description |
---|---|
private |
ShapeClipper() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
addToResult(java.awt.geom.Path2D.Double result,
double[] points,
int num,
java.awt.geom.Rectangle2D bbox,
java.awt.geom.Rectangle2D clippingRect)
Clip extracted segment if needed and add it to result if not completely outside of clipping rectangle.
|
static java.awt.geom.Path2D.Double |
clipShape(java.awt.Shape shape,
java.awt.geom.Rectangle2D clippingRect)
Clip a given (closed) shape with a given rectangle.
|
private static java.awt.geom.Path2D.Double |
clipSinglePathWithSutherlandHodgman(double[] points,
int num,
java.awt.geom.Rectangle2D bbox,
java.awt.geom.Rectangle2D clippingRect)
Clip a single path with a given rectangle using the Sutherland-Hodgman algorithm.
|
private static java.awt.geom.Path2D.Double |
pointsToPath2D(double[] points,
int num)
Convert a list of points to a Path2D.Double
|
private static final int LEFT
private static final int TOP
private static final int RIGHT
private static final int BOTTOM
private ShapeClipper()
public static java.awt.geom.Path2D.Double clipShape(java.awt.Shape shape, java.awt.geom.Rectangle2D clippingRect)
shape
- the subject shape to clipclippingRect
- the clipping rectangleprivate static boolean addToResult(java.awt.geom.Path2D.Double result, double[] points, int num, java.awt.geom.Rectangle2D bbox, java.awt.geom.Rectangle2D clippingRect)
result
- the path that will describe the clipped shape (modified)points
- array of x/y pairsnum
- the number of valid values in pointsbbox
- the bounding box of the pathclippingRect
- the clipping rectangleprivate static java.awt.geom.Path2D.Double pointsToPath2D(double[] points, int num)
points
- array of x/y pairsnum
- the number of valid values in pointsprivate static java.awt.geom.Path2D.Double clipSinglePathWithSutherlandHodgman(double[] points, int num, java.awt.geom.Rectangle2D bbox, java.awt.geom.Rectangle2D clippingRect)
points
- array of x/y pairsnum
- the number of valid values in pointsbbox
- the bounding box of the pathclippingRect
- the clipping rectangle