|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectinfo.aduna.linkmap.layout.GraphLayoutManager
info.aduna.linkmap.layout.IteratingLayoutManager
info.aduna.linkmap.layout.SpringLayoutManager
public class SpringLayoutManager
SpringLayoutManager is an IteratingLayoutManager that implements the "spring embedder" algorithm: it simulates a physical model of Vertices that repel each other like electrically charged particles, with the Edges between them acting like springs that hold them together. When used with carefully tested parameters - the spring embedder algorithm is quite sensitive when it comes to layout parameters, with regard to speed, quality and ability to reach an equilibrium -, SpringLayoutManager can calculate an aesthetically pleasing and almost organic layout for a Graph.
SpringLayoutManager assumes that the graph (or the part of it) for which it is calculating a layout, is connected, i.e. that there is a path between every pair of vertices in the graph (ignoring directionality). It is able to calculate the layout of non-connected graphs, but it will never stabilize in such a case (or only after a very large number of iterations): the various subgraphs will repel each other with absolutely no forces between them trying to hold them together. In order to calculate a reasonable layout for such a graph, SpringLayoutManager can be used in conjunction with SubgraphRelocationManager. The SpringLayoutManager is then used as a GraphLayoutManager for every connected subgraph, which are combined into one dense rectangular graph structure by the SubgraphRelocationManager.
During the design and implementation of this class, care has been taken to produce an API which allows for extreme customization through method overriding. This means that SpringLayoutManager can be tuned into the extreme for a specific kind of Graph rather easily. See the documentation of the methods for more information on this matter.
| Nested Class Summary | |
|---|---|
static class |
SpringLayoutManager.EdgeAttribute
|
static class |
SpringLayoutManager.VertexAttribute
|
| Field Summary | |
|---|---|
static double |
DEFAULT_ADAPTATION
The default value of the adaptation parameter. |
static double |
DEFAULT_ATTRACTION
The default value of the attraction parameter. |
static double |
DEFAULT_AVERAGE_MOVEMENT_THRESHOLD
The default value of the average movement threshold. |
static double |
DEFAULT_CHARGE
The default charge of a vertex. |
static double |
DEFAULT_MASS
The default mass of a vertex. |
static double |
DEFAULT_MAXIMUM_ALLOWED_MOVEMENT
The default value of the maximum allowed movement parameter. |
static double |
DEFAULT_MAXIMUM_OBSERVED_MOVEMENT_THRESHOLD
The default value of the maximum observed movement threshold. |
static double |
DEFAULT_MOMENTUM
The default value of the momentum parameter. |
static double |
DEFAULT_REPULSION
The default value of the repulsion parameter. |
static double |
DEFAULT_SPRING_CONSTANT
The default spring constant of an edge. |
static double |
DEFAULT_SPRING_LENGTH
The default spring length of an edge. |
static int |
DEFAULT_TRANSLATION_INTERVAL
The default value of the translation interval parameter. |
| Fields inherited from class info.aduna.linkmap.layout.IteratingLayoutManager |
|---|
UNDEFINED_MAX_ITERATION |
| Constructor Summary | |
|---|---|
SpringLayoutManager()
Create a new SpringLayoutManager which will calculate the layout for a (yet unspecified) Graph. |
|
| Method Summary | |
|---|---|
SpringLayoutManager.EdgeAttribute |
createEdgeAttribute(Edge edge)
Creates a new EdgeAttribute for the specified Edge. |
LayoutConverter |
createLayoutConverter()
Returns a LayoutConverter that allows the rendering mechanism to retrieve and adapt the layout of a graph, while abstracting from the specified GraphLayoutManager implementation that is used. |
SpringLayoutManager.VertexAttribute |
createVertexAttribute(Vertex vertex)
Creates a new VertexAttribute for the specified Vertex. |
void |
doLayout()
Calculates a layout for the Graph registered in this SpringLayoutManager. |
void |
doLayout(Collection<SpringLayoutManager.VertexAttribute> vertexAttributes,
Collection<SpringLayoutManager.EdgeAttribute> edgeAttributes)
Calculates a layout for a Graph represented by the specified Lists of VertexAttributes and EdgeAttributes. |
void |
doLayout(SpringLayoutManager.VertexAttribute[] vertexAttributes,
SpringLayoutManager.EdgeAttribute[] edgeAttributes)
Calculates a layout for a Graph represented by the specified arrays of VertexAttributes and EdgeAttributes. |
double |
getAdaptation()
|
double |
getAttraction()
|
double |
getAverageMovementThreshold()
|
double |
getCharge()
|
ArrayList<SpringLayoutManager.EdgeAttribute> |
getEdgeAttributes(Collection<Edge> edges)
Returns an ArrayList containing all EdgeAttributes occuring in the specified Graph. |
double |
getMass()
|
double |
getMaximumAllowedMovement()
|
double |
getMaximumObservedMovement()
|
double |
getMaximumObservedMovementThreshold()
|
double |
getMomentum()
|
double |
getRepulsion()
|
double |
getSpringConstant()
|
double |
getSpringLength()
|
double |
getSummedMovement()
|
int |
getTranslationInterval()
|
ArrayList<SpringLayoutManager.VertexAttribute> |
getVertexAttributes(Collection<Vertex> vertices)
Returns an ArrayList containing all VertexAttributes occuring in the specified Graph. |
void |
initialize(Graph graph)
Makes sure all Vertices and Edges in the specified Graph have layout attributes. |
void |
initLayoutParameters()
Initializes the layout parameters of this SpringLayoutManager. |
void |
initThresholds()
Initializes the quality thresholds of this SpringLayoutManager. |
boolean |
isAverageMovementThresholdEnabled()
Returns whether averageMovementThreshold is greater than or equal to zero. |
boolean |
isMaximumObservedMovementThresholdEnabled()
Returns whether maximumObservedMovementThreshold is greater than or equal to zero. |
void |
move(SpringLayoutManager.VertexAttribute attribute)
Moves a Vertex represented by the specified VertexAttribute. |
void |
randomizeCoordinates(Graph graph,
long seed)
Gives the Vertices in the specified Graph a random position in the area of the rectange (0, 0, 500, 500). |
void |
reset(SpringLayoutManager.EdgeAttribute attribute)
Resets the properties of the specified EdgeAttribute to its initial values. |
void |
reset(SpringLayoutManager.VertexAttribute attribute)
Resets the properties of the specified VertexAttribute to its initial values. |
void |
resetAttributes()
Sets the properties of all layout attributes inside the current Graph to their initial values. |
void |
resetAttributes(Graph graph)
Sets the properties of all layout attributes of the specified Graph to their initial values. |
void |
setAdaptation(double adaptation)
|
void |
setAttraction(double attraction)
|
void |
setAverageMovementThreshold(double averageMovementThreshold)
|
void |
setCharge(double charge)
Set the value of the standard vertex charge. |
void |
setEdgeAttribute(Edge edge)
Checks whether the specified Edge already has a layout attribute and, if not, installs one. |
void |
setMass(double mass)
Set the value of the standard vertex mass. |
void |
setMaximumAllowedMovement(double maximumAllowedMovement)
|
void |
setMaximumObservedMovement(double maximumObservedMovement)
|
void |
setMaximumObservedMovementThreshold(double maximumObservedMovementThreshold)
|
void |
setMomentum(double momentum)
|
void |
setRepulsion(double repulsion)
|
void |
setSpringConstant(double constant)
Set the value of the standard spring constant. |
void |
setSpringLength(double length)
Set the value of the standard spring length. |
void |
setSummedMovement(double summedMovement)
|
void |
setTranslationInterval(int translationInterval)
Sets the translation interval. |
void |
setVertexAttribute(Vertex vertex)
Checks whether the specified Vertex already has a layout attribute and, if not, installs one. |
| Methods inherited from class info.aduna.linkmap.layout.IteratingLayoutManager |
|---|
continueLayout, getIteration, getMaxIteration, handlePauseLayout, increaseIteration, isMaxIterationReached, pauseLayout, pauseLayoutRequested, setIteration, setMaxIteration, setPauseLayout, setStopLayout, stopLayout, stopLayoutRequested |
| Methods inherited from class info.aduna.linkmap.layout.GraphLayoutManager |
|---|
getGraph, run, setGraph |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double DEFAULT_MASS
public static final double DEFAULT_CHARGE
public static final double DEFAULT_SPRING_LENGTH
public static final double DEFAULT_SPRING_CONSTANT
public static final double DEFAULT_REPULSION
public static final double DEFAULT_ATTRACTION
public static final double DEFAULT_ADAPTATION
public static final int DEFAULT_TRANSLATION_INTERVAL
public static final double DEFAULT_MOMENTUM
public static final double DEFAULT_MAXIMUM_ALLOWED_MOVEMENT
public static final double DEFAULT_AVERAGE_MOVEMENT_THRESHOLD
public static final double DEFAULT_MAXIMUM_OBSERVED_MOVEMENT_THRESHOLD
| Constructor Detail |
|---|
public SpringLayoutManager()
| Method Detail |
|---|
public void initLayoutParameters()
public void initThresholds()
public void setRepulsion(double repulsion)
public double getRepulsion()
public void setAttraction(double attraction)
public double getAttraction()
public void setAdaptation(double adaptation)
public double getAdaptation()
public void setTranslationInterval(int translationInterval)
public int getTranslationInterval()
public void setMomentum(double momentum)
public double getMomentum()
public void setMaximumAllowedMovement(double maximumAllowedMovement)
public double getMaximumAllowedMovement()
public void setMass(double mass)
public double getMass()
public void setCharge(double charge)
public double getCharge()
public void setSpringConstant(double constant)
public double getSpringConstant()
public void setSpringLength(double length)
public double getSpringLength()
public void setSummedMovement(double summedMovement)
public double getSummedMovement()
public void setMaximumObservedMovement(double maximumObservedMovement)
public double getMaximumObservedMovement()
public void setAverageMovementThreshold(double averageMovementThreshold)
public double getAverageMovementThreshold()
public boolean isAverageMovementThresholdEnabled()
public void setMaximumObservedMovementThreshold(double maximumObservedMovementThreshold)
public double getMaximumObservedMovementThreshold()
public boolean isMaximumObservedMovementThresholdEnabled()
public void initialize(Graph graph)
initialize in class GraphLayoutManagerpublic void setVertexAttribute(Vertex vertex)
public void setEdgeAttribute(Edge edge)
public SpringLayoutManager.VertexAttribute createVertexAttribute(Vertex vertex)
public SpringLayoutManager.EdgeAttribute createEdgeAttribute(Edge edge)
public void randomizeCoordinates(Graph graph,
long seed)
public void resetAttributes()
public void resetAttributes(Graph graph)
public void reset(SpringLayoutManager.VertexAttribute attribute)
public void reset(SpringLayoutManager.EdgeAttribute attribute)
public void doLayout()
doLayout in class GraphLayoutManager
public void doLayout(Collection<SpringLayoutManager.VertexAttribute> vertexAttributes,
Collection<SpringLayoutManager.EdgeAttribute> edgeAttributes)
public void doLayout(SpringLayoutManager.VertexAttribute[] vertexAttributes,
SpringLayoutManager.EdgeAttribute[] edgeAttributes)
public void move(SpringLayoutManager.VertexAttribute attribute)
public LayoutConverter createLayoutConverter()
GraphLayoutManager
createLayoutConverter in class GraphLayoutManagerpublic ArrayList<SpringLayoutManager.VertexAttribute> getVertexAttributes(Collection<Vertex> vertices)
public ArrayList<SpringLayoutManager.EdgeAttribute> getEdgeAttributes(Collection<Edge> edges)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||