 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.label;
30 import java.awt.Color;
31 import java.awt.Dimension;
33 import java.awt.FontMetrics;
34 import java.awt.Graphics;
35 import java.awt.Graphics2D;
36 import java.awt.image.BufferedImage;
37 import java.util.regex.Pattern;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
63 private String @NotNull []
lines;
79 super(
tooltipManager,
elementListener,
name, picture,
text,
textFont,
textColor,
textColor,
backgroundColor, alignment,
guiFactory);
91 super.paintComponent(g);
93 if (
lines.length <= 0) {
97 final Graphics2D g2 = (Graphics2D)g;
99 final int lineHeight = rectangle.height;
102 for (String line :
lines) {
110 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
117 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
129 final FontMetrics fontMetrics = getFontMetrics(
getTextFont());
132 for (String line :
lines) {
134 if (width < dimension.width) {
135 width = dimension.width;
140 final int height =
lines.length*rectangle.height;
142 return new Dimension(width, height);
String getText()
Returns the label text.
final Color textColor
The text color when not highlighted.
final Color backgroundColor
If set, the opaque background color.
Dimension getPreferredSize()
void drawLine(@NotNull final Graphics2D g, final int y0, final int h0, @NotNull final String text)
Draws one line of text.
String[] lines
The text lines to draw.
static Dimension getTextDimension(@NotNull final String text, @NotNull final FontMetrics fontMetrics)
Returns the extents of a string when rendered in a given Font on this component.
final GUIElementListener elementListener
The GUIElementListener to notify.
Dimension getMinimumSize()
TooltipText getTooltip()
Returns the current tooltip text.
void paintComponent(@NotNull final Graphics g)
GUIMultiLineLabel(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final BufferedImage picture, @NotNull final Font textFont, @NotNull final Color textColor, @Nullable final Color backgroundColor, @NotNull final Alignment alignment, @NotNull final String text, @NotNull final GuiFactory guiFactory)
Creates a new instance.
Utility class for Gui related functions.
static final Pattern LINE_SEPARATOR_PATTERN
The pattern to split the text into lines.
void textChanged()
Will be called whenever text or getTextColor() has changed.
Abstract base class for labels that render text.
final GuiFactory guiFactory
The global GuiFactory instance.
static final long serialVersionUID
The serial version UID.
Information for displaying tooltips.
Factory for creating Gui instances.
final String name
The name of this element.
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
String text
The label text.
A AbstractLabel that renders the text as a list of plain strings.
final TooltipManager tooltipManager
The TooltipManager to update.
Dimension getTextSize()
Returns the minimal size of this component to display all of lines.
final Font textFont
The font for rendering the label text.
Listener for GUIElement related events.
Font getTextFont()
Returns the font.