y.layout
Class PortConstraint

java.lang.Object
  |
  +--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. Additionlly a strong port constraint fixes the position of port completely to the position of the original port coordinates

For example, PortConstraint p = new PortConstraint(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 = new PortConstraint(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. It 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()
          Creates the empty constraint, that allows ports to connect at any side of a node.
PortConstraint(byte side)
          Creates the weak constraint, that allows ports to connect to a specific side of a node.
PortConstraint(byte side, boolean strong)
          Creates a constraint, that allows ports to connect to a specific side of a node.
 
Method Summary
static PortConstraint create(byte side)
          Creates a weak port constraint.
static PortConstraint create(byte side, boolean strong)
          Creates a weak port constraint.
 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 constaint associated with the given edge.
static PortConstraint getTPC(LayoutGraph graph, Edge e)
          Returns the source port constaint associated with the given edge.
static boolean hasPC(LayoutGraph graph, Edge e)
          Returns whether or not there are non-trivial source or target port constaints associated with the given edge.
static boolean hasSPC(LayoutGraph graph, Edge e)
          Returns whether or not there is a non-trivial source port constaint associated with the given edge.
static boolean hasTPC(LayoutGraph graph, Edge e)
          Returns whether or not there is a non-trivial target port constaint associated with the given edge.
 boolean isAtAnySide()
          Returns whether or not this port constaint has has the weak constraint side PortConstraint.ANY_SIDE associated with it.
 boolean isAtEast()
          Returns whether or not this port constaint has has the weak constraint side PortConstraint.EAST associated with it.
 boolean isAtNorth()
          Returns whether or not this port constaint has has the weak constraint side PortConstraint.NORTH associated with it.
 boolean isAtSouth()
          Returns whether or not this port constaint has has the weak constraint side PortConstraint.SOUTH associated with it.
 boolean isAtWest()
          Returns whether or not this port constaint has has the weak constraint side PortConstraint.WEST associated with it.
 boolean isStrong()
          getter for strong property
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, 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()
Creates the empty constraint, that allows ports to connect at any side of a node.


PortConstraint

public PortConstraint(byte side)
Creates the weak constraint, that allows ports to connect to a specific side of a node.

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

PortConstraint

public PortConstraint(byte side,
                      boolean strong)
Creates a constraint, that allows ports to connect to a specific side of a node.

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

isStrong

public boolean isStrong()
getter for strong property


getSide

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

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

isAtNorth

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


isAtSouth

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


isAtEast

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


isAtWest

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


isAtAnySide

public boolean isAtAnySide()
Returns whether or not this port constaint has has the weak constraint side PortConstraint.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 constaints 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 constaint 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 constaint 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 constaint 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 source port constaint 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 PortConstraint.ANY_SIDE, PortConstraint.NORTH, PortConstraint.SOUTH, PortConstraint.EAST or PortConstraint.WEST.

create

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

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

toString

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

Overrides:
toString in class Object

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

2003