y.layout.hierarchic.incremental
Class PCListOptimizer

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

public class PCListOptimizer
extends Object
implements PortConstraintOptimizer

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.

 

Constructor Summary
PCListOptimizer()
           
 
Method Summary
 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.
 byte getLayoutOrientation()
          Returns the currently set layout orientation for this instance.
 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.
 void optimizeAfterSequencing(LayoutGraph graph, Layers layers, LayoutDataProvider ldp, ItemFactory itemFactory)
          Called after the sequence of the nodes has been determined after the layering.
 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 setLayoutOrientation(byte layoutOrientation)
          Sets the layout orientation that should be assumed by this instance.
 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 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

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 interface: PortConstraintOptimizer
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.

Specified by:
optimizeAfterLayering in interface PortConstraintOptimizer
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

public void optimizeAfterSequencing(LayoutGraph graph,
                                    Layers layers,
                                    LayoutDataProvider ldp,
                                    ItemFactory itemFactory)
Description copied from interface: PortConstraintOptimizer
Called after the sequence of the nodes has been determined after the layering. This method can be used to assign new temporary port constraints.

Specified by:
optimizeAfterSequencing in interface PortConstraintOptimizer
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)

setLayoutOrientation

public void setLayoutOrientation(byte layoutOrientation)
Sets the layout orientation that should be assumed by this instance. This setting is necessary to correctly interpret the values provided in the PortCandidate instances since the OrientationLayouter cannot automatically adjust these values.

Parameters:
layoutOrientation - The orientation constant as defined in OrientationLayouter.
See Also:
CanonicMultiStageLayouter.getLayoutOrientation()

getLayoutOrientation

public byte getLayoutOrientation()
Returns the currently set layout orientation for this instance.


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