Revision: 20895
          http://sourceforge.net/p/jmol/code/20895
Author:   hansonr
Date:     2015-12-20 22:01:37 +0000 (Sun, 20 Dec 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.4.1_2015.12.20"

code: (JavaScript) adding use of array.slice and implementing Java byte[] as 
JavaScript Int8Array()
bug fix: array handling for labels very inefficient
bug fix: y = javascript("x") only creates string equivalent of x, not actual 
numerical/object values
bug fix: y = javascript("x") draws "x" from wrapped anonymous function using 
eval() instead of global context using window.eval()

Modified Paths:
--------------
    branches/v14_4/Jmol/src/javajs/util/AU.java
    branches/v14_4/Jmol/src/javajs/util/BS.java
    branches/v14_4/Jmol/src/javajs/util/CompoundDocHeader.java
    branches/v14_4/Jmol/src/javajs/util/PT.java
    branches/v14_4/Jmol/src/javajs/util/Rdr.java
    branches/v14_4/Jmol/src/org/jmol/applet/Jmol.java
    branches/v14_4/Jmol/src/org/jmol/appletjs/Jmol.java
    branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java
    branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java
    branches/v14_4/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java
    branches/v14_4/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java
    branches/v14_4/Jmol/src/org/jmol/modelset/Atom.java
    branches/v14_4/Jmol/src/org/jmol/script/SV.java
    branches/v14_4/Jmol/src/org/jmol/script/ScriptMathProcessor.java
    branches/v14_4/Jmol/src/org/jmol/scriptext/IsoExt.java
    branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java
    branches/v14_4/Jmol/src/org/jmol/shape/AtomShape.java
    branches/v14_4/Jmol/src/org/jmol/util/GenericApplet.java
    branches/v14_4/Jmol/src/org/jmol/viewer/AnimationManager.java
    branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties
    branches/v14_4/Jmol/src/org/jmol/viewer/SelectionManager.java
    branches/v14_4/Jmol/src/org/jmol/viewer/StatusManager.java
    branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java

Modified: branches/v14_4/Jmol/src/javajs/util/AU.java
===================================================================
--- branches/v14_4/Jmol/src/javajs/util/AU.java 2015-12-17 22:22:22 UTC (rev 
20894)
+++ branches/v14_4/Jmol/src/javajs/util/AU.java 2015-12-20 22:01:37 UTC (rev 
20895)
@@ -36,46 +36,36 @@
 
   /**
    * Very important that this not be used with Int32Array or Float32Array,
-   * because it is not initialized to all zeros in MSIE 9.
+   * because it is not initialized to all zeros in MSIE 9. 
    * 
    * @param array
    * @param minimumLength
    * @return array
    */
   public static Object ensureLength(Object array, int minimumLength) {
-    if (array != null && getLength(array) >= minimumLength)
-      return array;
-    return arrayCopyObject(array, minimumLength);
+    return (array != null && getLength(array) >= minimumLength ? array 
+        : arrayCopyObject(array, minimumLength));
   }
 
   public static String[] ensureLengthS(String[] array, int minimumLength) {
-    if (array != null && array.length >= minimumLength)
-      return array;
-    return arrayCopyS(array, minimumLength);
+    return (array != null && array.length >= minimumLength ? array
+        : arrayCopyS(array, minimumLength));
   }
 
   public static float[] ensureLengthA(float[] array, int minimumLength) {
-    if (array != null && array.length >= minimumLength)
-      return array;
-    return arrayCopyF(array, minimumLength);
+   return (array != null && array.length >= minimumLength ? array: 
arrayCopyF(array, minimumLength));
   }
 
   public static int[] ensureLengthI(int[] array, int minimumLength) {
-    if (array != null && array.length >= minimumLength)
-      return array;
-    return arrayCopyI(array, minimumLength);
+    return (array != null && array.length >= minimumLength ? array : 
arrayCopyI(array, minimumLength));
   }
 
   public static short[] ensureLengthShort(short[] array, int minimumLength) {
-    if (array != null && array.length >= minimumLength)
-      return array;
-    return arrayCopyShort(array, minimumLength);
+    return (array != null && array.length >= minimumLength ? array : 
arrayCopyShort(array, minimumLength));
   }
 
   public static byte[] ensureLengthByte(byte[] array, int minimumLength) {
-    if (array != null && array.length >= minimumLength)
-      return array;
-    return arrayCopyByte(array, minimumLength);
+    return (array != null && array.length >= minimumLength ? array : 
arrayCopyByte(array, minimumLength));
   }
 
   /**
@@ -132,22 +122,26 @@
   }
 
   /**
-   * note -- cannot copy if array is null!
+   * note -- cannot copy if array is null! does not copy if length is unchanged
    * 
    * @param array
    * @param newLength
    * @return array
    */
-  public static Object arrayCopyObject(Object array, int newLength) {
-    //System.out.println("ArrayUtil.copy " + newLength + " " + array + "  ");
-    if (array == null) {
-      return null; // We can't allocate since we don't know the type of array
-    }
-    int oldLength = getLength(array);
+  public static Object arrayCopyObject(Object array, int newLength) {  
+    int oldLength = (array == null ? -1 : getLength(array));
+    if (newLength < 0) newLength = oldLength;
     if (newLength == oldLength)
-      return array;
+     return array;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     Object t = newInstanceO(array, newLength);
-    System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
+    if (oldLength > 0)
+      System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
         : newLength);
     return t;
 
@@ -190,11 +184,16 @@
   }
 
   public static String[] arrayCopyS(String[] array, int newLength) {
-    if (newLength < 0)
-      newLength = array.length;
+    int oldLength = (array == null ? -1 : array.length);
+    if (newLength < 0) newLength = oldLength;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     String[] t = new String[newLength];
     if (array != null) {
-      int oldLength = array.length;
       System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
           : newLength);
     }
@@ -224,11 +223,16 @@
   }
 
   public static float[] arrayCopyF(float[] array, int newLength) {
-    if (newLength < 0)
-      newLength = array.length;
+    int oldLength = (array == null ? -1 : array.length);
+    if (newLength < 0) newLength = oldLength;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     float[] t = new float[newLength];
     if (array != null) {
-      int oldLength = array.length;
       System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
           : newLength);
     }
@@ -236,11 +240,16 @@
   }
 
   public static int[] arrayCopyI(int[] array, int newLength) {
-    if (newLength < 0)
-      newLength = array.length;
+    int oldLength = (array == null ? -1 : array.length);
+    if (newLength < 0) newLength = oldLength;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     int[] t = new int[newLength];
     if (array != null) {
-      int oldLength = array.length;
       System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
           : newLength);
     }
@@ -261,29 +270,49 @@
     int oldLength = array.length;
     if (n == -1) n = oldLength;
     if (n == -2) n = oldLength / 2;
-    n = n - i0;
-    int[] t = new int[n];
-    System.arraycopy(array, i0, t, 0, n);
-    return t;
+    /**
+     * @j2sNative
+     * 
+     * return Clazz.newArray(-1, array, i0, n);
+     * 
+     */
+    {
+      n -= i0;
+      int[] t = new int[n];
+      System.arraycopy(array, i0, t, 0, n);
+      return t;
+    }
   }
 
   public static int[] arrayCopyRangeRevI(int[] array, int i0, int n) {
     if (array == null)
       return null;
-    int[] t = arrayCopyRangeI(array, i0, n);
-    if (n < 0)
-      n = array.length;
-    for (int i = n / 2; --i >= 0;)
-      swapInt(t, i, n - 1 - i);
-    return t;
+    /**
+     * @j2sNative
+     * 
+     * return Clazz.newArray(-1, array, i0, n).reverse();
+     */
+    {
+      int[] t = arrayCopyRangeI(array, i0, n);
+      if (n < 0)
+        n = array.length;
+      for (int i = n / 2; --i >= 0;)
+        swapInt(t, i, n - 1 - i);
+      return t;
+    }
   }
 
   public static short[] arrayCopyShort(short[] array, int newLength) {
-    if (newLength < 0)
-      newLength = array.length;
+    int oldLength = (array == null ? -1 : array.length);
+    if (newLength < 0) newLength = oldLength;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     short[] t = new short[newLength];
     if (array != null) {
-      int oldLength = array.length;
       System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
           : newLength);
     }
@@ -291,11 +320,16 @@
   }
 
   public static byte[] arrayCopyByte(byte[] array, int newLength) {
-    if (newLength < 0)
-      newLength = array.length;
+    int oldLength = (array == null ? -1 : array.length);
+    if (newLength < 0) newLength = oldLength;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     byte[] t = new byte[newLength];
     if (array != null) {
-      int oldLength = array.length;
       System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
           : newLength);
     }
@@ -303,11 +337,16 @@
   }
 
   public static boolean[] arrayCopyBool(boolean[] array, int newLength) {
-    if (newLength < 0)
-      newLength = array.length;
+    int oldLength = (array == null ? -1 : array.length);
+    if (newLength < 0) newLength = oldLength;
+    /**
+     * @j2sNative
+     * 
+     *     if (newLength < oldLength) return Clazz.newArray(-1, array, 0, 
newLength);
+     */
+    {}
     boolean[] t = new boolean[newLength];
     if (array != null) {
-      int oldLength = array.length;
       System.arraycopy(array, 0, t, 0, oldLength < newLength ? oldLength
           : newLength);
     }
@@ -584,7 +623,7 @@
        public static boolean isAB(Object x) {
          /**
           * @j2sNative
-          *  return Clazz.isAI(x);
+          *  return Clazz.isAB(x);
           */
          {
          return x instanceof byte[];
@@ -636,6 +675,7 @@
         * process, but particularly out of file reading.
         * 
         * @param b
+        * @return b
         */
        public static byte[] ensureSignedBytes(byte[] b) {
                if (b != null) {

Modified: branches/v14_4/Jmol/src/javajs/util/BS.java
===================================================================
--- branches/v14_4/Jmol/src/javajs/util/BS.java 2015-12-17 22:22:22 UTC (rev 
20894)
+++ branches/v14_4/Jmol/src/javajs/util/BS.java 2015-12-20 22:01:37 UTC (rev 
20895)
@@ -728,9 +728,18 @@
    * @param n 
    */
   private void setLength(int n) {
+    /**
+     * @j2sNative
+     *     if (n == this.words.length) return;
+     *     if (n == this.wordsInUse) {
+     *      this.words = Clazz.newArray(-1, this.words, 0, n);
+     *      return;
+     *     }
+     */
+    {}
     int[] a = new int[n];
-    System.arraycopy(words, 0, a, 0, Math.min(wordsInUse, n));
-    words = a;
+    System.arraycopy(words, 0, a, 0, wordsInUse);
+    words = a;    
   }
 
   /**
@@ -798,8 +807,21 @@
     if (wordCount == 0) {
       bs.words = emptyBitmap;
     } else {
-      bs.words = new int[bs.wordsInUse = wordCount];
-      System.arraycopy(bitsetToCopy.words, 0, bs.words, 0, wordCount);
+      
+      /**
+       * Clazz.clone will copy wordsInUse and sizeIsSticky, 
+       * but just a pointer to the words array.
+       * 
+       * @j2sNative
+       * 
+       *   bs.words = Clazz.newArray(-1, bitsetToCopy.words, 0, bs.wordsInUse 
= wordCount);
+       * 
+       */
+      {
+        bs.words = new int[bs.wordsInUse = wordCount];
+        System.arraycopy(bitsetToCopy.words, 0, bs.words, 0, wordCount);
+      }
+
     }
     return bs;
   }
@@ -820,8 +842,8 @@
   @Override
   public String toJSON() {
 
-    int numBits = (wordsInUse > 128) ? cardinality() : wordsInUse
-        * BITS_PER_WORD;
+    int numBits = (wordsInUse > 128 ? cardinality() : wordsInUse
+        * BITS_PER_WORD);
     SB b = SB.newN(6 * numBits + 2);
     b.appendC('[');
 

Modified: branches/v14_4/Jmol/src/javajs/util/CompoundDocHeader.java
===================================================================
--- branches/v14_4/Jmol/src/javajs/util/CompoundDocHeader.java  2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/javajs/util/CompoundDocHeader.java  2015-12-20 
22:01:37 UTC (rev 20895)
@@ -77,10 +77,10 @@
   final boolean readData() {
     try {
       cd.readByteArray(magicNumbers, 0, 8);
-      if (magicNumbers[0] != (byte) 0xD0 || magicNumbers[1] != (byte) 0xCF
-          || magicNumbers[2] != (byte) 0x11 || magicNumbers[3] != (byte) 0xE0
-          || magicNumbers[4] != (byte) 0xA1 || magicNumbers[5] != (byte) 0xB1
-          || magicNumbers[6] != (byte) 0x1A || magicNumbers[7] != (byte) 0xE1)
+      if ((magicNumbers[0] & 0xFF) != 0xD0 || (magicNumbers[1] & 0xFF) != 0xCF
+          || (magicNumbers[2] & 0xFF) != 0x11 || (magicNumbers[3] & 0xFF) != 
0xE0
+          || (magicNumbers[4] & 0xFF) != 0xA1 || (magicNumbers[5] & 0xFF) != 
0xB1
+          || (magicNumbers[6] & 0xFF) != 0x1A || (magicNumbers[7] & 0xFF) != 
0xE1)
         return false;
       cd.readByteArray(uniqueID16, 0, 16);
       revNumber = cd.readByte();

Modified: branches/v14_4/Jmol/src/javajs/util/PT.java
===================================================================
--- branches/v14_4/Jmol/src/javajs/util/PT.java 2015-12-17 22:22:22 UTC (rev 
20894)
+++ branches/v14_4/Jmol/src/javajs/util/PT.java 2015-12-20 22:01:37 UTC (rev 
20895)
@@ -863,7 +863,7 @@
   }
 
   /**
-   * Checks to see if an object is an array, and if it is, returns null;
+   * Checks to see if an object is an array (including typed arrays), and if 
it is, returns null;
    * otherwise it returns the string equivalent of that object.
    * 
    * @param x
@@ -873,7 +873,7 @@
     /**
      * @j2sNative
      * 
-     * return (x.constructor == Array ? null : x.toString());
+     * return (x.constructor == Array || x.BYTES_PER_ELEMENT ? null : 
x.toString());
      * 
      */
     {

Modified: branches/v14_4/Jmol/src/javajs/util/Rdr.java
===================================================================
--- branches/v14_4/Jmol/src/javajs/util/Rdr.java        2015-12-17 22:22:22 UTC 
(rev 20894)
+++ branches/v14_4/Jmol/src/javajs/util/Rdr.java        2015-12-20 22:01:37 UTC 
(rev 20895)
@@ -96,17 +96,17 @@
   }
 
   private static Encoding getUTFEncoding(byte[] bytes) {
-    if (bytes.length >= 3 && bytes[0] == (byte) 0xEF && bytes[1] == (byte) 
0xBB && bytes[2] == (byte) 0xBF)
+    if (bytes.length >= 3 && (bytes[0] & 0xFF) == 0xEF && (bytes[1] & 0xFF) == 
0xBB && (bytes[2] & 0xFF) == 0xBF)
       return Encoding.UTF8;
-    if (bytes.length >= 4 && bytes[0] == (byte) 0 && bytes[1] == (byte) 0 
-        && bytes[2] == (byte) 0xFE && bytes[3] == (byte) 0xFF)
+    if (bytes.length >= 4 && (bytes[0] & 0xFF) == 0 && (bytes[1] & 0xFF) == 0 
+        && (bytes[2] & 0xFF) == 0xFE && (bytes[3] & 0xFF) == 0xFF)
       return Encoding.UTF_32BE;
-    if (bytes.length >= 4 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 
0xFE 
-        && bytes[2] == (byte) 0 && bytes[3] == (byte) 0)
+    if (bytes.length >= 4 && (bytes[0] & 0xFF) == 0xFF && (bytes[1] & 0xFF) == 
0xFE 
+        && (bytes[2] & 0xFF) == 0 && (bytes[3] & 0xFF) == 0)
       return Encoding.UTF_32LE;
-    if (bytes.length >= 2 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 
0xFE)
+    if (bytes.length >= 2 && (bytes[0] & 0xFF) == 0xFF && (bytes[1] & 0xFF) == 
0xFE)
       return Encoding.UTF_16LE;
-    if (bytes.length >= 2 && bytes[0] == (byte) 0xFE && bytes[1] == (byte) 
0xFF)
+    if (bytes.length >= 2 && (bytes[0] & 0xFF) == 0xFE && (bytes[1] & 0xFF) == 
0xFF)
       return Encoding.UTF_16BE;
     return Encoding.NONE;
   
@@ -145,11 +145,11 @@
   }
 
   public static boolean isCompoundDocumentB(byte[] bytes) {
-    return (bytes.length >= 8 && bytes[0] == (byte) 0xD0
-        && bytes[1] == (byte) 0xCF && bytes[2] == (byte) 0x11
-        && bytes[3] == (byte) 0xE0 && bytes[4] == (byte) 0xA1
-        && bytes[5] == (byte) 0xB1 && bytes[6] == (byte) 0x1A 
-        && bytes[7] == (byte) 0xE1);
+    return (bytes.length >= 8 && (bytes[0] & 0xFF) == 0xD0
+        && (bytes[1] & 0xFF) == 0xCF && (bytes[2] & 0xFF) == 0x11
+        && (bytes[3] & 0xFF) == 0xE0 && (bytes[4] & 0xFF) == 0xA1
+        && (bytes[5] & 0xFF) == 0xB1 && (bytes[6] & 0xFF) == 0x1A 
+        && (bytes[7] & 0xFF) == 0xE1);
   }
 
   public static boolean isGzipS(InputStream is) {
@@ -158,7 +158,7 @@
 
   public static boolean isGzipB(byte[] bytes) {    
       return (bytes != null && bytes.length >= 2 
-          && bytes[0] == (byte) 0x1F && bytes[1] == (byte) 0x8B);
+          && (bytes[0] & 0xFF) == 0x1F && (bytes[1] & 0xFF) == 0x8B);
   }
 
   public static boolean isPickleS(InputStream is) {
@@ -167,7 +167,7 @@
 
   public static boolean isPickleB(byte[] bytes) {    
       return (bytes != null && bytes.length >= 2 
-          && bytes[0] == (byte) 0x7D && bytes[1] == (byte) 0x71);
+          && (bytes[0] & 0xFF) == 0x7D && (bytes[1] & 0xFF) == 0x71);
   }
 
   public static boolean isPngZipStream(InputStream is) {

Modified: branches/v14_4/Jmol/src/org/jmol/applet/Jmol.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/applet/Jmol.java   2015-12-17 22:22:22 UTC 
(rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/applet/Jmol.java   2015-12-20 22:01:37 UTC 
(rev 20895)
@@ -24,26 +24,26 @@
 
 package org.jmol.applet;
 
-import org.jmol.awt.FileDropper;
-import org.jmol.c.CBK;
-import org.jmol.util.GenericApplet;
-import org.jmol.util.Logger;
-import org.jmol.util.Parser;
-
 import java.applet.Applet;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Graphics;
 import java.net.URL;
-import javajs.util.PT;
-
 import java.util.Hashtable;
 import java.util.Map;
 
+import javajs.util.PT;
+
 import javax.swing.UIManager;
 
 import netscape.javascript.JSObject;
 
+import org.jmol.awt.FileDropper;
+import org.jmol.c.CBK;
+import org.jmol.util.GenericApplet;
+import org.jmol.util.Logger;
+import org.jmol.util.Parser;
+
 /*
  * 
  * 

Modified: branches/v14_4/Jmol/src/org/jmol/appletjs/Jmol.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/appletjs/Jmol.java 2015-12-17 22:22:22 UTC 
(rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/appletjs/Jmol.java 2015-12-20 22:01:37 UTC 
(rev 20895)
@@ -24,22 +24,21 @@
 
 package org.jmol.appletjs;
 
-import org.jmol.util.Logger;
-import org.jmol.util.Parser;
-import org.jmol.util.GenericApplet;
-
 import java.net.URL;
+import java.util.Hashtable;
+import java.util.Map;
 
 import javajs.api.JSInterface;
 import javajs.util.PT;
 
-import java.util.Hashtable;
-import java.util.Map;
+import org.jmol.util.GenericApplet;
+import org.jmol.util.Logger;
+import org.jmol.util.Parser;
 
 /**
  * Java2Script rendition of Jmol using HTML5-only or WebGL-based graphics
  * 
- * @author Bob Hanson hans...@stolaf.edu, Takanori Nakane, with the assistance
+ * @author Bob Hanson hans...@stolaf.edu, Takanori Nakane, with the assistance 
 
  *         of Jhou Renjian
  * 
  */
@@ -128,7 +127,7 @@
             /**
              * @j2sNative
              * 
-             *            fxy[i][j] = eval(functionName)(this.htmlName, i, j);
+             *            fxy[i][j] = window.eval(functionName)(this.htmlName, 
i, j);
              */
             {
             }
@@ -138,7 +137,7 @@
         /**
          * @j2sNative
          * 
-         *            data = eval(functionName)(this.htmlName, nX, nY);
+         *            data = window.eval(functionName)(this.htmlName, nX, nY);
          * 
          */
         {
@@ -156,7 +155,7 @@
         /**
          * @j2sNative
          * 
-         *            data = eval(functionName)(this.htmlName, nX, nY, fxy);
+         *            data = window.eval(functionName)(this.htmlName, nX, nY, 
fxy);
          * 
          */
         {
@@ -182,7 +181,7 @@
       /**
        * @j2sNative
        * 
-       *            eval(functionName)(this.htmlName, nX, nY, nZ, fxyz);
+       *            window.eval(functionName)(this.htmlName, nX, nY, nZ, fxyz);
        * 
        */
       {
@@ -240,13 +239,17 @@
     return "";
   }
 
+  /**
+   * return RAW JAVASCRIPT OBJECT, NOT A STRING 
+   */
   @Override
   protected String doEval(String strEval) {
     try {
       /**
+       * 
        * @j2sNative
        * 
-       *            return "" + eval(strEval);
+       *            return window.eval(strEval);
        */
       {
       }

Modified: branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java     
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoFxyReader.java     
2015-12-20 22:01:37 UTC (rev 20895)
@@ -99,7 +99,7 @@
 
   @Override
   public float[] getPlane(int x) {
-    float[] plane = getPlane2(x);
+    float[] plane = getPlaneSR(x);
     setPlane(x, plane);
     return plane;
   }

Modified: branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java      
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java      
2015-12-20 22:01:37 UTC (rev 20895)
@@ -343,7 +343,7 @@
   public float[] getPlane(int x) {
     if (!qSetupDone) 
       setupCalculation();
-    return getPlane2(x); 
+    return getPlaneSR(x); 
   }
 
   private boolean qSetupDone;

Modified: branches/v14_4/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java    
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/jvxl/readers/SurfaceReader.java    
2015-12-20 22:01:37 UTC (rev 20895)
@@ -547,10 +547,10 @@
   
   @Override
   public float[] getPlane(int x) {
-    return getPlane2(x);
+    return getPlaneSR(x);
   }
 
-  protected float[] getPlane2(int x) {
+  protected float[] getPlaneSR(int x) {
     if (yzCount == 0)
       initPlanes();
     if (qpc != null)

Modified: branches/v14_4/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java 
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/jvxl/readers/VolumeFileReader.java 
2015-12-20 22:01:37 UTC (rev 20895)
@@ -327,9 +327,9 @@
       initPlanes();
     if (preProcessPlanes)
       return getPlaneProcessed(x);
-    float[] plane = getPlane2(x);
+    float[] plane = getPlaneSR(x);
     if (qpc == null)
-      getPlane(plane, true);
+      getPlaneVFR(plane, true);
     return plane;
   }
 
@@ -362,8 +362,8 @@
       qpc.setPlanes(yzPlanesRaw = new float[4][yzCount]);
       if (hasColorData) {
         //float nan = qpc.getNoValue();
-        getPlane(yzPlanesRaw[0], false);
-        getPlane(yzPlanesRaw[1], false);
+        getPlaneVFR(yzPlanesRaw[0], false);
+        getPlaneVFR(yzPlanesRaw[1], false);
         plane = yzPlanes[0];
         for (int i = 0; i < yzCount; i++)
           plane[i] = Float.NaN;
@@ -391,7 +391,7 @@
       plane = yzPlanesRaw[iPlaneRaw];
     }
     if (x < x1) {
-      getPlane(plane, false);
+      getPlaneVFR(plane, false);
       qpc.calcPlane(x, plane = yzPlanes[x % 2]);
       for (int i = 0; i < yzCount; i++)
         if (plane[i] != nan)
@@ -403,7 +403,7 @@
     return plane;
   }
 
-  private void getPlane(float[] plane, boolean doRecord) {
+  private void getPlaneVFR(float[] plane, boolean doRecord) {
     try {
       for (int y = 0, ptyz = 0; y < nPointsY; ++y) {
         for (int z = 0; z < nPointsZ; ++z) {

Modified: branches/v14_4/Jmol/src/org/jmol/modelset/Atom.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/modelset/Atom.java 2015-12-17 22:22:22 UTC 
(rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/modelset/Atom.java 2015-12-20 22:01:37 UTC 
(rev 20895)
@@ -441,7 +441,7 @@
 
   public void setValence(int nBonds) {
     if (!isDeleted()) // no resurrection
-      valence = (byte) (nBonds < 0 ? 0 : nBonds < 0xEF ? nBonds : 0xEF);
+      valence = (byte) (nBonds < 0 ? 0 : nBonds <= 0x7F ? nBonds : 0x7F);
   }
 
   /**

Modified: branches/v14_4/Jmol/src/org/jmol/script/SV.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/script/SV.java     2015-12-17 22:22:22 UTC 
(rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/script/SV.java     2015-12-20 22:01:37 UTC 
(rev 20895)
@@ -86,6 +86,13 @@
     return sv;
   }
   
+  public static SV newF(float f) {
+    SV sv = new SV();
+    sv.tok = decimal;
+    sv.value = Float.valueOf(f);
+    return sv;
+  }
+  
   public static SV newS(String s) {
     return newV(string, s);
   }
@@ -267,6 +274,7 @@
     if (x instanceof ScriptContext)
       return newV(context, x);
     // rest are specific array types supported
+    // DO NOT ADD MORE UNLESS YOU CHANGE isArray(), above
     if (Escape.isAV(x))
       return getVariableAV((SV[]) x);
     if (AU.isAI(x))
@@ -291,12 +299,53 @@
       return getVariableADD((double[][]) x);
     if (AU.isAFloat(x))
       return newV(listf, x);
-    return newS(x.toString());
+    return newJSVar(x);
   }
 
+  /**
+   * Conversion to Jmol variables of JavaScript variables using
+   * y = javascript("x")
+   * 
+   * @param x a JavaScript variable, perhaps
+   * @return SV
+   */
+  @SuppressWarnings("unused")
+  private static SV newJSVar(Object x) {
+    // JavaScript only
+    /**
+     * @j2sNative
+     * 
+     *            switch(x.BYTES_PER_ELEMENT ? Array : x.constructor) {
+     *            case Boolean:
+     *              return (x ? org.jmol.script.SV.vT : org.jmol.script.SV.vF);
+     *            case Number:
+     *              return (x > Integer.MAX_VALUE || x != Math.floor(x) ? 
org.jmol.script.SV.newF(x) : org.jmol.script.SV.newI(x));
+     *            case Array:
+     *              var v =  new javajs.util.Lst();
+     *              for (var i = 0, n = x.length; i < n; i++)
+     *                v.addLast(org.jmol.script.SV.newJSVar(x[i]));
+     *              return org.jmol.script.SV.getVariableList(v);
+     *            case Object: 
+     *              var keys = Object.keys(x);
+     *              var v =  new java.util.Hashtable();
+     *              for (var i = keys.length; --i >= 0;)
+     *                v.put(keys[i],org.jmol.script.SV.newJSVar(x[keys[i]]));
+     *              return org.jmol.script.SV.getVariableMap(v);
+     *            }
+     *            
+     */
+    {
+      // for reference only; not included in JavaScript
+      if (false) {
+        getVariableList(new Lst<SV>());
+        getVariableMap(new Hashtable<String, Object>());
+      }
+    }
+    return newS(x.toString());    
+  }
+
   @SuppressWarnings("unchecked")
-  public
-  static SV getVariableMap(Map<String, ?> x) {
+  public static SV getVariableMap(Map<String, ?> x) {
     Map<String, Object> ht = (Map<String, Object>) x;
     Object o = null;
     for (Object oo : ht.values()) {
@@ -1080,16 +1129,17 @@
       intValue = index = Integer.MAX_VALUE;
       break;
     case varray:
-      len = getList().size();
+      @SuppressWarnings("unchecked")
+      Lst<SV> v = (Lst<SV>) value;
+      len = v.size();
       if (pt1 <= 0)
         pt1 = len + pt1;
       if (--pt1 < 0)
         pt1 = 0;
-      if (len <= pt1) {
+      if (len <= pt1)
         for (int i = len; i <= pt1; i++)
-          getList().addLast(newV(string, ""));
-      }
-      getList().set(pt1, var);
+          v.addLast(newV(string, ""));
+      v.set(pt1, var);
       break;
     }
   }
@@ -1217,12 +1267,13 @@
         .indexOf(";" + format.toLowerCase() + ";"));
   }
 
- /**
-   * Accepts arguments from the format() function First argument is a
-   * format string.
+  /**
+   * Accepts arguments from the format() function First argument is a format
+   * string.
    * 
    * @param args
-   * @param pt 0: to JSON, 5: to base64, 12: to bytearray, 22: to array
+   * @param pt
+   *        0: to JSON, 5: to base64, 12: to bytearray, 22: to array
    * @return formatted string
    */
   public static Object format(SV[] args, int pt) {
@@ -1263,7 +1314,7 @@
           break;
         default:
           String s = args[1].asString();
-          if (s.startsWith(";base64,")){
+          if (s.startsWith(";base64,")) {
             if (pt == 5)
               return s;
             bytes = Base64.decodeBase64(s);
@@ -1271,8 +1322,8 @@
             bytes = s.getBytes();
           }
         }
-        return (pt == 22 ? getVariable(bytes) : pt == 12 ? new BArray(bytes) : 
";base64,"
-            + javajs.util.Base64.getBase64(bytes).toString());
+        return (pt == 22 ? getVariable(bytes) : pt == 12 ? new BArray(bytes)
+            : ";base64," + javajs.util.Base64.getBase64(bytes).toString());
       }
     }
     // use values to replace codes in format string
@@ -1283,9 +1334,8 @@
     sb.append(format[0]);
     for (int i = 1; i < format.length; i++) {
       Object ret = sprintf(PT.formatCheck("%" + format[i]),
-          (args[1].tok == hash ? args[1] 
-              : args[1].tok == varray ? args[1].getList().get(i - 1)
-                  : i < args.length ? args[i] :  null));
+          (args[1].tok == hash ? args[1] : args[1].tok == varray ? args[1]
+              .getList().get(i - 1) : i < args.length ? args[i] : null));
       if (AU.isAS(ret)) {
         String[] list = (String[]) ret;
         for (int j = 0; j < list.length; j++)
@@ -1450,12 +1500,23 @@
    * @return array
    */
   public SV pushPop(SV value, SV mapKey) {
-    if (mapKey != null  ) {
+    if (mapKey != null) {
       Map<String, SV> m = getMap();
       if (value == null) {
-        SV v;
-        return (m == null || (v = m.remove(mapKey.asString())) == null ? 
-            newS("") : v);
+        SV v = null;
+        if (m == null) {
+          Lst<SV> lst = getList();
+          int len = lst.size();
+          int i = iValue(mapKey) - 1;
+          if (i < 0)
+              i += len;
+          if (i >= 0 && i < len) {
+            v = lst.remove(i);
+          }
+        } else {
+          v = m.remove(mapKey.asString());
+        }
+        return (v == null ? newS("") : v);
       }
       if (m != null)
         m.put(mapKey.asString(), newI(0).setv(value));
@@ -1500,27 +1561,6 @@
     return list;
   }
 
-// I have no idea! 
-//
-//  static List<Object> listAny(SV x) {
-//    List<Object> list = new List<Object>();
-//    List<SV> l = x.getList();
-//    for (int i = 0; i < l.size(); i++) {
-//      SV v = l.get(i);
-//      List<SV> l2 = v.getList();
-//      if (l2 == null) {
-//        list.addLast(v.value);        
-//      } else {
-//        List<Object> o = new List<Object>();
-//        for (int j = 0; j < l2.size(); j++) {
-//          v = l2.get(j);
-//        }
-//        list.addLast(o);
-//      }
-//    }
-//    return list;    
-//  }
-  
   public static float[] flistValue(T x, int nMin) {
     if (x.tok != varray)
       return new float[] { fValue(x) };
@@ -1765,4 +1805,5 @@
         + (property instanceof SV ? PT.esc(key) + " : " + format(new SV[] { 
null, (SV) property },
             0) : PT.toJSON(key, property)) + "}";
   }
+
 }

Modified: branches/v14_4/Jmol/src/org/jmol/script/ScriptMathProcessor.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/script/ScriptMathProcessor.java    
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/script/ScriptMathProcessor.java    
2015-12-20 22:01:37 UTC (rev 20895)
@@ -274,7 +274,7 @@
   public boolean addXFloat(float x) {
     if (Float.isNaN(x))
       return addXStr("NaN");
-    putX(SV.newV(T.decimal, Float.valueOf(x)));
+    putX(SV.newF(x));
     return wasX = true;
   }
 
@@ -309,7 +309,7 @@
           float f = ((Float) x.value).floatValue();
           if (f < 0 || f == 0 && 1 / f == Float.NEGATIVE_INFINITY) {
             addOp(T.tokenMinus);
-            v = SV.newV(T.decimal, Float.valueOf(-f));
+            v = SV.newF(-f);
             break;
           }
         }

Modified: branches/v14_4/Jmol/src/org/jmol/scriptext/IsoExt.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/scriptext/IsoExt.java      2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/scriptext/IsoExt.java      2015-12-20 
22:01:37 UTC (rev 20895)
@@ -1131,6 +1131,7 @@
     boolean isPmesh = (iShape == JC.SHAPE_PMESH);
     boolean isPlot3d = (iShape == JC.SHAPE_PLOT3D);
     boolean isLcaoCartoon = (iShape == JC.SHAPE_LCAOCARTOON);
+    boolean isSilent = (isLcaoCartoon || tokAt(1) == T.delete);
     boolean surfaceObjectSeen = false;
     boolean planeSeen = false;
     boolean isMapped = false;
@@ -1191,6 +1192,10 @@
         str = paramAsStr(i);
       switch (eval.theTok) {
       // settings only
+      case T.silent:
+        isSilent = true;
+        sbCommand.append(" silent");
+        continue;
       case T.isosurfacepropertysmoothing:
         smoothing = (getToken(++i).tok == T.on ? Boolean.TRUE
             : eval.theTok == T.off ? Boolean.FALSE : null);
@@ -2738,7 +2743,7 @@
                 + Escape.eBS(bsSelect) + " ")
                 + cmd);
         s = (String) getShapeProperty(iShape, "ID");
-        if (s != null && !eval.tQuiet) {
+        if (s != null && !eval.tQuiet && !isSilent) {
           cutoff = ((Float) getShapeProperty(iShape, "cutoff")).floatValue();
           if (Float.isNaN(cutoff) && !Float.isNaN(sigma))
             Logger.error("sigma not supported");
@@ -2765,7 +2770,7 @@
             s += "\n" + svol;
         }
       }
-      if (s != null)
+      if (s != null && !isSilent)
         showString(s);
     }
     if (translucency != null)
@@ -2773,7 +2778,7 @@
     setShapeProperty(iShape, "clear", null);
     if (toCache)
       setShapeProperty(iShape, "cache", null);
-    if (iShape != JC.SHAPE_LCAOCARTOON && !isDisplay && !haveSlab)
+    if (!isSilent && !isDisplay && !haveSlab && eval.theTok != T.delete)
       listIsosurface(iShape);
   }
 
@@ -3540,7 +3545,7 @@
           + ret + "}", false);
       Lst<SV> params = new Lst<SV>();
       for (int i = 0; i < xyz.length(); i += 2)
-        params.addLast(SV.newV(T.decimal, Float.valueOf(0f)).setName(
+        params.addLast(SV.newF(0).setName(
             xyz.substring(i, i + 1)));
       return new Object[] { e.aatoken[0][1].value, params };
     } catch (Exception ex) {

Modified: branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java     2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/scriptext/MathExt.java     2015-12-20 
22:01:37 UTC (rev 20895)
@@ -389,8 +389,8 @@
         map.put("_bin", SV.newI(bin));
         float v1 = f0 + df * bin;
         float v2 = v1 + df;
-        map.put("_binMin", SV.newV(T.decimal,  Float.valueOf(bin == 0 ? 
-Float.MAX_VALUE : v1)));
-        map.put("_binMax", SV.newV(T.decimal,  Float.valueOf(bin == nbins - 1 
? Float.MAX_VALUE  : v2)));        
+        map.put("_binMin", SV.newF(bin == 0 ? -Float.MAX_VALUE : v1));
+        map.put("_binMax", SV.newF(bin == nbins - 1 ? Float.MAX_VALUE  : v2)); 
       
       }
     }
     return mp.addXAI(array);
@@ -726,9 +726,8 @@
      * 
      * 
      */
-
-    boolean isBondCount = (tok == T.bondcount);
-    if (args.length > 5 || isBondCount && args.length != 1)
+    
+    if (args.length > 5)
       return false;
     float min = Integer.MIN_VALUE, max = Integer.MAX_VALUE;
     float fmin = 0, fmax = Float.MAX_VALUE;
@@ -740,6 +739,9 @@
     boolean isBonds = false;
     switch (tok) {
     case T.polyhedra:
+      // polyhedra()
+      // polyhedra(3)
+      // polyhedra(smilesString)
       int nv = Integer.MIN_VALUE;
       String smiles = null;
       if (args.length > 0) {
@@ -756,6 +758,7 @@
       vwr.shm.getShapePropertyData(JC.SHAPE_POLYHEDRA, "centers", data);
       return mp.addXBs(data[2] == null ? new BS() : (BS) data[2]);
     case T.bondcount:
+      // {atoms1}.bondCount({atoms2})
       SV x1 = mp.getX();
       if (x1.tok != T.bitset || args.length != 1 || args[0].tok != T.bitset)
         return false;
@@ -773,6 +776,8 @@
       }
       return mp.addXList(list);
     }
+    
+    // connected(
     for (int i = 0; i < args.length; i++) {
       SV var = args[i];
       switch (var.tok) {
@@ -1434,7 +1439,7 @@
    * 
    * @param mp
    * @param args
-   * @param tok0 
+   * @param tok0
    * @param isAtomProperty
    * @return true if no syntax problems
    * @throws ScriptException
@@ -1451,7 +1456,9 @@
       return mp.addXObj(vwr.extractProperty(args[0].value,
           args[1].value.toString(), -1));
     }
-    String propertyName = (args.length > 0 ? SV.sValue(args[pt++]) : "");
+    BS bsSelect = (isAtomProperty && args.length == 1 && args[0].tok == 
T.bitset ? (BS) args[0].value : null);
+    String pname = (bsSelect == null && args.length > 0 ? 
SV.sValue(args[pt++]) : "");
+    String propertyName = pname;
     String lc = propertyName.toLowerCase();
     if (!isSelect && lc.indexOf("[select ") < 0)
       propertyName = lc;
@@ -1463,9 +1470,48 @@
     SV x = null;
     if (isAtomProperty) {
       x = mp.getX();
-      if (x.tok != T.bitset) {
+      switch (x.tok) {
+      case T.bitset:
+        break;
+      case T.string:
+        String name = (String) x.value;
+        Object[] data = new Object[3];
+        int shapeID;
+        if (name.startsWith("$")) {
+          // "$P4".getProperty....
+          name = name.substring(1);
+          shapeID = vwr.shm.getShapeIdFromObjectName(name);
+          if (shapeID >= 0) {
+            data[0] = name;
+            vwr.shm.getShapePropertyData(shapeID, "index", data);
+            if (data[1] != null && !pname.equals("index")) {
+              int index = ((Integer) data[1]).intValue();
+                data[1] = vwr.shm.getShapePropertyIndex(shapeID,
+                    pname.intern(), index);
+            }
+          }
+        } else {
+          shapeID = JC.shapeTokenIndex(T.getTokFromName(name));
+          if (shapeID >= 0) {
+            // "isosurface".getProperty...
+            data[0] = pname;
+            data[1] = Integer.valueOf(-1);
+            vwr.shm.getShapePropertyData(shapeID, pname.intern(), data);
+          }
+        }
+        return (data[1] == null ? mp.addXStr("") : mp.addXObj(data[1]));
+      case T.varray:
+        if (bsSelect != null) {
+          Lst<SV> l0 = x.getList();
+          Lst<SV> lst = new Lst<SV>();
+          for (int i = bsSelect.nextSetBit(0); i >= 0; i = 
bsSelect.nextSetBit(i + 1))
+            lst.addLast(l0.get(i));
+          return mp.addXList(lst);
+        }
+        //$FALL-THROUGH$
+      default:
         if (isSelect)
-          propertyName = "[SELECT " + propertyName + "]"; 
+          propertyName = "[SELECT " + propertyName + "]";
         return mp.addXObj(vwr.extractProperty(x, propertyName, -1));
       }
     }
@@ -1828,14 +1874,14 @@
       else if (Float.isNaN(list2[i]))
         b = SV.getVariable(SV.unescapePointOrBitsetAsVariable(sList2[i]));
       else
-        b = SV.newV(T.decimal, Float.valueOf(list2[i]));
+        b = SV.newF(list2[i]);
       if (!isScalar1) {
         if (isArray1)
           a = alist1.get(i);
         else if (Float.isNaN(list1[i]))
           a = SV.getVariable(SV.unescapePointOrBitsetAsVariable(sList1[i]));
         else
-          a = SV.newV(T.decimal, Float.valueOf(list1[i]));
+          a = SV.newF(list1[i]);
       }
       if (tok == T.join) {
         if (a.tok != T.varray) {
@@ -2289,7 +2335,7 @@
         }
         if (args[1].tok == T.on) {
           // this is TO screen coordinates, 0 at bottom left
-        vwr.tm.transformPt3f(pt3, pt3);
+          vwr.tm.transformPt3f(pt3, pt3);
           pt3.y = vwr.tm.height - pt3.y;
           if (vwr.antialiased)
             pt3.scale(0.5f);
@@ -2675,8 +2721,7 @@
       e.runScriptBuffer("show " + s, sb, true);
       break;
     case T.javascript:
-      sb.append(vwr.jsEval(s));
-      break;
+      return mp.addX(vwr.jsEvalSV(s));
     }
     s = sb.toString();
     float f;
@@ -3157,20 +3202,67 @@
     if (pt != null) {
       if (args[last].tok == T.varray) {
         // within(dist, pt, [pt1, pt2, pt3...])
-        Lst<SV> sv = args[2].getList();
+        Lst<SV> sv = args[last].getList();
         Lst<T3> pts = new Lst<T3>();
         Bspt bspt = new Bspt(3, 0);
-        for (int i = sv.size(); --i >= 0;) {
+        CubeIterator iter;
+        if (Float.isNaN(pt.x)) {
+          // internal comparison
+          Point3fi p;
+          Point3fi[] pt3 = new Point3fi[sv.size()];
+          for (int i = pt3.length; --i >= 0;) {
+            P3 p3 = SV.ptValue(sv.get(i));
+            if (p3 == null)
+              return false;
+            p = new Point3fi();
+            p.setT(p3);
+            p.i = i;
+            pt3[i] = p;
+            bspt.addTuple(p);
+          }
+          iter = bspt.allocateCubeIterator();
+          BS bsp = BSUtil.newBitSet2(0, sv.size());
+          for (int i = pt3.length; --i >= 0;) {
+            iter.initialize(p = pt3[i], distance, false);
+            float d2 = distance * distance;
+            int n = 0;
+            while (iter.hasMoreElements()) {
+              Point3fi pt2 = (Point3fi) iter.nextElement();
+              if (bsp.get(pt2.i) && pt2.distanceSquared(p) <= d2 && (++n > 1))
+                bsp.clear(pt2.i);
+            }
+          }
+          for (int i = bsp.nextSetBit(0); i >= 0; i = bsp.nextSetBit(i + 1))
+            pts.addLast(P3.newP(pt3[i]));
+          return mp.addXList(pts);
+
+        }
+        float d2;
+        if (distance == 0) {
+          // closest
+          P3 pt3 = null, pta;
+          d2 = Float.MAX_VALUE;
+          for (int i = sv.size(); --i >= 0;) {
+            pta = SV.ptValue(sv.get(i));
+            distance = pta.distanceSquared(pt);
+            if (distance < d2) {
+              pt3 = pta;
+              d2 = distance;
+            }
+          }
+          return (pt3 == null ? mp.addXStr("") : mp.addXPt(pt3));
+        }
+        for (int i = sv.size(); --i >= 0;)
           bspt.addTuple(SV.ptValue(sv.get(i)));
-        }
-        CubeIterator iter = bspt.allocateCubeIterator();
+        iter = bspt.allocateCubeIterator();
         iter.initialize(pt, distance, false);
-        float d2 = distance * distance;
+        d2 = distance * distance;
         while (iter.hasMoreElements()) {
           T3 pt2 = iter.nextElement();
           if (pt2.distanceSquared(pt) <= d2)
             pts.addLast(pt2);
         }
+        iter.release();
         return mp.addXList(pts);
       }
       return mp.addXBs(vwr.getAtomsNearPt(distance, pt));

Modified: branches/v14_4/Jmol/src/org/jmol/shape/AtomShape.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/shape/AtomShape.java       2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/shape/AtomShape.java       2015-12-20 
22:01:37 UTC (rev 20895)
@@ -141,6 +141,8 @@
       float[] sizes = (float[]) data[2];
       RadiusData rd = new RadiusData(null, 0, RadiusData.EnumType.FACTOR,
           VDW.AUTO);
+      if (bsColixSet == null)
+        bsColixSet = new BS();
       if (bsSizeSet == null)
         bsSizeSet = new BS();
       int i0 = bs.nextSetBit(0);
@@ -205,9 +207,9 @@
     if (colixes == null || n > colixes.length) {
       colixes = AU.ensureLengthShort(colixes, n);
       paletteIDs = AU.ensureLengthByte(paletteIDs, n);
-      if (bsColixSet == null)
-        bsColixSet = BS.newN(ac);
     }
+    if (bsColixSet == null)
+      bsColixSet = BS.newN(ac);
     return n;
   }
   

Modified: branches/v14_4/Jmol/src/org/jmol/util/GenericApplet.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/util/GenericApplet.java    2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/util/GenericApplet.java    2015-12-20 
22:01:37 UTC (rev 20895)
@@ -6,7 +6,6 @@
 import java.util.Hashtable;
 import java.util.Map;
 
-import javajs.awt.Dimension;
 import javajs.util.Lst;
 import javajs.util.PT;
 import javajs.util.SB;
@@ -73,7 +72,7 @@
   abstract protected String getJmolParameter(String name);
 
   // callback implementations
-  abstract protected String doEval(String strEval);
+  abstract protected String doEval(String strEval); // in JavaScript, this 
will be an Object, Number, String, etc.
 
   abstract protected float[][] doFunctionXY(String functionName, int nX, int 
nY);
 

Modified: branches/v14_4/Jmol/src/org/jmol/viewer/AnimationManager.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/viewer/AnimationManager.java       
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/viewer/AnimationManager.java       
2015-12-20 22:01:37 UTC (rev 20895)
@@ -430,30 +430,41 @@
   private int lastModelPainted;
   private int intAnimThread;
   public int cai = -1;
+
   private void setViewer(boolean clearBackgroundModel) {
     vwr.ms.setTrajectory(cmi);
     vwr.tm.setFrameOffset(cmi);
     if (cmi == -1 && clearBackgroundModel)
-      setBackgroundModelIndex(-1);  
+      setBackgroundModelIndex(-1);
     vwr.setTainted(true);
-    setFrameRangeVisible();
+    int nDisplay = setFrameRangeVisible();
     vwr.setStatusFrameChanged(false, false);
-    if (vwr.ms != null && !vwr.g.selectAllModels)
-        
vwr.slm.setSelectionSubset(vwr.ms.getModelAtomBitSetIncludingDeleted(cmi, 
true));
+    if (!vwr.g.selectAllModels)
+      setSelectAllSubset(nDisplay < 2);
   }
 
-  private void setFrameRangeVisible() {
+  void setSelectAllSubset(boolean justOne) {
+    if (vwr.ms != null)
+      vwr.slm.setSelectionSubset(justOne ? vwr.ms
+          .getModelAtomBitSetIncludingDeleted(cmi, true) : vwr.ms
+          .getModelAtomBitSetIncludingDeletedBs(bsVisibleModels));
+  }
+
+  private int setFrameRangeVisible() {
+    int nDisplayed = 0;
     bsVisibleModels.clearAll();
-    if (backgroundModelIndex >= 0)
+    if (backgroundModelIndex >= 0) {
       bsVisibleModels.set(backgroundModelIndex);
+      nDisplayed = 1;
+    }
     if (cmi >= 0) {
       bsVisibleModels.set(cmi);
-      return;
+      return ++nDisplayed;
     }
     if (frameStep == 0)
-      return;
-    int nDisplayed = 0;
+      return nDisplayed;
     int frameDisplayed = 0;
+    nDisplayed = 0;
     for (int iframe = firstFrameIndex; iframe != lastFrameIndex; iframe += 
frameStep) {
       int i = modelIndexForFrame(iframe); 
       if (!vwr.ms.isJmolDataFrameForModel(i)) {
@@ -472,6 +483,7 @@
     }
     if (nDisplayed == 1 && cmi < 0)
       setFrame(frameDisplayed);   
+    return nDisplayed;
   }
 
   private void animation(boolean TF) {

Modified: branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties     2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/viewer/Jmol.properties     2015-12-20 
22:01:37 UTC (rev 20895)
@@ -7,9 +7,12 @@
 
 # see also http://chemapps.stolaf.edu/jmol/zip for daily updates
        
-Jmol.___JmolVersion="14.5.1_2015.12.16"
+Jmol.___JmolVersion="14.4.1_2015.12.20"
 
+code: (JavaScript) adding use of array.slice and implementing Java byte[] as 
JavaScript Int8Array()
 bug fix: array handling for labels very inefficient
+bug fix: y = javascript("x") only creates string equivalent of x, not actual 
numerical/object values
+bug fix: y = javascript("x") draws "x" from wrapped anonymous function using 
eval() instead of global context using window.eval()
 
 JmolVersion="14.4.1_2015.12.15"
 

Modified: branches/v14_4/Jmol/src/org/jmol/viewer/SelectionManager.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/viewer/SelectionManager.java       
2015-12-17 22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/viewer/SelectionManager.java       
2015-12-20 22:01:37 UTC (rev 20895)
@@ -89,11 +89,15 @@
   }
 
   void display(ModelSet modelSet, BS bs, int addRemove, boolean isQuiet) {
-    BS bsNotSubset = (bsSubset == null ? null : 
BSUtil.andNot(BSUtil.copy(bsHidden), bsSubset));
     switch (addRemove) {
     default:
+      BS bsNotSubset = (bsSubset == null ? null : 
BSUtil.andNot(BSUtil.copy(bsHidden), bsSubset));
       BS bsAll = modelSet.getModelAtomBitSetIncludingDeleted(-1, false);
       bsHidden.or(bsAll);
+      if (bsNotSubset != null) {
+        bsHidden.and(bsSubset);
+        bsHidden.or(bsNotSubset);
+      }
       //$FALL-THROUGH$
     case T.add:
       if (bs != null)
@@ -104,10 +108,6 @@
         bsHidden.or(bs);
       break;
     }
-    if (bsNotSubset != null) {
-      bsHidden.and(bsSubset);
-      bsHidden.or(bsNotSubset);
-    }
     BSUtil.andNot(bsHidden, bsDeleted);
     modelSet.setBsHidden(bsHidden);
     if (!isQuiet)
@@ -115,7 +115,7 @@
   }
 
   void hide(ModelSet modelSet, BS bs, int addRemove, boolean isQuiet) {
-    BS bsNotSubset = (bsSubset == null ? null : 
BSUtil.andNot(BSUtil.copy(bsHidden), bsSubset));
+    BS bsNotSubset = (addRemove == 0 || bsSubset == null ? null : 
BSUtil.andNot(BSUtil.copy(bsHidden), bsSubset));
     setBitSet(bsHidden, bs, addRemove);
     if (bsNotSubset != null)
       bsHidden.or(bsNotSubset);

Modified: branches/v14_4/Jmol/src/org/jmol/viewer/StatusManager.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/viewer/StatusManager.java  2015-12-17 
22:22:22 UTC (rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/viewer/StatusManager.java  2015-12-20 
22:01:37 UTC (rev 20895)
@@ -692,6 +692,12 @@
       jsl.functionXYZ(functionName, nX, nY, nZ));
   }
   
+  /**
+   * 
+   * @param strEval
+   * @return in Java a String; in JavaScript window.eval() 
+   * 
+   */
   String jsEval(String strEval) {
     return (jsl == null ? "" : jsl.eval(strEval));
   }

Modified: branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java 2015-12-17 22:22:22 UTC 
(rev 20894)
+++ branches/v14_4/Jmol/src/org/jmol/viewer/Viewer.java 2015-12-20 22:01:37 UTC 
(rev 20895)
@@ -265,7 +265,7 @@
   String logFilePath = "";
 
   private boolean allowScripting;
-  public boolean isPrintOnly = false;
+  public boolean isPrintOnly;
   public boolean isSignedApplet = false;
   private boolean isSignedAppletLocal = false;
   private boolean isSilent;
@@ -1781,18 +1781,19 @@
     ligandModelSet.put(id, Boolean.TRUE);
     if (ligandModels == null)
       ligandModels = new Hashtable<String, Object>();
-    boolean isPng = (id.indexOf("|") > 0);
-    if (isPng)
+    int pngPt = id.indexOf("|");
+    if (pngPt >= 0)
       id = id.substring(id.indexOf("|") + 1);
     Object model = (terminator == null ? ligandModels.get(id) : null);
     String data;
     String fname = null;
     if (model instanceof Boolean)
       return null;
-    if (model == null && (terminator == null || isPng))
+    if (model == null && (terminator == null || pngPt >= 0))
       model = ligandModels.get(id + suffix);
     boolean isError = false;
-    if (model == null) {
+    boolean isNew = (model == null);
+    if (isNew) {
       String s;
       if (isLigand) {
         fname = (String) setLoadFormat("#" + id, '#', false);
@@ -1801,6 +1802,7 @@
         scriptEcho("fetching " + fname);
         s = getFileAsString3(fname, false, null);
       } else {
+        scriptEcho("fetching " + prefix);
         s = getFileAsString3(prefix, false, null);
         int pt = (terminator == null ? -1 : s.indexOf(terminator));
         if (pt >= 0)
@@ -1811,8 +1813,11 @@
       if (!isError)
         ligandModels.put(id + suffix, model);
     }
-    if (!isLigand)
+    if (!isLigand) {
+      if (!isNew)
+        scriptEcho(prefix + " loaded from cache");
       return model;
+    }
     // process ligand business
     
     if (!isError && model instanceof String) {
@@ -3725,6 +3730,7 @@
 
   @Override
   public String evalFile(String strFilename) {
+    // from JmolApp and test suite only
     return (allowScripting && getScriptManager() != null ? scm
         .evalFile(strFilename) : null);
   }
@@ -4635,9 +4641,13 @@
    */
 
   public String jsEval(String strEval) {
-    return sm.jsEval(strEval);
+    return "" + sm.jsEval(strEval);
   }
 
+  public SV jsEvalSV(String strEval) {
+    return SV.getVariable(isJS ? sm.jsEval(strEval) : jsEval(strEval));
+  }
+
   /*
    * loadStructCallback indicates file load status.
    * 
@@ -5740,7 +5750,7 @@
       break;
     default:
       if (!g.htNonbooleanParameterValues.containsKey(key.toLowerCase())) {
-        g.setUserVariable(key, SV.newV(T.decimal, Float.valueOf(value)));
+        g.setUserVariable(key, SV.newF(value));
         return;
       }
     }
@@ -6214,7 +6224,7 @@
       if (value)
         slm.setSelectionSubset(null);
       else
-        slm.setSelectionSubset(ms.getModelAtomBitSetIncludingDeleted(am.cmi, 
true));
+        am.setSelectAllSubset(false);
       break;
     case T.messagestylechime:
       // 11.5.39

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


------------------------------------------------------------------------------
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to