Package com.motivewave.platform.sdk.draw
Class Text
java.lang.Object
com.motivewave.platform.sdk.draw.Text
- All Implemented Interfaces:
Cloneable
Encapsulates text that can be resized and displayed to the given
graphics context.
- Author:
- Tony Lindsay
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadjustFont
(Font f) Adjusts the font of the text while retaining the current line layout.clone()
void
compact()
Compresses the bounds to fit exactly the size of the text as per the last call to layout()boolean
contains
(double x, double y) void
destroy()
void
draw
(Graphics2D gc) Draws the text within the given bounds.double
getAngle()
Gets the background color for the outline.Gets the border color.getFont()
Gets the font for displaying the text.double
getImage()
Gets the image to display next to the text.Gets the text insets.getLines()
Gets the lines of text (text separated by newlines or word wrap)double
getMaxX()
double
getMaxY()
getText()
Gets the text to display when drawing this object.Gets the text color.double
getWidth()
double
getX()
double
getY()
boolean
boolean
Indicates if the border should be shown around the text.boolean
Indicates if the outline of the text should be drawn.boolean
void
layout()
Layout the text using the internal widthvoid
layout
(int maxWidth) Layout the text using the internal widthvoid
void
setAngle
(double radians) void
setBackground
(Color color) Sets the background color for the outline.void
setBGColor1
(Color c) void
setBGColor2
(Color c) void
setBorderColor
(Color color) Sets the color for the border of the text.void
setBorderStroke
(BasicStroke stroke) Sets the stroke for the border line.void
void
setBounds
(double x, double y, double width, double height) void
setCenter
(double x, double y) void
void
void
Sets the font to use when drawing the text.void
setHAlign
(Enums.TextAlign align) Sets the horizontal alignment.void
void
setHighlighted
(boolean b) void
Sets an image to display with the text.void
setInsets
(int top, int left, int bottom, int right) Sets the insets for the text.void
setLocation
(double x, double y) void
void
setOutline
(Enums.TextOutline outline) void
setShowBorder
(boolean b) Sets the show border attribute for the text.void
setShowOutline
(boolean b) Sets the attribute for drawing the outline.void
Sets the text to display when drawing this object.void
setTextColor
(Color color) Sets the text color.void
setVAlign
(Enums.TextAlign align) Sets the vertical alignment.void
setVisible
(boolean b) Sets the visible.
-
Constructor Details
-
Text
public Text()Constructor. Creates a Text object with default properties -
Text
Constructor. Creates a Text object with default properties -
Text
Constructor.- Parameters:
txt
-f
-
-
Text
Constructor.- Parameters:
txt
-font
-insets
-showBox
-
-
-
Method Details
-
destroy
public void destroy() -
draw
Draws the text within the given bounds.- Parameters:
gc
- graphics context
-
getText
Gets the text to display when drawing this object.- Returns:
- text to display
-
setText
Sets the text to display when drawing this object. Newlines may be inserted into this text by adding newline characters (ie '\n').- Parameters:
text
- text to display
-
setFont
Sets the font to use when drawing the text.- Parameters:
font
- font
-
getFont
Gets the font for displaying the text. -
setBorderColor
Sets the color for the border of the text.- Parameters:
color
- border color
-
getBorderColor
Gets the border color.- Returns:
- the color of the border
-
setBorderStroke
Sets the stroke for the border line.- Parameters:
stroke
- border stroke
-
setShowOutline
public void setShowOutline(boolean b) Sets the attribute for drawing the outline.- Parameters:
b
- true if the outline should be drawn
-
isShowOutline
public boolean isShowOutline()Indicates if the outline of the text should be drawn.- Returns:
- true if the outline should be drawn
-
setShowBorder
public void setShowBorder(boolean b) Sets the show border attribute for the text.- Parameters:
b
- true if the border should be drawn
-
isShowBorder
public boolean isShowBorder()Indicates if the border should be shown around the text.- Returns:
- true if the border should be drawn
-
setBackground
Sets the background color for the outline. Use 'null' if the background should not be drawn.- Parameters:
color
- background color
-
getBackground
Gets the background color for the outline.- Returns:
- background color for the text (null if no background)
-
setBGColor1
-
getBGColor1
-
setBGColor2
-
getBGColor2
-
setTextColor
Sets the text color.- Parameters:
color
- color of the text
-
getTextColor
Gets the text color.- Returns:
- the color of the text
-
setHAlign
Sets the horizontal alignment.- Parameters:
align
- horizontal alignment
-
setVAlign
Sets the vertical alignment.- Parameters:
align
- vertical alignment
-
getInsets
Gets the text insets. -
setInsets
public void setInsets(int top, int left, int bottom, int right) Sets the insets for the text.- Parameters:
top
- top insetleft
- left insetbottom
- bottom insetright
- right inset
-
setVisible
public void setVisible(boolean b) Sets the visible.- Parameters:
b
- true if the text is visible
-
isVisible
public boolean isVisible()- Returns:
- true if the text is visible.
-
setImage
Sets an image to display with the text.- Parameters:
img
- image
-
getImage
Gets the image to display next to the text.- Returns:
- image displayed next to the text
-
getLines
Gets the lines of text (text separated by newlines or word wrap)- Returns:
- text separated as lines (for display purposes)
-
setDisplayFont
-
getDisplayFont
-
adjustFont
Adjusts the font of the text while retaining the current line layout.- Returns:
- new dimensions of the text
-
layout
public void layout()Layout the text using the internal width -
layout
public void layout(int maxWidth) Layout the text using the internal width -
compact
public void compact()Compresses the bounds to fit exactly the size of the text as per the last call to layout() -
layout
-
contains
public boolean contains(double x, double y) -
getBounds
-
getOutline
-
setHighlighted
public void setHighlighted(boolean b) -
isHighlighted
public boolean isHighlighted() -
setBounds
public void setBounds(double x, double y, double width, double height) -
getBorderStroke
-
setBorderStroke
-
setLocation
-
setLocation
public void setLocation(double x, double y) -
setCenter
-
setCenter
public void setCenter(double x, double y) -
setHandle
-
getHandle
-
getY
public double getY() -
getX
public double getX() -
getHeight
public double getHeight() -
getWidth
public double getWidth() -
getMaxY
public double getMaxY() -
getMaxX
public double getMaxX() -
getCenter
-
getLocation
-
setAngle
public void setAngle(double radians) -
getAngle
public double getAngle() -
setOutline
-
clone
-