Search this API

y.layout
Class PortCandidate

java.lang.Object
  extended by y.layout.PortCandidate

public class PortCandidate
extends Object

This class represents a candidate for an edge's ports. It may be a fixed port, where the exact port coordinates are given or a free variant where the coordinates may be chosen arbitrarily. Additionally valid in- respectively outgoing directions may be specified for edges connecting to that PortCandidate's Port and a cost penalty may be specified that indicates the cost associated with the usage of the port.

See Also:
PortCandidateSet

Field Summary
static int AGAINST_THE_FLOW
          Constant indicating a port lying in the opposite direction of the main flow of the edge or overall layout.
static int ANY
          A bitwise combination of all possible direction constants.
static int EAST
          Constant indicating a port in the east of a node.
static int LEFT_IN_FLOW
          Constant indicating a port lying to the left of the direction of the main flow of the edge or overall layout.
static int NORTH
          Constant indicating a port in the north of a node.
static int RIGHT_IN_FLOW
          Constant indicating a port lying in the right of the direction of the main flow of the edge or overall layout.
static Object SOURCE_PCLIST_DPKEY
          DataProvider key that holds a Collection of PortCandidates for the source port of each edge.
static int SOUTH
          Constant indicating a port in the south of a node.
static Object TARGET_PCLIST_DPKEY
          DataProvider key that holds a Collection of PortCandidates for the target port of each edge.
static int WEST
          Constant indicating a port in the west of a node.
static int WITH_THE_FLOW
          Constant indicating a port lying in the direction of the main flow of the edge or overall layout.
 
Constructor Summary
protected PortCandidate(double xOffset, double yOffset, boolean fixed, int directionMask, double cost)
          Creates a new instance of PortCandidate using the given values.
protected PortCandidate(double xOffset, double yOffset, int directionMask)
          Creates a new instance of PortCandidate using the given values.
protected PortCandidate(int directionMask)
          Creates a new instance of PortCandidate using the given direction.
protected PortCandidate(int directionMask, double cost)
          Creates a new instance of PortCandidate using the given values.
 
Method Summary
static PortCandidate createCandidate(double xOffset, double yOffset, int directionMask)
          Factory method that returns an instance describing a fixed port with zero cost penalty for the given direction at the given offsets.
static PortCandidate createCandidate(double xOffset, double yOffset, int directionMask, double cost)
          Factory method that returns an instance describing a fixed port with the given cost penalty for the given direction at the given offset.
static PortCandidate createCandidate(int directionMask)
          Factory method that returns an instance describing a non-fixed port with 0 cost penalty for the given direction.
static PortCandidate createCandidate(int directionMask, double cost)
          Factory method that returns an instance describing a non-fixed port with the given cost penalty for the given direction.
static PortCandidate createCandidate(PortConstraint fromPortConstraint)
          Factory method that returns an instance describing a non-fixed port with zero cost penalty for the direction specified by the given PortConstraint
 boolean equals(Object other)
          Tests for equality based on the internal attributes.
 double getCost()
          Returns the cost associated with the usage of this PortCandidate.
 int getDirection()
          Returns the direction mask for this instance.
 int getDirectionForLayoutOrientation(byte layoutOrientation)
          Returns the direction constant with respect to the given layout orientation.
 double getXOffset()
          Returns the x offset of the port with respect to the corresponding node's center.
 double getXOffsetForLayoutOrientation(byte layoutOrientation)
          Yields the X-offset with respect for the given layout orientation.
 double getXOffsetForLayoutOrientation(byte layoutOrientation, int mirrorMask)
          Yields the X-offset with respect for the given layout orientation and OrientationLayouter.getMirrorMask() mirror mask}.
 double getYOffset()
          Returns the y offset of the port with respect to the corresponding node's center.
 double getYOffsetForLayoutOrientation(byte layoutOrientation)
          Yields the Y-offset with respect for the given layout orientation.
 double getYOffsetForLayoutOrientation(byte layoutOrientation, int mirrorMask)
          Yields the Y-offset with respect for the given layout orientation and OrientationLayouter.getMirrorMask() mirror mask}.
 int hashCode()
           
 boolean isFixed()
          Returns whether this instance describes a fixed or strong port.
 boolean isInDirection(int directionMask)
          Determines whether this instance lies in the given direction.
 PortConstraint toPortConstraint()
          A utility method for converting this instance to a PortConstraint
 PortConstraint toPortConstraintForLayoutOrientation(byte layoutOrientation)
          A utility method for converting this instance to a PortConstraint interpreted for the given layout orientation.
 String toString()
          Returns a human-readable string representation of this PortCandidate.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NORTH

public static final int NORTH
Constant indicating a port in the north of a node.

See Also:
Constant Field Values

EAST

public static final int EAST
Constant indicating a port in the east of a node.

See Also:
Constant Field Values

WEST

public static final int WEST
Constant indicating a port in the west of a node.

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
Constant indicating a port in the south of a node.

See Also:
Constant Field Values

WITH_THE_FLOW

public static final int WITH_THE_FLOW
Constant indicating a port lying in the direction of the main flow of the edge or overall layout. The exact direction is domain specific.

See Also:
Constant Field Values

AGAINST_THE_FLOW

public static final int AGAINST_THE_FLOW
Constant indicating a port lying in the opposite direction of the main flow of the edge or overall layout. The exact direction is domain specific.

See Also:
Constant Field Values

LEFT_IN_FLOW

public static final int LEFT_IN_FLOW
Constant indicating a port lying to the left of the direction of the main flow of the edge or overall layout. The exact direction is domain specific.

See Also:
Constant Field Values

RIGHT_IN_FLOW

public static final int RIGHT_IN_FLOW
Constant indicating a port lying in the right of the direction of the main flow of the edge or overall layout. The exact direction is domain specific.

See Also:
Constant Field Values

ANY

public static final int ANY
A bitwise combination of all possible direction constants.

See Also:
Constant Field Values

SOURCE_PCLIST_DPKEY

public static final Object SOURCE_PCLIST_DPKEY
DataProvider key that holds a Collection of PortCandidates for the source port of each edge.


TARGET_PCLIST_DPKEY

public static final Object TARGET_PCLIST_DPKEY
DataProvider key that holds a Collection of PortCandidates for the target port of each edge.

Constructor Detail

PortCandidate

protected PortCandidate(double xOffset,
                        double yOffset,
                        boolean fixed,
                        int directionMask,
                        double cost)
Creates a new instance of PortCandidate using the given values. Clients use the factory methods instead.

See Also:
createCandidate(double, double, int, double)

PortCandidate

protected PortCandidate(double xOffset,
                        double yOffset,
                        int directionMask)
Creates a new instance of PortCandidate using the given values. Clients use the factory methods instead.

See Also:
createCandidate(double, double, int)

PortCandidate

protected PortCandidate(int directionMask)
Creates a new instance of PortCandidate using the given direction. Clients use the factory methods instead.

See Also:
createCandidate(int)

PortCandidate

protected PortCandidate(int directionMask,
                        double cost)
Creates a new instance of PortCandidate using the given values. Clients use the factory methods instead.

See Also:
createCandidate(double, double, int, double)
Method Detail

isInDirection

public boolean isInDirection(int directionMask)
Determines whether this instance lies in the given direction.

Parameters:
directionMask - the mask of directions as defined by the constants in this class.
Returns:
whether this instance specifies on of the given directions

getDirection

public int getDirection()
Returns the direction mask for this instance.

Returns:
a bitwise combination of the constants defined in this class.
See Also:
getDirectionForLayoutOrientation(byte)

isFixed

public boolean isFixed()
Returns whether this instance describes a fixed or strong port.

Returns:
whether to respect the offsets of this instance.

getXOffset

public double getXOffset()
Returns the x offset of the port with respect to the corresponding node's center.

Returns:
the x offset to the center of the node
See Also:
isFixed(), getXOffsetForLayoutOrientation(byte)

getYOffset

public double getYOffset()
Returns the y offset of the port with respect to the corresponding node's center.

Returns:
the y offset to the center of the node
See Also:
isFixed(), getXOffsetForLayoutOrientation(byte)

createCandidate

public static PortCandidate createCandidate(int directionMask)
Factory method that returns an instance describing a non-fixed port with 0 cost penalty for the given direction.

Parameters:
directionMask - a bitwise combination of the constants in this class.

createCandidate

public static PortCandidate createCandidate(int directionMask,
                                            double cost)
Factory method that returns an instance describing a non-fixed port with the given cost penalty for the given direction.

Parameters:
directionMask - a bitwise combination of the constants in this class.
cost - the cost to associate with the usage of this port

createCandidate

public static PortCandidate createCandidate(double xOffset,
                                            double yOffset,
                                            int directionMask)
Factory method that returns an instance describing a fixed port with zero cost penalty for the given direction at the given offsets.

Parameters:
directionMask - a bitwise combination of the constants in this class.
xOffset - the x offset
yOffset - the y offset

createCandidate

public static PortCandidate createCandidate(double xOffset,
                                            double yOffset,
                                            int directionMask,
                                            double cost)
Factory method that returns an instance describing a fixed port with the given cost penalty for the given direction at the given offset.

Parameters:
directionMask - a bitwise combination of the constants in this class.
cost - the cost to associate with the usage of this port
xOffset - the x offset
yOffset - the y offset

createCandidate

public static PortCandidate createCandidate(PortConstraint fromPortConstraint)
Factory method that returns an instance describing a non-fixed port with zero cost penalty for the direction specified by the given PortConstraint

Parameters:
fromPortConstraint - the port constraint to obtain the direction from

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toPortConstraint

public PortConstraint toPortConstraint()
A utility method for converting this instance to a PortConstraint

Returns:
a PortConstraint that matches this PortCandidate
See Also:
toPortConstraintForLayoutOrientation(byte)

toPortConstraintForLayoutOrientation

public PortConstraint toPortConstraintForLayoutOrientation(byte layoutOrientation)
A utility method for converting this instance to a PortConstraint interpreted for the given layout orientation.

Returns:
a PortConstraint that matches this PortCandidate
See Also:
toPortConstraint()

equals

public boolean equals(Object other)
Tests for equality based on the internal attributes.

Overrides:
equals in class Object

getCost

public double getCost()
Returns the cost associated with the usage of this PortCandidate.

Returns:
the cost penalty that is associated with this candidate

getDirectionForLayoutOrientation

public int getDirectionForLayoutOrientation(byte layoutOrientation)
Returns the direction constant with respect to the given layout orientation.

Parameters:
layoutOrientation - the orientation for which the direction should be interpreted.
Returns:
the getDirection() with respect to the orientation.
See Also:
getDirection()

getXOffsetForLayoutOrientation

public double getXOffsetForLayoutOrientation(byte layoutOrientation,
                                             int mirrorMask)
Yields the X-offset with respect for the given layout orientation and OrientationLayouter.getMirrorMask() mirror mask}.

Parameters:
layoutOrientation - The orientation for which to interpret the x offset.
mirrorMask - The mirror mask for which to interpret the x offset.
Returns:
The x offset.
See Also:
getXOffset(), getXOffsetForLayoutOrientation(byte)

getYOffsetForLayoutOrientation

public double getYOffsetForLayoutOrientation(byte layoutOrientation,
                                             int mirrorMask)
Yields the Y-offset with respect for the given layout orientation and OrientationLayouter.getMirrorMask() mirror mask}.

Parameters:
layoutOrientation - The orientation for which to interpret the y offset.
mirrorMask - The mirror mask for which to interpret the y offset.
Returns:
The y offset.
See Also:
getYOffset(), getYOffsetForLayoutOrientation(byte)

getXOffsetForLayoutOrientation

public double getXOffsetForLayoutOrientation(byte layoutOrientation)
Yields the X-offset with respect for the given layout orientation.

Parameters:
layoutOrientation - The orientation for which to interpret the x offset.
Returns:
The x offset.
See Also:
getXOffset()

getYOffsetForLayoutOrientation

public double getYOffsetForLayoutOrientation(byte layoutOrientation)
Yields the Y-offset with respect for the given layout orientation.

Parameters:
layoutOrientation - The orientation for which to interpret the x offset.
Returns:
The y offset.
See Also:
getYOffset()

toString

public String toString()
Returns a human-readable string representation of this PortCandidate.

Overrides:
toString in class Object

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