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 which can be registered with the HierarchicLayouter instance using it's HierarchicLayouter.setPortConstraintOptimizer(PortConstraintOptimizer) method. It will query the graph's DataProvider repository for the PortCandidate.SOURCE_PCLIST_DPKEY and PortCandidate.TARGET_PCLIST_DPKEY keys and expects them to hold Collection instances of PortCandidates for each edge. Additionally it will query the DataProvider associated with PortCandidateSet.NODE_DP_KEY and expects PortCandidateSet instances associated with each node in the input graph.

This implementation will then try to assign each edge one of the PortCandidates without creating too many crossings or violating the cost constraints for each PortCandidate.


Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer
AbstractPortConstraintOptimizer.SameLayerData
 
Constructor Summary
PCListOptimizer()
           
 
Method Summary
 double getBackloopPenalty()
          Returns the penalty cost that is associated with each backloop.
 double getCrossingPenalty()
          Returns the penalty cost that is associated with each generated crossing that would be generated if a given combination of PortCandidates would be chosen.
 double getOverUsagePenalty()
          Returns the penalty cost that is associated with each edge being assigned to a port which has no capacity left.
protected  DataProvider getPortCandidateSetDataProvider(LayoutGraph graph)
          Returns the data provider that provides the port candidate sets for nodes.
 boolean isDeterministic()
          Determines whether this implementation should use a deterministic algorithm to assign the PortCandidates.
 void optimizeAfterLayering(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called after the layering information has been determined.
protected  void optimizeAfterSequencing(Node node, Comparator inEdgeOrder, Comparator outEdgeOrder, LayoutGraph graph, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called after the sequence of the nodes has been determined to assign new temporary port constraints to each original node.
 void setBackloopPenalty(double backloopPenalty)
          Sets the penalty cost that is associated with each backloop.
 void setCrossingPenalty(double crossingPenalty)
          Sets the penalty cost that is associated with each generated crossing that would be generated if a given combination of PortCandidates would be chosen.
 void setDeterministic(boolean deterministic)
          Sets whether this implementation should use a deterministic algorithm to assign the PortCandidates.
 void setOverUsagePenalty(double overUsagePenalty)
          Sets the penalty cost that is associated with each edge being assigned to a port which has no capacity left.
 
Methods inherited from class y.layout.hierarchic.incremental.AbstractPortConstraintOptimizer
getLayoutOrientation, getMirrorMask, insertSameLayerStructures, optimizeAfterSequencing, 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()
Method Detail

isDeterministic

public boolean isDeterministic()
Determines whether this implementation should use a deterministic algorithm to assign the PortCandidates.

Returns:
whether to use a deterministic algorithm

setDeterministic

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

Parameters:
deterministic - whether to use a deterministic algorithm

getBackloopPenalty

public double getBackloopPenalty()
Returns the penalty cost that is associated with each backloop. The default value is 1.0d.

Returns:
the penalty for a backloop

setBackloopPenalty

public void setBackloopPenalty(double backloopPenalty)
Sets the penalty cost that is associated with each backloop. The default value is 1.0d.

Parameters:
backloopPenalty - the penalty for a backloop

getCrossingPenalty

public double getCrossingPenalty()
Returns the penalty cost that is associated with each generated crossing that would be generated if a given combination of PortCandidates would be chosen. The default value is 10.0d.

Returns:
the penalty for two edges crossing

setCrossingPenalty

public void setCrossingPenalty(double crossingPenalty)
Sets the penalty cost that is associated with each generated crossing that would be generated if a given combination of PortCandidates would be chosen. The default value is 10.0d.

Parameters:
crossingPenalty - the penalty for two edges crossing

getOverUsagePenalty

public double getOverUsagePenalty()
Returns the penalty cost that is associated with each edge being assigned to a port which has no capacity left. The default value is 100.0d.

Returns:
the penalty for over usage of PortCandidates
See Also:
PortCandidateSet.Entry.getConnections()

setOverUsagePenalty

public void setOverUsagePenalty(double overUsagePenalty)
Sets the penalty cost that is associated with each edge being assigned to a port which has no capacity left. The default value is 100.0d.

Parameters:
overUsagePenalty - the penalty for over usage of PortCandidates

optimizeAfterLayering

public void optimizeAfterLayering(LayoutGraph graph,
                                  Layers layers,
                                  LayoutDataProvider ldp,
                                  ItemFactory itemFactory)
Description copied from class: AbstractPortConstraintOptimizer
Called after the layering information has been determined. This method can be used to assign new temporary port constraints for the next phases of the algorithm. In this phase, it is possible to create back-loops by assigning in-edges to the south side or out-edges to the north side, respectively.

Specified by:
optimizeAfterLayering in interface PortConstraintOptimizer
Specified by:
optimizeAfterLayering in class AbstractPortConstraintOptimizer
Parameters:
graph - the graph to work on
layers - the layering information
ldp - the implementation which provides access to the NodeData and EdgeData instances
itemFactory - the factory to set the temporary port constraints with
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

protected void optimizeAfterSequencing(Node node,
                                       Comparator inEdgeOrder,
                                       Comparator outEdgeOrder,
                                       LayoutGraph graph,
                                       LayoutDataProvider ldp,
                                       ItemFactory itemFactory)
Description copied from class: AbstractPortConstraintOptimizer
Called after the sequence of the nodes has been determined to assign new temporary port constraints to each original node.

Note that, in this phase, it's not allowed to create back-loops, that is, in-edges must not connect to the south side and out-edges must not connect to the north side.

Specified by:
optimizeAfterSequencing in class AbstractPortConstraintOptimizer
Parameters:
node - the original node to set temporary port constraints at.
inEdgeOrder - a Comparators.PartialOrder which defines the preferred ordering of the in-edges from left to right. Note: to sort collections according to a PartialOrder, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.
outEdgeOrder - a Comparators.PartialOrder which defines the preferred ordering of the out-edges from left to right. Note: to sort collections according to a PartialOrder, an appropriate method like Comparators.sort(java.util.List, java.util.Comparator) or YList.sort(java.util.Comparator) must be used.
graph - the graph to work on.
ldp - the LayoutDataProvider which provides access to the NodeData and EdgeData.
itemFactory - the factory which can set the temporary port constraints.
See Also:
AbstractPortConstraintOptimizer.optimizeAfterSequencing(y.layout.LayoutGraph, Layers, LayoutDataProvider, ItemFactory)

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