child. It provides an implementation of the
Java Accessibility API appropriate to tree nodes.
Method from javax.swing.JTree$AccessibleJTree$AccessibleJTreeNode Detail: |
public void addAccessibleSelection(int i) {
TreeModel model = JTree.this.getModel();
if (model != null) {
if (i >= 0 && i < getAccessibleChildrenCount()) {
TreePath path = getChildTreePath(i);
JTree.this.addSelectionPath(path);
}
}
}
Adds the specified selected item in the object to the object's
selection. If the object supports multiple selections,
the specified item is added to any existing selection, otherwise
it replaces any existing selection in the object. If the
specified item is already selected, this method has no effect. |
public void addFocusListener(FocusListener l) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).addFocusListener(l);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.addFocusListener(l);
}
}
}
|
public void addPropertyChangeListener(PropertyChangeListener l) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
ac.addPropertyChangeListener(l);
} else {
super.addPropertyChangeListener(l);
}
}
Add a PropertyChangeListener to the listener list.
The listener is registered for all properties. |
public void clearAccessibleSelection() {
int childCount = getAccessibleChildrenCount();
for (int i = 0; i < childCount; i++) {
removeAccessibleSelection(i);
}
}
Clears the selection in the object, so that nothing in the
object is selected. |
public boolean contains(Point p) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
Rectangle r = ((AccessibleComponent) ac).getBounds();
return r.contains(p);
} else {
Component c = getCurrentComponent();
if (c != null) {
Rectangle r = c.getBounds();
return r.contains(p);
} else {
return getBounds().contains(p);
}
}
}
|
public boolean doAccessibleAction(int i) {
if (i < 0 || i >= getAccessibleActionCount()) {
return false;
}
AccessibleContext ac = getCurrentAccessibleContext();
if (i == 0) {
if (JTree.this.isExpanded(path)) {
JTree.this.collapsePath(path);
} else {
JTree.this.expandPath(path);
}
return true;
} else if (ac != null) {
AccessibleAction aa = ac.getAccessibleAction();
if (aa != null) {
return aa.doAccessibleAction(i - 1);
}
}
return false;
}
Perform the specified Action on the tree node. If this node
is not a leaf, there is at least one action which can be
done (toggle expand), in addition to any available on the
object behind the TreeCellRenderer. |
public AccessibleAction getAccessibleAction() {
return this;
}
Get the AccessibleAction associated with this object. In the
implementation of the Java Accessibility API for this class,
return this object, which is responsible for implementing the
AccessibleAction interface on behalf of itself. |
public int getAccessibleActionCount() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
AccessibleAction aa = ac.getAccessibleAction();
if (aa != null) {
return (aa.getAccessibleActionCount() + (isLeaf ? 0 : 1));
}
}
return isLeaf ? 0 : 1;
}
Returns the number of accessible actions available in this
tree node. If this node is not a leaf, there is at least
one action (toggle expand), in addition to any available
on the object behind the TreeCellRenderer. |
public String getAccessibleActionDescription(int i) {
if (i < 0 || i >= getAccessibleActionCount()) {
return null;
}
AccessibleContext ac = getCurrentAccessibleContext();
if (i == 0) {
// TIGER - 4766636
return AccessibleAction.TOGGLE_EXPAND;
} else if (ac != null) {
AccessibleAction aa = ac.getAccessibleAction();
if (aa != null) {
return aa.getAccessibleActionDescription(i - 1);
}
}
return null;
}
Return a description of the specified action of the tree node.
If this node is not a leaf, there is at least one action
description (toggle expand), in addition to any available
on the object behind the TreeCellRenderer. |
public Accessible getAccessibleAt(Point p) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).getAccessibleAt(p);
} else {
return null;
}
}
Returns the Accessible child, if one exists,
contained at the local coordinate Point .
Otherwise returns null . |
public Accessible getAccessibleChild(int i) {
// Tree nodes can't be so complex that they have
// two sets of children - > we're ignoring that case
if (i < 0 || i >= getAccessibleChildrenCount()) {
return null;
} else {
Object childObj = treeModel.getChild(obj, i);
Object[] objPath = path.getPath();
Object[] objChildPath = new Object[objPath.length+1];
java.lang.System.arraycopy(objPath, 0, objChildPath, 0, objPath.length);
objChildPath[objChildPath.length-1] = childObj;
TreePath childPath = new TreePath(objChildPath);
return new AccessibleJTreeNode(JTree.this, childPath, this);
}
}
Return the specified Accessible child of the object. |
public int getAccessibleChildrenCount() {
// Tree nodes can't be so complex that they have
// two sets of children - > we're ignoring that case
return treeModel.getChildCount(obj);
}
Returns the number of accessible children in the object. |
public AccessibleComponent getAccessibleComponent() {
return this; // to override getBounds()
}
Get the AccessibleComponent associated with this object. In the
implementation of the Java Accessibility API for this class,
return this object, which is responsible for implementing the
AccessibleComponent interface on behalf of itself. |
public AccessibleContext getAccessibleContext() {
return this;
}
Get the AccessibleContext associated with this tree node.
In the implementation of the Java Accessibility API for
this class, return this object, which is its own
AccessibleContext. |
public String getAccessibleDescription() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
return ac.getAccessibleDescription();
} else {
return super.getAccessibleDescription();
}
}
Get the accessible description of this object. |
public int getAccessibleIndexInParent() {
// index is invalid 'till we have an accessibleParent...
if (accessibleParent == null) {
getAccessibleParent();
}
Object[] objPath = path.getPath();
if (objPath.length > 1) {
Object objParent = objPath[objPath.length-2];
if (treeModel != null) {
index = treeModel.getIndexOfChild(objParent, obj);
}
}
return index;
}
Get the index of this object in its accessible parent. |
public String getAccessibleName() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
String name = ac.getAccessibleName();
if ((name != null) && (name != "")) {
return ac.getAccessibleName();
} else {
return null;
}
}
if ((accessibleName != null) && (accessibleName != "")) {
return accessibleName;
} else {
// fall back to the client property
return (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
}
}
Get the accessible name of this object. |
public Accessible getAccessibleParent() {
// someone wants to know, so we need to create our parent
// if we don't have one (hey, we're a talented kid!)
if (accessibleParent == null) {
Object[] objPath = path.getPath();
if (objPath.length > 1) {
Object objParent = objPath[objPath.length-2];
if (treeModel != null) {
index = treeModel.getIndexOfChild(objParent, obj);
}
Object[] objParentPath = new Object[objPath.length-1];
java.lang.System.arraycopy(objPath, 0, objParentPath,
0, objPath.length-1);
TreePath parentPath = new TreePath(objParentPath);
accessibleParent = new AccessibleJTreeNode(tree,
parentPath,
null);
this.setAccessibleParent(accessibleParent);
} else if (treeModel != null) {
accessibleParent = tree; // we're the top!
index = 0; // we're an only child!
this.setAccessibleParent(accessibleParent);
}
}
return accessibleParent;
}
Get the Accessible parent of this object. |
public AccessibleRole getAccessibleRole() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
return ac.getAccessibleRole();
} else {
return AccessibleRole.UNKNOWN;
}
}
Get the role of this object. |
public AccessibleSelection getAccessibleSelection() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null && isLeaf) {
return getCurrentAccessibleContext().getAccessibleSelection();
} else {
return this;
}
}
Get the AccessibleSelection associated with this object if one
exists. Otherwise return null. |
public Accessible getAccessibleSelection(int i) {
int childCount = getAccessibleChildrenCount();
if (i < 0 || i >= childCount) {
return null; // out of range
}
int count = 0;
for (int j = 0; j < childCount && i >= count; j++) {
TreePath childPath = getChildTreePath(j);
if (tree.isPathSelected(childPath)) {
if (count == i) {
return new AccessibleJTreeNode(tree, childPath, this);
} else {
count++;
}
}
}
return null;
}
Returns an Accessible representing the specified selected item
in the object. If there isn't a selection, or there are
fewer items selected than the integer passed in, the return
value will be null. |
public int getAccessibleSelectionCount() {
int count = 0;
int childCount = getAccessibleChildrenCount();
for (int i = 0; i < childCount; i++) {
TreePath childPath = getChildTreePath(i);
if (tree.isPathSelected(childPath)) {
count++;
}
}
return count;
}
Returns the number of items currently selected.
If no items are selected, the return value will be 0. |
public AccessibleStateSet getAccessibleStateSet() {
AccessibleContext ac = getCurrentAccessibleContext();
AccessibleStateSet states;
if (ac != null) {
states = ac.getAccessibleStateSet();
} else {
states = new AccessibleStateSet();
}
// need to test here, 'cause the underlying component
// is a cellRenderer, which is never showing...
if (isShowing()) {
states.add(AccessibleState.SHOWING);
} else if (states.contains(AccessibleState.SHOWING)) {
states.remove(AccessibleState.SHOWING);
}
if (isVisible()) {
states.add(AccessibleState.VISIBLE);
} else if (states.contains(AccessibleState.VISIBLE)) {
states.remove(AccessibleState.VISIBLE);
}
if (tree.isPathSelected(path)){
states.add(AccessibleState.SELECTED);
}
if (path == getLeadSelectionPath()) {
states.add(AccessibleState.ACTIVE);
}
if (!isLeaf) {
states.add(AccessibleState.EXPANDABLE);
}
if (tree.isExpanded(path)) {
states.add(AccessibleState.EXPANDED);
} else {
states.add(AccessibleState.COLLAPSED);
}
if (tree.isEditable()) {
states.add(AccessibleState.EDITABLE);
}
return states;
}
Get the state set of this object. |
public AccessibleText getAccessibleText() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
return getCurrentAccessibleContext().getAccessibleText();
} else {
return null;
}
}
Get the AccessibleText associated with this object if one
exists. Otherwise return null. |
public AccessibleValue getAccessibleValue() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
return getCurrentAccessibleContext().getAccessibleValue();
} else {
return null;
}
}
Get the AccessibleValue associated with this object if one
exists. Otherwise return null. |
public Color getBackground() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).getBackground();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.getBackground();
} else {
return null;
}
}
}
Get the background color of this object. |
public Rectangle getBounds() {
Rectangle r = tree.getPathBounds(path);
Accessible parent = getAccessibleParent();
if (parent != null) {
if (parent instanceof AccessibleJTreeNode) {
Point parentLoc = ((AccessibleJTreeNode) parent).getLocationInJTree();
if (parentLoc != null && r != null) {
r.translate(-parentLoc.x, -parentLoc.y);
} else {
return null; // not visible!
}
}
}
return r;
}
|
public Cursor getCursor() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).getCursor();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.getCursor();
} else {
Accessible ap = getAccessibleParent();
if (ap instanceof AccessibleComponent) {
return ((AccessibleComponent) ap).getCursor();
} else {
return null;
}
}
}
}
|
public Font getFont() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).getFont();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.getFont();
} else {
return null;
}
}
}
|
public FontMetrics getFontMetrics(Font f) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).getFontMetrics(f);
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.getFontMetrics(f);
} else {
return null;
}
}
}
|
public Color getForeground() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).getForeground();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.getForeground();
} else {
return null;
}
}
}
Get the foreground color of this object. |
public Locale getLocale() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
return ac.getLocale();
} else {
return tree.getLocale();
}
}
Gets the locale of the component. If the component does not have
a locale, then the locale of its parent is returned. |
public Point getLocation() {
Rectangle r = getBounds();
if (r != null) {
return r.getLocation();
} else {
return null;
}
}
|
protected Point getLocationInJTree() {
Rectangle r = tree.getPathBounds(path);
if (r != null) {
return r.getLocation();
} else {
return null;
}
}
|
public Point getLocationOnScreen() {
if (tree != null) {
Point treeLocation = tree.getLocationOnScreen();
Rectangle pathBounds = tree.getPathBounds(path);
if (treeLocation != null && pathBounds != null) {
Point nodeLocation = new Point(pathBounds.x,
pathBounds.y);
nodeLocation.translate(treeLocation.x, treeLocation.y);
return nodeLocation;
} else {
return null;
}
} else {
return null;
}
}
|
public Dimension getSize() {
return getBounds().getSize();
}
|
public boolean isAccessibleChildSelected(int i) {
int childCount = getAccessibleChildrenCount();
if (i < 0 || i >= childCount) {
return false; // out of range
} else {
TreePath childPath = getChildTreePath(i);
return tree.isPathSelected(childPath);
}
}
Returns true if the current child of this object is selected. |
public boolean isEnabled() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).isEnabled();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.isEnabled();
} else {
return false;
}
}
}
|
public boolean isFocusTraversable() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
return ((AccessibleComponent) ac).isFocusTraversable();
} else {
Component c = getCurrentComponent();
if (c != null) {
return c.isFocusTraversable();
} else {
return false;
}
}
}
|
public boolean isShowing() {
return (tree.isShowing() && isVisible());
}
|
public boolean isVisible() {
Rectangle pathBounds = tree.getPathBounds(path);
Rectangle parentBounds = tree.getVisibleRect();
return pathBounds != null && parentBounds != null &&
parentBounds.intersects(pathBounds);
}
|
public void removeAccessibleSelection(int i) {
TreeModel model = JTree.this.getModel();
if (model != null) {
if (i >= 0 && i < getAccessibleChildrenCount()) {
TreePath path = getChildTreePath(i);
JTree.this.removeSelectionPath(path);
}
}
}
Removes the specified selected item in the object from the
object's
selection. If the specified item isn't currently selected, this
method has no effect. |
public void removeFocusListener(FocusListener l) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).removeFocusListener(l);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.removeFocusListener(l);
}
}
}
|
public void removePropertyChangeListener(PropertyChangeListener l) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
ac.removePropertyChangeListener(l);
} else {
super.removePropertyChangeListener(l);
}
}
Remove a PropertyChangeListener from the listener list.
This removes a PropertyChangeListener that was registered
for all properties. |
public void requestFocus() {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).requestFocus();
} else {
Component c = getCurrentComponent();
if (c != null) {
c.requestFocus();
}
}
}
|
public void selectAllAccessibleSelection() {
TreeModel model = JTree.this.getModel();
if (model != null) {
int childCount = getAccessibleChildrenCount();
TreePath path;
for (int i = 0; i < childCount; i++) {
path = getChildTreePath(i);
JTree.this.addSelectionPath(path);
}
}
}
Causes every selected item in the object to be selected
if the object supports multiple selections. |
public void setAccessibleDescription(String s) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
ac.setAccessibleDescription(s);
} else {
super.setAccessibleDescription(s);
}
}
Set the accessible description of this object. |
public void setAccessibleName(String s) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac != null) {
ac.setAccessibleName(s);
} else {
super.setAccessibleName(s);
}
}
Set the localized accessible name of this object. |
public void setBackground(Color c) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setBackground(c);
} else {
Component cp = getCurrentComponent();
if (cp != null) {
cp.setBackground(c);
}
}
}
Set the background color of this object. |
public void setBounds(Rectangle r) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setBounds(r);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.setBounds(r);
}
}
}
|
public void setCursor(Cursor c) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setCursor(c);
} else {
Component cp = getCurrentComponent();
if (cp != null) {
cp.setCursor(c);
}
}
}
|
public void setEnabled(boolean b) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setEnabled(b);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.setEnabled(b);
}
}
}
|
public void setFont(Font f) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setFont(f);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.setFont(f);
}
}
}
|
public void setForeground(Color c) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setForeground(c);
} else {
Component cp = getCurrentComponent();
if (cp != null) {
cp.setForeground(c);
}
}
}
|
public void setLocation(Point p) {
}
|
public void setSize(Dimension d) {
AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
((AccessibleComponent) ac).setSize(d);
} else {
Component c = getCurrentComponent();
if (c != null) {
c.setSize(d);
}
}
}
|
public void setVisible(boolean b) {
}
|