vrml.eai
Class BrowserFactory

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

public class BrowserFactory
extends java.lang.Object

Factory that creates new Browser instances. The methods of the BrowserFactory class are the only way to create new instances of the Browser object, i.e. it is essential for initiating the connection between your software components and the X3D browser.

The BrowserFactory itself does not implement much functionality, instead it depends on an implementation of the BrowserFactoryImpl interface that has to be provided by the deleveloper of the X3D browser you want to use. Usually you do not have to care about these details, because the BrowserFactory automatically chooses an implementation. See the setBrowserFactoryImpl(vrml.eai.BrowserFactoryImpl) method for more information about that.

The following example demonstrates how to create a new instance of the Browser interface by using the getBrowser(InetAddress, int) method of the BrowserFactory class:

 java.net.InetAddress address = java.net.InetAddress.getByName("localhost");
 vrml.eai.Browser browser = vrml.eai.BrowserFactory.getBrowser(address, 4848);
 ...
 browser.dispose();
 


Method Summary
static VrmlComponent createVrmlComponent(java.lang.String[] params)
          Creates an AWT component that is able to render VRML content.
static Browser getBrowser(java.applet.Applet applet)
          Creates a new Browser object that allows to communicate with a X3D browser running as a plugin on a web page.
static Browser getBrowser(java.applet.Applet applet, java.lang.String frameName, int index)
          Creates a new Browser object that allows to communicate with a X3D browser running as a plugin on a web page.
static Browser getBrowser(java.net.InetAddress address, int port)
          Creates a new Browser object.
static void setBrowserFactoryImpl(BrowserFactoryImpl fac)
          Sets the actual implementation of the BrowserFactory class.
 
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)
                                  throws VrmlException
Sets the actual implementation of the BrowserFactory class. This method is used only in very rare circumstances. By default, the BrowserFactory tries to determine the implementation itself when you try to create an instance of the Browser interface for the first time. By using this method, you can override the default BrowserFactory implementation.

The BrowserFactory tries to determine the default implementation by looking for a key "vrml.eai.factory.class" in the property file "vrml.properties". E.g. you can put a property file with the name "vrml.properties" into your Java class search path with the following contents:

 vrml.eai.factory.class=MyBrowserFactoryImpl
 
This tells the BrowserFactory to use the class "MyBrowserFactoryImpl".

When the BrowserFactory does not find a BrowserFactory implementation in the property file, it loads a browser-specific implementation (in the case of Instant Player, it's the class "net.inigraphics.Avalon.vrml.eai.BrowserFactoryImpl".

You have to set the actual implementation before you call any other method of this class. Once the implementation is set, you cannot change it anymore.

Parameters:
fac - The BrowserFactory implementation.
Throws:
VrmlException - when the factory implementation has already been set.

createVrmlComponent

public static VrmlComponent createVrmlComponent(java.lang.String[] params)
                                         throws NotSupportedException
Creates an AWT component that is able to render VRML content.

Parameters:
params - Browser-specific parameters. These are the same parameters as used for the Browser.loadURL(java.lang.String[], java.lang.String[]) method.
Returns:
The new AWT component.
Throws:
NotSupportedException - when this way to use the X3D browser via the EAI is not supported/implemented by the concrete browser you are using.

getBrowser

public static Browser getBrowser(java.applet.Applet applet)
                          throws NotSupportedException,
                                 NoSuchBrowserException,
                                 ConnectionException
Creates a new Browser object that allows to communicate with a X3D browser running as a plugin on a web page. When there is more than one plugin on the web page, this method creates a connection to the first plugin.

Parameters:
applet - An applet that is running on the same web page as the X3D browser plugin.
Returns:
The new Browser object.
Throws:
NotSupportedException - when this way to use the X3D browser via the EAI is not supported/implemented by the concrete browser you are using.
NoSuchBrowserException - when there is no X3D browser plugin running on the web page.
ConnectionException - when the connection failed.

getBrowser

public static Browser getBrowser(java.applet.Applet applet,
                                 java.lang.String frameName,
                                 int index)
                          throws NotSupportedException,
                                 NoSuchBrowserException,
                                 ConnectionException
Creates a new Browser object that allows to communicate with a X3D browser running as a plugin on a web page.

Parameters:
applet - An applet that is running on the same web page as the X3D browser plugin.
frameName - The name of the frame the X3D browser plugin is running in.
index - The index of the X3D browser plugin on the web page, starting at 0. This allows to specify which plugin to use when there is more than one X3D browser plugin on the web page.
Returns:
The new Browser object.
Throws:
NotSupportedException - when this way to use the X3D browser via the EAI is not supported/implemented by the concrete browser you are using.
NoSuchBrowserException - when there is no X3D browser plugin running on the web page.
ConnectionException - when the connection failed.

getBrowser

public static Browser getBrowser(java.net.InetAddress address,
                                 int port)
                          throws NotSupportedException,
                                 NoSuchBrowserException,
                                 java.net.UnknownHostException,
                                 ConnectionException
Creates a new Browser object. The Browser object created by this method allows to control a running instance of an X3D browser on the same or another machine via the network.

The following example demonstrates how to create a new instance of the Browser interface by using the getBrowser() method:

 java.net.InetAddress address = java.net.InetAddress.getByName("localhost");
 vrml.eai.Browser browser = vrml.eai.BrowserFactory.getBrowser(address, 4848);
 ...
 browser.dispose();
 

Parameters:
address - The address of the machine the X3D browser is running on.
port - The port number the X3D browser is listening on for connections. This port number can be configured, but by default it is 4848.
Returns:
The new Browser object.
Throws:
NotSupportedException - when this way to use the X3D browser via the EAI is not supported/implemented by the concrete browser you are using.
NoSuchBrowserException - when there is no browser running at the specified address.
java.net.UnknownHostException - when the address parameter is invalid.
ConnectionException - when the connection failed.