Class AbstractPathConnector<E extends AbstractPathConnector.ConnectableElement<E>>

    • Constructor Detail

      • AbstractPathConnector

        public AbstractPathConnector()
    • Method Detail

      • connectPathElements

        protected void connectPathElements​(java.lang.Iterable<E> elements)
        Add a collection of path elements to the connector and attempt to connect each new element with previously added ones.
        Parameters:
        elements - path elements to connect
      • computePathRoots

        protected java.util.List<E> computePathRoots()
        Compute all connected paths and return a list of path elements representing the roots (start locations) of each. Each returned element is the head of a (possibly circular) linked list that follows a connected path.

        The connector is reset after this call. Further calls to add elements will result in new paths being generated.

        Returns:
        a list of root elements for the computed connected paths
      • followForwardConnections

        private void followForwardConnections​(E start)
        Find and follow forward connections from the given start element.
        Parameters:
        start - element to begin the connection operation with
      • makeForwardConnection

        private E makeForwardConnection​(E element)
        Connect the end point of the given element to the start point of another element. Returns the newly connected element or null if no forward connection was made.
        Parameters:
        element - element to connect
        Returns:
        the next element in the path or null if no connection was made
      • findPossibleConnections

        private void findPossibleConnections​(E element)
        Find possible connections for the given element and place them in the possibleConnections and possiblePointConnections lists.
        Parameters:
        element - the element to find connections for
      • addPossibleConnection

        private boolean addPossibleConnection​(E element,
                                              E candidate)
        Add the candidate to one of the connection lists if it represents a possible connection. Returns true if the candidate was added, otherwise false.
        Parameters:
        element - element to check for connections with
        candidate - candidate connection element
        Returns:
        true if the candidate is a possible connection
      • selectPointConnection

        protected E selectPointConnection​(E incoming,
                                          java.util.List<E> outgoingList)
        Method called to select a connection to use for a given element when multiple zero-length connections are available. The algorithm here attempts to choose the point most likely to produce a logical path by selecting the outgoing element with the smallest relative angle with the incoming element, with unconnected element preferred over ones that are already connected (thereby allowing other connections to occur in the path).
        Parameters:
        incoming - the incoming element
        outgoingList - list of available outgoing point-like connections
        Returns:
        the connection to use
      • selectConnection

        protected abstract E selectConnection​(E incoming,
                                              java.util.List<E> outgoing)
        Method called to select a connection to use for a given segment when multiple non-length-zero connections are available. In this case, the selection of the outgoing connection depends only on the desired characteristics of the connected path.
        Parameters:
        incoming - the incoming segment
        outgoing - list of available outgoing connections; will always contain at least two elements
        Returns:
        the connection to use