public class Gui
extends java.lang.Object
GUIElements
to for a gui.
A dialog can be modal. Such dialogs do not propagate key or mouse events to lower dialogs.
Constructor and Description |
---|
Gui(@NotNull java.lang.String name,
@NotNull KeyBindings keyBindings)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
activateDefaultElement()
Activates the first default gui element of this gui.
|
void |
autoSize(int screenWidth,
int screenHeight)
Auto-resizes the dialog.
|
boolean |
deactivateCommandInput()
Deactivates the command text input field of this dialog.
|
@NotNull javax.swing.JComponent |
getComponent()
Returns the
JComponent for this instance. |
@Nullable AbstractGUIElement |
getElementFromPoint(int x,
int y)
Determines the
GUIElement for a given coordinate. |
<T extends GUIElement> |
getFirstElement(@NotNull java.lang.Class<T> class_)
Returns the first gui element of this gui belonging to the given class.
|
<T extends GUIElement> |
getFirstElement(@NotNull java.lang.Class<T> class_,
@NotNull java.lang.String name)
Returns the first gui element of this gui belonging to the given class
and having the given name.
|
<T extends GUIElement> |
getFirstElementEndingWith(@NotNull java.lang.Class<T> class_,
@NotNull java.lang.String ending)
Returns the first gui element of this gui which belongs to the given
class and that's name ends with the given ending.
|
<T extends GUIElement> |
getFirstElementNotEndingWith(@NotNull java.lang.Class<T> class_,
@NotNull java.lang.String ending)
Returns the first gui element of this gui which belongs to the given
class and that's name does not end with the given ending.
|
@Nullable GUIPicture |
getHelp()
Returns the help icon of this dialog.
|
@NotNull KeyBindings |
getKeyBindings()
Returns the key bindings instance for this gui.
|
boolean |
handleKeyPress(@NotNull KeyEvent2 e)
Dispatches a key press
KeyEvent . |
void |
hideInState(@NotNull RendererGuiState state)
Hides the dialog in a state.
|
boolean |
isActiveElement(@Nullable ActivatableGUIElement activeElement)
Returns whether a given gui element is the active element of this
dialog.
|
boolean |
isAutoSize()
Returns whether this dialog is an auto-size dialog.
|
boolean |
isHidden(@NotNull RendererGuiState state)
Returns whether this gui is visible in a state.
|
boolean |
isModal()
Returns the modal state.
|
boolean |
isSaveDialog()
Returns whether this dialog retains its position across restarts.
|
boolean |
isUserResizable()
Returns whether the dialog is user-resizable.
|
boolean |
isWithinDrawingArea(int x,
int y)
Returns whether a given point is within this dialog's drawing area.
|
void |
notifyOpen()
Call
GUIElement.notifyOpen() for all GUI elements. |
void |
repaint()
Repaints this component.
|
void |
setActiveElement(@NotNull ActivatableGUIElement activeElement,
boolean active)
Sets the gui element owning the focus.
|
void |
setActiveElementActive(boolean active)
Activates or deactivates the GUI element owning the focus.
|
void |
setAutoSize(@Nullable Extent autoSize)
Sets the auto-size state.
|
void |
setBounds(int x,
int y,
int width,
int height,
int windowWidth,
int windowHeight)
Sets the position and size of this dialog.
|
void |
setDefaultPosition(@NotNull Expression defaultX,
@NotNull Expression defaultY)
Sets the default position for this dialog.
|
void |
setForcedActive(@Nullable ActivatableGUIElement forcedActive)
Sets an
ActivatableGUIElement that is always active. |
void |
setGuiAutoCloseListener(@Nullable GuiAutoCloseListener guiAutoCloseListener)
Sets the
GuiAutoCloseListener to be notified when this dialog
becomes inactive. |
void |
setHelp(@NotNull GUIPicture help)
Sets the help icon of this dialog.
|
void |
setModal(boolean modal)
Sets the modal state.
|
void |
setOpaqueDialogBackground(boolean opaque)
Sets whether the dialog's background is opaque.
|
void |
setSaveDialog()
Makes this dialog retain its position across restarts.
|
void |
setShowSentCommands(boolean showSentCommands)
Sets whether the commands sent to the server should be shown in the
messages dialog.
|
void |
setShowTimestamps(boolean showTimestamps)
Sets whether timestamps should be shown in the messages dialog.
|
void |
setUserResizable(boolean userResizable)
Sets whether the dialog is user-resizable.
|
@NotNull java.lang.String |
toString() |
public Gui(@NotNull @NotNull java.lang.String name, @NotNull @NotNull KeyBindings keyBindings)
name
- the name of this GUIkeyBindings
- the keybindings to use@NotNull public @NotNull javax.swing.JComponent getComponent()
JComponent
for this instance.public void setAutoSize(@Nullable @Nullable Extent autoSize)
autoSize
- the new auto-size or null
public boolean isAutoSize()
public void setModal(boolean modal)
modal
- the new modal statepublic boolean isModal()
public void setUserResizable(boolean userResizable)
userResizable
- whether the dialog is user-resizablepublic boolean isUserResizable()
public void activateDefaultElement()
@Nullable public <T extends GUIElement> T getFirstElementEndingWith(@NotNull @NotNull java.lang.Class<T> class_, @NotNull @NotNull java.lang.String ending)
T
- the class to search forclass_
- the class to search forending
- the ending to search fornull
if not found@Nullable public <T extends GUIElement> T getFirstElementNotEndingWith(@NotNull @NotNull java.lang.Class<T> class_, @NotNull @NotNull java.lang.String ending)
T
- the class to search forclass_
- the class to search forending
- the ending to search fornull
if not found@Nullable public <T extends GUIElement> T getFirstElement(@NotNull @NotNull java.lang.Class<T> class_)
T
- the class to search forclass_
- the class to search fornull
if not found@Nullable public @Nullable AbstractGUIElement getElementFromPoint(int x, int y)
GUIElement
for a given coordinate.x
- the x-coordinate to checky
- the y-coordinate to checkGUIElement
at the given coordinate or null
if
none was foundpublic void setActiveElement(@NotNull @NotNull ActivatableGUIElement activeElement, boolean active)
activeElement
- the gui elementactive
- the new active statepublic boolean isActiveElement(@Nullable @Nullable ActivatableGUIElement activeElement)
activeElement
- the gui elementpublic void setActiveElementActive(boolean active)
active
- whether to activate the GUI elementpublic boolean handleKeyPress(@NotNull @NotNull KeyEvent2 e)
KeyEvent
.e
- the event to dispatchpublic boolean deactivateCommandInput()
@Nullable public <T extends GUIElement> T getFirstElement(@NotNull @NotNull java.lang.Class<T> class_, @NotNull @NotNull java.lang.String name)
T
- the class to search forclass_
- the class to search forname
- the button's namenull
if no button matches@NotNull public @NotNull KeyBindings getKeyBindings()
public void hideInState(@NotNull @NotNull RendererGuiState state)
state
- the statepublic boolean isHidden(@NotNull @NotNull RendererGuiState state)
state
- the statepublic void setGuiAutoCloseListener(@Nullable @Nullable GuiAutoCloseListener guiAutoCloseListener)
GuiAutoCloseListener
to be notified when this dialog
becomes inactive.guiAutoCloseListener
- the listener to be notified or null
public boolean isWithinDrawingArea(int x, int y)
x
- the x-coordinate of the pointy
- the y-coordinate of the pointpublic void setForcedActive(@Nullable @Nullable ActivatableGUIElement forcedActive)
ActivatableGUIElement
that is always active. It prevents
any other element from getting active.forcedActive
- the element to set or null
to unset@NotNull public @NotNull java.lang.String toString()
toString
in class java.lang.Object
public void autoSize(int screenWidth, int screenHeight)
screenWidth
- the screen widthscreenHeight
- the screen heightpublic void setDefaultPosition(@NotNull @NotNull Expression defaultX, @NotNull @NotNull Expression defaultY)
defaultX
- the default x-coordinatedefaultY
- the default y-coordinatepublic boolean isSaveDialog()
public void setSaveDialog()
public void notifyOpen()
GUIElement.notifyOpen()
for all GUI elements.@Nullable public @Nullable GUIPicture getHelp()
null
if this is not a dialog or if this
dialog has no help iconpublic void setHelp(@NotNull @NotNull GUIPicture help)
help
- the help iconpublic void setBounds(int x, int y, int width, int height, int windowWidth, int windowHeight)
x
- the x-coordinate of the dialogy
- the y-coordinate of the dialogwidth
- the width of the dialogheight
- the height of the dialogwindowWidth
- the main window's widthwindowHeight
- the main window's heightpublic void repaint()
public void setOpaqueDialogBackground(boolean opaque)
opaque
- whether the background is opaquepublic void setShowSentCommands(boolean showSentCommands)
showSentCommands
- whether to show the commandspublic void setShowTimestamps(boolean showTimestamps)
showTimestamps
- whether to show timestamps