java.lang.Object
it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
it.polimi.ingsw.view.cli.console.graphics.components.Window
it.polimi.ingsw.view.cli.console.graphics.components.Dialog
- All Implemented Interfaces:
KeyEventListener
- Direct Known Subclasses:
ErrorDialog
,InputDialog
,MessageDialog
public abstract class Dialog extends Window
General abstraction for a dialog window
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
message
The dialog messageprotected java.lang.String
title
The dialog titleFields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
background, cli, enableInputOnReturn, returnTo
Fields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
activeItems, id, parent, passiveItems
-
Constructor Summary
Constructors Modifier Constructor Description protected
Dialog(java.lang.String title, java.lang.String message, int width, int height, CursorPosition position, Window caller, java.lang.String id)
Custom constructorprotected
Dialog(java.lang.String title, java.lang.String message, int width, int height, Window caller, java.lang.String id)
Custom constructorprotected
Dialog(java.lang.String title, java.lang.String message, Window parent, java.lang.String id)
Default constructor -
Method Summary
Modifier and Type Method Description boolean
canBeClosed()
Determines if the dialog can be closed; by default, a dialog can be closed anytimeprotected void
drawBackground()
Draws the dialog backgroundprotected void
drawMessage()
Draws the dialog message, splitting it on multiple lines if necessaryprotected void
drawShadows()
Draws right and bottom shadows
Uses the caller's color as background, because it looks betterprotected void
drawTitle()
Draws the dialog titlejava.lang.String
getBackgroundColor()
background getterabstract void
onQuit()
Determines the Dialog behaviour when it is asked to close itselfvoid
remove()
Removes itself and eventually re-enables the console inputvoid
show()
Draws itselfMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
addToBackground, getCli, getReturnTo
Methods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
addActiveItem, addPassiveItem, currentActiveItem, getID, getParent, hideShadows, maxStringLength, nextActiveItem, previousActiveItem
Methods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
drawBorders, findCenter, getColor, getHeight, getInitCoord, getTextColor, getWidth, hideBorders, loadPropertiesFile
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface it.polimi.ingsw.view.cli.console.KeyEventListener
onArrowDown, onArrowLeft, onArrowRight, onArrowUp, onBackspace, onCarriageReturn, onPrintableKey, onTab
-
Field Details
-
Constructor Details
-
Dialog
protected Dialog(java.lang.String title, java.lang.String message, Window parent, java.lang.String id)Default constructorCreates a standard size dialog window, using the properties file, without printing it; if other dialogs are already showing, the new dialog is created at an offset from the already existing one.
The console echo is disabled as soon as the Dialog is created- Parameters:
title
- the dialog titlemessage
- the dialog messageparent
- the window which invoked thisid
- the object id
-
Dialog
protected Dialog(java.lang.String title, java.lang.String message, int width, int height, Window caller, java.lang.String id)Custom constructorCreates a custom size dialog window, without printing it; if other dialogs are already showing, the new dialog is created at an offset from the already existing one
The console echo is disabled as soon as the Dialog is created- Parameters:
height
- the dialog heightwidth
- the dialog widthtitle
- the dialog titlemessage
- the dialog messagecaller
- the window which invoked this
-
Dialog
protected Dialog(java.lang.String title, java.lang.String message, int width, int height, CursorPosition position, Window caller, java.lang.String id)Custom constructorCreates a custom size dialog window, without printing it;
The console echo is disabled as soon as the Dialog is created- Parameters:
height
- the dialog heightwidth
- the dialog widthtitle
- the dialog titlemessage
- the dialog messagecaller
- the window which invoked thisid
- the object id
-
-
Method Details
-
getBackgroundColor
public java.lang.String getBackgroundColor()background getter- Overrides:
getBackgroundColor
in classRectangle
- Returns:
- the parent's background color
-
canBeClosed
public boolean canBeClosed()Determines if the dialog can be closed; by default, a dialog can be closed anytime- Returns:
- true if the dialog can be closed, false otherwise
-
onQuit
public abstract void onQuit()Determines the Dialog behaviour when it is asked to close itself -
drawTitle
protected void drawTitle()Draws the dialog title -
drawMessage
protected void drawMessage()Draws the dialog message, splitting it on multiple lines if necessary -
drawBackground
protected void drawBackground()Draws the dialog background- Overrides:
drawBackground
in classRectangle
-
drawShadows
protected void drawShadows()Draws right and bottom shadows
Uses the caller's color as background, because it looks better- Overrides:
drawShadows
in classWindowItem
-
show
public void show()Draws itself -
remove
public void remove()Removes itself and eventually re-enables the console input- Overrides:
remove
in classWindowItem
-