Search this API

y.layout.hierarchic.incremental
Class PCListOptimizer

java.lang.Object
  extended by y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer
      extended by y.layout.hierarchic.incremental.PCListOptimizer
All Implemented Interfaces:
PortConstraintOptimizer

public class PCListOptimizer
extends AbstractPortConstraintOptimizer

This class is an implementation of the PortConstraintOptimizer interface that tries to assign the edges of the graph to ports considering the specified PortCandidates.

Instances of this class can be set using property HierarchicLayouter.setPortConstraintOptimizer(PortConstraintOptimizer).

This implementation will query for DataProviders registered with the graph with keys PortCandidate.SOURCE_PCLIST_DPKEY, PortCandidate.TARGET_PCLIST_DPKEY and PortCandidateSet.NODE_DP_KEY. It will try to assign each edge one of the matching PortCandidates without introducing too many crossings and without violating the cost or capacity constraints.

See Also:
PortCandidate.getCost(), PortCandidateSet.getEntries(), PortCandidateSet.getConnectionCount()
 

Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer
AbstractPortConstraintOptimizer.SameLayerData
 
Constructor Summary
PCListOptimizer()
          Creates a new instance of PCListOptimizer with the default settings.
 
Method Summary
 double getBackloopPenalty()
          Returns the penalty cost associated with each back-loop.
 double getCrossingPenalty()
          Returns the penalty cost associated with a crossing that would occur if a given combination of PortCandidates would be chosen.
 double getOverUsagePenalty()
          Returns the penalty cost associated with each edge being assigned to a port which has already reached its capacity.
protected  DataProvider getPortCandidateSetDataProvider(LayoutGraph graph)
          Returns the data provider that provides the port candidate sets for nodes.
protected  AbstractPortConstraintOptimizer.SameLayerData insertSameLayerStructures(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Inserts a same-layer edge structure for each same-layer edge of the original graph.
 boolean isDeterministic()
          Returns whether or not this implementation uses a deterministic algorithm to assign the PortCandidates.
 void optimizeAfterLayering(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Assigns new temporary port constraints after the nodes have been assigned to layers.
 void optimizeAfterSequencing(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Assigns new temporary port constraints after the order of the nodes in each layer has been determined.
protected  void optimizeAfterSequencing(Node node, java.util.Comparator inEdgeOrder, java.util.Comparator outEdgeOrder, LayoutGraph graph, LayoutDataProvider ldp, ItemFactory 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 backloopPenalty)
          Specifies the penalty cost associated with each back-loop.
 void setCrossingPenalty(double crossingPenalty)
          Specifies the penalty cost associated with a crossing that would occur if a given combination of PortCandidates would be chosen.
 void setDeterministic(boolean deterministic)
          Specifies whether this implementation should use a deterministic algorithm to assign the PortCandidates.
 void setOverUsagePenalty(double overUsagePenalty)
          Specifies the penalty cost associated with each edge being assigned to a port which has already reached its capacity.
 
Methods inherited from class y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer
getLayoutOrientation, getMirrorMask, optimizeAfterSequencing, removeSameLayerStructures, setLayoutOrientation, setMirrorMask
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PCListOptimizer

public PCListOptimizer()
Creates a new instance of PCListOptimizer with the default settings.

Method Detail

isDeterministic

public boolean isDeterministic()
Returns whether or not this implementation uses a deterministic algorithm to assign the PortCandidates.

Returns:
true if a deterministic algorithm should be applied, false otherwise
See Also:
setDeterministic(boolean)

setDeterministic

public void setDeterministic(boolean deterministic)
Specifies whether this implementation should use a deterministic algorithm to assign the PortCandidates.

Default Value:
The default value is true. A deterministic algorithm will be applied.
Parameters:
deterministic - true if a deterministic algorithm should be applied, false otherwise

getBackloopPenalty

public double getBackloopPenalty()
Returns the penalty cost associated with each back-loop.

Values should be non-negative.

Returns:
the penalty for a back-loop
See Also:
setBackloopPenalty(double)

setBackloopPenalty

public void setBackloopPenalty(double backloopPenalty)
Specifies the penalty cost associated with each back-loop.

Values should be non-negative.

Default Value:
The default value is 1.0.
Parameters:
backloopPenalty - the penalty for a back-loop
Throws:
java.lang.IllegalArgumentException - if the penalty cost is negative

getCrossingPenalty

public double getCrossingPenalty()
Returns the penalty cost associated with a crossing that would occur if a given combination of PortCandidates would be chosen.

Values should be non-negative.

Returns:
the penalty for a produced edge ctossing
See Also:
setCrossingPenalty(double)

setCrossingPenalty

public void setCrossingPenalty(double crossingPenalty)
Specifies the penalty cost associated with a crossing that would occur if a given combination of PortCandidates would be chosen.

Values should be non-negative.

Default Value:
The default value is 10.0d.
Parameters:
crossingPenalty - the penalty for a produced edge ctossing
Throws:
java.lang.IllegalArgumentException - if the crossing penalty is negative

getOverUsagePenalty

public double getOverUsagePenalty()
Returns the penalty cost associated with each edge being assigned to a port which has already reached its capacity.

Values should be non-negative.

 
When having port candidates with high costs, it may be necessary to increase the over-usage penalty to avoid extending the maximum connections.
Returns:
the penalty for over-saturated PortCandidates
See Also:
setOverUsagePenalty(double), PortCandidateSet.Entry.getConnections()

setOverUsagePenalty

public void setOverUsagePenalty(double overUsagePenalty)
Specifies the penalty cost associated with each edge being assigned to a port which has already reached its capacity.

Values should be non-negative.

 
When having port candidates with high costs, it may be necessary to increase the over-usage penalty to avoid extending the maximum connections.
Default Value:
The default value is 100.0d.
Parameters:
overUsagePenalty - the penalty for over-saturated PortCandidates
Throws:
java.lang.IllegalArgumentException - if the penalty cost is negative
See Also:
PortCandidateSet.Entry.getConnections()

optimizeAfterLayering

public void optimizeAfterLayering(LayoutGraph graph,
                                  Layers layers,
                                  LayoutDataProvider ldp,
                                  ItemFactory itemFactory)
Description copied from class: AbstractPortConstraintOptimizer
Assigns new temporary port constraints after the nodes have been assigned to layers.

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.

Specified by:
optimizeAfterLayering in interface PortConstraintOptimizer
Specified by:
optimizeAfterLayering in class AbstractPortConstraintOptimizer
Parameters:
graph - the input graph
layers - the given Layers instance holding the layering information
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

insertSameLayerStructures

protected AbstractPortConstraintOptimizer.SameLayerData insertSameLayerStructures(LayoutGraph graph,
                                                                                  Layers layers,
                                                                                  LayoutDataProvider ldp,
                                                                                  ItemFactory itemFactory)
Description copied from class: AbstractPortConstraintOptimizer
Inserts a same-layer edge structure for each same-layer edge of the original graph.

Overrides:
insertSameLayerStructures in class AbstractPortConstraintOptimizer
Parameters:
graph - the input graph
layers - the given Layers instance holding the layering information
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
ItemFactory.setTemporaryPortConstraint(y.base.Edge, boolean, y.layout.PortConstraint)

getPortCandidateSetDataProvider

protected DataProvider getPortCandidateSetDataProvider(LayoutGraph graph)
Returns the data provider that provides the port candidate sets for nodes.

Parameters:
graph - The graph that stores the data provider

optimizeAfterSequencing

public void optimizeAfterSequencing(LayoutGraph graph,
                                    Layers layers,
                                    LayoutDataProvider ldp,
                                    ItemFactory itemFactory)
Description copied from class: AbstractPortConstraintOptimizer
Assigns new temporary port constraints after the order of the nodes in each layer has been determined.

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.

Specified by:
optimizeAfterSequencing in interface PortConstraintOptimizer
Overrides:
optimizeAfterSequencing in class AbstractPortConstraintOptimizer
Parameters:
graph - the input graph
layers - the given Layers instance holding the layering information
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
AbstractPortConstraintOptimizer.insertSameLayerStructures(LayoutGraph, Layers, LayoutDataProvider, ItemFactory), AbstractPortConstraintOptimizer.optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory), AbstractPortConstraintOptimizer.removeSameLayerStructures(y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer.SameLayerData, y.layout.LayoutGraph, y.layout.hierarchic.incremental.LayoutDataProvider, y.layout.hierarchic.incremental.ItemFactory)

optimizeAfterSequencing

protected void optimizeAfterSequencing(Node node,
                                       java.util.Comparator inEdgeOrder,
                                       java.util.Comparator outEdgeOrder,
                                       LayoutGraph graph,
                                       LayoutDataProvider ldp,
                                       ItemFactory itemFactory)
Description copied from class: AbstractPortConstraintOptimizer
Assigns new temporary port constraints to a given node of the graph after the order of the nodes in each layer has been determined.

More precisely, it is called after the sequence of the nodes has been determined.

Incoming and outgoing edges are sorted using Comparators.PartialOrder instances which define the preferred ordering of the incoming and outgoing edges from left to right. To sort collections according to a Comparators.PartialOrder instance, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.

Specified by:
optimizeAfterSequencing in class AbstractPortConstraintOptimizer
Parameters:
node - the original node to set temporary port constraints
inEdgeOrder - a given Comparators.PartialOrder instance for incoming edges
outEdgeOrder - a given Comparators.PartialOrder instance for outgoing edges
graph - the input graph
ldp - the LayoutDataProvider implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory that sets the temporary port constraints
See Also:
AbstractPortConstraintOptimizer.optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory)

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