23 package com.realtime.crossfire.jxclient.gui.label;
25 import java.awt.Color;
27 import java.awt.FontMetrics;
28 import java.awt.Graphics;
29 import java.util.Stack;
30 import javax.swing.text.MutableAttributeSet;
31 import javax.swing.text.html.HTML.Tag;
32 import javax.swing.text.html.HTMLEditorKit.ParserCallback;
33 import org.jetbrains.annotations.NotNull;
41 private final Stack<Font>
fonts =
new Stack<>();
44 private final Stack<Color>
colors =
new Stack<>();
47 private final Graphics
gc;
68 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
69 public
void handleText(final
char @NotNull [] data, final
int pos) {
72 final FontMetrics m =
gc.getFontMetrics();
73 final String str =
new String(data);
74 final int w = m.stringWidth(str);
80 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
81 public
void handleStartTag(@NotNull final Tag t, @NotNull final MutableAttributeSet a, final
int pos) {
82 if (t.equals(Tag.A)) {
86 }
else if (t.equals(Tag.B)) {
87 fonts.push(
fonts.peek().deriveFont(Font.BOLD));
89 }
else if (t.equals(Tag.I)) {
90 fonts.push(
fonts.peek().deriveFont(Font.ITALIC));
92 }
else if (t.equals(Tag.LI)) {
97 final FontMetrics m =
gc.getFontMetrics();
99 y +=
fonts.peek().getSize()+1;
100 final String str =
" - ";
101 final int w = m.stringWidth(str);
111 @SuppressWarnings(
"MethodDoesntCallSuperMethod")
112 public
void handleSimpleTag(@NotNull final Tag t, @NotNull final MutableAttributeSet a, final
int pos) {
113 if (t.equals(Tag.BR)) {
114 y +=
fonts.peek().getSize()+1;
120 @SuppressWarnings(
"MethodDoesntCallSuperMethod")