Package snap.view

Class Label

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable
Direct Known Subclasses:
ListCell

public class Label extends ParentView
A class to display simple text with associcated image(s).
  • Field Details

  • Constructor Details

    • Label

      public Label()
      Creates a label node.
    • Label

      public Label(String aStr)
      Creates a label node with given text.
    • Label

      public Label(View aGrph, String aStr, View aGrphAfter)
      Creates a label node with given graphic, text, and after graphic.
  • Method Details

    • getText

      public String getText()
      Returns the text.
      Overrides:
      getText in class View
    • setText

      public void setText(String aValue)
      Sets the text.
      Overrides:
      setText in class View
    • getImage

      public Image getImage()
      Returns the image.
    • setImage

      public void setImage(Image anImage)
      Sets the image.
    • getImageAfter

      public Image getImageAfter()
      Returns the image after text.
    • setImageAfter

      public void setImageAfter(Image anImage)
      Sets the image after text.
    • getTextColor

      public Color getTextColor()
      Returns the text color.
      Overrides:
      getTextColor in class View
    • setTextColor

      public void setTextColor(Color aColor)
      Sets the text color.
      Overrides:
      setTextColor in class View
    • getTextStyle

      public TextStyle getTextStyle()
      Returns the text style.
    • setTextStyle

      public void setTextStyle(TextStyle textStyle)
      Sets the text style.
    • setTextStyleString

      public void setTextStyleString(String styleString)
      Sets the text style to style updated for style string.
    • isStringViewSet

      protected boolean isStringViewSet()
      Returns the StringView.
    • getStringView

      protected StringView getStringView()
      Returns the StringView.
    • getGraphic

      public View getGraphic()
      Returns the graphic node.
    • setGraphic

      public void setGraphic(View aGraphic)
      Sets the graphic node.
    • getGraphicAfter

      public View getGraphicAfter()
      Returns the graphic node after the text.
    • setGraphicAfter

      public void setGraphicAfter(View aGraphic)
      Sets the graphic node after the text.
    • getImageName

      public String getImageName()
      Returns the image name, if loaded from local resource.
    • setImageName

      public void setImageName(String aName)
      Sets the image name, if loaded from local resource.
    • getTextBounds

      public Rect getTextBounds()
      Returns the text bounds.
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Returns the preferred width.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Returns the preferred height.
      Overrides:
      getPrefHeightImpl in class View
    • layoutImpl

      protected void layoutImpl()
      Layout children.
      Overrides:
      layoutImpl in class ParentView
    • getValuePropName

      public String getValuePropName()
      Returns a mapped property name.
      Overrides:
      getValuePropName in class View
    • setAlign

      public void setAlign(Pos aPos)
      Override to forward to StringView.
      Overrides:
      setAlign in class View
    • initProps

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

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

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

      public XMLElement toXMLView(XMLArchiver anArchiver)
      XML archival.
      Overrides:
      toXMLView in class ParentView
    • fromXMLView

      protected void fromXMLView(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Overrides:
      fromXMLView in class ParentView
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class PropObject