public final class IlvGraphicUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Rectangle2D |
addToRect(Rectangle2D r,
double x,
double y)
Adds a point to a rectangle.
|
static Rectangle2D |
addToRect(Rectangle2D r1,
Rectangle2D r2)
Adds two rectangles.
|
static void |
addToRect(Rectangle r,
int x,
int y)
Adds a point to a rectangle.
|
static void |
addToRect(Rectangle r1,
Rectangle r2)
Adds two rectangles.
|
static Rectangle |
applyInsets(Rectangle r,
Insets insets)
Applies insets to the specified rectangle.
|
static int |
compareInsets(Insets i1,
Insets i2)
Compares two
Insets objects. |
static IlvDoublePoint |
computeTextLocation(IlvDoublePoint loc,
double angle,
int offset,
double width,
double height)
Computes the location of a text according to a reference point and
a direction angle.
|
static double |
computeXSeg(double x1,
double y1,
double x2,
double y2,
double y)
Computes the x-coordinate of a point on a segment, according to its
y-coordinate.
|
static double |
computeYSeg(double x1,
double y1,
double x2,
double y2,
double x)
Computes the y-coordinate of a point on a segment, according to its
x-coordinate.
|
static Polygon |
createPolygon(double[] xp,
double[] yp,
int count)
Creates a
Polygon from the specified double
coordinates. |
static int |
doubleToInts(int count,
double[] xpoints,
double[] ypoints,
int[] xp,
int[] yp,
boolean filter)
Converts the specified double coordinates into integer coordinates.
|
static FontRenderContext |
getFRC(boolean antiAliased,
boolean fractionalMetrics)
Returns a
FontRenderContext with the specified rendering
hints. |
static Rectangle2D |
grow(Rectangle2D rect,
double h,
double v)
Resizes the specified
Rectangle2D both horizontally and vertically. |
static boolean |
isEmpty(Insets insets)
Indicates whether the specified
Insets object is empty. |
static boolean |
lineIntersectsCircle(Line2D line,
double x,
double y,
double radius)
Returns whether the specified line intersects the specified circle.
|
static Insets |
mergeInsets(Insets result,
Insets insets)
Merge the specified insets.
|
static void |
paintJLabel(Graphics g,
JLabel label,
Rectangle bounds)
Paints the foreground content (text and icon) of a
JLabel
according to the given bounds. |
static double |
pointAngle(double x1,
double y1,
double x2,
double y2)
Returns the angle in radians formed by the specified points.
|
static double |
pointAngleDeg(double x1,
double y1,
double x2,
double y2)
Returns the angle in degrees, formed by the specified points.
|
static boolean |
rectangleIntersectsCircle(Rectangle2D rect,
double x,
double y,
double radius)
Returns whether the specified rectangle intersects the specified circle.
|
static boolean |
startAntiAliasing(Graphics g)
Activates anti-aliasing on the specified
Graphics context. |
static boolean |
startTextAntiAliasing(Graphics g)
Activates text anti-aliasing on the specified
Graphics
context. |
static void |
stopAntiAliasing(Graphics g)
Deactivates anti-aliasing on the specified
Graphics context. |
static void |
stopTextAntiAliasing(Graphics g)
Deactivates text anti-aliasing on the specified
Graphics
context. |
static int |
toInt(double coord)
Converts a double coordinate to an integer coordinate.
|
static Rectangle |
toRectangle(Rectangle2D r2d,
Rectangle r)
Converts a
Rectangle2D object into a Rectangle
object. |
static Rectangle2D |
transform(Rectangle2D bounds,
AffineTransform t)
Applies an affine transformation to a bounding rectangle.
|
public static boolean startAntiAliasing(Graphics g)
Graphics
context.
This method does not activate text anti-aliasing. In order to toggle text
anti-aliasing, use the startTextAntiAliasing(java.awt.Graphics)
and
stopTextAntiAliasing(java.awt.Graphics)
methods.g
- The considered Graphics
.public static void stopAntiAliasing(Graphics g)
Graphics
context.startAntiAliasing(java.awt.Graphics)
public static boolean startTextAntiAliasing(Graphics g)
Graphics
context.
Text anti-aliasing can only be turned on when global anti-aliasing is
enabled.g
- The considered Graphics
.startAntiAliasing(java.awt.Graphics)
public static void stopTextAntiAliasing(Graphics g)
Graphics
context.startTextAntiAliasing(java.awt.Graphics)
public static Rectangle applyInsets(Rectangle r, Insets insets)
public static int compareInsets(Insets i1, Insets i2)
Insets
objects.-1
if all the insets of i1
are
less than the insets of i2
, 0
if all the
insets are equal, and 1
otherwise.public static boolean isEmpty(Insets insets)
Insets
object is empty.true
if all the insets of insets
are
equal to 0
, and false
otherwise.public static Insets mergeInsets(Insets result, Insets insets)
result
- The first insets, which is also used to store the result.insets
- The second insets.result
.public static final double pointAngle(double x1, double y1, double x2, double y2)
public static final double pointAngleDeg(double x1, double y1, double x2, double y2)
public static final void addToRect(Rectangle r, int x, int y)
1
, and a top-left corner
located at the specified coordinates.public static final void addToRect(Rectangle r1, Rectangle r2)
r1
and r2
and returns the result into r1
. The behavior of this method
differs from the corresponding add
method of
java.awt.Rectangle
when one of the rectangle is empty: in
that case, the result is equal to the non-empty rectangle.public static final Rectangle2D addToRect(Rectangle2D r, double x, double y)
1
, and a top-left corner
located at the specified coordinates.r
- The considered rectangle. This rectangle is modified and
returned by the method.x
- The x-coordinate of the point to add.y
- The x-coordinate of the point to add.public static final Rectangle2D addToRect(Rectangle2D r1, Rectangle2D r2)
r1
and r2
and returns the result into r1
. The behavior of this method
differs from the corresponding add
method of
java.awt.geom.Rectangle2D
when one of the rectangle is empty:
in that case, the result is equal to the non-empty rectangle.r1
- The first rectangle. This rectangle is modified and
returned by the method.r2
- The second rectangle.public static final Rectangle toRectangle(Rectangle2D r2d, Rectangle r)
Rectangle2D
object into a Rectangle
object.r2d
- The Rectangle2D
object to convert.r
- A Rectangle
object optionally used to
store the result. If null
, a new Rectangle
is
allocated.public static Rectangle2D grow(Rectangle2D rect, double h, double v)
Rectangle2D
both horizontally and vertically.
This method modifies rect
so that it is
h
units larger on both the left and right side,
and v
units larger both at the top and bottom side.
The new Rectangle2D
has
(r.getX() - w, r.getY() - h)
as its top-left corner, a
width of r.getWidth() + 2*w
, and a height of
r.getHeight() + 2*h
.
If negative values are supplied for h
and
v
, the size of the Rectangle2D
decreases accordingly.
rect
- The rectangle to resize. This rectangle is modified by the
method.h
- The horizontal expansion.v
- The vertical expansion.public static Rectangle2D transform(Rectangle2D bounds, AffineTransform t)
bounds
- The initial bounds. This rectangle is modified by this
method.t
- The considered transformation.public static double computeYSeg(double x1, double y1, double x2, double y2, double x)
public static double computeXSeg(double x1, double y1, double x2, double y2, double y)
public static boolean lineIntersectsCircle(Line2D line, double x, double y, double radius)
line
- A line segment.x
- The x-coordinate of the center of the circle to test.y
- The y-coordinate of the center of the circle to test.radius
- The radius of the circle to test, should be > 0.IlvShapeUtil.distanceTo(Line2D, double, double, Point2D)
public static boolean rectangleIntersectsCircle(Rectangle2D rect, double x, double y, double radius)
rect
- A rectangle.x
- The x-coordinate of the center of the circle to test.y
- The y-coordinate of the center of the circle to test.radius
- The radius of the circle to test.IlvShapeUtil.distanceTo(Rectangle2D, double, double, Point2D)
public static final int toInt(double coord)
public static int doubleToInts(int count, double[] xpoints, double[] ypoints, int[] xp, int[] yp, boolean filter)
count
- The number of coordinates to convert.xpoints
- The x-double coordinates.ypoints
- The y-double coordinates.xp
- The returned x-integer coordinates. The array size must be at
least equal to count
.yp
- The returned y-integer coordinates. The array size must be at
least equal to count
.filter
- A boolean value indicating whether the method should prune
consecutive coordinates when they are equal.count
if the filter
parameter is set to true
.public static Polygon createPolygon(double[] xp, double[] yp, int count)
Polygon
from the specified double
coordinates.xp
- The x-double coordinates.yp
- The y-double coordinates.count
- The number of coordinates.public static IlvDoublePoint computeTextLocation(IlvDoublePoint loc, double angle, int offset, double width, double height)
loc
- The reference point. This parameter is modified and
returned by the method.angle
- The angle in degrees between the center of the text
and the reference point.offset
- The desired distance between the point and the text
boundaries.width
- The width of the text.height
- The height of the text.public static final FontRenderContext getFRC(boolean antiAliased, boolean fractionalMetrics)
FontRenderContext
with the specified rendering
hints.antiAliased
- Specifies whether anti-aliased is used.fractionalMetrics
- Specifies whether fractional metrics are used.public static void paintJLabel(Graphics g, JLabel label, Rectangle bounds)
JLabel
according to the given bounds.
Assumes that the background (if any) of the JLabel
has already
been painted and that the needed font and anti-aliasing settings have been
set on the Graphics
context.
Can be called in any thread.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.