org.odejava.xode
Class XODEObject

java.lang.Object
  extended by org.odejava.xode.XODEObject
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
XODEContainer, XODEJoint

public abstract class XODEObject
extends Object
implements Serializable

Base XODE object (as defined in the spec)

Author:
William Denniss
See Also:
Serialized Form

Field Summary
protected  Node node
          The DOM objects that represents this XODEObject generated while importing/exporting to/from XML.
protected  Object odeObject
          The ODE objects created last time buildOde was called.
 
Constructor Summary
protected XODEObject()
           
protected XODEObject(Node node)
          Sets the world and space variables, and parses the 'name' attribute.
  XODEObject(String name)
           
 
Method Summary
protected abstract  Element buildElement(Document doc)
          Builds an XML DOM representation of this XODEObject
abstract  void buildOde(World world, Space space, String namePrefix, List<Object> odeList)
          Constructs the ODE scene based on this XODE structure
 XODEObject clone()
          Returns a deep copy of this XODEObject
 Node getDOMNode()
          Returns DOM node represented by this XODEObject or null if no XML import/export functions have been performed on this XODEObject, or the cache was lost by purging or serialization.
protected  Body getFirstBodyAncestor()
          Recursivly locates then returns the Body of the first XODEBody ancestor or null if there is none.
protected  JointGroup getFirstJointGroupAncestor()
          Recursivly locates then returns the JointGroup of the first XODEJointGroup ancestor or null if there is none.
protected  Space getFirstSpaceAncestor()
          Recursivly locates then returns the Space of the first XODESpace ancestor or null if there is none.
 String getName()
          Returns the name of this XODEObject or null if it has no name.
 Object getODEObject()
          Returns the Odejava object represented by this XODEObject or null if no Odejava object has been created, or the cache was scrapped.
 XODEContainer getParent()
          Returns the parent XODEContainer of this XODEObject or null if it does not have a parent.
 void setName(String name)
          Sets the name to the given new name.
protected  void setParent(XODEContainer parent)
          Sets the parent of this object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

odeObject

protected transient Object odeObject
The ODE objects created last time buildOde was called. Used to aid calculations of relitive transforms while building the ODE representation of the XODE tree. Outside the buildOde method should be used for debugging use only.


node

protected transient Node node
The DOM objects that represents this XODEObject generated while importing/exporting to/from XML. Debugging use only, not designed to be be accessed in normal operation.

Constructor Detail

XODEObject

protected XODEObject()

XODEObject

public XODEObject(String name)

XODEObject

protected XODEObject(Node node)
Sets the world and space variables, and parses the 'name' attribute.

Parameters:
node - the XML data
Method Detail

getFirstBodyAncestor

protected Body getFirstBodyAncestor()
Recursivly locates then returns the Body of the first XODEBody ancestor or null if there is none. An ancestor is a parent or a parent of a parent ad infinitum. Used in the buildOde method to aid in calculations of relitive transforms.

Returns:
the Body of the first XODEBody ancestor or null if there is none

getFirstJointGroupAncestor

protected JointGroup getFirstJointGroupAncestor()
Recursivly locates then returns the JointGroup of the first XODEJointGroup ancestor or null if there is none. An ancestor is a parent or a parent of a parent ad infinitum.

Returns:
the JointGroup of the first XODEJointGroup ancestor or null if there is none

getFirstSpaceAncestor

protected Space getFirstSpaceAncestor()
Recursivly locates then returns the Space of the first XODESpace ancestor or null if there is none. An ancestor is a parent or a parent of a parent ad infinitum.

Returns:
the Space of the first XODESpace ancestor or null if there is none

getODEObject

public Object getODEObject()
Returns the Odejava object represented by this XODEObject or null if no Odejava object has been created, or the cache was scrapped.

Returns:
the Odejava object represented by this XODEObject

getDOMNode

public Node getDOMNode()
Returns DOM node represented by this XODEObject or null if no XML import/export functions have been performed on this XODEObject, or the cache was lost by purging or serialization. Not suggestd to be used for non-debugging reasons.

Returns:
the DOM node represented by this XODEObject

buildOde

public abstract void buildOde(World world,
                              Space space,
                              String namePrefix,
                              List<Object> odeList)
Constructs the ODE scene based on this XODE structure

Parameters:
world - the World to add created bodies
space - the Space to add created geometry
namePrefix - string to prefix all names
odeList - list of all created ODE files (will be added to)

setParent

protected void setParent(XODEContainer parent)
Sets the parent of this object. Should only be called by the addChild() method of XODEContainer.

Parameters:
parent - the parent of this object or null if there isn't one
Throws:
XODEException - if this XODEObject has a parent and a non-null parent was passed
See Also:
XODEContainer.addChild(XODEObject)

buildElement

protected abstract Element buildElement(Document doc)
Builds an XML DOM representation of this XODEObject

Parameters:
doc - the Document this Element will be associated with
Returns:
and XML DOM representation of this XODEObject

getParent

public XODEContainer getParent()
Returns the parent XODEContainer of this XODEObject or null if it does not have a parent.

Returns:
this object's parent container
See Also:
XODEContainer.addChild(XODEObject)

getName

public String getName()
Returns the name of this XODEObject or null if it has no name.

Returns:
the name of this XODEObject

setName

public void setName(String name)
Sets the name to the given new name.

Parameters:
name - the new name to use

clone

public XODEObject clone()
Returns a deep copy of this XODEObject

Overrides:
clone in class Object
Returns:
a deep copy of this XODEObject