Package snap.text

Class StringBox

All Implemented Interfaces:
Cloneable

public class StringBox extends RoundRect
This class manages a string and a bounding rect.
  • Constructor Details

    • StringBox

      public StringBox()
      Constructor.
    • StringBox

      public StringBox(String aString)
      Constructor.
  • Method Details

    • getSvgString

      public String getSvgString()
      Returns the string.
      Overrides:
      getSvgString in class RectBase
    • length

      public int length()
      Returns the length of the string.
    • setString

      public void setString(String aString)
      Sets the string.
    • getTextStyle

      public TextStyle getTextStyle()
      Returns the TextStyle.
    • setTextStyle

      public void setTextStyle(TextStyle textStyle)
      Sets the TextStyle.
    • getFont

      public Font getFont()
      Returns the font.
    • setFont

      public void setFont(Font aFont)
      Sets the font.
    • getTextColor

      public Color getTextColor()
      Returns the color for string text.
    • setTextColor

      public void setTextColor(Color aColor)
      Sets the color for string text.
    • isUnderlined

      public boolean isUnderlined()
      Returns whether this run is underlined.
    • setUnderlined

      public void setUnderlined(boolean aValue)
      Sets whether this run is underlined.
    • getScripting

      public int getScripting()
      Returns the run's scripting.
    • getBorder

      public Border getBorder()
      Returns the border.
    • setBorder

      public void setBorder(Border aBorder)
      Sets the border.
    • setBorder

      public void setBorder(Color aColor, double aWidth)
      Sets the border for given color and stroke width.
    • getPadding

      public Insets getPadding()
      Returns the padding.
    • setPadding

      public void setPadding(Insets theInsets)
      Sets the padding.
    • setPadding

      public void setPadding(double aTop, double aRgt, double aBtm, double aLft)
      Sets the padding to given insets.
    • getAlign

      public Pos getAlign()
      Returns how the string is positioned in the box if larger than String width/height (default is Top-Left).
    • setAlign

      public void setAlign(Pos aPos)
      Sets how the string is positioned in the box if larger than String width/height (default is Top-Left).
    • isFontSizing

      public boolean isFontSizing()
      Returns whether to size to font (looser) instead of glyphs (tighter).
    • setFontSizing

      public void setFontSizing(boolean aValue)
      Sets whether to size to font (looser) instead of glyphs (tighter).
    • isHyphenated

      public boolean isHyphenated()
      Returns whether this run has a hyphen at the end.
    • setHyphenated

      public void setHyphenated(boolean aFlag)
      Sets whether this run has a hyphen at the end.
    • getInsetsAll

      public Insets getInsetsAll()
      Returns the total insets due to border and/or padding.
    • resize

      public void resize()
      Resizes bounds to fit string.
    • getStringWidth

      public double getStringWidth()
      Returns the width of the string (aka the 'advance').
    • getStringHeight

      public double getStringHeight()
      Returns the height of the current string/font (aka the 'line height').
    • getAscent

      public double getAscent()
      Returns the ascent.
    • getDescent

      public double getDescent()
      Returns the descent.
    • getPrefWidth

      public double getPrefWidth()
      Returns the preferred width of box.
    • getPrefHeight

      public double getPrefHeight()
      Returns the preferred height of box.
    • getStringX

      public double getStringX()
      Returns the string X point.
    • getStringY

      public double getStringY()
      Returns the string Y point.
    • setStringXY

      public void setStringXY(double aX, double aY)
      Sets the string X/Y.
    • drawString

      public void drawString(Painter aPntr)
      Draws the string.
    • drawRect

      public void drawRect(Painter aPntr)
      Draws the string.
    • paint

      public void paint(Painter aPntr)
      Paints the string box.
    • setWidth

      public void setWidth(double aValue)
      Override to mark sized.
      Overrides:
      setWidth in class RectBase
    • setCenteredXY

      public void setCenteredXY(double aX, double aY)
      Override to size.
      Overrides:
      setCenteredXY in class RectBase
    • clone

      public StringBox clone()
      Standard clone implementation.
      Overrides:
      clone in class RectBase
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class RectBase
    • getForStringAndAttributes

      public static StringBox getForStringAndAttributes(String aStr, Object... theAttrs)
      Returns a StringBox for string and attributes.