Package snap.text

Class TextStyle

All Implemented Interfaces:
Cloneable, PropChange.DoChange

public class TextStyle extends PropObject implements Cloneable
A class to hold style attributes for a text run.
  • Field Details

  • Constructor Details

    • TextStyle

      public TextStyle()
      Creates a new TextStyle.
    • TextStyle

      public TextStyle(Object... theAttrs)
      Creates a new TextStyle for given attributes.
  • Method Details

    • getFont

      public Font getFont()
      Returns the font for this run.
    • getColor

      public Color getColor()
      Returns the color for this run.
    • isUnderlined

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

      public int getUnderlineStyle()
      Returns the underline style of this run.
    • getScripting

      public int getScripting()
      Returns the scripting for this run (1=SuperScripting, -1=Subscripting, 0=none).
    • getCharSpacing

      public double getCharSpacing()
      Returns the char spacing.
    • getLink

      public TextLink getLink()
      Returns the link.
    • getFormat

      public TextFormat getFormat()
      Returns the format.
    • getBorder

      public Border getBorder()
      Returns the text border.
    • getCharAdvance

      public double getCharAdvance(char aChar)
      Returns the char advance for a given character.
    • getAscent

      public double getAscent()
      Returns the max distance above the baseline for this run font.
    • getDescent

      public double getDescent()
      Returns the max distance below the baseline that this font goes.
    • getLeading

      public double getLeading()
      Returns the default distance between lines for this font.
    • getLineHeight

      public double getLineHeight()
      Returns the line height.
    • getLineAdvance

      public double getLineAdvance()
      Returns the line advance.
    • equals

      public boolean equals(Object anObj)
      Standard equals implementation.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Standard hashCode implementation.
      Overrides:
      hashCode in class Object
    • clone

      public TextStyle clone()
      Standard clone implementation.
      Overrides:
      clone in class PropObject
    • copyFor

      public TextStyle copyFor(Object anObj)
      Clone with new value.
    • copyFor

      public TextStyle copyFor(Object... theObjs)
      Clone with new values.
    • copyFor

      public TextStyle copyFor(String aKey, Object aValue)
      Clone with key/value.
    • copyFor

      public TextStyle copyFor(Map<? super Object,? super Object> aMap)
      Clone with map.
    • copyForPropsString

      public TextStyle copyForPropsString(String propsString)
      Returns a copy of this style for given props string.
    • initProps

      protected void initProps(PropSet aPropSet)
      Initialize Props. Override to provide custom defaults.
      Overrides:
      initProps in class PropObject
    • getPropValue

      public Object getPropValue(String aPropName)
      Returns the value for given prop name.
      Overrides:
      getPropValue in class PropObject
    • setPropValue

      public void setPropValue(String aPropName, Object aValue)
      Sets the value for given prop name.
      Overrides:
      setPropValue in class PropObject
    • getStyleKey

      public static String getStyleKey(Object anAttr)
      Returns the most likely style key for a given attribute.
    • createForPropsString

      public static TextStyle createForPropsString(String propsString)
      Creates a TextStyle for given prop string.