FileDocCategorySizeDatePackage
AccessibleHTML.javaAPI DocJava SE 6 API91838Tue Jun 10 00:26:58 BST 2008javax.swing.text.html

AccessibleHTML

public class AccessibleHTML extends Object implements Accessible

Fields Summary
private JEditorPane
editor
The editor.
private Document
model
Current model.
private DocumentListener
docListener
DocumentListener installed on the current model.
private PropertyChangeListener
propChangeListener
PropertyChangeListener installed on the editor
private ElementInfo
rootElementInfo
The root ElementInfo for the document
private RootHTMLAccessibleContext
rootHTMLAccessibleContext
Constructors Summary
public AccessibleHTML(JEditorPane pane)

	editor = pane;
	propChangeListener = new PropertyChangeHandler();
        setDocument(editor.getDocument());

        docListener = new DocumentHandler();
    
Methods Summary
private voidbuildInfo()
Rebuilds the information from the current info.

        Object lock = lock();

        try {
            Document doc = getDocument();
            Element root = doc.getDefaultRootElement();

            rootElementInfo = new ElementInfo(root);
            rootElementInfo.validate();
        } finally {
            unlock(lock);
        }
    
javax.swing.text.html.AccessibleHTML$ElementInfocreateElementInfo(javax.swing.text.Element e, javax.swing.text.html.AccessibleHTML$ElementInfo parent)

        AttributeSet attrs = e.getAttributes();

        if (attrs != null) {
            Object name = attrs.getAttribute(StyleConstants.NameAttribute);

            if (name == HTML.Tag.IMG) {
                return new IconElementInfo(e, parent);
            }
            else if (name == HTML.Tag.CONTENT || name == HTML.Tag.CAPTION) {
                return new TextElementInfo(e, parent);
            }
            else if (name == HTML.Tag.TABLE) {
                return new TableElementInfo(e, parent);
            }
        }
        return null;
    
public javax.accessibility.AccessibleContextgetAccessibleContext()
Returns the root AccessibleContext for the document

	if (rootHTMLAccessibleContext == null) {
	    rootHTMLAccessibleContext = 
		new RootHTMLAccessibleContext(rootElementInfo);
	}
	return rootHTMLAccessibleContext;
    
private javax.swing.text.DocumentgetDocument()
Returns the Document currently presenting information for.

        return model;
    
private java.awt.RectanglegetRootEditorRect()
Returns the bounds the root View will be rendered in.

        Rectangle alloc = getTextComponent().getBounds();
        if ((alloc.width > 0) && (alloc.height > 0)) {
            alloc.x = alloc.y = 0;
            Insets insets = editor.getInsets();
            alloc.x += insets.left;
            alloc.y += insets.top;
            alloc.width -= insets.left + insets.right;
            alloc.height -= insets.top + insets.bottom;
            return alloc;
        }
        return null;
    
private javax.swing.text.html.AccessibleHTML$ElementInfogetRootInfo()
Returns the ElementInfo representing the root Element.

        return rootElementInfo;
    
private javax.swing.text.ViewgetRootView()
Returns the root View associated with the current text component.

        return getTextComponent().getUI().getRootView(getTextComponent());
    
private javax.swing.JEditorPanegetTextComponent()
Returns the JEditorPane providing information for.

        return editor;
    
private java.lang.Objectlock()
If possible acquires a lock on the Document. If a lock has been obtained a key will be retured that should be passed to unlock.

        Document document = getDocument();

        if (document instanceof AbstractDocument) {
            ((AbstractDocument)document).readLock();
            return document;
        }
        return null;
    
private voidsetDocument(javax.swing.text.Document document)
Sets the document.

        if (model != null) {
            model.removeDocumentListener(docListener);
        }
	if (editor != null) {
	    editor.removePropertyChangeListener(propChangeListener);
	}
        this.model = document;
        if (model != null) {
            if (rootElementInfo != null) {
                rootElementInfo.invalidate(false);
            }
            buildInfo();
            model.addDocumentListener(docListener);
        }
        else {
            rootElementInfo = null;
        }
	if (editor != null) {
	    editor.addPropertyChangeListener(propChangeListener);
	}
    
private voidunlock(java.lang.Object key)
Releases a lock previously obtained via lock.

        if (key != null) {
            ((AbstractDocument)key).readUnlock();
        }