Package org.csstudio.swt.widgets.util
Class TextPainter
java.lang.Object
org.csstudio.swt.widgets.util.TextPainter
Utility class for drawing text at different angles and alignments.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Alignment constants.static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
drawRotatedText
(org.eclipse.draw2d.Graphics gfx, String text, double angle, int x, int y, int align) Draws the given text, rotated for the specified angle (counter-clockwise).static void
Draws the given string horizontally at the given anchor point.static org.eclipse.draw2d.geometry.Point
Calculates the offset to the top-left corner of the text, according to the given anchor point.
-
Field Details
-
TOP_LEFT
public static final int TOP_LEFTAlignment constants.- See Also:
-
TOP_CENTER
public static final int TOP_CENTER- See Also:
-
TOP_RIGHT
public static final int TOP_RIGHT- See Also:
-
LEFT
public static final int LEFT- See Also:
-
CENTER
public static final int CENTER- See Also:
-
RIGHT
public static final int RIGHT- See Also:
-
BOTTOM_LEFT
public static final int BOTTOM_LEFT- See Also:
-
BOTTOM_CENTER
public static final int BOTTOM_CENTER- See Also:
-
BOTTOM_RIGHT
public static final int BOTTOM_RIGHT- See Also:
-
-
Constructor Details
-
TextPainter
public TextPainter()
-
-
Method Details
-
getDelta
public static org.eclipse.draw2d.geometry.Point getDelta(org.eclipse.draw2d.Graphics gfx, String text, int align) Calculates the offset to the top-left corner of the text, according to the given anchor point.- Parameters:
gfx
- the graphics context (need this to get the font)text
- the text to be drawnalign
- alignment- Returns:
- the point at which the text is to be drawn
-
drawText
Draws the given string horizontally at the given anchor point.- Parameters:
gfx
- the graphics contexttext
- the text to be drawnx
- the x coordinate of the anchory
- the y coordinate of the anchoralign
- where on the bounding box the anchor is
-
drawRotatedText
public static void drawRotatedText(org.eclipse.draw2d.Graphics gfx, String text, double angle, int x, int y, int align) Draws the given text, rotated for the specified angle (counter-clockwise). The text will be rotated around the anchor.- Parameters:
gfx
- the graphics contexttext
- the text to be drawnangle
- the rotation of the text, in degreesx
- the x coordinate of the anchory
- the y coordinate of the anchoralign
- where on the bounding box the anchor is
-