22 package com.realtime.crossfire.jxclient.gui.label;
26 import java.awt.Color;
28 import java.awt.Graphics2D;
29 import java.awt.geom.RectangularShape;
30 import java.awt.image.BufferedImage;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
64 super(tooltipManager, elementListener, name, text, textFont, textColor, picture, backgroundColor);
83 protected void drawLine(@NotNull
final Graphics2D g,
final int y0,
final int h0, @NotNull
final String
text) {
84 g.setBackground(
new Color(0, 0, 0, 0.0f));
87 final RectangularShape rectangle =
getTextFont().getStringBounds(text, g.getFontRenderContext());
88 final int y = y0+(int)(Math.round(h0-rectangle.getHeight())/2-rectangle.getY());
89 switch (textAlignment) {
91 g.drawString(text, 0, y);
95 g.drawString(text, (
int)Math.round((getWidth()-rectangle.getWidth())/2), y);
99 g.drawString(text, (
int)Math.round(getWidth()-rectangle.getWidth()), y);
Listener for GUIElement related events.
Abstract base class for all label classes.
final TooltipManager tooltipManager
The TooltipManager to update.
final Color textColor
The text color.
final Font textFont
The font for rendering the label text.
void setChanged()
Records that the contents have changed and must be repainted.
void drawLine(@NotNull final Graphics2D g, final int y0, final int h0, @NotNull final String text)
Draws one line of text.
Color getTextColor()
Returns the text color.
final GUIElementListener elementListener
The GUIElementListener to notify.
Abstract base class for labels that render text.
final Color backgroundColor
If set, the opaque background color.
final String name
The name of this element.
Font getTextFont()
Returns the font.
static final long serialVersionUID
The serial version UID.
final Alignment textAlignment
The text alignment.
String text
The label text.
GUILabel(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final BufferedImage picture, @NotNull final String text, @NotNull final Font textFont, @NotNull final Color textColor, @Nullable final Color backgroundColor, @NotNull final Alignment textAlignment)
Creates a new instance.