org.jfree.util
Class ShapeUtils

java.lang.Object
  extended byorg.jfree.util.ShapeUtils

public abstract class ShapeUtils
extends java.lang.Object

Utility methods for Shape objects.


Constructor Summary
ShapeUtils()
           
 
Method Summary
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 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 boolean equal(java.awt.Polygon p1, java.awt.Polygon p2)
          Tests two polygons for equality.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeUtils

public ShapeUtils()
Method Detail

rotateShape

public static java.awt.Shape rotateShape(java.awt.Shape base,
                                         double angle,
                                         float x,
                                         float y)
Rotates a shape about the specified coordinates.

Parameters:
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).
Returns:
the rotated shape.

clone

public static java.awt.Shape clone(java.awt.Shape shape)
Returns a clone of the specified shape, or null. At the current time, this method supports cloning for instances of Line2D, RectangularShape, Area and GeneralPath.

RectangularShape includes Arc2D, Ellipse2D, Rectangle2D, RoundRectangle2D.

Parameters:
shape - the shape to clone (null permitted, returns null).
Returns:
A clone or null.

equal

public static boolean equal(java.awt.Polygon p1,
                            java.awt.Polygon p2)
Tests two polygons for equality. If both are null this method returns true.

Parameters:
p1 - polygon 1 (null permitted).
p2 - polygon 2 (null permitted).
Returns:
A boolean.

translateShape

public static java.awt.Shape translateShape(java.awt.Shape shape,
                                            double transX,
                                            double transY)
Returns a translated shape.

Parameters:
shape - the shape (null not permitted).
transX - the x translation.
transY - the y translation.
Returns:
The translated shape.

createDiagonalCross

public static java.awt.Shape createDiagonalCross(float l,
                                                 float t)
Creates a diagonal cross shape.

Parameters:
l - the length of each 'arm'.
t - the thickness.
Returns:
A diagonal cross shape.

createRegularCross

public static java.awt.Shape createRegularCross(float l,
                                                float t)
Creates a diagonal cross shape.

Parameters:
l - the length of each 'arm'.
t - the thickness.
Returns:
A diagonal cross shape.

createDiamond

public static java.awt.Shape createDiamond(float s)
Creates a diamond shape.

Parameters:
s - the size factor (equal to half the height of the diamond).
Returns:
A diamond shape.

createUpTriangle

public static java.awt.Shape createUpTriangle(float s)
Creates a triangle shape that points upwards.

Parameters:
s - the size factor (equal to half the height of the triangle).
Returns:
A triangle shape.

createDownTriangle

public static java.awt.Shape createDownTriangle(float s)
Creates a triangle shape that points downwards.

Parameters:
s - the size factor (equal to half the height of the triangle).
Returns:
A triangle shape.