 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.gauge;
31 import java.awt.Color;
32 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 java.awt.geom.RectangularShape;
39 import org.jetbrains.annotations.NotNull;
40 import org.jetbrains.annotations.Nullable;
140 public GUIDupGauge(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name, @NotNull
final Image fullImageDiv, @NotNull
final Image fullImageMod, @Nullable
final Image
emptyImage, @NotNull
final Orientation orientationDiv, @NotNull
final Orientation orientationMod, @Nullable
final String
tooltipPrefix, @NotNull
final Color
color, @NotNull
final Font
font, @Nullable
final CommandList commandList, @NotNull
final GuiFactory guiFactory) {
150 final int w = getWidth();
151 final int h = getHeight();
163 super.paintComponent(g);
164 g.setColor(
new Color(0, 0, 0, 0.0f));
165 g.fillRect(0, 0, getWidth(), getHeight());
172 final Graphics2D g2 = (Graphics2D)g;
173 g2.setBackground(
new Color(0, 0, 0, 0.0f));
177 final RectangularShape rectangle =
font.getStringBounds(text, g2.getFontRenderContext());
178 g2.drawString(text, (
int)Math.round((getWidth()-rectangle.getWidth())/2), (int)Math.round(getHeight()-rectangle.getMaxY()-rectangle.getMinY())/2);
183 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
190 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
197 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
211 return new Dimension(Math.max(div.width, mod.width), div.height+mod.height);
217 throw new IllegalArgumentException(
"minValue="+minValue);
219 if (maxValue != 99) {
220 throw new IllegalArgumentException(
"maxValue="+maxValue);
243 public void setBounds(
final int x,
final int y,
final int width,
final int height) {
244 super.setBounds(x, y, width, height);
257 super.mouseClicked(e);
263 switch (e.getButton()) {
264 case MouseEvent.BUTTON1:
267 case MouseEvent.BUTTON2:
273 case MouseEvent.BUTTON3:
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
void tooltipChanged()
Must be called whenever the tooltip may have changed.
final Orientation orientationDiv
The gauge's orientation.
void draw(@NotNull final Graphics g)
Draws the gauge image into the given graphics context.
TooltipText getTooltip()
Returns the current tooltip text.
final Image emptyImage
The image representing an empty gauge.
void mouseClicked(@NotNull final MouseEvent e)
Will be called when the user has clicked (pressed+released) this element.
boolean setExtends(int width, int height)
Sets the extends of the image.
Dimension getPreferredSize()
void setChanged()
Records that the contents have changed and must be repainted.
void setDy(final int dy)
Sets the y-offset for drawing.
Abstract base class for GUI elements to be shown in Guis.
final String tooltipPrefix
The tooltip prefix.
void setHidden(final boolean hidden)
Specify whether this item should hide itself, independent of the "visibility" state.
final GUIElementListener elementListener
The GUIElementListener to notify.
Dimension getMinimumSize()
Interface for orientation images.
final Color color
The text color.
Dimension getPreferredSize()
Returns the preferred size.
Displays a value as a graphical gauge that's filling state depends on the value.
void setBounds(final int x, final int y, final int width, final int height)
final GaugeState gaugeStateMod
The gauge state.
GUIDupGauge(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final Image fullImageDiv, @NotNull final Image fullImageMod, @Nullable final Image emptyImage, @NotNull final Orientation orientationDiv, @NotNull final Orientation orientationMod, @Nullable final String tooltipPrefix, @NotNull final Color color, @NotNull final Font font, @Nullable final CommandList commandList, @NotNull final GuiFactory guiFactory)
Creates a new instance.
boolean setValues(int cur, int min, int max)
Sets the gauge's values.
final GaugeState gaugeStateDiv
The gauge state.
final GuiFactory guiFactory
The global GuiFactory instance.
TooltipText newTooltipText(@Nullable final String tooltipText)
Creates a TooltipText instance relative to this instance.
Interface which is implemented by all listener classes.
Information for displaying tooltips.
void paintComponent(@NotNull final Graphics g)
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.
Dimension getGaugeStateSize()
Returns the maximum size of gaugeStateDiv and gaugeStateMod.
final Font font
The text font.
String labelText
The label text.
final CommandList commandList
The CommandList that is executed on button 2.
static final long serialVersionUID
The serial version UID.
void setValues(final int curValue, final int minValue, final int maxValue, @NotNull final String labelText, @NotNull final String tooltipText)
Sets the values to display.
boolean setValues(@NotNull final Orientation orientation)
Updates the values from a Orientation state.
final TooltipManager tooltipManager
The TooltipManager to update.
Dimension getMaximumSize()
String tooltipText
The tooltip suffix.
final Orientation orientationMod
The gauge's orientation.
Listener for GUIElement related events.