Java 类javax.swing.text.ViewFactory 实例源码

项目:incubator-netbeans    文件:GapBoxView.java   
/**
 * Loads child views by tracking child elements of the element
 * this view was created for.
 * @param index index at which the views should be added/replaced.
 * @param removeLength number of removed children views. It is useful
 *  when rebuilding children for a portion of the view.
 * @param elementIndex index of the first child element for which
 *  the view should be created
 * @param elementCount number of elements for which the views should be created.
 */
protected void elementReloadChildren(int index, int removeLength,
int elementCount) {

    Element e = getElement();
    View[] added = null;

    ViewFactory f = getViewFactory();
    // Null view factory can mean that one of the grand parents is already disconnected
    // from the view hierarchy. No added children for null factory.

    if (f != null) {
        added = new View[elementCount];
        for (int i = 0; i < elementCount; i++) {
            added[i] = f.create(e.getElement(index + i));
        }

    }

    replace(index, removeLength, added);
}
项目:powertext    文件:WrappedSyntaxView.java   
private void handleDocumentEvent(DocumentEvent e, Shape a,
                                    ViewFactory f) {
    int n = calculateLineCount();
    if (this.nlines != n) {
        this.nlines = n;
        WrappedSyntaxView.this.preferenceChanged(this, false, true);
        // have to repaint any views after the receiver.
        RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
        textArea.repaint();
        // Must also revalidate container so gutter components, such
        // as line numbers, get updated for this line's new height
        Gutter gutter = RSyntaxUtilities.getGutter(textArea);
        if (gutter!=null) {
            gutter.revalidate();
            gutter.repaint();
        }
    }
    else if (a != null) {
        Component c = getContainer();
        Rectangle alloc = (Rectangle) a;
        c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
    }
}
项目:PhET    文件:SoftwareAgreementDialog.java   
protected JComponent createAgreementPanel() {

        String html = HTMLUtils.createStyledHTMLFromFragment( SoftwareAgreement.getInstance().getContent() );
        HTMLEditorPane htmlEditorPane = new HTMLUtils.InteractiveHTMLPane( html );

        final HTMLEditorKit.HTMLFactory htmlFactory = new HTMLFactoryWithImages();

        htmlEditorPane.setEditorKit( new HTMLEditorKit() {
            public ViewFactory getViewFactory() {
                return htmlFactory;
            }
        } );
        htmlEditorPane.setText( html );
        htmlEditorPane.setBackground( Color.WHITE );

        JScrollPane scrollPane = new JScrollPane( htmlEditorPane );
        scrollPane.setPreferredSize( new Dimension( scrollPane.getPreferredSize().width + 30, 300 ) );

        // this ensures that the first line of text is at the top of the scrollpane
        htmlEditorPane.setCaretPosition( 0 );

        return scrollPane;
    }
项目:javify    文件:BasicTextUI.java   
/**
 * Indicates that the model of a text component has changed. This
 * triggers a rebuild of the view hierarchy.
 */
protected void modelChanged()
{
  if (textComponent == null || rootView == null)
    return;
  ViewFactory factory = rootView.getViewFactory();
  if (factory == null)
    return;
  Document doc = textComponent.getDocument();
  if (doc == null)
    return;
  Element elem = doc.getDefaultRootElement();
  if (elem == null)
    return;
  View view = factory.create(elem);
  setView(view);
}
项目:PasswordSafe    文件:LocalImageView.java   
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
{
    super.changedUpdate(e, a, f);
    float align = getVerticalAlignment();

    int h = height;
    int w = width;

    initialize(getElement());

    boolean hChanged = (height != h);
    boolean wChanged = (width != w);
    if(hChanged || wChanged || getVerticalAlignment() != align)
    {
        getParent().preferenceChanged(this, hChanged, wChanged);
    }
}
项目:jvm-stm    文件:BasicTextUI.java   
/**
 * Indicates that the model of a text component has changed. This
 * triggers a rebuild of the view hierarchy.
 */
protected void modelChanged()
{
  if (textComponent == null || rootView == null) 
    return;
  ViewFactory factory = rootView.getViewFactory();
  if (factory == null) 
    return;
  Document doc = textComponent.getDocument();
  if (doc == null)
    return;
  Element elem = doc.getDefaultRootElement();
  if (elem == null)
    return;
  View view = factory.create(elem);
  setView(view);
}
项目:swingx    文件:JXLabel.java   
public static View createView(JXLabel c) {
    BasicEditorKit kit = getFactory();
    float rightIndent = 0;
    if (c.getIcon() != null && c.getHorizontalTextPosition() != SwingConstants.CENTER) {
        rightIndent = c.getIcon().getIconWidth() + c.getIconTextGap(); 
    }
    Document doc = kit.createDefaultDocument(c.getFont(), c.getForeground(), c.getTextAlignment(), rightIndent);
    Reader r = new StringReader(c.getText() == null ? "" : c.getText());
    try {
        kit.read(r, doc, 0);
    } catch (Throwable e) {
    }
    ViewFactory f = kit.getViewFactory();
    View hview = f.create(doc.getDefaultRootElement());
    View v = new Renderer(c, f, hview, true);
    return v;
}
项目:swingx    文件:JXLabel.java   
Renderer(JXLabel c, ViewFactory f, View v, boolean wordWrap) {
    super(null, wordWrap);
    factory = f;
    view = v;
    view.setParent(this);
    host = c;
    //log.fine("vir: " +  host.getVisibleRect());
    int w;
    if (host.getVisibleRect().width == 0) {
        invalidated = true;
        return;
    } else {
        w = host.getVisibleRect().width;
    }
    //log.fine("w:" + w);
    // initially layout to the preferred size
    //setSize(c.getMaxLineSpan() > -1 ? c.getMaxLineSpan() : view.getPreferredSpan(X_AXIS), view.getPreferredSpan(Y_AXIS));
    setSize(c.getMaxLineSpan() > -1 ? c.getMaxLineSpan() : w, host.getVisibleRect().height);
}
项目:swingx    文件:BasicHyperlinkUI.java   
/**
 * Create an html renderer for the given component and
 * string of html.
 */
public static View createHTMLView(JComponent c, String html) {
    BasicEditorKit kit = getFactory();
    Document doc = kit.createDefaultDocument(c.getFont(),
                                             c.getForeground());
    Object base = c.getClientProperty(documentBaseKey);
    if (base instanceof URL) {
        ((HTMLDocument)doc).setBase((URL)base);
    }
    Reader r = new StringReader(html);
    try {
        kit.read(r, doc, 0);
    } catch (Throwable e) {
    }
    ViewFactory f = kit.getViewFactory();
    View hview = f.create(doc.getDefaultRootElement());
    View v = new Renderer(c, f, hview);
    return v;
}
项目:metasfresh    文件:HTMLRenderer.java   
/**
 *  Get View from HTML String
 *  @param html html string
 *  @return renderer view
 */
public static HTMLRenderer get (String html)
{
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument doc = (HTMLDocument)kit.createDefaultDocument();
    try
    {
        doc.remove(0, doc.getLength());
        Reader r = new StringReader(html);
        kit.read(r, doc, 0);
    }
    catch (Exception e)
    {
        log.error("", e);
    }
    //  Create Renderer
    Element element = doc.getDefaultRootElement();
    ViewFactory factory = kit.getViewFactory();
    View view = factory.create(element);    //  Y_AXIS is main
    HTMLRenderer renderer = new HTMLRenderer (factory, view);
    renderer.preferenceChanged (null, true, true);
    return renderer;
}
项目:swingbox-javahelp-viewer    文件:DelegateView.java   
/**
 * Sets the view parent.
 * 
 * @param parent
 *            the parent view
 */
@Override
public void setParent(View parent)
{

    if (parent == null && view != null) view.setParent(null);
    this.parent = parent;

    // if set new parent and has some element, try to load children
    // this element is a BranchElement ("collection"),
    // so we should have some LeafElements ("children")
    if ((parent != null) && (getElement() != null))
    {
        ViewFactory f = getViewFactory();
        loadChildren(f);
    }
}
项目:swingbox-javahelp-viewer    文件:ElementBoxView.java   
@Override
protected void forwardUpdate(DocumentEvent.ElementChange ec,
        DocumentEvent e, Shape a, ViewFactory f)
{
    boolean wasValid = isLayoutValid(majorAxis);
    super.forwardUpdate(ec, e, a, f);

    // determine if a repaint is needed
    if (wasValid && (!isLayoutValid(majorAxis)))
    {
        // Repaint is needed because one of the tiled children
        // have changed their span along the major axis. If there
        // is a hosting component and an allocated shape we repaint.
        Component c = getContainer();
        if ((a != null) && (c != null))
        {
            Rectangle alloc = getInsideAllocation(a);
            c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
        }
    }
}
项目:swingbox-javahelp-viewer    文件:BrowserPane.java   
/**
 * Renders current content to given graphic context, which is updated and
 * returned. Context must have set the clip, otherwise NullPointerException
 * is throwen.
 * 
 * @param g
 *            the context to be rendered to.
 * @return the Graphics2D context
 * @see Graphics2D
 */
public Graphics2D renderContent(Graphics2D g)
{

    if (g.getClip() == null)
        throw new NullPointerException(
                "Clip is not set on graphics context");
    ViewFactory factory = getEditorKit().getViewFactory();
    if (factory instanceof SwingBoxViewFactory)
    {
        View view = ((SwingBoxViewFactory) factory).getViewport();
        if (view != null) view.paint(g, g.getClip());
    }

    return g;
}
项目:aibench-project    文件:JXLabel.java   
public static View createView(JXLabel c) {
    BasicEditorKit kit = getFactory();
    float rightIndent = 0;
    if (c.getIcon() != null && c.getHorizontalTextPosition() != SwingConstants.CENTER) {
        rightIndent = c.getIcon().getIconWidth() + c.getIconTextGap(); 
    }
    Document doc = kit.createDefaultDocument(c.getFont(), c.getForeground(), c.getTextAlignment(), rightIndent);
    Reader r = new StringReader(c.getText() == null ? "" : c.getText());
    try {
        kit.read(r, doc, 0);
    } catch (Throwable e) {
    }
    ViewFactory f = kit.getViewFactory();
    View hview = f.create(doc.getDefaultRootElement());
    View v = new Renderer(c, f, hview, true);
    return v;
}
项目:aibench-project    文件:JXLabel.java   
Renderer(JXLabel c, ViewFactory f, View v, boolean wordWrap) {
    super(null, wordWrap);
    factory = f;
    view = v;
    view.setParent(this);
    host = c;
    //log.fine("vir: " +  host.getVisibleRect());
    int w;
    if (host.getVisibleRect().width == 0) {
        invalidated = true;
        return;
    } else {
        w = host.getVisibleRect().width;
    }
    //log.fine("w:" + w);
    // initially layout to the preferred size
    //setSize(c.getMaxLineSpan() > -1 ? c.getMaxLineSpan() : view.getPreferredSpan(X_AXIS), view.getPreferredSpan(Y_AXIS));
    setSize(c.getMaxLineSpan() > -1 ? c.getMaxLineSpan() : w, host.getVisibleRect().height);
}
项目:aibench-project    文件:BasicHyperlinkUI.java   
/**
 * Create an html renderer for the given component and
 * string of html.
 */
public static View createHTMLView(JComponent c, String html) {
    BasicEditorKit kit = getFactory();
    Document doc = kit.createDefaultDocument(c.getFont(),
                                             c.getForeground());
    Object base = c.getClientProperty(documentBaseKey);
    if (base instanceof URL) {
        ((HTMLDocument)doc).setBase((URL)base);
    }
    Reader r = new StringReader(html);
    try {
        kit.read(r, doc, 0);
    } catch (Throwable e) {
    }
    ViewFactory f = kit.getViewFactory();
    View hview = f.create(doc.getDefaultRootElement());
    View v = new Renderer(c, f, hview);
    return v;
}
项目:cn1    文件:ParagraphView_RequirementsTest.java   
protected void setUp() throws Exception {
    super.setUp();
    setIgnoreNotImplemented(true);
    kit = new HTMLEditorKit();
    doc = (HTMLDocument)kit.createDefaultDocument();
    StringReader reader = new StringReader("<html><head></head><body>" +
           "<p><small>one long</small>Word" +
           "<p>very LongWord" +
           "</body></html>");
    kit.read(reader, doc, 0);

    metrics = getFontMetrics(null, CHAR_WIDTH);
    factory = new ViewFactory() {
        public View create(final Element element) {
            InlineView result = new InlineView(element) {
                protected FontMetrics getFontMetrics() {
                    return metrics;
                }
            };
            result.setGlyphPainter(BlockViewTest.InlineViewFactory.painter);
            return result;
        }
    };
}
项目:cn1    文件:ParagraphView_RequirementsTest.java   
public void testCalculateMinorAxisRequirements04() throws Exception {
    factory = new ViewFactory() {
        public View create(Element element) {
            PlainView result = new PlainView(element) {
                public float getPreferredSpan(int axis) {
                    if (axis == X_AXIS) {
                        return CHAR_WIDTH
                               * (getEndOffset() - getStartOffset());
                    }
                    return super.getPreferredSpan(axis);
                }
            };
            return result;
        }
    };
    view = new ParagraphViewImpl(doc.getParagraphElement(10), factory);
    SizeRequirements sr =
        view.calculateMinorAxisRequirements(View.X_AXIS, null);
    assertEquals(8 * CHAR_WIDTH, sr.minimum);
    assertEquals(13 * CHAR_WIDTH, sr.preferred);
    assertEquals(Integer.MAX_VALUE, sr.maximum);
}
项目:JamVM-PH    文件:BasicTextUI.java   
/**
 * Indicates that the model of a text component has changed. This
 * triggers a rebuild of the view hierarchy.
 */
protected void modelChanged()
{
  if (textComponent == null || rootView == null) 
    return;
  ViewFactory factory = rootView.getViewFactory();
  if (factory == null) 
    return;
  Document doc = textComponent.getDocument();
  if (doc == null)
    return;
  Element elem = doc.getDefaultRootElement();
  if (elem == null)
    return;
  View view = factory.create(elem);
  setView(view);
}
项目:SwingBox    文件:DelegateView.java   
/**
 * Sets the view parent.
 * 
 * @param parent
 *            the parent view
 */
@Override
public void setParent(View parent)
{

    if (parent == null && view != null) view.setParent(null);
    this.parent = parent;

    // if set new parent and has some element, try to load children
    // this element is a BranchElement ("collection"),
    // so we should have some LeafElements ("children")
    if ((parent != null) && (getElement() != null))
    {
        ViewFactory f = getViewFactory();
        loadChildren(f);
    }
}
项目:SwingBox    文件:ElementBoxView.java   
@Override
protected void forwardUpdate(DocumentEvent.ElementChange ec,
        DocumentEvent e, Shape a, ViewFactory f)
{
    boolean wasValid = isLayoutValid(majorAxis);
    super.forwardUpdate(ec, e, a, f);

    // determine if a repaint is needed
    if (wasValid && (!isLayoutValid(majorAxis)))
    {
        // Repaint is needed because one of the tiled children
        // have changed their span along the major axis. If there
        // is a hosting component and an allocated shape we repaint.
        Component c = getContainer();
        if ((a != null) && (c != null))
        {
            Rectangle alloc = getInsideAllocation(a);
            c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
        }
    }
}
项目:SwingBox    文件:BrowserPane.java   
/**
 * Renders current content to given graphic context, which is updated and
 * returned. Context must have set the clip, otherwise NullPointerException
 * is thrown.
 * 
 * @param g
 *            the context to be rendered to.
 * @return the Graphics2D context
 * @see Graphics2D
 */
public Graphics2D renderContent(Graphics2D g)
{

    if (g.getClip() == null)
        throw new NullPointerException(
                "Clip is not set on graphics context");
    ViewFactory factory = getEditorKit().getViewFactory();
    if (factory instanceof SwingBoxViewFactory)
    {
        View view = ((SwingBoxViewFactory) factory).getViewport();
        if (view != null) view.paint(g, g.getClip());
    }

    return g;
}
项目:classpath    文件:BasicTextUI.java   
/**
 * Indicates that the model of a text component has changed. This
 * triggers a rebuild of the view hierarchy.
 */
protected void modelChanged()
{
  if (textComponent == null || rootView == null)
    return;
  ViewFactory factory = rootView.getViewFactory();
  if (factory == null)
    return;
  Document doc = textComponent.getDocument();
  if (doc == null)
    return;
  Element elem = doc.getDefaultRootElement();
  if (elem == null)
    return;
  View view = factory.create(elem);
  setView(view);
}
项目:freeVM    文件:ParagraphView_RequirementsTest.java   
protected void setUp() throws Exception {
    super.setUp();
    setIgnoreNotImplemented(true);
    kit = new HTMLEditorKit();
    doc = (HTMLDocument)kit.createDefaultDocument();
    StringReader reader = new StringReader("<html><head></head><body>" +
           "<p><small>one long</small>Word" +
           "<p>very LongWord" +
           "</body></html>");
    kit.read(reader, doc, 0);

    metrics = getFontMetrics(null, CHAR_WIDTH);
    factory = new ViewFactory() {
        public View create(final Element element) {
            InlineView result = new InlineView(element) {
                protected FontMetrics getFontMetrics() {
                    return metrics;
                }
            };
            result.setGlyphPainter(BlockViewTest.InlineViewFactory.painter);
            return result;
        }
    };
}
项目:lexml-swing-editorhtml    文件:RelativeImageView.java   
/** My attributes may have changed. */
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
{
    super.changedUpdate(e, a, f);
    float align = getVerticalAlignment();

    int height = fHeight;
    int width  = fWidth;

    initialize(getElement());

    boolean hChanged = fHeight != height;
    boolean wChanged = fWidth != width;
    if(hChanged || wChanged || getVerticalAlignment() != align)
    {
        getParent().preferenceChanged(this, hChanged, wChanged);
    }
}
项目:lexml-swing-editorhtml    文件:EkitTableView.java   
/**
 * The table itself acts as a factory for the various views that actually
 * represent pieces of the table. All other factory activity is delegated to
 * the factory returned by the parent of the table.
 */
public View create(Element elem) {
    Object o = elem.getAttributes().getAttribute(
            StyleConstants.NameAttribute);
    if (o instanceof HTML.Tag) {
        HTML.Tag kind = (HTML.Tag) o;
        if (kind == HTML.Tag.TR) {
            return createTableRow(elem);
        } else if ((kind == HTML.Tag.TD) || (kind == HTML.Tag.TH)) {
            return new CellView(elem);
        } else if (kind == HTML.Tag.CAPTION) {
            return new javax.swing.text.html.ParagraphView(elem);
        }
    }
    // default is to delegate to the normal factory
    View p = getParent();
    if (p != null) {
        ViewFactory f = p.getViewFactory();
        if (f != null) {
            return f.create(elem);
        }
    }
    return null;
}
项目:freeVM    文件:ParagraphView_RequirementsTest.java   
protected void setUp() throws Exception {
    super.setUp();
    setIgnoreNotImplemented(true);
    kit = new HTMLEditorKit();
    doc = (HTMLDocument)kit.createDefaultDocument();
    StringReader reader = new StringReader("<html><head></head><body>" +
           "<p><small>one long</small>Word" +
           "<p>very LongWord" +
           "</body></html>");
    kit.read(reader, doc, 0);

    metrics = getFontMetrics(null, CHAR_WIDTH);
    factory = new ViewFactory() {
        public View create(final Element element) {
            InlineView result = new InlineView(element) {
                protected FontMetrics getFontMetrics() {
                    return metrics;
                }
            };
            result.setGlyphPainter(BlockViewTest.InlineViewFactory.painter);
            return result;
        }
    };
}
项目:freeVM    文件:ParagraphView_RequirementsTest.java   
public void testCalculateMinorAxisRequirements04() throws Exception {
    factory = new ViewFactory() {
        public View create(Element element) {
            PlainView result = new PlainView(element) {
                public float getPreferredSpan(int axis) {
                    if (axis == X_AXIS) {
                        return CHAR_WIDTH
                               * (getEndOffset() - getStartOffset());
                    }
                    return super.getPreferredSpan(axis);
                }
            };
            return result;
        }
    };
    view = new ParagraphViewImpl(doc.getParagraphElement(10), factory);
    SizeRequirements sr =
        view.calculateMinorAxisRequirements(View.X_AXIS, null);
    assertEquals(8 * CHAR_WIDTH, sr.minimum);
    assertEquals(13 * CHAR_WIDTH, sr.preferred);
    assertEquals(Integer.MAX_VALUE, sr.maximum);
}
项目:incubator-netbeans    文件:DrawEngineDocView.java   
protected @Override View createCustomView(ViewFactory f,
int startOffset, int maxEndOffset, int elementIndex) {
    if (elementIndex == -1) {
        throw new IllegalStateException("Need underlying line element structure"); // NOI18N
    }

    View view = null;

    Element elem = getElement();
    Element lineElem = elem.getElement(elementIndex);
    view = f.create(lineElem);
    return view;
}
项目:incubator-netbeans    文件:FoldMultiLineView.java   
protected @Override void reloadChildren(int index, int removeLength, int startOffset, int endOffset) {
    // TODO uncomment assert (index == 0 && removeLength == 0
        // && startOffset == getStartOffset() && endOffset == getEndOffset());

    // Rebuild all the present child views completely
    index = 0;
    removeLength = getViewCount();

    Element lineElem = getElement(); // starting line element
    View[] added = null;
    ViewFactory f = getViewFactory();
    if (f != null) {
        int lineElemEndOffset = lineElem.getEndOffset();
        // Ending offset of the previously created view - here start with
        //   begining of the first line
        int lastViewEndOffset = lineElem.getStartOffset();

        List childViews = new ArrayList();
        // Append ending fragment if necessary
        // asserted non-empty list => foldEndOffset populated
        if (lastViewEndOffset < lineElemEndOffset) { // need ending fragment
            View lineView = f.create(lineElem);
            View endingFrag = lineView.createFragment(lastViewEndOffset, lineElemEndOffset);
            childViews.add(endingFrag);
            // lastViewEndOffset = lineElemEndOffset;  <- can be ignored here
        }

        added = new View[childViews.size()];
        childViews.toArray(added);
    }


    replace(index, removeLength, added);
}
项目:incubator-netbeans    文件:GapBoxView.java   
public @Override void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    // #38993 - until parent is set - do not do anything
    if (children == null && getParent() == null) {
        return;
    }

    if (useCustomReloadChildren()) {
        customInsertUpdate(evt, a, f);
    } else { // custom insert update
        super.insertUpdate(evt, a, f); // default element-based update
    }
}
项目:incubator-netbeans    文件:GapBoxView.java   
protected void customInsertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    int[] offsetRange = getInsertUpdateRebuildOffsetRange(evt);
    if (offsetRange != null) {
        offsetRebuild(offsetRange[0], offsetRange[1]);
    } else {
        forwardUpdate(null, evt, a, f);
    }
}
项目:incubator-netbeans    文件:GapBoxView.java   
public @Override void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    // #38993 - until parent is set - do not do anything
    if (children == null && getParent() == null) {
        return;
    }

    if (useCustomReloadChildren()) {
        customRemoveUpdate(evt, a, f);
    } else {
        super.removeUpdate(evt, a, f); // default element-based update
    }
}
项目:incubator-netbeans    文件:GapBoxView.java   
protected void customRemoveUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    int[] offsetRange = getRemoveUpdateRebuildOffsetRange(evt);
    if (offsetRange != null) {
        offsetRebuild(offsetRange[0], offsetRange[1]);
    } else {
        forwardUpdate(null, evt, a, f);
    }
}
项目:incubator-netbeans    文件:GapBoxView.java   
public @Override void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    // #38993 - until parent is set - do not do anything
    if (children == null && getParent() == null) {
        return;
    }

    super.changedUpdate(e, a, f);
}
项目:incubator-netbeans    文件:GapBoxView.java   
/**
     * Create custom child view starting at <code>startOffset</code>.
     *
     * @param f view factory to be used.
     * @param startOffset offset at which the created view must start.
     * @param maxEndOffset maximum ending offset to which the created view
     *  may span.
     * @param elementIndex index of the child element that best represents
     *  the startOffset. The element is child of the element that this view
     *  is responsible for. If this view is not based by element then this
     *  parameter will be -1.
     */
    protected View createCustomView(ViewFactory f,
    int startOffset, int maxEndOffset, int elementIndex) {


/*
        // Default implementation delegating to view factory
        // is here just to show the possible functionality
        // and clarify the variables

        View v;
        if (parentElement != null) {
            Element elem = parentElement.getElement(elementIndex);
            if (elem.getStartOffset() != startOffset) {
                throw new IllegalStateException("Not element boundary");
            }

            if (elem.getEndOffset() > maxEndOffset) {
                throw new IllegalStateException("Beyond maximum ending offset");
            }

            v = f.create(elem);

        } else { // no element - need more information
            return null;
        }
 */

        return null;
    }
项目:incubator-netbeans    文件:GapDocumentView.java   
public void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    layoutLockDepth++;
    try {
        pendingUpdate = false; // Reset before so that child view do not estimate
        super.insertUpdate(evt, a, f);
    } finally {
        updateLayout();
        checkPendingDamageRange();
        layoutLockDepth--;
    }
}
项目:incubator-netbeans    文件:GapDocumentView.java   
public void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f) {
    layoutLockDepth++;
    try {
        pendingUpdate = false; // Reset before so that child view do not estimate
        super.removeUpdate(evt, a, f);
    } finally {
        updateLayout();
        checkPendingDamageRange();
        layoutLockDepth--;
    }
}
项目:incubator-netbeans    文件:GapDocumentView.java   
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    layoutLockDepth++;
    try {
        // Do not check pendingUpdate since changedUpdate() is likely invoked by BaseDocument.repaintBlock()
        super.changedUpdate(e, a, f);
    } finally {
        updateLayout();
        layoutLockDepth--;
    }
}
项目:incubator-netbeans    文件:LockView.java   
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    lock();
    try {

        if (view != null) {
            view.insertUpdate(e, a, f);
        }

    } finally {
        unlock();
    }
}