|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.tree.DefaultPortAssignment
public class DefaultPortAssignment
The DefaultPortAssignment
provides some simple port assignment styles
.
Ports are either centered
on the node, distributed at one side of the node or placed considering
PortConstraint
s.
Field Summary | |
---|---|
static byte |
MODE_NONE
A port assignment specifier which defines that all ports are reset to the center of their nodes. |
static byte |
MODE_PORT_CONSTRAINTS
A port assignment specifier that defines that PortConstraint s are considered. |
static byte |
MODE_PORT_DISTRIBUTED_EAST
A port assignment specifier which defines that edges are distributed evenly at the eastern side of their nodes. |
static byte |
MODE_PORT_DISTRIBUTED_NORTH
A port assignment specifier which defines that edges are distributed evenly at the northern side of their nodes. |
static byte |
MODE_PORT_DISTRIBUTED_SOUTH
A port assignment specifier which defines that edges are distributed evenly at the southern side of their nodes. |
static byte |
MODE_PORT_DISTRIBUTED_WEST
A port assignment specifier which defines that edges are distributed evenly at the western side of their nodes. |
Constructor Summary | |
---|---|
DefaultPortAssignment()
Creates a new DefaultPortAssignment instance with default settings. |
|
DefaultPortAssignment(byte mode)
Creates a new DefaultPortAssignment instance using the given port assignment mode . |
|
DefaultPortAssignment(byte mode,
double ratio)
Creates a new DefaultPortAssignment instance using the given port assignment mode and ratio between the
border and the ports and the gap between the ports themselves. |
Method Summary | |
---|---|
protected void |
assignChildEdgeSourcePort(LayoutGraph graph,
Node node,
Edge edge,
int index)
Assigns relative coordinates to the source port of the outgoing edge to a child of the given node. |
protected void |
assignParentEdgeTargetPort(LayoutGraph graph,
Node node,
Edge edge)
Assigns relative coordinates to the target port of the incoming edge from the parent of the given node. |
void |
assignPorts(LayoutGraph graph,
Node node)
Places the ports of edges connecting to the given node according to the port assignment mode . |
double |
getBorderGapToPortGapRatio()
Returns the ratio of the border gap (distance between the outer ports to the node border) to the port gap (distance between adjacent ports). |
byte |
getMode()
Returns the mode that describes how ports are placed. |
protected double |
getPortBorderGap(double sideLength,
int edgeCount)
Determines the distance between the outer ports and the border of the node. |
protected double |
getPortDistanceDelta(double sideLength,
int edgeCount,
double portBorderGap)
Determines the distance between two adjacent ports. |
protected PortConstraint |
getSourcePortConstraint(LayoutGraph graph,
Edge edge,
int index)
Retrieves the source PortConstraint for the given edge. |
protected PortConstraint |
getTargetPortConstraint(LayoutGraph graph,
Edge edge)
Retrieves the target PortConstraint for the given edge. |
boolean |
isReversedPortOrder()
Returns whether or not the port assignment should reverse the order of the ports. |
void |
setBorderGapToPortGapRatio(double borderGapToPortGapRatio)
Specifies the ratio of the border gap (distance between the outer ports to the node border) to the port gap (distance between adjacent ports). |
void |
setMode(byte mode)
Specifies the mode that describes how ports are placed. |
void |
setReversedPortOrder(boolean reversedPortOrder)
Specifies whether or not the port assignment should reverse the order of the ports. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final byte MODE_PORT_CONSTRAINTS
PortConstraint
s are considered.
Ports are placed using the following rules:
PortConstraint
are anchored at the center of the nodePortConstraint
are anchored at the center of their specified sidePortConstraint
are anchored at their initial coordinates
If edges with PortConstraint
s are grouped, all edges in the same group will use the port coordinates of
the first edge in the group.
public static final byte MODE_PORT_DISTRIBUTED_NORTH
Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.
public static final byte MODE_PORT_DISTRIBUTED_SOUTH
Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.
public static final byte MODE_PORT_DISTRIBUTED_EAST
Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.
public static final byte MODE_PORT_DISTRIBUTED_WEST
Grouped edges will use the same port coordinate and will be considered as a single edge when calculating the distribution.
public static final byte MODE_NONE
Constructor Detail |
---|
public DefaultPortAssignment()
DefaultPortAssignment
instance with default settings.
public DefaultPortAssignment(byte mode)
DefaultPortAssignment
instance using the given port assignment mode
.
mode
- one of the predefined port assignment specifiers
java.lang.IllegalArgumentException
- if an unknown mode is specifiedpublic DefaultPortAssignment(byte mode, double ratio)
DefaultPortAssignment
instance using the given port assignment mode and ratio between the
border and the ports and the gap between the ports themselves.
mode
- one of the predefined port assignment specifiersratio
- the ratio of the distance between outer ports and the border to the distance between any two ports
java.lang.IllegalArgumentException
- if an unknown mode is specified or if the specified ratio is negativeMethod Detail |
---|
public void assignPorts(LayoutGraph graph, Node node)
port assignment mode
.
assignPorts
in interface PortAssignment
graph
- the input graphnode
- the node whose adjacent edges' ports should be placedgetMode()
protected void assignParentEdgeTargetPort(LayoutGraph graph, Node node, Edge edge)
This method is called by assignPorts(LayoutGraph, Node)
if the given node has a parent node.
It may be overridden to assign a custom location to the target port of the incoming edge.
PortConstraint
s despite the port assignment mode
.graph
- the input graphnode
- the nodeedge
- the edge from the parent nodeEdgeLayout.setTargetPoint(YPoint)
protected void assignChildEdgeSourcePort(LayoutGraph graph, Node node, Edge edge, int index)
This method is called by assignPorts(LayoutGraph, Node)
for each outgoing edge of the given node.
It may be overridden to assign a custom location to the source port of outgoing edges.
PortConstraint
s despite the port assignment mode
.graph
- the input graphnode
- the nodeedge
- the edge to the child nodeindex
- the zero-based index of the child edgeEdgeLayout.setSourcePoint(YPoint)
protected double getPortBorderGap(double sideLength, int edgeCount)
This implementation calculates the gap according to the number of edges at one side of the node. It also includes
the ratio between border gap and port gap
.
This method is called by assignChildEdgeSourcePort(LayoutGraph, Node, Edge, int)
to calculate the
location of the first port. It may be overridden to implement a different distribution of ports on the node's
side.
sideLength
- the width/height of the sideedgeCount
- the number of edges that connect to this side
assignChildEdgeSourcePort(LayoutGraph, Node, Edge, int)
,
getBorderGapToPortGapRatio()
protected double getPortDistanceDelta(double sideLength, int edgeCount, double portBorderGap)
This implementation calculates the gap according to the number of edges at one side of the node. The edges are distributed keeping the given gap to the border of the node.
This method is called by assignChildEdgeSourcePort(LayoutGraph, Node, Edge, int)
to calculate the
distance between two ports. It may be overridden to implement a different distribution of ports on the node's
side.
sideLength
- the width/height of the sideedgeCount
- the number of edges/ports that connect to this sideportBorderGap
- the port border gap (i.e. calculated by getPortBorderGap(double, int)
)
assignChildEdgeSourcePort(LayoutGraph, Node, Edge, int)
,
getPortBorderGap(double, int)
protected PortConstraint getSourcePortConstraint(LayoutGraph graph, Edge edge, int index)
PortConstraint
for the given edge.
This implementation accesses the DataProvider
registered with
PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY
.
This method is called by assignChildEdgeSourcePort(LayoutGraph, Node, Edge, int)
in
MODE_PORT_CONSTRAINTS
.
graph
- the input graphedge
- the edgeindex
- the index of the child that is the target of the given edge
PortConstraint
or null
if no source PortConstraint
is specifiedPortConstraint
,
PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY
,
assignChildEdgeSourcePort(LayoutGraph, Node, Edge, int)
protected PortConstraint getTargetPortConstraint(LayoutGraph graph, Edge edge)
PortConstraint
for the given edge.
This implementation accesses the DataProvider
registered with
PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY
.
This method is called by assignParentEdgeTargetPort(LayoutGraph, Node, Edge)
in
MODE_PORT_CONSTRAINTS
.
graph
- the input graphedge
- the edge
PortConstraint
or null
if no target PortConstraint
is specifiedPortConstraint
,
PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY
,
assignParentEdgeTargetPort(LayoutGraph, Node, Edge)
public byte getMode()
setMode(byte)
public void setMode(byte mode)
MODE_NONE
mode
- one of the predefined port assignment specifiers
java.lang.IllegalArgumentException
- if an unknown mode is specifiedpublic double getBorderGapToPortGapRatio()
The ratio must have a positive value. When the ratio is 0
the ports will be distributed along the
whole side of the node without a gap between the last port and the corner.
MODE_PORT_DISTRIBUTED_NORTH
).setBorderGapToPortGapRatio(double)
public void setBorderGapToPortGapRatio(double borderGapToPortGapRatio)
The ratio must have a positive value. When the ratio is 0
the ports will be distributed along the
whole side of the node without a gap between the last port and the corner.
MODE_PORT_DISTRIBUTED_NORTH
).borderGapToPortGapRatio
- the ratio of the border gap (gap between ports and border) to the port gap (gap between two ports)
java.lang.IllegalArgumentException
- if the specified ratio is negative0.5 | 1 |
public boolean isReversedPortOrder()
The normal order is from left to right and from top to bottom. It will be reversed if this option is enabled.
MODE_PORT_DISTRIBUTED_NORTH
).true
if the order of the ports are reversed, false
otherwisesetReversedPortOrder(boolean)
public void setReversedPortOrder(boolean reversedPortOrder)
The normal order is from left to right and from top to bottom. It will be reversed if this option is enabled.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |