Xj3D VRML/X3D Code API

org.web3d.vrml.renderer
Class CRExternPrototypeDecl

java.lang.Object
  extended byorg.web3d.vrml.nodes.proto.AbstractProto
      extended byorg.web3d.vrml.nodes.proto.ExternalPrototypeDecl
          extended byorg.web3d.vrml.renderer.CRExternPrototypeDecl
All Implemented Interfaces:
VRMLExternalNodeType, VRMLExternProtoDeclare, VRMLNodeTemplate, VRMLSingleExternalNodeType
Direct Known Subclasses:
J3DExternPrototypeDecl, NRExternPrototypeDecl, OGLExternPrototypeDecl

public abstract class CRExternPrototypeDecl
extends ExternalPrototypeDecl

A CR External Prototype Declaration.

This node will be placed on the content loader. Instances of this EP will go into the scenegraph as stubs. When this EP is loaded it will finish creating those instances.

Version:
$Revision: 1.18 $
Author:
Alan Hudson

Field Summary
protected  ErrorReporter errorReporter
          Reporter instance for handing out errors
protected  boolean inSetup
          Flag indicating we are in setup mode currently
protected  java.util.ArrayList instanceList
          List of EP instances to fill in.
protected  int loadState
          The state of the load
protected  VRMLNodeFactory nodeFactory
          The node factory used to create real node instances
protected  VRMLNodeTemplate proto
          The prototype declaration that we always use
protected  FrameStateManager stateManager
          Frame state manager for this event model instance
protected  java.lang.String uriRef
          The reference part of the URI loaded
protected  java.lang.String[] vfUrl
          url field
protected  java.lang.String worldURL
          The world URL for correcting relative URL values
protected  java.util.ArrayList wrInstances
          List of EP instances.
 
Fields inherited from class org.web3d.vrml.nodes.proto.ExternalPrototypeDecl
loadedURI
 
Fields inherited from class org.web3d.vrml.nodes.proto.AbstractProto
BAD_NODE_MSG, FIELD_CLASH_MSG, fieldData, fieldDeclList, fieldIndexMap, isVrml97, nodeName, protoCreator, VRML97_FIELD_MSG, vrmlMajorVersion, vrmlMinorVersion
 
Fields inherited from interface org.web3d.vrml.nodes.VRMLExternalNodeType
LOAD_COMPLETE, LOAD_FAILED, LOADING, NOT_LOADED
 
Constructor Summary
CRExternPrototypeDecl(java.lang.String name, VRMLNodeFactory fac, int majorVersion, int minorVersion, NodeTemplateToInstanceCreator creator)
          Create a place holder that represents the given extern proto declaration.
 
Method Summary
 void addInstance(VRMLNodeType parent, int idx, VRMLNodeType node)
          Add an instance of a EXTERNPROTO to be filled out when loaded
 boolean checkValidContentType(java.lang.String mimetype)
          Check to see if the given MIME type is one that would be supported as content coming into this node.
protected  void finishSetContent(PrototypeDecl protoDef, CRProtoCreator protoCreator, VRMLExecutionSpace rootSpace)
          Finish off the creation process of the generic externproto handling.
 int getLoadState()
          Ask the state of the load of this node.
 VRMLNodeTemplate getProtoDefinition()
          Get the PROTO/EXTERNPROTO definition used by this place holder.
 java.lang.String[] getUrl()
          Fetch the set values for the URL(s) of the externproto definition.
 java.lang.String getWorldUrl()
          Get the world URL so set for this node.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion.
 void setFrameStateManager(FrameStateManager mgr)
          Set the frame state manager to be used by this proto instance.
 void setLoadedURI(java.lang.String URI)
          Notify the node which URL was used to load the content.
 void setLoadState(int state)
          Set the load state of the node.
 void setUrl(java.lang.String[] newUrl, int numValid)
          Set the URL list that describes the sources for this externproto.
 void setWorldUrl(java.lang.String url)
          Set the world URL so that any relative URLs may be corrected to the fully qualified version.
 
Methods inherited from class org.web3d.vrml.nodes.proto.ExternalPrototypeDecl
addContentStateListener, addUrlListener, createNewInstance, getPrimaryType, getProtoDetails, removeContentStateListener, removeUrlListener, setContent, setProtoDetails
 
Methods inherited from class org.web3d.vrml.nodes.proto.AbstractProto
addNodeListener, appendField, checkNodeType, deleteField, deleteField, fireFieldChanged, getAllFields, getFieldCount, getFieldDeclaration, getFieldIndex, getNumFields, getVRMLNodeName, isVRML97, removeNodeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.web3d.vrml.lang.VRMLNodeTemplate
appendField, deleteField, deleteField, getAllFields, getFieldCount, getFieldDeclaration, getFieldIndex, getNumFields, getVRMLNodeName
 

Field Detail

proto

protected VRMLNodeTemplate proto
The prototype declaration that we always use


inSetup

protected boolean inSetup
Flag indicating we are in setup mode currently


vfUrl

protected java.lang.String[] vfUrl
url field


worldURL

protected java.lang.String worldURL
The world URL for correcting relative URL values


loadState

protected int loadState
The state of the load


nodeFactory

protected VRMLNodeFactory nodeFactory
The node factory used to create real node instances


instanceList

protected java.util.ArrayList instanceList
List of EP instances to fill in.


wrInstances

protected java.util.ArrayList wrInstances
List of EP instances. Stored as a list of WeakReferences


uriRef

protected java.lang.String uriRef
The reference part of the URI loaded


stateManager

protected FrameStateManager stateManager
Frame state manager for this event model instance


errorReporter

protected ErrorReporter errorReporter
Reporter instance for handing out errors

Constructor Detail

CRExternPrototypeDecl

public CRExternPrototypeDecl(java.lang.String name,
                             VRMLNodeFactory fac,
                             int majorVersion,
                             int minorVersion,
                             NodeTemplateToInstanceCreator creator)
Create a place holder that represents the given extern proto declaration.

Parameters:
name - The name of the declaration to base this placeholder on
fac - The factory to use for creating the instances
majorVersion - The major version number of this scene
minorVersion - The minor version number of this scene
creator - The node creator for generating instances of ourself
Method Detail

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.

Specified by:
setErrorReporter in interface VRMLNodeTemplate
Overrides:
setErrorReporter in class AbstractProto
Parameters:
reporter - The instance to use or null

addInstance

public void addInstance(VRMLNodeType parent,
                        int idx,
                        VRMLNodeType node)
Add an instance of a EXTERNPROTO to be filled out when loaded

Parameters:
parent - The parent node for this EP
idx - The field index
node - The instance

setFrameStateManager

public void setFrameStateManager(FrameStateManager mgr)
Set the frame state manager to be used by this proto instance. used to pass in information about the contained scene for extern proto handler.

Parameters:
mgr - The manager instance to use

getProtoDefinition

public VRMLNodeTemplate getProtoDefinition()
Get the PROTO/EXTERNPROTO definition used by this place holder.

Returns:
The proto definition used by the node

getLoadState

public int getLoadState()
Ask the state of the load of this node. The value will be one of the constants defined above.

Specified by:
getLoadState in interface VRMLSingleExternalNodeType
Overrides:
getLoadState in class ExternalPrototypeDecl
Returns:
The current load state of the node

setLoadState

public void setLoadState(int state)
Set the load state of the node. The value must be one of the constants defined above.

Specified by:
setLoadState in interface VRMLSingleExternalNodeType
Overrides:
setLoadState in class ExternalPrototypeDecl
Parameters:
state - The new state of the node

setWorldUrl

public void setWorldUrl(java.lang.String url)
Set the world URL so that any relative URLs may be corrected to the fully qualified version. Guaranteed to be non-null.

Specified by:
setWorldUrl in interface VRMLExternalNodeType
Overrides:
setWorldUrl in class ExternalPrototypeDecl
Parameters:
url - The world URL.

getWorldUrl

public java.lang.String getWorldUrl()
Get the world URL so set for this node.

Specified by:
getWorldUrl in interface VRMLExternalNodeType
Overrides:
getWorldUrl in class ExternalPrototypeDecl
Returns:
url The world URL.

checkValidContentType

public boolean checkValidContentType(java.lang.String mimetype)
Check to see if the given MIME type is one that would be supported as content coming into this node.

Specified by:
checkValidContentType in interface VRMLSingleExternalNodeType
Overrides:
checkValidContentType in class ExternalPrototypeDecl
Parameters:
mimetype - The type to check for
Returns:
true if this is OK, false if not

setLoadedURI

public void setLoadedURI(java.lang.String URI)
Notify the node which URL was used to load the content. It will be the complete URI with path, query and references parts. This method will be called before setContent.

Specified by:
setLoadedURI in interface VRMLSingleExternalNodeType
Overrides:
setLoadedURI in class ExternalPrototypeDecl
Parameters:
URI - The URI used to load this content

setUrl

public void setUrl(java.lang.String[] newUrl,
                   int numValid)
Set the URL list that describes the sources for this externproto.

Specified by:
setUrl in interface VRMLSingleExternalNodeType
Overrides:
setUrl in class ExternalPrototypeDecl
Parameters:
newUrl - The list of URLs to use
numValid - The number of valid items to use from the array
Throws:
java.lang.RuntimeException - Attempting to change the URL at runtime

getUrl

public java.lang.String[] getUrl()
Fetch the set values for the URL(s) of the externproto definition.

Specified by:
getUrl in interface VRMLSingleExternalNodeType
Overrides:
getUrl in class ExternalPrototypeDecl
Returns:
A list of URL strings, guaranteed to be at least 1 in length

finishSetContent

protected void finishSetContent(PrototypeDecl protoDef,
                                CRProtoCreator protoCreator,
                                VRMLExecutionSpace rootSpace)
Finish off the creation process of the generic externproto handling.

Parameters:
protoDef - The declaration to build stuff from
protoCreator - The creator used to copy the node
rootSpace - Parent execution space that this instance belongs to

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium