public class PortCalculator extends AbstractLayoutStage implements ILayoutStage
PortCalculator
adjusts the final port assignments after a layout has been calculated.
This can be useful if the port assignment calculated by the layout algorithm is insufficient. This stage uses IDataProvider
instances registered with the graph using the keys defined in the IIntersectionCalculator
interface to calculate
the new port offsets.
For each edge in the graph, IIntersectionCalculator
s are retrieved from these IDataProvider
s. If such an
IIntersectionCalculator
is assigned, it will provide the intersection point of the edge and the node. Then
this point is added to the IEdgeLayout
.
For this layout stage to work properly, use CompositeLayoutStage.prependStage(ILayoutStage)
or MultiStageLayout.prependStage(ILayoutStage)
to add this layout stage and register appropriate IDataProvider
s with the graph using the keys defined in
IIntersectionCalculator
.
Note that this class will not change the coordinates of a port if it is associated with a strong port constraint.
Modifier and Type | Field and Description |
---|---|
protected double |
Eps
EPSILON used by
equalsEps(double, double, double, double) . |
Constructor and Description |
---|
PortCalculator()
Creates a new
PortCalculator instance with an optional
core layout algorithm . |
Modifier and Type | Method and Description |
---|---|
void |
applyLayout(LayoutGraph graph)
Adjusts the ports after invoking the
core layout algorithm . |
protected void |
calculatePorts(LayoutGraph graph)
Performs the actual port calculation on the specified graph instance.
|
protected boolean |
equalsEps(double x1,
double y1,
double x2,
double y2)
Determines whether two points are equal.
|
applyLayoutCore, getCoreLayout, setCoreLayout
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCoreLayout, setCoreLayout
protected double Eps
equalsEps(double, double, double, double)
.
By default this is 0.2d
.
public PortCalculator()
PortCalculator
instance with an optional
core layout algorithm
.public void applyLayout(LayoutGraph graph)
core layout algorithm
.applyLayout
in interface ILayoutAlgorithm
applyLayout
in class AbstractLayoutStage
graph
- the input graphprotected void calculatePorts(LayoutGraph graph)
graph
- the input graphprotected boolean equalsEps(double x1, double y1, double x2, double y2)
This implementation uses Eps
to add some tolerance to the comparison. It is called by calculatePorts(LayoutGraph)
and may be overridden to change the accuracy/tolerance of the comparison.
x1
- the x-coordinate of the first pointy1
- the y-coordinate of the first pointx2
- the x-coordinate of the second pointy2
- the y-coordinate of the second pointtrue
if both points are considered equal, false
otherwisecalculatePorts(LayoutGraph)
,
Eps