did.xml
Class DIDDefaultTreeModel

java.lang.Object
  |
  +--javax.swing.tree.DefaultTreeModel
        |
        +--did.xml.DIDDefaultTreeModel

public class DIDDefaultTreeModel
extends javax.swing.tree.DefaultTreeModel

File:         DIDDefaultTreeModel.java
Version:      1.0
Description:  Implementation of the Java DefaultTreeModel.  A DefaultTreeModel handles 
data stored in a series of nodes organized in a tree structure.  An XML document can be 
parsed into a DOM tree which is also a series of nodes organized into a tree structure 
but Java can not use the DOM tree directly.  So, to accomodate this shortcoming a Java
based node structure (DIDNodes) is create based off of the DOM Tree.  The Java tree 
references the corresponding node in the DOM Tree by setting the DOM node as its 
userObject.  This way the Java Tree is always aware of what part of the DOM tree it 
represents.
NOTE: This class also contains several attributes that also make reference to the 
Document node of independed DOM trees.  Their purpose is aid in the creation of new data
files (Pages) as well as aid in the creation of specific portions or the data file 
architecture (Zone, Line, Charater, Vertex).
This architecture is a stopgap messure until an adeqaute and efficient means of generating
well formed, valid XML directly from the DTD can be established.

Modification Log:
Date          Name    Comment
xx-xx-xxxx    XXX	   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

See Also:
DIDNode, Serialized Form

Field Summary
static DIDEntityType EntityType
          Attribute that specify the entity types
static java.util.Vector myROIs
          Vector whose purpose is to hold and track all the DIDRoiIFC object implementations currently on the screen.
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
DIDDefaultTreeModel(javax.swing.tree.TreeNode root)
          Method used to instantiate this class.
DIDDefaultTreeModel(javax.swing.tree.TreeNode root, java.lang.String nodeMessage)
          Method used to instantiate this class.
 
Method Summary
 DIDNode addROI(int n, DIDNode anchorNode, java.lang.String dataType)
          Method used to add the data behind an ROI (whether it be a Zone, Line, or Character) to both the Java and DOM Trees.
 void buildDIDModel(java.lang.String fileName)
          Method used to build the tree of nodes this model manages.
 void buildLogicalLinks(DIDNode anchorNode)
          Method used to build logical links.
 void buildROI(DIDNode anchorNode, java.lang.String roiType)
          Method used to build ROI objects from the XML.
 java.util.Enumeration findChildren(DIDNode anchorNode, java.lang.String nodeName)
          Method used to locate a specific set of children by the name.
 java.util.Enumeration findNodes(DIDNode anchorNode, java.lang.String nodeName)
          Method used to locate a specific set of nodes by the name their userObjects (DOM Nodes).
 java.util.Enumeration findNodesByID(DIDNode anchorNode, java.lang.String idName)
          Method used to locate a specific set of nodes by the ID.
 java.util.Enumeration findNodesHaving(DIDNode anchorNode, java.lang.String suffix)
          Method used to find a specific set of nodes the suffix of whose name equals to the suffix parameter.
 java.lang.String getAttribute(DIDNode anchorNode, java.lang.String attrName)
          Method used to find the value of entity attribute.
 DIDNode getChild(DIDNode anchorNode, java.lang.String nodeName)
          Method used to get the first children of a specific node whose name is same as the nodeName parameter.
 DIDNode getNodeByID(DIDNode anchorNode, java.lang.String idName)
          Method used to get the first node whose ID is same as the idName parameter.
 java.util.Vector getROIs()
          Method used to return all the ROIs built from the open docuement (XML file loaded into the myDocument attibute).
 void loadStub(java.lang.String dataType)
          Method used to create a document stub from an XML file.
 void printTree(DIDNode startNode)
          Convenience method used to print out the structure of the nodes rooted at the startNode.
 void saveModel(java.lang.String fileName)
          Method used to persist the DOM tree structure rooted at myDocument to a physical storage device.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Method used to respond to the editing of a node in the tree.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getPathToRoot, getPathToRoot, getRoot, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EntityType

public static DIDEntityType EntityType
Attribute that specify the entity types

myROIs

public static java.util.Vector myROIs
Vector whose purpose is to hold and track all the DIDRoiIFC object implementations currently on the screen.
Constructor Detail

DIDDefaultTreeModel

public DIDDefaultTreeModel(javax.swing.tree.TreeNode root)
Method used to instantiate this class.
Parameters:
root - The root node for this models node tree.

DIDDefaultTreeModel

public DIDDefaultTreeModel(javax.swing.tree.TreeNode root,
                           java.lang.String nodeMessage)
Method used to instantiate this class. This constructor creates a node based on the DIDNode structure (DOM node as userObject) and sets it as the root node for this model. Basically this is used to initialize the model.
Parameters:
root - The root node for this models node tree.
nodeMessage - The name of the node created by this method.
Method Detail

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Method used to respond to the editing of a node in the tree. When editing of a node is completed the DIDTreeCellEditor calls this method passing in the path to the node edited and the new value for the node. This implementation takes that value and assigns it to the DOM node the node at the end of the path is mirroring.
Overrides:
valueForPathChanged in class javax.swing.tree.DefaultTreeModel
Parameters:
path - TreePath to the node being edited.
newValue - new value for the node being edited.

buildDIDModel

public void buildDIDModel(java.lang.String fileName)
Method used to build the tree of nodes this model manages.
Parameters:
fileName - Fully qualified path to the XML file this model should mirror.

saveModel

public void saveModel(java.lang.String fileName)
Method used to persist the DOM tree structure rooted at myDocument to a physical storage device.
Parameters:
fileName - Fully qualified path to the file that the DOM tree is to be saved.

printTree

public void printTree(DIDNode startNode)
Convenience method used to print out the structure of the nodes rooted at the startNode.
Parameters:
startNode - Node from which to begin recursively walking down.

getROIs

public java.util.Vector getROIs()
Method used to return all the ROIs built from the open docuement (XML file loaded into the myDocument attibute).
Returns:
A vector containing all ROIs.

buildROI

public void buildROI(DIDNode anchorNode,
                     java.lang.String roiType)
Method used to build ROI objects from the XML. This method walks down the node tree starting at the anchorNode and finds any node whose name begins with "Vertex" and whose parent node's name begins with roiType and ends with "Corners". This node's children contains vertex information that is placed in a Vector based on whether it is an x or y coordinate. These Vectors are then used to construct a new ROI.
Parameters:
anchorNode - A DIDNode representing the starting point from which Verticies (a set of x, y corrdinates) can be extracted.
roiType - A String denoting the type of data (Zone, Line, Character)

buildLogicalLinks

public void buildLogicalLinks(DIDNode anchorNode)
Method used to build logical links. This method walks down the node tree starting at the anchorNode and if any node have a child node name ends with "Next", make a link between the node and the next node whose ID is the value of "Next" node.
Parameters:
anchorNode - is a starting point.

findNodes

public java.util.Enumeration findNodes(DIDNode anchorNode,
                                       java.lang.String nodeName)
Method used to locate a specific set of nodes by the name their userObjects (DOM Nodes).
Parameters:
nodeName - A String that is the name of the node this method should find.
Returns:
An Enumeration of DIDNodes whose userObject's names matche the nodeName parameter.

findNodesHaving

public java.util.Enumeration findNodesHaving(DIDNode anchorNode,
                                             java.lang.String suffix)
Method used to find a specific set of nodes the suffix of whose name equals to the suffix parameter.
Parameters:
suffix - A String that is the suffix of the node name this method should find.
Returns:
An Enumeration of DIDNodes whose userObject's name ends with the suffix parameter.

getNodeByID

public DIDNode getNodeByID(DIDNode anchorNode,
                           java.lang.String idName)
Method used to get the first node whose ID is same as the idName parameter.
Parameters:
idName - A String that is the ID of the node this method should find.
Returns:
The DIDNodes whose userObject's ID matches the idName parameter.

findNodesByID

public java.util.Enumeration findNodesByID(DIDNode anchorNode,
                                           java.lang.String idName)
Method used to locate a specific set of nodes by the ID.
Parameters:
idName - A String that is the ID of the node this method should find.
Returns:
An Enumeration of DIDNodes whose userObject's IDs match the idName parameter.

getChild

public DIDNode getChild(DIDNode anchorNode,
                        java.lang.String nodeName)
Method used to get the first children of a specific node whose name is same as the nodeName parameter.
Parameters:
nodeName - A String that is the name of the node this method should find.
Returns:
the first DIDNode whose name matches the nodeName parameter.

findChildren

public java.util.Enumeration findChildren(DIDNode anchorNode,
                                          java.lang.String nodeName)
Method used to locate a specific set of children by the name.
Parameters:
nodeName - A String that is the name of the node this method should find.
Returns:
An Enumeration of DIDNodes whose userObject's names matche the nodeName parameter.

getAttribute

public java.lang.String getAttribute(DIDNode anchorNode,
                                     java.lang.String attrName)
Method used to find the value of entity attribute.
Parameters:
attrName - is a String that is the name of attribute to find.
Returns:
a String which is the value of the attribute. return null, if there is no such an attribute.

loadStub

public void loadStub(java.lang.String dataType)
Method used to create a document stub from an XML file. The stubs serve as well formed canned peices of XML specific to this application. These stubs can then be processed and placed into the Java and DOM trees whenever necessary.
Parameters:
dataType - The type of data stub to load (Page, Zone, Line, Character).

addROI

public DIDNode addROI(int n,
                      DIDNode anchorNode,
                      java.lang.String dataType)
Method used to add the data behind an ROI (whether it be a Zone, Line, or Character) to both the Java and DOM Trees.
Parameters:
n - An Integer representing the number of Verticies this ROI contains.
anchorNode - The parent node of the ROI being added. If null the Page assumed.
dataType - A String representing the type of data the ROI represents (Zone, Line, etc.)
Returns:
A DIDNode that is the root of the portion of the overall data tree that the ROI being added should set as its anchorNode.
See Also:
#processDomNode