22 package com.realtime.crossfire.jxclient.gui.gauge;
27 import java.awt.Color;
29 import java.awt.Graphics;
30 import java.awt.Graphics2D;
31 import java.awt.Image;
32 import java.awt.geom.RectangularShape;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
81 public GUITextGauge(@NotNull
final TooltipManager tooltipManager, @NotNull
final GUIElementListener elementListener, @NotNull
final String
name, @NotNull
final Image pictureFull, @Nullable
final Image pictureNegative, @NotNull
final Image pictureEmpty, @NotNull
final Orientation orientation, @Nullable
final String tooltipPrefix, @NotNull
final Color color, @NotNull
final Font font,
final float alpha, @Nullable
final CommandList commandList) {
82 super(tooltipManager, elementListener, name, pictureFull, pictureNegative, pictureEmpty, orientation, tooltipPrefix, alpha, commandList);
92 super.paintComponent(g);
93 final Graphics2D g2 = (Graphics2D)g;
94 g2.setBackground(
new Color(0, 0, 0, 0.0f));
98 final RectangularShape rectangle = font.getStringBounds(text, g2.getFontRenderContext());
99 final int x = (int)Math.round((getWidth()-rectangle.getWidth())/2);
100 final int y = (int)Math.round(getHeight()-rectangle.getMaxY()-rectangle.getMinY())/2;
101 g2.drawString(text, x, y);
108 public void setValues(
final int curValue,
final int minValue,
final int maxValue, @NotNull
final String labelText, @NotNull
final String
tooltipText) {
109 super.setValues(curValue, minValue, maxValue, labelText, tooltipText);
Listener for GUIElement related events.
final TooltipManager tooltipManager
The TooltipManager to update.
void setChanged()
Records that the contents have changed and must be repainted.
void paintComponent(@NotNull final Graphics g)
Interface for orientation images.
final GUIElementListener elementListener
The GUIElementListener to notify.
final String name
The name of this element.
void setValues(final int curValue, final int minValue, final int maxValue, @NotNull final String labelText, @NotNull final String tooltipText)
Sets the values to display.the values to display the minimum possible value the maximum possible valu...
String labelText
The label text.
final float alpha
The gauge alpha value, 1 is opaque and 0 full transparent.
final Orientation orientation
The gauge's orientation.
final Color color
The text color.
final Font font
The text font.
static final long serialVersionUID
The serial version UID.
final CommandList commandList
The CommandList that is executed on button 2.
GUITextGauge(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @NotNull final Image pictureFull, @Nullable final Image pictureNegative, @NotNull final Image pictureEmpty, @NotNull final Orientation orientation, @Nullable final String tooltipPrefix, @NotNull final Color color, @NotNull final Font font, final float alpha, @Nullable final CommandList commandList)
Creates a new instance.
String tooltipText
The default tooltip text.
Displays a value as a graphical gauge that's filling state depends on the value.
A list of GUICommand instances.
A GUIGauge which displays the current value as a text string on top of the gauge. ...