45 HTMLEditorKit editorKit =
new HTMLEditorKit() {
46 private static final long serialVersionUID = 1L;
49 public ViewFactory getViewFactory() {
51 return new HTMLEditorKit.HTMLFactory() {
53 public View create(Element e) {
54 View v = super.create(e);
55 if (v instanceof InlineView) {
56 return new InlineView(e) {
58 public int getBreakWeight(
int axis,
float pos,
float len) {
59 return GoodBreakWeight;
63 public View breakView(
int axis,
int p0,
float pos,
float len) {
64 if (axis == View.X_AXIS) {
66 int p1 = getGlyphPainter().getBoundedPosition(
this, p0, pos, len);
67 if (p0 == getStartOffset() && p1 == getEndOffset()) {
70 return createFragment(p0, p1);
75 }
else if (v instanceof ParagraphView) {
76 return new ParagraphView(e) {
78 protected SizeRequirements calculateMinorAxisRequirements(
int axis, SizeRequirements r) {
79 SizeRequirements requirements = r;
80 if (requirements ==
null) {
81 requirements =
new SizeRequirements();
83 float pref = layoutPool.getPreferredSpan(axis);
84 float min = layoutPool.getMinimumSpan(axis);
86 requirements.minimum = (int) min;
87 requirements.preferred = Math.max(requirements.minimum, (
int) pref);
88 requirements.maximum = Integer.MAX_VALUE;
89 requirements.alignment = 0.5f;
100 this.setEditorKit(editorKit);