public class ForceDirectedLayout extends Object implements GraphLayoutManager, Runnable
However, note that the implementation is a bit different to the equation 10.2 in the book such that:
| Constructor and Description |
|---|
ForceDirectedLayout(VisualGraph vGraph) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(VisualEdge vEdge)
Automatically called when a VisualEdge object has been added
to the VisualGraph object being laid out.
|
void |
addFixedVertex(VisualVertex vVertex)
Adds a VisuaLVertex that will not be moved from its position
during the layout operation of ForceDirectedLayout.
|
void |
addVertex(VisualVertex vVertex)
Automatically called when a VisualVertex object has been added
to the VisualGraph object being laid out.
|
void |
drawLayout()
This method is called to actually paint or draw the layout of the graph.
|
double |
getEletricalRepulsion()
Returns the eletrical repulsion between all vertices
The default value is 400.
|
double |
getIncrement()
Returns the increment by which the vertices gets closer
to the equilibrium or closer to the force.
|
double |
getSpringLength()
Returns the desired spring length for all edges.
|
double |
getStiffness()
Returns the stiffness for all edges.
|
boolean |
isInitialized()
Determines if the graph has been initially laid out.
|
boolean |
isVertexFixed(VisualVertex vVertex)
Returns true if the specified VisualVertex has
a fixed position.
|
void |
layout()
This method is called to layout the vertices in the graph, running
a thread to perform the layout if the thread is not running, or stopping
the thread if the thread is running.
|
void |
paintEdge(Graphics2D g2d,
VisualEdge vEdge) |
void |
removeEdge(VisualEdge vEdge)
Automatically called when a VisualEdge object is about to be removed
from the VisualGraph object being laid out.
|
void |
removeFixedVertex(VisualVertex vVertex)
Removes a VisualVertex from the list of VisualVertices
that has a fixed position.
|
void |
removeVertex(VisualVertex vVertex)
Automatically called when a VisualVertex object is about to be removed
from the VisualGraph object being laid out.
|
void |
routeEdge(Graphics2D g2d,
VisualEdge vEdge)
Automatically called when a VisualEdge object needs to be drawn.
|
void |
run() |
void |
setEletricalRepulsion(double repulsion)
Sets the value of the electrical repulsion between all vertices
|
void |
setIncrement(double increment)
Sets the increment by which the vertices gets close to the equilibrium
or gets closer to the direction of the force.
|
void |
setSpringLength(double length)
Sets the desired length of the spring among all edges
|
void |
setStiffness(double stiffness)
Sets the value of stiffness among all edges
|
public ForceDirectedLayout(VisualGraph vGraph)
public double getSpringLength()
public double getStiffness()
public double getEletricalRepulsion()
public double getIncrement()
public void setSpringLength(double length)
public void setStiffness(double stiffness)
public void setEletricalRepulsion(double repulsion)
public void setIncrement(double increment)
public void addFixedVertex(VisualVertex vVertex)
public boolean isVertexFixed(VisualVertex vVertex)
public void removeFixedVertex(VisualVertex vVertex)
public boolean isInitialized()
isInitialized in interface GraphLayoutManagerpublic void paintEdge(Graphics2D g2d, VisualEdge vEdge)
public void routeEdge(Graphics2D g2d, VisualEdge vEdge)
GraphLayoutManagerImplementations of this method should set the segments of the VisualEdge's GeneralPath by calling the methods moveTo(), lineTo(), curveTo(), and quadTo().
routeEdge in interface GraphLayoutManagerg2d - The Graphics2D object used for paintingpublic void layout()
layout in interface GraphLayoutManagerpublic void drawLayout()
drawLayout in interface GraphLayoutManagerpublic void addVertex(VisualVertex vVertex)
GraphLayoutManageraddVertex in interface GraphLayoutManagervVertex - The newly added VisualVertex object.public void removeEdge(VisualEdge vEdge)
GraphLayoutManagerremoveEdge in interface GraphLayoutManagervEdge - The VisualEdge object to be removedpublic void removeVertex(VisualVertex vVertex)
GraphLayoutManagerremoveVertex in interface GraphLayoutManagervVertex - The VisualVertex object to be removed.public void addEdge(VisualEdge vEdge)
GraphLayoutManageraddEdge in interface GraphLayoutManagervEdge - The newly added VisualEdge object.Copyright © 2019 JULIE Lab, Germany. All rights reserved.