Package noaa.coastwatch.render
Class TextElement
java.lang.Object
noaa.coastwatch.render.AnnotationElement
noaa.coastwatch.render.TextElement
A text element is an annotation element the renders text strings.
The element specifies various text properties such as the text
string value, position, orientation, alignment, and so on. The
text is rendered in the annotation foreground color, and a drop
shadow in the background color.
- Since:
- 3.1.1
- Author:
- Peter Hollemans
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTextElement
(String text, Font font, Point2D base, double[] align, double angle) Creates a new text element with the specified properties.TextElement
(String text, Point2D base) Creates a new text element with the specified string and base point. -
Method Summary
Modifier and TypeMethodDescriptionGets the element bounding area.Gets the text base point.getFont()
Gets the text font.Gets the text layout object for this element.getText()
Gets the text string.void
render
(Graphics2D g2, Color foreground, Color background) Renders the element graphics.void
setAlignment
(double[] align) Sets the text alignment.void
setAngle
(double angle) Sets the text orientation angle.void
setBasePoint
(Point2D base) Sets the text base point.void
Sets the text font.void
Sets the text string.Methods inherited from class noaa.coastwatch.render.AnnotationElement
getBounds
-
Field Details
-
DEFAULT_FONT
The default font.
-
-
Constructor Details
-
TextElement
Creates a new text element with the specified string and base point. The font is initialized to the default 12 point plain font, the alignment to [0,0], and the angle to 0.- Parameters:
text
- the text string.base
- the text base point.
-
TextElement
Creates a new text element with the specified properties.- Parameters:
text
- the text string.font
- the text font.base
- the base point.align
- the text alignment as [horizontal, vertical]. The alignment is a set of normalized values in the range [0..1] which represent where in the bounding box of the text string the base point is located. For example if the alignment is [0,0], then the base point is at the lower-left corner of the text string. If the alignment is [0.5, 0], then the base point is at the bottom-center of the text string. If null, the alignment is set to [0,0].angle
- the orientation angle. The angle is measured in degrees and represents the angle between the horizontal and the text string baseline direction. For example, and angle of 45 would draw text from lower-left to upper-right.
-
-
Method Details
-
getLayout
Gets the text layout object for this element.- Parameters:
g
- the graphics device for drawing.
-
getText
Gets the text string. -
setText
Sets the text string. -
setBasePoint
Sets the text base point. -
getBasePoint
Gets the text base point. -
setAngle
public void setAngle(double angle) Sets the text orientation angle. -
setFont
Sets the text font. -
getFont
Gets the text font. -
setAlignment
public void setAlignment(double[] align) Sets the text alignment. -
render
Description copied from class:AnnotationElement
Renders the element graphics.- Specified by:
render
in classAnnotationElement
- Parameters:
g2
- the graphics object for drawing.foreground
- the foreground element color.background
- the background element color or null for no background.
-
getArea
Description copied from class:AnnotationElement
Gets the element bounding area.- Specified by:
getArea
in classAnnotationElement
- Parameters:
g
- the graphics object for drawing.
-