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 Summary
Fields Modifier and Type Field Description protected java.util.Deque<ActiveItem>activeItemsA list containing all the active itemsprotected java.lang.StringidThe item idprotected WindowItemparentThe window which invoked the dialogprotected java.util.List<WindowItem>passiveItemsA list containing all non-active items (e.g. -
Constructor Summary
Constructors Modifier Constructor Description protectedWindowItem(WindowItem parent, CursorPosition initCoord, int width, int height, java.lang.String id)Custom constructorprotectedWindowItem(WindowItem parent, CursorPosition initCoord, java.lang.String id)Default constructorprotectedWindowItem(Window parent, java.lang.String id)Window constructor -
Method Summary
Modifier and Type Method Description protected voidaddActiveItem(ActiveItem item)Adds a new active item to the items listprotected voidaddPassiveItem(WindowItem item)Adds a new item to the items listprotected ActiveItemcurrentActiveItem()Provides the dialog item which is currently selectedprotected voiddrawShadows()Draws right and bottom shadows
Uses the parent color scheme, to merge seamlessly with the backgroundprotected CLIgetCli()cli getterjava.lang.StringgetID()id getterWindowItemgetParent()parent getterprotected voidhideShadows()Hides the shadowsstatic intmaxStringLength(java.util.List<java.lang.String> strings)Provides the length of the longest string in a listprotected ActiveItemnextActiveItem()Retrieves the next itemprotected ActiveItempreviousActiveItem()Retrieves the previous itemvoidremove()Removes itself, restoring the underlying dialogsvoidshow()Prints the object on the screenMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
drawBackground, drawBorders, findCenter, getBackgroundColor, getColor, getHeight, getInitCoord, getTextColor, getWidth, hideBorders, loadPropertiesFile
-
Field Details
-
parent
The window which invoked the dialog -
id
protected final java.lang.String idThe item id -
activeItems
A list containing all the active items -
passiveItems
A list containing all non-active items (e.g. DetailPane)
-
-
Constructor Details
-
WindowItem
Window constructorCreates a Window using its default settings
- Parameters:
parent- the Window containing thisid- the object id
-
WindowItem
Default constructorCreates an item using its default settings;
The initial coordinates are relative to the object's parent- Parameters:
parent- the Window containing thisinitCoord- the item coordinatesid- the object id
-
WindowItem
protected WindowItem(WindowItem parent, CursorPosition initCoord, int width, int height, java.lang.String id)Custom constructorCreates an item using custom settings
The initial coordinates are relative to the object's parent- Parameters:
parent- the Dialog containing thisinitCoord- the item coordinateswidth- the object widthheight- the object heightid- the object id
-
-
Method Details
-
getCli
cli getter- Returns:
- null, if not overridden
-
addActiveItem
Adds a new active item to the items list- Parameters:
item- the item to add
-
addPassiveItem
Adds a new item to the items list- Parameters:
item- the item to add
-
currentActiveItem
Provides the dialog item which is currently selected- Returns:
- the currently selected active item
-
nextActiveItem
Retrieves the next item- Returns:
- the next item in the deque
-
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
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:
drawShadowsin classRectangle
-
hideShadows
protected void hideShadows()Hides the shadows- Overrides:
hideShadowsin classRectangle
-
show
public void show()Prints the object on the screen -
remove
public void remove()Removes itself, restoring the underlying dialogs
-