📄 configcontainer.java
字号:
* <propertyName> <arg0> ... <argn></i>) * </blockquote> * * ViewPlatformBehavior subclasses inherit a number of pre-defined * properties that can be directly specified with the <i>propertyName</i> * string; see the configuration file documentation for details.<p> * * Concrete ViewPlatformBehavior instances can also define their own * unique properties. In those cases, <i>propertyName</i> 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 <i>arg0</i> * through <i>argn</i> 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. * * @return read-only Set of all unique instances, or null */ public Set getViewPlatformBehaviors() { if (behaviors != null) return behaviors ; behaviors = createSet("ViewPlatformBehavior") ; return behaviors ; } /** * Returns a read-only Map that maps ViewPlatformBehavior names to * instances. Names may be aliases and if so will map to the original * instances.<p> * * The behaviors are attached to any ViewingPlatforms that specified them; * that is, the <code>setViewPlatformBehavior</code> and * <code>setViewingPlatform</code> methods of ViewingPlatform and * ViewPlatformBehavior have been called if appropriate. However, a * behavior's <code>initialize</code> method is not called until the * ViewingPlatform to which it is attached is made live.<p> * * @return read-only Map from names to ViewPlatformBehavior instances, or * null if no instances * @see #getViewPlatformBehaviors */ public Map getNamedViewPlatformBehaviors() { if (behaviorMap != null) return behaviorMap ; behaviorMap = createMap("ViewPlatformBehavior") ; return behaviorMap ; } /** * Returns a read-only Map containing the named Canvas3D instances used by * the specified Viewer. Names may be aliases and if so will map to the * original instances. The set of unique Canvas3D instances used by a * Viewer may be obtained by calling the Viewer's accessor methods * directly.<p> * * A named Canvas3D is created and added to a Viewer whenever any of the * following configuration commands are used:<p> * <blockquote> * (ViewProperty <i><view></i> Screen <i><screenName></i>)<br> * (ViewProperty <i><view></i> Window <i><windowName></i>) * </blockquote> * * <i>view</i> is the name of a Viewer created with the NewView command. * The <i>screenName</i> and <i>windowName</i> parameters of the above * commands are the keys to use when looking up the associated Canvas3D * instances in the Map returned by this method. <b>Note:</b> the * NewScreen and NewWindow commands do <i>not</i> create Canvas3D * instances themselves; they are created only by the above configuration * commands. * * @param viewName the name of the Viewer * @return read-only Map containing the Viewer's named Canvas3D instances */ public Map getNamedCanvases(String viewName) { Map m = (Map)viewCanvasMap.get(viewName) ; if (m != null) return m ; m = new HashMap() ; ConfigView cv = (ConfigView)findConfigObject("View", viewName) ; Iterator i = cv.screens.iterator() ; while (i.hasNext()) { ConfigScreen cs = (ConfigScreen)i.next() ; m.put(cs.instanceName, cs.j3dCanvas) ; // The aliases list contains all alias strings for the canvas. Iterator j = cs.aliases.iterator() ; while (j.hasNext()) m.put(j.next(), cs.j3dCanvas) ; } m = new ReadOnlyMap(m) ; viewCanvasMap.put(viewName, m) ; return m ; } /** * Returns a read-only Set of all generic configuration object * instances in the order they were defined in the configuration file.<p> * * Generic object instances are created with the following command:<p> * <blockquote> * (NewObject <i><instanceName> <className></i>) * </blockquote> * * <i>className</i> must be the fully-qualified name of a class that * provides a parameterless constructor.<p> * * The object is configured through the ObjectProperty command:<p> * <blockquote> * (ObjectProperty <i><instanceName> <propertyName> * <arg0> ... <argn></i>) * </blockquote> * * <i>propertyName</i> must be the name of a method provided by object * <i>instanceName</i>. It must take an array of Objects as its only * parameter; the array is populated with the values of <i>arg0</i> * through <i>argn</i> 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. * * @return read-only Set of all unique instances, or null */ public Set getGenericObjects() { if (genericObjects != null) return genericObjects ; genericObjects = createSet("Object") ; return genericObjects ; } /** * Returns a read-only Map that maps generic object names to * instances. Names may be aliases and if so will map to the original * instances. * * @return read-only Map from names to generic object instances, or * null if no instances * @see #getGenericObjects */ public Map getNamedGenericObjects() { if (genericObjectMap != null) return genericObjectMap ; genericObjectMap = createMap("Object") ; return genericObjectMap ; } /** * Returns the number of TransformGroups with which ViewingPlatforms * should be created. This is useful for clients that wish to provide a * default ViewingPlatform if the configuration file doesn't specify one. * * @return the number of TransformGroups */ public int getViewPlatformTransformCount() { return transformCount ; } /** * Returns whether Viewers should be created with their AWT components * initially visible or invisible. This is useful for clients that wish * to provide a default Viewer if the configuration file doesn't specify * one. * * @return true if Viewer components should be initially visible; false * otherwise */ public boolean getViewerVisibility() { return setVisible ; } /** * Release memory references used by this ConfigContainer. All Sets and * Maps obtained from this ConfigContainer are cleared. */ public void clear() { // Clear baseNameList. Iterator i = baseNameMap.values().iterator() ; while (i.hasNext()) ((Collection)i.next()).clear() ; baseNameMap.clear() ; // Clear viewCanvasMap. i = viewCanvasMap.values().iterator() ; while (i.hasNext()) ((ReadOnlyMap)i.next()).map.clear() ; viewCanvasMap.clear() ; // Release reference to file name. currentFileName = null ; // Clear and release sets. if (bodies != null) { bodies.collection.clear() ; bodies = null ; } if (environments != null) { environments.collection.clear() ; environments = null ; } if (devices != null) { devices.collection.clear() ; devices = null ; } if (sensors != null) { sensors.collection.clear() ; sensors = null ; } if (behaviors != null) { behaviors.collection.clear() ; behaviors = null ; } if (platforms != null) { platforms.collection.clear() ; platforms = null ; } if (viewers != null) { viewers.collection.clear() ; viewers = null ; } if (genericObjects != null) { genericObjects.collection.clear() ; genericObjects = null ; } // Clear and release maps. if (bodyMap != null) { bodyMap.map.clear() ; bodyMap = null ; } if (environmentMap != null) { environmentMap.map.clear() ; environmentMap = null ; } if (deviceMap != null) { deviceMap.map.clear() ; deviceMap = null ; } if (sensorMap != null) { sensorMap.map.clear() ; sensorMap = null ; } if (behaviorMap != null) { behaviorMap.map.clear() ; behaviorMap = null ; } if (platformMap != null) { platformMap.map.clear() ; platformMap = null ; } if (viewerMap != null) { viewerMap.map.clear() ; viewerMap = null ; } if (genericObjectMap != null) { genericObjectMap.map.clear() ; genericObjectMap = null ; } } /** * Returns the config file URL based on system properties. The current * implementation of this method parses the j3d.configURL property as a * URL string. For example, the following command line would specify that * the config file is taken from the file "j3dconfig" in the current * directory: * <ul> * <code>java -Dj3d.configURL=file:j3dconfig ...</code> * </ul> * * @return the URL of the config file; null is returned if no valid * URL is defined by the system properties */ public static URL getConfigURL() { return getConfigURL(null) ; } /** * Returns the config file URL based on system properties. The current * implementation of this method parses the j3d.configURL property as a * URL string. For example, the following command line would specify that * the config file is taken from the file "j3dconfig" in the current * directory: * <ul> * <code>java -Dj3d.configURL=file:j3dconfig ...</code> * </ul> * * @param defaultURLString the default string used to construct * the URL if the appropriate system properties are not defined * @return the URL of the config file; null is returned if no * valid URL is defined either by the system properties or the * default URL string */ public static URL getConfigURL(String defaultURLString) { URL url = null ; String urlString = null ; final String defProp = defaultURLString ; urlString = (String)java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { public Object run() { return System.getProperty("j3d.configURL", defProp) ; } }) ; if (urlString == null) { return null ; } try { url = new URL(urlString) ; } catch(MalformedURLException e) { System.out.println(e) ; return null ; } return url ; } // A general purpose read-only Map backed by a HashMap. private static class ReadOnlyMap extends AbstractMap { HashMap map ; private Set entrySet = null ; ReadOnlyMap(Map map) { this.map = new HashMap(map) ; } // overridden for efficiency public Object get(Object key) { return map.get(key) ; } // overridden for efficiency public boolean containsKey(Object key) { return map.containsKey(key) ; } // overridden for efficiency public boolean containsValue(Object value) { return map.containsValue(value) ; } public Set entrySet() { if (entrySet == null) entrySet = new ReadOnlySet(map.entrySet()) ; return entrySet ; } } // A general purpose read-only Set backed by a Collection containing // unique objects. private static class ReadOnlySet extends AbstractSet { Collection collection = null ; ReadOnlySet(Collection c) { this.collection = c ; } public int size() { return collection.size() ; } public Iterator iterator() { return new ReadOnlyIterator(collection.iterator()) ; } } // A general purpose read-only Iterator backed by another Iterator. private static class ReadOnlyIterator implements Iterator { private Iterator i ; ReadOnlyIterator(Iterator i) { this.i = i ; } public boolean hasNext() { return i.hasNext() ; } public Object next() { return i.next() ; } public void remove() { throw new UnsupportedOperationException() ; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -