y.layout.router
Class ChannelRouter

java.lang.Object
  |
  +--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 direction specifier.
static byte ROUTE_VERTICAL
          Channel direction specifier.
 
Constructor Summary
ChannelRouter(double min, double max)
          Creates a new instance of ChannelRouter for a horizontal channel.
ChannelRouter(double min, double max, byte direction)
          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)
           
 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 direction)
          Sets the channel bounds and direction.
 void setEpsilon(double epsilon)
          Setter for property epsilon.
 void setEpsilonChannelIgnored(boolean ignore)
          Determines if subchannel lengths smaller than epsilon should be ignored by the channelrouter.
 
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 direction specifier. Used to route edges in a vertical channel.

See Also:
Constant Field Values

ROUTE_HORIZONTAL

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

See Also:
Constant Field Values
Constructor Detail

ChannelRouter

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

Parameters:
min - the smallest assignable coordinate within the channel
max - the largest assignable coordinate within the channel
direction - the direction of the channel. One of ChannelRouter.ROUTE_VERTICAL and ChannelRouter.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 direction)
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
direction - the direction of the channel. One of ChannelRouter.ROUTE_VERTICAL and ChannelRouter.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 ChannelRouter.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 ChannelRouter.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 ChannelRouter.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 ChannelRouter.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 ChannelRouter.addSegment(Object,YPoint,YPoint)

getGroupSubChannelRank

public int getGroupSubChannelRank(Object groupKey)

isEpsilonChannelIgnored

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

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

setEpsilonChannelIgnored

public void setEpsilonChannelIgnored(boolean ignore)
Determines if subchannel lengths smaller than epsilon should be ignored by the channelrouter. 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:
epsilon
See Also:
ChannelRouter.setEpsilonChannelIgnored(boolean)

setEpsilon

public void setEpsilon(double epsilon)
Setter for property epsilon.

Parameters:
epsilon - New value of property epsilon.

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

2003