Search this API

y.layout.router
Class ChannelRouter

java.lang.Object
  extended by y.layout.router.ChannelRouter

public class ChannelRouter
extends Object

Class that routes edges within a vertical or horizontal channel All edges will then be routed in an orthogonal fashion. This class basically assigns subchannels to each each key (normally edges) so that the overall number of subchannels is small.


Field Summary
static byte ROUTE_HORIZONTAL
          Channel orientation specifier.
static byte ROUTE_VERTICAL
          Channel orientation specifier.
 
Constructor Summary
ChannelRouter(double min, double max)
          Creates a new instance of ChannelRouter for a horizontal channel.
ChannelRouter(double min, double max, byte orientation)
          Creates a new instance of ChannelRouter.
 
Method Summary
 void addGroupSegment(Object key, Object groupId, YPoint p1, YPoint p2)
          Adds an edge object that belongs to a group of edges with source and target coordinates to the set of edges that have to be routed within the channel Edges sharing the same groupId will be placed on the same channel.
 void addSegment(Object key, YPoint p1, YPoint p2)
          Adds an edge object with source and target coordinates to the set of edges that have to be routed within the channel
 boolean containsGroupKey(Object groupKey)
          Determines if the given key has been registered as a grouping key with this instance.
 boolean containsKey(Object key)
          Determines if the given key has been registered already with this instance.
 double getCoord(Object key)
          Returns the calculated channel coordinate for an added edge object.
 double getEpsilon()
          Returns the current epsilon value.
 int getGroupSubChannelRank(Object groupKey)
          Returns the subchannel rank for the group indicated by the groupKey.
 int getSubChannelCount()
          Returns the number of subchannels within this channel.
 int getSubChannelRank(Object key)
          Returns the subchannel rank of this segment within the channel.
 boolean isEpsilonChannelIgnored()
          Returns whether subchannels shorter than epsilon are ignored by this instance.
 void route()
          Routes all added edges within the specified channel.
 Iterator segmentKeys()
          Returns an iterator over all added segment keys.
 void setChannel(double min, double max, byte orientation)
          Sets the channel bounds and direction.
 void setEpsilon(double epsilon)
          Specifies the current epsilon value.
 void setEpsilonChannelIgnored(boolean ignore)
          Determines if subchannel lengths smaller than epsilon should be ignored by the channel router.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROUTE_VERTICAL

public static final byte ROUTE_VERTICAL
Channel orientation specifier. Used to route edges in a vertical channel.

See Also:
Constant Field Values

ROUTE_HORIZONTAL

public static final byte ROUTE_HORIZONTAL
Channel orientation specifier. Used to route edges in a horizontal channel.

See Also:
Constant Field Values
Constructor Detail

ChannelRouter

public ChannelRouter(double min,
                     double max,
                     byte orientation)
Creates a new instance of ChannelRouter.

Parameters:
min - the smallest assignable coordinate within the channel
max - the largest assignable coordinate within the channel
orientation - the direction of the channel. One of ROUTE_VERTICAL and ROUTE_HORIZONTAL

ChannelRouter

public ChannelRouter(double min,
                     double max)
Creates a new instance of ChannelRouter for a horizontal channel.

Parameters:
min - the smallest assignable coordinate within the channel
max - the largest assignable coordinate within the channel
Method Detail

setChannel

public void setChannel(double min,
                       double max,
                       byte orientation)
Sets the channel bounds and direction. A call to this method implies that all previously added segments will be removed.

Parameters:
min - the smallest assignable coordinate within the channel
max - the largest assignable coordinate within the channel
orientation - the orientation of the channel. One of ROUTE_VERTICAL and ROUTE_HORIZONTAL

addSegment

public void addSegment(Object key,
                       YPoint p1,
                       YPoint p2)
Adds an edge object with source and target coordinates to the set of edges that have to be routed within the channel


addGroupSegment

public void addGroupSegment(Object key,
                            Object groupId,
                            YPoint p1,
                            YPoint p2)
Adds an edge object that belongs to a group of edges with source and target coordinates to the set of edges that have to be routed within the channel Edges sharing the same groupId will be placed on the same channel.


segmentKeys

public Iterator segmentKeys()
Returns an iterator over all added segment keys. For grouped edges, there will be a YList returned.


containsKey

public boolean containsKey(Object key)
Determines if the given key has been registered already with this instance.

Parameters:
key - the key which is used in addSegment(Object, YPoint, YPoint)

containsGroupKey

public boolean containsGroupKey(Object groupKey)
Determines if the given key has been registered as a grouping key with this instance.

Parameters:
groupKey - the key which is used in addGroupSegment(Object, Object, YPoint, YPoint)

route

public void route()
Routes all added edges within the specified channel. The resulting subchannels can then be queried using the getSubChannelRank(Object) method.


getCoord

public double getCoord(Object key)
Returns the calculated channel coordinate for an added edge object. If for example the router was instantiated with the arguments ChannelRouter(100,200,ChannelRouter.ROUTE_HORIZONTAL) then the returned coordinate is an x-coordinate between 100 and 200. This coordinate represents the x-coordinate of two additional bends that are needed to route the edge orthogonally from p1 to p2 (as specified in addSegment).

Parameters:
key - an edge object added with addSegment(Object,YPoint,YPoint)

getSubChannelCount

public int getSubChannelCount()
Returns the number of subchannels within this channel. The return value 0 indicates that there are no subchannels present.


getSubChannelRank

public int getSubChannelRank(Object key)
Returns the subchannel rank of this segment within the channel.

Parameters:
key - an edge object added with addSegment(Object,YPoint,YPoint)

getGroupSubChannelRank

public int getGroupSubChannelRank(Object groupKey)
Returns the subchannel rank for the group indicated by the groupKey.

See Also:
addGroupSegment(Object, Object, y.geom.YPoint, y.geom.YPoint)

isEpsilonChannelIgnored

public boolean isEpsilonChannelIgnored()
Returns whether subchannels shorter than epsilon are ignored by this instance.

See Also:
setEpsilon(double), setEpsilonChannelIgnored(boolean)

setEpsilonChannelIgnored

public void setEpsilonChannelIgnored(boolean ignore)
Determines if subchannel lengths smaller than epsilon should be ignored by the channel router. Default is true with an epsilon value of 0.5d.


getEpsilon

public double getEpsilon()
Returns the current epsilon value. Subchannel lengths smaller than this value will be ignored by this instance if the the epsilonChannelIgnored property is set to true

Returns:
the current epsilon value.
See Also:
setEpsilonChannelIgnored(boolean)

setEpsilon

public void setEpsilon(double epsilon)
Specifies the current epsilon value.


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