public class PortCandidate extends Object
The notion of PortCandidate
s extends the one of PortConstraint
s. In contrast to PortConstraint
s,
they can be associated with both edges and nodes. Moreover, more than one PortCandidate
can be specified for an
edge or a node.
Edge PortCandidate
s can be introduced to define specific sides or exact locations on which a given edge
can be connected to its source or target node.
Information about edge PortCandidate
s is held by IDataProvider
s that are
registered with the graph using keys SOURCE_PORT_CANDIDATE_COLLECTION_DPKEY
(to specify PortCandidate
s
for an edge on the source node) and TARGET_PORT_CANDIDATE_COLLECTION_DPKEY
(to specify PortCandidate
s
for an edge on the target node). The IDataProvider
s hold a collection
of PortCandidate
s for each edge.
Node PortCandidate
s determine available ports on the nodes to which edges can be connected. This means
that an edge of the graph can be connected to any of these node ports (unless edge PortCandidate
s are specified
too).
To register and define node PortCandidate
s refer to PortCandidateSet
.
A PortCandidate
is described by the following attributes:
PortCandidate
relative to
the center of the node.
PortCandidate
s are defined using exact coordinates, whereas coordinates of free candidates are selected
arbitrarily.
PortCandidate
. During the processing of an edge by a layout or routing algorithm, candidates of lower cost
will be considered first.
Example of using edge port candidates. Edge port candidates are colored uniquely based on the edge with which they are associated.
Not all layout and routing algorithms are able to handle PortCandidate
s. Major layout algorithms that obey them
are HierarchicLayout
,
EdgeRouter
, ChannelEdgeRouter
and BusRouter
.
PortPlacementStage
can be appended to any layout algorithm that cannot handle port constraints in order to
assign edges to the ports specified by PortConstraint
s or
PortCandidate
s after calling the core layout algorithm.PortConstraint
s and
PortCandidate
s (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.Modifier and Type | Field and Description |
---|---|
static EdgeDpKey<Collection<PortCandidate>> |
SOURCE_PORT_CANDIDATE_COLLECTION_DPKEY
A
DataProvider key for specifying source port candidates for each edge.
|
static EdgeDpKey<Collection<PortCandidate>> |
TARGET_PORT_CANDIDATE_COLLECTION_DPKEY
A
DataProvider key for specifying target port candidates for each edge.
|
Modifier and Type | Method and Description |
---|---|
static PortCandidate |
createCandidate(double xOffset,
double yOffset,
PortDirections directionMask)
Factory method that creates a fixed
PortCandidate instance with the given cost of usage, direction and offset
values. |
static PortCandidate |
createCandidate(double xOffset,
double yOffset,
PortDirections directionMask,
double cost)
Factory method that creates a fixed
PortCandidate instance with the given cost of usage, direction and offset
values. |
static PortCandidate |
createCandidate(PortConstraint fromPortConstraint)
Factory method that returns a free
PortCandidate instance with zero cost of usage and the direction specified by
the side of the given PortConstraint . |
static PortCandidate |
createCandidate(PortDirections directionMask)
Factory method that creates a free
PortCandidate instance with the given direction and zero cost of usage. |
static PortCandidate |
createCandidate(PortDirections directionMask,
double cost)
Factory method that creates a free
PortCandidate instance with the given direction and cost of usage. |
boolean |
equals(Object other)
Returns whether or not this
PortCandidate is equal to another PortCandidate based on their internal
attributes. |
double |
getCost()
Gets the penalty cost for using this
PortCandidate instance. |
PortDirections |
getDirection()
Gets the direction of this
PortCandidate . |
PortDirections |
getDirectionForLayoutOrientation(LayoutOrientation layoutOrientation)
Returns the direction of this
PortCandidate instance with respect to the given
layout orientation . |
double |
getXOffset()
Gets the X-offset of the
PortCandidate with respect to the center of the corresponding node. |
double |
getXOffsetForLayoutOrientation(LayoutOrientation layoutOrientation)
Returns the X-offset of the
PortCandidate with respect to the center of the corresponding node for the given
layout orientation . |
double |
getXOffsetForLayoutOrientation(LayoutOrientation layoutOrientation,
MirrorModes mirrorMask)
Returns the X-offset of the
PortCandidate with respect to the center of the corresponding node for the given layout orientation
and mirror mask . |
double |
getYOffset()
Gets the Y-offset of the
PortCandidate with respect to the center of the corresponding node. |
double |
getYOffsetForLayoutOrientation(LayoutOrientation layoutOrientation)
Returns the Y-offset of the
PortCandidate with respect to the center of the corresponding node for the given
layout orientation . |
double |
getYOffsetForLayoutOrientation(LayoutOrientation layoutOrientation,
MirrorModes mirrorMask)
Returns the Y-offset of the
PortCandidate with respect to the center of the corresponding node for the given layout orientation
and mirror mask . |
int |
hashCode()
Returns a hash code value for this
PortCandidate instance based on the internal attributes. |
boolean |
isFixed()
Gets whether or not this
PortCandidate is fixed. |
boolean |
isInDirection(PortDirections directionMask)
Returns whether or not this
PortCandidate lies in the given direction. |
PortConstraint |
toPortConstraint()
A utility method that converts the current
PortCandidate instance to a PortConstraint . |
PortConstraint |
toPortConstraintForLayoutOrientation(LayoutOrientation layoutOrientation)
A utility method that converts the current
PortCandidate instance to a PortConstraint with respect to
the given layout orientation . |
String |
toString()
Returns a string representation of this
PortCandidate instance. |
public static final EdgeDpKey<Collection<PortCandidate>> SOURCE_PORT_CANDIDATE_COLLECTION_DPKEY
DataProvider
key for specifying source port candidates for each edge.
public static final EdgeDpKey<Collection<PortCandidate>> TARGET_PORT_CANDIDATE_COLLECTION_DPKEY
DataProvider
key for specifying target port candidates for each edge.
public static final PortCandidate createCandidate(double xOffset, double yOffset, PortDirections directionMask)
PortCandidate
instance with the given cost of usage, direction and offset
values.xOffset
- the X-offset relative to the center of the nodeyOffset
- the Y-offset relative to the center of the nodedirectionMask
- any combination of the default direction specifiersPortCandidate
instancepublic static final PortCandidate createCandidate(double xOffset, double yOffset, PortDirections directionMask, double cost)
PortCandidate
instance with the given cost of usage, direction and offset
values.directionMask
- any combination of the default direction specifiersxOffset
- the X-offset relative to the center of the nodeyOffset
- the Y-offset relative to the center of the nodecost
- the penalty cost for using this PortCandidate
instancePortCandidate
instancepublic static final PortCandidate createCandidate(PortConstraint fromPortConstraint)
PortCandidate
instance with zero cost of usage and the direction specified by
the side
of the given PortConstraint
.fromPortConstraint
- the PortConstraint
whose side
should be used as directionPortCandidate
instancepublic static final PortCandidate createCandidate(PortDirections directionMask)
PortCandidate
instance with the given direction and zero cost of usage.directionMask
- any combination of the default direction specifiersPortCandidate
instancepublic static final PortCandidate createCandidate(PortDirections directionMask, double cost)
PortCandidate
instance with the given direction and cost of usage.directionMask
- any combination of the default direction specifierscost
- the penalty cost for using this PortCandidate
PortCandidate
instancepublic boolean equals(Object other)
PortCandidate
is equal to another PortCandidate
based on their internal
attributes.equals
in class Object
other
- the reference PortCandidate
object with which to comparetrue
if this object is the same as the PortCandidate
argument, false
otherwisepublic double getCost()
PortCandidate
instance.PortCandidate
public PortDirections getDirection()
PortCandidate
.
If the direction is required to be calculated with respect to the actual
layout orientation
, getDirectionForLayoutOrientation(LayoutOrientation)
should be used instead.
PortCandidate
getDirectionForLayoutOrientation(LayoutOrientation)
public PortDirections getDirectionForLayoutOrientation(LayoutOrientation layoutOrientation)
PortCandidate
instance with respect to the given
layout orientation
.
If the direction mask is not required to be calculated with respect to the actual
layout orientation
, Direction
should be used instead.
PortCandidate
with respect to the given layout orientationgetDirection()
public double getXOffset()
PortCandidate
with respect to the center of the corresponding node.
The X-offset encodes the horizontal distance of the port relative to the center of a node. If the PortCandidate
is not fixed
(i.e., free), the X-offset is zero.
layout orientation
, getXOffsetForLayoutOrientation(LayoutOrientation)
should be used instead.PortCandidate
public double getXOffsetForLayoutOrientation(LayoutOrientation layoutOrientation)
PortCandidate
with respect to the center of the corresponding node for the given
layout orientation
.
The X-offset encodes the horizontal distance of the port relative to the center of a node. If the PortCandidate
is not fixed
(i.e., free), the X-offset is equal to zero.
layout orientation
, XOffset
should be used instead.layoutOrientation
- the layout orientationPortCandidate
with respect to the given layout orientationpublic double getXOffsetForLayoutOrientation(LayoutOrientation layoutOrientation, MirrorModes mirrorMask)
PortCandidate
with respect to the center of the corresponding node for the given layout orientation
and mirror mask
.
The X-offset encodes the horizontal distance of the port relative to the center of a node. If the PortCandidate
is not fixed
(i.e., free), the X-offset is equal to zero.
layout orientation
, XOffset
should be used instead.layoutOrientation
- the layout orientationmirrorMask
- the mirror maskpublic double getYOffset()
PortCandidate
with respect to the center of the corresponding node.
The Y-offset encodes the vertical distance of the port relative to the center of a node. If the PortCandidate
is
not fixed
(i.e., free), the Y-offset is zero.
layout orientation
, method getYOffsetForLayoutOrientation(LayoutOrientation)
should be used instead.PortCandidate
public double getYOffsetForLayoutOrientation(LayoutOrientation layoutOrientation)
PortCandidate
with respect to the center of the corresponding node for the given
layout orientation
.
The Y-offset encodes the vertical distance of the port relative to the center of a node. If the PortCandidate
is
not fixed
(i.e., free), the Y-offset is equal to zero.
layout orientation
, YOffset
should be used instead.layoutOrientation
- the layout orientationPortCandidate
with respect to the given layout orientationpublic double getYOffsetForLayoutOrientation(LayoutOrientation layoutOrientation, MirrorModes mirrorMask)
PortCandidate
with respect to the center of the corresponding node for the given layout orientation
and mirror mask
.
The Y-offset encodes the vertical distance of the port relative to the center of a node. If the PortCandidate
is
not fixed
(i.e., free), the Y-offset is equal to zero.
layout orientation
, YOffset
should be used instead.layoutOrientation
- the layout orientationmirrorMask
- the mirror maskPortCandidate
with respect to the given orientation and mirror maskpublic int hashCode()
PortCandidate
instance based on the internal attributes.public boolean isFixed()
PortCandidate
is fixed.
Fixed
PortCandidate
s are defined using exact coordinates, whereas coordinates of free candidates are selected
arbitrarily.
true
if this PortCandidate
is fixed, false
otherwisepublic boolean isInDirection(PortDirections directionMask)
PortCandidate
lies in the given direction.directionMask
- one of the default direction specifierstrue
if this PortCandidate
lies in the given direction, false
otherwisepublic PortConstraint toPortConstraint()
PortCandidate
instance to a PortConstraint
.
The side
of the created PortConstraint
matches the direction
of this PortCandidate
.
If this PortCandidate
is fixed
, the resulting PortConstraint
will be
strong
.
PortConstraint
should be determined with respect to a certain
layout orientation
, method toPortConstraintForLayoutOrientation(LayoutOrientation)
should be used instead.PortConstraint
that matches this PortCandidate
public PortConstraint toPortConstraintForLayoutOrientation(LayoutOrientation layoutOrientation)
PortCandidate
instance to a PortConstraint
with respect to
the given layout orientation
.
The side
of the created PortConstraint
is the direction
of this PortCandidate
interpreted for the given orientation.
If this PortCandidate
is fixed
, the resulting PortConstraint
will be
strong
.
PortConstraint
should not be determined with respect to a certain
layout orientation
, method toPortConstraint()
should be used instead.PortConstraint
that matches this PortCandidate
with respect to the given orientationpublic String toString()
PortCandidate
instance.toString
in class Object
PortCandidate