experiment
Class ExperimentState

java.lang.Object
  extended by experiment.ExperimentState
All Implemented Interfaces:
java.io.Serializable

public class ExperimentState
extends java.lang.Object
implements java.io.Serializable

Created by IntelliJ IDEA. User: andy Date: Mar 22, 2010 Contains all the data that corresponds to a single experiment state. Implements Serializable in order to allow easy storing.

See Also:
Serialized Form

Constructor Summary
ExperimentState()
           
 
Method Summary
 void add(Link link)
          Adds a Link to the current state.
 void add(Node node)
          Adds a Node to the current state.
 long getByteOffset()
          As a state contains parsed experiment data it is also associated with a byte offset, which points to the location of the file where the parsing has reached.
 int getLinkNumber()
           
 int getNodeNumber()
           
 java.util.Collection<Node> getNodeSet()
           
 double getTime()
           
 ExtendedXMLStreamReader getXMLReader()
          Each ExperimentState object is bound to one ExtendedXMLStreamReader.
 Link indexLink(java.lang.String sourceId, java.lang.String targetId)
          Indexes a link.
 Node indexNode(java.lang.String nodeId)
          Indexes a node based on its id.
 Node indexNode(javax.vecmath.Vector3d position)
          Tries to find the Node that corresponds to a position in 3d space.
 void setByteOffset()
          As a state contains parsed experiment data it is also associated with a byte offset which points to the location of the file where the parsing has reached.
 void setTime(double timestamp)
          Is called to change a state's timestamp.
 void setXMLReader(ExtendedXMLStreamReader reader)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExperimentState

public ExperimentState()
Method Detail

add

public void add(Link link)
Adds a Link to the current state.

Parameters:
link - the link object to be added.

add

public void add(Node node)
Adds a Node to the current state.

Parameters:
node - the node object to be added.

getByteOffset

public long getByteOffset()
As a state contains parsed experiment data it is also associated with a byte offset, which points to the location of the file where the parsing has reached.

Returns:
the long value of the experiment state's byte offset.

getLinkNumber

public int getLinkNumber()
Returns:
the current number of Links in the experiment

getNodeNumber

public int getNodeNumber()
Returns:
the number of nodes currently in the experiment

getNodeSet

public java.util.Collection<Node> getNodeSet()
Returns:
a collection of all Nodes in this state.

getTime

public double getTime()
Returns:
the state's time.

getXMLReader

public ExtendedXMLStreamReader getXMLReader()
Each ExperimentState object is bound to one ExtendedXMLStreamReader. When the object is cloned or serialized and stored, the ExtendedXMLStreamReader is also cloned/stored. This way the parsing may continue from any cloned/serialized state.

Returns:
the ExtendedXMLStreamReader that updates this state.

indexLink

public Link indexLink(java.lang.String sourceId,
                      java.lang.String targetId)
Indexes a link.

Parameters:
sourceId - the Link's source Node id.
targetId - the Link's target Node id.
Returns:
the Link or null.

indexNode

public Node indexNode(java.lang.String nodeId)
Indexes a node based on its id.

Parameters:
nodeId - the node's id
Returns:
a reference to the Node object

indexNode

public Node indexNode(javax.vecmath.Vector3d position)
Tries to find the Node that corresponds to a position in 3d space. Is called when a user picks an object.

Parameters:
position - a three dimensional Vector containing the x, y, z double values.
Returns:
The indexed Node or null;

setByteOffset

public void setByteOffset()
As a state contains parsed experiment data it is also associated with a byte offset which points to the location of the file where the parsing has reached. The byte offset is set when the state is serialized. To compensate for a previous jump, StaxParxer's jumpOffset variable is also added.


setTime

public void setTime(double timestamp)
             throws badSyntaxException
Is called to change a state's timestamp. It only changes the timestamp if the new time value is greater than the old one.

Parameters:
timestamp - is a long variable containing the new timestamp.
Throws:
badSyntaxException - if the timestamp is smaller than the state's timestamp.

setXMLReader

public void setXMLReader(ExtendedXMLStreamReader reader)