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: