Example usage for javax.swing.text View getView

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

Introduction

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

Prototype

public View getView(int n) 

Source Link

Document

Gets the nth child 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 w  w.  j a v a 2  s.c  o  m*/
}

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 w w .j a  va2  s  . 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: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  .  ja va 2s .c om*/

    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: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 ww w.  j  a v  a 2s  .  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("");
}