public class TextUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.awt.geom.Rectangle2D |
drawAlignedString(java.lang.String text,
java.awt.Graphics2D g2,
float x,
float y,
TextAnchor anchor)
Draws a string such that the specified anchor point is aligned to the
given
(x, y) location. |
static void |
drawRotatedString(java.lang.String text,
java.awt.Graphics2D g2,
double angle,
float x,
float y)
A utility method for drawing rotated text.
|
static void |
drawRotatedString(java.lang.String text,
java.awt.Graphics2D g2,
float textX,
float textY,
double angle,
float rotateX,
float rotateY)
A utility method for drawing rotated text.
|
static void |
drawRotatedString(java.lang.String text,
java.awt.Graphics2D g2,
float x,
float y,
TextAnchor textAnchor,
double angle,
float rotationX,
float rotationY)
Draws a string that is aligned by one anchor point and rotated about
another anchor point.
|
static void |
drawRotatedString(java.lang.String text,
java.awt.Graphics2D g2,
float x,
float y,
TextAnchor textAnchor,
double angle,
TextAnchor rotationAnchor)
Draws a string that is aligned by one anchor point and rotated about
another anchor point.
|
static java.awt.geom.Rectangle2D |
getTextBounds(java.lang.String text,
java.awt.Graphics2D g2,
java.awt.FontMetrics fm)
Returns the bounds for the specified text.
|
public static java.awt.geom.Rectangle2D drawAlignedString(java.lang.String text, java.awt.Graphics2D g2, float x, float y, TextAnchor anchor)
(x, y)
location.text
- the text.g2
- the graphics device.x
- the x coordinate (Java 2D).y
- the y coordinate (Java 2D).anchor
- the anchor location.public static java.awt.geom.Rectangle2D getTextBounds(java.lang.String text, java.awt.Graphics2D g2, java.awt.FontMetrics fm)
text
- the text (null
permitted).g2
- the graphics context (not null
).fm
- the font metrics (not null
).null
if the text
argument is null
).public static void drawRotatedString(java.lang.String text, java.awt.Graphics2D g2, float x, float y, TextAnchor textAnchor, double angle, float rotationX, float rotationY)
text
- the text.g2
- the graphics device.x
- the x-coordinate for positioning the text.y
- the y-coordinate for positioning the text.textAnchor
- the text anchor.angle
- the rotation angle.rotationX
- the x-coordinate for the rotation anchor point.rotationY
- the y-coordinate for the rotation anchor point.public static void drawRotatedString(java.lang.String text, java.awt.Graphics2D g2, float x, float y, TextAnchor textAnchor, double angle, TextAnchor rotationAnchor)
text
- the text.g2
- the graphics device.x
- the x-coordinate for positioning the text.y
- the y-coordinate for positioning the text.textAnchor
- the text anchor.angle
- the rotation angle (in radians).rotationAnchor
- the rotation anchor.public static void drawRotatedString(java.lang.String text, java.awt.Graphics2D g2, double angle, float x, float y)
A common rotation is -Math.PI/2
which draws text 'vertically'
(with the top of the characters on the left).
text
- the text.g2
- the graphics device.angle
- the angle of the (clockwise) rotation (in radians).x
- the x-coordinate.y
- the y-coordinate.public static void drawRotatedString(java.lang.String text, java.awt.Graphics2D g2, float textX, float textY, double angle, float rotateX, float rotateY)
A common rotation is -Math.PI/2
which draws text 'vertically'
(with the top of the characters on the left).
text
- the text.g2
- the graphics device.textX
- the x-coordinate for the text (before rotation).textY
- the y-coordinate for the text (before rotation).angle
- the angle of the (clockwise) rotation (in radians).rotateX
- the point about which the text is rotated.rotateY
- the point about which the text is rotated.