Xj3D 2.0 VRML/X3D Code API

vrml.eai
Class BrowserFactory

java.lang.Object
  extended by vrml.eai.BrowserFactory

public class BrowserFactory
extends java.lang.Object

The factory class for obtaining references to browser instances.

An implementation independent representation of the class used to access and create browsers. The model follows that used by java.net.Socket. A setImpl method is provided for browser writers to provide the internal implementations of the browser.

An alternative way of doing this is through a properties file. The class, when it loads looks for the file vrml.properties in the class path. (For more information on how this works read java.lang.ClassLoader.getSystemResourceAsStream()). From this file this class then uses the following properties:

The value of the factory class is then used as the name of the class to load as the default browser implementation. This name must represent the full package qualified name of the class. This class is then loaded using the following method:
  Class factory_class = Class.forName(factory_class_name);
  factory = (BrowserFactoryImpl)factory_class.newInstance();
 
If a class cast exception is raised at the end, then an error is printed but nothing is done about it. The result would be NullPointerExceptions later in the code. Also, this may cause some security errors in some web browsers.

To provide a custom implementation of the factory (which all implementations must do) the user has the choice of the above two options of either calling setImpl or by making sure that the vrml.properties file appears in the classpath before the sample implementation that comes with the classes from the VRMLC. If setBrowserFactoryImpl has not been called at the time that any of the other methods have been, then the class will attempt to load the implementation defined in the properties file. Attempting to call the set implementation method after this point shall result in a VrmlException being generated. Otherwise, it shall use the set implementation.

If for some reason the properties file does not contain the property for the name of the factory class or the properties file does not exist, then the default class name is vrml.eai.DefaultBrowserImpl

Supported Parameters

The X3D specification allows applications to specify parameters to change how a browser operates. You can also specify browser specifc options. The following options are supported by Xj3D.

Param NameDescriptionTypeDefaultLegal Values
AntialiasedWhether to turn on antialiasingBooleanflasetrue,false
TextureQualityA quality metric for texturing. High turns on all tricks like anisotropicFilteringStringmediumlow,medium,high
PrimitiveQualityA quality metric for primitives. Scales how many polygons to use for primitiveStringmediumlow,medium,high
Xj3D_InterfaceTypeWhether to use Swing or AWTStringSwingswing,awt,swing-lightweight
Xj3D_NavbarShownWhether to show the navigation barBooleantruetrue,false
Xj3D_NavbarPositionWhere to position the navigation barStringTopTop,Bottom
Xj3D_LocationShownWhether the current location is shownBooleantruetrue,false
Xj3D_LocationPositionWhere to position the location barStringTopTop,Bottom
Xj3D_LocationReadOnlyWhether the location is read onlyBooleanfalsetrue,false
Xj3D_ShowConsoleWhether to show the consoleBooleanfalsetrue,false
Xj3D_OpenButtonShownWhether to show a content Open buttonBooleanfalsetrue,false
Xj3D_ReloadButtonShownWhether to show a content Reload buttonBooleanfalsetrue,false
Xj3D_StatusBarShownWhether to show a status barBooleanfalsetrue,false
Xj3D_FPSShownWhether to show a Frames Per Second meterBooleanfalsetrue,false
Xj3D_ContentDirectoryThe initial directory to load content fromStringCurrent DirectoryAll
Xj3D_AntialiasingQualityHow many multisamples to use for antialiasing. Must be enabled to matter.Stringlowlow,medium,high

Version:
$Revision: 1.6 $
Author:
Justin Couch

Method Summary
static VrmlComponent createVrmlComponent(java.lang.String[] params)
          Create a VRML browser that can be used as an AWT component.
static Browser getBrowser(java.applet.Applet applet)
          Get a browser from the given java applet reference as a base in the current HTML page.
static Browser getBrowser(java.applet.Applet applet, java.lang.String frameName, int index)
          Get a browser from the given java applet reference one some named page and at some embbed location.
static Browser getBrowser(java.net.InetAddress address, int port)
          Get a reference to a browser that is located on a remote machine.
static void setBrowserFactoryImpl(BrowserFactoryImpl fac)
          set the factory implementation to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setBrowserFactoryImpl

public static void setBrowserFactoryImpl(BrowserFactoryImpl fac)
set the factory implementation to use.


createVrmlComponent

public static VrmlComponent createVrmlComponent(java.lang.String[] params)
                                         throws NotSupportedException
Create a VRML browser that can be used as an AWT component. The component returned is guaranteed to be an instance of VrmlComponent.

Parameters:
params - Parameters to control the look and feel.
Returns:
The component browser initialised to be empty.
Throws:
NotSupportedException - The implementation does not support this type of VRML browser.
See Also:
VrmlComponent

getBrowser

public static Browser getBrowser(java.applet.Applet applet)
                          throws NotSupportedException,
                                 NoSuchBrowserException,
                                 ConnectionException
Get a browser from the given java applet reference as a base in the current HTML page. Used when attempting to access a browser on the current page as this applet and is the first browser on the page. Generically, the same as calling getBrowser(applet, "", 0);

Parameters:
applet - The applet reference to use
Returns:
A reference to the Browser implementation
Throws:
NotSupportedException - The implementation does not support this type of VRML browser
NoSuchBrowserException - Could not locate a VRML browser on the same page as the applet.
ConnectionException - An error occurred during the connecting process

getBrowser

public static Browser getBrowser(java.applet.Applet applet,
                                 java.lang.String frameName,
                                 int index)
                          throws NotSupportedException,
                                 NoSuchBrowserException,
                                 ConnectionException
Get a browser from the given java applet reference one some named page and at some embbed location. Used when attempting to access a browser on another HTML page within a multi-framed environment, or if there are a number of VRML browser instances located on the same page.

If the frame name is a zero length string or null then it is assumed to be located on the same HTML page as the applet. The index is the number of the embbed VRML browser starting from the top of the page. If there are other non-VRML plugins embedded in the page these are not taken into account in calculating the embed index.

Parameters:
applet - The applet reference to use
frameName - The name of the frame to look into for the browser
index - The embed index of the VRML browser in the page
Returns:
A reference to the Browser implementation
Throws:
NotSupportedException - The implementation does not support this type of VRML browser.
NoSuchBrowserException - Could not locate a VRML browser on the same page as the applet.
ConnectionException - An error occurred during the connecting process

getBrowser

public static Browser getBrowser(java.net.InetAddress address,
                                 int port)
                          throws NotSupportedException,
                                 NoSuchBrowserException,
                                 java.net.UnknownHostException,
                                 ConnectionException
Get a reference to a browser that is located on a remote machine. This a server application to send scene updates to a number of client browsers located on remote machines. If there are a number of browsers running on a remote machine, they can be differentiated by the port number they are listening on.

There is no default port number for VRML browsers.

Parameters:
address - The address of the machine to connect to
port - The port number on that machine to connect to.
Returns:
A reference to the Browser implementation
Throws:
NotSupportedException - The implementation does not support this type of VRML browser.
NoSuchBrowserException - Could not locate a VRML browser on the same page as the applet.
java.net.UnknownHostException - Could not find the machine named in the address.
ConnectionException - An error occurred during the connecting process

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium