|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.graphstream.stream.SourceBase
org.graphstream.ui.layout.springbox.SpringBox
public class SpringBox
An implementation of spring algorithms to layout a graph.
This spring method use repulsive forces (electric field) between each nodes and attractive forces (springs) between each node connected by an edge. To speed up the algorithm, a n-tree is used to divide space. A Barnes-Hut like algorithm is used to speed up repulsion force influence when nodes are far away.
This algorithm can be configured using several attributes put on the graph :
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.graphstream.stream.SourceBase |
---|
SourceBase.ElementType |
Constructor Summary | |
---|---|
SpringBox()
|
|
SpringBox(boolean is3D)
|
|
SpringBox(boolean is3D,
Random randomNumberGenerator)
|
Method Summary | |
---|---|
void |
addListener(LayoutListener listener)
Add a listener for specific layout events. |
void |
clear()
Clears the whole nodes and edges structures |
void |
compute()
Method to call repeatedly to compute the layout. |
void |
edgeAdded(String graphId,
long time,
String edgeId,
String fromNodeId,
String toNodeId,
boolean directed)
An edge was inserted in graph. |
void |
edgeAttributeAdded(String graphId,
long time,
String edgeId,
String attribute,
Object value)
A edge attribute was added. |
void |
edgeAttributeChanged(String graphId,
long time,
String edgeId,
String attribute,
Object oldValue,
Object newValue)
A edge attribute was changed. |
void |
edgeAttributeRemoved(String graphId,
long time,
String edgeId,
String attribute)
A edge attribute was removed. |
void |
edgeRemoved(String graphId,
long time,
String edgeId)
An edge of graph was removed.The nodes the edge connects may already have been removed from the graph. |
void |
freezeNode(String id,
boolean on)
Freeze or un-freeze a node. |
double |
getForce()
The current layout force. |
Point3 |
getHiPoint()
Largest point in space of the layout bounding box. |
long |
getLastStepTime()
Time in nanoseconds used by the last call to step(). |
String |
getLayoutAlgorithmName()
Name of the layout algorithm. |
Point3 |
getLowPoint()
Smallest point in space of the layout bounding box. |
int |
getNodeMoved()
How many nodes moved during the last step?. |
int |
getQuality()
The current layout algorithm quality. |
org.miv.pherd.ParticleBox |
getSpatialIndex()
|
double |
getStabilization()
How close to stabilisation the layout algorithm is. |
double |
getStabilizationLimit()
Above which value a correct stabilisation is achieved? |
int |
getSteps()
Number of calls made to step() so far. |
void |
graphAttributeAdded(String graphId,
long time,
String attribute,
Object value)
A graph attribute was added. |
void |
graphAttributeChanged(String graphId,
long time,
String attribute,
Object oldValue,
Object newValue)
A graph attribute was changed. |
void |
graphAttributeRemoved(String graphId,
long time,
String attribute)
A graph attribute was removed. |
void |
graphCleared(String graphId,
long time)
The whole graph was cleared. |
void |
inputPos(String filename)
Read the nodes positions from a file. |
void |
moveNode(String id,
double dx,
double dy,
double dz)
Move a node by force to a new location. |
void |
nodeAdded(String graphId,
long time,
String nodeId)
A node was inserted in the given graph. |
void |
nodeAttributeAdded(String graphId,
long time,
String nodeId,
String attribute,
Object value)
A node attribute was added. |
void |
nodeAttributeChanged(String graphId,
long time,
String nodeId,
String attribute,
Object oldValue,
Object newValue)
A node attribute was changed. |
void |
nodeAttributeRemoved(String graphId,
long time,
String nodeId,
String attribute)
A node attribute was removed. |
void |
nodeRemoved(String graphId,
long time,
String nodeId)
A node was removed from the graph. |
void |
outputPos(String filename)
Output the nodes positions to a file. |
void |
particleAdded(Object id,
double x,
double y,
double z)
|
void |
particleAdded(Object id,
double x,
double y,
double z,
Object mark)
|
void |
particleAttributeChanged(Object id,
String attribute,
Object newValue,
boolean removed)
|
void |
particleMarked(Object id,
Object mark)
|
void |
particleMoved(Object id,
double x,
double y,
double z)
|
void |
particleRemoved(Object id)
|
void |
removeListener(LayoutListener listener)
Remove a listener for specific layout events. |
void |
setForce(double value)
The general "speed" of the algorithm. |
void |
setQuality(int qualityLevel)
Set the overall quality level. |
void |
setSendNodeInfos(boolean on)
If true, node informations messages are sent for every node. |
void |
setStabilizationLimit(double value)
Change the stabilisation limit for this layout algorithm. |
void |
shake()
Add a random vector whose length is 10% of the size of the graph to all node positions. |
void |
stepBegins(String graphId,
long time,
double step)
Since dynamic graphs are based on discrete event modifications, the notion of step is defined to simulate elapsed time between events. |
void |
stepFinished(int time)
|
Methods inherited from class org.graphstream.stream.SourceBase |
---|
addAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, removeAttributeSink, removeElementSink, removeSink, sendAttributeChangedEvent, sendAttributeChangedEvent, sendEdgeAdded, sendEdgeAdded, sendEdgeRemoved, sendEdgeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBegins |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.graphstream.stream.Source |
---|
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink |
Constructor Detail |
---|
public SpringBox()
public SpringBox(boolean is3D)
public SpringBox(boolean is3D, Random randomNumberGenerator)
Method Detail |
---|
public Point3 getLowPoint()
Layout
getLowPoint
in interface Layout
public Point3 getHiPoint()
Layout
getHiPoint
in interface Layout
public org.miv.pherd.ParticleBox getSpatialIndex()
public long getLastStepTime()
Layout
getLastStepTime
in interface Layout
public String getLayoutAlgorithmName()
Layout
getLayoutAlgorithmName
in interface Layout
public int getNodeMoved()
Layout
getNodeMoved
in interface Layout
public double getStabilization()
Layout
getStabilization
in interface Layout
public double getStabilizationLimit()
Layout
getStabilizationLimit
in interface Layout
public int getSteps()
Layout
getSteps
in interface Layout
public int getQuality()
Layout
getQuality
in interface Layout
public double getForce()
Layout
getForce
in interface Layout
public void setSendNodeInfos(boolean on)
Layout
setSendNodeInfos
in interface Layout
on
- If true, send node informations.public void addListener(LayoutListener listener)
Layout
addListener
in interface Layout
public void removeListener(LayoutListener listener)
Layout
removeListener
in interface Layout
public void setForce(double value)
Layout
setForce
in interface Layout
value
- A number in [0..1].public void setStabilizationLimit(double value)
Layout
The stabilisation is a number
between 0 and 1 that indicates how close to stabilisation (no nodes need to move) the
layout is. The value 1 means the layout is fully stabilised. Naturally this is often only
an indication only, for some algorithms, it is difficult to determine if the layout is
correct or acceptable enough. You can get the actual stabilisation limit using
Layout.getStabilizationLimit()
. You can get the actual stabilisation using
Layout.getStabilization()
.
Be careful, most layout classes do not use the stabilisation limit, this number is mostly
used the process that control the layout, like the LayoutRunner
for example. The
stabilisation limit is only an indication with a default set for each layout algorithm.
However this default can be changed using this method, or by storing on the graph an
attribute "layout.stabilization-limit" (or "layout.stabilisation-limit").
The convention is that the value 0 means that the process controlling the layout will not stop the layout (will therefore not consider the stabilisation limit). In other words the layout will compute endlessly.
setStabilizationLimit
in interface Layout
value
- The new stabilisation limit, 0 means no need to stabilise. Else a value larger than
zero or equal to 1 is accepted.public void setQuality(int qualityLevel)
Layout
setQuality
in interface Layout
qualityLevel
- The quality level in [0..4].public void clear()
Layout
clear
in interface Layout
public void compute()
Layout
This method implements the layout algorithm proper. It must be called in
a loop, until the layout stabilises. You can know if the layout is stable
by using the Layout.getNodeMoved()
method that returns the number of
node that have moved during the last call to step().
The listener is called by this method, therefore each call to step() will also trigger layout events, allowing to reproduce the layout process graphically for example. You can insert the listener only when the layout stabilised, and then call step() anew if you do not want to observe the layout process.
compute
in interface Layout
public void shake()
Layout
shake
in interface Layout
public void moveNode(String id, double dx, double dy, double dz)
Layout
moveNode
in interface Layout
id
- The node identifier.dx
- The node new X.dy
- The node new Y.dz
- The node new Z.public void freezeNode(String id, boolean on)
Layout
freezeNode
in interface Layout
id
- The node identifier.on
- If true the node is frozen.public void outputPos(String filename) throws IOException
Layout
outputPos
in interface Layout
IOException
public void inputPos(String filename) throws IOException
Layout
Layout.outputPos(String)
for
the file format.
inputPos
in interface Layout
IOException
public void particleAdded(Object id, double x, double y, double z, Object mark)
public void particleMarked(Object id, Object mark)
public void particleMoved(Object id, double x, double y, double z)
particleMoved
in interface org.miv.pherd.ParticleBoxListener
public void particleRemoved(Object id)
particleRemoved
in interface org.miv.pherd.ParticleBoxListener
public void stepFinished(int time)
stepFinished
in interface org.miv.pherd.ParticleBoxListener
public void particleAdded(Object id, double x, double y, double z)
particleAdded
in interface org.miv.pherd.ParticleBoxListener
public void particleAttributeChanged(Object id, String attribute, Object newValue, boolean removed)
particleAttributeChanged
in interface org.miv.pherd.ParticleBoxListener
public void edgeAdded(String graphId, long time, String edgeId, String fromNodeId, String toNodeId, boolean directed)
ElementSink
edgeAdded
in interface ElementSink
graphId
- Identifier of the graph where the edge was added.edgeId
- Identifier of the added edge.fromNodeId
- Identifier of the first node of the edge.toNodeId
- Identifier of the second node of the edge.directed
- If true, the edge is directed.public void nodeAdded(String graphId, long time, String nodeId)
ElementSink
nodeAdded
in interface ElementSink
graphId
- Identifier of the graph where the node was added.nodeId
- Identifier of the added node.public void edgeRemoved(String graphId, long time, String edgeId)
ElementSink
edgeRemoved
in interface ElementSink
graphId
- The graph where the edge will be removed.edgeId
- The edge that will be removed.public void nodeRemoved(String graphId, long time, String nodeId)
ElementSink
nodeRemoved
in interface ElementSink
graphId
- Identifier of the graph where the node will be removed.nodeId
- Identifier of the removed node.public void graphCleared(String graphId, long time)
ElementSink
graphCleared
in interface ElementSink
graphId
- The graph cleared.public void stepBegins(String graphId, long time, double step)
ElementSink
Since dynamic graphs are based on discrete event modifications, the notion of step is defined to simulate elapsed time between events. So a step is a event that occurs in the graph, it does not modify it but it gives a kind of timestamp that allow the tracking of the progress of the graph over the time.
This kind of event is useful for dynamic algorithms that listen to the dynamic graph and need to measure the time in the graph's evolution.
stepBegins
in interface ElementSink
graphId
- Identifier of the graph where the step starts.time
- A numerical value that may give a timestamp to track the
evolution of the graph over the time.public void graphAttributeAdded(String graphId, long time, String attribute, Object value)
AttributeSink
graphAttributeAdded
in interface AttributeSink
graphId
- Identifier of the graph where the attribute changed.attribute
- The attribute name.value
- The attribute new value.public void graphAttributeChanged(String graphId, long time, String attribute, Object oldValue, Object newValue)
AttributeSink
graphAttributeChanged
in interface AttributeSink
graphId
- Identifier of the graph where the attribute changed.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void graphAttributeRemoved(String graphId, long time, String attribute)
AttributeSink
graphAttributeRemoved
in interface AttributeSink
graphId
- Identifier of the graph where the attribute was removed.attribute
- The removed attribute name.public void nodeAttributeAdded(String graphId, long time, String nodeId, String attribute, Object value)
AttributeSink
nodeAttributeAdded
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.nodeId
- Identifier of the node whose attribute changed.attribute
- The attribute name.value
- The attribute new value.public void nodeAttributeChanged(String graphId, long time, String nodeId, String attribute, Object oldValue, Object newValue)
AttributeSink
nodeAttributeChanged
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.nodeId
- Identifier of the node whose attribute changed.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void nodeAttributeRemoved(String graphId, long time, String nodeId, String attribute)
AttributeSink
nodeAttributeRemoved
in interface AttributeSink
graphId
- Identifier of the graph where the attribute was removed.nodeId
- Identifier of the node whose attribute was removed.attribute
- The removed attribute name.public void edgeAttributeAdded(String graphId, long time, String edgeId, String attribute, Object value)
AttributeSink
edgeAttributeAdded
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.edgeId
- Identifier of the edge whose attribute changed.attribute
- The attribute name.value
- The attribute new value.public void edgeAttributeChanged(String graphId, long time, String edgeId, String attribute, Object oldValue, Object newValue)
AttributeSink
edgeAttributeChanged
in interface AttributeSink
graphId
- Identifier of the graph where the change occurred.edgeId
- Identifier of the edge whose attribute changed.attribute
- The attribute name.oldValue
- The attribute old value.newValue
- The attribute new value.public void edgeAttributeRemoved(String graphId, long time, String edgeId, String attribute)
AttributeSink
edgeAttributeRemoved
in interface AttributeSink
graphId
- Identifier of the graph where the attribute was removed.edgeId
- Identifier of the edge whose attribute was removed.attribute
- The removed attribute name.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |