Class Window

java.lang.Object
app.ui.windows.Window
Direct Known Subclasses:
CampListView, ChangePasswordView, LoginView, StaffMainView, StudentMainView, WindowOverlayClass

public class Window extends Object
Class representing a basic window in a user interface. This class provides a foundation for creating windows in a user interface with text-based graphics. It includes methods for adding, removing, and managing widgets within the window, handling user input, and rendering the window's content on a screen.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.googlecode.lanterna.TextColor[][]
     
    protected char[][]
     
     
    protected com.googlecode.lanterna.TextColor[][]
     
    protected int
     
    protected List<Widget>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Window(int y, int x, String windowName)
    Constructor for Window class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addOverlay(WindowOverlayClass windowOverlayClass)
    Adds an overlay to the window.
    int
    addWidget(Widget widget)
    Adds a widget to the window.
    int
    addWidgetAfter(Widget widget, int afterWhich)
    addWidgetAfter method for the window.
    void
    clearArea(com.googlecode.lanterna.screen.Screen screen, int startX, int endX, int startY, int endY)
    clearArea method for the window.
    void
    clearOuterArea(com.googlecode.lanterna.screen.Screen screen, int x, int y, double transparency)
     
    void
    draw(com.googlecode.lanterna.screen.Screen screen, int x, int y, double transparency)
     
    int
    Gets the length of the window in the X direction.
    int
    Gets the length of the window in the Y direction.
    int
    switchToWindow method for the window.
    int
    getWidgetIndex method for the window.
    int
    Gets the X position of the window.
    int
    Gets the Y position of the window.
    void
    keyStroke(com.googlecode.lanterna.input.KeyStroke keyStroke)
    keyStroke method for the window.
    void
    keyStrokeHelper(com.googlecode.lanterna.input.KeyStroke keyStroke)
    keyStrokeHelper method for the window.
    void
    The main loop for processing window messages.
    void
    The helper method for processing window messages.
    void
    onExit method for the window.
    int
    removeWidget method for the window.
    void
    Selects the next selectable widget in the window.
    void
    Selects the previous selectable widget in the window.
    void
    setClear method for the window.
    void
    setPointer method for the window.
    void
    setY(int y)
     
    void
    switchFrom(Window oldWindow, com.googlecode.lanterna.screen.Screen screen, int x, int y, double percentage, double directionX, double directionY)
    switchFrom method for the window.

    Methods inherited from class java.lang.Object

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

    • buffer

      protected char[][] buffer
    • printColor

      protected com.googlecode.lanterna.TextColor[][] printColor
    • backColor

      protected com.googlecode.lanterna.TextColor[][] backColor
    • widgets

      protected List<Widget> widgets
    • switchToWindow

      protected int switchToWindow
    • overlays

      protected ArrayList<WindowOverlayClass> overlays
  • Constructor Details

    • Window

      public Window(int y, int x, String windowName)
      Constructor for Window class.
      Parameters:
      y - The Y position of the window.
      x - The X position of the window.
      windowName - The name of the window.
  • Method Details

    • setY

      public void setY(int y)
    • getY

      public int getY()
      Gets the Y position of the window.
      Returns:
      The Y position.
    • getX

      public int getX()
      Gets the X position of the window.
      Returns:
      The X position.
    • messageLoop

      public void messageLoop()
      The main loop for processing window messages. This method should be overridden by subclasses to define specific behavior.
    • messageLoopHelper

      public void messageLoopHelper()
      The helper method for processing window messages. This method should be overridden by subclasses to define specific behavior.
    • onExit

      public void onExit()
      onExit method for the window. This method should be overridden by subclasses to define specific behavior.
    • getSwitchToWindow

      public int getSwitchToWindow()
      switchToWindow method for the window. This method should be overridden by subclasses to define specific behavior.
      Returns:
      The window to switch to.
    • getLenX

      public int getLenX()
      Gets the length of the window in the X direction.
      Returns:
      The length of the window in the X direction.
    • getLenY

      public int getLenY()
      Gets the length of the window in the Y direction.
      Returns:
      The length of the window in the Y direction.
    • selectNext

      public void selectNext()
      Selects the next selectable widget in the window.
    • selectPrev

      public void selectPrev()
      Selects the previous selectable widget in the window.
    • keyStroke

      public void keyStroke(com.googlecode.lanterna.input.KeyStroke keyStroke)
      keyStroke method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      keyStroke - The key stroke to process.
    • keyStrokeHelper

      public void keyStrokeHelper(com.googlecode.lanterna.input.KeyStroke keyStroke)
      keyStrokeHelper method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      keyStroke - The key stroke to process.
    • switchFrom

      public void switchFrom(Window oldWindow, com.googlecode.lanterna.screen.Screen screen, int x, int y, double percentage, double directionX, double directionY)
      switchFrom method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      oldWindow - The window to switch from.
      screen - The screen to draw on.
      x - The X position of the window.
      y - The Y position of the window.
      percentage - The percentage of the transition.
      directionX - The X direction of the transition.
      directionY - The Y direction of the transition.
    • clearArea

      public void clearArea(com.googlecode.lanterna.screen.Screen screen, int startX, int endX, int startY, int endY)
      clearArea method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      screen - The screen to draw on.
      startX - The X position of the start of the area to clear.
      endX - The X position of the end of the area to clear.
      startY - The Y position of the start of the area to clear.
      endY - The Y position of the end of the area to clear.
    • addWidget

      public int addWidget(Widget widget)
      Adds a widget to the window.
      Parameters:
      widget - The widget to be added.
      Returns:
      The ID assigned to the widget.
    • getWidgetIndex

      public int getWidgetIndex(Widget widget)
      getWidgetIndex method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      widget - The widget to get the index of.
      Returns:
      The index of the widget.
    • removeWidget

      public int removeWidget(Widget widget)
      removeWidget method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      widget - The widget to remove.
      Returns:
      The ID of the widget.
    • addWidgetAfter

      public int addWidgetAfter(Widget widget, int afterWhich)
      addWidgetAfter method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      widget - The widget to add.
      afterWhich - The index of the widget to add after.
      Returns:
      The ID of the widget.
    • setClear

      public void setClear()
      setClear method for the window. This method should be overridden by subclasses to define specific behavior.
    • clearOuterArea

      public void clearOuterArea(com.googlecode.lanterna.screen.Screen screen, int x, int y, double transparency)
    • draw

      public void draw(com.googlecode.lanterna.screen.Screen screen, int x, int y, double transparency)
    • setPointer

      public void setPointer(Widget widget)
      setPointer method for the window. This method should be overridden by subclasses to define specific behavior.
      Parameters:
      widget - The widget to set as the pointer.
    • addOverlay

      public void addOverlay(WindowOverlayClass windowOverlayClass)
      Adds an overlay to the window.
      Parameters:
      windowOverlayClass - The overlay to be added.