wobs.scene3d.player
Class X3DField

java.lang.Object
  extended by wobs.scene3d.player.X3DField

public class X3DField
extends java.lang.Object

This class is used to represent a X3D/VRML field of any type. The Java type that an instance of this class contains depends on the X3D/VRML field represented. For a particular field only one Java value access method will work, and calling other incompatible access methods will throw an exception. Similarly, trying to set the field value to an incompatible java type will throw an exception. The following table shows the X3D/VRML field type, its associated java value that is supported as parameter to the set()-methods , its corresponding getXX()-method, and the structure of the java data:

X3D/VRML field type Java type Supported getXX()-method The java data structure
SFBool boolean getBoolean() -
SFString String getString() -
SFInt32 int getInt() -
SFNode X3DNode getNode() -
SFRotation float[4] getFloatArray() { Nx, Ny, Nz, angle }
SFColor int getInt() 0xRRGGBB (hexadecimal)
SFImage Texture3D getImage() -
SFFloat float getFloat() -
SFTime double getDouble() -
SFVec2f float[2] getFloatArray() { s, t }
SFVec3f float[3] getFloatArray() { x, y, z }
MFString String[...] getStringArray() { string0, string1 ... }
MFInt32 int[...] getIntArray() { int0, int1, ... }
MFNode X3DNode[...] getNodeArray() { node0, node1, ...}
MFRotation float[...] getFloatArray() { Nx0, Ny0, Nz0, angle0, Nx1, Ny1, Nz1, angle1, ... ]
MFColor int[...] getIntArray() { 0xRRGGBB0, 0xRRGGBB1, ... }
MFFloat float[...] getFloatArray() { float0, float1 ... }
MFVec2f float[...] getFloatArray() { x0, y0, x1, y1, ... }
MFVec3f float[...] getFloatArray() [ x0, y0, z0, x1, y1, z1, ... ]



Field Summary
 X3DNode parent
          Deprecated. should use getParent() instead
 byte type
          Deprecated. should use getType() instead
 
Method Summary
 void addFieldEventListener(X3DFieldEventListener listener)
          Adds the specified field listener to receive field events from this field.
 java.lang.Object clone()
          Creates and returns a copy of this object.
 boolean getBoolean()
          Retrieves the boolean value (if the field type is SFBool).
 boolean[] getBooleanArray()
          Retrieves the boolean array value (if the field type is MFBool.
 double getDouble()
          Retrieves the double value (if the field type is SFTime).
 double[] getDoubleArray()
          Retrieves the double array value (if the field type is MFTime).
 float getFloat()
          Retrieves the float value (if the field type is SFFloat).
 float[] getFloatArray()
          Retrieves the float array value (if the field type is SFVec2f, SFVec3f, MFFloat, MFVec2f or MFVec3f).
 int getInt()
          Retrieves the int value (if the field type is SFInt32 or SFColor).
 int[] getIntArray()
          Retrieves the int array value (if the field type is MFInt32 or MFColor).
 X3DNode getNode()
          Retrieves the X3DNode value (if the field type is SFNode or MFNode).
 X3DNode[] getNodeArray()
          Retrieves the X3DNode array(if the field type is MFNode).
 java.lang.String getString()
          Retrieves the String value (if the field type is SFString or MFString).
 java.lang.String[] getStringArray()
          Retrieves the String array value (if the field type is MFString).
 int getType()
          Returns the type of this field.
 void removeFieldEventListener(X3DFieldEventListener listener)
          Removes the specified field listener so that it no longer receives field events from this field.
 void set()
          Signals to the SceneGraph that this field has been set.
 void set(boolean newValue)
          Sets the field value, (if the field type is SFBool).
 void set(double newValue)
          Sets the field value (if the field type is SFTime).
 void set(float newValue)
          Sets the field value (if the field type is SFFloat).
 void set(int newValue)
          Sets the field value, (if the field type is SFInt32).
 void set(java.lang.Object newValue)
          Sets the field value (if the field type is SFString, SFNode, SFImage or any Field.MFxxx type).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public final byte type
Deprecated. should use getType() instead
The field type. See class Field for a listing of existing field types.


parent

public X3DNode parent
Deprecated. should use getParent() instead
The node this field belongs to.

Method Detail

getType

public int getType()
Returns the type of this field. See class Field for a listing of existing field types.

Returns:
the field type

clone

public java.lang.Object clone()
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.

addFieldEventListener

public void addFieldEventListener(X3DFieldEventListener listener)
Adds the specified field listener to receive field events from this field.

Parameters:
listener - - the field listener.

removeFieldEventListener

public void removeFieldEventListener(X3DFieldEventListener listener)
Removes the specified field listener so that it no longer receives field events from this field. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this field.

Parameters:
listener - - the field listener.

set

public void set()
Signals to the SceneGraph that this field has been set.


set

public void set(java.lang.Object newValue)
Sets the field value (if the field type is SFString, SFNode, SFImage or any Field.MFxxx type). The argument type must be compatible with the X3D/VRML field type this object represent (see above conversion table), or else this may cause an error. Any array sent to this method will not be used directly as the field value, a copy of the array will be created and used.

Parameters:
newValue - The new value this field will contain.

set

public void set(boolean newValue)
Sets the field value, (if the field type is SFBool). This function may only be called on objects representing a X3D/VRML field of type SFBool.

Parameters:
newValue - The new boolean value this field will contain.

set

public void set(int newValue)
Sets the field value, (if the field type is SFInt32). This function may only be called on objects representing a X3D/VRML field of type SFInt32 or SFColor.

Parameters:
newValue - The new int value this field will contain.

set

public void set(float newValue)
Sets the field value (if the field type is SFFloat). This function may only be called on objects representing a X3D/VRML field of type SFFloat.

Parameters:
newValue - The new float value this field will contain.

set

public void set(double newValue)
Sets the field value (if the field type is SFTime). This function may only be called on objects representing a X3D/VRML field of type SFTime.

Parameters:
newValue - The new double value this field will contain.

getBoolean

public boolean getBoolean()
Retrieves the boolean value (if the field type is SFBool). This method will generate an error if the object represent any other than a X3D/VRML field of type SFBool.

Returns:
The boolean value this field contains.

getInt

public int getInt()
Retrieves the int value (if the field type is SFInt32 or SFColor). This method will generate an error if the object represent any other than a X3D/VRML field of type SFInt32 or SFColor.

Returns:
The int value this field contains.

getFloat

public float getFloat()
Retrieves the float value (if the field type is SFFloat). This method will generate an error if the object represent any other than a X3D/VRML field of type SFFloat.

Returns:
The float value this field contains.

getDouble

public double getDouble()
Retrieves the double value (if the field type is SFTime). This method will generate an error if the object represent any other than a X3D/VRML field of type SFTime.

Returns:
The double value this field contains.

getString

public java.lang.String getString()
Retrieves the String value (if the field type is SFString or MFString). In the case of MFString fields this method returns the first String element in the String array. This method will generate an error if the object represent any other than a X3D/VRML field of type SFString or MFString.

Returns:
The String value this field contains.

getNode

public X3DNode getNode()
Retrieves the X3DNode value (if the field type is SFNode or MFNode). In the case of MFNode this method returns the first X3DNode element in the X3DNode array. This method will generate an error if the object represent any other than a X3D/VRML field of type SFNode or MFNode.

Returns:
The X3DNode value this field contains.

getBooleanArray

public boolean[] getBooleanArray()
Retrieves the boolean array value (if the field type is MFBool. This method will generate an error if the object represent any other than a X3D/VRML field of type MFBool.

Returns:
The boolean array value this field contains.

getIntArray

public int[] getIntArray()
Retrieves the int array value (if the field type is MFInt32 or MFColor). This method will generate an error if the object represent any other than a X3D/VRML field of type MFInt32 or MFColor.

Returns:
The int array value this field contains.

getFloatArray

public float[] getFloatArray()
Retrieves the float array value (if the field type is SFVec2f, SFVec3f, MFFloat, MFVec2f or MFVec3f). This method will generate an error if the object represent any other than a X3D/VRML field of type SFVec2f, SFVec3f, MFFloat, MFVec2f or MFVec3f.

Returns:
The float array this field contains.

getDoubleArray

public double[] getDoubleArray()
Retrieves the double array value (if the field type is MFTime). This method will generate an error if the object represent any other than a X3D/VRML field of type MFTime.

Returns:
The float array this field contains.

getStringArray

public java.lang.String[] getStringArray()
Retrieves the String array value (if the field type is MFString). This method will generate an error if the object represent any other than a X3D/VRML field of type MFString.

Returns:
The String array this field contains.

getNodeArray

public X3DNode[] getNodeArray()
Retrieves the X3DNode array(if the field type is MFNode). This method will generate an error if the object represent any other than a X3D/VRML field of type MFNode.

Returns:
The X3DNode array this field contains.