|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.activity.Activity prefuse.action.Action prefuse.action.GroupAction prefuse.action.layout.Layout prefuse.action.layout.graph.ForceDirectedLayout
public class ForceDirectedLayout
Layout that positions graph elements based on a physics simulation of interacting forces; by default, nodes repel each other, edges act as springs, and drag forces (similar to air resistance) are applied. This algorithm can be run for multiple iterations for a run-once layout computation or repeatedly run in an animated fashion for a dynamic and interactive layout.
The running time of this layout algorithm is the greater of O(N log N) and O(E), where N is the number of nodes and E the number of edges. The addition of custom force calculation modules may, however, increase this value.
The ForceSimulator
used to drive this layout
can be set explicitly, allowing any number of custom force directed layouts
to be created through the user's selection of included
Force
components. Each node in the layout is
mapped to a ForceItem
instance and each edge
to a Spring
instance for storing the state
of the simulation. See the prefuse.util.force
package for more.
Field Summary | |
---|---|
static java.lang.String |
FORCEITEM
The data field in which the parameters used by this layout are stored. |
static Schema |
FORCEITEM_SCHEMA
The schema for the parameters used by this layout. |
protected java.lang.String |
m_edgeGroup
|
protected java.lang.String |
m_nodeGroup
|
protected VisualItem |
referrer
|
Fields inherited from class prefuse.action.layout.Layout |
---|
m_anchor, m_bounds, m_bpts, m_insets, m_margin, m_tmpa, m_tmpb |
Fields inherited from class prefuse.action.GroupAction |
---|
m_group |
Fields inherited from class prefuse.action.Action |
---|
m_vis |
Fields inherited from class prefuse.activity.Activity |
---|
DEFAULT_STEP_TIME, INFINITY |
Constructor Summary | |
---|---|
ForceDirectedLayout(java.lang.String graph)
Create a new ForceDirectedLayout. |
|
ForceDirectedLayout(java.lang.String group,
boolean enforceBounds)
Create a new ForceDirectedLayout. |
|
ForceDirectedLayout(java.lang.String group,
boolean enforceBounds,
boolean runonce)
Create a new ForceDirectedLayout. |
|
ForceDirectedLayout(java.lang.String group,
ForceSimulator fsim,
boolean enforceBounds)
Create a new ForceDirectedLayout. |
|
ForceDirectedLayout(java.lang.String group,
ForceSimulator fsim,
boolean enforceBounds,
boolean runonce)
Create a new ForceDirectedLayout. |
Method Summary | |
---|---|
ForceSimulator |
getForceSimulator()
Get the force simulator driving this layout. |
int |
getIterations()
Get the number of iterations to use when computing a layout in run-once mode. |
protected float |
getMassValue(VisualItem n)
Get the mass value associated with the given node. |
long |
getMaxTimeStep()
Get the maximum timestep allowed for integrating node settings between runs of this layout. |
VisualItem |
getReferrer()
Get the referrer item to use to set x or y coordinates that are initialized to NaN. |
protected float |
getSpringCoefficient(EdgeItem e)
Get the spring coefficient for the given edge, which controls the tension or strength of the spring. |
protected float |
getSpringLength(EdgeItem e)
Get the spring length for the given edge. |
protected void |
initSimulator(ForceSimulator fsim)
Loads the simulator with all relevant force items and springs. |
void |
reset()
Reset the force simulation state for all nodes processed by this layout. |
void |
run(double frac)
Runs this Action, triggering whatever processing this Action performs. |
void |
setDataGroups(java.lang.String nodeGroup,
java.lang.String edgeGroup)
Explicitly sets the node and edge groups to use for this layout, overriding the group setting passed to the constructor. |
void |
setForceSimulator(ForceSimulator fsim)
Set the force simulator driving this layout. |
void |
setIterations(int iter)
Set the number of iterations to use when computing a layout in run-once mode. |
void |
setMaxTimeStep(long maxstep)
Set the maximum timestep allowed for integrating node settings between runs of this layout. |
void |
setReferrer(VisualItem referrer)
Set the referrer item to use to set x or y coordinates that are initialized to NaN. |
Methods inherited from class prefuse.action.layout.Layout |
---|
getLayoutAnchor, getLayoutBounds, setLayoutAnchor, setLayoutBounds, setMargin, setX, setY |
Methods inherited from class prefuse.action.GroupAction |
---|
getGroup, setGroup |
Methods inherited from class prefuse.action.Action |
---|
getVisualization, run, setVisualization |
Methods inherited from class prefuse.activity.Activity |
---|
addActivityListener, alwaysRunAfter, cancel, fireActivityCancelled, fireActivityFinished, fireActivityScheduled, fireActivityStarted, fireActivityStepped, getDuration, getNextTime, getPace, getPacingFunction, getStartTime, getStepTime, getStopTime, isEnabled, isRunning, isScheduled, removeActivityListener, run, runAfter, runAt, setDuration, setEnabled, setPacingFunction, setStartTime, setStepTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient VisualItem referrer
protected java.lang.String m_nodeGroup
protected java.lang.String m_edgeGroup
public static final java.lang.String FORCEITEM
public static final Schema FORCEITEM_SCHEMA
Constructor Detail |
---|
public ForceDirectedLayout(java.lang.String graph)
graph
- the data group to layout. Must resolve to a Graph instance.public ForceDirectedLayout(java.lang.String group, boolean enforceBounds)
group
- the data group to layout. Must resolve to a Graph instance.enforceBounds
- indicates whether or not the layout should require
that all node placements stay within the layout bounds.public ForceDirectedLayout(java.lang.String group, boolean enforceBounds, boolean runonce)
group
- the data group to layout. Must resolve to a Graph instance.enforceBounds
- indicates whether or not the layout should require
that all node placements stay within the layout bounds.runonce
- indicates if the layout will be run in a run-once or
animated fashion. In run-once mode, the layout will run for a set number
of iterations when invoked. In animation mode, only one iteration of the
layout is computed.public ForceDirectedLayout(java.lang.String group, ForceSimulator fsim, boolean enforceBounds)
group
- the data group to layout. Must resolve to a Graph instance.fsim
- the force simulator used to drive the layout computationenforceBounds
- indicates whether or not the layout should require
that all node placements stay within the layout bounds.public ForceDirectedLayout(java.lang.String group, ForceSimulator fsim, boolean enforceBounds, boolean runonce)
group
- the data group to layout. Must resolve to a Graph instance.fsim
- the force simulator used to drive the layout computationenforceBounds
- indicates whether or not the layout should require
that all node placements stay within the layout bounds.runonce
- indicates if the layout will be run in a run-once or
animated fashion. In run-once mode, the layout will run for a set number
of iterations when invoked. In animation mode, only one iteration of the
layout is computed.Method Detail |
---|
public long getMaxTimeStep()
public void setMaxTimeStep(long maxstep)
maxstep
- the maximum timestep allowed for integrating between two
layout stepspublic ForceSimulator getForceSimulator()
public void setForceSimulator(ForceSimulator fsim)
fsim
- the force simulatorpublic int getIterations()
public void setIterations(int iter)
iter
- the number of layout iterations to runpublic void setDataGroups(java.lang.String nodeGroup, java.lang.String edgeGroup)
nodeGroup
- the node data groupedgeGroup
- the edge data grouppublic void run(double frac)
Action
run
in class GroupAction
frac
- the fraction of this Action's duration that has elapsed.Action.run(double)
public void reset()
protected void initSimulator(ForceSimulator fsim)
fsim
- the force simulator driving this layoutprotected float getMassValue(VisualItem n)
n
- the node for which to compute the mass value
protected float getSpringLength(EdgeItem e)
e
- the edge for which to compute the spring length
protected float getSpringCoefficient(EdgeItem e)
e
- the edge for which to compute the spring coefficient.
public VisualItem getReferrer()
PrefuseLib.setX(VisualItem, VisualItem, double)
,
PrefuseLib.setY(VisualItem, VisualItem, double)
public void setReferrer(VisualItem referrer)
referrer
- the referrer item to use.PrefuseLib.setX(VisualItem, VisualItem, double)
,
PrefuseLib.setY(VisualItem, VisualItem, double)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |