|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindfusion.diagramming.AnnealLayout
public class AnnealLayout
Implements a simulated annealing graph layout algorithm.
Simulated Annealing is a general-purpose optimization method used to solve large-scale combinatorial problems by simulating the process of heating and cooling of metal to achieve freedom from defects. Finding a nice arrangement of a graph is a combinatorial problem that can be reduced to assigning costs to graph configurations and finding the minimum cost configuration. In that case, a cost is assigned to a graph configuration by evaluating different aesthetic criteria such as distance between nodes, length of arrows and the number of arrow crossings.
The AnnealLayout class implements a Simulated Annealing graph layout algorithm that can be used
to arrange JDiagram diagrams. To arrange a diagram, create an AnnealLayout instance, set its properties
and call the arrange(com.mindfusion.diagramming.Diagram)
method.
The algorithm starts the simulation with the temperature set via setInitialTemperature(double)
,
and runs several cooling stages, as set via setStages(int)
. At each stage the algorithm
evaluates several graph configurations for each node, as set by calling setIterationsPerStage(int)
.
At the end of each stage, the algorithm selects the configuration that has a minimum cost and
decreases the temperature by multiplying it by TemperatureScale
.
The relative weight of an aesthetic criterion relative to the other criteria is set via the
setDistributionFactor(double)
, setLinkLengthFactor(double)
, setBoundaryFactor(double)
and setCrossingLinksCost(double)
methods.
Constructor Summary | |
---|---|
AnnealLayout()
Initializes a new instance of the AnnealLayout class. |
Method Summary | |
---|---|
boolean |
arrange(Diagram chart)
Applies the layout to the specified Diagram . |
int |
getAnchoring()
Gets a value specifying how arrows will be aligned to the anchor points of nodes. |
double |
getBoundaryFactor()
Gets a value indicating how important the distance from nodes to the layout area boundaries is relatively to the other criteria considered by the algorithm. |
double |
getCrossingLinksCost()
Gets a value specifying how important the low number of arrow crossings is relatively to the other criteria considered by the algorithm. |
double |
getDistributionFactor()
Gets a value indicating the importance of node distribution relatively to the other criteria considered by the algorithm. |
double |
getInitialTemperature()
Gets the initial temperature of the simulated annealing process. |
int |
getIterationsPerStage()
Gets how many node shift iterations to perform at each stage of the algorithm. |
boolean |
getKeepGroupLayout()
Gets a value indicating whether to treat each Group
of nodes as a single vertex in the arranged graph. |
java.awt.geom.Rectangle2D.Float |
getLayoutArea()
Gets the size of the layout area. |
double |
getLinkLengthFactor()
Gets a value specifying how important the short length of arrows is relatively to the other criteria considered by the algorithm. |
int |
getMultipleGraphsOrientation()
How multiple independent graphs in the diagram should be positioned relative to one another. |
double |
getNodeLinkCrossingCost()
Gets a value specifying how important the low number of crossings of arrows with edges is relatively to the other criteria considered by the algorithm. |
double |
getNodeLinkDistFactor()
Gets a value specifying the importance of the distance between nodes and arrows relative to the other criteria considered by the algorithm. |
double |
getPrecision()
Gets the cost calculations precision. |
boolean |
getRandomize()
Gets a value indicating whether the nodes should be placed at random positions when the layout routine starts. |
DiagramNode |
getRoot()
Gets the diagram node that specifies which connected graph in the diagram should be arranged. |
boolean |
getSplitGraph()
Whether unconnected sub-graphs should be laid out independently from each other. |
int |
getStages()
Gets how many cooling stages the algorithm should simulate. |
double |
getTemperatureScale()
Gets how much the simulated temperature is decreased at each stage of the algorithm. |
float |
getWidthHeightRatio()
Gets what width / height ratio the layout area should have. |
void |
setAnchoring(int value)
Sets a value specifying how arrows will be aligned to the anchor points of nodes. |
void |
setBoundaryFactor(double value)
Sets a value indicating how important the distance from nodes to the layout area boundaries is relatively to the other criteria considered by the algorithm. |
void |
setCrossingLinksCost(double value)
Sets a value specifying how important the low number of arrow crossings is relatively to the other criteria considered by the algorithm. |
void |
setDistributionFactor(double value)
Sets a value indicating the importance of node distribution relatively to the other criteria considered by the algorithm. |
void |
setInitialTemperature(double value)
Sets the initial temperature of the simulated annealing process. |
void |
setIterationsPerStage(int value)
Sets how many node shift iterations to perform at each stage of the algorithm. |
void |
setKeepGroupLayout(boolean value)
Sets a value indicating whether to treat each Group
of nodes as a single vertex in the arranged graph. |
void |
setLayoutArea(java.awt.geom.Rectangle2D.Float value)
Sets the size of the layout area. |
void |
setLinkLengthFactor(double value)
Sets a value specifying how important the short length of arrows is relatively to the other criteria considered by the algorithm. |
void |
setMultipleGraphsOrientation(int value)
How multiple independent graphs in the diagram should be positioned relative to one another. |
void |
setNodeLinkCrossingCost(double nodeLinkCrossingCost)
Sets a value specifying how important the low number of crossings of arrows with edges is relatively to the other criteria considered by the algorithm. |
void |
setNodeLinkDistFactor(double value)
Sets a value specifying the importance of the distance between nodes and arrows relative to the other criteria considered by the algorithm. |
void |
setPrecision(double precision)
Sets the cost calculations precision. |
void |
setRandomize(boolean value)
Sets a value indicating whether the nodes should be placed at random positions when the layout routine starts. |
void |
setRoot(DiagramNode value)
Sets the diagram node that specifies which connected graph in the diagram should be arranged. |
void |
setSplitGraph(boolean value)
Whether unconnected sub-graphs should be laid out independently from each other. |
void |
setStages(int value)
Sets how many cooling stages the algorithm should simulate. |
void |
setTemperatureScale(double value)
Sets how much the simulated temperature is decreased at each stage of the algorithm. |
void |
setWidthHeightRatio(float value)
Sets what width / height ratio the layout area should have. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnealLayout()
Method Detail |
---|
public boolean arrange(Diagram chart)
Diagram
.
arrange
in interface Layout
chart
- A Diagram
instance that should be laid out.public DiagramNode getRoot()
DiagramNode
object whose containing graph will be arranged.public void setRoot(DiagramNode value)
value
- A DiagramNode
object whose containing graph will be arranged.public boolean getKeepGroupLayout()
Group
of nodes as a single vertex in the arranged graph.
true
if groups will be treated as single graph vertices,
otherwise false
public void setKeepGroupLayout(boolean value)
Group
of nodes as a single vertex in the arranged graph.
value
- true
if groups must be treated as single graph vertices,
otherwise false
public int getAnchoring()
Anchoring
public void setAnchoring(int value)
value
- One of the constants defined in Anchoring
public double getDistributionFactor()
public void setDistributionFactor(double value)
value
- A multiplier applied to the node distribution cost when evaluating
the total cost of a graph configuration. The default is 40000.public double getBoundaryFactor()
public void setBoundaryFactor(double value)
value
- A multiplier applied to the node-to-boundary distance cost when evaluating
the total cost of a graph configuration. The default is 3000.public double getLinkLengthFactor()
public void setLinkLengthFactor(double value)
value
- A multiplier applied to the arrow length cost when evaluating
the total cost of a graph configuration. The default is 0.25.public double getCrossingLinksCost()
public void setCrossingLinksCost(double value)
value
- A value added to the total cost of a graph configuration
for each pair of crossing arrows. The default is 100000.public double getNodeLinkCrossingCost()
public void setNodeLinkCrossingCost(double nodeLinkCrossingCost)
nodeLinkCrossingCost
- A value added to the total cost of a graph configuration
for each crossing of arrow and node. The default is 100000.public double getNodeLinkDistFactor()
public void setNodeLinkDistFactor(double value)
value
- A multiplier applied to the node-to-link distance cost when evaluating
the total cost of a graph configuration. The default is 20000.public double getInitialTemperature()
public void setInitialTemperature(double value)
value
- A double value specifying the initial temperature of the simulated process.public double getTemperatureScale()
public void setTemperatureScale(double value)
value
- A multiplier applied to the current temperature at the end of each
cooling stage. The default value is 0.75public int getIterationsPerStage()
public void setIterationsPerStage(int value)
value
- An integer value specifying the number of iterations. The default is 50public int getStages()
public void setStages(int value)
value
- The number of cooling stagespublic java.awt.geom.Rectangle2D.Float getLayoutArea()
public void setLayoutArea(java.awt.geom.Rectangle2D.Float value)
value
- The layout area coordinates.public float getWidthHeightRatio()
public void setWidthHeightRatio(float value)
public boolean getRandomize()
public void setRandomize(boolean value)
public boolean getSplitGraph()
public void setSplitGraph(boolean value)
public int getMultipleGraphsOrientation()
public void setMultipleGraphsOrientation(int value)
public double getPrecision()
public void setPrecision(double precision)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |