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.StringmessageThe dialog messageprotected java.lang.StringtitleThe dialog titleFields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
background, cli, enableInputOnReturn, returnToFields inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
activeItems, id, parent, passiveItems -
Constructor Summary
Constructors Modifier Constructor Description protectedDialog(java.lang.String title, java.lang.String message, int width, int height, CursorPosition position, Window caller, java.lang.String id)Custom constructorprotectedDialog(java.lang.String title, java.lang.String message, int width, int height, Window caller, java.lang.String id)Custom constructorprotectedDialog(java.lang.String title, java.lang.String message, Window parent, java.lang.String id)Default constructor -
Method Summary
Modifier and Type Method Description booleancanBeClosed()Determines if the dialog can be closed; by default, a dialog can be closed anytimeprotected voiddrawBackground()Draws the dialog backgroundprotected voiddrawMessage()Draws the dialog message, splitting it on multiple lines if necessaryprotected voiddrawShadows()Draws right and bottom shadows
Uses the caller's color as background, because it looks betterprotected voiddrawTitle()Draws the dialog titlejava.lang.StringgetBackgroundColor()background getterabstract voidonQuit()Determines the Dialog behaviour when it is asked to close itselfvoidremove()Removes itself and eventually re-enables the console inputvoidshow()Draws itselfMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Window
addToBackground, getCli, getReturnToMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.WindowItem
addActiveItem, addPassiveItem, currentActiveItem, getID, getParent, hideShadows, maxStringLength, nextActiveItem, previousActiveItemMethods inherited from class it.polimi.ingsw.view.cli.console.graphics.components.Rectangle
drawBorders, findCenter, getColor, getHeight, getInitCoord, getTextColor, getWidth, hideBorders, loadPropertiesFileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
getBackgroundColorin 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:
drawBackgroundin classRectangle
-
drawShadows
protected void drawShadows()Draws right and bottom shadows
Uses the caller's color as background, because it looks better- Overrides:
drawShadowsin classWindowItem
-
show
public void show()Draws itself -
remove
public void remove()Removes itself and eventually re-enables the console input- Overrides:
removein classWindowItem
-