Example usage for javax.swing.text View getAttributes

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

Introduction

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

Prototype

public AttributeSet getAttributes() 

Source Link

Document

Fetches the attributes to use when rendering.

Usage

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  v a2s.co 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("");
}