7 package org.libcsdbg.jtracer;
10 import java.awt.Color;
11 import java.awt.Insets;
12 import java.awt.EventQueue;
14 import javax.swing.JTextPane;
15 import javax.swing.SwingUtilities;
16 import javax.swing.text.Style;
17 import javax.swing.text.StyleContext;
18 import javax.swing.text.StyleConstants;
19 import javax.swing.text.Document;
38 StyleContext sc = StyleContext.getDefaultStyleContext();
39 Style s = addStyle(
"debug", sc.getStyle(StyleContext.DEFAULT_STYLE));
40 Registry conf = Registry.getCurrent();
43 Integer padding = (Integer) conf.
get(
"text",
"padding");
44 if (padding != null) {
45 StyleConstants.setLeftIndent(s, padding);
46 StyleConstants.setRightIndent(s, padding);
49 Float spacing = (Float) conf.get(
"text",
"line-height");
51 StyleConstants.setLineSpacing(s, spacing);
53 StyleConstants.setAlignment(s, StyleConstants.ALIGN_JUSTIFIED);
54 setParagraphAttributes(s,
true);
57 Font fnt = (Font) conf.get(
"text",
"font");
59 StyleConstants.setFontFamily(s, fnt.getFamily());
60 StyleConstants.setFontSize(s, fnt.getSize());
61 StyleConstants.setBold(s, fnt.isBold());
62 StyleConstants.setItalic(s, fnt.isItalic());
65 Color fg = (Color) conf.get(
"text",
"fgcolor-debug");
66 StyleConstants.setForeground(s, fg);
69 s = addStyle(
"status", s);
70 fg = (Color) conf.get(
"text",
"fgcolor-status");
71 StyleConstants.setForeground(s, fg);
73 s = addStyle(
"data", s);
74 fg = (Color) conf.get(
"text",
"fgcolor-data");
75 StyleConstants.setForeground(s, fg);
77 s = addStyle(
"alert", s);
78 fg = (Color) conf.get(
"text",
"fgcolor-alert");
79 StyleConstants.setForeground(s, fg);
81 s = addStyle(
"error", s);
82 fg = (Color) conf.get(
"text",
"fgcolor-error");
83 StyleConstants.setForeground(s, fg);
86 Color bg = (Color) conf.get(
"text",
"bgcolor-selection");
87 fg = (Color) conf.get(
"text",
"fgcolor-selection");
88 setSelectionColor(bg);
89 setSelectedTextColor(fg);
91 setMargin((Insets) conf.get(
"text",
"margin"));
108 public void append(
final String ln,
final String tag)
111 if (EventQueue.isDispatchThread()) {
113 Document doc = getDocument();
114 int len = doc.getLength();
115 doc.insertString(len, ln, getStyle(tag));
116 setCaretPosition(len + ln.length());
119 catch (Throwable t) {
139 SwingUtilities.invokeLater(
new Worker());
142 catch (Throwable t) {
167 Document doc = getDocument();
168 doc.remove(0, doc.getLength());
172 catch (Throwable t) {
Object get(String section, String key)
Get an entry.
Main application logging pane.
void append(final String ln, final String tag)
Append a line of formatted text.
void appendln(String ln, String tag)
Append a line of formatted text and a line break.
void clear()
Remove all contents.
static final long serialVersionUID
Class version.