java.lang.Object
com.glitchybyte.glib.terminal.display.GPanel
Direct Known Subclasses:
GRootPanel

public abstract class GPanel extends Object
Terminal UI panel.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    Panel height.
    protected GRootPanel
    Root panel that contains all panels.
    final int
    Panel width.
    final int
    X position.
    final int
    Y position.
    final int
    Panel Z position.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GPanel(int zOrder, int x, int y, int width, int height)
    Creates a terminal panel.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a child panel to this panel.
    protected abstract String
    Creates the panel imprint.
    protected void
    Draws the panel.
    protected String
    fill(char glyph, Integer fgColor, Integer bgColor)
    Convenience method to fill the panel area with a glyph and colors.
    protected String
    Convenience method to fill the panel with a background color.
    protected int
    Returns the distance from the left of the screen to the left side of this panel.
    protected int
    Returns the distance from the top of the root panel the top side of this panel.
    protected String
    Returns a String to move the cursor to the X offset.
    void
    Refreshes the imprint.
    void
    Refreshes this panel and all its children.
    void
    Signals this panel's contents have changed and needs to be refreshed.

    Methods inherited from class java.lang.Object

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

    • zOrder

      public final int zOrder
      Panel Z position. Lower number gets drawn first.
    • x

      public final int x
      X position.
    • y

      public final int y
      Y position.
    • width

      public final int width
      Panel width.
    • height

      public final int height
      Panel height.
    • rootPanel

      protected GRootPanel rootPanel
      Root panel that contains all panels.
  • Constructor Details

    • GPanel

      public GPanel(int zOrder, int x, int y, int width, int height)
      Creates a terminal panel.
      Parameters:
      zOrder - Panel Z position. Lower number gets drawn first.
      x - X position.
      y - Y position.
      width - Panel width.
      height - Panel height.
  • Method Details

    • addPanel

      public void addPanel(GPanel panel)
      Adds a child panel to this panel.
      Parameters:
      panel - Child panel.
    • getXOffset

      protected int getXOffset()
      Returns the distance from the left of the screen to the left side of this panel.
      Returns:
      The distance from the left of the screen to the left side of this panel.
    • getYOffset

      protected int getYOffset()
      Returns the distance from the top of the root panel the top side of this panel.
      Returns:
      The distance from the top of the root panel the top side of this panel.
    • moveToXOffset

      protected String moveToXOffset()
      Returns a String to move the cursor to the X offset.
      Returns:
      A String to move the cursor to the X offset.
    • createImprint

      protected abstract String createImprint()
      Creates the panel imprint.

      This method MUST return the cursor to the same line. Horizontal position is not important.

      Returns:
      A complete imprint of the panel.
    • signalDirty

      public void signalDirty()
      Signals this panel's contents have changed and needs to be refreshed.
    • refresh

      public void refresh()
      Refreshes the imprint.
    • refreshAll

      public void refreshAll()
      Refreshes this panel and all its children.
    • drawPanel

      protected void drawPanel()
      Draws the panel.
    • fill

      protected String fill(char glyph, Integer fgColor, Integer bgColor)
      Convenience method to fill the panel area with a glyph and colors.
      Parameters:
      glyph - Glyph to fill the area with.
      fgColor - Foreground color.
      bgColor - Background color.
      Returns:
      A String to fill the panel area with a glyph and colors.
    • fillBackground

      protected String fillBackground(Integer bgColor)
      Convenience method to fill the panel with a background color.
      Parameters:
      bgColor - Background color.
      Returns:
      A String to fill the panel area with a background color.