usb.view
Class USBNode

java.lang.Object
  |
  +--usb.view.USBNode
All Implemented Interfaces:
javax.swing.tree.TreeNode
Direct Known Subclasses:
HubNode, KodakNode, RioNode

public class USBNode
extends java.lang.Object
implements javax.swing.tree.TreeNode

Models entities, in particular devices, that are displayed using this package's USB tree viewer.

Subclassers will commonly provide support specific to a class or device device information. If the device wants to present children (such as hub ports, files of images or audio data, or something else) then the three relevant methods should be overridden: getAllowsChildren(), getChildAt(int) and getChildCount(). By default, nodes provide textual descriptions using HTML, and subclasses can add more information by overriding showClassInfo(java.lang.StringBuffer). If a non-HTML display is needed, override draw(javax.swing.JEditorPane).


Field Summary
protected  Device dev
          The device node which is associated with this node, or null.
protected  javax.swing.tree.TreeNode parent
          Swing's tree model requires nodes to know their parents.
 
Constructor Summary
USBNode(Device device, javax.swing.tree.TreeNode nodeParent)
          Constructs a tree node model.
 
Method Summary
 java.util.Enumeration children()
          Not implemented.
 void draw(javax.swing.JEditorPane editor)
          Renders this node in an auxiliary pane.
 boolean getAllowsChildren()
          Reports that children are not allowed.
 javax.swing.tree.TreeNode getChildAt(int n)
          Returns null.
 int getChildCount()
          Returns zero.
 int getIndex(javax.swing.tree.TreeNode n)
          Not implemented.
 javax.swing.tree.TreeNode getParent()
          Returns the parent provided to the constructcor.
 boolean isLeaf()
          Returns true for nodes that don't allow children.
protected  void showClassInfo(java.lang.StringBuffer buf)
          This method is a hook to provide class-specific data (in HTML) when this node is selected.
 java.lang.String toString()
          Returns the label to be used displaying this tree node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dev

protected final Device dev
The device node which is associated with this node, or null.


parent

protected final javax.swing.tree.TreeNode parent
Swing's tree model requires nodes to know their parents.

Constructor Detail

USBNode

public USBNode(Device device,
               javax.swing.tree.TreeNode nodeParent)
        throws java.io.IOException
Constructs a tree node model.

Method Detail

getAllowsChildren

public boolean getAllowsChildren()
Reports that children are not allowed.

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int n)
Returns null.

Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Returns zero.

Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode n)
Not implemented.

Specified by:
getIndex in interface javax.swing.tree.TreeNode

children

public java.util.Enumeration children()
Not implemented.

Specified by:
children in interface javax.swing.tree.TreeNode

getParent

public final javax.swing.tree.TreeNode getParent()
Returns the parent provided to the constructcor.

Specified by:
getParent in interface javax.swing.tree.TreeNode

isLeaf

public final boolean isLeaf()
Returns true for nodes that don't allow children.

Specified by:
isLeaf in interface javax.swing.tree.TreeNode

toString

public java.lang.String toString()
Returns the label to be used displaying this tree node. This uses the device's product string if one exists, else the name of the device class. If no device is available, the default java.lang.Object method is used.

Overrides:
toString in class java.lang.Object

draw

public void draw(javax.swing.JEditorPane editor)
Renders this node in an auxiliary pane. The base class uses a simple HTML rendering of any available device information, both standard and (through showClassInfo(java.lang.StringBuffer)) class-specific. Subclasses may choose to use a non-HTML display, or a different sort of HTML display, by overriding this method.


showClassInfo

protected void showClassInfo(java.lang.StringBuffer buf)
This method is a hook to provide class-specific data (in HTML) when this node is selected. Subclasses using the default HTML display should append markup to the string buffer, ending in an empty line (use <br>;<br>). Note that this can be used both to provide standardized USB class data (e.g. for hubs and printers) as well as "class-per-interface" style data, for devices with less standard behaviours.