Search in sources :

Example 1 with InlineView

use of javax.swing.text.html.InlineView in project jsql-injection by ron190.

the class HTMLEditorKitTextPaneWrap method getViewFactory.

@Override
public ViewFactory getViewFactory() {
    return new HTMLFactory() {

        @Override
        public View create(Element e) {
            View v = super.create(e);
            if (v instanceof InlineView) {
                return new InlineView(e) {

                    @Override
                    public int getBreakWeight(int axis, float pos, float len) {
                        return GoodBreakWeight;
                    }

                    @Override
                    public View breakView(int axis, int p0, float pos, float len) {
                        if (axis == View.X_AXIS) {
                            this.checkPainter();
                            int p1 = this.getGlyphPainter().getBoundedPosition(this, p0, pos, len);
                            if (p0 == this.getStartOffset() && p1 == this.getEndOffset()) {
                                return this;
                            }
                            return this.createFragment(p0, p1);
                        }
                        return this;
                    }
                };
            } else if (v instanceof ParagraphView) {
                return new ParagraphView(e) {

                    @Override
                    protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements valueR) {
                        SizeRequirements r = valueR;
                        if (r == null) {
                            r = new SizeRequirements();
                        }
                        float pref = this.layoutPool.getPreferredSpan(axis);
                        float min = this.layoutPool.getMinimumSpan(axis);
                        // Don't include insets, Box.getXXXSpan will include
                        // them.
                        r.minimum = (int) min;
                        r.preferred = Math.max(r.minimum, (int) pref);
                        r.maximum = Integer.MAX_VALUE;
                        r.alignment = 0.5f;
                        return r;
                    }
                };
            }
            return v;
        }
    };
}
Also used : Element(javax.swing.text.Element) ParagraphView(javax.swing.text.html.ParagraphView) SizeRequirements(javax.swing.SizeRequirements) ParagraphView(javax.swing.text.html.ParagraphView) InlineView(javax.swing.text.html.InlineView) View(javax.swing.text.View) InlineView(javax.swing.text.html.InlineView)

Aggregations

SizeRequirements (javax.swing.SizeRequirements)1 Element (javax.swing.text.Element)1 View (javax.swing.text.View)1 InlineView (javax.swing.text.html.InlineView)1 ParagraphView (javax.swing.text.html.ParagraphView)1