E
- Element typepublic abstract static class AbstractPathConnector.ConnectableElement<E extends AbstractPathConnector.ConnectableElement<E>> extends Object implements Comparable<E>
AbstractPathConnector
.
Subclasses must fulfill the following requirements in order for path connection operations
to work correctly:
Comparable.compareTo(Object)
such that elements are sorted by their start
point locations. Other criteria may be used as well but elements with start points in close
proximity must be grouped together.getConnectionSearchKey()
such that it returns an instance that will be placed
next to elements with start points close to the current instance's end point when sorted with
Comparable.compareTo(Object)
.shouldContinueConnectionSearch(AbstractPathConnector.ConnectableElement, boolean)
such that it returns false when the search for possible connections through a sorted list of elements
may terminate.AbstractPathConnector
Constructor and Description |
---|
ConnectableElement() |
Modifier and Type | Method and 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareTo
public ConnectableElement()
public boolean hasNext()
public E getNext()
protected void setNext(E next)
connectTo(AbstractPathConnector.ConnectableElement)
method instead.next
- next path elementpublic boolean hasPrevious()
public E getPrevious()
protected void setPrevious(E previous)
connectTo(AbstractPathConnector.ConnectableElement)
method instead.previous
- previous path elementpublic void connectTo(E nextElement)
canConnectTo(AbstractPathConnector.ConnectableElement)
method must have been called previously.nextElement
- the next element in the pathpublic E exportPath()
protected boolean markExported()
public abstract boolean hasStart()
public abstract boolean hasEnd()
public abstract boolean endPointsEq(E other)
other
- element to compare end points withpublic abstract boolean canConnectTo(E nextElement)
nextElement
- candidate for the next element in the path; this value
is guaranteed to not be null and to contain a start pointpublic abstract double getRelativeAngle(E other)
other
- element to compute the angle withpublic abstract E getConnectionSearchKey()
Comparable.compareTo(Object)
method.public abstract boolean shouldContinueConnectionSearch(E candidate, boolean ascending)
candidate
- last tested candidate connection elementascending
- true if the search is proceeding in an ascending direction;
false otherwiseCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.