Package com.sun.j3d.utils.universe

Source Code of com.sun.j3d.utils.universe.ConfigContainer$ReadOnlySet

/*      */ package com.sun.j3d.utils.universe;
/*      */
/*      */ import java.io.BufferedReader;
/*      */ import java.io.IOException;
/*      */ import java.io.InputStream;
/*      */ import java.io.InputStreamReader;
/*      */ import java.io.PrintStream;
/*      */ import java.io.Reader;
/*      */ import java.io.StreamTokenizer;
/*      */ import java.net.MalformedURLException;
/*      */ import java.net.URL;
/*      */ import java.security.AccessController;
/*      */ import java.security.PrivilegedAction;
/*      */ import java.util.AbstractMap;
/*      */ import java.util.AbstractSet;
/*      */ import java.util.ArrayList;
/*      */ import java.util.Collection;
/*      */ import java.util.HashMap;
/*      */ import java.util.Iterator;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import java.util.Set;
/*      */ import javax.media.j3d.InputDevice;
/*      */
/*      */ public class ConfigContainer
/*      */ {
/*   88 */   private Map baseNameMap = new HashMap();
/*      */
/*   91 */   private Map viewCanvasMap = new HashMap();
/*      */
/*   94 */   private ReadOnlyMap bodyMap = null;
/*   95 */   private ReadOnlyMap environmentMap = null;
/*   96 */   private ReadOnlyMap viewerMap = null;
/*   97 */   private ReadOnlyMap deviceMap = null;
/*   98 */   private ReadOnlyMap sensorMap = null;
/*   99 */   private ReadOnlyMap behaviorMap = null;
/*  100 */   private ReadOnlyMap platformMap = null;
/*  101 */   private ReadOnlyMap genericObjectMap = null;
/*      */
/*  104 */   private ReadOnlySet bodies = null;
/*  105 */   private ReadOnlySet environments = null;
/*  106 */   private ReadOnlySet viewers = null;
/*  107 */   private ReadOnlySet devices = null;
/*  108 */   private ReadOnlySet sensors = null;
/*  109 */   private ReadOnlySet behaviors = null;
/*  110 */   private ReadOnlySet platforms = null;
/*  111 */   private ReadOnlySet genericObjects = null;
/*      */
/*  114 */   private int transformCount = 1;
/*      */
/*  117 */   private boolean setVisible = false;
/*      */
/*  122 */   String currentFileName = null;
/*      */
/*      */   public ConfigContainer(URL userConfig)
/*      */   {
/*  132 */     this(userConfig, false, 1, true);
/*      */   }
/*      */
/*      */   public ConfigContainer(URL userConfig, boolean setVisible, int transformCount)
/*      */   {
/*  151 */     this(userConfig, setVisible, transformCount, true);
/*      */   }
/*      */
/*      */   ConfigContainer(URL userConfig, boolean setVisible, int transformCount, boolean attachBehaviors)
/*      */   {
/*  188 */     if (transformCount < 1) {
/*  189 */       throw new IllegalArgumentException("transformCount must be greater than 0");
/*      */     }
/*      */
/*  192 */     loadConfig(userConfig);
/*  193 */     processConfig(setVisible, transformCount, attachBehaviors);
/*      */   }
/*      */
/*      */   private void loadConfig(URL userConfig)
/*      */   {
/*  202 */     InputStream inputStream = null;
/*  203 */     StreamTokenizer streamTokenizer = null;
/*  204 */     String lastFileName = this.currentFileName;
/*      */
/*  206 */     this.currentFileName = userConfig.toString();
/*      */     try {
/*  208 */       inputStream = userConfig.openStream();
/*  209 */       Reader r = new BufferedReader(new InputStreamReader(inputStream));
/*  210 */       streamTokenizer = new StreamTokenizer(r);
/*      */     }
/*      */     catch (IOException e) {
/*  213 */       throw new IllegalArgumentException("\n" + e + "\nUnable to open " + this.currentFileName);
/*      */     }
/*      */
/*  232 */     streamTokenizer.ordinaryChar(47);
/*  233 */     streamTokenizer.wordChars(95, 95);
/*  234 */     streamTokenizer.wordChars(36, 36);
/*  235 */     streamTokenizer.wordChars(123, 125);
/*  236 */     streamTokenizer.slashSlashComments(true);
/*  237 */     streamTokenizer.slashStarComments(true);
/*      */
/*  240 */     ConfigSexpression sexp = new ConfigSexpression();
/*      */
/*  244 */     while (sexp.parseAndEval(this, streamTokenizer, 0) != Boolean.FALSE);
/*      */     try
/*      */     {
/*  248 */       inputStream.close();
/*      */     }
/*      */     catch (IOException e) {
/*  251 */       throw new IllegalArgumentException("\n" + e + "\nUnable to close " + this.currentFileName);
/*      */     }
/*      */
/*  256 */     this.currentFileName = lastFileName;
/*      */   }
/*      */
/*      */   void evaluateCommand(ArrayList elements, int lineNumber)
/*      */   {
/*  271 */     ConfigCommand cmd = new ConfigCommand(elements, this.currentFileName, lineNumber);
/*      */     ConfigObject co;
/*  274 */     switch (cmd.type) {
/*      */     case 0:
/*  276 */       co = createConfigObject(cmd);
/*  277 */       addConfigObject(co);
/*  278 */       break;
/*      */     case 3:
/*  280 */       co = createConfigAlias(cmd);
/*  281 */       addConfigObject(co);
/*  282 */       break;
/*      */     case 2:
/*  284 */       co = findConfigObject(cmd.baseName, cmd.instanceName);
/*  285 */       co.setProperty(cmd);
/*  286 */       break;
/*      */     case 5:
/*  288 */       if (!(cmd.argv[1] instanceof String)) {
/*  289 */         throw new IllegalArgumentException("Include file must be a URL string");
/*      */       }
/*      */
/*  292 */       URL url = null;
/*  293 */       String urlString = (String)cmd.argv[1];
/*      */       try {
/*  295 */         url = new URL(urlString);
/*      */       }
/*      */       catch (MalformedURLException e) {
/*  298 */         throw new IllegalArgumentException(e.toString());
/*      */       }
/*  300 */       loadConfig(url);
/*  301 */       break;
/*      */     case 6:
/*  303 */       break;
/*      */     case 1:
/*      */     case 4:
/*      */     default:
/*  305 */       throw new IllegalArgumentException("Unknown command \"" + cmd.commandName + "\"");
/*      */     }
/*      */   }
/*      */
/*      */   private ConfigObject createConfigObject(ConfigCommand cmd)
/*      */   {
/*  325 */     Class objectClass = null;
/*  326 */     ConfigObject configObject = null;
/*      */     try
/*      */     {
/*  333 */       objectClass = Class.forName("com.sun.j3d.utils.universe.Config" + cmd.baseName);
/*      */     }
/*      */     catch (ClassNotFoundException e)
/*      */     {
/*  337 */       throw new IllegalArgumentException("\"" + cmd.baseName + "\"" + " is not a configurable object; ignoring command");
/*      */     }
/*      */
/*      */     try
/*      */     {
/*  342 */       configObject = (ConfigObject)objectClass.newInstance();
/*      */     }
/*      */     catch (IllegalAccessException e) {
/*  345 */       System.out.println(e);
/*  346 */       throw new IllegalArgumentException("Ignoring command");
/*      */     }
/*      */     catch (InstantiationException e) {
/*  349 */       System.out.println(e);
/*  350 */       throw new IllegalArgumentException("Ignoring command");
/*      */     }
/*      */
/*  356 */     for (int i = 2; i < cmd.argc; i++) {
/*  357 */       if (((cmd.argv[i] instanceof String)) && (((String)cmd.argv[i]).equals("Alias")))
/*      */       {
/*  359 */         if ((i == cmd.argc - 2) && ((cmd.argv[(i + 1)] instanceof String))) {
/*  360 */           addConfigObject(new ConfigAlias(cmd.baseName, (String)cmd.argv[(i + 1)], configObject));
/*      */
/*  363 */           cmd.argc -= 2;
/*      */         }
/*      */         else {
/*  366 */           throw new IllegalArgumentException("The alias name must be a string and must be the last command argument");
/*      */         }
/*      */
/*      */       }
/*      */
/*      */     }
/*      */
/*  374 */     configObject.baseName = cmd.baseName;
/*  375 */     configObject.instanceName = cmd.instanceName;
/*  376 */     configObject.creatingCommand = cmd;
/*  377 */     configObject.configContainer = this;
/*      */
/*  380 */     configObject.initialize(cmd);
/*  381 */     return configObject;
/*      */   }
/*      */
/*      */   private ConfigObject createConfigAlias(ConfigCommand cmd)
/*      */   {
/*  396 */     if ((cmd.argc != 3) || (!(cmd.argv[2] instanceof String))) {
/*  397 */       throw new IllegalArgumentException("Command \"" + cmd.commandName + "\" requires an instance name as second argument");
/*      */     }
/*      */
/*  401 */     ConfigObject original = findConfigObject(cmd.baseName, (String)cmd.argv[2]);
/*  402 */     return new ConfigAlias(cmd.baseName, cmd.instanceName, original);
/*      */   }
/*      */
/*      */   private void addConfigObject(ConfigObject object)
/*      */   {
/*  430 */     ArrayList instances = (ArrayList)this.baseNameMap.get(object.baseName);
/*  431 */     if (instances == null) {
/*  432 */       instances = new ArrayList();
/*  433 */       this.baseNameMap.put(object.baseName, instances);
/*      */     }
/*      */
/*  437 */     for (int i = 0; i < instances.size(); i++) {
/*  438 */       ConfigObject co = (ConfigObject)instances.get(i);
/*  439 */       if (co.instanceName.equals(object.instanceName))
/*      */       {
/*  441 */         String base = object.baseName;
/*  442 */         if (base.equals("Screen")) base = "Screen or Window";
/*  443 */         throw new IllegalArgumentException("Duplicate " + base + " instance name \"" + object.instanceName + "\" ignored");
/*      */       }
/*      */
/*      */     }
/*      */
/*  449 */     instances.add(object);
/*      */   }
/*      */
/*      */   ConfigObject findConfigObject(String baseName, String instanceName)
/*      */   {
/*  465 */     ArrayList instances = (ArrayList)this.baseNameMap.get(baseName);
/*  466 */     if (instances != null) {
/*  467 */       for (int i = 0; i < instances.size(); i++) {
/*  468 */         ConfigObject configObject = (ConfigObject)instances.get(i);
/*      */
/*  470 */         if (configObject.instanceName.equals(instanceName)) {
/*  471 */           if (configObject.isAlias) {
/*  472 */             return configObject.original;
/*      */           }
/*  474 */           return configObject;
/*      */         }
/*      */       }
/*      */
/*      */     }
/*      */
/*  480 */     if (baseName.equals("Screen")) baseName = "Screen or Window";
/*  481 */     throw new IllegalArgumentException(baseName + " \"" + instanceName + "\" not found");
/*      */   }
/*      */
/*      */   Collection findConfigObjects(String baseName)
/*      */   {
/*  495 */     return findConfigObjects(baseName, true);
/*      */   }
/*      */
/*      */   Collection findConfigObjects(String baseName, boolean filterAlias)
/*      */   {
/*  511 */     ArrayList instances = (ArrayList)this.baseNameMap.get(baseName);
/*  512 */     if ((instances == null) || (instances.size() == 0)) {
/*  513 */       return null;
/*      */     }
/*      */
/*  516 */     if (filterAlias) {
/*  517 */       ArrayList output = new ArrayList();
/*  518 */       for (int i = 0; i < instances.size(); i++) {
/*  519 */         ConfigObject configObject = (ConfigObject)instances.get(i);
/*      */
/*  521 */         if (!configObject.isAlias) {
/*  522 */           output.add(configObject);
/*      */         }
/*      */       }
/*  525 */       return output;
/*      */     }
/*      */
/*  528 */     return instances;
/*      */   }
/*      */
/*      */   private ConfigObject findConfigObject(String baseName, ConfigCommand cmd)
/*      */   {
/*  544 */     if ((cmd.argc != 2) || (!(cmd.argv[1] instanceof String))) {
/*  545 */       throw new IllegalArgumentException(ConfigObject.errorMessage(cmd, "Parameter must be a single string"));
/*      */     }
/*      */     try
/*      */     {
/*  549 */       return findConfigObject(baseName, (String)cmd.argv[1]);
/*      */     }
/*      */     catch (IllegalArgumentException e) {
/*  552 */       throw new IllegalArgumentException(ConfigObject.errorMessage(cmd, e.getMessage()));
/*      */     }
/*      */   }
/*      */
/*      */   Object evaluateBuiltIn(ConfigCommand cmd)
/*      */   {
/*  566 */     int argc = cmd.argc;
/*  567 */     Object[] argv = cmd.argv;
/*      */
/*  569 */     if (cmd.commandName.equals("ConfigContainer"))
/*      */     {
/*  571 */       return this;
/*      */     }
/*  573 */     if (cmd.commandName.equals("Canvas3D"))
/*      */     {
/*  575 */       return ((ConfigScreen)findConfigObject("Screen", cmd)).j3dCanvas;
/*      */     }
/*  577 */     if (this.baseNameMap.get(cmd.commandName) != null)
/*      */     {
/*  580 */       return findConfigObject(cmd.commandName, cmd).targetObject;
/*      */     }
/*      */
/*  584 */     throw new IllegalArgumentException(ConfigObject.errorMessage(cmd, "Unknown built-in command \"" + cmd.commandName + "\""));
/*      */   }
/*      */
/*      */   private void processConfig(boolean setVisible, int transformCount, boolean attachBehaviors)
/*      */   {
/*  605 */     this.setVisible = setVisible;
/*  606 */     this.transformCount = transformCount;
/*      */
/*  608 */     Collection c = findConfigObjects("PhysicalBody");
/*  609 */     if (c != null) {
/*  610 */       processPhysicalBodies(c);
/*      */     }
/*      */
/*  613 */     Collection pe = findConfigObjects("PhysicalEnvironment");
/*  614 */     if (pe != null) {
/*  615 */       processPhysicalEnvironments(pe);
/*      */     }
/*      */
/*  618 */     c = findConfigObjects("View");
/*  619 */     if (c != null) {
/*  620 */       processViews(c, setVisible);
/*      */     }
/*      */
/*  623 */     c = findConfigObjects("Device");
/*  624 */     Collection s = findConfigObjects("Sensor");
/*  625 */     if (c != null) {
/*  626 */       processDevices(c, s, pe);
/*      */     }
/*      */
/*  629 */     Collection vp = findConfigObjects("ViewPlatform");
/*  630 */     if (vp != null) {
/*  631 */       processViewPlatforms(vp, transformCount);
/*      */     }
/*      */
/*  634 */     c = findConfigObjects("ViewPlatformBehavior");
/*  635 */     if (c != null) {
/*  636 */       processViewPlatformBehaviors(c, vp, attachBehaviors);
/*      */     }
/*      */
/*  639 */     c = findConfigObjects("Object");
/*  640 */     if (c != null)
/*  641 */       processGenericObjects(c);
/*      */   }
/*      */
/*      */   private void processPhysicalEnvironments(Collection c)
/*      */   {
/*  648 */     Iterator i = c.iterator();
/*  649 */     while (i.hasNext()) {
/*  650 */       ConfigPhysicalEnvironment e = (ConfigPhysicalEnvironment)i.next();
/*  651 */       e.targetObject = e.createJ3dPhysicalEnvironment();
/*      */     }
/*      */   }
/*      */
/*      */   private void processPhysicalBodies(Collection c)
/*      */   {
/*  657 */     Iterator i = c.iterator();
/*  658 */     while (i.hasNext()) {
/*  659 */       ConfigPhysicalBody b = (ConfigPhysicalBody)i.next();
/*  660 */       b.targetObject = b.createJ3dPhysicalBody();
/*      */     }
/*      */   }
/*      */
/*      */   private void processViews(Collection c, boolean setVisible)
/*      */   {
/*  668 */     Iterator i = c.iterator();
/*  669 */     while (i.hasNext()) {
/*  670 */       ConfigView v = (ConfigView)i.next();
/*  671 */       v.targetObject = v.createViewer(setVisible);
/*      */     }
/*      */   }
/*      */
/*      */   private void processDevices(Collection c, Collection s, Collection p)
/*      */   {
/*  679 */     ConfigDevice cd = null;
/*  680 */     Iterator i = c.iterator();
/*  681 */     while (i.hasNext()) {
/*  682 */       cd = (ConfigDevice)i.next();
/*  683 */       cd.targetObject = cd.createInputDevice();
/*      */     }
/*      */
/*  689 */     i = c.iterator();
/*  690 */     while (i.hasNext()) ((ConfigDevice)i.next()).processProperties();
/*      */
/*  695 */     i = c.iterator();
/*  696 */     while (i.hasNext()) {
/*  697 */       cd = (ConfigDevice)i.next();
/*  698 */       if (!cd.j3dInputDevice.initialize()) {
/*  699 */         throw new RuntimeException(ConfigDevice.errorMessage(cd.creatingCommand, "could not initialize device \"" + cd.instanceName + "\""));
/*      */       }
/*      */
/*      */     }
/*      */
/*  707 */     if (s != null) {
/*  708 */       i = s.iterator();
/*  709 */       while (i.hasNext()) {
/*  710 */         ConfigSensor cs = (ConfigSensor)i.next();
/*  711 */         cs.configureSensor();
/*  712 */         cs.targetObject = cs.j3dSensor;
/*      */       }
/*      */
/*      */     }
/*      */
/*  717 */     if (p != null) {
/*  718 */       i = p.iterator();
/*  719 */       while (i.hasNext())
/*  720 */         ((ConfigPhysicalEnvironment)i.next()).processDevices();
/*      */     }
/*      */   }
/*      */
/*      */   private void processViewPlatforms(Collection c, int numTransforms)
/*      */   {
/*  726 */     Iterator i = c.iterator();
/*  727 */     while (i.hasNext()) {
/*  728 */       ConfigViewPlatform cvp = (ConfigViewPlatform)i.next();
/*  729 */       cvp.targetObject = cvp.createViewingPlatform(numTransforms);
/*      */     }
/*      */   }
/*      */
/*      */   private void processViewPlatformBehaviors(Collection behaviors, Collection viewPlatforms, boolean attach)
/*      */   {
/*  737 */     Iterator i = behaviors.iterator();
/*  738 */     while (i.hasNext()) {
/*  739 */       ConfigViewPlatformBehavior b = (ConfigViewPlatformBehavior)i.next();
/*      */
/*  741 */       b.targetObject = b.createViewPlatformBehavior();
/*      */     }
/*      */
/*  745 */     i = behaviors.iterator();
/*  746 */     while (i.hasNext()) {
/*  747 */       ((ConfigViewPlatformBehavior)i.next()).processProperties();
/*      */     }
/*      */
/*  750 */     if ((attach) && (viewPlatforms != null)) {
/*  751 */       i = viewPlatforms.iterator();
/*  752 */       while (i.hasNext())
/*  753 */         ((ConfigViewPlatform)i.next()).processBehavior();
/*      */     }
/*      */   }
/*      */
/*      */   private void processGenericObjects(Collection objects)
/*      */   {
/*  759 */     Iterator i = objects.iterator();
/*  760 */     while (i.hasNext()) {
/*  761 */       ConfigObject o = (ConfigObject)i.next();
/*  762 */       o.targetObject = o.createTargetObject();
/*      */     }
/*      */
/*  766 */     i = objects.iterator();
/*  767 */     while (i.hasNext()) ((ConfigObject)i.next()).processProperties();
/*      */   }
/*      */
/*      */   private ReadOnlySet createSet(String baseName)
/*      */   {
/*  773 */     Collection c = findConfigObjects(baseName, true);
/*  774 */     if ((c == null) || (c.size() == 0)) {
/*  775 */       return null;
/*      */     }
/*  777 */     Iterator i = c.iterator();
/*  778 */     ArrayList l = new ArrayList();
/*  779 */     while (i.hasNext()) l.add(((ConfigObject)i.next()).targetObject);
/*      */
/*  781 */     return new ReadOnlySet(l);
/*      */   }
/*      */
/*      */   private ReadOnlyMap createMap(String baseName)
/*      */   {
/*  787 */     Collection c = findConfigObjects(baseName, false);
/*  788 */     if ((c == null) || (c.size() == 0)) {
/*  789 */       return null;
/*      */     }
/*  791 */     Iterator i = c.iterator();
/*  792 */     HashMap m = new HashMap();
/*  793 */     while (i.hasNext()) {
/*  794 */       ConfigObject co = (ConfigObject)i.next();
/*  795 */       if (co.isAlias)
/*  796 */         m.put(co.instanceName, co.original.targetObject);
/*      */       else {
/*  798 */         m.put(co.instanceName, co.targetObject);
/*      */       }
/*      */     }
/*  801 */     return new ReadOnlyMap(m);
/*      */   }
/*      */
/*      */   public Set getPhysicalBodies()
/*      */   {
/*  823 */     if (this.bodies != null) return this.bodies;
/*  824 */     this.bodies = createSet("PhysicalBody");
/*  825 */     return this.bodies;
/*      */   }
/*      */
/*      */   public Map getNamedPhysicalBodies()
/*      */   {
/*  836 */     if (this.bodyMap != null) return this.bodyMap;
/*  837 */     this.bodyMap = createMap("PhysicalBody");
/*  838 */     return this.bodyMap;
/*      */   }
/*      */
/*      */   public Set getPhysicalEnvironments()
/*      */   {
/*  860 */     if (this.environments != null) return this.environments;
/*  861 */     this.environments = createSet("PhysicalEnvironment");
/*  862 */     return this.environments;
/*      */   }
/*      */
/*      */   public Map getNamedPhysicalEnvironments()
/*      */   {
/*  874 */     if (this.environmentMap != null) return this.environmentMap;
/*  875 */     this.environmentMap = createMap("PhysicalEnvironment");
/*  876 */     return this.environmentMap;
/*      */   }
/*      */
/*      */   public Set getViewers()
/*      */   {
/*  900 */     if (this.viewers != null) return this.viewers;
/*  901 */     this.viewers = createSet("View");
/*  902 */     return this.viewers;
/*      */   }
/*      */
/*      */   public Map getNamedViewers()
/*      */   {
/*  916 */     if (this.viewerMap != null) return this.viewerMap;
/*  917 */     this.viewerMap = createMap("View");
/*  918 */     return this.viewerMap;
/*      */   }
/*      */
/*      */   public Set getInputDevices()
/*      */   {
/*  953 */     if (this.devices != null) return this.devices;
/*  954 */     this.devices = createSet("Device");
/*  955 */     return this.devices;
/*      */   }
/*      */
/*      */   public Map getNamedInputDevices()
/*      */   {
/*  969 */     if (this.deviceMap != null) return this.deviceMap;
/*  970 */     this.deviceMap = createMap("Device");
/*  971 */     return this.deviceMap;
/*      */   }
/*      */
/*      */   public Set getSensors()
/*      */   {
/* 1005 */     if (this.sensors != null) return this.sensors;
/* 1006 */     this.sensors = createSet("Sensor");
/* 1007 */     return this.sensors;
/*      */   }
/*      */
/*      */   public Map getNamedSensors()
/*      */   {
/* 1024 */     if (this.sensorMap != null) return this.sensorMap;
/* 1025 */     this.sensorMap = createMap("Sensor");
/* 1026 */     return this.sensorMap;
/*      */   }
/*      */
/*      */   public Set getViewingPlatforms()
/*      */   {
/* 1051 */     if (this.platforms != null) return this.platforms;
/* 1052 */     this.platforms = createSet("ViewPlatform");
/* 1053 */     return this.platforms;
/*      */   }
/*      */
/*      */   public Map getNamedViewingPlatforms()
/*      */   {
/* 1067 */     if (this.platformMap != null) return this.platformMap;
/* 1068 */     this.platformMap = createMap("ViewPlatform");
/* 1069 */     return this.platformMap;
/*      */   }
/*      */
/*      */   public Set getViewPlatformBehaviors()
/*      */   {
/* 1114 */     if (this.behaviors != null) return this.behaviors;
/* 1115 */     this.behaviors = createSet("ViewPlatformBehavior");
/* 1116 */     return this.behaviors;
/*      */   }
/*      */
/*      */   public Map getNamedViewPlatformBehaviors()
/*      */   {
/* 1136 */     if (this.behaviorMap != null) return this.behaviorMap;
/* 1137 */     this.behaviorMap = createMap("ViewPlatformBehavior");
/* 1138 */     return this.behaviorMap;
/*      */   }
/*      */
/*      */   public Map getNamedCanvases(String viewName)
/*      */   {
/* 1167 */     Map m = (Map)this.viewCanvasMap.get(viewName);
/* 1168 */     if (m != null) return m;
/*      */
/* 1170 */     m = new HashMap();
/* 1171 */     ConfigView cv = (ConfigView)findConfigObject("View", viewName);
/* 1172 */     Iterator i = cv.screens.iterator();
/* 1173 */     while (i.hasNext()) {
/* 1174 */       ConfigScreen cs = (ConfigScreen)i.next();
/* 1175 */       m.put(cs.instanceName, cs.j3dCanvas);
/*      */
/* 1178 */       Iterator j = cs.aliases.iterator();
/* 1179 */       while (j.hasNext()) m.put(j.next(), cs.j3dCanvas);
/*      */     }
/* 1181 */     m = new ReadOnlyMap(m);
/* 1182 */     this.viewCanvasMap.put(viewName, m);
/* 1183 */     return m;
/*      */   }
/*      */
/*      */   public Set getGenericObjects()
/*      */   {
/* 1214 */     if (this.genericObjects != null) return this.genericObjects;
/* 1215 */     this.genericObjects = createSet("Object");
/* 1216 */     return this.genericObjects;
/*      */   }
/*      */
/*      */   public Map getNamedGenericObjects()
/*      */   {
/* 1229 */     if (this.genericObjectMap != null) return this.genericObjectMap;
/* 1230 */     this.genericObjectMap = createMap("Object");
/* 1231 */     return this.genericObjectMap;
/*      */   }
/*      */
/*      */   public int getViewPlatformTransformCount()
/*      */   {
/* 1242 */     return this.transformCount;
/*      */   }
/*      */
/*      */   public boolean getViewerVisibility()
/*      */   {
/* 1255 */     return this.setVisible;
/*      */   }
/*      */
/*      */   public void clear()
/*      */   {
/* 1264 */     Iterator i = this.baseNameMap.values().iterator();
/* 1265 */     while (i.hasNext()) ((Collection)i.next()).clear();
/* 1266 */     this.baseNameMap.clear();
/*      */
/* 1269 */     i = this.viewCanvasMap.values().iterator();
/* 1270 */     while (i.hasNext()) ((ReadOnlyMap)i.next()).map.clear();
/* 1271 */     this.viewCanvasMap.clear();
/*      */
/* 1274 */     this.currentFileName = null;
/*      */
/* 1277 */     if (this.bodies != null) {
/* 1278 */       this.bodies.collection.clear();
/* 1279 */       this.bodies = null;
/*      */     }
/* 1281 */     if (this.environments != null) {
/* 1282 */       this.environments.collection.clear();
/* 1283 */       this.environments = null;
/*      */     }
/* 1285 */     if (this.devices != null) {
/* 1286 */       this.devices.collection.clear();
/* 1287 */       this.devices = null;
/*      */     }
/* 1289 */     if (this.sensors != null) {
/* 1290 */       this.sensors.collection.clear();
/* 1291 */       this.sensors = null;
/*      */     }
/* 1293 */     if (this.behaviors != null) {
/* 1294 */       this.behaviors.collection.clear();
/* 1295 */       this.behaviors = null;
/*      */     }
/* 1297 */     if (this.platforms != null) {
/* 1298 */       this.platforms.collection.clear();
/* 1299 */       this.platforms = null;
/*      */     }
/* 1301 */     if (this.viewers != null) {
/* 1302 */       this.viewers.collection.clear();
/* 1303 */       this.viewers = null;
/*      */     }
/* 1305 */     if (this.genericObjects != null) {
/* 1306 */       this.genericObjects.collection.clear();
/* 1307 */       this.genericObjects = null;
/*      */     }
/*      */
/* 1311 */     if (this.bodyMap != null) {
/* 1312 */       this.bodyMap.map.clear();
/* 1313 */       this.bodyMap = null;
/*      */     }
/* 1315 */     if (this.environmentMap != null) {
/* 1316 */       this.environmentMap.map.clear();
/* 1317 */       this.environmentMap = null;
/*      */     }
/* 1319 */     if (this.deviceMap != null) {
/* 1320 */       this.deviceMap.map.clear();
/* 1321 */       this.deviceMap = null;
/*      */     }
/* 1323 */     if (this.sensorMap != null) {
/* 1324 */       this.sensorMap.map.clear();
/* 1325 */       this.sensorMap = null;
/*      */     }
/* 1327 */     if (this.behaviorMap != null) {
/* 1328 */       this.behaviorMap.map.clear();
/* 1329 */       this.behaviorMap = null;
/*      */     }
/* 1331 */     if (this.platformMap != null) {
/* 1332 */       this.platformMap.map.clear();
/* 1333 */       this.platformMap = null;
/*      */     }
/* 1335 */     if (this.viewerMap != null) {
/* 1336 */       this.viewerMap.map.clear();
/* 1337 */       this.viewerMap = null;
/*      */     }
/* 1339 */     if (this.genericObjectMap != null) {
/* 1340 */       this.genericObjectMap.map.clear();
/* 1341 */       this.genericObjectMap = null;
/*      */     }
/*      */   }
/*      */
/*      */   public static URL getConfigURL()
/*      */   {
/* 1360 */     return getConfigURL(null);
/*      */   }
/*      */
/*      */   public static URL getConfigURL(String defaultURLString)
/*      */   {
/* 1380 */     URL url = null;
/* 1381 */     String urlString = null;
/* 1382 */     String defProp = defaultURLString;
/*      */
/* 1384 */     urlString = (String)AccessController.doPrivileged(new PrivilegedAction() {
/*      */       private final String val$defProp;
/*      */
/* 1387 */       public Object run() { return System.getProperty("j3d.configURL", this.val$defProp); }
/*      */
/*      */     });
/* 1391 */     if (urlString == null)
/* 1392 */       return null;
/*      */     try
/*      */     {
/* 1395 */       url = new URL(urlString);
/*      */     }
/*      */     catch (MalformedURLException e) {
/* 1398 */       System.out.println(e);
/* 1399 */       return null;
/*      */     }
/* 1401 */     return url;
/*      */   }
/*      */
/*      */   private static class ReadOnlyIterator
/*      */     implements Iterator
/*      */   {
/*      */     private Iterator i;
/*      */
/*      */     ReadOnlyIterator(Iterator i)
/*      */     {
/* 1459 */       this.i = i;
/*      */     }
/*      */
/*      */     public boolean hasNext() {
/* 1463 */       return this.i.hasNext();
/*      */     }
/*      */
/*      */     public Object next() {
/* 1467 */       return this.i.next();
/*      */     }
/*      */
/*      */     public void remove() {
/* 1471 */       throw new UnsupportedOperationException();
/*      */     }
/*      */   }
/*      */
/*      */   private static class ReadOnlySet extends AbstractSet
/*      */   {
/* 1439 */     Collection collection = null;
/*      */
/*      */     ReadOnlySet(Collection c) {
/* 1442 */       this.collection = c;
/*      */     }
/*      */
/*      */     public int size() {
/* 1446 */       return this.collection.size();
/*      */     }
/*      */
/*      */     public Iterator iterator() {
/* 1450 */       return new ConfigContainer.ReadOnlyIterator(this.collection.iterator());
/*      */     }
/*      */   }
/*      */
/*      */   private static class ReadOnlyMap extends AbstractMap
/*      */   {
/*      */     HashMap map;
/* 1407 */     private Set entrySet = null;
/*      */
/*      */     ReadOnlyMap(Map map) {
/* 1410 */       this.map = new HashMap(map);
/*      */     }
/*      */
/*      */     public Object get(Object key)
/*      */     {
/* 1415 */       return this.map.get(key);
/*      */     }
/*      */
/*      */     public boolean containsKey(Object key)
/*      */     {
/* 1420 */       return this.map.containsKey(key);
/*      */     }
/*      */
/*      */     public boolean containsValue(Object value)
/*      */     {
/* 1425 */       return this.map.containsValue(value);
/*      */     }
/*      */
/*      */     public Set entrySet() {
/* 1429 */       if (this.entrySet == null) {
/* 1430 */         this.entrySet = new ConfigContainer.ReadOnlySet(this.map.entrySet());
/*      */       }
/* 1432 */       return this.entrySet;
/*      */     }
/*      */   }
/*      */
/*      */   private static class ConfigAlias extends ConfigObject
/*      */   {
/*      */     ConfigAlias(String baseName, String instanceName, ConfigObject targ)
/*      */     {
/*  413 */       this.baseName = baseName;
/*  414 */       this.instanceName = instanceName;
/*  415 */       this.isAlias = true;
/*  416 */       this.original = targ;
/*  417 */       targ.aliases.add(instanceName);
/*      */     }
/*      */   }
/*      */ }

/* Location:           Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name:     com.sun.j3d.utils.universe.ConfigContainer
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.sun.j3d.utils.universe.ConfigContainer$ReadOnlySet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.