public class GraphTreeNode
extends java.lang.Object
implements java.lang.Cloneable, javax.swing.tree.MutableTreeNode
Title: 结构化数据的图形树
Description: 结构化数据的图形树
Swing包的JTree加强版
限定符和类型 | 字段和说明 |
---|---|
boolean |
allowMapping
是否允许输出热点映射 (默认允许)
|
java.lang.String |
anchor
超级链接锚点
|
static java.lang.String |
CTLR
当前平台的回车换行符
|
static java.util.Enumeration |
EMPTY_ENUMERATION
An enumeration that is always empty.
|
int |
height
坐标以及尺寸
|
int |
isoH
记忆等容尺寸
|
int |
isoW
记忆等容尺寸
|
int |
level
层信息
|
java.lang.String |
target
超级链接锚点连接目标
|
java.lang.String |
toolTips
热点提示信息
|
int |
treeHeight
记忆领导子树的展开宽 (横向演化则treeHeight有效,纵向演化则treeWidth有效)
|
int |
treeWidth
记忆领导子树的展开宽 (横向演化则treeHeight有效,纵向演化则treeWidth有效)
|
int |
width
坐标以及尺寸
|
int |
x
坐标以及尺寸
|
int |
y
坐标以及尺寸
|
构造器和说明 |
---|
GraphTreeNode()
Creates a tree node that has no parent and no children, but which
allows children.
|
GraphTreeNode(NodeTemplet nodeTemplet)
Creates a tree node with no parent, no children, but which allows
children, and initializes it with the specified user object.
|
GraphTreeNode(NodeTemplet nodeTemplet,
boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with
the specified user object, and that allows children only if
specified.
|
限定符和类型 | 方法和说明 |
---|---|
void |
_enum()
枚举测试
|
void |
_print() |
void |
_print(java.lang.String demo) |
void |
add(javax.swing.tree.MutableTreeNode 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. |
java.util.Enumeration |
breadthFirstEnumeration()
Creates and returns an enumeration that traverses the subtree rooted at
this node in breadth-first order.
|
java.util.Enumeration |
children()
Creates and returns a forward-order enumeration of this node's
children.
|
java.lang.Object |
clone()
Overridden to make clone public.
|
java.util.Enumeration |
depthFirstEnumeration()
Creates and returns an enumeration that traverses the subtree rooted at
this node in depth-first order.
|
boolean |
getAllowMapping() |
boolean |
getAllowsChildren()
Returns true if this node is allowed to have children.
|
java.lang.String |
getAnchor()
返回锚点
|
java.awt.Rectangle |
getBound() |
int |
getCenX()
中心点
|
int |
getCenY() |
javax.swing.tree.TreeNode |
getChildAfter(javax.swing.tree.TreeNode aChild) |
javax.swing.tree.TreeNode |
getChildAt(int index)
Returns the child at the specified index in this node's child array.
|
javax.swing.tree.TreeNode |
getChildBefore(javax.swing.tree.TreeNode aChild)
Returns the child in this node's child array that immediately
precedes
aChild , which must be a child of this node. |
int |
getChildCount()
Returns the number of children of this node.
|
java.lang.String |
getCoords() |
int |
getDepth()
Returns the depth of the tree rooted at this node -- the longest
distance from this node to a leaf.
|
javax.swing.tree.TreeNode |
getFirstChild()
Returns this node's first child.
|
GraphTreeNode |
getFirstLeaf()
Finds and returns the first leaf that is a descendant of this node --
either this node or its first child's first leaf.
|
int |
getHeight() |
int |
getIndex(javax.swing.tree.TreeNode aChild)
Returns the index of the specified child in this node's child array.
|
javax.swing.tree.TreeNode |
getLastChild()
Returns this node's last child.
|
GraphTreeNode |
getLastLeaf()
Finds and returns the last leaf that is a descendant of this node --
either this node or its last child's last leaf.
|
java.awt.Dimension |
getLeadingTreeSize() |
int |
getLeafCount()
Returns the total number of leaves that are descendants of this node.
|
int |
getLevel()
Returns the number of levels above this node -- the distance from
the root to this node.
|
int |
getNegX()
负焦点
|
int |
getNegY() |
GraphTreeNode |
getNextLeaf()
Returns the leaf after this node or null if this node is the
last leaf in the tree.
|
GraphTreeNode |
getNextNode()
Returns the node that follows this node in a preorder traversal of this
node's tree.
|
GraphTreeNode |
getNextSibling()
Returns the next sibling of this node in the parent's children array.
|
NodeTemplet |
getNodeTemplet()
返回节点模板.
|
javax.swing.tree.TreeNode |
getParent()
Returns this node's parent or null if this node has no parent.
|
javax.swing.tree.TreeNode[] |
getPath()
Returns the path from the root, to get to this node.
|
int |
getPathIsoHeight(int space) |
int |
getPathIsoWidth(int space) |
java.awt.Point |
getPoint() |
java.awt.Point |
getPoint2() |
java.awt.Point |
getPointEast() |
java.awt.Point |
getPointNorth()
吸附点坐标提供给连接线使用
|
java.awt.Point |
getPointSouth() |
java.awt.Point |
getPointWest() |
GraphTreeNode |
getPreviousLeaf()
Returns the leaf before this node or null if this node is the
first leaf in the tree.
|
GraphTreeNode |
getPreviousNode()
Returns the node that precedes this node in a preorder traversal of
this node's tree.
|
GraphTreeNode |
getPreviousSibling()
Returns the previous sibling of this node in the parent's children
array.
|
javax.swing.tree.TreeNode |
getRoot()
Returns the root of the tree that contains this node.
|
javax.swing.tree.TreeNode |
getSharedAncestor(GraphTreeNode aNode)
Returns the nearest common ancestor to this node and
aNode . |
int |
getSiblingCount()
Returns the number of siblings of this node.
|
java.awt.Dimension |
getSize() |
java.lang.String |
getTarget()
返回锚点
|
java.lang.String |
getToolTips()
返回提示信息
|
int |
getTotalDepth()
获取总的树深
|
java.lang.Object |
getUserObject()
Returns this node's user object.
|
java.lang.Object[] |
getUserObjectPath()
Returns the user object path, from the root, to get to this node.
|
int |
getWidth() |
int |
getX() |
int |
getY() |
void |
initGraphics()
初始化图形节点
|
void |
insert(javax.swing.tree.MutableTreeNode newChild,
int childIndex)
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 |
isAllowMapping()
判断是否生成该结点的热点信息
|
boolean |
isLeaf()
Returns true if this node has no children.
|
boolean |
isNodeAncestor(javax.swing.tree.TreeNode anotherNode)
Returns true if
anotherNode is an ancestor of this node
-- if it is this node, this node's parent, or an ancestor of this
node's parent. |
boolean |
isNodeChild(javax.swing.tree.TreeNode aNode)
Returns true if
aNode is a child of this node. |
boolean |
isNodeDescendant(GraphTreeNode anotherNode)
Returns true if
anotherNode is a descendant of this node
-- if it is this node, one of this node's children, or a descendant of
one of this node's children. |
boolean |
isNodeRelated(GraphTreeNode aNode)
Returns true if and only if
aNode is in the same tree
as this node. |
boolean |
isNodeSibling(javax.swing.tree.TreeNode anotherNode)
Returns true if
anotherNode is a sibling of (has the
same parent as) this node. |
boolean |
isRoot()
Returns true if this node is the root of the tree.
|
void |
moveWithChildren(int dx,
int dy)
移动当前节点 同时移动子树
|
void |
moveWithoutChildren(int dx,
int dy)
移动当前节点 不移动子树
|
java.util.Enumeration |
pathFromAncestorEnumeration(javax.swing.tree.TreeNode ancestor) |
java.util.Enumeration |
postorderEnumeration()
Creates and returns an enumeration that traverses the subtree rooted at
this node in postorder.
|
java.util.Enumeration |
preorderEnumeration()
Creates and returns an enumeration that traverses the subtree rooted at
this node in preorder.
|
void |
rememberLevel()
让节点实体记忆自己的层信息 (这个函数主要为复杂布局运算提高性能而设计)
|
void |
remove(int childIndex)
Removes the child at the specified index from this node's children
and sets that node's parent to null.
|
void |
remove(javax.swing.tree.MutableTreeNode aChild)
Removes
aChild from this node's child array, giving it a
null parent. |
void |
removeAllChildren()
Removes all of this node's children, setting their parents to null.
|
void |
removeFromParent()
Removes the subtree rooted at this node from the tree, giving this
node a null parent.
|
void |
setAllowMapping(boolean allow)
设置是否生成该结点的热点信息,对应于MAP文件的AREA部分
|
void |
setAllowsChildren(boolean allows)
Determines whether or not this node is allowed to have children.
|
void |
setAnchor(java.lang.String url)
重新设置锚点
|
void |
setBound(int x,
int y,
int w,
int h) |
void |
setHeight(int h) |
void |
setLeadingTreeSize(int tw,
int th) |
void |
setNodeTemplet(NodeTemplet templet)
设置节点模板到
nodeTemplet . |
void |
setParent(javax.swing.tree.MutableTreeNode newParent)
Sets this node's parent to
newParent but does not
change the parent's child array. |
void |
setPoint(int x,
int y) |
void |
setSize(int w,
int h) |
void |
setTarget(java.lang.String aim)
重新设置锚点
|
void |
setToolTips(java.lang.String s)
提示信息重设
|
void |
setUserObject(java.lang.Object nodeTemplet)
Sets the user object for this node to
nodeTemplet . |
void |
setWidth(int w) |
void |
setX(int x) |
void |
setY(int y) |
java.lang.String |
toMap()
热点映射
|
java.lang.String |
toString()
Returns the result of sending
toString() to this node's
user object, or null if this node has no user object. |
public static final java.util.Enumeration EMPTY_ENUMERATION
public int x
public int y
public int width
public int height
public int level
public int isoW
public int isoH
public int treeWidth
public int treeHeight
public static final java.lang.String CTLR
public java.lang.String toolTips
public java.lang.String anchor
public java.lang.String target
public boolean allowMapping
public GraphTreeNode()
public GraphTreeNode(NodeTemplet nodeTemplet)
nodeTemplet
- an Object provided by the user that constitutes
the node's datapublic GraphTreeNode(NodeTemplet nodeTemplet, boolean allowsChildren)
nodeTemplet
- 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 nodepublic void setX(int x)
public void setY(int y)
public void setWidth(int w)
public void setHeight(int h)
public void setPoint(int x, int y)
public void setSize(int w, int h)
public void setBound(int x, int y, int w, int h)
public int getX()
public int getY()
public int getWidth()
public int getHeight()
public java.awt.Point getPoint()
public java.awt.Dimension getSize()
public java.awt.Rectangle getBound()
public int getNegX()
public int getNegY()
public java.awt.Point getPoint2()
public int getCenX()
public int getCenY()
public java.awt.Point getPointNorth()
public java.awt.Point getPointSouth()
public java.awt.Point getPointWest()
public java.awt.Point getPointEast()
public void initGraphics()
public void rememberLevel()
public int getPathIsoWidth(int space)
public int getPathIsoHeight(int space)
public void setLeadingTreeSize(int tw, int th)
public java.awt.Dimension getLeadingTreeSize()
public void moveWithChildren(int dx, int dy)
dx
- X轴平移dy
- Y轴平移public void moveWithoutChildren(int dx, int dy)
dx
- X轴平移dy
- Y轴平移public int getTotalDepth()
public void _print()
public void _print(java.lang.String demo)
public void _enum()
public NodeTemplet getNodeTemplet()
setNodeTemplet(com.sh.javax.tree.NodeTemplet)
,
toString()
public void setNodeTemplet(NodeTemplet templet)
nodeTemplet
.templet
- 包含节点的用户自定义数据的模板getNodeTemplet()
,
toString()
public java.lang.String toMap()
public java.lang.String getCoords()
public void setToolTips(java.lang.String s)
s
- 信息提示字符串public java.lang.String getToolTips()
public void setAnchor(java.lang.String url)
url
- Stringpublic java.lang.String getAnchor()
public void setTarget(java.lang.String aim)
aim
- Stringpublic java.lang.String getTarget()
public void setAllowMapping(boolean allow)
allow
- boolean true生成(默认),false不生成public boolean getAllowMapping()
public boolean isAllowMapping()
public void insert(javax.swing.tree.MutableTreeNode 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.insert
在接口中 javax.swing.tree.MutableTreeNode
newChild
- the MutableTreeNode to insert under this nodechildIndex
- the index in this node's child array
where this node is to be insertedjava.lang.ArrayIndexOutOfBoundsException
- if
childIndex
is out of boundsjava.lang.IllegalArgumentException
- if
newChild
is null or is an
ancestor of this nodejava.lang.IllegalStateException
- if this node does not allow
childrenisNodeDescendant(com.sh.javax.tree.GraphTreeNode)
public void remove(int childIndex)
MutableTreeNode
.remove
在接口中 javax.swing.tree.MutableTreeNode
childIndex
- the index in this node's child array
of the child to removejava.lang.ArrayIndexOutOfBoundsException
- if
childIndex
is out of boundspublic void setParent(javax.swing.tree.MutableTreeNode 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.setParent
在接口中 javax.swing.tree.MutableTreeNode
newParent
- this node's new parentpublic javax.swing.tree.TreeNode getParent()
getParent
在接口中 javax.swing.tree.TreeNode
public javax.swing.tree.TreeNode getChildAt(int index)
getChildAt
在接口中 javax.swing.tree.TreeNode
index
- an index into this node's child arrayjava.lang.ArrayIndexOutOfBoundsException
- if index
is out of boundspublic int getChildCount()
getChildCount
在接口中 javax.swing.tree.TreeNode
public int getIndex(javax.swing.tree.TreeNode aChild)
-1
. This method performs a linear search and is O(n)
where n is the number of children.getIndex
在接口中 javax.swing.tree.TreeNode
aChild
- the TreeNode to search for among this node's children-1
if the specified node is a not
a child of this nodejava.lang.IllegalArgumentException
- if aChild
is nullpublic java.util.Enumeration children()
children
在接口中 javax.swing.tree.TreeNode
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()
getAllowsChildren
在接口中 javax.swing.tree.TreeNode
public void setUserObject(java.lang.Object nodeTemplet)
nodeTemplet
.setUserObject
在接口中 javax.swing.tree.MutableTreeNode
nodeTemplet
- the Object that constitutes this node's
user-specified datagetUserObject()
,
toString()
public java.lang.Object getUserObject()
setUserObject(java.lang.Object)
,
toString()
public void removeFromParent()
removeFromParent
在接口中 javax.swing.tree.MutableTreeNode
public void remove(javax.swing.tree.MutableTreeNode aChild)
aChild
from this node's child array, giving it a
null parent.remove
在接口中 javax.swing.tree.MutableTreeNode
aChild
- a child of this node to removejava.lang.IllegalArgumentException
- if aChild
is null or is not a child of this nodepublic void removeAllChildren()
public void add(javax.swing.tree.MutableTreeNode 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 nodejava.lang.IllegalArgumentException
- if newChild
is nulljava.lang.IllegalStateException
- if this node does not allow
childreninsert(javax.swing.tree.MutableTreeNode, int)
public boolean isNodeAncestor(javax.swing.tree.TreeNode anotherNode)
anotherNode
is an ancestor of this node
-- if it is this node, this node's parent, or an ancestor of this
node's parent. (Note that a node is considered an ancestor of itself.)
If anotherNode
is null, this method returns false. This
operation is at worst O(h) where h is the distance from the root to
this node.anotherNode
- node to test as an ancestor of this nodeanotherNode
isNodeDescendant(com.sh.javax.tree.GraphTreeNode)
,
getSharedAncestor(com.sh.javax.tree.GraphTreeNode)
public boolean isNodeDescendant(GraphTreeNode anotherNode)
anotherNode
is a descendant of this node
-- if it is this node, one of this node's children, or a descendant of
one of this node's children. Note that a node is considered a
descendant of itself. If anotherNode
is null, returns
false. This operation is at worst O(h) where h is the distance from the
root to anotherNode
.anotherNode
- node to test as descendant of this nodeanotherNode
isNodeAncestor(javax.swing.tree.TreeNode)
,
getSharedAncestor(com.sh.javax.tree.GraphTreeNode)
public javax.swing.tree.TreeNode getSharedAncestor(GraphTreeNode aNode)
aNode
.
Returns null, if no such ancestor exists -- if this node and
aNode
are in different trees or if aNode
is
null. A node is considered an ancestor of itself.aNode
- node to find common ancestor withaNode
,
or null if noneisNodeAncestor(javax.swing.tree.TreeNode)
,
isNodeDescendant(com.sh.javax.tree.GraphTreeNode)
public boolean isNodeRelated(GraphTreeNode aNode)
aNode
is in the same tree
as this node. Returns false if aNode
is null.aNode
- GraphTreeNodeaNode
is in the same tree as this node;
false if aNode
is nullgetSharedAncestor(com.sh.javax.tree.GraphTreeNode)
,
getRoot()
public int getDepth()
getLevel()
because it must effectively traverse the entire
tree rooted at this node.getLevel()
public int getLevel()
getDepth()
public javax.swing.tree.TreeNode[] getPath()
public java.lang.Object[] getUserObjectPath()
public javax.swing.tree.TreeNode getRoot()
isNodeAncestor(javax.swing.tree.TreeNode)
public boolean isRoot()
public GraphTreeNode getNextNode()
preorderEnumeration()
public GraphTreeNode getPreviousNode()
null
if this node is the
first node of the traversal -- the root of the tree.
This is an inefficient way to
traverse the entire tree; use an enumeration, instead.preorderEnumeration()
public java.util.Enumeration preorderEnumeration()
nextElement()
method is this node.Modifying the tree by inserting, removing, or moving a node invalidates any enumerations created before the modification.
postorderEnumeration()
public java.util.Enumeration postorderEnumeration()
nextElement()
method is the leftmost leaf. This is the
same as a depth-first traversal.Modifying the tree by inserting, removing, or moving a node invalidates any enumerations created before the modification.
depthFirstEnumeration()
,
preorderEnumeration()
public java.util.Enumeration breadthFirstEnumeration()
nextElement()
method is this node.Modifying the tree by inserting, removing, or moving a node invalidates any enumerations created before the modification.
depthFirstEnumeration()
public java.util.Enumeration depthFirstEnumeration()
nextElement()
method is the leftmost leaf.
This is the same as a postorder traversal.Modifying the tree by inserting, removing, or moving a node invalidates any enumerations created before the modification.
breadthFirstEnumeration()
,
postorderEnumeration()
public java.util.Enumeration pathFromAncestorEnumeration(javax.swing.tree.TreeNode ancestor)
public boolean isNodeChild(javax.swing.tree.TreeNode aNode)
aNode
is a child of this node. If
aNode
is null, this method returns false.aNode
- TreeNodeaNode
is a child of this node; false if
aNode
is nullpublic javax.swing.tree.TreeNode getFirstChild()
java.util.NoSuchElementException
- if this node has no childrenpublic javax.swing.tree.TreeNode getLastChild()
java.util.NoSuchElementException
- if this node has no childrenpublic javax.swing.tree.TreeNode getChildAfter(javax.swing.tree.TreeNode aChild)
public javax.swing.tree.TreeNode getChildBefore(javax.swing.tree.TreeNode aChild)
aChild
, which must be a child of this node. If
aChild
is the first child, returns null. This method
performs a linear search of this node's children for aChild
and is O(n) where n is the number of children.aChild
- TreeNodeaChild
java.lang.IllegalArgumentException
- if aChild
is null
or is not a child of this nodepublic boolean isNodeSibling(javax.swing.tree.TreeNode anotherNode)
anotherNode
is a sibling of (has the
same parent as) this node. A node is its own sibling. If
anotherNode
is null, returns false.anotherNode
- node to test as sibling of this nodeanotherNode
is a sibling of this nodepublic int getSiblingCount()
1
).public GraphTreeNode getNextSibling()
children
public GraphTreeNode getPreviousSibling()
public boolean isLeaf()
getAllowsChildren
isLeaf
在接口中 javax.swing.tree.TreeNode
getAllowsChildren()
public GraphTreeNode getFirstLeaf()
isLeaf()
,
isNodeDescendant(com.sh.javax.tree.GraphTreeNode)
public GraphTreeNode getLastLeaf()
isLeaf()
,
isNodeDescendant(com.sh.javax.tree.GraphTreeNode)
public GraphTreeNode getNextLeaf()
In this implementation of the MutableNode
interface,
this operation is very inefficient. In order to determine the
next node, this method first performs a linear search in the
parent's child-list in order to find the current node.
That implementation makes the operation suitable for short
traversals from a known position. But to traverse all of the
leaves in the tree, you should use depthFirstEnumeration
to enumerate the nodes in the tree and use isLeaf
on each node to determine which are leaves.
depthFirstEnumeration()
,
isLeaf()
public GraphTreeNode getPreviousLeaf()
In this implementation of the MutableNode
interface,
this operation is very inefficient. In order to determine the
previous node, this method first performs a linear search in the
parent's child-list in order to find the current node.
That implementation makes the operation suitable for short
traversals from a known position. But to traverse all of the
leaves in the tree, you should use depthFirstEnumeration
to enumerate the nodes in the tree and use isLeaf
on each node to determine which are leaves.
depthFirstEnumeration()
,
isLeaf()
public int getLeafCount()
1
. This method is O(n)
where n is the number of descendants of this node.isNodeAncestor(javax.swing.tree.TreeNode)
public java.lang.String toString()
toString()
to this node's
user object, or null if this node has no user object.toString
在类中 java.lang.Object
getUserObject()
public java.lang.Object clone()
clone
在类中 java.lang.Object