 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.gauge;
32 import java.awt.AlphaComposite;
33 import java.awt.Dimension;
34 import java.awt.Graphics;
35 import java.awt.Graphics2D;
36 import java.awt.Image;
37 import java.awt.event.MouseEvent;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
126 public GUIGauge(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name, @Nullable
final Image fullImage, @Nullable
final Image lowImage, @Nullable
final Image negativeImage, @Nullable
final Image
emptyImage, @NotNull
final Orientation orientation, @Nullable
final String
tooltipFormat,
final float alpha, @Nullable
final CommandList commandList, @NotNull
final GuiFactory guiFactory, @NotNull
final Stats stats) {
142 public void setBounds(
final int x,
final int y,
final int width,
final int height) {
143 super.setBounds(x, y, width, height);
157 final Graphics paint;
159 final Graphics2D g2d = (Graphics2D)g.create();
160 g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
alpha));
166 super.paintComponent(paint);
177 public void setValues(
final int curValue,
final int minValue,
final int maxValue, @NotNull
final String labelText, @NotNull
final String
tooltipText) {
193 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
200 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
207 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
219 super.mouseClicked(e);
225 switch (e.getButton()) {
226 case MouseEvent.BUTTON1:
229 case MouseEvent.BUTTON2:
235 case MouseEvent.BUTTON3:
265 final StringBuilder sb =
new StringBuilder();
268 while (i < formatChars.length) {
269 final char ch = formatChars[i++];
270 if (ch !=
'%' || i >= formatChars.length) {
273 switch (formatChars[i++]) {
288 sb.append(formatChars[i-1]);
293 return sb.toString();
Displays a value as a graphical gauge that's filling state depends on the value.
void tooltipChanged()
Must be called whenever the tooltip may have changed.
final String tooltipFormat
The tooltip format.
void setHidden(final boolean hidden)
Specify whether this item should hide itself, independent of the "visibility" state.
Dimension getPreferredSize()
void setBounds(final int x, final int y, final int width, final int height)
void draw(@NotNull final Graphics g)
Draws the gauge image into the given graphics context.
final Orientation orientation
The gauge's orientation.
GUIGauge(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final Image fullImage, @Nullable final Image lowImage, @Nullable final Image negativeImage, @Nullable final Image emptyImage, @NotNull final Orientation orientation, @Nullable final String tooltipFormat, final float alpha, @Nullable final CommandList commandList, @NotNull final GuiFactory guiFactory, @NotNull final Stats stats)
Creates a new instance.
boolean setExtends(int width, int height)
Sets the extends of the image.
void setChanged()
Records that the contents have changed and must be repainted.
final Stats stats
The Stats instance to use.
Abstract base class for GUI elements to be shown in Guis.
final GUIElementListener elementListener
The GUIElementListener to notify.
Interface for orientation images.
Dimension getPreferredSize()
Returns the preferred size.
Dimension getMaximumSize()
Dimension getMinimumSize()
String tooltipText
The default tooltip text.
String formatTooltip()
Returns a formatted string using the given format.
final GaugeState gaugeState
The gauge state.
TooltipText getTooltip()
Returns the current tooltip text.
final float alpha
The gauge alpha value, 1 is opaque and 0 full transparent.
String getActiveSkill()
Returns the active skill name.
boolean setValues(int cur, int min, int max)
Sets the gauge's values.
This is the representation of all the statistics of a player, like its speed or its experience.
void setHasNegativeImage(boolean hasNegativeImage)
Sets whether the gauge can display negative images.
final GuiFactory guiFactory
The global GuiFactory instance.
TooltipText newTooltipText(@Nullable final String tooltipText)
Creates a TooltipText instance relative to this instance.
static final long serialVersionUID
The serial version UID.
Interface which is implemented by all listener classes.
final CommandList commandList
The CommandList that is executed on button 2.
Information for displaying tooltips.
void setValues(final int curValue, final int minValue, final int maxValue, @NotNull final String labelText, @NotNull final String tooltipText)
Sets the values to display.
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
Factory for creating Gui instances.
void execute()
Execute the command list by calling GUICommand#execute() for each command in order.
A list of GUICommand instances.
final String name
The name of this element.
boolean hidden
If true, the gauge will not paint itself, whatever its visibility.
boolean setValues(@NotNull final Orientation orientation)
Updates the values from a Orientation state.
void mouseClicked(@NotNull final MouseEvent e)
Will be called when the user has clicked (pressed+released) this element.
final Image emptyImage
The image representing an empty gauge.
final TooltipManager tooltipManager
The TooltipManager to update.
void paintComponent(@NotNull final Graphics g)
Listener for GUIElement related events.