Class TextState

java.lang.Object
com.spinyowl.legui.component.optional.TextState
All Implemented Interfaces:
Serializable

public class TextState extends Object implements Serializable
Used to hold text state of components.
See Also:
  • Field Details

    • INTEGER_VALIDATOR

      public static final Predicate<String> INTEGER_VALIDATOR
    • NUMBER_VALIDATOR

      public static final Predicate<String> NUMBER_VALIDATOR
  • Constructor Details

    • TextState

      public TextState()
      Default constructor.
    • TextState

      public TextState(String text)
      Used to create TextState with predefined text.
      Parameters:
      text - text to set.
    • TextState

      public TextState(BiConsumer<String,String> textSetCallback)
      Used to create TextState with predefined text.
      Parameters:
      textSetCallback - callback to call some extra functionality after setText(String). Accepts old value as first arg, and new value as the second arg.
    • TextState

      public TextState(String text, BiConsumer<String,String> textSetCallback)
      Used to create TextState with predefined text.
      Parameters:
      text - text to set.
      textSetCallback - callback to call some extra functionality after setText(String). Accepts old value as first arg, and new value as the second arg.
  • Method Details

    • getText

      public String getText()
      Returns text.
      Returns:
      text.
    • setText

      public void setText(String text)
      Used to set new text.
      Parameters:
      text - new text.
    • length

      public int length()
      Returns text length.
      Returns:
      text length.
      See Also:
    • getMouseCaretPosition

      public int getMouseCaretPosition()
      Returns mouse caret position.
      Returns:
      mouse caret position.
    • setMouseCaretPosition

      public void setMouseCaretPosition(int mouseCaretPosition)
      Used to set mouse caret position.
      Parameters:
      mouseCaretPosition - mouse caret position to set.
    • isEditable

      public boolean isEditable()
      Returns true if text is editable.
      Returns:
      true if text is editable.
    • setEditable

      public void setEditable(boolean editable)
      Used to set editable text or not.
      Parameters:
      editable - editable text or not.
    • getCaretPosition

      public int getCaretPosition()
      Returns caret position.
      Returns:
      caret position.
    • setCaretPosition

      public void setCaretPosition(int caretPosition)
      Used to set caret position.
      Parameters:
      caretPosition - caret position to set.
    • getStartSelectionIndex

      public int getStartSelectionIndex()
      Returns start selection index.
      Returns:
      start selection index.
    • setStartSelectionIndex

      public void setStartSelectionIndex(int startSelectionIndex)
      Used to set start selection index.
      Parameters:
      startSelectionIndex - start selection index to set.
    • getEndSelectionIndex

      public int getEndSelectionIndex()
      Returns end selection index.
      Returns:
      end selection index.
    • setEndSelectionIndex

      public void setEndSelectionIndex(int endSelectionIndex)
      Used to set end selection index.
      Parameters:
      endSelectionIndex - end selection index to set.
    • getSelection

      public String getSelection()
      Returns selected text.
      Returns:
      selected text.
    • getTextWidth

      public float getTextWidth()
    • setTextWidth

      public void setTextWidth(float textWidth)
    • getTextHeight

      public float getTextHeight()
    • setTextHeight

      public void setTextHeight(float textHeight)
    • getCaretX

      public Float getCaretX()
      Absolute caret X position.
      Returns:
      absolute caret X position.
    • setCaretX

      public void setCaretX(Float caretX)
      Used by renderer to set absolute caret x position.
      Parameters:
      caretX - caret x position.
    • getCaretY

      public Float getCaretY()
      Absolute caret Y position.
      Returns:
      absolute caret Y position.
    • setCaretY

      public void setCaretY(Float caretY)
      Used by renderer to set absolute caret y position.
      Parameters:
      caretY - caret x position.
    • getTextSetCallback

      public BiConsumer<String,String> getTextSetCallback()
    • setTextSetCallback

      public void setTextSetCallback(BiConsumer<String,String> textSetCallback)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getValidator

      public Predicate<String> getValidator()
    • setValidator

      public void setValidator(Predicate<String> validator)