|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gicentre.utils.network.ParticleViewer
public class ParticleViewer
Allows particles to be viewed and animated. Suitable for spring embedded / force directed layouts for arranging networks and other collections of interacting objects. Note this class relies on the traer physics library for particle management and the traer animation library for smooth camera movement.
Constructor Summary | |
---|---|
ParticleViewer(processing.core.PApplet parent,
int width,
int height)
Initialises the particle viewer. |
Method Summary | |
---|---|
boolean |
addEdge(Edge edge)
Adds the given edge to those to be displayed in the viewer. |
boolean |
addForce(Node node1,
Node node2,
float force)
Creates a attractive or repulsive force between the two given nodes. |
boolean |
addForce(Node node1,
Node node2,
float force,
float minDistance)
Creates a attractive or repulsive force between the two given nodes. |
void |
addNode(Node node)
Adds a node to those to be displayed in the viewer. |
boolean |
addSpring(Node node1,
Node node2,
float length)
Creates a spring between the two given nodes. |
void |
draw()
Updates the particle view. |
void |
dropSelected()
Releases the mouse-selected node so that it readjusts in response to other node positions. |
traer.physics.Particle |
getParticle(Node node)
Provides the particle associated with the given node. |
void |
resetView()
Resets the zoomed view to show the entire network. |
void |
selectNearestWithMouse()
Allows a node to be selected with the mouse. |
void |
setDrag(float drag)
Sets the drag on all particles in the system. |
boolean |
tether(Node node,
float strength)
Tethers the given node to its location with the given strength. |
void |
updateParticles()
Updates the positions of nodes and edges in the viewer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParticleViewer(processing.core.PApplet parent, int width, int height)
parent
- Parent sketch in which this viewer is to be drawn.Method Detail |
---|
public void draw()
public void updateParticles()
public void setDrag(float drag)
drag
- Drag effect (larger numbers slow down movement).public boolean addForce(Node node1, Node node2, float force)
node1
- First of the two nodes to have a force between them.node2
- Second of the two nodes to have a force between them.force
- Force to create between the two nodes. If positive, the nodes will attract
each other, if negative they will repulse. The larger the magnitude the stronger the force.
public boolean addForce(Node node1, Node node2, float force, float minDistance)
node1
- First of the two nodes to have a force between them.node2
- Second of the two nodes to have a force between them.force
- Force to create between the two nodes. If positive, the nodes will attract
each other, if negative they will repulse. The larger the magnitude the stronger the force.minDistance
- Minimum distance within which no force is applied.
public boolean addSpring(Node node1, Node node2, float length)
node1
- First of the two nodes to have a spring between them.node2
- Second of the two nodes to have a spring between them.length
- The length of this spring (natural rest distance at which the two nodes would sit).
public boolean tether(Node node, float strength)
node
- The node to be tethered.strength
- Strength of the tether.
public traer.physics.Particle getParticle(Node node)
node
- The node for which the associated particle is to be retrieved.
public void addNode(Node node)
node
- Node to add to the viewer.public boolean addEdge(Edge edge)
edge
- Edge to add to the display.
public void selectNearestWithMouse()
public void dropSelected()
public void resetView()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |