Search this API

y.layout
Class PortConstraint

java.lang.Object
  extended by y.layout.PortConstraint
All Implemented Interfaces:
PortConstraintKeys

public class PortConstraint
extends java.lang.Object
implements PortConstraintKeys

A PortConstraint represents a constraint for the source or target port of an edge path.

It determines the location at which an edge path can be connected to its source and/or target node. There exist two different types of PortConstraints:


Sample output of weak port constraints. For both edges, source port constraints are associated with side EAST while target port constraints are associated with side WEST. Red rectangles indicate that edges can be connected to any point of these sides. Black rectangles represent the selected ports.

Sample output of strong port constraints. For both edges, source port constraints are associated with side EAST while target port constraints are associated with side WEST. Black rectangles indicate the exact points on the corresponding sides of the nodes to which edges can be connected.

Information about PortConstraints is held by DataProviders that are registered with the graph using keys PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY (to specify PortConstraints for an edge on its source node) and PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY (to specify PortConstraints for an edge on its target node).

Not all layout and routing algorithms are able to handle PortConstraints. Major layout algorithms that obey them are IncrementalHierarchicLayouter, GenericTreeLayouter, EdgeRouter, OrthogonalEdgeRouter, ChannelEdgeRouter and BusRouter.

 
PortCandidateAssignmentStage can be appended to any layout algorithm that cannot handle port constraints in order to assign edges to the ports specified by PortConstraints or PortCandidates after calling the core layout algorithm.
 
In case that both PortConstraints and PortCandidates (on edges and/or nodes) are defined for a graph, the layout or the routing algorithm will try to match both of them in order to find an appropriate port. The matching process depends on the actual algorithm.
See Also:
PortConstraintKeys
 

Field Summary
static byte ANY_SIDE
          A weak constraint indicating that edges can connect to any side of a node.
static byte EAST
          A weak constraint indicating that edges can connect to the east side (right side) of a node.
static byte NORTH
          A weak constraint indicating that edges can connect to the north side (top side) of a node.
static byte SOUTH
          A weak constraint indicating that edges can connect to the south side (bottom side) of a node.
static byte WEST
          A weak constraint indicating that edges can connect to the west side (left side) of a node.
 
Fields inherited from interface y.layout.PortConstraintKeys
SOURCE_GROUPID_KEY, SOURCE_PORT_CONSTRAINT_KEY, SOURCE_PORT_GROUP_ID_DPKEY, TARGET_GROUPID_KEY, TARGET_PORT_CONSTRAINT_KEY, TARGET_PORT_GROUP_ID_DPKEY
 
Constructor Summary
PortConstraint()
          Deprecated. Use the factory method create(byte) instead.
PortConstraint(byte side)
          Deprecated. Use the factory method create(byte) instead.
PortConstraint(byte side, boolean strong)
          Deprecated. Use the factory method create(byte, boolean) instead.
 
Method Summary
static PortConstraint create(byte side)
          Creates a weak PortConstraint that constrains the edge to connect to the given side of a node.
static PortConstraint create(byte side, boolean strong)
          Creates a new PortConstraint that constrains the edge to connect to the given side of a node and that can be either strong or weak.
 boolean equals(java.lang.Object other)
          Returns whether or not this PortConstraint is equal to another PortConstraint based on whether they are both strong constraints or not and the side attribute.
 byte getSide()
          Returns the side of the node to which an edge should connect.
static PortConstraint getSPC(LayoutGraph graph, Edge e)
          Returns the source PortConstraint associated with the given edge.
static PortConstraint getTPC(LayoutGraph graph, Edge e)
          Returns the target PortConstraint associated with the given edge.
 int hashCode()
          Returns a hash code value for this PortConstraint instance based on whether it is a strong constraint or not and the side attribute.
static boolean hasPC(LayoutGraph graph, Edge e)
          Checks whether or not there exist source or target PortConstraints associated with the given edge.
static boolean hasSPC(LayoutGraph graph, Edge e)
          Checks whether or not there exist source PortConstraints associated with the given edge.
static boolean hasTPC(LayoutGraph graph, Edge e)
          Checks whether or not there exist target PortConstraints associated with the given edge.
 boolean isAtAnySide()
          Returns whether or not this PortConstraint instance is associated with side ANY_SIDE.
 boolean isAtEast()
          Returns whether or not this PortConstraint instance is associated with side EAST.
 boolean isAtNorth()
          Returns whether or not this PortConstraint instance is associated with side NORTH.
 boolean isAtSouth()
          Returns whether or not this PortConstraint instance is associated with side SOUTH.
 boolean isAtWest()
          Returns whether or not this PortConstraint instance is associated with side WEST.
 boolean isStrong()
          Returns whether or not this PortConstraint instance represents a strong constraint.
 java.lang.String toString()
          Returns a String representation of this PortConstraint instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY_SIDE

public static final byte ANY_SIDE
A weak constraint indicating that edges can connect to any side of a node.

See Also:
create(byte), create(byte, boolean), Constant Field Values

NORTH

public static final byte NORTH
A weak constraint indicating that edges can connect to the north side (top side) of a node.

See Also:
create(byte), create(byte, boolean), Constant Field Values

SOUTH

public static final byte SOUTH
A weak constraint indicating that edges can connect to the south side (bottom side) of a node.

See Also:
create(byte), create(byte, boolean), Constant Field Values

EAST

public static final byte EAST
A weak constraint indicating that edges can connect to the east side (right side) of a node.

See Also:
create(byte), create(byte, boolean), Constant Field Values

WEST

public static final byte WEST
A weak constraint indicating that edges can connect to the west side (left side) of a node.

See Also:
create(byte), create(byte, boolean), Constant Field Values
Constructor Detail

PortConstraint

public PortConstraint()
Deprecated. Use the factory method create(byte) instead.

Creates a new weak PortConstraint instance that allows ports to connect to any side of a node.

A weak PortConstraint determines the side of the node to which an edge should be connected.


PortConstraint

public PortConstraint(byte side)
Deprecated. Use the factory method create(byte) instead.

Creates a new weak PortConstraint instance that allows ports to connect to a specific side of a node.

A weak PortConstraint determines the side of the node to which an edge should be connected.

Parameters:
side - one of the default side specifiers

PortConstraint

public PortConstraint(byte side,
                      boolean strong)
Deprecated. Use the factory method create(byte, boolean) instead.

Creates a new (strong or weak) PortConstraint instance that allows ports to connect to a specific side of a node.

If the PortConstraint is strong, the layout or routing algorithm should use the port coordinates of this constraint.

Parameters:
side - one of the default side specifiers
strong - true if the PortConstraint represents a strong constraint, false otherwise
Method Detail

isStrong

public boolean isStrong()
Returns whether or not this PortConstraint instance represents a strong constraint.

A strong PortConstraint determines the exact coordinates where the edge path's end should be located.

Returns:
true if this PortConstraint is strong, false if it is a weak one

getSide

public byte getSide()
Returns the side of the node to which an edge should connect.

Returns:
one of the default side specifiers

isAtNorth

public boolean isAtNorth()
Returns whether or not this PortConstraint instance is associated with side NORTH.

Returns:
true if the associated side is NORTH, false otherwise

isAtSouth

public boolean isAtSouth()
Returns whether or not this PortConstraint instance is associated with side SOUTH.

Returns:
true if the associated side is SOUTH, false otherwise

isAtEast

public boolean isAtEast()
Returns whether or not this PortConstraint instance is associated with side EAST.

Returns:
true if the associated side is EAST, false otherwise

isAtWest

public boolean isAtWest()
Returns whether or not this PortConstraint instance is associated with side WEST.

Returns:
true if the associated side is WEST, false otherwise

isAtAnySide

public boolean isAtAnySide()
Returns whether or not this PortConstraint instance is associated with side ANY_SIDE.

Returns:
true if the associated side is ANY_SIDE, false otherwise

hasPC

public static boolean hasPC(LayoutGraph graph,
                            Edge e)
Checks whether or not there exist source or target PortConstraints associated with the given edge.

To retrieve the DataProviders that hold information about source or target PortConstraints, keys PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY and PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY are used.

 
A weak PortConstraint that allows any side is not considered to be a real constraint and ignored during this check.
Parameters:
graph - the input graph
e - the edge
Returns:
true if the edge has source or target PortConstraints, false otherwise

hasSPC

public static boolean hasSPC(LayoutGraph graph,
                             Edge e)
Checks whether or not there exist source PortConstraints associated with the given edge.

To retrieve the DataProvider that holds information about source PortConstraints, key PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY is used.

 
A weak PortConstraint that allows any side is not considered to be a real constraint and ignored during this check.
Parameters:
graph - the input graph
e - the edge
Returns:
true if the edge has source PortConstraints, false otherwise

hasTPC

public static boolean hasTPC(LayoutGraph graph,
                             Edge e)
Checks whether or not there exist target PortConstraints associated with the given edge.

To retrieve the DataProvider that holds information about target PortConstraints, key PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY is used.

 
A weak PortConstraint that allows any side is not considered to be a real constraint and ignored during this check.
Parameters:
graph - the input graph
e - the edge
Returns:
true if the edge has target PortConstraints, false otherwise

getSPC

public static PortConstraint getSPC(LayoutGraph graph,
                                    Edge e)
Returns the source PortConstraint associated with the given edge.

To retrieve the DataProvider that holds information about source PortConstraints, key PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY is used.

Parameters:
graph - the input graph
e - the edge
Returns:
the source PortConstraint of the given edge or null if there is none

getTPC

public static PortConstraint getTPC(LayoutGraph graph,
                                    Edge e)
Returns the target PortConstraint associated with the given edge.

To retrieve the DataProvider that holds information about target PortConstraints, key PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY is used.

Parameters:
graph - the input graph
e - the edge
Returns:
the target PortConstraint of the given edge or null if there is none

create

public static PortConstraint create(byte side)
Creates a weak PortConstraint that constrains the edge to connect to the given side of a node.

Parameters:
side - one of the default side specifiers
Returns:
a new weak PortConstraint

hashCode

public int hashCode()
Returns a hash code value for this PortConstraint instance based on whether it is a strong constraint or not and the side attribute.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value

equals

public boolean equals(java.lang.Object other)
Returns whether or not this PortConstraint is equal to another PortConstraint based on whether they are both strong constraints or not and the side attribute.

Overrides:
equals in class java.lang.Object
Parameters:
other - the reference PortConstraint object with which to compare
Returns:
true if this PortConstraint is equal to the given PortConstraint argument, false otherwise

create

public static PortConstraint create(byte side,
                                    boolean strong)
Creates a new PortConstraint that constrains the edge to connect to the given side of a node and that can be either strong or weak.

If the PortConstraint is strong, port constraint aware layout algorithms keep the current source/target point location as returned by method LayoutGraph.getSourcePointRel(Edge) and LayoutGraph.getTargetPointRel(Edge) respectively.

Parameters:
side - one of the default side specifiers
strong - true if this PortConstraint is strong, false otherwise
Returns:
a new PortConstraint instance
Throws:
java.lang.IllegalArgumentException - if an unknown side is given

toString

public java.lang.String toString()
Returns a String representation of this PortConstraint instance.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the PortConstraint

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