|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.PortCandidateSet
public class PortCandidateSet
This class associates PortCandidate
s with the nodes of a graph.
PortCandidate
s defined on nodes specify sides or even exact locations at which edges can be connected.
This means that an edge can be connected to any of the available node ports (unless edge PortCandidate
s
are specified too).
Each node PortCandidate
has a capacity, i.e., a maximum number of edges allowed to connect to it.
Information about PortCandidate
s on nodes is held by a DataProvider
that stores a
PortCandidateSet
for each node and is registered with the graph using key NODE_DP_KEY
.
The PortCandidate
s are retrieved from the PortCandidateSet
through a
PortCandidateSet.Entry
that holds the information about the actual PortCandidate
.
This object is also used for retrieving the best candidate from a PortCandidateSet
based on the cost
(lower costs are considered first) and the available capacity of each candidate.
Custom searching for the best PortCandidate
can be achieved by implementing
PortCandidateSet.CandidateMatcher
interface.
Not all layout and routing algorithms are able to handle PortCandidate
s. Major layout algorithms
that obey them are IncrementalHierarchicLayouter
,
EdgeRouter
, 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 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.Nested Class Summary | |
---|---|
static interface |
PortCandidateSet.CandidateMatcher
A PortCandidateSet.CandidateMatcher retrieves the best matching entries from a
PortCandidateSet . |
static interface |
PortCandidateSet.Entry
This interface represents an entry of a PortCandidateSet and provides access to the actual
PortCandidate instance and the maximum number of edges allowed to connect to it. |
Field Summary | |
---|---|
static java.lang.Object |
NODE_DP_KEY
A DataProvider key for specifying a port candidate set for each node.
|
Constructor Summary | |
---|---|
PortCandidateSet()
Creates a new empty PortCandidateSet instance. |
Method Summary | |
---|---|
void |
add(PortCandidate p)
Adds a PortCandidate with capacity 1 to this PortCandidateSet . |
void |
add(PortCandidate p,
int connections)
Adds a PortCandidate with the given capacity to this PortCandidateSet . |
PortCandidateSet.CandidateMatcher |
createMatcher()
Creates a PortCandidateSet.CandidateMatcher that retrieves entries from this
PortCandidateSet . |
int |
getConnectionCount()
Returns the total number of connections allowed by the PortCandidate s described by this
PortCandidateSet or Integer.MAX_VALUE if the number is unbounded. |
protected double |
getCost(PortCandidateSet.Entry entry,
Edge edge,
boolean source,
double xOffset,
double yOffset)
Calculates the penalty cost for the usage of the given entry and the given
parameters. |
java.util.Iterator |
getEntries()
Returns an Iterator over the list of candidate entries of
this PortCandidateSet . |
protected double |
getPriority(PortCandidateSet.Entry entry,
Edge edge,
boolean source)
Calculates the priority of the given entry . |
void |
remove(PortCandidateSet.Entry entry)
Removes the given entry from the list of candidate entries. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object NODE_DP_KEY
DataProvider
key for specifying a port candidate set for each node.
Constructor Detail |
---|
public PortCandidateSet()
PortCandidateSet
instance.
Addition of PortCandidate
s to this set
can be performed using
add(PortCandidate)
or add(PortCandidate, int)
.
Method Detail |
---|
public void add(PortCandidate p)
PortCandidate
with capacity 1
to this PortCandidateSet
.
Addition of PortCandidate
s with capacity greater than 1
can be performed using
add(PortCandidate, int)
.
p
- the PortCandidate
to addadd(PortCandidate, int)
public void add(PortCandidate p, int connections)
PortCandidate
with the given capacity to this PortCandidateSet
.
The capacity value defines the maximum number of edges allowed to connect to the candidate. If no limitation
for this number exists, Integer.MAX_VALUE
can be used.
The capacity must be greater than zero.
p
- the PortCandidate
to addconnections
- the capacity of the given port
java.lang.IllegalArgumentException
- if the given capacity is less than or equal to zeropublic int getConnectionCount()
PortCandidate
s described by this
PortCandidateSet
or Integer.MAX_VALUE
if the number is unbounded.
PortCandidateSet
public void remove(PortCandidateSet.Entry entry)
entry
from the list of candidate entries.
entry
- the entry to removepublic java.util.Iterator getEntries()
Iterator
over the list of candidate entries
of
this PortCandidateSet
.
Iterator
over the list of PortCandidateSet.Entry
spublic PortCandidateSet.CandidateMatcher createMatcher()
PortCandidateSet.CandidateMatcher
that retrieves entries
from this
PortCandidateSet
.
Each next best matching candidate is determined based on its cost, its current available capacity and based on whether or not its direction is consistent with the desired one.
This method may be overridden to support custom implementations of PortCandidateSet.CandidateMatcher
.
EdgeRouter
supports PortCandidateSet
s, it doesn't
support custom PortCandidateSet.CandidateMatcher
implementations.PortCandidateSet.CandidateMatcher
instanceprotected double getCost(PortCandidateSet.Entry entry, Edge edge, boolean source, double xOffset, double yOffset)
entry
and the given
parameters.
The cost is equal to the cost of usage
of the
associated port candidate
.
This method may be overridden to customize the calculation of the cost of usage of an
entry
.
entry
- the entry for which the cost is computededge
- the edge that will connect to the PortCandidate
associated with the entrysource
- true
if the given edge connects to its source node, false
otherwisexOffset
- the preferred X-offset of the port relative to the center of the nodeyOffset
- the preferred Y-offset of the port relative to the center of the node
PortCandidateSet.Entry
protected double getPriority(PortCandidateSet.Entry entry, Edge edge, boolean source)
entry
.
Higher priority means that the entry will be considered earlier by a PortCandidateSet.CandidateMatcher
.
This method may be overridden to customize the calculation of the priority of entries
.
entry
- the entry for which the cost is computededge
- the edge that will connect to the PortCandidate
associated with the entrysource
- true
if the given edge connects to its source node, false
otherwise
PortCandidateSet.Entry
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |