Class AbstractGUIElement

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
All Implemented Interfaces:
GUIElement, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
AbstractGUIMap, AbstractLabel, ActivatableGUIElement, GUIComboBox, GUIDialogBackground, GUIDupGauge, GUIFill, GUIGauge, GUILog, GUIMapDirections, GUIPicture, GUIPictureStat

public abstract class AbstractGUIElement extends JComponent implements GUIElement
Abstract base class for GUI elements to be shown in Guis.
See Also:
  • Constructor Details

    • AbstractGUIElement

      protected AbstractGUIElement(@NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, boolean opaque, @NotNull @NotNull GuiFactory guiFactory)
      Creates a new instance.
      Parameters:
      tooltipManager - the tooltip manager to update
      elementListener - the element listener to notify
      name - the name of this element
      opaque - whether this element is opaque
      guiFactory - the global GUI factory instance
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: GUIElement
      Releases all allocated resources.
      Specified by:
      dispose in interface GUIElement
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Component
    • isDefault

      public boolean isDefault()
      Description copied from interface: GUIElement
      Returns whether this element is the default element. The default element is selected with the ENTER key.
      Specified by:
      isDefault in interface GUIElement
      Returns:
      whether this element is the default element
    • setDefault

      public void setDefault(boolean isDefault)
      Description copied from interface: GUIElement
      Sets whether this element is the default element. The default element is selected with the ENTER key.
      Specified by:
      setDefault in interface GUIElement
      Parameters:
      isDefault - whether this element is the default element
    • setIgnore

      public void setIgnore()
      Description copied from interface: GUIElement
      Marks this gui element to be ignored for user interaction.
      Specified by:
      setIgnore in interface GUIElement
    • isIgnore

      public boolean isIgnore()
      Description copied from interface: GUIElement
      Returns whether this gui element is to be ignored for user interaction.
      Specified by:
      isIgnore in interface GUIElement
      Returns:
      whether this gui element is ignored
    • getName

      @NotNull public @NotNull String getName()
      Description copied from interface: GUIElement
      Returns the internal name of this gui element. The name is used in skin files for identifying an element.
      Specified by:
      getName in interface GUIElement
      Overrides:
      getName in class Component
      Returns:
      the name
    • mouseClicked

      public void mouseClicked(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the user has clicked (pressed+released) this element. This event will be delivered after GUIElement.mouseReleased(MouseEvent).
      Specified by:
      mouseClicked in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mouseEntered

      public void mouseEntered(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the mouse has entered the bounding box of this element.
      Specified by:
      mouseEntered in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mouseExited

      public void mouseExited(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the mouse has left the bounding box of this element. This function will not be called unless GUIElement.mouseEntered(MouseEvent) has been called before.
      Specified by:
      mouseExited in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mousePressed

      public void mousePressed(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the user has pressed the mouse inside this element.
      Specified by:
      mousePressed in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mouseReleased

      public void mouseReleased(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the user has released the mouse. This event may be delivered even if no previous GUIElement.mousePressed(MouseEvent) has been delivered before.
      Specified by:
      mouseReleased in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mouseMoved

      public void mouseMoved(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the mouse moves within this component. before.
      Specified by:
      mouseMoved in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mouseDragged

      public void mouseDragged(@NotNull @NotNull MouseEvent e)
      Description copied from interface: GUIElement
      Will be called when the mouse moves within this component while the button is pressed. This event will be delivered after GUIElement.mouseMoved(MouseEvent).

      Note: if the mouse leaves this element's bounding box while the mouse button is still pressed, further mouseDragged (but no mouseMoved) events will be generated.

      Specified by:
      mouseDragged in interface GUIElement
      Parameters:
      e - the mouse event relative to this element
    • mouseWheelMoved

      public void mouseWheelMoved(int wheelRotation)
      Description copied from interface: GUIElement
      Will be called when the mouse wheel has been moved.
      Specified by:
      mouseWheelMoved in interface GUIElement
      Parameters:
      wheelRotation - the movement amount; negative=away from the user, positive=towards the user
    • setChanged

      public void setChanged()
      Description copied from interface: GUIElement
      Records that the contents have changed and must be repainted.
      Specified by:
      setChanged in interface GUIElement
    • getTooltip

      @Nullable public abstract @Nullable TooltipText getTooltip()
      Returns the current tooltip text.
      Returns:
      the tooltip text or null to not show a tooltip
    • newTooltipText

      @Nullable protected @Nullable TooltipText newTooltipText(@Nullable @Nullable String tooltipText)
      Creates a TooltipText instance relative to this instance.
      Parameters:
      tooltipText - the text of the instance or null to return null
      Returns:
      the new instance or null if this component is not in a GUI
    • tooltipChanged

      protected void tooltipChanged()
      Must be called whenever the tooltip may have changed.
    • setChangedListener

      public void setChangedListener(@Nullable @Nullable GUIElementChangedListener changedListener)
      Description copied from interface: GUIElement
      Sets the GUIElementChangedListener to be notified. Note that at most one such listener may be set per gui element.
      Specified by:
      setChangedListener in interface GUIElement
      Parameters:
      changedListener - the listener or null to unset
    • inhibitListeners

      public void inhibitListeners()
      Prevents change listeners to be notified.
    • getDialogBorderTop

      public int getDialogBorderTop()
      Returns the size of the dialog's top border.
      Returns:
      the size in pixels or 0 if this GUI element is not a dialog
    • getDialogBorderLeft

      public int getDialogBorderLeft()
      Returns the size of the dialog's left border.
      Returns:
      the size in pixels or 0 if this GUI element is not a dialog
    • getDialogBorderRight

      public int getDialogBorderRight()
      Returns the size of the dialog's right border.
      Returns:
      the size in pixels or 0 if this GUI element is not a dialog
    • getDialogBorderBottom

      public int getDialogBorderBottom()
      Returns the size of the dialog's bottom border.
      Returns:
      the size in pixels or 0 if this GUI element is not a dialog