Example usage for javax.swing.text View getViewCount

List of usage examples for javax.swing.text View getViewCount

Introduction

In this page you can find the example usage for javax.swing.text View getViewCount.

Prototype

public int getViewCount() 

Source Link

Document

Returns the number of views in this view.

Usage

From source file:Main.java

public static void walkView(View view, int level) {
    int n = view.getViewCount();
    for (int i = 0; i < n; i++) {
        walkView(view.getView(i), level + 1);
    }//from  w ww.  j a v a2  s .c  om
}

From source file:TextFieldViews.java

public static void displayView(View view, int indent, Document doc, PrintStream out) {
    String name = view.getClass().getName();
    for (int i = 0; i < indent; i++) {
        out.print("\t");
    }/*from  w  ww  .  java  2 s  .  com*/

    int start = view.getStartOffset();
    int end = view.getEndOffset();
    out.println(name + "; offsets [" + start + ", " + end + "]");
    int viewCount = view.getViewCount();
    if (viewCount == 0) {
        int length = Math.min(32, end - start);
        try {
            String txt = doc.getText(start, length);
            for (int i = 0; i < indent + 1; i++) {
                out.print("\t");
            }
            out.println("[" + txt + "]");
        } catch (BadLocationException e) {
        }
    } else {
        for (int i = 0; i < viewCount; i++) {
            displayView(view.getView(i), indent + 1, doc, out);
        }
    }
}

From source file:TextComponentDisplay.java

public static void displayView(View view, int tabs, PrintStream out) {
    // Print info about this view
    for (int i = 0; i < tabs; i++) {
        out.print("\t");
    }//from   w ww  . j ava 2s  .  c  o  m

    out.println(view.getClass().getName());

    for (int i = 0; i < tabs; i++) {
        out.print("\t");
    }

    out.println("Start: " + view.getStartOffset() + "; end: " + view.getEndOffset());

    // Display child views, if any.
    int childViews = view.getViewCount();
    for (int i = 0; i < childViews; i++) {
        View childView = view.getView(i);
        displayView(childView, tabs + 1, out);
    }
}

From source file:ShowHTMLViews.java

public static void displayView(View view, int indent, Document doc, PrintStream out) {
    String name = view.getClass().getName();
    for (int i = 0; i < indent; i++) {
        out.print("  ");
    }/*from   w w  w  .j a  va  2 s  . c  o m*/

    int start = view.getStartOffset();
    int end = view.getEndOffset();
    out.println(name + "; offsets [" + start + ", " + end + "]");
    for (int i = 0; i < indent; i++) {
        out.print("  ");
    }
    HTMLDocDisplay.displayAttributes(view.getAttributes(), indent, out);
    int viewCount = view.getViewCount();
    if (viewCount == 0) {
        int length = Math.min(32, end - start);
        try {
            String txt = doc.getText(start, length);
            for (int i = 0; i < indent + 1; i++) {
                out.print("  ");
            }
            out.println("[" + txt + "]");
        } catch (BadLocationException e) {
        }
    } else {
        for (int i = 0; i < viewCount; i++) {
            displayView(view.getView(i), indent + 1, doc, out);
        }
    }
    out.println("");
}