public class IlvShapeUtil extends Object
IlvShapeUtil
contains static methods that are useful
when working with Java2D Shape
objects.Modifier and Type | Method and Description |
---|---|
static double |
distanceTo(Line2D line,
double x,
double y,
Point2D nearestPoint)
Computes the distance between the specified line segment and the specified
point (x,y).
|
static double |
distanceTo(Rectangle2D rect,
double x,
double y,
Point2D nearestPoint)
Computes the distance between the specified rectangle and the specified
point.
|
static double |
distanceTo(Shape shape,
double x,
double y,
Point2D nearestPoint)
Computes the distance between the specified shape and the specified point.
|
static double |
distanceToBorder(Shape shape,
double x,
double y,
Point2D nearestPoint)
Computes the distance between the border of the specified shape and the
specified point.
|
static Rectangle2D |
getTightBounds2D(Shape shape)
Returns a tightly fitting rectangle around the given shape.
|
static Shape |
getTranslatedShape(Shape origShape,
double dx,
double dy)
Returns the translation of a given shape by a given vector.
|
public static Rectangle2D getTightBounds2D(Shape shape)
Note: The method Shape.getBounds2D()
returns a rectangle that
encloses even the knots of each spline that is part of the shape's
approximation. For curved shapes, such as Arc2D
, this rectangle
is significantly wider than the smallest rectangle around the shape.
This method is essentially equivalent to
new Area(shape).getBounds2D()
(except for shapes without area,
like Line2D
), only much faster.
public static double distanceTo(Line2D line, double x, double y, Point2D nearestPoint)
line
- The line segment.x
- The x coordinate of the specified point.y
- The y coordinate of the specified point.nearestPoint
- If not null
, this will be used to return
the nearest point in the line segment. You can pass
null
if you don't need this information.public static double distanceTo(Rectangle2D rect, double x, double y, Point2D nearestPoint)
rect
- The rectangle.x
- The x coordinate of the specified point.y
- The y coordinate of the specified point.nearestPoint
- If not null
, this will be used to return
the nearest point in the rectangle. You can pass
null
if you don't need this information.public static double distanceTo(Shape shape, double x, double y, Point2D nearestPoint)
shape
- The shape.x
- The x coordinate of the specified point.y
- The y coordinate of the specified point.nearestPoint
- If not null
, this will be used to return
the nearest point in the shape. You can pass
null
if you don't need this information.public static double distanceToBorder(Shape shape, double x, double y, Point2D nearestPoint)
shape
- The shape.x
- The x coordinate of the specified point.y
- The y coordinate of the specified point.nearestPoint
- If not null
, this will be used to return
the nearest point in the border of the shape. You can
pass null
if you don't need this
information.public static Shape getTranslatedShape(Shape origShape, double dx, double dy)
origShape
- The original shape. It is supposed not to change while
the returned Shape
object in use.dx
- Translation in x direction.dy
- Translation in y direction.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.