Search this API

y.layout.hierarchic.incremental
Class DefaultPortAllocator

java.lang.Object
  extended by y.layout.hierarchic.incremental.DefaultPortAllocator
All Implemented Interfaces:
PortAllocator

public class DefaultPortAllocator
extends Object
implements PortAllocator

Default implementation of the PortAllocator interface.


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 the port positions for the drawer.
 double getDefaultPortBorderGapRatio()
          Returns the default port to border gap ratio.
protected  double getPortBorderGap(LayoutGraph graph, LayoutDataProvider ldp, Node node, int sideIndex, double sideLength, int edgeCount)
          Callback method used to determine 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 to determine 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 to determine the distance between two adjacent ports
 void setDefaultPortBorderGapRatio(double defaultPortBorderGapRatio)
          Sets for default port to border gap ratio.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultPortAllocator

public DefaultPortAllocator()
Creates a new instance of DefaultPortAllocator with default settings

See Also:
setDefaultPortBorderGapRatio(double)
Method Detail

assignPorts

public void assignPorts(LayoutGraph graph,
                        Layers layers,
                        LayoutDataProvider ldp,
                        ItemFactory itemFactory)
Assigns the port positions for the drawer. Assigns PortConstraint.ANY_SIDE ports to appropriate sides. Assigns weak ports to appropriate positions between strong ones

Specified by:
assignPorts in interface PortAllocator
Parameters:
graph - the graph
layers - the layering
ldp - the LayoutDataProvider that can be used to query information
itemFactory - the ItemFactory that can be used for temporarily altering the graph

getPortBorderGap

protected double getPortBorderGap(LayoutGraph graph,
                                  LayoutDataProvider ldp,
                                  Node node,
                                  int sideIndex,
                                  double sideLength,
                                  int edgeCount)
Callback method used to determine the port border gap for each node and side.

Parameters:
graph - the graph
ldp - the LayoutDataProvider that can be used to query information from
node - the node
sideIndex - 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 side
edgeCount - the number of edges/port that connect to this side
Returns:
the absolute gap to be used on both sides of the ports
See Also:
getPortDistanceDelta(LayoutGraph, LayoutDataProvider, Node, int, double, int, double)

getPortDistanceDelta

protected double getPortDistanceDelta(LayoutGraph graph,
                                      LayoutDataProvider ldp,
                                      Node node,
                                      int sideIndex,
                                      double sideLength,
                                      int edgeCount,
                                      double portBorderGap)
Callback method used to determine the distance between two adjacent ports

Parameters:
graph - the graph
ldp - the LayoutDataProvider that can be used to query information from
node - the node
sideIndex - 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 side
edgeCount - the number of edges/port that connect to this side
portBorderGap - the previously calculated port border gap
Returns:
the absolute distance to be used between two adjacent ports

getPortBorderGapRatio

protected double getPortBorderGapRatio(LayoutGraph graph,
                                       LayoutDataProvider ldp,
                                       Node node,
                                       int sideIndex,
                                       double sideLength,
                                       int edgeCount)
Callback method used to determine the port border gap ratio. See setDefaultPortBorderGapRatio(double) for an explanation. This implementation returns the same value as getDefaultPortBorderGapRatio() does.

Parameters:
graph - the graph
ldp - the LayoutDataProvider that can be used to query information from
node - the node
sideIndex - 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 side
edgeCount - the number of edges/port that connect to this side
Returns:
the ratio

getDefaultPortBorderGapRatio

public double getDefaultPortBorderGapRatio()
Returns the default port to border gap ratio.

Returns:
the ratio
See Also:
setDefaultPortBorderGapRatio(double)

setDefaultPortBorderGapRatio

public void setDefaultPortBorderGapRatio(double defaultPortBorderGapRatio)
Sets for default port to border gap ratio. This ratio determines the gap between a corner of the node and the first assigned port. A value of 0.0d results in ports being placed directly on the corner of the node (if there is more than one port). The default 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.

Parameters:
defaultPortBorderGapRatio - the new ratio

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