Class Text

java.lang.Object
com.motivewave.platform.sdk.draw.Text
All Implemented Interfaces:
Cloneable

public class Text extends Object implements Cloneable
Encapsulates text that can be resized and displayed to the given graphics context.
Author:
Tony Lindsay
  • Constructor Details

    • Text

      public Text()
      Constructor. Creates a Text object with default properties
    • Text

      public Text(String text)
      Constructor. Creates a Text object with default properties
    • Text

      public Text(String txt, Font f)
      Constructor.
      Parameters:
      txt -
      f -
    • Text

      public Text(String txt, Font font, Insets insets, boolean showBox)
      Constructor.
      Parameters:
      txt -
      font -
      insets -
      showBox -
  • Method Details

    • destroy

      public void destroy()
    • draw

      public void draw(Graphics2D gc)
      Draws the text within the given bounds.
      Parameters:
      gc - graphics context
    • getText

      public String getText()
      Gets the text to display when drawing this object.
      Returns:
      text to display
    • setText

      public void setText(String text)
      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

      public void setFont(Font font)
      Sets the font to use when drawing the text.
      Parameters:
      font - font
    • getFont

      public Font getFont()
      Gets the font for displaying the text.
    • setBorderColor

      public void setBorderColor(Color color)
      Sets the color for the border of the text.
      Parameters:
      color - border color
    • getBorderColor

      public Color getBorderColor()
      Gets the border color.
      Returns:
      the color of the border
    • setBorderStroke

      public void setBorderStroke(BasicStroke stroke)
      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

      public void setBackground(Color color)
      Sets the background color for the outline. Use 'null' if the background should not be drawn.
      Parameters:
      color - background color
    • getBackground

      public Color getBackground()
      Gets the background color for the outline.
      Returns:
      background color for the text (null if no background)
    • setBGColor1

      public void setBGColor1(Color c)
    • getBGColor1

      public Color getBGColor1()
    • setBGColor2

      public void setBGColor2(Color c)
    • getBGColor2

      public Color getBGColor2()
    • setTextColor

      public void setTextColor(Color color)
      Sets the text color.
      Parameters:
      color - color of the text
    • getTextColor

      public Color getTextColor()
      Gets the text color.
      Returns:
      the color of the text
    • setHAlign

      public void setHAlign(Enums.TextAlign align)
      Sets the horizontal alignment.
      Parameters:
      align - horizontal alignment
    • setVAlign

      public void setVAlign(Enums.TextAlign align)
      Sets the vertical alignment.
      Parameters:
      align - vertical alignment
    • getInsets

      public Insets 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 inset
      left - left inset
      bottom - bottom inset
      right - 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

      public void setImage(Image img)
      Sets an image to display with the text.
      Parameters:
      img - image
    • getImage

      public Image getImage()
      Gets the image to display next to the text.
      Returns:
      image displayed next to the text
    • getLines

      public List<String> getLines()
      Gets the lines of text (text separated by newlines or word wrap)
      Returns:
      text separated as lines (for display purposes)
    • setDisplayFont

      public void setDisplayFont(Font f)
    • getDisplayFont

      public Font getDisplayFont()
    • adjustFont

      public Rectangle2D adjustFont(Font f)
      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

      public void layout(int width, Font f)
    • contains

      public boolean contains(double x, double y)
    • getBounds

      public Rectangle2D getBounds()
    • getOutline

      public Shape getOutline()
    • setHighlighted

      public void setHighlighted(boolean b)
    • isHighlighted

      public boolean isHighlighted()
    • setBounds

      public void setBounds(double x, double y, double width, double height)
    • getBorderStroke

      public Stroke getBorderStroke()
    • setBorderStroke

      public void setBorderStroke(Stroke s)
    • setLocation

      public void setLocation(Point2D p)
    • setLocation

      public void setLocation(double x, double y)
    • setCenter

      public void setCenter(Point2D p)
    • setCenter

      public void setCenter(double x, double y)
    • setHandle

      public void setHandle(Point2D p)
    • getHandle

      public Point2D 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

      public Point2D getCenter()
    • getLocation

      public Point2D getLocation()
    • setAngle

      public void setAngle(double radians)
    • getAngle

      public double getAngle()
    • setOutline

      public void setOutline(Enums.TextOutline outline)
    • clone

      public Text clone()
      Overrides:
      clone in class Object