public class HierarchicalLayout extends PipeBase implements Layout
Modifier and Type | Class and Description |
---|---|
(package private) static class |
HierarchicalLayout.Box |
(package private) static class |
HierarchicalLayout.LevelBox |
(package private) static class |
HierarchicalLayout.Position |
static class |
HierarchicalLayout.Rendering |
SourceBase.ElementType
Modifier and Type | Field and Description |
---|---|
(package private) double |
distanceBetweenLevels |
(package private) Point3 |
hi |
(package private) Graph |
internalGraph |
(package private) long |
lastStep |
(package private) double |
levelHeight |
(package private) double |
levelWidth |
(package private) Point3 |
lo |
(package private) int |
nodeMoved |
(package private) HashMap<String,HierarchicalLayout.Position> |
nodesPosition |
(package private) HierarchicalLayout.Rendering |
renderingType |
(package private) LinkedList<String> |
roots |
(package private) boolean |
structureChanged |
attrSinks, eltsSinks, eventProcessing, eventQueue, sourceId, sourceTime
Constructor and Description |
---|
HierarchicalLayout() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the whole nodes and edges structures
|
void |
compute()
Method to call repeatedly to compute the layout.
|
protected void |
computePositions() |
void |
edgeAdded(String sourceId,
long timeId,
String edgeId,
String fromId,
String toId,
boolean directed)
An edge was inserted in graph.
|
void |
edgeRemoved(String sourceId,
long timeId,
String edgeId)
An edge of graph was removed.The nodes the edge connects may already have
been removed from the graph.
|
protected void |
explore(Node parent,
Node who,
SpanningTree tree,
int[] levels) |
void |
freezeNode(String id,
boolean frozen)
Freeze or un-freeze a node.
|
protected static HierarchicalLayout.Box |
getBox(Node node) |
protected static HierarchicalLayout.Box |
getChildrenBox(Node 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 |
getNodeMovedCount()
How many nodes moved during the last step?.
|
double |
getQuality()
The current layout algorithm quality.
|
double |
getStabilization()
Estimate of how close to stabilization the layout algorithm is.
|
double |
getStabilizationLimit()
Above which value a correct stabilization is achieved?
|
int |
getSteps()
Number of calls made to step() so far.
|
void |
graphCleared(String sourceId,
long timeId)
The whole graph was cleared.
|
void |
inputPos(String filename) |
static void |
main(String... args) |
void |
moveNode(String id,
double x,
double y,
double z)
Move a node by force to a new location.
|
void |
nodeAdded(String sourceId,
long timeId,
String nodeId)
A node was inserted in the given graph.
|
void |
nodeRemoved(String sourceId,
long timeId,
String nodeId)
A node was removed from the graph.
|
void |
outputPos(String filename) |
protected void |
publishPositions() |
protected void |
renderBox(HierarchicalLayout.Box box) |
protected void |
setBox(HierarchicalLayout.Box box,
Node node) |
void |
setForce(double value)
The general "speed" of the algorithm.
|
void |
setQuality(double qualityLevel)
Set the overall quality level, a number between 0 and 1 with 1 the
highest quality available, but often with a slower computation.
|
void |
setRoots(String... rootsId) |
void |
setSendNodeInfos(boolean send)
If true, node informations messages are sent for every node.
|
void |
setStabilizationLimit(double value)
Change the stabilization 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.
|
edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, nodeAttributeAdded, nodeAttributeChanged, nodeAttributeRemoved, stepBegins
addAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, manageEvents, removeAttributeSink, removeElementSink, removeSink, sendAttributeChangedEvent, sendAttributeChangedEvent, sendEdgeAdded, sendEdgeAdded, sendEdgeAttributeAdded, sendEdgeAttributeAdded, sendEdgeAttributeChanged, sendEdgeAttributeChanged, sendEdgeAttributeRemoved, sendEdgeAttributeRemoved, sendEdgeRemoved, sendEdgeRemoved, sendGraphAttributeAdded, sendGraphAttributeAdded, sendGraphAttributeChanged, sendGraphAttributeChanged, sendGraphAttributeRemoved, sendGraphAttributeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeAttributeAdded, sendNodeAttributeAdded, sendNodeAttributeChanged, sendNodeAttributeChanged, sendNodeAttributeRemoved, sendNodeAttributeRemoved, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBegins
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSink
edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, nodeAttributeAdded, nodeAttributeChanged, nodeAttributeRemoved
stepBegins
final HashMap<String,HierarchicalLayout.Position> nodesPosition
final LinkedList<String> roots
final Graph internalGraph
boolean structureChanged
HierarchicalLayout.Rendering renderingType
long lastStep
int nodeMoved
double distanceBetweenLevels
double levelWidth
double levelHeight
public HierarchicalLayout()
public void clear()
Layout
public void compute()
Layout
This method implements the layout algorithm proper. It must be called in
a loop, until the layout stabilizes. You can know if the layout is stable
by using the Layout.getNodeMovedCount()
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 stabilized, and then call step() anew if you do not want to observe the layout process.
protected void computePositions()
protected void setBox(HierarchicalLayout.Box box, Node node)
protected static HierarchicalLayout.Box getBox(Node node)
protected static HierarchicalLayout.Box getChildrenBox(Node node)
protected void renderBox(HierarchicalLayout.Box box)
protected void explore(Node parent, Node who, SpanningTree tree, int[] levels)
protected void publishPositions()
public void freezeNode(String id, boolean frozen)
Layout
freezeNode
in interface Layout
id
- The node identifier.frozen
- If true the node is frozen.public double getForce()
Layout
public Point3 getHiPoint()
Layout
getHiPoint
in interface Layout
public long getLastStepTime()
Layout
getLastStepTime
in interface Layout
public String getLayoutAlgorithmName()
Layout
getLayoutAlgorithmName
in interface Layout
public Point3 getLowPoint()
Layout
getLowPoint
in interface Layout
public int getNodeMovedCount()
Layout
getNodeMovedCount
in interface Layout
public double getQuality()
Layout
getQuality
in interface Layout
public double getStabilization()
Layout
getStabilization
in interface Layout
public double getStabilizationLimit()
Layout
getStabilizationLimit
in interface Layout
public int getSteps()
Layout
public void inputPos(String filename) throws IOException
IOException
public void moveNode(String id, double x, double y, double z)
Layout
public void outputPos(String filename) throws IOException
IOException
public void setForce(double value)
Layout
public void setQuality(double qualityLevel)
Layout
setQuality
in interface Layout
qualityLevel
- The quality level, a number between 0 and 1.public void setSendNodeInfos(boolean send)
Layout
setSendNodeInfos
in interface Layout
send
- If true, send node informations to a "layout.info" attribute.public void setStabilizationLimit(double value)
Layout
The stabilization is a number between 0 and 1 that indicates how close to
stabilization (no nodes need to move) the layout is. The value 1 means
the layout is fully stabilized. 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
stabilization limit using Layout.getStabilizationLimit()
. You can get
the actual stabilization using Layout.getStabilization()
.
Be careful, most layout classes do not use the stabilization limit, this
number is mostly used the process that control the layout, like the
LayoutRunner
for example. The stabilization 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 stabilization limit). In other words the layout will compute endlessly.
setStabilizationLimit
in interface Layout
value
- The new stabilization limit, 0 means no need to stabilize.
Else a value larger than zero or equal to 1 is accepted.public void shake()
Layout
public void nodeAdded(String sourceId, long timeId, String nodeId)
ElementSink
nodeAdded
in interface ElementSink
nodeAdded
in class PipeBase
sourceId
- Identifier of the graph where the node was added.nodeId
- Identifier of the added node.public void nodeRemoved(String sourceId, long timeId, String nodeId)
ElementSink
nodeRemoved
in interface ElementSink
nodeRemoved
in class PipeBase
sourceId
- Identifier of the graph where the node will be removed.nodeId
- Identifier of the removed node.public void edgeAdded(String sourceId, long timeId, String edgeId, String fromId, String toId, boolean directed)
ElementSink
edgeAdded
in interface ElementSink
edgeAdded
in class PipeBase
sourceId
- Identifier of the graph where the edge was added.edgeId
- Identifier of the added edge.fromId
- Identifier of the first node of the edge.toId
- Identifier of the second node of the edge.directed
- If true, the edge is directed.public void edgeRemoved(String sourceId, long timeId, String edgeId)
ElementSink
edgeRemoved
in interface ElementSink
edgeRemoved
in class PipeBase
sourceId
- The graph where the edge will be removed.edgeId
- The edge that will be removed.public void graphCleared(String sourceId, long timeId)
ElementSink
graphCleared
in interface ElementSink
graphCleared
in class PipeBase
sourceId
- The graph cleared.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses