public class ShapeUtil extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ShapeUtil.BooleanOperator |
static interface |
ShapeUtil.PathConsumer |
static interface |
ShapeUtil.ShapeConsumer |
static class |
ShapeUtil.ShapeOperation
Deprecated.
Use
ShapeUtil.BooleanOperator instead. |
Constructor and Description |
---|
ShapeUtil() |
Modifier and Type | Method and Description |
---|---|
static java.awt.Shape |
add(java.awt.Shape shape1,
java.awt.Shape shape2)
Deprecated.
Use
union(Shape, Shape) instead |
static java.awt.geom.Path2D |
buildPathFromAnchors(java.awt.geom.Path2D path,
java.util.List<PathAnchor2D> points)
Update specified path from the specified list of PathAnchor2D
|
static java.awt.geom.Path2D |
buildPathFromAnchors(java.awt.geom.Path2D path,
java.util.List<PathAnchor2D> points,
boolean closePath)
Update specified path from the specified list of PathAnchor2D
|
static boolean |
consumeShapeFromPath(java.awt.geom.PathIterator path,
ShapeUtil.ShapeConsumer consumer)
Permit to describe any PathIterator in a list of Shape which are returned
to the specified ShapeConsumer
|
static void |
consumeSubPath(java.awt.geom.PathIterator pathIt,
ShapeUtil.PathConsumer consumer)
Consume all sub path of the specified
PathIterator . |
static void |
consumeSubPath(java.awt.Shape shape,
ShapeUtil.PathConsumer consumer)
Consume all sub path of the specified
Shape . |
static void |
drawFromPath(java.awt.geom.PathIterator path,
java.awt.Graphics2D g)
Deprecated.
|
static void |
enlarge(java.awt.geom.RectangularShape shape,
double width,
double height,
boolean centered)
Enlarge the specified
RectangularShape by specified width and height. |
static java.awt.geom.Area |
exclusiveUnion(java.awt.Shape shape1,
java.awt.Shape shape2)
Do exclusive union between the 2 shapes and return result in an
Area type shape. |
static java.util.ArrayList<PathAnchor2D> |
getAnchorsFromShape(java.awt.Shape shape)
Return all PathAnchor points from the specified shape
|
static java.util.ArrayList<PathAnchor2D> |
getAnchorsFromShape(java.awt.Shape shape,
java.awt.Color color,
java.awt.Color selectedColor)
Return all PathAnchor points from the specified shape
|
static java.awt.geom.Path2D |
getClosedPath(java.awt.Shape shape)
Returns only the closed path part of the specified Shape.
|
static java.awt.geom.Path2D |
getOpenPath(java.awt.Shape shape)
Returns only the open path part of the specified Shape.
|
static java.awt.geom.Path2D |
getPathFromAnchors(java.util.List<PathAnchor2D> points)
Create and return a path from the specified list of PathAnchor2D
|
static java.awt.geom.Path2D |
getPathFromAnchors(java.util.List<PathAnchor2D> points,
boolean closePath)
Create and return a path from the specified list of PathAnchor2D
|
static java.awt.geom.Area |
intersect(java.awt.Shape shape1,
java.awt.Shape shape2)
Intersects 2 shapes and return result in an
Area type shape. |
static boolean |
isClosed(java.awt.Shape shape)
Returns
true if the specified Shape define a closed Shape (Area). |
static boolean |
isVisible(java.awt.Graphics g,
java.awt.Shape shape)
Use the
Graphics clip area and Shape bounds informations to determine if
the specified Shape is visible in the specified Graphics object. |
static java.awt.Shape |
merge(java.util.List<java.awt.Shape> shapes,
ShapeUtil.BooleanOperator operator)
Merge the specified list of
Shape with the given ShapeUtil.BooleanOperator . |
static java.awt.Shape |
merge(java.awt.Shape[] shapes,
ShapeUtil.ShapeOperation operation)
Deprecated.
Use
merge(List, BooleanOperator) instead. |
static boolean |
pathIntersects(java.awt.geom.PathIterator path,
java.awt.geom.Rectangle2D rect)
Return true if the specified PathIterator intersects with the specified Rectangle
|
static void |
scale(java.awt.geom.RectangularShape shape,
double factor,
boolean centered)
Scale the specified
RectangularShape by specified factor. |
static void |
scale(java.awt.geom.RectangularShape shape,
double factor,
boolean centered,
boolean scalePosition)
Scale the specified
RectangularShape by specified factor. |
static java.awt.geom.Area |
subtract(java.awt.Shape shape1,
java.awt.Shape shape2)
Subtract shape2 from shape1 return result in an
Area type shape. |
static void |
translate(java.awt.geom.RectangularShape shape,
double dx,
double dy)
Translate a rectangular shape by the specified dx and dy value
|
static void |
translate(java.awt.geom.RectangularShape shape,
int dx,
int dy)
Translate a rectangular shape by the specified dx and dy value
|
static java.awt.Shape |
union(java.awt.Shape shape1,
java.awt.Shape shape2)
Process union between the 2 shapes and return result in a new Shape.
|
static java.awt.geom.Area |
xor(java.awt.Shape shape1,
java.awt.Shape shape2)
Deprecated.
Use
exclusiveUnion(Shape, Shape) instead. |
public ShapeUtil()
public static boolean isVisible(java.awt.Graphics g, java.awt.Shape shape)
Graphics
clip area and Shape
bounds informations to determine if
the specified Shape
is visible in the specified Graphics object.public static boolean isClosed(java.awt.Shape shape)
true
if the specified Shape define a closed Shape (Area).false
if the specified Shape define a open Shape (Path).public static java.awt.Shape merge(java.util.List<java.awt.Shape> shapes, ShapeUtil.BooleanOperator operator)
shapes
- Shapes we want to merge.operator
- ShapeUtil.BooleanOperator
to apply.Area
shape representing the result of the merge operation.@Deprecated public static java.awt.Shape merge(java.awt.Shape[] shapes, ShapeUtil.ShapeOperation operation)
merge(List, BooleanOperator)
instead.public static java.awt.Shape union(java.awt.Shape shape1, java.awt.Shape shape2)
@Deprecated public static java.awt.Shape add(java.awt.Shape shape1, java.awt.Shape shape2)
union(Shape, Shape)
insteadpublic static java.awt.geom.Area intersect(java.awt.Shape shape1, java.awt.Shape shape2)
Area
type shape.public static java.awt.geom.Area exclusiveUnion(java.awt.Shape shape1, java.awt.Shape shape2)
Area
type shape.@Deprecated public static java.awt.geom.Area xor(java.awt.Shape shape1, java.awt.Shape shape2)
exclusiveUnion(Shape, Shape)
instead.public static java.awt.geom.Area subtract(java.awt.Shape shape1, java.awt.Shape shape2)
Area
type shape.public static void scale(java.awt.geom.RectangularShape shape, double factor, boolean centered, boolean scalePosition)
RectangularShape
by specified factor.shape
- the RectangularShape
to scalefactor
- the scale factorcentered
- if true then scaling is centered (shape location is modified)scalePosition
- if true then position is also 'rescaled' (shape location is modified)public static void scale(java.awt.geom.RectangularShape shape, double factor, boolean centered)
RectangularShape
by specified factor.shape
- the RectangularShape
to scalefactor
- the scale factorcentered
- if true then scaling is centered (shape location is modified)public static void enlarge(java.awt.geom.RectangularShape shape, double width, double height, boolean centered)
RectangularShape
by specified width and height.shape
- the RectangularShape
to scalewidth
- the width to addheight
- the height to addcentered
- if true then enlargement is centered (shape location is modified)public static void translate(java.awt.geom.RectangularShape shape, int dx, int dy)
public static void translate(java.awt.geom.RectangularShape shape, double dx, double dy)
public static boolean consumeShapeFromPath(java.awt.geom.PathIterator path, ShapeUtil.ShapeConsumer consumer)
public static void consumeSubPath(java.awt.geom.PathIterator pathIt, ShapeUtil.PathConsumer consumer)
PathIterator
.PathIterator.SEG_MOVETO
segment or after a
PathIterator.SEG_CLOSE
segment (except the ending one).public static void consumeSubPath(java.awt.Shape shape, ShapeUtil.PathConsumer consumer)
Shape
.PathIterator.SEG_MOVETO
segment or after a
PathIterator.SEG_CLOSE
segment (except the ending one).public static java.awt.geom.Path2D getOpenPath(java.awt.Shape shape)
Path2D.contains(double, double)
method.public static java.awt.geom.Path2D getClosedPath(java.awt.Shape shape)
Path2D.contains(double, double)
method.public static java.util.ArrayList<PathAnchor2D> getAnchorsFromShape(java.awt.Shape shape, java.awt.Color color, java.awt.Color selectedColor)
public static java.util.ArrayList<PathAnchor2D> getAnchorsFromShape(java.awt.Shape shape)
public static java.awt.geom.Path2D buildPathFromAnchors(java.awt.geom.Path2D path, java.util.List<PathAnchor2D> points, boolean closePath)
public static java.awt.geom.Path2D buildPathFromAnchors(java.awt.geom.Path2D path, java.util.List<PathAnchor2D> points)
public static java.awt.geom.Path2D getPathFromAnchors(java.util.List<PathAnchor2D> points, boolean closePath)
public static java.awt.geom.Path2D getPathFromAnchors(java.util.List<PathAnchor2D> points)
@Deprecated public static void drawFromPath(java.awt.geom.PathIterator path, java.awt.Graphics2D g)
GraphicsUtil.drawPathIterator(PathIterator, Graphics2D)
insteadpublic static boolean pathIntersects(java.awt.geom.PathIterator path, java.awt.geom.Rectangle2D rect)