Class JXCWindowRenderer


  • public class JXCWindowRenderer
    extends java.lang.Object
    Renders a Gui instance into a Frame.
    • 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 instance
        crossfireServerConnection - the server connection to monitor
        debugScreen - the writer to write screen debug to or null
    • 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 frame
        resolution - the resolution to switch to; null to 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 frame
        resolution - the resolution to switch to, null for default
        minResolution - the minimal supported resolution
        fixedSize - 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 show
        autoCloseOnDeactivate - 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; false if 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 the Gui to 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; false if 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, or null if no tooltips should be shown.
        Parameters:
        tooltip - the tooltip to use, or null
      • 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 about rendererGuiState changes.
        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 null if 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 null if no command input text field exists
      • handleKeyPress

        public boolean handleKeyPress​(@NotNull
                                      @NotNull KeyEvent2 e)
        Dispatches a key press KeyEvent.
        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 null if this gui does not contain any command text fields