java.lang.Object
it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
Direct Known Subclasses:
ActiveItem, DetailPane, LoggerPane, Window

public abstract class WindowItem
extends Rectangle
An abstraction for any kind of item that can be put inside a window, including a window itself
  • Field Details

    • parent

      protected final WindowItem parent
      The window which invoked the dialog
    • id

      protected final java.lang.String id
      The item id
    • activeItems

      protected final java.util.Deque<ActiveItem> activeItems
      A list containing all the active items
    • passiveItems

      protected final java.util.List<WindowItem> passiveItems
      A list containing all non-active items (e.g. DetailPane)
  • Constructor Details

    • WindowItem

      protected WindowItem​(Window parent, java.lang.String id)
      Window constructor

      Creates a Window using its default settings

      Parameters:
      parent - the Window containing this
      id - the object id
    • WindowItem

      protected WindowItem​(WindowItem parent, CursorPosition initCoord, java.lang.String id)
      Default constructor

      Creates an item using its default settings;
      The initial coordinates are relative to the object's parent

      Parameters:
      parent - the Window containing this
      initCoord - the item coordinates
      id - the object id
    • WindowItem

      protected WindowItem​(WindowItem parent, CursorPosition initCoord, int width, int height, java.lang.String id)
      Custom constructor

      Creates an item using custom settings
      The initial coordinates are relative to the object's parent

      Parameters:
      parent - the Dialog containing this
      initCoord - the item coordinates
      width - the object width
      height - the object height
      id - the object id
  • Method Details

    • getCli

      protected CLI getCli()
      cli getter
      Returns:
      null, if not overridden
    • addActiveItem

      protected void addActiveItem​(ActiveItem item)
      Adds a new active item to the items list
      Parameters:
      item - the item to add
    • addPassiveItem

      protected void addPassiveItem​(WindowItem item)
      Adds a new item to the items list
      Parameters:
      item - the item to add
    • currentActiveItem

      protected ActiveItem currentActiveItem()
      Provides the dialog item which is currently selected
      Returns:
      the currently selected active item
    • nextActiveItem

      protected ActiveItem nextActiveItem()
      Retrieves the next item
      Returns:
      the next item in the deque
    • previousActiveItem

      protected ActiveItem previousActiveItem()
      Retrieves the previous item
      Returns:
      the previous item in the deque
    • maxStringLength

      public static int maxStringLength​(java.util.List<java.lang.String> strings)
      Provides the length of the longest string in a list
      Parameters:
      strings - the list of strings
      Returns:
      the length of the longest string
    • getParent

      public WindowItem getParent()
      parent getter
      Returns:
      this item's parent
    • getID

      public java.lang.String getID()
      id getter
      Returns:
      the WindowItem id
    • drawShadows

      protected void drawShadows()
      Draws right and bottom shadows
      Uses the parent color scheme, to merge seamlessly with the background
      Overrides:
      drawShadows in class Rectangle
    • hideShadows

      protected void hideShadows()
      Hides the shadows
      Overrides:
      hideShadows in class Rectangle
    • show

      public void show()
      Prints the object on the screen
    • remove

      public void remove()
      Removes itself, restoring the underlying dialogs