public final class CanvasUtilities
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
EAST
double representation of EAST: 0 degrees.
|
static double |
NORTH
double representation of NORTH: -90 degrees (-PI/2).
|
static double |
NORTHEAST
double representation of NORTHEAST: -45 degrees (PI/4).
|
static double |
NORTHWEST
double representation of NORTHWEST: -135 degrees (-PI*3/4).
|
static double |
SOUTH
double representation of SOUTH: 90 degrees (PI/2).
|
static double |
SOUTHEAST
double representation of SOUTHEAST: 45 degrees (PI/4).
|
static double |
SOUTHWEST
double representation of SOUTHWEST: 135 degrees (PI*3/4).
|
static double |
WEST
double representation of WEST: 180 degrees (PI).
|
Modifier and Type | Method and Description |
---|---|
static java.awt.Shape |
clone(java.awt.Shape s)
Deprecated.
Use ShapeUtilities.cloneShape() instead
|
static java.awt.geom.Rectangle2D |
computeCompositeBounds(java.util.Iterator<Figure> i)
Compute a composite bounding box.
|
static java.awt.Shape |
computeCompositeShape(java.util.Iterator<Figure> i)
Compute a composite shape.
|
static java.awt.geom.AffineTransform |
computeFitTransform(java.awt.geom.RectangularShape r,
java.awt.geom.RectangularShape s)
Get the transform that will make the first
rectangle change fit within the second, while preserving the shape.
|
static java.awt.geom.Rectangle2D |
computeSiteBounds(java.util.Iterator<Site> i)
Compute the bounding box of a set of connectors.
|
static java.awt.geom.AffineTransform |
computeTransform(java.awt.geom.RectangularShape r,
java.awt.geom.RectangularShape s)
Get the transform that will make the first rectangle change
into the second.
|
static java.awt.geom.Point2D |
getCenterPoint(Figure f)
Return the point at the center of a figure.
|
static java.awt.geom.Point2D |
getCenterPoint(Figure f,
TransformContext root)
Return the point at the center of a figure, in the
given transform context.
|
static java.awt.geom.Point2D |
getCenterPoint(java.awt.geom.Rectangle2D r)
Return the point at the center of a Rectangle.
|
static int |
getDirection(double angle)
Return the closest direction from SwingConstants, based on the
given angle.
|
static java.awt.geom.Point2D |
getLocation(java.awt.geom.Rectangle2D r,
int location)
Get the point on the given rectangular shape indicated by the location
flag.
|
static double |
getNormal(int direction)
Return an angle in radians, given a direction from SwingConstants.
|
static boolean |
isOrthogonal(java.awt.geom.AffineTransform at)
Return true if the given transform maps a rectangle
to a rectangle.
|
static double |
moduloAngle(double angle)
Return the angle between -PI and PI that corresponds to the
given angle.
|
static Figure |
pick(java.util.Iterator i,
java.awt.geom.Rectangle2D region)
Return the first figure that is hit by the given region.
|
static Figure |
pick(java.util.Iterator i,
java.awt.geom.Rectangle2D region,
Filter filter)
Return the first figure that is hit by the given region.
|
static java.util.Iterator |
pickIter(java.util.Iterator i,
java.awt.geom.Rectangle2D region)
Return an iterator over the figures hit by the given region.
|
static int |
reverseDirection(int direction)
Reverse a direction flag.
|
static java.awt.Shape |
transform(java.awt.geom.RectangularShape r,
java.awt.geom.AffineTransform at)
Deprecated.
Use diva.util.java2d.ShapeUtilities.transformRectangle()
or diva.util.java2d.ShapeUtilities.transformRectangularShape()
|
static java.awt.Shape |
transform(java.awt.Shape s,
java.awt.geom.AffineTransform at)
Deprecated.
Use ShapeUtilities.transformModify()
|
static java.awt.geom.Point2D |
transformInto(java.awt.geom.Point2D p,
TransformContext local,
TransformContext root)
Deprecated.
Use local.getTransform(root) instead.
|
static void |
translate(Figure f,
double distance,
int direction)
Translate a figure the given distance in the direction given
by the flag.
|
static java.awt.geom.Point2D |
translate(java.awt.geom.Point2D.Double p,
double distance,
int direction)
Translate a point the given distance in the direction given
by the flag.
|
static java.awt.geom.Point2D |
translate(java.awt.geom.Point2D.Float p,
double distance,
int direction)
Translate a point the given distance in the direction given
by the flag.
|
static java.awt.geom.Point2D |
translate(java.awt.geom.Point2D p,
double distance,
int direction)
Translate a point the given distance in the direction given
by the flag.
|
static java.awt.Shape |
translate(java.awt.Shape s,
double x,
double y)
Deprecated.
Use ShapeUtilities.translateModify()
|
static void |
translateTo(Figure f,
double x,
double y)
Move a figure so that its origin is located at the given
coordinates.
|
public static final double WEST
public static final double NORTH
public static final double EAST
public static final double SOUTH
public static final double NORTHWEST
public static final double NORTHEAST
public static final double SOUTHWEST
public static final double SOUTHEAST
@Deprecated public static java.awt.Shape clone(java.awt.Shape s)
s
- The shape.public static java.awt.Shape computeCompositeShape(java.util.Iterator<Figure> i)
i
- The iterator of Figurespublic static java.awt.geom.Rectangle2D computeSiteBounds(java.util.Iterator<Site> i)
i
- the iterator of Sitespublic static java.awt.geom.Rectangle2D computeCompositeBounds(java.util.Iterator<Figure> i)
i
- The iterator of Figures.public static java.awt.geom.AffineTransform computeTransform(java.awt.geom.RectangularShape r, java.awt.geom.RectangularShape s)
r
- The shape to be transformed.s
- The resulting shape.public static java.awt.geom.AffineTransform computeFitTransform(java.awt.geom.RectangularShape r, java.awt.geom.RectangularShape s)
r
- The shape to be transformed.s
- The resulting shape.public static java.awt.geom.Point2D getCenterPoint(java.awt.geom.Rectangle2D r)
r
- The Rectangle.public static java.awt.geom.Point2D getCenterPoint(Figure f)
f
- The figure.public static java.awt.geom.Point2D getCenterPoint(Figure f, TransformContext root)
f
- The figure.root
- The TransformContext.public static int getDirection(double angle)
angle
- The anglepublic static double getNormal(int direction)
direction
- The direction, see SwingConstants.public static java.awt.geom.Point2D getLocation(java.awt.geom.Rectangle2D r, int location)
r
- The give rectanglelocation
- One of the directions (CENTER, NORTH etc.)
defined in SwingConstants.public static boolean isOrthogonal(java.awt.geom.AffineTransform at)
at
- The AffineTransformationpublic static double moduloAngle(double angle)
angle
- The anglepublic static Figure pick(java.util.Iterator i, java.awt.geom.Rectangle2D region)
i
- An iterator over figuresregion
- A rectangle which represents the pick or hit regionpublic static Figure pick(java.util.Iterator i, java.awt.geom.Rectangle2D region, Filter filter)
i
- An iterator over figuresregion
- A rectangle which represents the pick or hit regionfilter
- The filter that is called to accept the figure.public static java.util.Iterator pickIter(java.util.Iterator i, java.awt.geom.Rectangle2D region)
i
- An iterator over figuresregion
- A rectangle which represents the pick or hit regionpublic static int reverseDirection(int direction)
direction
- One of the directions from SwingContatn@Deprecated public static java.awt.Shape transform(java.awt.geom.RectangularShape r, java.awt.geom.AffineTransform at)
r
- The rectangular shapeat
- The AffineTransform@Deprecated public static java.awt.Shape transform(java.awt.Shape s, java.awt.geom.AffineTransform at)
s
- The shapeat
- The AffineTransform@Deprecated public static java.awt.geom.Point2D transformInto(java.awt.geom.Point2D p, TransformContext local, TransformContext root)
p
- The point to be transformedlocal
- The local contextroot
- The rootpublic static void translate(Figure f, double distance, int direction)
f
- The figure.distance
- The distance.direction
- One of the eight compass directions defined in
javax.swing.SwingConstants.public static java.awt.geom.Point2D translate(java.awt.geom.Point2D p, double distance, int direction)
p
- The point to be translated as a Float or Double.distance
- The distance.direction
- One of the eight compass directions defined in
javax.swing.SwingConstants.public static java.awt.geom.Point2D translate(java.awt.geom.Point2D.Double p, double distance, int direction)
p
- The point to be translated as a Double.distance
- The distance.direction
- One of the eight compass directions defined in
javax.swing.SwingConstants.public static java.awt.geom.Point2D translate(java.awt.geom.Point2D.Float p, double distance, int direction)
p
- The point to be translated as a float.distance
- The distance.direction
- One of the eight compass directions defined in
javax.swing.SwingConstants.@Deprecated public static java.awt.Shape translate(java.awt.Shape s, double x, double y)
s
- The shape to translate.x
- amount to translate.y
- amount to translate.public static void translateTo(Figure f, double x, double y)
f
- The figure to be moved.x
- The new x location.y
- The new y location.