java.lang.Object java.awt.Component java.awt.Container com.realtime.crossfire.jxclient.gui.gui.Gui
public class Gui
Combines a list of GUIElement
s to for a gui.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
private ActivatableGUIElement |
activeElement
The gui element which has the focus. |
private boolean |
autoSize
Whether this dialog is auto-sizing. |
private Extent |
extent
The extent of this dialog, or null . |
private ActivatableGUIElement |
forcedActive
If non- null , this element is always active. |
private GuiAutoCloseListener |
guiAutoCloseListener
If set, the auto-close listener to notify if this dialog looses the active gui element. |
private boolean |
hasChangedElements
Records whether at least one gui element has changed since last redraw. |
private java.util.Collection<RendererGuiState> |
hideInStates
The gui states that do not show this dialog. |
private boolean |
initialPositionSet
Whether an initial position has been set. |
private KeyBindings |
keyBindings
The KeyBindings for this gui. |
private boolean |
modal
Whether this dialog is modal. |
private MouseTracker |
mouseTracker
The MouseTracker if in GUI debug mode or null
otherwise. |
private static long |
serialVersionUID
The serial version UID. |
private boolean |
stateChanged
Whether the state (position or size) has changed. |
private java.util.Collection<GUIElement> |
visibleElements
The list of GUIElement s comprising this gui. |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Gui(MouseTracker mouseTracker,
Commands commands,
CommandCallback commandCallback,
Macros macros)
Creates a new instance. |
Method Summary | ||
---|---|---|
GUIText |
activateCommandInput()
Returns the first command text field of this gui and make it active. |
|
void |
activateDefaultElement()
Activates the first default gui element of this gui. |
|
private GUIText |
activateFirstTextArea()
Returns the first GUIText gui element of this gui and make it
active. |
|
void |
addElement(GUIElement element)
Adds a GUIElement to this gui. |
|
void |
autoSize(int screenWidth,
int screenHeight)
Auto-resizes the dialog. |
|
boolean |
deactivateCommandInput()
Deactivates the command text input field of this dialog. |
|
ActivatableGUIElement |
getActiveElement()
Returns the gui element owning the focus. |
|
private GUIElement |
getDefaultElement()
Returns the first default gui element of this gui. |
|
GUIElement |
getElementFromPoint(int x,
int y)
Determines the GUIElement for a given coordinate. |
|
|
getFirstElement(java.lang.Class<T> class_)
Returns the first gui element of this gui belonging to the given class. |
|
|
getFirstElement(java.lang.Class<T> class_,
java.lang.String name)
Returns the first gui element of this gui belonging to the given class and having the given name. |
|
|
getFirstElementEndingWith(java.lang.Class<T> class_,
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. |
|
|
getFirstElementNotEndingWith(java.lang.Class<T> class_,
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. |
|
KeyBindings |
getKeyBindings()
Returns the key bindings instance for this gui. |
|
boolean |
handleKeyPress(java.awt.event.KeyEvent e)
Dispatches a key press KeyEvent . |
|
boolean |
handleKeyTyped(java.awt.event.KeyEvent e)
Dispatches a key typed KeyEvent . |
|
void |
hideInState(RendererGuiState state)
Hides the dialog in a state. |
|
private boolean |
isActiveElement(ActivatableGUIElement activeElement)
Returns whether a given gui element is the active element of this dialog. |
|
boolean |
isAutoSize()
Returns the auto-size state. |
|
boolean |
isChangedFromDefault()
Returns whether this dialog has changed from its default state. |
|
boolean |
isHidden(RendererGuiState state)
Returns whether this gui is visible in a state. |
|
boolean |
isModal()
Returns the modal state. |
|
boolean |
isWithinDrawingArea(int x,
int y)
Returns whether a given point is within this dialog's drawing area. |
|
boolean |
needRedraw()
Checks whether any visible gui element of this gui has been changed since it was painted last time. |
|
void |
redraw(java.awt.Graphics g)
Repaints the gui and clear the changed flags of all repainted elements. |
|
void |
setActiveElement(ActivatableGUIElement activeElement,
boolean active)
Sets the gui element owning the focus. |
|
void |
setAutoSize(boolean autoSize)
Sets the auto-size state. |
|
void |
setChangedElements()
Notifies that one gui element has changed since last redraw. |
|
void |
setExtent(Extent extent)
Sets the extent of this dialog. |
|
void |
setForcedActive(ActivatableGUIElement forcedActive)
Sets an ActivatableGUIElement that is always active. |
|
void |
setGuiAutoCloseListener(GuiAutoCloseListener guiAutoCloseListener)
Sets the GuiAutoCloseListener to be notified when this dialog
becomes inactive. |
|
void |
setHideInput(boolean hideInput)
Enables or disables hidden text in the first input field. |
|
void |
setModal(boolean modal)
Sets the modal state. |
|
void |
setPosition(int x,
int y)
Sets the position of this dialog. |
|
void |
setSize(int width,
int height)
Sets the size of this dialog. |
|
void |
setStateChanged(boolean stateChanged)
Sets whether the state (position or size) has changed. |
|
java.lang.String |
toString()
|
|
void |
updateVisibleElement(GUIElement element)
Adds or removes a GUIElement from this gui. |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
@Nullable private ActivatableGUIElement activeElement
null
if no such
element exists.
private boolean autoSize
@Nullable private Extent extent
null
.
@Nullable private ActivatableGUIElement forcedActive
null
, this element is always active. No other element
can become active.
@Nullable private GuiAutoCloseListener guiAutoCloseListener
private boolean hasChangedElements
@NotNull private final java.util.Collection<RendererGuiState> hideInStates
private boolean initialPositionSet
@NotNull private final KeyBindings keyBindings
KeyBindings
for this gui.
private boolean modal
@Nullable private final MouseTracker mouseTracker
MouseTracker
if in GUI debug mode or null
otherwise.
private static final long serialVersionUID
private boolean stateChanged
@NotNull private final java.util.Collection<GUIElement> visibleElements
GUIElement
s comprising this gui.
Constructor Detail |
---|
public Gui(@Nullable MouseTracker mouseTracker, @NotNull Commands commands, @NotNull CommandCallback commandCallback, @NotNull Macros macros)
mouseTracker
- the mouse tracker when in debug GUI mode or
null
otherwisecommands
- the commands instance for executing commandscommandCallback
- the command callback to usemacros
- the macros instance to useMethod Detail |
---|
@Nullable public GUIText activateCommandInput()
null
if this gui does not
contain any command text fieldspublic void activateDefaultElement()
@Nullable private GUIText activateFirstTextArea()
GUIText
gui element of this gui and make it
active.
GUIText
element, or null
if this
gui does not contain any GUIText
gui elementspublic void addElement(@NotNull GUIElement element)
GUIElement
to this gui. The element must not be added to
more than one gui at a time.
element
- the GUIElement
to addpublic void autoSize(int screenWidth, int screenHeight)
screenWidth
- the screen widthscreenHeight
- the screen heightpublic boolean deactivateCommandInput()
@Nullable public ActivatableGUIElement getActiveElement()
null
if no such
element exists@Nullable private GUIElement getDefaultElement()
null
@Nullable public GUIElement getElementFromPoint(int x, int y)
GUIElement
for a given coordinate.
x
- the x-coordinate to checky
- the y-coordinate to check
GUIElement
at the given coordinate, or
null
if none was found@Nullable public <T extends GUIElement> T getFirstElement(@NotNull java.lang.Class<T> class_)
class_
- the class to search for
null
if not found@Nullable public <T extends GUIElement> T getFirstElement(@NotNull java.lang.Class<T> class_, @NotNull java.lang.String name)
class_
- the class to search forname
- the button's name
null
if no button matches@Nullable public <T extends GUIElement> T getFirstElementEndingWith(@NotNull java.lang.Class<T> class_, @NotNull java.lang.String ending)
class_
- the class to search forending
- the ending to search for
null
if not found@Nullable public <T extends GUIElement> T getFirstElementNotEndingWith(@NotNull java.lang.Class<T> class_, @NotNull java.lang.String ending)
class_
- the class to search forending
- the ending to search for
null
if not found@NotNull public KeyBindings getKeyBindings()
public boolean handleKeyPress(@NotNull java.awt.event.KeyEvent e)
KeyEvent
.
e
- the event to dispatch
public boolean handleKeyTyped(@NotNull java.awt.event.KeyEvent e)
KeyEvent
.
e
- the event to dispatch
public void hideInState(@NotNull RendererGuiState state)
state
- the stateprivate boolean isActiveElement(@Nullable ActivatableGUIElement activeElement)
activeElement
- the gui element
public boolean isAutoSize()
public boolean isChangedFromDefault()
public boolean isHidden(@NotNull RendererGuiState state)
state
- the state
public boolean isModal()
public boolean isWithinDrawingArea(int x, int y)
x
- the x-coordinate of the the pointy
- the y-coordinate of the the point
public boolean needRedraw()
true
if any gui element has changed;
false
otherwisepublic void redraw(@NotNull java.awt.Graphics g)
g
- the Graphics
to paint intopublic void setActiveElement(@NotNull ActivatableGUIElement activeElement, boolean active)
activeElement
- the gui elementactive
- the new active statepublic void setAutoSize(boolean autoSize)
autoSize
- the new auto-size statepublic void setChangedElements()
public void setExtent(@NotNull Extent extent)
extent
- the extentpublic void setForcedActive(@Nullable ActivatableGUIElement forcedActive)
ActivatableGUIElement
that is always active. It prevents
any other element from getting active.
forcedActive
- the element to set or null
to unsetpublic void setGuiAutoCloseListener(@Nullable GuiAutoCloseListener guiAutoCloseListener)
GuiAutoCloseListener
to be notified when this dialog
becomes inactive.
guiAutoCloseListener
- the listener to be notified or
null
public void setHideInput(boolean hideInput)
hideInput
- if set, hide input; else show inputpublic void setModal(boolean modal)
modal
- the new modal statepublic void setPosition(int x, int y)
x
- the x-coordinatey
- the y-coordinatepublic void setSize(int width, int height)
setSize
in class java.awt.Component
width
- the widthheight
- the heightpublic void setStateChanged(boolean stateChanged)
stateChanged
- whether the state has changed@NotNull public java.lang.String toString()
toString
in class java.awt.Component
public void updateVisibleElement(@NotNull GUIElement element)
GUIElement
from this gui. The gui element is
added if it is visible or removed if it is invisible.
element
- the gui element