public class GridAnnealingLayout extends AbstractGlobalLayout
Modifier and Type | Field and Description |
---|---|
protected double |
_cool
The cooling constant.
|
protected int |
_gh
The grid height.
|
protected java.lang.Object |
_graph
The original graph that is passed in by the user on
which the layout is applied.
|
protected java.lang.Object[][] |
_grid
The current grid configuration as the algorithm progresses.
|
protected int |
_gw
The grid width.
|
protected java.util.HashMap |
_map
A mapping from nodes to their corresponding logical grid
positions, stored as integer arrays of length 2.
|
protected double |
_minCost
The relative cost of the best grid configuration so far as the
algorithm progresses.
|
protected java.lang.Object[][] |
_minGrid
The best grid configuration so far as the algorithm progresses.
|
protected int |
_numIters
The number of iterations to cool over.
|
protected int |
_numMoves
The number of moves per iteration.
|
protected java.util.Random |
_random
The random number generator used in choosing which
nodes to swap.
|
protected double |
_sparseness
A sparseness measure for the layout.
|
_layoutTarget
Constructor and Description |
---|
GridAnnealingLayout(LayoutTarget target) |
Modifier and Type | Method and Description |
---|---|
protected double |
edgeCost(java.lang.Object edge)
Return the absolute cost of an individual edge.
|
double |
getCoolingFactor() |
int |
getIterationCount(int cnt) |
int |
getMoveCount(int cnt) |
double |
getSparseness()
Return the sparseness value of this layout; the default value
is 1.0.
|
protected int[] |
getXY(java.lang.Object node)
Return the logical X, Y positions of the given
node as an integer array of length 2.
|
protected void |
initGrid()
Initialize the grid and randomly assign nodes to vertices of
the grid.
|
void |
layout(java.lang.Object composite)
Perform the annealing layout algorithm on the given graph
in the context of the given layout target.
|
protected double |
nodeCost(java.lang.Object node)
Return the absolute cost of an individual node.
|
protected int |
numCrossings(java.lang.Object inEdge,
java.lang.Object composite)
Return the number of crossings between this edge and other
edges in the graph.
|
protected int |
numOverlaps(java.lang.Object inEdge,
java.lang.Object composite)
Return the number of overlaps between this edge and other edges
in the graph.
|
protected int |
numTees(java.lang.Object composite)
Return the number of instances of nodes that are being placed
on top of edges that they are not connected to.
|
void |
setCoolingFactor(double val)
Set the cooling factor to be a value greater than 0 and less
than or equal to 1.
|
void |
setIterationCount(int cnt)
Set the number of iterations to cool over.
|
void |
setMoveCount(int cnt)
Set the number of moves per iteration.
|
void |
setSparseness(double val)
Set the sparseness of this layout.
|
protected void |
setXY(java.lang.Object node,
int x,
int y)
Set the logical X, Y positions of the given node.
|
getLayoutTarget, setLayoutTarget
protected java.util.Random _random
protected java.lang.Object _graph
protected int _gw
protected int _gh
protected java.lang.Object[][] _grid
protected java.lang.Object[][] _minGrid
protected double _minCost
protected java.util.HashMap _map
protected double _sparseness
setSparseness(double)
protected int _numIters
protected int _numMoves
protected double _cool
public GridAnnealingLayout(LayoutTarget target)
protected double edgeCost(java.lang.Object edge)
EDGE_COST(e) = [ HEIGHT(e) + WIDTH(e) + ELBOW_PENALTY(e) + EDGE_OVERLAP_PENALTY * num_overlap(e) + CROSSING_PENALTY * num_crossing(e) ]
public double getCoolingFactor()
setCoolingFactor(double)
public int getIterationCount(int cnt)
setIterationCount(int)
public int getMoveCount(int cnt)
setMoveCount(int)
public double getSparseness()
setSparseness(double)
protected int[] getXY(java.lang.Object node)
protected void initGrid()
GH = H/W * sqrt(N) * SPARSENESSWhere H and W are the height and width of the viewport, N is the number of nodes in the graph, and SPARSENESS is some measure of the sparseness of the layout. A SPARSENESS of 1 will mean that the graph is tightly packed, and the packing amount decreases linearly with the SPARSENESS value.
setSparseness(double)
public void layout(java.lang.Object composite)
layout
in interface GlobalLayout
layout
in class AbstractGlobalLayout
protected double nodeCost(java.lang.Object node)
NODE_COST(n) = SUM [ EDGE_COST(n.edge(i)) ] + TEE_PENALTY * num_tee(g)
protected final int numCrossings(java.lang.Object inEdge, java.lang.Object composite)
protected final int numTees(java.lang.Object composite)
protected final int numOverlaps(java.lang.Object inEdge, java.lang.Object composite)
public void setCoolingFactor(double val)
public void setIterationCount(int cnt)
public void setMoveCount(int cnt)
public void setSparseness(double val)
protected void setXY(java.lang.Object node, int x, int y)