Xj3D 2.0 VRML/X3D Code API

Package org.web3d.net.content

Content handler implementation code to allow the Xj3D code to load inline data or run as a standalone system without needing to use other loader interfaces.

See:
          Description

Class Summary
ImageContentHandler Base abstract ContentHandler implementation for loading images from a URI resource connection.
VRMLContentHandlerFactory A Factory implementation for VRML content handlers that produces VRML output.
VRMLFileNameMap An implementation of a file name mapping for handling VRML file types.
 

Package org.web3d.net.content Description

Content handler implementation code to allow the Xj3D code to load inline data or run as a standalone system without needing to use other loader interfaces.

As our asynchronous load mechanism for Xj3D does not use the standard java.net packages for loading external content, we extend the classes used by our system. It can be used with the standard java.net system, but will not use it for it's own internal loading.

Registering VRML Content Loaders

Content handlers are not automatically registered with the system. This means that inlines will fail to load unless you register one of these handlers with the URI resolver system within your own code. To register one, you need to use the following code guide.
import org.ietf.uri.URI;
import org.ietf.uri.FileNameMap;

...

     ContentHandlerFactory fac = URI.getContentHandlerFactory();
     if(!(fac instanceof J3DContentHandlerFactory)) {
         fac = new J3DContentHandlerFactory(fac);
                 URI.setContentHandlerFactory(fac);
     }

Registering VRML file types

Under the standard Java setup, the VRML file types are not mapped. While you will get the right information from a webserver, files fetched from the local disk will not give you the right information. Therefore you will need to register a mapping for the filename. To do this, we must create and register an instance of a mapping - represented by the org.ietf.uri.FileNameMap interface.

The registration process is very similar to the content handler factory process:

import org.ietf.uri.URI;
import org.ietf.uri.FileNameMap;

...

     FileNameMap fn_map = URI.getFileNameMap();
     if(!(fn_map instanceof VRMLFileNameMap)) {
         fn_map = new VRMLFileNameMap(fn_map);
                 URI.setFileNameMap(fn_map);
     }
The URI packages are included as part of the CVS download or install and should be registered in your classpath.

If you wish to get the source for the URI system, the handler makes use of Justin Couch's URIlib Java library for loading URNs and URLs. The standard java.net library is not used. Note that if you are using URNs, you will need to set a few system properties defined by that package.


Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium