public class PortCandidateOptimizer extends AbstractPortConstraintOptimizer
IPortConstraintOptimizer
interface that tries to assign the edges of the
graph to ports
considering the specified PortCandidate
s.
Instances of this class can be set using property
PortConstraintOptimizer
.
This implementation will query for IDataProvider
s registered with the graph with keys
PortCandidate.SOURCE_PORT_CANDIDATE_COLLECTION_DPKEY
, PortCandidate.TARGET_PORT_CANDIDATE_COLLECTION_DPKEY
and PortCandidateSet.NODE_PORT_CANDIDATE_SET_DPKEY
. It will try to assign each edge one of the matching
PortCandidate
s without introducing too many crossings and without violating the cost
or capacity
constraints.
AbstractPortConstraintOptimizer.SameLayerData
Constructor and Description |
---|
PortCandidateOptimizer()
Creates a new instance of
PortCandidateOptimizer with the default settings. |
Modifier and Type | Method and Description |
---|---|
double |
getBackLoopPenalty()
Gets the penalty cost associated with each back-loop.
|
double |
getCrossingPenalty()
Gets the penalty cost associated with a crossing that would occur if a given combination of
PortCandidate s would be chosen. |
double |
getOverUsagePenalty()
Gets the penalty cost associated with each edge being assigned to a port which has already reached its
capacity . |
protected IDataProvider |
getPortCandidateSetDataProvider(LayoutGraph graph)
Returns the data provider that provides the port candidate sets for nodes.
|
protected AbstractPortConstraintOptimizer.SameLayerData |
insertSameLayerStructures(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Inserts a same-layer edge structure for each same-layer edge of the original graph.
|
boolean |
isDeterministicModeEnabled()
Gets whether or not this implementation uses a deterministic algorithm to assign the
PortCandidate s. |
void |
optimizeAfterLayering(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Assigns new temporary port constraints after the nodes have been assigned to layers.
|
void |
optimizeAfterSequencing(LayoutGraph graph,
ILayers layers,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
|
protected void |
optimizeAfterSequencing(Node node,
Comparator<Object> inEdgeOrder,
Comparator<Object> outEdgeOrder,
LayoutGraph graph,
ILayoutDataProvider ldp,
IItemFactory itemFactory)
Assigns new temporary port constraints to a given node of the graph after the order of the nodes in each layer has been
determined.
|
void |
setBackLoopPenalty(double value)
Sets the penalty cost associated with each back-loop.
|
void |
setCrossingPenalty(double value)
Sets the penalty cost associated with a crossing that would occur if a given combination of
PortCandidate s would be chosen. |
void |
setDeterministicModeEnabled(boolean value)
Sets whether or not this implementation uses a deterministic algorithm to assign the
PortCandidate s. |
void |
setOverUsagePenalty(double value)
Sets the penalty cost associated with each edge being assigned to a port which has already reached its
capacity . |
getLayoutOrientation, getMirrorMode, optimizeAfterSequencing, removeSameLayerStructures, setLayoutOrientation, setMirrorMode
public PortCandidateOptimizer()
PortCandidateOptimizer
with the default settings.public double getBackLoopPenalty()
Values should be non-negative.
IllegalArgumentException
- if the penalty cost is negativesetBackLoopPenalty(double)
public double getCrossingPenalty()
PortCandidate
s would be chosen.
Values should be non-negative.
IllegalArgumentException
- if the crossing penalty is negativesetCrossingPenalty(double)
public double getOverUsagePenalty()
capacity
.
Values should be non-negative.
IllegalArgumentException
- if the penalty cost is negativePortCandidate
sPortCandidateSet.IEntry#getConnections()
,
setOverUsagePenalty(double)
protected IDataProvider getPortCandidateSetDataProvider(LayoutGraph graph)
graph
- The graph that stores the data providerprotected AbstractPortConstraintOptimizer.SameLayerData insertSameLayerStructures(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
AbstractPortConstraintOptimizer
insertSameLayerStructures
in class AbstractPortConstraintOptimizer
graph
- the input graphlayers
- the given ILayers
instance holding the layering informationldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesitemFactory
- the factory
that sets the temporary port constraintsIItemFactory.setTemporaryPortConstraint(Edge, boolean, com.yworks.yfiles.layout.PortConstraint)
public boolean isDeterministicModeEnabled()
PortCandidate
s.true
. A deterministic algorithm will be applied.true
if a deterministic algorithm should be applied, false
otherwisesetDeterministicModeEnabled(boolean)
public void optimizeAfterLayering(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
AbstractPortConstraintOptimizer
More precisely, it is called after the layering information has been determined. In this phase, it is possible to create back-loops by assigning incoming edges to the south (i.e. bottom) side or outgoing edges to the north (i.e. top) side, respectively.
optimizeAfterLayering
in interface IPortConstraintOptimizer
optimizeAfterLayering
in class AbstractPortConstraintOptimizer
graph
- the input graphlayers
- the given ILayers
instance holding the layering informationldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesitemFactory
- the factory
that sets the temporary port constraintsIItemFactory.setTemporaryPortConstraint(Edge, boolean, com.yworks.yfiles.layout.PortConstraint)
public void optimizeAfterSequencing(LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory)
AbstractPortConstraintOptimizer
More precisely, it is called after the sequence of the nodes has been determined. It
inserts the same-layer structures
,
invokes the hook
in which the custom port assignment should be done, and finally restores the original state
of the layout graph by removing the temporary edges.
optimizeAfterSequencing
in interface IPortConstraintOptimizer
optimizeAfterSequencing
in class AbstractPortConstraintOptimizer
graph
- the input graphlayers
- the given ILayers
instance holding the layering informationldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesitemFactory
- the factory
that sets the temporary port constraintsAbstractPortConstraintOptimizer.insertSameLayerStructures(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory)
,
AbstractPortConstraintOptimizer.optimizeAfterSequencing(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory)
,
AbstractPortConstraintOptimizer.removeSameLayerStructures(SameLayerData, LayoutGraph, ILayoutDataProvider, IItemFactory)
protected void optimizeAfterSequencing(Node node, Comparator<Object> inEdgeOrder, Comparator<Object> outEdgeOrder, LayoutGraph graph, ILayoutDataProvider ldp, IItemFactory itemFactory)
AbstractPortConstraintOptimizer
More precisely, it is called after the sequence of the nodes has been determined.
Incoming and outgoing edges are sorted using Comparator
instances which define the preferred ordering of the
incoming and outgoing edges from left to right.
optimizeAfterSequencing
in class AbstractPortConstraintOptimizer
node
- the original node to set temporary port constraintsinEdgeOrder
- a given Comparator
instance for incoming edgesoutEdgeOrder
- a given Comparator
instance for outgoing edgesgraph
- the input graphldp
- the ILayoutDataProvider
implementation which provides access to the INodeData
and IEdgeData
instancesitemFactory
- the factory
that sets the temporary port constraintsAbstractPortConstraintOptimizer.optimizeAfterSequencing(LayoutGraph, ILayers, ILayoutDataProvider, IItemFactory)
public void setBackLoopPenalty(double value)
Values should be non-negative.
IllegalArgumentException
- if the penalty cost is negativevalue
- the penalty for a back-loopgetBackLoopPenalty()
public void setCrossingPenalty(double value)
PortCandidate
s would be chosen.
Values should be non-negative.
IllegalArgumentException
- if the crossing penalty is negativevalue
- the penalty for a produced edge ctossinggetCrossingPenalty()
public void setDeterministicModeEnabled(boolean value)
PortCandidate
s.true
. A deterministic algorithm will be applied.value
- true
if a deterministic algorithm should be applied, false
otherwiseisDeterministicModeEnabled()
public void setOverUsagePenalty(double value)
capacity
.
Values should be non-negative.
IllegalArgumentException
- if the penalty cost is negativevalue
- the penalty for over-saturated PortCandidate
sPortCandidateSet.IEntry#getConnections()
,
getOverUsagePenalty()