 |
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.image.BufferedImage;
36 import java.io.IOException;
37 import java.io.Reader;
38 import java.io.StringReader;
39 import java.util.regex.Pattern;
40 import javax.swing.text.html.HTMLEditorKit.ParserCallback;
41 import javax.swing.text.html.parser.ParserDelegator;
42 import org.jetbrains.annotations.NotNull;
43 import org.jetbrains.annotations.Nullable;
111 super.paintComponent(g);
118 final Reader reader =
new StringReader(
getText());
120 final ParserDelegator parserDelegator =
new ParserDelegator();
122 parserDelegator.parse(reader, renderer,
false);
123 }
catch (
final IOException ex) {
124 System.err.println(
"GUIHTMLLabel: cannot render HTML: "+ex.getMessage());
137 final FontMetrics fontMetrics = getFontMetrics(
getTextFont());
143 width = Math.max(width, size.width);
144 height += size.height;
151 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
153 return new Dimension(100, 32);
158 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
160 return new Dimension(100, 32);
String getText()
Returns the label text.
final Color backgroundColor
If set, the opaque background color.
void setAutoResize(final boolean autoResize)
Enable or disable auto-resizing.
void setChanged()
Records that the contents have changed and must be repainted.
Abstract base class for all label classes.
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.
Implements an AbstractLabel that displays HTML contents.
Utility class for Gui related functions.
Color getTextColor()
Returns the text color.
static final int AUTO_BORDER_SIZE
Size of border around text in auto-resize mode.
final GuiFactory guiFactory
The global GuiFactory instance.
Dimension getMinimumSize()
static final Pattern PATTERN_LINE_BREAK
The pattern used to split a string into lines.
Information for displaying tooltips.
boolean autoResize
If set, auto-resize this element to the extent of getText().
TooltipText getTooltip()
Returns the current tooltip text.
Factory for creating Gui instances.
final String name
The name of this element.
GUIHTMLLabel(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final BufferedImage backgroundPicture, @NotNull final Font font, @NotNull final Color color, @Nullable final Color backgroundColor, @NotNull final String text, @NotNull final GuiFactory guiFactory)
Creates a new instance.
String text
The label text.
void textChanged()
Will be called whenever text or getTextColor() has changed.
final TooltipManager tooltipManager
The TooltipManager to update.
Dimension getPreferredSize()
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
void autoResize()
If auto-resizing is enabled, calculate the new width and height.
static final long serialVersionUID
The serial version UID.
Listener for GUIElement related events.
Font getTextFont()
Returns the font.
void paintComponent(@NotNull final Graphics g)