javax.swing.text.View#getViewCount ( )源码实例Demo

下面列出了javax.swing.text.View#getViewCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: ViewUtilitiesImpl.java
public int updateIndex(int viewIndex, int offset, View view, FlyView.Parent flyParent) {
    int lastViewIndex = view.getViewCount() - 1;

    while (true) {
        int endOffset = (flyParent != null)
            ? flyParent.getEndOffset(viewIndex)
            : view.getView(viewIndex).getEndOffset();
        if (endOffset != offset) { // view ends after offset
            if (excludeAtOffset) {
                viewIndex--; // return the lower view that ends at offset
            }
            break;
        }
     
        if (viewIndex == lastViewIndex) { // over last view
            break;
        }
        viewIndex++;
    }
    
    return viewIndex;
}
 
源代码2 项目: dragonwell8_jdk   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码3 项目: TencentKona-8   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码4 项目: jdk8u60   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码5 项目: openjdk-jdk8u   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码6 项目: jdk8u-dev-jdk   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码7 项目: netbeans   文件: ViewUtilitiesImpl.java
private static void checkChildrenParent(View v) {
    int cnt = v.getViewCount();
    for (int i = 0; i < cnt; i++) {
        View child = v.getView(i);
        View childParent = child.getParent();
        if (childParent != v) {
            throw new IllegalStateException("child=" + child // NOI18N
                + " has parent=" + childParent // NOI18N
                + " instead of " + v // NOI18N
            );
        }
        checkChildrenParent(child);
    }
}
 
源代码8 项目: netbeans   文件: Utilities.java
/**
 * Get first view in the hierarchy that is an instance of the given class.
 * It allows to skip various wrapper-views around the doc-view that holds
 * the child views for the lines.
 *
 * @param component component from which the root view is fetched.
 * @param rootViewClass class of the view to return.
 * @return view being instance of the requested class or null if there
 *  is not one.
 */
public static View getRootView(JTextComponent component, Class rootViewClass) {
    View view = null;
    TextUI textUI = component.getUI();
    if (textUI != null) {
        view = textUI.getRootView(component);
        while (view != null && !rootViewClass.isInstance(view)
            && view.getViewCount() == 1 // must be wrapper view
        ) {
            view = view.getView(0); // get the only child
        }
    }
    
    return view;
}
 
源代码9 项目: spotbugs   文件: NumberedParagraphView.java
public int getPreviousLineCount0() {
    int lineCount = 0;
    View parent = this.getParent();
    int count = parent.getViewCount();
    for (int i = 0; i < count; i++) {
        if (parent.getView(i) == this) {
            break;
        } else {
            lineCount += parent.getView(i).getViewCount();
        }
    }
    return lineCount;
}
 
源代码10 项目: jdk8u_jdk   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码11 项目: openjdk-jdk9   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码12 项目: openjdk-jdk9   文件: bug4960629.java
private void test() {
    View root = ((View)label.getClientProperty(BasicHTML.propertyKey))
            .getView(0);
    int n = root.getViewCount();
    View v  = root.getView(n - 1);
    AttributeSet attrs = v.getAttributes();
    StyleSheet ss = ((HTMLDocument) v.getDocument()).getStyleSheet();
    Font font = ss.getFont(attrs);
    System.out.println(font.getSize());
    passed = (font.getSize() == 12);
    if(!passed) {
        throw new RuntimeException("Test failed.");
    }
}
 
源代码13 项目: jdk8u-jdk   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码14 项目: trygve   文件: NumberedParagraphView.java
public int getPreviousLineCount() {
    int lineCount = 0;
    View parent = this.getParent();
    int count = parent.getViewCount();
    for (int i = 0; i < count; i++) {
        if (parent.getView(i) == this) {
            break;
        }
        else {
        	// Count source number lines rather than display lines...
            lineCount += 1; // Old (display lines): parent.getView(i).getViewCount();
        }
    }
    return lineCount;
}
 
源代码15 项目: hottub   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码16 项目: openjdk-8-source   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码17 项目: openjdk-8   文件: bug8014863.java
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
源代码18 项目: netbeans   文件: ActionFactory.java
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    AbstractDocument adoc = (AbstractDocument)target.getDocument();

    // Dump fold hierarchy
    FoldHierarchy hierarchy = FoldHierarchy.get(target);
    adoc.readLock();
    try {
        hierarchy.lock();
        try {
            /*DEBUG*/System.err.println("FOLD HIERARCHY DUMP:\n" + hierarchy); // NOI18N
            TokenHierarchy<?> th = TokenHierarchy.get(adoc);
            /*DEBUG*/System.err.println("TOKEN HIERARCHY DUMP:\n" + (th != null ? th : "<NULL-TH>")); // NOI18N

        } finally {
            hierarchy.unlock();
        }
    } finally {
        adoc.readUnlock();
    }

    View rootView = null;
    TextUI textUI = target.getUI();
    if (textUI != null) {
        rootView = textUI.getRootView(target); // Root view impl in BasicTextUI
        if (rootView != null && rootView.getViewCount() == 1) {
            rootView = rootView.getView(0); // Get DocumentView
        }
    }
    if (rootView != null) {
        String rootViewDump = (rootView instanceof DocumentView)
                ? ((DocumentView)rootView).toStringDetail()
                : rootView.toString();
        /*DEBUG*/System.err.println("DOCUMENT VIEW: " + System.identityHashCode(rootView) + // NOI18N
                "\n" + rootViewDump); // NOI18N
        int caretOffset = target.getCaretPosition();
        int caretViewIndex = rootView.getViewIndex(caretOffset, Position.Bias.Forward);
        /*DEBUG*/System.err.println("caretOffset=" + caretOffset + ", caretViewIndex=" + caretViewIndex); // NOI18N
        if (caretViewIndex >= 0 && caretViewIndex < rootView.getViewCount()) {
            View caretView = rootView.getView(caretViewIndex);
            /*DEBUG*/System.err.println("caretView: " + caretView); // NOI18N
        }
        /*DEBUG*/System.err.println(FixLineSyntaxState.lineInfosToString(adoc));
        // Check the hierarchy correctness
        //org.netbeans.editor.view.spi.ViewUtilities.checkViewHierarchy(rootView);
    }
    
    if (adoc instanceof BaseDocument) {
        /*DEBUG*/System.err.println("DOCUMENT:\n" + ((BaseDocument)adoc).toStringDetail()); // NOI18N
    }
}
 
源代码19 项目: Spark   文件: ChatPrinter.java
private boolean printView(Graphics2D graphics2D, Shape allocation,
                              View view) {
        boolean pageExists = false;
        Rectangle clipRectangle = graphics2D.getClipBounds();
        Shape childAllocation;
        View childView;

        if (view.getViewCount() > 0) {
            for (int i = 0; i < view.getViewCount(); i++) {
                childAllocation = view.getChildAllocation(i, allocation);
                if (childAllocation != null) {
                    childView = view.getView(i);
                    if (printView(graphics2D, childAllocation, childView)) {
                        pageExists = true;
                    }
                }
            }
        }
        else {
//  I
            if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {
                pageExists = true;
//  II
                if ((allocation.getBounds().getHeight() > clipRectangle.getHeight()) &&
                        (allocation.intersects(clipRectangle))) {
                    view.paint(graphics2D, allocation);
                }
                else {
//  III
                    if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                        if (allocation.getBounds().getMaxY() <= clipRectangle.getMaxY()) {
                            view.paint(graphics2D, allocation);
                        }
                        else {
//  IV
                            if (allocation.getBounds().getY() < pageEndY) {
                                pageEndY = allocation.getBounds().getY();
                            }
                        }
                    }
                }
            }
        }
        return pageExists;
    }
 
源代码20 项目: ramus   文件: HTMLPrintable.java
private boolean printView(final Graphics2D graphics2D,
                          final Shape allocation, final View view) {
    boolean pageExists = false;
    final Rectangle clipRectangle = new Rectangle(0, 0, (int) (pageFormat
            .getImageableWidth() / SCALE), (int) clientHeight);
    Shape childAllocation;
    View childView;

    if (view.getViewCount() > 0) {
        for (int i = 0; i < view.getViewCount(); i++) {
            childAllocation = view.getChildAllocation(i, allocation);
            if (childAllocation != null) {
                childView = view.getView(i);
                if (printView(graphics2D, childAllocation, childView)) {
                    pageExists = true;
                }
            }
        }
    } else {
        if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {

            if (allocation.getBounds().getHeight() > clipRectangle
                    .getHeight()
                    && allocation.intersects(clipRectangle)) {
                paintView(graphics2D, view, allocation);
                pageExists = true;
            } else {
                if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                    if (allocation.getBounds().getMaxY() <= clipRectangle
                            .getMaxY()) {
                        paintView(graphics2D, view, allocation);
                        pageExists = true;

                    } else {
                        if (allocation.getBounds().getY() < pageEndY) {
                            pageEndY = allocation.getBounds().getY();
                        }
                    }
                }
            }
        }
    }
    return pageExists;
}