|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgps.core.GPSNode
gps.core.HierarchyNode
public class HierarchyNode
A HierarchyNode
is a general-purpose node in a tree data
structure.
A tree node may have at most one parent and 0 or more children.
HierarchyNode
provides operations for examining and modifying a
node's parent and children and also operations for examining the tree that
the node is a part of. A node's tree is the set of all nodes that can be
reached by starting at the node and following all the possible links to
parents and children. A node with no parent is the root of its tree; a
node with no children is a leaf. A tree may consist of many subtrees,
each node acting as the root for its own subtree.
This class provides enumerations for efficiently traversing a tree or
subtree in various orders or for following the path between two nodes.
A HierarchyNode
may also hold a reference to a user object, the
use of which is left to the user. Asking a HierarchyNode
for its
string representation with toString()
returns the string
representation of its user object.
This is not a thread safe class.If you intend to use a HierarchyNode (or a tree of TreeNodes) in more than one thread, you need to do your own synchronizing. A good convention to adopt is synchronizing on the root node of a tree.
While HierarchyNode implements the HierarchyNode interface and will allow you to add in any implementation of HierarchyNode not all of the methods in HierarchyNode will be applicable to all MutableTreeNodes implementations. Especially with some of the enumerations that are provided, using some of these methods assumes the HierarchyNode contains only DefaultMutableNode instances. All of the HierarchyNode/HierarchyNode methods will behave as defined no matter what implementations are added.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Field Summary | |
---|---|
static int |
NODE_COLLAPSE
|
static int |
NODE_EXPAND
|
static int |
NODE_NORMAL
variable which represent what kind of view mode a node can have |
static int |
RELATION_CHILD
|
static int |
RELATION_PARENT
variables which represent what kind of relation a node can have values are given based on Model Architect |
Constructor Summary | |
---|---|
HierarchyNode()
Creates a tree node that has no parent and no children, but which allows children. |
|
HierarchyNode(java.lang.Object userObject)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object. |
|
HierarchyNode(java.lang.Object userObject,
boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified. |
|
HierarchyNode(java.lang.String name)
|
Method Summary | |
---|---|
void |
addAlternate(HierarchyNode newAlternate)
|
void |
addAlternateAt(HierarchyNode newAlternate,
int index)
method added by lavanya kumar chinta on 01202002 adds alternate at specified position |
void |
addChild(HierarchyNode newChild)
Removes newChild from its parent and makes it a child of
this node by adding it to the end of this node's child array. |
void |
addChildAt(HierarchyNode newChild,
int index)
method added by lavanya kumar chinta on 01202002 adds child at specified position |
void |
addToParentNodesVector(HierarchyNode parentNode)
|
java.lang.Object |
clone()
|
boolean |
getAllowsChildren()
Returns true if this node is allowed to have children. |
HierarchyNode |
getAlternateAt(int index)
|
int |
getAlternateIndex(HierarchyNode alternateNode)
|
java.util.Enumeration |
getAlternates()
|
int |
getAlternatesCount()
|
java.util.Vector |
getAlternateVector()
gets alternate vector |
boolean |
getAvailableInPath()
gets available in path flag for this node |
HierarchyNode |
getChildAt(int index)
Returns the child at the specified index in this node's child array. |
int |
getChildCount()
Returns the number of children of this node. |
int |
getChildIndex(HierarchyNode aChild)
Returns the index of the specified child in this node's child array. |
java.util.Enumeration |
getChildrens()
Creates and returns a forward-order enumeration of this node's children. |
java.util.Vector |
getChildVector()
gets child nodes |
int |
getCreatedBy()
gets who created the node |
boolean |
getLegIncrementedFlag()
|
int |
getLegIndex()
|
int |
getLevelIndex()
|
int |
getMode()
|
int |
getNodeNumber()
|
GPSNode |
getParent()
Returns this node's parent or null if this node has no parent. |
java.util.Vector |
getParentNodesVector()
|
int |
getPathKey()
Returns path key |
int |
getPosition()
code added by lavanya on 02182002 gets position in the list of nodes to its parent/primary/child |
GPSNode |
getPrimaryNode()
written by lavanya gets the primary node reference, if the node is alternate node |
boolean |
getRelationalORType()
gets relational OR type flag, whether the node having OR Type relation with it's sibblings or not |
java.lang.String |
getRelationName()
|
int |
getRelationTypeID()
|
HierarchyNode |
getSecondaryParentAt(int index)
method added by lavanya on 01242002 |
int |
getSecondaryParentCount()
method added by lavanya on 01242002 gets secondary parent nodes count |
boolean |
getSecondaryParentFlag()
|
void |
insertAlternate(HierarchyNode newAlternate,
int alternateIndex)
|
void |
insertChild(HierarchyNode newChild,
int childIndex)
method modified by lavanya on 03142002 Removes newChild from its present parent (if it has a
parent), sets the child's parent to this node, and then adds the child
to this node's child array at index childIndex . |
boolean |
isAlternate()
|
void |
remove(HierarchyNode aChild)
Removes aChild from this node's child array, giving it a
null parent. |
void |
removeAllAlternates()
|
void |
removeAllChildren()
Removes all of this node's children, setting their parents to null. |
void |
removeAlternate(int alternateIndex)
|
void |
removeChild(int childIndex)
Removes the child at the specified index from this node's children and sets that node's parent to null. |
void |
removeFromParent()
Removes the subtree rooted at this node from the tree, giving this node a null parent. |
void |
setAllowsChildren(boolean allows)
Determines whether or not this node is allowed to have children. |
void |
setAlternateFlag(boolean alternateFlag)
|
void |
setAlternates(java.util.Vector alternates)
|
void |
setAvailableInPath(boolean availableInPath)
sets available in path flag for this node |
void |
setChildrens(java.util.Vector children)
|
void |
setCreatedBy(int createdBy)
sets who created the node |
void |
setLegIncrementedFlag(boolean legIncrementedFlag)
|
void |
setLegIndex(int index)
|
void |
setLevelIndex(int index)
|
void |
setMode(int mode)
|
void |
setNodeNumber(int nodeNumber)
|
void |
setParent(HierarchyNode newParent)
Sets this node's parent to newParent but does not
change the parent's child array. |
void |
setParentNodesVector(java.util.Vector parentNodesVector)
|
void |
setPathKey(int pathKey)
Sets path key |
void |
setPosition(int position)
code added by lavanya on 02182002 sets position in the list of nodes to its parent/primary/child |
void |
setPrimaryNode(GPSNode primaryNode)
written by lavanya sets the primary node reference, if the node is alternate node |
void |
setRelationalORType(boolean relationalORType)
sets relational OR type flag, whether the node having OR Type relation with it's sibblings or not |
void |
setRelationName(java.lang.String relationName)
|
void |
setRelationTypeID(int relationTypeID)
|
void |
setSecondaryParentAt(HierarchyNode secondaryParentNode,
int position)
method added by lavanya on 02182002 sets secondary parent node at the specified position |
void |
setSecondaryParentFlag(boolean secondaryParentFlag)
|
java.lang.String |
toString()
toString method |
Methods inherited from class gps.core.GPSNode |
---|
getACDFlag, getCustomPanelFile, getCustomPanelObject, getDataFlag, getDrillDownFlag, getExplosionStopFlag, getImageName, getKey, getModel, getName, getNodeID, getNodeType, getNodeTypeID, getNotes, getOrigin, getType, getUserObject, setACDFlag, setCustomPanelFile, setCustomPanelObject, setDataFlag, setExplosionStopFlag, setImageFile, setImageName, setKey, setModel, setName, setNodeID, setNodeType, setNodeTypeID, setNotes, setOrigin, setOrigin, setType, setUserObject |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int RELATION_PARENT
public static int RELATION_CHILD
public static int NODE_NORMAL
public static int NODE_COLLAPSE
public static int NODE_EXPAND
Constructor Detail |
---|
public HierarchyNode()
public HierarchyNode(java.lang.String name)
public HierarchyNode(java.lang.Object userObject)
userObject
- an Object provided by the user that constitutes
the node's datapublic HierarchyNode(java.lang.Object userObject, boolean allowsChildren)
userObject
- an Object provided by the user that constitutes
the node's dataallowsChildren
- if true, the node is allowed to have child
nodes -- otherwise, it is always a leaf nodeMethod Detail |
---|
public void insertChild(HierarchyNode newChild, int childIndex)
newChild
from its present parent (if it has a
parent), sets the child's parent to this node, and then adds the child
to this node's child array at index childIndex
.
newChild
must not be null and must not be an ancestor of
this node.
newChild
- the HierarchyNode to insert under this nodechildIndex
- the index in this node's child array
where this node is to be inserted
java.lang.ArrayIndexOutOfBoundsException
- if
childIndex
is out of bounds
java.lang.IllegalArgumentException
- if
newChild
is null or is an
ancestor of this node
java.lang.IllegalStateException
- if this node does not allow
childrenpublic void insertAlternate(HierarchyNode newAlternate, int alternateIndex)
public void removeChild(int childIndex)
HierarchyNode
.
childIndex
- the index in this node's child array
of the child to remove
java.lang.ArrayIndexOutOfBoundsException
- if
childIndex
is out of boundspublic void removeAlternate(int alternateIndex)
public void removeAllAlternates()
public void setParent(HierarchyNode newParent)
newParent
but does not
change the parent's child array. This method is called from
insert()
and remove()
to
reassign a child's parent, it should not be messaged from anywhere
else.
newParent
- this node's new parentpublic GPSNode getParent()
getParent
in class GPSNode
public void setParentNodesVector(java.util.Vector parentNodesVector)
public java.util.Vector getParentNodesVector()
getParentNodesVector
in class GPSNode
public void addToParentNodesVector(HierarchyNode parentNode)
public int getSecondaryParentCount()
public HierarchyNode getSecondaryParentAt(int index)
int
- index
public void setSecondaryParentAt(HierarchyNode secondaryParentNode, int position)
HierarchyNode
- secondary parent nodeint
- positionpublic void setRelationTypeID(int relationTypeID)
public int getRelationTypeID()
public HierarchyNode getChildAt(int index)
index
- an index into this node's child array
java.lang.ArrayIndexOutOfBoundsException
- if index
is out of boundspublic HierarchyNode getAlternateAt(int index)
public int getChildCount()
public int getAlternatesCount()
public int getChildIndex(HierarchyNode aChild)
-1
. This method performs a linear search and is O(n)
where n is the number of children.
aChild
- the HierarchyNode to search for among this node's children
-1
if the specified node is a not
a child of this node
java.lang.IllegalArgumentException
- if aChild
is nullpublic int getAlternateIndex(HierarchyNode alternateNode)
public java.util.Enumeration getChildrens()
getChildrens
in class GPSNode
public void setChildrens(java.util.Vector children)
public java.util.Enumeration getAlternates()
getAlternates
in class GPSNode
public void setAlternates(java.util.Vector alternates)
public void setAllowsChildren(boolean allows)
allows
is false, all of this node's children are
removed.
Note: By default, a node allows children.
allows
- true if this node is allowed to have childrenpublic boolean getAllowsChildren()
public void removeFromParent()
public void remove(HierarchyNode aChild)
aChild
from this node's child array, giving it a
null parent.
aChild
- a child of this node to remove
java.lang.IllegalArgumentException
- if aChild
is null or is not a child of this nodepublic void removeAllChildren()
public void addChild(HierarchyNode newChild)
newChild
from its parent and makes it a child of
this node by adding it to the end of this node's child array.
newChild
- node to add as a child of this node
java.lang.IllegalArgumentException
- if newChild
is null
java.lang.IllegalStateException
- if this node does not allow
childrenpublic void addAlternate(HierarchyNode newAlternate)
public void addAlternateAt(HierarchyNode newAlternate, int index)
HierarchyNode
- new alternateint
- indexpublic void addChildAt(HierarchyNode newChild, int index)
HierarchyNode
- new childint
- indexpublic java.util.Vector getChildVector()
public java.util.Vector getAlternateVector()
public void setRelationName(java.lang.String relationName)
public java.lang.String getRelationName()
getRelationName
in class GPSNode
public void setMode(int mode)
public int getMode()
public void setLegIncrementedFlag(boolean legIncrementedFlag)
public boolean getLegIncrementedFlag()
public void setLegIndex(int index)
public int getLegIndex()
public void setLevelIndex(int index)
public int getLevelIndex()
public void setNodeNumber(int nodeNumber)
public int getNodeNumber()
public java.lang.String toString()
GPSNode
toString
in class GPSNode
public java.lang.Object clone()
clone
in class GPSNode
public void setAlternateFlag(boolean alternateFlag)
public boolean isAlternate()
isAlternate
in class GPSNode
public void setPrimaryNode(GPSNode primaryNode)
setPrimaryNode
in class GPSNode
HierarchyNode
- primary nodepublic GPSNode getPrimaryNode()
getPrimaryNode
in class GPSNode
public void setSecondaryParentFlag(boolean secondaryParentFlag)
public boolean getSecondaryParentFlag()
getSecondaryParentFlag
in class GPSNode
public void setPosition(int position)
int
- positionpublic int getPosition()
public void setCreatedBy(int createdBy)
setCreatedBy
in class GPSNode
int
- created by constantpublic int getCreatedBy()
getCreatedBy
in class GPSNode
public void setPathKey(int pathKey)
int
- keypublic int getPathKey()
public void setAvailableInPath(boolean availableInPath)
boolean
- availableInPathpublic boolean getAvailableInPath()
public void setRelationalORType(boolean relationalORType)
boolean
- relationalORTypepublic boolean getRelationalORType()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |