public class ChannelBasedPathRouting extends Object
Path information.
The concept of this algorithm is to bundle edge segments into so-called Channels and route
each Channel individually.
This class is initialized using initialize(PathSearchConfiguration) which must have been called before the
edges are routed.
After a ChannelBasedPathRouting instance is no longer in use, the Channel information and the reference
to the configuration must be reset using method cleanup().
| Constructor and Description |
|---|
ChannelBasedPathRouting()
Creates a new instance of
ChannelBasedPathRouting. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
adjustSegmentLocations(Channel channel)
Adjusts the location assigned to a
segment info in the channel considering the
preferred alignment of the segment. |
protected void |
calculateSegmentLocations(Channel channel)
Calculates the locations of the
segment infos in the given channel. |
void |
cleanup()
Resets all
channel information and the reference to the configuration. |
protected Comparator<Object> |
createSegmentInfoComparator(YList channels,
PathSearchResult pathSearchResult,
PathSearchConfiguration configuration)
Creates a
comparator for sorting the SegmentInfos in a Channel from left to right
(for vertical segments) or top to bottom (for horizontal segments), respectively. |
protected PathSearchConfiguration |
getConfiguration()
|
void |
initialize(PathSearchConfiguration configuration)
Initializes this
ChannelBasedPathRouting instance for routing paths that have been found with the given
configuration. |
protected void |
optimizeSegmentOrder(Channel channel)
|
void |
route(EdgeList edges,
PathSearchResult pathSearchResult)
Routes the given edges.
|
protected void |
sortSegmentInfos(List<Object> segmentInfos,
Comparator<Object> segmentInfoComparator)
Sorts the given list of
SegmentInfos using the given comparator. |
public ChannelBasedPathRouting()
ChannelBasedPathRouting.protected void adjustSegmentLocations(Channel channel)
segment info in the channel considering the
preferred alignment of the segment.
This method is called after the segments have been distributed in the channel but before the final locations of the
segments are assigned to the segment infos.
channel - the channel that contains the segment infos for which the alignment should be consideredChannel.getCurrentLocation(SegmentInfo),
AbstractSegmentInfo.getPreferredAlignment()protected void calculateSegmentLocations(Channel channel)
segment infos in the given channel.
This method is called after the order of the segment infos within a channel has been
optimized.
stored in the
channel. They should respect minimum edge to edge distances and grid constraints and must lie in the
respective location ranges.channel - the channel that contains the segment infos for which the locations will be calculatedChannel.setCurrentLocation(SegmentInfo, double)public void cleanup()
channel information and the reference to the configuration.
Afterwards, ChannelBasedPathRouting is ready to calculate paths for a new layout.
protected Comparator<Object> createSegmentInfoComparator(YList channels, PathSearchResult pathSearchResult, PathSearchConfiguration configuration)
comparator for sorting the SegmentInfos in a Channel from left to right
(for vertical segments) or top to bottom (for horizontal segments), respectively.
This method is called in route(EdgeList, PathSearchResult) before edge segments are distributed within the
channels.
channels - the channels whose segments will be sorted by the comparatorpathSearchResult - the path search result containing the EdgeInfos with the
SegmentInfos for which the comparator will be usedconfiguration - the configuration used during this path searchcomparator used for sorting the SegmentInfos in a channelprotected PathSearchConfiguration getConfiguration()
configuration of this ChannelBasedPathRouting instanceinitialize(PathSearchConfiguration)public void initialize(PathSearchConfiguration configuration)
ChannelBasedPathRouting instance for routing paths that have been found with the given
configuration.
This method must be called before the edges are routed.
configuration - the configuration used for the following path routingroute(EdgeList, PathSearchResult)protected void optimizeSegmentOrder(Channel channel)
segments in the given channel.
After the segments in the channel have been sorted using the comparator created by method
createSegmentInfoComparator(YList, PathSearchResult, PathSearchConfiguration), segments having a common SegmentGroup
are replaced by their common representative segment info.
This method further improves the order of the resulting segment info list to make sure that the subsequent location calculation
is able to respect the location ranges
of the
SegmentInfos and, if possible, the minimum edge to edge distances and possible grid constraints for the
segments.
channel - the channel for which the order of the SegmentInfos is optimizedpublic void route(EdgeList edges, PathSearchResult pathSearchResult)
Before calling this method, method initialize(PathSearchConfiguration) must have been called.
As a first step, the SegmentInfos of all edge paths are distributed to Channels. After that, the
segments in each of these
Channels are sorted and locations are assigned respecting the segments' location ranges by calling the
subsequent methods:
Finally, the control points for the paths are calculated.
IllegalStateException - if the locations are not within the segment's location rangeedges - the list of edges to be routedpathSearchResult - the path search result containing the Path
objects for the edgesPathSearchResult.getPath(Edge),
AbstractSegmentInfo.getLocationRange(),
AbstractSegmentInfo.setLocation(double)protected void sortSegmentInfos(List<Object> segmentInfos, Comparator<Object> segmentInfoComparator)
SegmentInfos using the given comparator.
This method is called in route(EdgeList, PathSearchResult) when the edge segments are distributed within the
channels.
segmentInfos - the list of SegmentInfos to be sortedsegmentInfoComparator - the comparator used for sorting the list of SegmentInfos