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

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean exported
      Flag set to true when this element has exported its value to a path.
      private E next
      Next connected element.
      private E previous
      Previous connected element.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract boolean canConnectTo​(E nextElement)
      Return true if this instance's end point can be connected to the argument's start point.
      void connectTo​(E nextElement)
      Connect this instance's end point to the given element's start point.
      abstract boolean endPointsEq​(E other)
      Return true if the end point of this instance should be considered equivalent to the end point of the argument.
      E exportPath()
      Export the path that this element belongs to, returning the root segment.
      abstract E getConnectionSearchKey()
      Get a new instance used as a search key to help locate other elements with start points matching this instance's end point.
      E getNext()
      Get the next connected element in the path, if any.
      E getPrevious()
      Get the previous connected element in the path, if any.
      abstract double getRelativeAngle​(E other)
      Return the relative angle between this element and the argument.
      protected abstract E getSelf()
      Return the current instance as the generic type.
      abstract boolean hasEnd()
      Return true if this instance has an end point that can be connected to another element's start point.
      boolean hasNext()
      Return true if the instance is connected to another element's start point.
      boolean hasPrevious()
      Return true if another element is connected to this instance's start point.
      abstract boolean hasStart()
      Return true if this instance has a start point that can be connected to another element's end point.
      protected boolean markExported()
      Set the export flag for this instance to true.
      protected void setNext​(E next)
      Set the next connected element for this path.
      protected void setPrevious​(E previous)
      Set the previous connected element for this path.
      abstract boolean shouldContinueConnectionSearch​(E candidate, boolean ascending)
      Return true if the search for possible connections should continue through the sorted set of possible path elements given the current candidate element and search direction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Comparable

        compareTo
    • Constructor Detail

      • ConnectableElement

        public ConnectableElement()
    • Method Detail

      • hasNext

        public boolean hasNext()
        Return true if the instance is connected to another element's start point.
        Returns:
        true if the instance has a next element
      • getNext

        public E getNext()
        Get the next connected element in the path, if any.
        Returns:
        the next connected segment in the path; may be null
      • setNext

        protected void setNext​(E next)
        Set the next connected element for this path. This is intended for internal use only. Callers should use the connectTo(AbstractPathConnector.ConnectableElement) method instead.
        Parameters:
        next - next path element
      • hasPrevious

        public boolean hasPrevious()
        Return true if another element is connected to this instance's start point.
        Returns:
        true if the instance has a previous element
      • getPrevious

        public E getPrevious()
        Get the previous connected element in the path, if any.
        Returns:
        the previous connected element in the path; may be null
      • setPrevious

        protected void setPrevious​(E previous)
        Set the previous connected element for this path. This is intended for internal use only. Callers should use the connectTo(AbstractPathConnector.ConnectableElement) method instead.
        Parameters:
        previous - previous path element
      • connectTo

        public void connectTo​(E nextElement)
        Connect this instance's end point to the given element's start point. No validation is performed in this method. The canConnectTo(AbstractPathConnector.ConnectableElement) method must have been called previously.
        Parameters:
        nextElement - the next element in the path
      • exportPath

        public E exportPath()
        Export the path that this element belongs to, returning the root segment. This method traverses all connected element, sets their exported flags to true, and returns the root element of the path (or this element in the case of a loop). Each path can only be exported once. Later calls to this method on this instance or any of its connected elements will return null.
        Returns:
        the root of the path or null if the path that this element belongs to has already been exported
      • markExported

        protected boolean markExported()
        Set the export flag for this instance to true. Returns true if the flag was changed and false otherwise.
        Returns:
        true if the flag was changed and false if it was already set to true
      • hasStart

        public abstract boolean hasStart()
        Return true if this instance has a start point that can be connected to another element's end point.
        Returns:
        true if this instance has a start point that can be connected to another element's end point
      • hasEnd

        public abstract boolean hasEnd()
        Return true if this instance has an end point that can be connected to another element's start point.
        Returns:
        true if this instance has an end point that can be connected to another element's start point
      • endPointsEq

        public abstract boolean endPointsEq​(E other)
        Return true if the end point of this instance should be considered equivalent to the end point of the argument.
        Parameters:
        other - element to compare end points with
        Returns:
        true if this instance has an end point equivalent to that of the argument
      • canConnectTo

        public abstract boolean canConnectTo​(E nextElement)
        Return true if this instance's end point can be connected to the argument's start point.
        Parameters:
        nextElement - candidate for the next element in the path; this value is guaranteed to not be null and to contain a start point
        Returns:
        true if this instance's end point can be connected to the argument's start point
      • getRelativeAngle

        public abstract double getRelativeAngle​(E other)
        Return the relative angle between this element and the argument.
        Parameters:
        other - element to compute the angle with
        Returns:
        the relative angle between this element and the argument
      • getConnectionSearchKey

        public abstract E getConnectionSearchKey()
        Get a new instance used as a search key to help locate other elements with start points matching this instance's end point. The only restriction on the returned instance is that it be compatible with the implementation class' Comparable.compareTo(Object) method.
        Returns:
        a new instance used to help locate other path elements with start points equivalent to this instance's end point
      • shouldContinueConnectionSearch

        public abstract boolean shouldContinueConnectionSearch​(E candidate,
                                                               boolean ascending)
        Return true if the search for possible connections should continue through the sorted set of possible path elements given the current candidate element and search direction. The search operation stops for the given direction when this method returns false.
        Parameters:
        candidate - last tested candidate connection element
        ascending - true if the search is proceeding in an ascending direction; false otherwise
        Returns:
        true if the connection search should continue
      • getSelf

        protected abstract E getSelf()
        Return the current instance as the generic type.
        Returns:
        the current instance as the generic type.