|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.router.ChannelRouter
public class ChannelRouter
This routing algorithm applies orthogonal routes to the edges within a channel.
Each edge that should be routed has to be specified by a unique key (e.g., the edge itself) as well as two points that
represent the two endpoints of this edge, see addSegment(Object, YPoint, YPoint)
.
The orthogonal route of each edge consists of three segments. More precisely, for an edge with source point (sx,sy)
,
target point (tx,ty)
and vertical
channel orientation,
the algorithm calculates the x-coordinate of the vertical middle segment (called mx
) that can be obtained
with method getCoord(Object)
after routing
the edges.
Hence, the actual route consists of points (sx,sy), (mx,sy), (mx,ty)
and (tx,ty)
.
Analogously, if the channel orientation is horizontal
,
the route consists of the points (sx,sy), (sx,my), (tx,my)
and (tx,ty)
.
Besides the orientation, each channel is restricted by a smallest and largest
assignable coordinate. If, for example, the orientation is vertical
, the calculated
x-coordinate
of the middle segment lies between these two values. Both values can be changed by means of method
setChannel(double, double, byte)
.
All edges assigned to the same coordinate are said to lie in the same sub-channel. In general, the routing algorithm tries to assign coordinates such the number of sub-channels as well as the number of edge crossings is small.
getCoord(Object)
or getSubChannelRank(Object)
.Field Summary | |
---|---|
static byte |
ROUTE_HORIZONTAL
Channel orientation specifier for routing edges horizontally. |
static byte |
ROUTE_VERTICAL
Channel orientation specifier for routing edges vertically. |
Constructor Summary | |
---|---|
ChannelRouter(double min,
double max)
Creates a new instance of ChannelRouter for a channel with horizontal orientation. |
|
ChannelRouter(double min,
double max,
byte orientation)
Creates a new instance of ChannelRouter . |
Method Summary | |
---|---|
void |
addGroupSegment(java.lang.Object key,
java.lang.Object groupId,
YPoint p1,
YPoint p2)
Adds an edge object that belongs to an edge group to the set of elements that should be routed within the channel. |
void |
addSegment(java.lang.Object key,
YPoint p1,
YPoint p2)
Adds an edge object with endpoint p1 and p2
to the set of elements that should be routed within the channel. |
boolean |
containsGroupKey(java.lang.Object groupId)
Returns whether the given id has already been registered as a group id. |
boolean |
containsKey(java.lang.Object key)
Returns whether the given key has already been registered. |
double |
getCoord(java.lang.Object key)
Returns the calculated channel coordinate for an added edge object. |
double |
getEpsilon()
Returns the current epsilon value. |
int |
getGroupSubChannelRank(java.lang.Object groupId)
Returns the sub-channel rank for the specified edge group within the channel. |
int |
getSubChannelCount()
Returns the number of sub-channels (i.e., different coordinates assigned to the edge objects) within this channel. |
int |
getSubChannelRank(java.lang.Object key)
Returns the sub-channel rank of the specified edge object within the channel. |
boolean |
isEpsilonChannelIgnored()
Returns whether or not middle segments with lengths smaller than epsilon
are ignored. |
void |
route()
Routes all added edge objects within the specified channel. |
java.util.Iterator |
segmentKeys()
Returns an iterator over all added keys of edge objects. |
void |
setChannel(double min,
double max,
byte orientation)
Specifies the channel bounds and orientation. |
void |
setEpsilon(double epsilon)
Specifies the current epsilon value. |
void |
setEpsilonChannelIgnored(boolean ignore)
Specifies whether or not middle segments with lengths smaller than epsilon
should be ignored. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte ROUTE_VERTICAL
More precisely, the algorithm calculates the x-coordinates of the vertical middle segments of the added edges.
public static final byte ROUTE_HORIZONTAL
More precisely, the algorithm calculates the y-coordinates of the horizontal middle segments of the added edges.
Constructor Detail |
---|
public ChannelRouter(double min, double max, byte orientation)
ChannelRouter
.
min
- the smallest assignable coordinate within the channelmax
- the largest assignable coordinate within the channelorientation
- the orientation of the channelpublic ChannelRouter(double min, double max)
ChannelRouter
for a channel with horizontal orientation.
min
- the smallest assignable coordinate within the channelmax
- the largest assignable coordinate within the channelMethod Detail |
---|
public void setChannel(double min, double max, byte orientation)
Calling this method removes all previously added elements.
min
- the smallest assignable coordinate within the channelmax
- the largest assignable coordinate within the channelorientation
- the orientation of the channeladdSegment(Object, YPoint, YPoint)
public void addSegment(java.lang.Object key, YPoint p1, YPoint p2)
p1
and p2
to the set of elements that should be routed within the channel.
key
- the unique id of the edgep1
- the first endpoint of the edgep2
- the second endpoint of the edgepublic void addGroupSegment(java.lang.Object key, java.lang.Object groupId, YPoint p1, YPoint p2)
key
- the unique id of the edgegroupId
- the id of the edge groupp1
- the first endpoint of the edgep2
- the second endpoint of the edgepublic java.util.Iterator segmentKeys()
added keys
of edge objects.
It also contains keys for grouped edges added with addGroupSegment(Object, Object, YPoint, YPoint)
.
added keys
of edge objectspublic boolean containsKey(java.lang.Object key)
key
- the key used during adding
true
if the key has already been registered, false
otherwisepublic boolean containsGroupKey(java.lang.Object groupId)
groupId
- the group id used during adding
true
if the key has already been registered, false
otherwisepublic void route()
The resulting sub-channels can then be queried using method getSubChannelRank(Object)
, while the exact
coordinates can be queried with method getCoord(Object)
.
addSegment(Object, YPoint, YPoint)
,
addGroupSegment(Object, Object, YPoint, YPoint)
public double getCoord(java.lang.Object key)
key
- the key used during adding
the edge object
addSegment(Object, YPoint, YPoint)
public int getSubChannelCount()
A return value of 0
indicates that there are no sub-channels present.
public int getSubChannelRank(java.lang.Object key)
coordinate
of an edge object increases with increasing sub-channel rank.
Edge objects assigned to the same sub-channel rank are placed on the same coordinate.key
- the key used during adding
the edge object
getSubChannelCount()
,
addSegment(Object, YPoint, YPoint)
public int getGroupSubChannelRank(java.lang.Object groupId)
groupId
- the group id used during adding
an edge object
getSubChannelCount()
,
addGroupSegment(Object, Object, YPoint, YPoint)
public boolean isEpsilonChannelIgnored()
epsilon
are ignored.
true
if middle segments with length smaller than epsilon are ignored,
false
otherwisesetEpsilon(double)
,
setEpsilonChannelIgnored(boolean)
public void setEpsilonChannelIgnored(boolean ignore)
epsilon
should be ignored.
ignore
- true
if middle segments with length smaller than epsilon should be ignored,
false
otherwisesetEpsilon(double)
public double getEpsilon()
If option setEpsilonChannelIgnored(boolean)
is enabled, middle segments with length smaller than this value
are ignored.
setEpsilonChannelIgnored(boolean)
,
setEpsilon(double)
public void setEpsilon(double epsilon)
If option setEpsilonChannelIgnored(boolean)
is enabled, middle segments with length smaller than this value
are ignored.
epsilon
- the epsilon valuesetEpsilonChannelIgnored(boolean)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |