public abstract class ShapeUtilities
extends java.lang.Object
Shape objects.| Constructor and Description |
|---|
ShapeUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static java.awt.Shape |
clone(java.awt.Shape shape)
Returns a clone of the specified shape, or
null. |
static java.awt.Shape |
createDiagonalCross(float l,
float t)
Creates a diagonal cross shape.
|
static java.awt.Shape |
createDiamond(float s)
Creates a diamond shape.
|
static java.awt.Shape |
createDownTriangle(float s)
Creates a triangle shape that points downwards.
|
static java.awt.Shape |
createLineRegion(java.awt.geom.Line2D line,
float width)
Creates a region surrounding a line segment by 'widening' the line
segment.
|
static java.awt.Shape |
createRegularCross(float l,
float t)
Creates a diagonal cross shape.
|
static java.awt.Shape |
createUpTriangle(float s)
Creates a triangle shape that points upwards.
|
static void |
drawRotatedShape(java.awt.Graphics2D g2,
java.awt.Shape shape,
double angle,
float x,
float y)
Draws a shape with the specified rotation about
(x, y). |
static boolean |
equal(java.awt.Polygon p1,
java.awt.Polygon p2)
Tests two polygons for equality.
|
static java.awt.geom.Point2D |
getPointInRectangle(double x,
double y,
java.awt.geom.Rectangle2D area)
Returns a point based on (x, y) but constrained to be within the bounds of a given
rectangle.
|
static java.awt.Shape |
rotateShape(java.awt.Shape base,
double angle,
float x,
float y)
Rotates a shape about the specified coordinates.
|
static java.awt.Shape |
translateShape(java.awt.Shape shape,
double transX,
double transY)
Returns a translated shape.
|
public static java.awt.Shape clone(java.awt.Shape shape)
null. At the current time, this
method supports cloning for instances of Line2D, RectangularShape,
Area and GeneralPath.
RectangularShape includes Arc2D, Ellipse2D,
Rectangle2D, RoundRectangle2D.
shape - the shape to clone (null permitted, returns null).null.public static boolean equal(java.awt.Polygon p1,
java.awt.Polygon p2)
null this method
returns true.p1 - polygon 1 (null permitted).p2 - polygon 2 (null permitted).public static java.awt.Shape translateShape(java.awt.Shape shape,
double transX,
double transY)
shape - the shape (null not permitted).transX - the x translation.transY - the y translation.public static java.awt.Shape rotateShape(java.awt.Shape base,
double angle,
float x,
float y)
base - the shape (null permitted, returns null).angle - the angle (in radians).x - the x coordinate for the rotation point (in Java2D space).y - the y coordinate for the rotation point (in Java2D space).public static void drawRotatedShape(java.awt.Graphics2D g2,
java.awt.Shape shape,
double angle,
float x,
float y)
(x, y).g2 - the graphics device (null not permitted).shape - the shape (null not permitted).angle - the angle (in radians).x - the x coordinate for the rotation point.y - the y coordinate for the rotation point.public static java.awt.Shape createDiagonalCross(float l,
float t)
l - the length of each 'arm'.t - the thickness.public static java.awt.Shape createRegularCross(float l,
float t)
l - the length of each 'arm'.t - the thickness.public static java.awt.Shape createDiamond(float s)
s - the size factor (equal to half the height of the diamond).public static java.awt.Shape createUpTriangle(float s)
s - the size factor (equal to half the height of the triangle).public static java.awt.Shape createDownTriangle(float s)
s - the size factor (equal to half the height of the triangle).public static java.awt.Shape createLineRegion(java.awt.geom.Line2D line,
float width)
line - the line (null not permitted).width - the width of the region.public static java.awt.geom.Point2D getPointInRectangle(double x,
double y,
java.awt.geom.Rectangle2D area)
x - the x-coordinate.y - the y-coordinate.area - the constraining rectangle (null not permitted).java.lang.NullPointerException - if area is null.