Class BSPTreePrinter<P extends Point<P>, N extends BSPTree.Node<P,N>>
java.lang.Object
org.apache.commons.geometry.core.partitioning.bsp.BSPTreePrinter<P,N>
- Type Parameters:
P- Point implementation typeN- Node implementation type
- All Implemented Interfaces:
BSPTreeVisitor<P,N>
final class BSPTreePrinter<P extends Point<P>, N extends BSPTree.Node<P,N>>
extends Object
implements BSPTreeVisitor<P,N>
Internal class for creating simple string representations of BSP trees.
-
Nested Class Summary
Nested classes/interfaces inherited from interface BSPTreeVisitor
BSPTreeVisitor.ClosestFirstVisitor<P,N>, BSPTreeVisitor.FarthestFirstVisitor<P, N>, BSPTreeVisitor.Order, BSPTreeVisitor.Result, BSPTreeVisitor.TargetPointVisitor<P, N> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringEllipsis for truncated representations.private static final StringLine indent string.private final intMaximum depth of nodes that will be printed.private static final StringEntry prefix for nodes on the minus side of their parent.private static final StringNew line character.private final StringBuilderContains the string output.private static final StringEntry prefix for nodes on the plus side of their parent. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidStart a line for the given node.toString()Return the string representation of the visited tree.Visit a node in a BSP tree.visitOrder(N node) Determine the visit order for the given internal node.private voidAdd the given string to the output.private voidWrites the given node to the output.
-
Field Details
-
INDENT
-
NEW_LINE
-
MINUS_CHILD
Entry prefix for nodes on the minus side of their parent.- See Also:
-
PLUS_CHILD
Entry prefix for nodes on the plus side of their parent.- See Also:
-
ELLIPSIS
-
maxDepth
private final int maxDepthMaximum depth of nodes that will be printed. -
output
Contains the string output.
-
-
Constructor Details
-
BSPTreePrinter
BSPTreePrinter(int maxDepth) Simple constructor.- Parameters:
maxDepth- maximum depth of nodes to be printed
-
-
Method Details
-
visit
Visit a node in a BSP tree. This method is called for both internal nodes and leaf nodes.- Specified by:
visitin interfaceBSPTreeVisitor<P extends Point<P>, N extends BSPTree.Node<P,N>> - Parameters:
node- the node being visited- Returns:
- the result of the visit operation
-
visitOrder
Determine the visit order for the given internal node. This is called for each internal node beforeBSPTreeVisitor.visit(BSPTree.Node)is called. Returning null orBSPTreeVisitor.Order.NONEfrom this method skips the subtree rooted at the given node. This method is not called on leaf nodes.- Specified by:
visitOrderin interfaceBSPTreeVisitor<P extends Point<P>, N extends BSPTree.Node<P,N>> - Parameters:
node- the internal node to determine the visit order for- Returns:
- the order that the subtree rooted at the given node should be visited
-
startLine
Start a line for the given node.- Parameters:
node- the node to begin a line for
-
writeNode
Writes the given node to the output.- Parameters:
node- the node to write
-
write
Add the given string to the output.- Parameters:
str- the string to add
-
toString
-