|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.hierarchic.incremental.DefaultPortAllocator
public class DefaultPortAllocator
This class is a default PortAllocator
implementation.
It is used by HierarchicLayouter
after the sequencing phase.
Constructor Summary | |
---|---|
DefaultPortAllocator()
Creates a new instance of DefaultPortAllocator with default settings. |
Method Summary | |
---|---|
void |
assignPorts(LayoutGraph graph,
Layers layers,
LayoutDataProvider ldp,
ItemFactory itemFactory)
Assigns source and target port coordinates to each edge of the graph. |
double |
getDefaultPortBorderGapRatio()
Returns the border gap ratio for the default port. |
protected double |
getPortBorderGap(LayoutGraph graph,
LayoutDataProvider ldp,
Node node,
int sideIndex,
double sideLength,
int edgeCount)
Callback method used for determining the port border gap for each node and side. |
protected double |
getPortBorderGapRatio(LayoutGraph graph,
LayoutDataProvider ldp,
Node node,
int sideIndex,
double sideLength,
int edgeCount)
Callback method used for determining the port border gap ratio. |
protected double |
getPortDistanceDelta(LayoutGraph graph,
LayoutDataProvider ldp,
Node node,
int sideIndex,
double sideLength,
int edgeCount,
double portBorderGap)
Callback method used for determining the distance between two adjacent ports. |
boolean |
isFixedPortConsiderationEnabled()
Returns whether or not this PortAllocator considers edges with strong PortConstraint s
or fixed PortCandidate . |
void |
setDefaultPortBorderGapRatio(double defaultPortBorderGapRatio)
Specifies the border gap ratio for the default port. |
void |
setFixedPortConsiderationEnabled(boolean considerStrongPorts)
Specifies whether or not this PortAllocator considers edges with strong PortConstraint s
or fixed PortCandidate . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultPortAllocator()
DefaultPortAllocator
with default settings.
setDefaultPortBorderGapRatio(double)
Method Detail |
---|
public boolean isFixedPortConsiderationEnabled()
PortAllocator
considers edges with strong PortConstraint
s
or fixed PortCandidate
.
If these edges are ignored, the ports of the other edges are uniformly distributed on the sides of the nodes which may lead to intersections with the ignored edges. On the other hand, if these edges are considered, the port assignment of the other edges may no longer be uniform.
true
if the port allocator takes edges with strong/fixed ports into account,
false
otherwisesetFixedPortConsiderationEnabled(boolean)
public void setFixedPortConsiderationEnabled(boolean considerStrongPorts)
PortAllocator
considers edges with strong PortConstraint
s
or fixed PortCandidate
.
If these edges are ignored, the ports of the other edges are uniformly distributed on the sides of the nodes which may lead to intersections with the ignored edges. On the other hand, if these edges are considered, the port assignment of the other edges may no longer be uniform.
considerStrongPorts
- true
if the port allocator should take edges with strong/fixed ports
into account, false
otherwisepublic void assignPorts(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
This method assigns:
PortConstraint.ANY_SIDE
ports to appropriate sides.Weak
ports to appropriate positions between strong ones.
This method is called by HierarchicLayouter
after the sequencing phase.
assignPorts
in interface PortAllocator
graph
- the input graphlayers
- the given Layers
instance containing the layering structureldp
- the LayoutDataProvider
containing information about the nodes and edges of the graphitemFactory
- the ItemFactory
used for creating and destroying helper structuresprotected double getPortBorderGap(LayoutGraph graph, LayoutDataProvider ldp, Node node, int sideIndex, double sideLength, int edgeCount)
It may be overridden for a custom calculation of port border gap on a given node.
graph
- the input graphldp
- the LayoutDataProvider
containing information about the nodes and edges of the graphnode
- the given nodesideIndex
- the zero-based (top is 0) clock-wise index of the side of the node (for top-to-bottom layouts)sideLength
- the width/height of the sideedgeCount
- the number of edges/ports that connect to this side
getPortDistanceDelta(LayoutGraph, LayoutDataProvider, Node, int, double, int, double)
protected double getPortDistanceDelta(LayoutGraph graph, LayoutDataProvider ldp, Node node, int sideIndex, double sideLength, int edgeCount, double portBorderGap)
It may be overridden for a custom calculation of the distance between two adjacent ports..
graph
- the input graphldp
- the LayoutDataProvider
containing information about the nodes and edges of the graphnode
- the given nodesideIndex
- the zero-based (top is 0) clock-wise index of the side of the node (for top-to-bottom layouts)sideLength
- the width/height of the sideedgeCount
- the number of edges/ports that connect to this sideportBorderGap
- the previously calculated port border gap
protected double getPortBorderGapRatio(LayoutGraph graph, LayoutDataProvider ldp, Node node, int sideIndex, double sideLength, int edgeCount)
See setDefaultPortBorderGapRatio(double)
for an explanation.
It may be overridden for a custom calculation of port border gap ratio on a given node.
NodeLayoutDescriptor
instance registered for the given node, this implementation
returns the same value as NodeLayoutDescriptor.getPortBorderGapRatio(int)
. Else, returns the
same value as getDefaultPortBorderGapRatio()
.graph
- the input graphldp
- the LayoutDataProvider
containing information about the nodes and edges of the graphnode
- the given nodesideIndex
- the zero-based (top is 0) clock-wise index of the side of the node (for top-to-bottom layouts)sideLength
- the width/height of the sideedgeCount
- the number of edges/ports that connect to this side
public double getDefaultPortBorderGapRatio()
This ratio determines the gap between a corner of the node and the first assigned port.
The ratio should be greater than 0
.
A value of 0.0d
results in ports being placed directly on the corner of the node (if there is more
than one port).
A value of 0.5d
results in ports being distributed along the side of the node so that the
distance between the corner of the node and the first port is half as wide as the distance between two adjacent
ports.
A value of Double.POSITIVE_INFINITY
results in all ports being centered at the side in one point.
setDefaultPortBorderGapRatio(double)
public void setDefaultPortBorderGapRatio(double defaultPortBorderGapRatio)
This ratio determines the gap between a corner of the node and the first assigned port.
The ratio should be greater than 0
.
A value of 0.0d
results in ports being placed directly on the corner of the node (if there is more
than one port).
A value of 0.5d
results in ports being distributed along the side of the node so that the
distance between the corner of the node and the first port is half as wide as the distance between two adjacent
ports.
A value of Double.POSITIVE_INFINITY
results in all ports being centered at the side in one point.
defaultPortBorderGapRatio
- the given border gap ratio
java.lang.IllegalArgumentException
- if the given ratio is negativePort border gap ratio 0.0d - node 1 has port constraint PortConstraint.SOUTH while nodes
2,3,4 have port constraints PortConstraint.NORTH . | Port border gap ratio 0.5d - node 1 has port constraint PortConstraint.SOUTH while nodes
2,3,4 have port constraints PortConstraint.NORTH . | Port border gap ratio Double.POSITIVE_INFINITY - node 1 has port constraint PortConstraint.SOUTH while nodes
2,3,4 have port constraints PortConstraint.NORTH . |
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |