 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.item;
39 import java.awt.Color;
40 import java.awt.Dimension;
42 import java.awt.Graphics;
43 import java.awt.Image;
44 import org.jetbrains.annotations.NotNull;
45 import org.jetbrains.annotations.Nullable;
129 private final Object
sync =
new Object();
199 public GUIItemShortcut(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name, @Nullable
final Color
activateColor, @Nullable
final Image
activateImage, @Nullable
final Color
immediateColor, @Nullable
final Image
immediateImage, @NotNull
final ShortcutSlot shortcutSlot, @NotNull
final FacesManager facesManager, @NotNull
final CommandExecutor commandExecutor, @NotNull
final Shortcuts shortcuts, @NotNull
final Font
font, @NotNull
final GuiFactory guiFactory) {
228 synchronized (
sync) {
250 synchronized (
sync) {
255 if (this.shortcut !=
null) {
259 if (this.shortcut !=
null) {
304 super.paintComponent(g);
307 g.fillRect(0, 0, getWidth(), getHeight());
316 g.fillRect(0, 0, getWidth(), getHeight());
321 g.drawImage(image, 0, 0,
null);
328 g.setColor(
shortcut ==
null ? Color.LIGHT_GRAY : Color.DARK_GRAY);
334 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
341 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
352 return new Dimension(32, 32);
void setShortcut(@Nullable final Shortcut shortcut)
Updates shortcut and registers/de-registers shortcutListener.
Maintains a mapping of face numbers to face data.
String getCommand()
Returns the command to execute.
void tooltipChanged()
Must be called whenever the tooltip may have changed.
static final long serialVersionUID
The serial version UID.
boolean canScroll(final int distance)
Returns whether scrolling is possible.
void removeFacesManagerListener(@NotNull FacesManagerListener facesManagerListener)
Removes a FacesManagerListener to be notified about updated faces.
A slot in the shortcuts bar.
Shortcut getShortcut()
Returns shortcut.
GUIItemShortcut(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final Color activateColor, @Nullable final Image activateImage, @Nullable final Color immediateColor, @Nullable final Image immediateImage, @NotNull final ShortcutSlot shortcutSlot, @NotNull final FacesManager facesManager, @NotNull final CommandExecutor commandExecutor, @NotNull final Shortcuts shortcuts, @NotNull final Font font, @NotNull final GuiFactory guiFactory)
Creates a new instance.
Shortcut shortcut
The currently monitored Shortcut instance.
int getFaceNum()
Returns the face number.
ImageIcon getOriginalImageIcon(int faceNum, @Nullable AtomicBoolean returnIsUnknownImage)
Returns the "original" face for a face ID.
final CommandExecutor commandExecutor
The CommandExecutor for executing commands.
Interface for listeners for Shortcut changes.
static final int MASK
The mask for all used modifiers.
static Dimension getMinimumSizeInt()
Returns the minimal size to display this component.
void toggleImmediate()
Toggles between immediate execution and activation only.
void setChanged()
Records that the contents have changed and must be repainted.
void dispose()
Releases all allocated resources.
Interface for listeners interested in FacesManager events.
final Shortcuts shortcuts
The Shortcuts instance for looking up Shortcuts.
A GUIElement representing an in-game object.
Manages image information ("faces") needed to display the map view, items, and spell icons.
void button1Clicked(final int modifiers)
Called when the left mouse button was pressed.
final Image activateImage
The overlay image for shortcuts that activate the command.
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
Dimension getMinimumSize()
void removeShortcutsListener(@NotNull final ShortcutsListener listener)
Removes a ShortcutsListener.
Describes a Crossfire spell.
final ShortcutSlot shortcutSlot
The shortcut slot.
String getTooltipText()
Returns the current tooltip text.
void button2Clicked(final int modifiers)
Called when the middle mouse button was pressed.
Helper functions for keyboard modifiers.
void button3Clicked(final int modifiers)
Called when the right mouse button was pressed.
void scroll(final int distance)
Scrolls the element.
final Color immediateColor
The background color for shortcuts that immediately execute the command.
void addShortcutListener(@NotNull final ShortcutListener listener)
Registers a shortcut listener.
void resetScroll()
Resets the scroll index to the default value.
final Image immediateImage
The overlay image for shortcuts that immediately execute the command.
Spell getSpell()
Returns the associated spell to cast.
static final String DEFAULT_TOOLTIP_TEXT
The default tooltip text for empty slots.
final GuiFactory guiFactory
The global GuiFactory instance.
Abstract base class for shortcut commands.
final Color activateColor
The background color for shortcuts that activate the command.
TooltipText newTooltipText(@Nullable final String tooltipText)
Creates a TooltipText instance relative to this instance.
final GUIElementListener elementListener
The GUIElementListener to notify.
void paintComponent(@NotNull final Graphics g)
final FacesManagerListener facesManagerListener
The FacesManagerListener registered to detect updated faces.
Interface for listeners for Shortcut changes.
static final int CTRL
The mask for "ctrl".
void executeCommand(@NotNull final CharSequence commandLine)
Executes a command or a list of commands.
Information for displaying tooltips.
TooltipText getTooltip()
Returns the current tooltip text.
Factory for creating Gui instances.
final String name
The name of this element.
static final int NONE
The mask for "no modifier".
final FacesManager facesManager
The FacesManager instance for looking up faces.
final Font font
The Font for displaying the key that activates the shortcut.
Dimension getPreferredSize()
final TooltipManager tooltipManager
The TooltipManager to update.
static final Color BACKGROUND_COLOR
The background color of this item.
final ShortcutsListener shortcutsListener
The ShortcutsListener attached to shortcuts.
Manages a list of Shortcuts.
boolean displaysFace(@NotNull final Face face)
Returns whether this shortcut displays the given face.
boolean isImmediate()
Returns whether the command should be executed immediately.
final Object sync
The synchronization object for accesses to shortcut.
Displays a shortcut command.
final ShortcutListener shortcutListener
The ShortcutListener attached to shortcut.
Listener for GUIElement related events.