Class Widget

java.lang.Object
app.ui.widgets.Widget
All Implemented Interfaces:
IDrawable
Direct Known Subclasses:
WidgetButton, WidgetLabel, WidgetPageSelection, WidgetTextBox, WidgetToggle

public abstract class Widget extends Object implements IDrawable
Abstract class for all widgets in the UI package. This class provides basic properties and functionalities common to all widgets, such as position, text, and visibility.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected int
     
    protected boolean
     
    protected String
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Widget(int x, int y, int len, String text)
    Constructor for Widget.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    draw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor)
    Abstract method to draw the widget.
    void
    drawText(char[][] buffer)
    Draws the text of the widget onto a buffer.
    int
    Returns the length of the widget.
    boolean
    Checks if the widget is selected.
    boolean
    Checks if the widget's selection is skipped.
    Returns the text of the widget.
    int
    Returns the widget ID.
    int
    Returns the x-coordinate of the widget.
    int
    Returns the y-coordinate of the widget.
    boolean
    Checks if the widget is hidden.
    void
    setHide(boolean ifHide)
    Sets the visibility of the widget.
    void
    setSkipSelection(boolean skipSelection)
    Sets whether the widget's selection should be skipped.
    void
    Sets the text of the widget.
    void
    setWidgetID(int id)
    Sets the widget ID.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      protected int x
    • y

      protected int y
    • len

      protected int len
    • selected

      protected boolean selected
    • text

      protected String text
    • hide

      protected boolean hide
  • Constructor Details

    • Widget

      public Widget(int x, int y, int len, String text)
      Constructor for Widget.
      Parameters:
      x - x coordinate of the widget.
      y - y coordinate of the widget.
      len - length of the widget.
      text - text of the widget.
  • Method Details

    • isHide

      public boolean isHide()
      Checks if the widget is hidden.
      Returns:
      true if the widget is hidden, false otherwise.
    • getSkipSelection

      public boolean getSkipSelection()
      Checks if the widget's selection is skipped.
      Returns:
      true if the widget's selection is skipped, false otherwise.
    • setSkipSelection

      public void setSkipSelection(boolean skipSelection)
      Sets whether the widget's selection should be skipped.
      Parameters:
      skipSelection - true to skip the selection, false otherwise.
    • setHide

      public void setHide(boolean ifHide)
      Sets the visibility of the widget.
      Parameters:
      ifHide - true to hide the widget, false to show it.
    • getLen

      public int getLen()
      Returns the length of the widget.
      Returns:
      The length of the widget.
    • getText

      public String getText()
      Returns the text of the widget.
      Returns:
      The text of the widget.
    • setText

      public void setText(String text)
      Sets the text of the widget.
      Parameters:
      text - The text to set for the widget.
    • getSelected

      public boolean getSelected()
      Checks if the widget is selected.
      Returns:
      true if the widget is selected, false otherwise.
    • getX

      public int getX()
      Returns the x-coordinate of the widget.
      Returns:
      The x-coordinate of the widget.
    • getY

      public int getY()
      Returns the y-coordinate of the widget.
      Returns:
      The y-coordinate of the widget.
    • drawText

      public void drawText(char[][] buffer)
      Draws the text of the widget onto a buffer.
      Specified by:
      drawText in interface IDrawable
      Parameters:
      buffer - The character buffer to draw onto.
    • setWidgetID

      public void setWidgetID(int id)
      Sets the widget ID.
      Parameters:
      id - The new ID for the widget.
    • getWidgetID

      public int getWidgetID()
      Returns the widget ID.
      Returns:
      The ID of the widget.
    • draw

      public abstract void draw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor)
      Abstract method to draw the widget. This method should be implemented by subclasses.
      Specified by:
      draw in interface IDrawable
      Parameters:
      buffer - The character buffer to draw onto.
      printColor - The array of text colors for each character.
      backColor - The array of background colors for each character.