Search this API

y.layout
Class PortConstraint

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

public class PortConstraint
extends Object
implements PortConstraintKeys

This class represents a constraint for either a source or target port of an edge. Objects of type PortConstraint are expected to be returned by data providers that are registered by the keys defined in the interface PortConstraintKeys.

A port constraint expresses at what position an edge is allowed to connect to either its source or target node. A weak port constraint limits the position of the port to a particular side of a node. Additionally, a strong port constraint fixes the position of the port completely to the position of the current port coordinates.

For example, PortConstraint p = PortConstraint.create(PortConstraint.NORTH) expresses that an edge should connect at the north side of a node. It is a weak constraint. On the other hand p = PortConstraint.create(PortConstraint.NORTH, true) expresses that an edge should not only connect at the north side of a node but also should use the current port coordinates. This is a strong constraint.


Field Summary
static byte ANY_SIDE
          Weak constraint specifier.
static byte EAST
          Weak constraint specifier.
static byte NORTH
          Weak constraint specifier.
static byte SOUTH
          Weak constraint specifier.
static byte WEST
          Weak constraint specifier.
 
Fields inherited from interface y.layout.PortConstraintKeys
SOURCE_GROUPID_KEY, SOURCE_PORT_CONSTRAINT_KEY, TARGET_GROUPID_KEY, TARGET_PORT_CONSTRAINT_KEY
 
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 port constraint.
static PortConstraint create(byte side, boolean strong)
          Creates a port constraint.
 boolean equals(Object other)
          Tests for equality based on the strong attribute and the side attribute.
 byte getSide()
          Returns the side of a node at which a port should connect.
static PortConstraint getSPC(LayoutGraph graph, Edge e)
          Returns the source port constraint associated with the given edge.
static PortConstraint getTPC(LayoutGraph graph, Edge e)
          Returns the target port constraint associated with the given edge.
 int hashCode()
           
static boolean hasPC(LayoutGraph graph, Edge e)
          Returns whether or not there are non-trivial source or target port constraints associated with the given edge.
static boolean hasSPC(LayoutGraph graph, Edge e)
          Returns whether or not there is a non-trivial source port constraint associated with the given edge.
static boolean hasTPC(LayoutGraph graph, Edge e)
          Returns whether or not there is a non-trivial target port constraint associated with the given edge.
 boolean isAtAnySide()
          Returns whether or not this port constraint has the weak constraint side ANY_SIDE associated with it.
 boolean isAtEast()
          Returns whether or not this port constraint has the weak constraint side EAST associated with it.
 boolean isAtNorth()
          Returns whether or not this port constraint has the weak constraint side NORTH associated with it.
 boolean isAtSouth()
          Returns whether or not this port constraint has the weak constraint side SOUTH associated with it.
 boolean isAtWest()
          Returns whether or not this port constraint has the weak constraint side WEST associated with it.
 boolean isStrong()
          Returns true if this PortConstraint represents a strong constraint and false otherwise.
 String toString()
          Returns a string representation of this object.
 
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
Weak constraint specifier. Indicates that any side of the node will do for the port direction.

See Also:
Constant Field Values

NORTH

public static final byte NORTH
Weak constraint specifier. Indicates that a port has to connect at the north side (i.e. top side) of a node.

See Also:
Constant Field Values

SOUTH

public static final byte SOUTH
Weak constraint specifier. Indicates that a port has to connect at the south side (i.e. bottom side) of a node.

See Also:
Constant Field Values

EAST

public static final byte EAST
Weak constraint specifier. Indicates that a port has to connect at the east side (i.e. right side) of a node.

See Also:
Constant Field Values

WEST

public static final byte WEST
Weak constraint specifier. Indicates that a port has to connect at the west side (i.e. left side) of a node.

See Also:
Constant Field Values
Constructor Detail

PortConstraint

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

Creates the empty constraint, that allows ports to connect at any side of a node.


PortConstraint

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

Creates the weak constraint, that allows ports to connect to a specific side of a node.

Parameters:
side - weak constraint specifier. One of ANY_SIDE, NORTH, SOUTH, EAST or WEST.

PortConstraint

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

Creates a constraint, that allows ports to connect to a specific side of a node.

Parameters:
side - weak constraint specifier. One of ANY_SIDE, NORTH, SOUTH, EAST or WEST.
strong - whether the layouter should use the current port coordinates (strong constraint)
Method Detail

isStrong

public boolean isStrong()
Returns true if this PortConstraint represents a strong constraint and false otherwise.


getSide

public byte getSide()
Returns the side of a node at which a port should connect.

Returns:
One of ANY_SIDE, NORTH, SOUTH, EAST or WEST.

isAtNorth

public boolean isAtNorth()
Returns whether or not this port constraint has the weak constraint side NORTH associated with it.


isAtSouth

public boolean isAtSouth()
Returns whether or not this port constraint has the weak constraint side SOUTH associated with it.


isAtEast

public boolean isAtEast()
Returns whether or not this port constraint has the weak constraint side EAST associated with it.


isAtWest

public boolean isAtWest()
Returns whether or not this port constraint has the weak constraint side WEST associated with it.


isAtAnySide

public boolean isAtAnySide()
Returns whether or not this port constraint has the weak constraint side ANY_SIDE associated with it.


hasPC

public static boolean hasPC(LayoutGraph graph,
                            Edge e)
Returns whether or not there are non-trivial source or target port constraints associated with the given edge. The data provider keys PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY and PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY are used to lookup the data providers in the given graph.


hasSPC

public static boolean hasSPC(LayoutGraph graph,
                             Edge e)
Returns whether or not there is a non-trivial source port constraint associated with the given edge. The data provider key PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY is used to lookup the source port constraint data provider in the given graph.


hasTPC

public static boolean hasTPC(LayoutGraph graph,
                             Edge e)
Returns whether or not there is a non-trivial target port constraint associated with the given edge. The data provider key PortConstraintKeys.TARGET_PORT_CONSTRAINT_KEY is used to lookup the source port constraint data provider in the given graph.


getSPC

public static PortConstraint getSPC(LayoutGraph graph,
                                    Edge e)
Returns the source port constraint associated with the given edge. The data provider key PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY is used to lookup the source port constraint data provider in the given graph.


getTPC

public static PortConstraint getTPC(LayoutGraph graph,
                                    Edge e)
Returns the target port constraint associated with the given edge. The data provider key PortConstraintKeys.SOURCE_PORT_CONSTRAINT_KEY is used to lookup the source port constraint data provider in the given graph.


create

public static PortConstraint create(byte side)
Creates a weak port constraint.

Parameters:
side - One of ANY_SIDE, NORTH, SOUTH, EAST or WEST.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Tests for equality based on the strong attribute and the side attribute.

Overrides:
equals in class Object

create

public static PortConstraint create(byte side,
                                    boolean strong)
Creates a port constraint. The boolean value defines whether it is a strong or weak one.

Parameters:
side - One of ANY_SIDE, NORTH, SOUTH, EAST or WEST.
strong - defines whether it is a strong or weak PortConstraint.

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

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