Class JXCWindowRenderer
- java.lang.Object
-
- com.realtime.crossfire.jxclient.gui.misc.JXCWindowRenderer
-
public class JXCWindowRenderer extends java.lang.ObjectRenders aGuiinstance into aFrame.
-
-
Constructor Summary
Constructors Constructor Description JXCWindowRenderer(@NotNull MouseTracker mouseTracker, @NotNull CrossfireServerConnection crossfireServerConnection, @Nullable java.io.Writer debugScreen)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable GUITextactivateCommandInput()Activates the command input text field.static @Nullable GUITextactivateCommandInput(@NotNull Gui gui)Returns the first command text field of a gui and make it active.voidaddGuiStateListener(@NotNull RendererGuiStateListener listener)Adds a gui state listener to be notified aboutrendererGuiStatechanges.voidclearGUI(@NotNull Gui gui)Sets a gui to display and clears the display.booleancloseDialog(@NotNull Gui dialog)Closes a dialog.booleandeactivateCommandInput()Deactivates the command input text field.voidendRendering()Ends rendering and reverts the display settings.@Nullable BuffergetActiveMessageBuffer()Returns the active message buffer.@NotNull RendererGuiStategetGuiState()Returns the current gui state.@NotNull java.lang.Iterable<Gui>getOpenDialogs()Returns all open dialogs in reverse painting order; the first element is the top-most dialog.intgetWindowHeight()Returns the height of the client area.intgetWindowWidth()Returns the width of the client area.booleanhandleKeyPress(@NotNull KeyEvent2 e)Dispatches a key pressKeyEvent.booleanisDialogOpen(@NotNull Gui dialog)Returns whether a given dialog is currently visible.booleanopenDialog(@NotNull Gui dialog, boolean autoCloseOnDeactivate)Opens a dialog.voidraiseDialog(@NotNull Gui dialog)Raises an already opened dialog.voidredraw(@NotNull java.awt.Graphics g)Paints the view into the given graphics instance.voidsetCurrentGui(@NotNull Gui gui)Sets theGuito display.booleansetFullScreenMode(@NotNull javax.swing.JFrame frame, @Nullable Resolution resolution)Tries to switch to the given resolution.voidsetGuiState(@NotNull RendererGuiState rendererGuiState)Sets the current gui state.voidsetSelectedHostname(@NotNull java.lang.String serverName)Selects a server entry.voidsetTooltip(@Nullable java.awt.Component tooltip)Sets the tooltip to use, ornullif no tooltips should be shown.voidsetWindowMode(@NotNull javax.swing.JFrame frame, @Nullable Resolution resolution, @NotNull Resolution minResolution, boolean fixedSize)Tries to switch to the given resolution.booleantoggleDialog(@NotNull Gui dialog)Toggles a dialog: if the dialog is not shown, show it; else hide it.voidupdateServerSettings()Updates server based settings to current screen size.
-
-
-
Constructor Detail
-
JXCWindowRenderer
public JXCWindowRenderer(@NotNull @NotNull MouseTracker mouseTracker, @NotNull @NotNull CrossfireServerConnection crossfireServerConnection, @Nullable @Nullable java.io.Writer debugScreen)Creates a new instance.- Parameters:
mouseTracker- the mouse tracker instancecrossfireServerConnection- the server connection to monitordebugScreen- the writer to write screen debug to ornull
-
-
Method Detail
-
setFullScreenMode
public boolean setFullScreenMode(@NotNull @NotNull javax.swing.JFrame frame, @Nullable @Nullable Resolution resolution)Tries to switch to the given resolution. If resolution switching fails, the window might be invisible.- Parameters:
frame- the associated frameresolution- the resolution to switch to;nullto keep current resolution- Returns:
- whether the resolution has been changed
-
setWindowMode
public void setWindowMode(@NotNull @NotNull javax.swing.JFrame frame, @Nullable @Nullable Resolution resolution, @NotNull @NotNull Resolution minResolution, boolean fixedSize)Tries to switch to the given resolution. If resolution switching fails, the window might be invisible.- Parameters:
frame- the associated frameresolution- the resolution to switch to,nullfor defaultminResolution- the minimal supported resolutionfixedSize- whether the window should have fixed size
-
endRendering
public void endRendering()
Ends rendering and reverts the display settings.
-
redraw
public void redraw(@NotNull @NotNull java.awt.Graphics g)Paints the view into the given graphics instance.- Parameters:
g- the graphics instance to paint to
-
clearGUI
public void clearGUI(@NotNull @NotNull Gui gui)Sets a gui to display and clears the display.- Parameters:
gui- the gui to set
-
openDialog
public boolean openDialog(@NotNull @NotNull Gui dialog, boolean autoCloseOnDeactivate)Opens a dialog. Raises an already opened dialog.- Parameters:
dialog- the dialog to showautoCloseOnDeactivate- whether the dialog should auto-close when it becomes inactive; ignored if the dialog is already open- Returns:
- whether the dialog was opened or raised;
falseif the dialog already was opened as the topmost dialog
-
raiseDialog
public void raiseDialog(@NotNull @NotNull Gui dialog)Raises an already opened dialog. Does nothing if the dialog is not open.- Parameters:
dialog- the dialog to show
-
isDialogOpen
public boolean isDialogOpen(@NotNull @NotNull Gui dialog)Returns whether a given dialog is currently visible.- Parameters:
dialog- the dialog to check- Returns:
- whether the dialog is visible
-
getOpenDialogs
@NotNull public @NotNull java.lang.Iterable<Gui> getOpenDialogs()
Returns all open dialogs in reverse painting order; the first element is the top-most dialog.- Returns:
- the open dialogs; client code must not modify this list
-
setCurrentGui
public void setCurrentGui(@NotNull @NotNull Gui gui)Sets theGuito display.- Parameters:
gui- the gui to display
-
closeDialog
public boolean closeDialog(@NotNull @NotNull Gui dialog)Closes a dialog. Does nothing if the given dialog is not open.- Parameters:
dialog- the dialog to close- Returns:
- whether the dialog has been closed;
falseif the dialog was not open
-
toggleDialog
public boolean toggleDialog(@NotNull @NotNull Gui dialog)Toggles a dialog: if the dialog is not shown, show it; else hide it.- Parameters:
dialog- the dialog to toggle- Returns:
- whether the dialog is shown
-
setTooltip
public void setTooltip(@Nullable @Nullable java.awt.Component tooltip)Sets the tooltip to use, ornullif no tooltips should be shown.- Parameters:
tooltip- the tooltip to use, ornull
-
setGuiState
public void setGuiState(@NotNull @NotNull RendererGuiState rendererGuiState)Sets the current gui state.- Parameters:
rendererGuiState- the gui state
-
getGuiState
@NotNull public @NotNull RendererGuiState getGuiState()
Returns the current gui state.- Returns:
- the gui state
-
addGuiStateListener
public void addGuiStateListener(@NotNull @NotNull RendererGuiStateListener listener)Adds a gui state listener to be notified aboutrendererGuiStatechanges.- Parameters:
listener- the listener to add
-
deactivateCommandInput
public boolean deactivateCommandInput()
Deactivates the command input text field. Does nothing if the command input text field is not active.- Returns:
- whether the command input text field has been deactivated
-
getActiveMessageBuffer
@Nullable public @Nullable Buffer getActiveMessageBuffer()
Returns the active message buffer.- Returns:
- the active message buffer or
nullif none is active
-
setSelectedHostname
public void setSelectedHostname(@NotNull @NotNull java.lang.String serverName)Selects a server entry.- Parameters:
serverName- the server name to select
-
activateCommandInput
@Nullable public @Nullable GUIText activateCommandInput()
Activates the command input text field. If more than one input field exists, the first matching one is selected.- Returns:
- the command input text field or
nullif no command input text field exists
-
handleKeyPress
public boolean handleKeyPress(@NotNull @NotNull KeyEvent2 e)Dispatches a key pressKeyEvent.- Parameters:
e- the event to dispatch- Returns:
- whether a gui element did handle the event
-
getWindowWidth
public int getWindowWidth()
Returns the width of the client area.- Returns:
- the width in pixels
-
getWindowHeight
public int getWindowHeight()
Returns the height of the client area.- Returns:
- the height in pixels
-
updateServerSettings
public void updateServerSettings()
Updates server based settings to current screen size. Does nothing if the main window is not visible.
-
activateCommandInput
@Nullable public static @Nullable GUIText activateCommandInput(@NotNull @NotNull Gui gui)
Returns the first command text field of a gui and make it active.- Parameters:
gui- the gui to check- Returns:
- the comment text field, or
nullif this gui does not contain any command text fields
-
-