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 type
N - 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.
  • Field Details

    • INDENT

      private static final String INDENT
      Line indent string.
      See Also:
    • NEW_LINE

      private static final String NEW_LINE
      New line character.
      See Also:
    • MINUS_CHILD

      private static final String MINUS_CHILD
      Entry prefix for nodes on the minus side of their parent.
      See Also:
    • PLUS_CHILD

      private static final String PLUS_CHILD
      Entry prefix for nodes on the plus side of their parent.
      See Also:
    • ELLIPSIS

      private static final String ELLIPSIS
      Ellipsis for truncated representations.
      See Also:
    • maxDepth

      private final int maxDepth
      Maximum depth of nodes that will be printed.
    • output

      private final StringBuilder 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

      public BSPTreeVisitor.Result visit(N node)
      Visit a node in a BSP tree. This method is called for both internal nodes and leaf nodes.
      Specified by:
      visit in interface BSPTreeVisitor<P extends Point<P>,N extends BSPTree.Node<P,N>>
      Parameters:
      node - the node being visited
      Returns:
      the result of the visit operation
    • visitOrder

      public BSPTreeVisitor.Order visitOrder(N node)
      Determine the visit order for the given internal node. This is called for each internal node before BSPTreeVisitor.visit(BSPTree.Node) is called. Returning null or BSPTreeVisitor.Order.NONEfrom this method skips the subtree rooted at the given node. This method is not called on leaf nodes.
      Specified by:
      visitOrder in interface BSPTreeVisitor<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

      private void startLine(N node)
      Start a line for the given node.
      Parameters:
      node - the node to begin a line for
    • writeNode

      private void writeNode(N node)
      Writes the given node to the output.
      Parameters:
      node - the node to write
    • write

      private void write(String str)
      Add the given string to the output.
      Parameters:
      str - the string to add
    • toString

      public String toString()
      Return the string representation of the visited tree.
      Overrides:
      toString in class Object