|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.graph.layout.AbstractGlobalLayout
diva.graph.layout.GridAnnealingLayout
public class GridAnnealingLayout
A simple layout which places nodes on a grid using a cost function. It performs the following simple-minded algorithm:
Field Summary | |
---|---|
protected double |
_cool
The cooling constant. |
protected int |
_gh
The grid height. |
protected Object |
_graph
The original graph that is passed in by the user on which the layout is applied. |
protected Object[][] |
_grid
The current grid configuration as the algorithm progresses. |
protected int |
_gw
The grid width. |
protected 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 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 Random |
_random
The random number generator used in choosing which nodes to swap. |
protected double |
_sparseness
A sparseness measure for the layout. |
Constructor Summary | |
---|---|
GridAnnealingLayout(LayoutTarget target)
|
Method Summary | |
---|---|
protected double |
edgeCost(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(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(Object composite)
Perform the annealing layout algorithm on the given graph in the context of the given layout target. |
protected double |
nodeCost(Object node)
Return the absolute cost of an individual node. |
protected int |
numCrossings(Object inEdge,
Object composite)
Return the number of crossings between this edge and other edges in the graph. |
protected int |
numOverlaps(Object inEdge,
Object composite)
Return the number of overlaps between this edge and other edges in the graph. |
protected int |
numTees(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(Object node,
int x,
int y)
Set the logical X, Y positions of the given node. |
Methods inherited from class diva.graph.layout.AbstractGlobalLayout |
---|
getLayoutTarget, setLayoutTarget |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Random _random
protected Object _graph
protected int _gw
protected int _gh
protected Object[][] _grid
protected Object[][] _minGrid
protected double _minCost
protected HashMap _map
protected double _sparseness
setSparseness(double)
protected int _numIters
protected int _numMoves
protected double _cool
Constructor Detail |
---|
public GridAnnealingLayout(LayoutTarget target)
Method Detail |
---|
protected double edgeCost(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(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(Object composite)
layout
in interface GlobalLayout
layout
in class AbstractGlobalLayout
protected double nodeCost(Object node)
NODE_COST(n) = SUM [ EDGE_COST(n.edge(i)) ] + TEE_PENALTY * num_tee(g)
protected final int numCrossings(Object inEdge, Object composite)
protected final int numTees(Object composite)
protected final int numOverlaps(Object inEdge, 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(Object node, int x, int y)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |