Revision: 20480
          http://sourceforge.net/p/jmol/code/20480
Author:   hansonr
Date:     2015-05-06 23:26:41 +0000 (Wed, 06 May 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.13_2015.05.06"

new feature: "drilling" in associative arrays for sub arrays with a given 
property (Rolf Huehne)
   -- uses "**" as the SELECT option, sort of the way ** sometimes means 
"subdirectories of"
   -- example:
   
    x = [key_1:[type:"a"],key_2:[type:"b"],key_3:[type:"a"]]
        z = getProperty(x, "[SELECT ** WHERE type='a']");
        show z;

                z = { "key_1":{ "type":"a" },"key_3":{ "type":"a" } }

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/PropertyManager.java

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-05-05 18:30:30 UTC 
(rev 20479)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-05-06 23:26:41 UTC 
(rev 20480)
@@ -14,8 +14,20 @@
 
 TODO: remove HTML5 dependency on synchronous file loading (check SCRIPT 
command for problems)
 
-Jmol.___JmolVersion="14.3.13_2015.05.05"
+Jmol.___JmolVersion="14.3.13_2015.05.06"
 
+new feature: "drilling" in associative arrays for sub arrays with a given 
property (Rolf Huehne)
+   -- uses "**" as the SELECT option, sort of the way ** sometimes means 
"subdirectories of"
+   -- example:
+   
+    x = [key_1:[type:"a"],key_2:[type:"b"],key_3:[type:"a"]]
+       z = getProperty(x, "[SELECT ** WHERE type='a']");
+       show z;
+
+               z = { "key_1":{ "type":"a" },"key_3":{ "type":"a" } }
+
+JmolVersion="14.3.13_2015.05.05"
+
 bug fix: set modifyStructureCallback does not work with "JmolScript:...."
 
 JmolVersion="14.3.13_2015.05.03"

Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-05-05 18:30:30 UTC 
(rev 20479)
+++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2015-05-06 23:26:41 UTC 
(rev 20480)
@@ -46,6 +46,7 @@
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 
 import org.jmol.api.Interface;
@@ -393,9 +394,25 @@
       if (property instanceof Map<?, ?>) {
         Map<String, ?> h = (Map<String, ?>) property;
         String key;
+        boolean asMap = false;
         if (arg.tok == T.select) {
           key = arg.myName;
-          if (!vwr.checkSelect((Map<String, SV>) property, (T[]) arg.value))
+          if (key.equals("**")) {
+            // find associated keys whose associated arrays fulfill the 
requirements
+            key = "";
+            for (Entry<String, ?>e : h.entrySet()) {
+              String k = e.getKey();
+              SV v = (SV) e.getValue();
+              if (v.tok == T.hash) {
+                if (vwr.checkSelect((Map<String, SV>) v.value, (T[]) 
arg.value))
+                  key += "," + k;
+              }
+            }
+            if (key.length() == 0)
+              return "";
+            key = key.substring(1);
+            asMap = true;
+          } else if (!vwr.checkSelect((Map<String, SV>) property, (T[]) 
arg.value))
             return "";
         } else {
           key = arg.asString();
@@ -406,7 +423,6 @@
             return extractProperty(keys, args, ptr, null, true);
           }
         }
-
         boolean isWild = (key.startsWith("*") || key.endsWith("*") || 
key.indexOf(",") >= 0);
         if (isWild && v2 == null)
           v2 = new Lst<Object>();
@@ -414,15 +430,16 @@
           if (ptr == ((SV[]) args).length) {
             v2.addLast(property);
             return v2;
-          }
+          } 
           return extractProperty(property, args, ptr, v2, true);
         }
         if (key.contains(",")) {
-          Map<String, Object> mapNew = null;
-          mapNew = new Hashtable<String, Object>();
+          Map<String, Object> mapNew = new Hashtable<String, Object>();
           String[] tokens = PT.split(key, ",");
           for (int i = tokens.length; --i >= 0;)
             PT.getMapSubset(h, tokens[i], mapNew);
+          if (asMap)
+            return mapNew;
           if (ptr == ((SV[]) args).length) {
             v2.addLast(mapNew);
             return v2;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to