org.graphstream.boids
Class BoidGraph

java.lang.Object
  extended by org.graphstream.graph.implementations.AbstractElement
      extended by org.graphstream.graph.implementations.AbstractGraph
          extended by org.graphstream.graph.implementations.AdjacencyListGraph
              extended by org.graphstream.boids.BoidGraph
All Implemented Interfaces:
Iterable<org.graphstream.graph.Node>, org.graphstream.graph.Element, org.graphstream.graph.Graph, org.graphstream.graph.Structure, org.graphstream.stream.AttributeSink, org.graphstream.stream.ElementSink, org.graphstream.stream.Pipe, org.graphstream.stream.Sink, org.graphstream.stream.Source

public class BoidGraph
extends org.graphstream.graph.implementations.AdjacencyListGraph

Represents a boid simulation and their underlying interaction graph.

Author:
Damien Olivier, Guilhelm Savin, Antoine Dutot

Nested Class Summary
static class BoidGraph.Parameter
           
 
Nested classes/interfaces inherited from class org.graphstream.graph.implementations.AbstractElement
org.graphstream.graph.implementations.AbstractElement.AttributeChangeEvent
 
Field Summary
static boolean VERBOSE
           
 
Fields inherited from class org.graphstream.graph.implementations.AdjacencyListGraph
DEFAULT_EDGE_CAPACITY, DEFAULT_NODE_CAPACITY, GROW_FACTOR
 
Constructor Summary
BoidGraph()
          New boids simulation represented as an interaction graph.
BoidGraph(String dgsConfig)
          New boids simulation represented as an interaction graph.
 
Method Summary
 void addBoidGraphListener(BoidGraphListener listener)
          Register a listener for boid specific events.
 BoidSpecies addDefaultSpecies()
          Add a species with name "default" if does not yet exists.
<T extends org.graphstream.graph.Node>
T
addNode(String nodeId)
           
 void deleteSpecies(String name)
          Remove a species.
 org.graphstream.ui.swingViewer.Viewer display(boolean autoLayout)
           
 double getArea()
           
 BoidSpecies getDefaultSpecies()
          The species whose name is "default".
 org.miv.pherd.geom.Point3 getHighAnchor()
           
 org.miv.pherd.geom.Point3 getLowAnchor()
           
 int getMaxSteps()
           
 BoidSpecies getOrCreateSpecies(String name)
           
 BoidSpecies getOrCreateSpecies(String name, String clazz)
           
 Random getRandom()
          The random number generator used.
 long getRandomSeed()
           
 int getSleepTime()
           
 BoidSpecies getSpecies(String name)
          The species with the given name.
 int getSpeciesCount()
          The number of boid species actually.
 boolean isForcesAttributesStored()
           
 boolean isLooping()
           
 boolean isNormalizeMode()
           
 void loadDGSConfiguration(InputStream in)
          Load configuration from a dgs file.
 void loadDGSConfiguration(String dgs)
          Load configuration from a dgs file or resource.
 void loop()
          Run the simulation in a loop.
static void main(String... args)
           
 void removeBoidGraphListener(BoidGraphListener listener)
          Unregister a listener for boid specific events.
 void set(BoidGraph.Parameter param, String value)
           
 void set(String paramName, String value)
           
 void setArea(double area)
           
 void setForcesFactory(BoidForcesFactory bff)
          Set the factory used to instantiate the force system to use.
 void setMaxSteps(int maxSteps)
           
 void setNormalizeMode(boolean on)
           
 void setRandomSeed(long randomSeed)
           
 void setSleepTime(int sleepTime)
           
 void setStoreForcesAttributes(boolean storeForcesAttributes)
           
 void step()
           
 void stepBegins(double step)
           
 void stopLoop()
          Stop the main simulation loop.
 
Methods inherited from class org.graphstream.graph.implementations.AdjacencyListGraph
getEdge, getEdge, getEdgeCount, getEdgeIterator, getNode, getNode, getNodeCount, getNodeIterator
 
Methods inherited from class org.graphstream.graph.implementations.AbstractGraph
addAttributeSink, addEdge, addEdge, addEdge, addEdge, addEdge, addEdge, addElementSink, addSink, attributeSinks, clear, clearAttributeSinks, clearElementSinks, clearSinks, display, edgeAdded, edgeAttributeAdded, edgeAttributeChanged, edgeAttributeRemoved, edgeFactory, edgeRemoved, elementSinks, getEachEdge, getEachNode, getEdgeSet, getNodeSet, getStep, graphAttributeAdded, graphAttributeChanged, graphAttributeRemoved, graphCleared, isAutoCreationEnabled, isStrict, iterator, nodeAdded, nodeAttributeAdded, nodeAttributeChanged, nodeAttributeRemoved, nodeFactory, nodeRemoved, nullAttributesAreErrors, read, read, removeAttributeSink, removeEdge, removeEdge, removeEdge, removeEdge, removeEdge, removeEdge, removeElementSink, removeNode, removeNode, removeNode, removeSink, setAutoCreate, setEdgeFactory, setNodeFactory, setNullAttributesAreErrors, setStrict, stepBegins, write, write
 
Methods inherited from class org.graphstream.graph.implementations.AbstractElement
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graphstream.graph.Element
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
 

Field Detail

VERBOSE

public static boolean VERBOSE
Constructor Detail

BoidGraph

public BoidGraph()
New boids simulation represented as an interaction graph.

All parameters are set to defaults.


BoidGraph

public BoidGraph(String dgsConfig)
          throws IOException
New boids simulation represented as an interaction graph.

This pre-load a configuration from a DGS file.

Parameters:
dgsConfig - The initial configuration in DGS format.
Throws:
IOException - If the DGS cannot be read.
Method Detail

loadDGSConfiguration

public void loadDGSConfiguration(String dgs)
                          throws IOException
Load configuration from a dgs file or resource. See 'configExample.dgs' for an example of dgs configuration. The loader try to open the file first. If file is not found, loader try to get the resource using ClassLoader.getResourceAsStream(String).

Parameters:
dgs - path to the DGS file or resource containing the configuration.
Throws:
IOException - if something wrong happens with io.

loadDGSConfiguration

public void loadDGSConfiguration(InputStream in)
                          throws IOException
Load configuration from a dgs file. See 'configExample.dgs' for an example of dgs configuration.

Parameters:
in -
Throws:
IOException - if something wrong happens with io.

setForcesFactory

public void setForcesFactory(BoidForcesFactory bff)
Set the factory used to instantiate the force system to use.

Parameters:
bff - The force system factory.

getArea

public double getArea()

setArea

public void setArea(double area)

getLowAnchor

public org.miv.pherd.geom.Point3 getLowAnchor()

getHighAnchor

public org.miv.pherd.geom.Point3 getHighAnchor()

getRandomSeed

public long getRandomSeed()

setRandomSeed

public void setRandomSeed(long randomSeed)

getSleepTime

public int getSleepTime()

setSleepTime

public void setSleepTime(int sleepTime)

isNormalizeMode

public boolean isNormalizeMode()

setNormalizeMode

public void setNormalizeMode(boolean on)

isForcesAttributesStored

public boolean isForcesAttributesStored()

setStoreForcesAttributes

public void setStoreForcesAttributes(boolean storeForcesAttributes)

getMaxSteps

public int getMaxSteps()

setMaxSteps

public void setMaxSteps(int maxSteps)

getRandom

public Random getRandom()
The random number generator used.

Returns:
The random number generator.

getOrCreateSpecies

public BoidSpecies getOrCreateSpecies(String name)

getOrCreateSpecies

public BoidSpecies getOrCreateSpecies(String name,
                                      String clazz)

getSpecies

public BoidSpecies getSpecies(String name)
The species with the given name.

Parameters:
name - The species name.
Returns:
The corresponding species or null if not found.

getSpeciesCount

public int getSpeciesCount()
The number of boid species actually.

Returns:
The number of boid species.

getDefaultSpecies

public BoidSpecies getDefaultSpecies()
The species whose name is "default".

Returns:
The default species.

addDefaultSpecies

public BoidSpecies addDefaultSpecies()
Add a species with name "default" if does not yet exists.

Returns:
The created default species or the old one if it was already present.

deleteSpecies

public void deleteSpecies(String name)
Remove a species. This also removed all the boids of this species. You cannot remove the "default" species.

Parameters:
name - The species name.

set

public void set(String paramName,
                String value)
         throws IllegalArgumentException
Throws:
IllegalArgumentException

set

public void set(BoidGraph.Parameter param,
                String value)

stopLoop

public void stopLoop()
Stop the main simulation loop.


loop

public void loop()
Run the simulation in a loop.


step

public void step()

stepBegins

public void stepBegins(double step)
Specified by:
stepBegins in interface org.graphstream.graph.Graph
Overrides:
stepBegins in class org.graphstream.graph.implementations.AbstractGraph

isLooping

public boolean isLooping()

display

public org.graphstream.ui.swingViewer.Viewer display(boolean autoLayout)
Specified by:
display in interface org.graphstream.graph.Graph
Overrides:
display in class org.graphstream.graph.implementations.AbstractGraph

addBoidGraphListener

public void addBoidGraphListener(BoidGraphListener listener)
Register a listener for boid specific events.

Parameters:
listener - The listener to register.

removeBoidGraphListener

public void removeBoidGraphListener(BoidGraphListener listener)
Unregister a listener for boid specific events.

Parameters:
listener - The listener to remove.

addNode

public <T extends org.graphstream.graph.Node> T addNode(String nodeId)
Specified by:
addNode in interface org.graphstream.graph.Graph
Overrides:
addNode in class org.graphstream.graph.implementations.AbstractGraph

main

public static void main(String... args)


Copyright © 2013. All Rights Reserved.