|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.j3d.utils.universe.ConfigContainer
public class ConfigContainer
Loads a Java 3D configuration file and creates a container of named objects that will effect the viewing configuration specified in the file. These can include Viewers, ViewingPlatforms, ViewPlatformBehaviors, InputDevices, Sensors, and other objects.
Clients can construct the view side of a scene graph by retrieving these objects using the accessor methods provided by this class. This could involve as little as just attaching ViewingPlatforms to a Locale, depending upon how completely the viewing configuration is specified in the file. The ConfiguredUniverse class is an example of a ConfigContainer client and how it can be used.
ConfigContainer can be useful for clients other than ConfiguredUniverse.
InputDevice and ViewPlatformBehavior configuration is fully supported, so a
given Java 3D installation can provide configuration files to an
application that will allow it to fully utilize whatever site-specific
devices and behaviors are available. The configuration mechanism can be
extended for any target object through the use of the
NewObject
and ObjectProperty
configuration
commands.
ConfiguredUniverse
,
The Java 3D Configuration File,
Example Configuration FilesNested Class Summary | |
---|---|
private static class |
ConfigContainer.ConfigAlias
A class that does nothing but reference another ConfigObject. |
private static class |
ConfigContainer.ReadOnlyIterator
|
private static class |
ConfigContainer.ReadOnlyMap
|
private static class |
ConfigContainer.ReadOnlySet
|
Constructor Summary | |
---|---|
ConfigContainer(java.net.URL userConfig)
Creates a new ConfigContainer and loads the configuration file at the specified URL. |
|
ConfigContainer(java.net.URL userConfig,
boolean setVisible,
int transformCount)
Creates a new ConfigContainer and loads the configuration file at the specified URL. |
|
ConfigContainer(java.net.URL userConfig,
boolean setVisible,
int transformCount,
boolean attachBehaviors)
Package-scoped constructor for ConfigContainer. |
|
ConfigContainer(java.net.URL userConfig,
boolean setVisible,
int transformCount,
boolean attachBehaviors,
java.lang.ClassLoader classLoader)
Package scoped constructor that adds the ability to set the ClassLoader which will be used to load any app specific classes specified in the configuration file. |
|
ConfigContainer(java.net.URL userConfig,
boolean setVisible,
int transformCount,
java.lang.ClassLoader classLoader)
Creates a new ConfigContainer and loads the configuration file at the specified URL. |
|
ConfigContainer(java.net.URL userConfig,
java.lang.ClassLoader classLoader)
Creates a new ConfigContainer and loads the configuration file at the specified URL. |
Method Summary | |
---|---|
private void |
addConfigObject(ConfigObject object)
Adds the specified ConfigObject instance into this container using the given ConfigCommand's base name and instance name. |
void |
clear()
Release memory references used by this ConfigContainer. |
private ConfigObject |
createConfigAlias(ConfigCommand cmd)
Instantiate and initialize a ConfigObject base class containing alias information. |
private ConfigObject |
createConfigObject(ConfigCommand cmd)
Instantiates and initializes an object that extends the ConfigObject base class. |
private ConfigContainer.ReadOnlyMap |
createMap(java.lang.String baseName)
|
private ConfigContainer.ReadOnlySet |
createSet(java.lang.String baseName)
|
(package private) java.lang.Object |
evaluateBuiltIn(ConfigCommand cmd)
This method gets called from a ConfigObject to evaluate a retained built-in command nested within a property command. |
(package private) void |
evaluateCommand(java.util.ArrayList elements,
int lineNumber)
This method gets called from the s-expression parser to process a configuration command. |
private ConfigObject |
findConfigObject(java.lang.String baseName,
ConfigCommand cmd)
Returns the ConfigObject associated with the name in the given ConfigCommand. |
(package private) ConfigObject |
findConfigObject(java.lang.String baseName,
java.lang.String instanceName)
Finds a config object matching the given base name and the instance name. |
(package private) java.util.Collection |
findConfigObjects(java.lang.String baseName)
Find instances of config objects with the given base name. |
(package private) java.util.Collection |
findConfigObjects(java.lang.String baseName,
boolean filterAlias)
Find instances of config objects with the given base name. |
static java.net.URL |
getConfigURL()
Returns the config file URL based on system properties. |
static java.net.URL |
getConfigURL(java.lang.String defaultURLString)
Returns the config file URL based on system properties. |
java.util.Set |
getGenericObjects()
Returns a read-only Set of all generic configuration object instances in the order they were defined in the configuration file. |
java.util.Set |
getInputDevices()
Returns a read-only Set of all configured InputDevice instances in the order they were defined in the configuration file. |
java.util.Map |
getNamedCanvases(java.lang.String viewName)
Returns a read-only Map containing the named Canvas3D instances used by the specified Viewer. |
java.util.Map |
getNamedGenericObjects()
Returns a read-only Map that maps generic object names to instances. |
java.util.Map |
getNamedInputDevices()
Returns a read-only Map that maps InputDevice names to instances. |
java.util.Map |
getNamedPhysicalBodies()
Returns a read-only Map that maps PhysicalBody names to instances. |
java.util.Map |
getNamedPhysicalEnvironments()
Returns a read-only Map that maps PhysicalEnvironment names to instances. |
java.util.Map |
getNamedSensors()
Returns a read-only Map that maps Sensor names to instances. |
java.util.Map |
getNamedViewers()
Returns a read-only Map that maps Viewer names to instances. |
java.util.Map |
getNamedViewingPlatforms()
Returns a read-only Map that maps ViewingPlatform names to instances. |
java.util.Map |
getNamedViewPlatformBehaviors()
Returns a read-only Map that maps ViewPlatformBehavior names to instances. |
java.util.Set |
getPhysicalBodies()
Returns a read-only Set of all configured PhysicalBody instances in the order they were defined in the configuration file. |
java.util.Set |
getPhysicalEnvironments()
Returns a read-only Set of all configured PhysicalEnvironment instances in the order they were defined in the configuration file. |
java.util.Set |
getSensors()
Returns a read-only Set of all configured Sensor instances in the order they were defined in the configuration file. |
java.util.Set |
getViewers()
Returns a read-only Set of all configured Viewer instances in the order they were defined in the configuration file. |
boolean |
getViewerVisibility()
Returns whether Viewers should be created with their AWT components initially visible or invisible. |
java.util.Set |
getViewingPlatforms()
Returns a read-only Set of all configured ViewingPlatform instances in the order they were defined in the configuration file. |
java.util.Set |
getViewPlatformBehaviors()
Returns a read-only Set of all configured ViewPlatformBehavior instances in the order they were defined in the configuration file. |
int |
getViewPlatformTransformCount()
Returns the number of TransformGroups with which ViewingPlatforms should be created. |
private void |
loadConfig(java.net.URL userConfig)
Open, parse, and load the contents of a configuration file. |
private void |
processConfig(boolean setVisible,
int transformCount,
boolean attachBehaviors)
Process the configuration after parsing the configuration file. |
private void |
processDevices(java.util.Collection c,
java.util.Collection s,
java.util.Collection p)
|
private void |
processGenericObjects(java.util.Collection objects)
|
private void |
processPhysicalBodies(java.util.Collection c)
|
private void |
processPhysicalEnvironments(java.util.Collection c)
|
private void |
processViewPlatformBehaviors(java.util.Collection behaviors,
java.util.Collection viewPlatforms,
boolean attach)
|
private void |
processViewPlatforms(java.util.Collection c,
int numTransforms)
|
private void |
processViews(java.util.Collection c,
boolean setVisible)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map baseNameMap
private java.util.Map viewCanvasMap
private ConfigContainer.ReadOnlyMap bodyMap
private ConfigContainer.ReadOnlyMap environmentMap
private ConfigContainer.ReadOnlyMap viewerMap
private ConfigContainer.ReadOnlyMap deviceMap
private ConfigContainer.ReadOnlyMap sensorMap
private ConfigContainer.ReadOnlyMap behaviorMap
private ConfigContainer.ReadOnlyMap platformMap
private ConfigContainer.ReadOnlyMap genericObjectMap
private ConfigContainer.ReadOnlySet bodies
private ConfigContainer.ReadOnlySet environments
private ConfigContainer.ReadOnlySet viewers
private ConfigContainer.ReadOnlySet devices
private ConfigContainer.ReadOnlySet sensors
private ConfigContainer.ReadOnlySet behaviors
private ConfigContainer.ReadOnlySet platforms
private ConfigContainer.ReadOnlySet genericObjects
private int transformCount
private boolean setVisible
private java.lang.ClassLoader classLoader
java.lang.String currentFileName
Constructor Detail |
---|
public ConfigContainer(java.net.URL userConfig)
userConfig
- URL of the configuration file to loadpublic ConfigContainer(java.net.URL userConfig, java.lang.ClassLoader classLoader)
userConfig
- URL of the configuration file to loadclassLoader
- the class loader to use to load classes specified
in the config file.public ConfigContainer(java.net.URL userConfig, boolean setVisible, int transformCount)
setVisible
flag.
userConfig
- URL of the configuration file to loadsetVisible
- if true, setVisible(true)
is called on
all ViewerstransformCount
- number of transforms to be included in any
ViewingPlatform created; must be greater than 0public ConfigContainer(java.net.URL userConfig, boolean setVisible, int transformCount, java.lang.ClassLoader classLoader)
setVisible
flag.
userConfig
- URL of the configuration file to loadsetVisible
- if true, setVisible(true)
is called on
all ViewerstransformCount
- number of transforms to be included in any
ViewingPlatform created; must be greater than 0classLoader
- the class loader to use to load classes specified
in the config file.ConfigContainer(java.net.URL userConfig, boolean setVisible, int transformCount, boolean attachBehaviors)
attachBehaviors
, which indicates whether
or not ViewPlatformBehaviors should be attached to the ViewingPlatforms
specified for them.
Normally the flag should be true. However, when instantiated by
ConfiguredUniverse, this flag is set false so that ConfiguredUniverse
can set a reference to itself in the ViewingPlatform before attaching
the behavior. This provides backwards compatibility to behaviors that
access the ConfiguredUniverse instance from a call to
setViewingPlatform
in order to look up the actual Sensor,
Viewer, Behavior, etc., instances associated with the names provided
them from the configuration file.
The preferred methods to retrieve instances of specific objects defined
in the configuration file are to either 1) get the ConfiguredUniverse
instance when the behavior's initialize
method is called,
or to 2) define properties that accept object instances directly, and
then use the newer Device, Sensor, ViewPlatform, etc., built-in
commands in the configuration file. These built-ins will return an
object instance from a name.
userConfig
- URL of the configuration file to loadsetVisible
- if true, setVisible(true)
is called on
all ViewerstransformCount
- number of transforms to be included in any
ViewingPlatform created; must be greater than 0attachBehaviors
- if true, attach ViewPlatformBehaviors to the
appropriate ViewingPlatformsConfigContainer(java.net.URL userConfig, boolean setVisible, int transformCount, boolean attachBehaviors, java.lang.ClassLoader classLoader)
Method Detail |
---|
private void loadConfig(java.net.URL userConfig)
userConfig
- location of the configuration filevoid evaluateCommand(java.util.ArrayList elements, int lineNumber)
elements
- tokenized list of sexp elementslineNumber
- command line numberprivate ConfigObject createConfigObject(ConfigCommand cmd)
(New{baseName} {instanceName} ... [Alias {aliasName}])
The first two command elements and the optional trailing Alias syntax are processed here, at which point the subclass implementation of initialize() is called. Subclasses must override initialize() if they need to process more than what is processed by default here.
cmd
- configuration command that creates a new ConfigObjectprivate ConfigObject createConfigAlias(ConfigCommand cmd)
({baseName}Alias {aliasName} {originalName})
cmd
- configuration command that creates a new alias
private void addConfigObject(ConfigObject object)
object
- the ConfigObject instance to add into the databaseConfigObject findConfigObject(java.lang.String baseName, java.lang.String instanceName)
basename
- base name of the config objectinstanceName
- name associated with this config object instance
java.util.Collection findConfigObjects(java.lang.String baseName)
findConfigObjects(baseName, true)
.
Aliases are filtered out so that all returned instances are unique.
baseName
- base name of desired config object class
java.util.Collection findConfigObjects(java.lang.String baseName, boolean filterAlias)
baseName
- base name of desired config object classfilterAlias
- if true, aliases are filtered out so that all
returned instances are unique
private ConfigObject findConfigObject(java.lang.String baseName, ConfigCommand cmd)
basename
- base name of the config objectcmd
- command containing the name in argv[1]
java.lang.Object evaluateBuiltIn(ConfigCommand cmd)
cmd
- the built-in command
private void processConfig(boolean setVisible, int transformCount, boolean attachBehaviors)
setVisible
- true if Viewer components should be visibletransformCount
- number of TransformGroups with which
ViewingPlatforms should be createdattachBehaviors
- true if behaviors should be attached to
ViewingPlatformsprivate void processPhysicalEnvironments(java.util.Collection c)
private void processPhysicalBodies(java.util.Collection c)
private void processViews(java.util.Collection c, boolean setVisible)
private void processDevices(java.util.Collection c, java.util.Collection s, java.util.Collection p)
private void processViewPlatforms(java.util.Collection c, int numTransforms)
private void processViewPlatformBehaviors(java.util.Collection behaviors, java.util.Collection viewPlatforms, boolean attach)
private void processGenericObjects(java.util.Collection objects)
private ConfigContainer.ReadOnlySet createSet(java.lang.String baseName)
private ConfigContainer.ReadOnlyMap createMap(java.lang.String baseName)
public java.util.Set getPhysicalBodies()
(NewPhysicalBody <instance name> [Alias <alias name>])The PhysicalBody is configured through the following command:
(PhysicalBodyProperty <instance name> <property name> <property value>)
public java.util.Map getNamedPhysicalBodies()
public java.util.Set getPhysicalEnvironments()
PhysicalEnvironment instances are created with the following command:
(NewPhysicalEnvironment <instance name> [Alias <alias name>])The PhysicalEnvironment is configured through the following command:
(PhysicalEnvironmentProperty <instance name> <property name> <property value>)
public java.util.Map getNamedPhysicalEnvironments()
public java.util.Set getViewers()
Viewer instances are created with the following command:
(NewView <instance name> [Alias <alias name>])The Viewer is configured through the following command:
(ViewProperty <instance name> <property name> <property value>)
public java.util.Map getNamedViewers()
public java.util.Set getInputDevices()
InputDevice instances are created with the following command:
(NewDevice <instanceName> <className> [Alias <alias name>])className must be the fully-qualified name of a class that implements the InputDevice interface. The implementation must provide a parameterless constructor.
The InputDevice is configured through the DeviceProperty command:
(DeviceProperty <instanceName> <propertyName> <arg0> ... <argn>)propertyName must be the name of a input device method that takes an array of Objects as its only parameter; the array is populated with the values of arg0 through argn when the method is invoked to set the property. These additional requirements for configurable input devices can usually be fulfilled by extending or wrapping available InputDevice implementations.
public java.util.Map getNamedInputDevices()
getInputDevices()
public java.util.Set getSensors()
Sensor instances are named with the following command:
(NewSensor <instance name> <device name> <sensor index> [Alias <alias name>])device name is the instance name of a previously defined InputDevice, and sensor index is the index of the Sensor to be bound to instance name. The InputDevice implementation is responsible for creating its own Sensor objects, so this command does not create any new instances.
The Sensor is configured through the SensorProperty command:
(SensorProperty <instance name> <property name> <property value>)With the sole exception of the Sensor assigned to the head tracker, none of the Sensors defined in the configuration file are placed into the Sensor array maintained by a PhysicalEnvironment.
public java.util.Map getNamedSensors()
With the sole exception of the Sensor assigned to the head tracker, none of the Sensors defined in the configuration file are placed into the Sensor array maintained by a PhysicalEnvironment.
public java.util.Set getViewingPlatforms()
(NewViewPlatform <instance name> [Alias <alias name>])The ViewingPlatform is configured through the following command:
(ViewPlatformProperty <instance name> <property name> <property value>)
public java.util.Map getNamedViewingPlatforms()
public java.util.Set getViewPlatformBehaviors()
The behaviors are attached to any ViewingPlatforms that specified them;
that is, the setViewPlatformBehavior
and
setViewingPlatform
methods of ViewingPlatform and
ViewPlatformBehavior have been called if appropriate. However, a
behavior's initialize
method is not called until the
ViewingPlatform to which it is attached is made live.
ViewPlatformBehavior instances are created by the following command:
(NewViewPlatformBehavior <instanceName> <className>)className must be the fully qualified name of a concrete class that extends the abstract ViewPlatformBehavior class. The implementation must provide a parameterless constructor.
The behavior is configured using ViewPlatformBehaviorProperty:
(ViewPlatformBehaviorProperty <instanceName> <propertyName> <arg0> ... <argn>)ViewPlatformBehavior subclasses inherit a number of pre-defined properties that can be directly specified with the propertyName string; see the configuration file documentation for details.
Concrete ViewPlatformBehavior instances can also define their own unique properties. In those cases, propertyName must be the name of a behavior method that takes an array of Objects as its only parameter; the array is populated with the values of arg0 through argn when the method is invoked to set the property. These additional requirements for configurable behaviors can usually be fulfilled by extending or wrapping available ViewPlatformBehavior subclasses.
public java.util.Map getNamedViewPlatformBehaviors()
The behaviors are attached to any ViewingPlatforms that specified them;
that is, the setViewPlatformBehavior
and
setViewingPlatform
methods of ViewingPlatform and
ViewPlatformBehavior have been called if appropriate. However, a
behavior's initialize
method is not called until the
ViewingPlatform to which it is attached is made live.
getViewPlatformBehaviors()
public java.util.Map getNamedCanvases(java.lang.String viewName)
A named Canvas3D is created and added to a Viewer whenever any of the following configuration commands are used:
(ViewProperty <view> Screen <screenName>)view is the name of a Viewer created with the NewView command. The screenName and windowName parameters of the above commands are the keys to use when looking up the associated Canvas3D instances in the Map returned by this method. Note: the NewScreen and NewWindow commands do not create Canvas3D instances themselves; they are created only by the above configuration commands.
(ViewProperty <view> Window <windowName>)
viewName
- the name of the Viewer
public java.util.Set getGenericObjects()
Generic object instances are created with the following command:
(NewObject <instanceName> <className>)className must be the fully-qualified name of a class that provides a parameterless constructor.
The object is configured through the ObjectProperty command:
(ObjectProperty <instanceName> <propertyName> <arg0> ... <argn>)propertyName must be the name of a method provided by object instanceName. It must take an array of Objects as its only parameter; the array is populated with the values of arg0 through argn when the method is invoked to set the property. These additional requirements for configurable objects can usually be fulfilled by extending or wrapping available object classes.
public java.util.Map getNamedGenericObjects()
getGenericObjects()
public int getViewPlatformTransformCount()
public boolean getViewerVisibility()
public void clear()
public static java.net.URL getConfigURL()
java -Dj3d.configURL=file:j3dconfig ...
public static java.net.URL getConfigURL(java.lang.String defaultURLString)
java -Dj3d.configURL=file:j3dconfig ...
defaultURLString
- the default string used to construct
the URL if the appropriate system properties are not defined
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |