Revision: 20697
          http://sourceforge.net/p/jmol/code/20697
Author:   hansonr
Date:     2015-08-14 13:40:28 +0000 (Fri, 14 Aug 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.16_2015.08.14"

bug fix: label "3%"  reads "3null"
bug fix: {*}.label = ... resets offsets, fonts, and alignment

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java
    trunk/Jmol/src/org/jmol/modelset/LabelToken.java
    trunk/Jmol/src/org/jmol/modelset/Text.java
    trunk/Jmol/src/org/jmol/render/LabelsRenderer.java
    trunk/Jmol/src/org/jmol/script/ScriptExpr.java
    trunk/Jmol/src/org/jmol/scriptext/CmdExt.java
    trunk/Jmol/src/org/jmol/shape/Echo.java
    trunk/Jmol/src/org/jmol/shape/Hover.java
    trunk/Jmol/src/org/jmol/shape/Labels.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/ShapeManager.java
    trunk/Jmol/src/org/jmol/viewer/StateCreator.java

Modified: trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java       
2015-08-14 00:05:00 UTC (rev 20696)
+++ trunk/Jmol/src/org/jmol/adapter/readers/pymol/PyMOLScene.java       
2015-08-14 13:40:28 UTC (rev 20697)
@@ -1228,7 +1228,9 @@
     Font font = vwr.getFont3D(face, style, fontSize == 0 ? 12 : fontSize
         * factor);
     Text t = Text.newLabel(vwr, font, label, getColix(
-        colorIndex, 0), (short) 0, 0, 0, labelOffset);
+        colorIndex, 0), (short) 0, 0, 0);
+    if (t != null)
+      t.pymolOffset = labelOffset;
     return t;
   }
 

Modified: trunk/Jmol/src/org/jmol/modelset/LabelToken.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/LabelToken.java    2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/modelset/LabelToken.java    2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -358,8 +358,11 @@
   private static int setToken(Viewer vwr, String strFormat, LabelToken lt,
                               int cch, int chAtom, Map<String, Object> 
htValues) {
     int ich = lt.pt + 1;
-    if (ich >= cch)
+    // trailing % is OK
+    if (ich >= cch) {
+      lt.text = "%";
       return ich;
+    }
     char ch;
     if (strFormat.charAt(ich) == '-') {
       lt.alignLeft = true;

Modified: trunk/Jmol/src/org/jmol/modelset/Text.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Text.java  2015-08-14 00:05:00 UTC (rev 
20696)
+++ trunk/Jmol/src/org/jmol/modelset/Text.java  2015-08-14 13:40:28 UTC (rev 
20697)
@@ -81,10 +81,10 @@
   }
 
   static public Text newLabel(Viewer vwr, Font font, String text,
-                              short colix, short bgcolix, int align, float 
scalePixelsPerMicron, float[] value) {
+                              short colix, short bgcolix, int align, float 
scalePixelsPerMicron) {
     // for labels and hover
     Text t = new Text(vwr);
-    t.set(font, colix, align, true, scalePixelsPerMicron, value);
+    t.set(font, colix, align, true, scalePixelsPerMicron);
     t.setText(text);
     t.bgcolix = bgcolix;
     return t;
@@ -95,10 +95,8 @@
                       float scalePixelsPerMicron) {
     isEcho = true;
     Text t = new Text(vwr);
-    t.set(font, colix, align, false, scalePixelsPerMicron, null);
+    t.set(font, colix, align, false, scalePixelsPerMicron);
     t.target = target;
-    if (target.equals("error"))
-      valign = JC.ECHO_TOP;
     t.valign = valign;
     t.z = 2;
     t.zSlab = Integer.MIN_VALUE;
@@ -106,12 +104,11 @@
   }
 
   private void set(Font font, short colix, int align, boolean isLabelOrHover,
-                   float scalePixelsPerMicron, float[] value) {
+                   float scalePixelsPerMicron) {
     this.scalePixelsPerMicron = scalePixelsPerMicron;
     this.isLabelOrHover = isLabelOrHover;
     this.colix = colix;
     this.align = align;
-    this.pymolOffset = value;
     this.setFont(font, isLabelOrHover);
   }
 

Modified: trunk/Jmol/src/org/jmol/render/LabelsRenderer.java
===================================================================
--- trunk/Jmol/src/org/jmol/render/LabelsRenderer.java  2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/render/LabelsRenderer.java  2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -208,7 +208,7 @@
         return null;
       }
       text = Text.newLabel(vwr, font3d, label, labelColix, bgcolix, textAlign,
-          0, null);
+          0);
       text.atomX = atomPt.sX; // just for pointer
       text.atomY = atomPt.sY;
       text.atomZ = zSlab;

Modified: trunk/Jmol/src/org/jmol/script/ScriptExpr.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptExpr.java      2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/script/ScriptExpr.java      2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -2143,29 +2143,37 @@
         }
         break;
       case T.bitset:
+        bs = SV.getBitSet(t, true);
+        int nAtoms = vwr.ms.ac;
+        int nbs = bs.cardinality();
         propertyName = sel.asString();
-        boolean isprop = propertyName.startsWith("property_");
-        int tok = (isprop ? -1 : T.getTokFromName(propertyName));
-        if (tok == 0) {
+        int tok = T.getTokFromName(propertyName);
+        switch(tok) {
+        case T.nada:
+          if (propertyName.startsWith("property_")) {
+            Object obj = (tv.tok == T.varray ? SV.flistValue(tv, tv.getList()
+                .size() == nbs ? nbs : nAtoms) : tv.asString());
+            vwr.setData(
+                propertyName,
+                new Object[] { propertyName, obj, BSUtil.copy(bs),
+                    Integer.valueOf(JmolDataManager.DATA_TYPE_UNKNOWN) }, 
nAtoms,
+                0, 0, tv.tok == T.varray ? Integer.MAX_VALUE : 
Integer.MIN_VALUE,
+                0);
+            break;
+          }
           iToken = pt;
           error(ERROR_cannotSet);
-        }
-        bs = SV.getBitSet(t, true);
-        int nAtoms = vwr.ms.ac;
-        int nbs = bs.cardinality();
-        if (isprop) {
-          Object obj = (tv.tok == T.varray ? SV.flistValue(tv, tv.getList()
-              .size() == nbs ? nbs : nAtoms) : tv.asString());
-          vwr.setData(
-              propertyName,
-              new Object[] { propertyName, obj, BSUtil.copy(bs),
-                  Integer.valueOf(JmolDataManager.DATA_TYPE_UNKNOWN) }, nAtoms,
-              0, 0, tv.tok == T.varray ? Integer.MAX_VALUE : Integer.MIN_VALUE,
-              0);
           break;
+        case T.label:
+        case T.format:
+          vwr.shm.loadShape(JC.SHAPE_LABELS);
+          //$FALL-THROUGH$
+        default:
+          setBitsetProperty(bs, tok, tv.asInt(),
+              tv.asFloat(), tv);
+          break;
         }
-        setBitsetProperty(bs, tok, tv.asInt(),
-            tv.asFloat(), tv);
+        break;
       }
       if (selectOne)
         t.setSelectedValue(sel.intValue, Integer.MAX_VALUE, tv);

Modified: trunk/Jmol/src/org/jmol/scriptext/CmdExt.java
===================================================================
--- trunk/Jmol/src/org/jmol/scriptext/CmdExt.java       2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/scriptext/CmdExt.java       2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -1567,7 +1567,7 @@
       Text text = null;
       if (font != null)
         text = ((Text) Interface.getInterface("org.jmol.modelset.Text", vwr, 
"script")).newLabel(
-            vwr, font, "", colix, (short) 0, 0, 0, null);
+            vwr, font, "", colix, (short) 0, 0, 0);
       if (text != null)
         text.pymolOffset = offset;
       setShapeProperty(

Modified: trunk/Jmol/src/org/jmol/shape/Echo.java
===================================================================
--- trunk/Jmol/src/org/jmol/shape/Echo.java     2015-08-14 00:05:00 UTC (rev 
20696)
+++ trunk/Jmol/src/org/jmol/shape/Echo.java     2015-08-14 13:40:28 UTC (rev 
20697)
@@ -147,6 +147,8 @@
             halign = JC.TEXT_ALIGN_CENTER;
           } else if ("bottom" == target) {
             valign = JC.ECHO_BOTTOM;
+          } else if ("error" == target) {
+            valign = JC.ECHO_TOP;
           }
           text = Text.newEcho(vwr, vwr.gdata.getFont3DFS(FONTFACE,
               FONTSIZE), target, COLOR, valign, halign, 0);

Modified: trunk/Jmol/src/org/jmol/shape/Hover.java
===================================================================
--- trunk/Jmol/src/org/jmol/shape/Hover.java    2015-08-14 00:05:00 UTC (rev 
20696)
+++ trunk/Jmol/src/org/jmol/shape/Hover.java    2015-08-14 13:40:28 UTC (rev 
20697)
@@ -55,8 +55,7 @@
     Font font3d = vwr.gdata.getFont3DFSS(FONTFACE, FONTSTYLE, FONTSIZE);
     short bgcolix = C.getColixS("#FFFFC3"); // 255, 255, 195
     short colix = C.BLACK;
-    currentObject = hoverText = Text.newLabel(vwr, font3d, null, colix, 
bgcolix, JC.TEXT_ALIGN_LEFT, 0,
-        null);
+    currentObject = hoverText = Text.newLabel(vwr, font3d, null, colix, 
bgcolix, JC.TEXT_ALIGN_LEFT, 0);
     hoverText.adjustForWindow = true;
   }
 

Modified: trunk/Jmol/src/org/jmol/shape/Labels.java
===================================================================
--- trunk/Jmol/src/org/jmol/shape/Labels.java   2015-08-14 00:05:00 UTC (rev 
20696)
+++ trunk/Jmol/src/org/jmol/shape/Labels.java   2015-08-14 13:40:28 UTC (rev 
20697)
@@ -56,8 +56,6 @@
   public int[] offsets;
 
   private Map<Integer, Text> atomLabels = new Hashtable<Integer, Text>();
-  private Text text;
-
   private Map<Integer, float[]> labelBoxes;
 
   public BS bsFontSet;
@@ -123,10 +121,10 @@
           .nextSetBit(i + 1)) {
         if (strings.length <= i)
           continue;
-        text = getLabel(i);
+        Text text = getLabel(i);
         if (text == null) {
           text = Text.newLabel(vwr, null, strings[i], C.INHERIT_ALL, (short) 0,
-              0, scalePixelsPerMicron, null);
+              0, scalePixelsPerMicron);
           putLabel(i, text);
         } else {
           text.setScalePixelsPerMicron(scalePixelsPerMicron);
@@ -145,11 +143,11 @@
         for (int pt = 0, i = bsSelected.nextSetBit(0); i >= 0 && i < ac; i = 
bsSelected
             .nextSetBit(i + 1)) {
           if (pt >= n) {
-            setLabel(nullToken, "", i);
+            setLabel(nullToken, "", i, true);
             return;
           }
           tokens[0] = null;
-          setLabel(tokens, SV.sValue(list.get(pt++)), i);
+          setLabel(tokens, SV.sValue(list.get(pt++)), i, true);
         }
       } else {
         String strLabel = (String) value;
@@ -157,23 +155,24 @@
             : new LabelToken[][] { null });
         for (int i = bsSelected.nextSetBit(0); i >= 0 && i < ac; i = bsSelected
             .nextSetBit(i + 1))
-          setLabel(tokens, strLabel, i);
+          setLabel(tokens, strLabel, i, true);
       }
       return;
     }
 
-    if ("labels" == propertyName) {
-      setScaling();
-      Lst<String> labels = (Lst<String>) value;
-      for (int i = bsSelected.nextSetBit(0), pt = 0; i >= 0 && i < ac; i = 
bsSelected
-          .nextSetBit(i + 1)) {
-        String strLabel = labels.get(pt++);
-        LabelToken[][] tokens = (strLabel == null || strLabel.length() == 0 ? 
nullToken
-            : new LabelToken[][] { null });
-        setLabel(tokens, strLabel, i);
-      }
-      return;
-    }
+// see label:
+//    if ("labels" == propertyName) {
+//      setScaling();
+//      Lst<String> labels = (Lst<String>) value;
+//      for (int i = bsSelected.nextSetBit(0), pt = 0; i >= 0 && i < ac; i = 
bsSelected
+//          .nextSetBit(i + 1)) {
+//        String strLabel = labels.get(pt++);
+//        LabelToken[][] tokens = (strLabel == null || strLabel.length() == 0 
? nullToken
+//            : new LabelToken[][] { null });
+//        setLabel(tokens, strLabel, i, true);
+//      }
+//      return;
+//    }
 
     if ("clearBoxes" == propertyName) {
       labelBoxes = null;
@@ -204,15 +203,6 @@
     if (bsFontSet == null)
       bsFontSet = new BS();
 
-    if ("textLabels" == propertyName) {
-      setScaling();
-      Map<Integer, Text> labels = (Map<Integer, Text>) value;
-      for (int i = bsSelected.nextSetBit(0); i >= 0 && i < ac; i = bsSelected
-          .nextSetBit(i + 1))
-        setTextLabel(i, labels.get(Integer.valueOf(i)));
-      return;
-    }
-
     if ("fontsize" == propertyName) {
       int fontsize = ((Integer) value).intValue();
       if (fontsize < 0) {
@@ -363,12 +353,23 @@
     }
 
     if (propertyName.startsWith("label:")) {
+      // from @1.label = "xxx"
       setScaling();
       setLabel(new LabelToken[1][], propertyName.substring(6),
-          ((Integer) value).intValue());
+          ((Integer) value).intValue(), false);
       return;
     }
 
+    if ("textLabels" == propertyName) {
+      // from PyMOL reader
+      setScaling();
+      Map<Integer, Text> labels = (Map<Integer, Text>) value;
+      for (int i = bsSelected.nextSetBit(0); i >= 0 && i < ac; i = bsSelected
+          .nextSetBit(i + 1))
+        setTextLabel(i, labels.get(Integer.valueOf(i)));
+      return;
+    }
+
     if (propertyName == "deleteModelAtoms") {
       labelBoxes = null;
       int firstAtomDeleted = ((int[]) ((Object[]) value)[2])[1];
@@ -399,14 +400,14 @@
       byte fid = (bsFontSet != null && bsFontSet.get(i) ? fids[i] : -1);
       if (fid < 0)
         setFont(i, fid = defaultFontId);
-      Font font = Font.getFont3D(fid);
-      short colix = getColix2(i, atoms[i], false);
-      text = Text.newLabel(vwr, font, strings[i], colix, getColix2(i, 
atoms[i], true), 
-          0, scalePixelsPerMicron, value);
+      text = Text.newLabel(vwr, Font.getFont3D(fid), strings[i],
+          getColix2(i, atoms[i], false), getColix2(i, atoms[i], true), 0,
+          scalePixelsPerMicron);
       setTextLabel(i, text);
-    } else {
-      text.pymolOffset = value;
+      if (text == null)
+        return;
     }
+    text.pymolOffset = value;
   }
 
   private final static LabelToken[][] nullToken = new LabelToken[][] { null };
@@ -436,21 +437,23 @@
     putLabel(i, t);
   }
 
-  private void setLabel(LabelToken[][] temp, String strLabel, int i) {
+  private void setLabel(LabelToken[][] temp, String strLabel, int i, boolean 
doAll) {
     Atom atom = atoms[i];
     LabelToken[] tokens = temp[0];
     if (tokens == null)
       tokens = temp[0] = LabelToken.compile(vwr, strLabel, '\0', null);
     String label = (tokens == null ? null : LabelToken.formatLabelAtomArray(
         vwr, atom, tokens, '\0', null, ptTemp ));
-    addString(atom, i, label, strLabel);
-    text = getLabel(i);
-    if (isScaled) {
-      text = Text.newLabel(vwr, null, label, C.INHERIT_ALL, (short) 0, 0, 
scalePixelsPerMicron, null);
-      putLabel(i, text);
+    boolean isNew = addString(atom, i, label, strLabel); 
+    doAll |= isNew || label == null;
+    Text text = getLabel(i);
+    if (isScaled && doAll) {
+      putLabel(i, Text.newLabel(vwr, null, label, C.INHERIT_ALL, (short) 0, 0, 
scalePixelsPerMicron));
     } else if (text != null && label != null) {
       text.setText(label);
     }
+    if (!doAll)
+      return;
     if (defaultOffset != JC.LABEL_DEFAULT_OFFSET)
       setOffsets(i, defaultOffset);
     if (defaultAlignment != JC.TEXT_ALIGN_LEFT)
@@ -469,16 +472,19 @@
       setFont(i, defaultFontId);
   }
 
-  private void addString(Atom atom, int i, String label, String strLabel) {
+  private boolean addString(Atom atom, int i, String label, String strLabel) {
     setShapeVisibility(atom, label != null);
     if (strings == null || i >= strings.length)
       strings = AU.ensureLengthS(strings, i + 1);
     if (formats == null || i >= formats.length)
       formats = AU.ensureLengthS(formats, i + 1);
+    boolean notNull = (strLabel != null);
+    boolean isNew = (strings[i] == null);
     strings[i] = label;
-    formats[i] = (strLabel != null && strLabel.indexOf("%{") >= 0 ? label
-        : strLabel);
-    bsSizeSet.setBitTo(i, (strLabel != null));
+    // formats are put into state, but only if we are not pulling from DATA
+    formats[i] = (notNull && strLabel.indexOf("%{") >= 0 ? label : strLabel);
+    bsSizeSet.setBitTo(i, notNull);
+    return isNew;
   }
 
   @Override
@@ -517,6 +523,7 @@
   private void setLabelColix(int i, short colix, byte pid) {
     setColixAndPalette(colix, pid, i);
     // text is only created by labelsRenderer
+    Text text;
     if (colixes != null && ((text = getLabel(i)) != null))
       text.colix = colixes[i];
   }
@@ -529,7 +536,7 @@
     }
     bgcolixes[i] = bgcolix;
     bsBgColixSet.setBitTo(i, bgcolix != 0);
-    text = getLabel(i);
+    Text text = getLabel(i);
     if (text != null)
       text.bgcolix = bgcolix;
   }
@@ -545,7 +552,7 @@
       offset = JC.LABEL_DEFAULT_OFFSET;
     offsets[i] = (offsets[i] & JC.LABEL_FLAGS) | offset;
 
-    text = getLabel(i);
+    Text text = getLabel(i);
     if (text != null)
       text.setOffset(offset);
   }
@@ -557,7 +564,7 @@
       offsets = AU.ensureLengthI(offsets, i + 1);
     }
     offsets[i] = JC.setHorizAlignment(offsets[i], hAlign);
-    text = getLabel(i);
+    Text text = getLabel(i);
     if (text != null)
       text.setAlignment(hAlign);
   }
@@ -569,7 +576,7 @@
       offsets = AU.ensureLengthI(offsets, i + 1);
     }
     offsets[i] = JC.setPointer(offsets[i], pointer);
-    text = getLabel(i);
+    Text text = getLabel(i);
     if (text != null)
       text.pointer = pointer;
   }
@@ -591,7 +598,7 @@
     }
     fids[i] = fid;
     bsFontSet.set(i);
-    text = getLabel(i);
+    Text text = getLabel(i);
     if (text != null) {
       text.setFontFromFid(fid);
     }

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -57,8 +57,13 @@
 that still places it in the "proper" place even when perspective is on. 
(Daniele Tomerini)
 
 
-Jmol.___JmolVersion="14.3.16_2015.08.13"
+Jmol.___JmolVersion="14.3.16_2015.08.14"
 
+bug fix: label "3%"  reads "3null"
+bug fix: {*}.label = ... resets offsets, fonts, and alignment
+
+JmolVersion="14.3.16_2015.08.13"
+
 released
 
 JmolVersion="14.3.16_2015.08.12"

Modified: trunk/Jmol/src/org/jmol/viewer/ShapeManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java    2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/viewer/ShapeManager.java    2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -348,10 +348,8 @@
   }
 
   public void setAtomLabel(String strLabel, int i) {
-    if (shapes == null)
-      return;
-    loadShape(JC.SHAPE_LABELS);
-    shapes[JC.SHAPE_LABELS].setProperty("label:"+strLabel, Integer.valueOf(i), 
null);
+    if (shapes != null)
+      shapes[JC.SHAPE_LABELS].setProperty("label:"+strLabel, 
Integer.valueOf(i), null);
   }
   
   /**

Modified: trunk/Jmol/src/org/jmol/viewer/StateCreator.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2015-08-14 00:05:00 UTC 
(rev 20696)
+++ trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2015-08-14 13:40:28 UTC 
(rev 20697)
@@ -1188,14 +1188,14 @@
       for (int i = l.bsSizeSet.nextSetBit(0); i >= 0; i = l.bsSizeSet
           .nextSetBit(i + 1)) {
         Text t = l.getLabel(i);
-        String cmd = null;
-        if (t != null) {
-          cmd = "label " + PT.esc(t.textUnformatted);
+        String cmd = "label ";
+        if (t == null) {
+          cmd += PT.esc(l.formats[i]);
+        } else {
+          cmd += PT.esc(t.textUnformatted);
           if (t.pymolOffset != null)
             cmd += ";set labelOffset " + Escape.eAF(t.pymolOffset);
         }
-        if (cmd == null)
-          cmd = "label " + PT.esc(l.formats[i]);
         BSUtil.setMapBitSet(temp, i, i, cmd);
         if (l.bsColixSet != null && l.bsColixSet.get(i))
           BSUtil.setMapBitSet(temp2, i, i, Shape.getColorCommand("label",

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