Search this API

y.layout.router.polyline
Class ChannelBasedPathRouting

java.lang.Object
  extended by y.layout.router.polyline.ChannelBasedPathRouting

public class ChannelBasedPathRouting
extends Object

Routes edges using their pre-calculated Path information.

Initialize must be called before the edges can be routed.

The basic approach of this router is to bundle edge segments into so-called Channels and route each channel individually.

See Also:
EdgeInfo.getSegmentInfo(int), LayoutGraph.setPath(y.base.Edge, y.base.YList)

Constructor Summary
ChannelBasedPathRouting()
           
 
Method Summary
protected  void adjustSegmentLocations(Channel channel)
          Tries to adjust the location set for a segment info in the channel to consider the preferred alignment of the segment.
protected  void calculateSegmentLocations(Channel channel)
          Calculates locations for the segment infos in the given channel.
 void cleanup()
          Resets all channel information and the reference to the PathSearchConfiguration.
protected  Comparator createSegmentInfoComparator(YList channels, PathSearchResult pathSearchResult, PathSearchConfiguration configuration)
          Creates a comparator for SegmentInfos that can be used to sort the segment infos in a Channel from left to right (for vertical segments) or top to bottom (for horizontal segments), respectively.
protected  PathSearchConfiguration getConfiguration()
          Returns the configuration this class was initialized with.
 void initialize(PathSearchConfiguration configuration)
          Initializes this class for routing paths that were found with the given configuration.
protected  void optimizeSegmentOrder(Channel channel)
          Optimizes the order of the segments in the given channel.
 void route(EdgeList edges, PathSearchResult pathSearchResult)
          Routes the given edges.
protected  void sortSegmentInfos(List segmentInfos, Comparator segmentInfoComparator)
          Sorts the given list of SegmentInfos using the given comparator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChannelBasedPathRouting

public ChannelBasedPathRouting()
Method Detail

initialize

public void initialize(PathSearchConfiguration configuration)
Initializes this class for routing paths that were found with the given configuration. Must be called before route(y.base.EdgeList, PathSearchResult).

Parameters:
configuration - The configuration to use for the following path routings.
See Also:
route(y.base.EdgeList, PathSearchResult)

cleanup

public void cleanup()
Resets all channel information and the reference to the PathSearchConfiguration. So, ChannelBasedPathRouting is ready to calculate paths for a new layout.


getConfiguration

protected PathSearchConfiguration getConfiguration()
Returns the configuration this class was initialized with.

Returns:
The configuration this class was initialized with.
See Also:
initialize(PathSearchConfiguration)

route

public void route(EdgeList edges,
                  PathSearchResult pathSearchResult)
Routes the given edges. initialize(PathSearchConfiguration) must be called first.

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 segment's location ranges by calling the subsequent methods:

  1. optimizeSegmentOrder(y.layout.router.polyline.Channel)
  2. calculateSegmentLocations(y.layout.router.polyline.Channel)
  3. adjustSegmentLocations(y.layout.router.polyline.Channel)

Finally the control points for the paths are calculated.

Throws:
IllegalStateException - If the locations are not inside of the segment's location range.
Parameters:
edges - The edges to route.
pathSearchResult - The path search results containing the Path objects for the edges.
See Also:
PathSearchResult.getPath(y.base.Edge), AbstractSegmentInfo.getLocationRange(), AbstractSegmentInfo.setLocation(double)

createSegmentInfoComparator

protected Comparator createSegmentInfoComparator(YList channels,
                                                 PathSearchResult pathSearchResult,
                                                 PathSearchConfiguration configuration)
Creates a comparator for SegmentInfos that can be used to sort the segment infos in a Channel from left to right (for vertical segments) or top to bottom (for horizontal segments), respectively.

Parameters:
channels - The channels this comparator will be used for later.
pathSearchResult - The path search result containing the EdgeInfos with the SegmentInfos this comparator that will be used for later.
configuration - The configuration used during this path search.
Returns:
A comparator for SegmentInfos that can be used to sort the segment infos in a Channel.

sortSegmentInfos

protected void sortSegmentInfos(List segmentInfos,
                                Comparator segmentInfoComparator)
Sorts the given list of SegmentInfos using the given comparator.

Parameters:
segmentInfos - The list of SegmentInfos to sort.
segmentInfoComparator - The comparator to use for the sorting.

optimizeSegmentOrder

protected void optimizeSegmentOrder(Channel channel)
Optimizes the order of the segments in the given channel.

After the segments in the channel have been sorted using the segment info comparator, segment infos having a common SegmentGroup are replaced by their common representative segment info.

This method further improves the order of the resulting segment info list is to make sure that the subsequent location calculation is able to respect the segment infos location ranges and if possible the minimal edge to edge distances and possible grid constraints for the segments.

Parameters:
channel - The channel to optimize the segment info order for.

calculateSegmentLocations

protected void calculateSegmentLocations(Channel channel)
Calculates locations for the segment infos in the given channel.

Precondition: The locations of the segments are stored in the Channel. They should respect minimal edge to edge distances and grid constraints and must lie in the respective location ranges.

Parameters:
channel - The channel to calculate locations for the segment infos for.
See Also:
Channel.setCurrentLocation(SegmentInfo, double)

adjustSegmentLocations

protected void adjustSegmentLocations(Channel channel)
Tries to adjust the location set for a segment info in the channel to consider 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.

Parameters:
channel - The channel of the segment infos to consider the alignments for.
See Also:
Channel.getCurrentLocation(SegmentInfo), AbstractSegmentInfo.getPreferredAlignment()

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.