org.foray.common
Interface OrderedTreeNode

All Superinterfaces:
TreeNode
All Known Implementing Classes:
AbstractAncestralInlineArea, AbstractCharacterSequence, AbstractFlow, AbstractFolioDescriptor, AbstractIndexFormatting, AbstractInlineArea, AbstractListItemContent, AbstractOrderedTreeNode, AbstractPageMaster, AbstractPageReference, AbstractTablePart, AbstractTablePartContainer, Area, AreaFixed, AreaFlexible, AreaNode, AreaTree, BasicLink, BasicLinkArea, BeforeFloatRA, BidiOverride, BidiOverrideArea, Block, BlockArea, BlockContainer, BlockContainerRA, Bookmark, BookmarkTitle, BookmarkTree, ChangeBarBegin, ChangeBarEnd, Character, CharacterSequence4a, ColorProfile, ConditionalPageMasterReference, ContainerRA, Declarations, ExternalGraphic, ExternalGraphicArea, Float, Flow, FlowAssignment, FlowMap, FlowNameSpecifier, FlowSourceList, FlowTargetList, FObj, FObjMixed, FObjScaled, FolioPrefix, FolioSuffix, Footnote, FootnoteBody, FootnoteRA, ForeignObjectArea, ForeignXML, FoWordSequence, IndexKeyReference, IndexPageCitationList, IndexPageCitationListArea, IndexPageCitationListSeparator, IndexPageCitationRangeSeparator, IndexPageNumberPrefix, IndexPageNumberSuffix, IndexRangeBegin, IndexRangeEnd, InitialPropertySet, Inline, InlineArea, InlineContainer, InlineContainerArea, InstreamForeignObject, InstreamMathElement, InstreamSvgElement, LayoutMasterSet, Leader, LeaderArea, LineArea, ListBlock, ListBlockArea, ListItem, ListItemArea, ListItemBody, ListItemBodyContainer, ListItemLabel, ListItemLabelContainer, MainRA, Marker, Metadata, MultiCase, MultiProperties, MultiPropertySet, MultiSwitch, MultiToggle, NonArea, NormalBlockArea, NormalFlowRA, PageCollection, PageNumber, PageNumberArea, PageNumberCitation, PageNumberCitationArea, PageNumberCitationLast, PageNumberCitationLastArea, PageRA, PageSequence, PageSequenceMaster, PageSequenceWrapper, Region, RegionAfter, RegionBefore, RegionBody, RegionEnd, RegionNameSpecifier, RegionRA, RegionRABody, RegionStart, RepeatablePMAlternatives, RepeatablePMReference, RetrieveMarker, RetrieveTableMarker, Root, ScalingValueCitation, ScalingValueCitationArea, SimplePageMaster, SinglePageMasterReference, SpanRA, StaticContent, SubSequenceSpecifier, Table, TableAndCaption, TableBody, TableBodyContainer, TableCaption, TableCell, TableCellRA, TableColumn, TableFooter, TableFooterContainer, TableHeader, TableHeaderContainer, TableRA, TableRow, TableRowContainer, TextArea, Title, Wrapper

public interface OrderedTreeNode
extends TreeNode

A TreeNode that is aware of its relationships not only to its parents and children, but also to its siblings. The order and placement of children is significant.


Method Summary
 OrderedTreeNode getFirstChild()
          Returns the first child of this node.
 OrderedTreeNode getFirstLeaf()
          Finds and returns the first leaf that is a descendant of this node -- either this node or its first child's first leaf.
 OrderedTreeNode getLastChild()
          Returns the last child of this node.
 OrderedTreeNode getLastLeaf()
          Finds and returns the last leaf that is a descendant of this node -- either this node or its last child's last leaf.
 int getLevel()
          Returns the number of levels above this node -- the distance from the root to this node.
 OrderedTreeNode getNextLeaf()
          Returns the leaf after this node or null if this node is the last leaf in the tree.
 OrderedTreeNode getNextSibling()
          Returns the next sibling node.
 OrderedTreeNode getOrderedParent()
          Returns the parent of this node, cast as an OrderedTreeNode.
 OrderedTreeNode getPreviousLeaf()
          Returns the leaf before this node or null if this node is the first leaf in the tree.
 OrderedTreeNode getPreviousSibling()
          Returns the previous sibling node.
 boolean hasChildren()
          Reports whether this node has any children.
 boolean isNodeAncestor(OrderedTreeNode 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.
 OrderedTreeNode nextPostOrderNode()
          Returns the next node in the tree relative to the current node, in post-order traversal order.
 OrderedTreeNode nextPreOrderNode()
          Returns the next node in the tree relative to the current node, in pre-order traversal order.
 int siblingIndex()
          Returns this node's position within the siblings.
 
Methods inherited from interface javax.swing.tree.TreeNode
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
 

Method Detail

getOrderedParent

OrderedTreeNode getOrderedParent()
Returns the parent of this node, cast as an OrderedTreeNode.

Returns:
The parent of this node.

siblingIndex

int siblingIndex()
Returns this node's position within the siblings.

Returns:
The index to "this" in the parent's children.

getPreviousSibling

OrderedTreeNode getPreviousSibling()
Returns the previous sibling node.

Returns:
Return the sibling immediately preceding "this" in the parent's children, or null if this is the first child.

getNextSibling

OrderedTreeNode getNextSibling()
Returns the next sibling node.

Returns:
Return the sibling immediately following "this" in the parent's children, or null if this is the last child.

hasChildren

boolean hasChildren()
Reports whether this node has any children.

Returns:
True if this node has any children, false if it has none.

getFirstChild

OrderedTreeNode getFirstChild()
Returns the first child of this node.

Returns:
The first child of this node, or null if this node has no children.

getLastChild

OrderedTreeNode getLastChild()
Returns the last child of this node.

Returns:
The last child of this node, or null if this node has no children.

nextPreOrderNode

OrderedTreeNode nextPreOrderNode()
Returns the next node in the tree relative to the current node, in pre-order traversal order. This is also known as breadth-first order.

Returns:
The next pre-order node, or null if there is none.

nextPostOrderNode

OrderedTreeNode nextPostOrderNode()
Returns the next node in the tree relative to the current node, in post-order traversal order. This is also known as depth-first order.

Returns:
The next post-order node, or null if there is none.

getFirstLeaf

OrderedTreeNode getFirstLeaf()
Finds and returns the first leaf that is a descendant of this node -- either this node or its first child's first leaf. Returns this node if it is a leaf. (Liberated from DefaultMutableTreeNode).

Returns:
the first leaf in the subtree rooted at this node
See Also:
TreeNode.isLeaf(), DefaultMutableTreeNode.isNodeDescendant(javax.swing.tree.DefaultMutableTreeNode)

getLastLeaf

OrderedTreeNode getLastLeaf()
Finds and returns the last leaf that is a descendant of this node -- either this node or its last child's last leaf. Returns this node if it is a leaf. (Liberated from DefaultMutableTreeNode).

Returns:
the last leaf in the subtree rooted at this node
See Also:
TreeNode.isLeaf(), DefaultMutableTreeNode.isNodeDescendant(javax.swing.tree.DefaultMutableTreeNode)

getNextLeaf

OrderedTreeNode getNextLeaf()
Returns the leaf after this node or null if this node is the last leaf in the tree.

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. (Liberated from DefaultMutableTreeNode).

Returns:
returns the next leaf past this node
See Also:
DefaultMutableTreeNode.depthFirstEnumeration(), TreeNode.isLeaf()

getPreviousLeaf

OrderedTreeNode getPreviousLeaf()
Returns the leaf before this node or null if this node is the first leaf in the tree.

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. (Liberated from DefaultMutableTreeNode).

Returns:
returns the leaf before this node
See Also:
DefaultMutableTreeNode.depthFirstEnumeration(), TreeNode.isLeaf()

getLevel

int getLevel()
Returns the number of levels above this node -- the distance from the root to this node. If this node is the root, returns 0. This implementation was liberated from DefaultMutableTreeNode).

Returns:
The number of levels above this node.

isNodeAncestor

boolean isNodeAncestor(OrderedTreeNode 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. (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.

Parameters:
anotherNode - node to test as an ancestor of this node
Returns:
true if this node is a descendant of anotherNode


Copyright © 2017. All rights reserved.