 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.label;
28 import java.awt.Color;
30 import java.awt.Graphics2D;
31 import java.awt.geom.RectangularShape;
32 import java.awt.image.BufferedImage;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
67 protected 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, @NotNull
final Color
textHighlightColor, @Nullable
final Color
backgroundColor, @NotNull
final Alignment textAlignment, @NotNull
final GuiFactory guiFactory) {
85 protected void drawLine(@NotNull
final Graphics2D g,
final int y0,
final int h0, @NotNull
final String
text) {
86 g.setBackground(
new Color(0, 0, 0, 0.0f));
89 final RectangularShape rectangle =
getTextFont().getStringBounds(
text, g.getFontRenderContext());
90 final int y = y0+(int)(Math.round(h0-rectangle.getHeight())/2-rectangle.getY());
93 g.drawString(
text, 0, y);
97 g.drawString(
text, (
int)Math.round((getWidth()-rectangle.getWidth())/2), y);
101 g.drawString(
text, (
int)Math.round(getWidth()-rectangle.getWidth()), y);
final Color textColor
The text color when not highlighted.
static final long serialVersionUID
The serial version UID.
final Color backgroundColor
If set, the opaque background color.
void drawLine(@NotNull final Graphics2D g, final int y0, final int h0, @NotNull final String text)
Draws one line of text.
void setChanged()
Records that the contents have changed and must be repainted.
Abstract base class for all label classes.
final GUIElementListener elementListener
The GUIElementListener to notify.
void textChanged()
Will be called whenever text or getTextColor() has changed.
final Color textHighlightColor
The text color when highlighted.
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, @NotNull final Color textHighlightColor, @Nullable final Color backgroundColor, @NotNull final Alignment textAlignment, @NotNull final GuiFactory guiFactory)
Creates a new instance.
Color getTextColor()
Returns the text color.
Abstract base class for labels that render text.
final GuiFactory guiFactory
The global GuiFactory instance.
Factory for creating Gui instances.
final String name
The name of this element.
String text
The label text.
final TooltipManager tooltipManager
The TooltipManager to update.
final Alignment textAlignment
The text alignment.
final Font textFont
The font for rendering the label text.
Listener for GUIElement related events.
Font getTextFont()
Returns the font.