Class BrowserFactory
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:
vrml.eai.factory.class
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 specific options. The following options are supported by Xj3D.
Param Name | Description | Type | Default | Legal Values |
Antialiased | Whether to turn on antialiasing | Boolean | false | true,false |
TextureQuality | A quality metric for texturing. High turns on all tricks like anisotropicFiltering | String | medium | low,medium,high |
PrimitiveQuality | A quality metric for primitives. Scales how many polygons to use for primitive | String | medium | low,medium,high |
Xj3D_InterfaceType | Whether to use NEWT, Swing or AWT | String | Swing | swing,awt,swing-lightweight,newt |
Xj3D_NavbarShown | Whether to show the navigation bar | Boolean | true | true,false |
Xj3D_NavbarPosition | Where to position the navigation bar | String | Top | Top,Bottom |
Xj3D_LocationShown | Whether the current location is shown | Boolean | true | true,false |
Xj3D_LocationPosition | Where to position the location bar | String | Top | Top,Bottom |
Xj3D_LocationReadOnly | Whether the location is read only | Boolean | false | true,false |
Xj3D_ShowConsole | Whether to show the console | Boolean | false | true,false |
Xj3D_OpenButtonShown | Whether to show a content Open button | Boolean | false | true,false |
Xj3D_ReloadButtonShown | Whether to show a content Reload button | Boolean | false | true,false |
Xj3D_StatusBarShown | Whether to show a status bar | Boolean | false | true,false |
Xj3D_FPSShown | Whether to show a Frames Per Second meter | Boolean | false | true,false |
Xj3D_ContentDirectory | The initial directory to load content from | String | Current Directory | All |
Xj3D_AntialiasingQuality | How many multisamples to use for antialiasing. Must be enabled to matter. | String | low | low,medium,high |
- Version:
- $Revision: 1.6 $
- Author:
- Justin Couch
-
Method Summary
Modifier and TypeMethodDescriptionstatic VrmlComponent
createVrmlComponent
(String[] params) Create a VRML browser that can be used as an AWT component.static Browser
getBrowser
(Applet applet) Get a browser from the given java applet reference as a base in the current HTML page.static Browser
getBrowser
(Applet applet, String frameName, int index) Get a browser from the given java applet reference one some named page and at some embed location.static Browser
getBrowser
(InetAddress address, int port) Get a reference to a browser that is located on a remote machine.static void
set the factory implementation to use.
-
Method Details
-
setBrowserFactoryImpl
set the factory implementation to use.- Parameters:
fac
-
-
createVrmlComponent
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:
-
getBrowser
public static Browser getBrowser(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 browserNoSuchBrowserException
- 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(Applet applet, String frameName, int index) throws NotSupportedException, NoSuchBrowserException, ConnectionException Get a browser from the given java applet reference one some named page and at some embed 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 embed 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 useframeName
- The name of the frame to look into for the browserindex
- 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(InetAddress address, int port) throws NotSupportedException, NoSuchBrowserException, 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 toport
- 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.UnknownHostException
- Could not find the machine named in the address.ConnectionException
- An error occurred during the connecting process
-