19 package org.sleuthkit.autopsy.corecomponents;
21 import javax.swing.JTextPane;
22 import javax.swing.SizeRequirements;
23 import javax.swing.text.Element;
24 import javax.swing.text.View;
25 import static javax.swing.text.View.GoodBreakWeight;
26 import javax.swing.text.ViewFactory;
27 import javax.swing.text.html.HTMLEditorKit;
28 import javax.swing.text.html.InlineView;
29 import javax.swing.text.html.ParagraphView;
41 HTMLEditorKit editorKit =
new HTMLEditorKit() {
42 private static final long serialVersionUID = 1L;
45 public ViewFactory getViewFactory() {
47 return new HTMLEditorKit.HTMLFactory() {
49 public View create(Element e) {
50 View v = super.create(e);
51 if (v instanceof InlineView) {
52 return new InlineView(e) {
54 public int getBreakWeight(
int axis,
float pos,
float len) {
55 return GoodBreakWeight;
59 public View breakView(
int axis,
int p0,
float pos,
float len) {
60 if (axis == View.X_AXIS) {
62 int p1 = getGlyphPainter().getBoundedPosition(
this, p0, pos, len);
63 if (p0 == getStartOffset() && p1 == getEndOffset()) {
66 return createFragment(p0, p1);
71 }
else if (v instanceof ParagraphView) {
72 return new ParagraphView(e) {
74 protected SizeRequirements calculateMinorAxisRequirements(
int axis, SizeRequirements r) {
75 SizeRequirements requirements = r;
76 if (requirements == null) {
77 requirements =
new SizeRequirements();
79 float pref = layoutPool.getPreferredSpan(axis);
80 float min = layoutPool.getMinimumSpan(axis);
82 requirements.minimum = (int) min;
83 requirements.preferred = Math.max(requirements.minimum, (
int) pref);
84 requirements.maximum = Integer.MAX_VALUE;
85 requirements.alignment = 0.5f;
96 this.setEditorKit(editorKit);
101 super.setText(
"<pre>" + text +
"</pre>");
void setText(String text)