Class AbstractLabelUIComponent

All Implemented Interfaces:
UIKeyHandler, Textable, Hintable, Savable
Direct Known Subclasses:
UIButton, UILabel

public abstract class AbstractLabelUIComponent extends StateBasedUIComponent implements Textable
A state component containing a text label and an icon. These are separated by an optional gap and can also be given a specific alignment. By default, the text is aligned LEFT and has no icon or gap.
  • Field Details

    • _styled

      protected boolean _styled
      If true, our text could be marked up with style information.
  • Constructor Details

    • AbstractLabelUIComponent

      public AbstractLabelUIComponent()
  • Method Details

    • updateMinimumSizeFromContents

      public void updateMinimumSizeFromContents()
      Description copied from class: UIComponent
      Ask this component to update its minimum allowed size, based on its contents.
      Overrides:
      updateMinimumSizeFromContents in class UIComponent
    • getText

      public String getText()
      Specified by:
      getText in interface Textable
      Returns:
      the currently set text value of this label.
    • setText

      public void setText(String text)
      Set the text for this component. Also updates the minimum size of the component.
      Specified by:
      setText in interface Textable
      Parameters:
      text - the new text
    • isStyledText

      public boolean isStyledText()
      Specified by:
      isStyledText in interface Textable
    • setStyledText

      public void setStyledText(boolean value)
      Specified by:
      setStyledText in interface Textable
    • updateChildren

      protected void updateChildren(double time)
      Description copied from class: Spatial
      Override to allow objects like Node to update their children.
      Overrides:
      updateChildren in class Node
      Parameters:
      time - The time in seconds between the last two consecutive frames (time per frame). See ReadOnlyTimer.getTimePerFrame()
    • getAlignment

      public Alignment getAlignment()
    • setAlignment

      public void setAlignment(Alignment alignment)
    • getGap

      public int getGap()
    • setGap

      public void setGap(int gap)
      Note: Also updates the minimum size of the component.
      Parameters:
      gap - the size of the gap, in pixels, between the text and the label text. This is only used if both icon and text are set.
    • getIcon

      public SubTex getIcon()
    • setIcon

      public void setIcon(SubTex icon)
      Note: Also updates the minimum size of the component.
      Parameters:
      icon - the new icon for this label.
    • updateIconDimensionsFromIcon

      public void updateIconDimensionsFromIcon()
      Set the icon dimensions from the currently set icon. If no icon is set, the dimensions are set to 0x0.
    • setIconDimensions

      public void setIconDimensions(Dimension dimensions)
      Overrides any currently set icon size. Call this after setting the icon to prevent overriding.
      Parameters:
      dimensions - a new icon size.
    • getIconDimensions

      public Dimension getIconDimensions()
    • fireStyleChanged

      public void fireStyleChanged()
      Description copied from class: UIComponent
      Let subcomponents know that style has been changed.
      Overrides:
      fireStyleChanged in class UIComponent
    • drawComponent

      protected void drawComponent(Renderer renderer)
      Description copied from class: UIComponent
      Draw this component's contents using the given renderer.
      Overrides:
      drawComponent in class UIComponent
      Parameters:
      renderer - the renderer
    • getTextObject

      public RenderedText getTextObject()