Revision: 20553
          http://sourceforge.net/p/jmol/code/20553
Author:   hansonr
Date:     2015-06-06 17:03:31 +0000 (Sat, 06 Jun 2015)
Log Message:
-----------
Jmol.___JmolVersion="14.3.14_2015.06.05"

new feature: set labelOffsetAbsolute x y  
 -- was undocumented as "set labelOffsetExact" but used in state (still 
available)
 -- sets label to specific value; same as set labelOffset, but allows 0 in x or 
y
 
bug fix: dragging labels not working properly
bug fix: axisangle not resetting angle to 0 --> wrong default orientation saved 
to state after RESET (broken in 14.1.6_dev_2014.01.16c)

Modified Paths:
--------------
    trunk/Jmol/src/javajs/util/A4.java
    trunk/Jmol/src/org/jmol/modelset/Object2d.java
    trunk/Jmol/src/org/jmol/modelset/Text.java
    trunk/Jmol/src/org/jmol/render/LabelsRenderer.java
    trunk/Jmol/src/org/jmol/render/TextRenderer.java
    trunk/Jmol/src/org/jmol/script/ScriptEval.java
    trunk/Jmol/src/org/jmol/shape/Labels.java
    trunk/Jmol/src/org/jmol/viewer/ActionManager.java
    trunk/Jmol/src/org/jmol/viewer/JC.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/StateCreator.java
    trunk/Jmol/src/org/jmol/viewer/Viewer.java

Modified: trunk/Jmol/src/javajs/util/A4.java
===================================================================
--- trunk/Jmol/src/javajs/util/A4.java  2015-06-05 23:16:38 UTC (rev 20552)
+++ trunk/Jmol/src/javajs/util/A4.java  2015-06-06 17:03:31 UTC (rev 20553)
@@ -193,6 +193,7 @@
     if (sin == 0 && cos == 1) {
       x = y = 0;
       z = 1;
+      angle = 0;
     } else {
       angle = (float) Math.atan2(sin, cos);
     }

Modified: trunk/Jmol/src/org/jmol/modelset/Object2d.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Object2d.java      2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/modelset/Object2d.java      2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -21,13 +21,11 @@
   public int align;
   public int valign;
   public int atomX, atomY, atomZ = Integer.MAX_VALUE;
-  public int movableX, movableY, movableZ;
-  public int movableXPercent = Integer.MAX_VALUE;
-  public int movableYPercent = Integer.MAX_VALUE;
-  public int movableZPercent = Integer.MAX_VALUE;
+  public int movableX, movableY, movableZ; // Echo only
+  public int movableXPercent = Integer.MAX_VALUE; // Echo only
+  public int movableYPercent = Integer.MAX_VALUE; // Echo only
+  public int movableZPercent = Integer.MAX_VALUE; // Echo only
 
-  protected int offsetX;
-  protected int offsetY;
   public int z = 1; // front plane
   public int zSlab = Integer.MIN_VALUE; // z for slabbing purposes -- may be 
near an atom
 
@@ -130,14 +128,6 @@
     this.script = (script == null || script.length() == 0 ? null : script);
   }
 
-  public void setOffset(int offset) {
-    //Labels only
-    offsetX = JC.getXOffset(offset);
-    offsetY = JC.getYOffset(offset);
-    pymolOffset = null;
-    valign = JC.VALIGN_XY;
-  }
-
   public boolean setAlignmentLCR(String align) {
     if ("left".equals(align))
       return setAlignment(JC.ALIGN_LEFT);

Modified: trunk/Jmol/src/org/jmol/modelset/Text.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/Text.java  2015-06-05 23:16:38 UTC (rev 
20552)
+++ trunk/Jmol/src/org/jmol/modelset/Text.java  2015-06-06 17:03:31 UTC (rev 
20553)
@@ -49,6 +49,9 @@
   public int descent;
   private int lineHeight;
 
+  protected int offsetX; // Labels only
+  protected int offsetY; // Labels only
+
   private int textWidth;
   private int textHeight;
   private String text;
@@ -56,6 +59,14 @@
     return text;
   }
 
+  public void setOffset(int offset) {
+    //Labels only
+    offsetX = JC.getXOffset(offset);
+    offsetY = JC.getYOffset(offset);
+    pymolOffset = null;
+    valign = JC.VALIGN_XY;
+  }
+
   private int[] widths;
 
   private Viewer vwr;
@@ -211,7 +222,7 @@
 
 
   public void setPosition(float scalePixelsPerMicron, float imageFontScaling,
-                          boolean isExact, float[] boxXY) {
+                          boolean isAbsolute, float[] boxXY) {
     if (boxXY == null)
       boxXY = this.boxXY;
     else
@@ -265,12 +276,12 @@
         boxXY[0] = movableX - xAdj;
         boxXY[1] = movableY - yAdj;
         y0 = movableY - dy - descent;        
-        isExact = true;
+        isAbsolute = true;
         boxYoff2 = -2; // empirica fudge factor 
       } else {
         boxYoff2 = 0;
       }
-      setBoxXY(boxWidth, boxHeight, dx, dy, boxXY, isExact);
+      setBoxXY(boxWidth, boxHeight, dx, dy, boxXY, isAbsolute);
     } else {
       setPos(fontScale);
     }
@@ -282,7 +293,7 @@
     if (adjustForWindow)
       setBoxOffsetsInWindow(/*image == null ? fontScale * 5 :*/0,
           isLabelOrHover ? 16 * fontScale + lineHeight : 0, boxY - textHeight);
-    if (!isExact)
+    //if (!isAbsolute)
       y0 = boxY + yAdj;
   }
 
@@ -345,11 +356,11 @@
   }
 
   public static void setBoxXY(float boxWidth, float boxHeight, float xOffset,
-                               float yOffset, float[] boxXY, boolean isExact) {
+                               float yOffset, float[] boxXY, boolean 
isAbsolute) {
     float xBoxOffset, yBoxOffset;
 
     // these are based on a standard |_ grid, so y is reversed.
-    if (xOffset > 0 || isExact) {
+    if (xOffset > 0 || isAbsolute) {
       xBoxOffset = xOffset;
     } else {
       xBoxOffset = -boxWidth;
@@ -358,14 +369,12 @@
       else
         xBoxOffset += xOffset;
     }
-    if (isExact) {
-      yBoxOffset = -yOffset;
-    } else if (yOffset < 0) {
-      yBoxOffset = -boxHeight + yOffset;
+    if (isAbsolute || yOffset > 0) {
+      yBoxOffset = -boxHeight - yOffset;
     } else if (yOffset == 0) {
       yBoxOffset = -boxHeight / 2; // - 2; removed in Jmol 11.7.45 06/24/2009
     } else {
-      yBoxOffset = yOffset;
+      yBoxOffset = -yOffset;
     }
     boxXY[0] += xBoxOffset;
     boxXY[1] += yBoxOffset;

Modified: trunk/Jmol/src/org/jmol/render/LabelsRenderer.java
===================================================================
--- trunk/Jmol/src/org/jmol/render/LabelsRenderer.java  2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/render/LabelsRenderer.java  2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -59,7 +59,7 @@
   private Atom atom;
   protected Point3fi atomPt;
 
-  private boolean isExact;
+  private boolean isAbsolute;
 
   private int offset;
 
@@ -113,13 +113,13 @@
         labelColix = backgroundColixContrast;
       fid = ((fids == null || i >= fids.length || fids[i] == 0) ? 
labels.zeroFontId
           : fids[i]);
-      int offsetFull = (offsets == null || i >= offsets.length ? 0 : 
offsets[i]);
-      boolean labelsFront = ((offsetFull & JC.LABEL_FRONT_FLAG) != 0);
-      boolean labelsGroup = ((offsetFull & JC.LABEL_GROUP_FLAG) != 0);
-      isExact = ((offsetFull & JC.LABEL_EXACT_OFFSET_FLAG) != 0);
-      offset = offsetFull >> JC.LABEL_FLAG_OFFSET;
-      textAlign = Labels.getAlignment(offsetFull);
-      pointer = offsetFull & JC.LABEL_POINTER_FLAGS;
+      offset = (offsets == null || i >= offsets.length ? 0: offsets[i]);
+      boolean labelsFront = ((offset & JC.LABEL_FRONT_FLAG) != 0);
+      boolean labelsGroup = ((offset & JC.LABEL_GROUP_FLAG) != 0);
+      textAlign = Labels.getAlignment(offset);
+      isAbsolute = JC.isOffsetExplicit(offset);
+      
+      pointer = offset & JC.LABEL_POINTER_FLAGS;
       zSlab = atom.sZ - atom.sD / 2 - 3;
       if (zSlab > zCutoff)
         continue;
@@ -178,7 +178,8 @@
           pTemp.setT(atomPt);
         else
           pTemp.set(0, 0, 0);
-        pTemp.add3(text.pymolOffset[4], text.pymolOffset[5], 
text.pymolOffset[6]);
+        pTemp.add3(text.pymolOffset[4], text.pymolOffset[5],
+            text.pymolOffset[6]);
         tm.transformPtScr(pTemp, screen);
         text.setXYZs(screen.x, screen.y, screen.z, zSlab);
         text.setScalePixelsPerMicron(sppm);
@@ -196,7 +197,8 @@
       }
       boolean isSimple = isLeft
           && (imageFontScaling == 1 && scalePixelsPerMicron == 0
-              && label.indexOf("|") < 0 && label.indexOf("<su") < 0 && 
label.indexOf("<co") < 0);
+              && label.indexOf("|") < 0 && label.indexOf("<su") < 0 && label
+              .indexOf("<co") < 0);
       if (isSimple) {
         boolean doPointer = ((pointer & JC.POINTER_ON) != 0);
         short pointerColix = ((pointer & JC.POINTER_BACKGROUND) != 0
@@ -204,30 +206,26 @@
         boxXY[0] = atomPt.sX;
         boxXY[1] = atomPt.sY;
         TextRenderer.renderSimpleLabel(g3d, font3d, label, labelColix, bgcolix,
-            boxXY, zBox, zSlab, JC.getXOffset(offset), JC
-                .getYOffset(offset), ascent, descent, doPointer, pointerColix,
-            isExact);
-        atomPt = null;
-      } else {
-        text = Text.newLabel(vwr, font3d, label, labelColix,
-            bgcolix, textAlign, 0, null);
-        text.atomX = atomPt.sX; // just for pointer
-        text.atomY = atomPt.sY;
-        text.atomZ = zSlab;
-        text.setXYZs(atomPt.sX, atomPt.sY, zBox, zSlab);
-        newText = true;
+            boxXY, zBox, zSlab, JC.getXOffset(offset), JC.getYOffset(offset),
+            ascent, descent, doPointer, pointerColix, isAbsolute);
+        return null;
       }
+      text = Text.newLabel(vwr, font3d, label, labelColix, bgcolix, textAlign,
+          0, null);
+      text.atomX = atomPt.sX; // just for pointer
+      text.atomY = atomPt.sY;
+      text.atomZ = zSlab;
+      text.setXYZs(atomPt.sX, atomPt.sY, zBox, zSlab);
+      newText = true;
     }
-    if (atomPt != null) {
-      if (text.pymolOffset == null) {
-        text.setOffset(offset);
-        if (textAlign != JC.ALIGN_NONE)
-          text.setAlignment(textAlign);
-      }
-      text.pointer = pointer;
-      TextRenderer.render(text, g3d, scalePixelsPerMicron,
-          imageFontScaling, isExact, boxXY, xy);
+    if (text.pymolOffset == null) {
+      text.setOffset(offset);
+      if (textAlign != JC.ALIGN_NONE)
+        text.setAlignment(textAlign);
     }
+    text.pointer = pointer;
+    TextRenderer.render(text, g3d, scalePixelsPerMicron, imageFontScaling,
+        isAbsolute, boxXY, xy);
     return (newText ? text : null);
   }
 }

Modified: trunk/Jmol/src/org/jmol/render/TextRenderer.java
===================================================================
--- trunk/Jmol/src/org/jmol/render/TextRenderer.java    2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/render/TextRenderer.java    2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -35,7 +35,7 @@
   
   static void render(Text text, JmolRendererInterface g3d,
                      float scalePixelsPerMicron, float imageFontScaling,
-                     boolean isExact, float[] boxXY, float[] temp) {
+                     boolean isAbsolute, float[] boxXY, float[] temp) {
     if (text == null || text.image == null && !text.doFormatText && text.lines 
== null)
       return;
     boolean showText = g3d.setC(text.colix);
@@ -43,7 +43,7 @@
         && (text.image == null && (text.bgcolix == 0 || !g3d
             .setC(text.bgcolix))))
       return;
-    text.setPosition(scalePixelsPerMicron, imageFontScaling, isExact, boxXY);
+    text.setPosition(scalePixelsPerMicron, imageFontScaling, isAbsolute, 
boxXY);
     // draw the box if necessary; colix has been set
     if (text.image == null && text.bgcolix != 0) {
       if (g3d.setC(text.bgcolix))
@@ -97,7 +97,7 @@
                                  float[] boxXY, int z, int zSlab,
                                  int xOffset, int yOffset, float ascent,
                                  int descent, boolean doPointer,
-                                 short pointerColix, boolean isExact) {
+                                 short pointerColix, boolean isAbsolute) {
 
     // old static style -- quick, simple, no line breaks, odd alignment?
     // LabelsRenderer only
@@ -108,7 +108,7 @@
     int x0 = (int) boxXY[0];
     int y0 = (int) boxXY[1];
     
-    Text.setBoxXY(boxWidth, boxHeight, xOffset, yOffset, boxXY, isExact);
+    Text.setBoxXY(boxWidth, boxHeight, xOffset, yOffset, boxXY, isAbsolute);
 
     float x = boxXY[0];
     float y = boxXY[1];

Modified: trunk/Jmol/src/org/jmol/script/ScriptEval.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/script/ScriptEval.java      2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -6926,7 +6926,7 @@
       if (lckey.indexOf("label") == 0
           && PT
               .isOneOf(lckey.substring(5),
-                  
";front;group;atom;offset;offsetexact;pointer;alignment;toggle;scalereference;"))
 {
+                  
";front;group;atom;offset;offsetexact;offsetabsolute;pointer;alignment;toggle;scalereference;"))
 {
         if (cmdSetLabel(lckey.substring(5)))
           return;
       }
@@ -7161,7 +7161,9 @@
         propertyValue = Float.valueOf(scaleAngstromsPerPixel);
         break;
       }
-      if (str.equals("offset") || str.equals("offsetexact")) {
+      boolean isAbsolute = false;
+      if (str.equals("offset") || (isAbsolute = (str.equals("offsetabsolute") 
|| str.equals("offsetexact")))) {
+        str = "offset";
         if (isPoint3f(2)) {
           // PyMOL offsets -- {x, y, z} in angstroms
           P3 pt = getPoint3f(2, false);
@@ -7170,11 +7172,11 @@
           // PyMOL offsets -- [1, scrx, scry, scrz, molx, moly, molz] in 
angstroms
           propertyValue = floatParameterSet(2, 7, 7);
         } else {
-          int xOffset = intParameterRange(2, -127, 127);
-          int yOffset = intParameterRange(3, -127, 127);
+          int xOffset = intParameterRange(2, -JC.LABEL_OFFSET_MAX, 
JC.LABEL_OFFSET_MAX);
+          int yOffset = intParameterRange(3, -JC.LABEL_OFFSET_MAX, 
JC.LABEL_OFFSET_MAX);
           if (xOffset == Integer.MAX_VALUE || yOffset == Integer.MAX_VALUE)
             return true;
-          propertyValue = Integer.valueOf(JC.getOffset(xOffset, yOffset));
+          propertyValue = Integer.valueOf(JC.getOffset(xOffset, yOffset, 
isAbsolute));
         }
         break;
       }

Modified: trunk/Jmol/src/org/jmol/shape/Labels.java
===================================================================
--- trunk/Jmol/src/org/jmol/shape/Labels.java   2015-06-05 23:16:38 UTC (rev 
20552)
+++ trunk/Jmol/src/org/jmol/shape/Labels.java   2015-06-06 17:03:31 UTC (rev 
20553)
@@ -71,9 +71,6 @@
   public short defaultBgcolix;
   public byte defaultPaletteID;
   public int defaultPointer;
-  public static int zeroOffset = (JC.LABEL_DEFAULT_X_OFFSET << 8)
-      | JC.LABEL_DEFAULT_Y_OFFSET;
-
   public byte zeroFontId;
 
   private boolean defaultsOnlyForNone = true;
@@ -88,7 +85,7 @@
         JC.DEFAULT_FONTSTYLE, JC.LABEL_DEFAULT_FONTSIZE).fid;
     defaultColix = 0; //"none" -- inherit from atom
     defaultBgcolix = 0; //"none" -- off
-    defaultOffset = zeroOffset;
+    defaultOffset = JC.LABEL_DEFAULT_OFFSET;
     defaultZPos = 0;
     translucentAllowed = false;
   }
@@ -130,8 +127,8 @@
           continue;
         text = getLabel(i);
         if (text == null) {
-          text = Text.newLabel(vwr, null, strings[i], C.INHERIT_ALL,
-              (short) 0, 0, scalePixelsPerMicron, null);
+          text = Text.newLabel(vwr, null, strings[i], C.INHERIT_ALL, (short) 0,
+              0, scalePixelsPerMicron, null);
           putLabel(i, text);
         } else {
           text.setScalePixelsPerMicron(scalePixelsPerMicron);
@@ -245,7 +242,7 @@
       return;
     }
 
-    if ("offset" == propertyName || "offsetexact" == propertyName) {
+    if ("offset" == propertyName) {
       if (!(value instanceof Integer)) {
         if (!setDefaults)
           for (int i = bsSelected.nextSetBit(0); i >= 0 && i < ac; i = 
bsSelected
@@ -255,19 +252,10 @@
       }
 
       int offset = ((Integer) value).intValue();
-      // 0 must be the default, because we initialize the array
-      // in segments and so there will be extra 0s.
-      // but this "0" only means that "zero" offset; you 
-      // can change the default to anything you want.
-      boolean isExact = (propertyName == "offsetexact");
-      if (offset == 0)
-        offset = Short.MAX_VALUE;
-      else if (offset == zeroOffset)
-        offset = 0;
       if (!setDefaults)
         for (int i = bsSelected.nextSetBit(0); i >= 0 && i < ac; i = bsSelected
             .nextSetBit(i + 1))
-          setOffsets(i, offset, isExact);
+          setOffsets(i, offset);
       if (setDefaults || !defaultsOnlyForNone)
         defaultOffset = offset;
       return;
@@ -359,8 +347,8 @@
             strLabel = strLabelPDB;
             tokens = tokensPDB;
           }
-          strings[i] = LabelToken.formatLabelAtomArray(vwr, atom, tokens,
-              '\0', null, ptTemp);
+          strings[i] = LabelToken.formatLabelAtomArray(vwr, atom, tokens, '\0',
+              null, ptTemp);
           formats[i] = strLabel;
           bsSizeSet.set(i);
           if ((bsBgColixSet == null || !bsBgColixSet.get(i))
@@ -368,8 +356,8 @@
             setBgcolix(i, defaultBgcolix);
           mads[i] = (short) (mode >= 0 ? 1 : -1);
         }
-        setShapeVisibility(atom, strings != null
-            && i < strings.length && strings[i] != null && mads[i] >= 0);
+        setShapeVisibility(atom, strings != null && i < strings.length
+            && strings[i] != null && mads[i] >= 0);
         //        } else if (strings != null && atomIndex < strings.length) {
         //        strings[atomIndex] = null;          
       }
@@ -465,8 +453,8 @@
     } else if (text != null && label != null) {
       text.setText(label);
     }
-    if (defaultOffset != zeroOffset)
-      setOffsets(i, defaultOffset, false);
+    if (defaultOffset != JC.LABEL_DEFAULT_OFFSET)
+      setOffsets(i, defaultOffset);
     if (defaultAlignment != JC.ALIGN_LEFT)
       setAlignment(i, defaultAlignment);
     if ((defaultZPos & JC.LABEL_FRONT_FLAG) != 0)
@@ -548,15 +536,15 @@
       text.bgcolix = bgcolix;
   }
 
-  private void setOffsets(int i, int offset, boolean isExact) {
+  private void setOffsets(int i, int offset) {
+    
     if (offsets == null || i >= offsets.length) {
       if (offset == 0)
         return;
       offsets = AU.ensureLengthI(offsets, i + 1);
     }
-    offsets[i] = (offsets[i] & JC.LABEL_FLAGS) | (offset << 
JC.LABEL_FLAG_OFFSET);
-    if (isExact)
-      offsets[i] |= JC.LABEL_EXACT_OFFSET_FLAG;
+    offsets[i] = (offsets[i] & JC.LABEL_FLAGS) | offset;
+
     text = getLabel(i);
     if (text != null)
       text.setOffset(offset);
@@ -574,8 +562,8 @@
       text.setAlignment(alignment);
   }
 
-  public static int getAlignment(int offsetFull) {
-    return (offsetFull & JC.LABEL_ALIGN_FLAGS) >> 2;
+  public static int getAlignment(int offset) {
+    return (offset & JC.LABEL_ALIGN_FLAGS) >> 2;
   }
   
   private void setPointer(int i, int pointer) {
@@ -650,18 +638,23 @@
   public synchronized boolean checkObjectDragged(int prevX, int prevY, int x,
                                                  int y, int dragAction,
                                                  BS bsVisible) {
-    if (vwr.getPickingMode() != ActionManager.PICKING_LABEL || labelBoxes == 
null)
+
+    if (vwr.getPickingMode() != ActionManager.PICKING_LABEL
+        || labelBoxes == null)
       return false;
     // mouse down ?
     if (prevX == Integer.MIN_VALUE) {
       int iAtom = findNearestLabel(x, y);
       if (iAtom >= 0) {
         pickedAtom = iAtom;
+        vwr.acm.setDragAtomIndex(iAtom);
         pickedX = x;
         pickedY = y;
-        pickedOffset = (offsets == null 
-            || pickedAtom >= offsets.length ? 0 
-                : offsets[pickedAtom]) >> JC.LABEL_FLAG_OFFSET;
+        pickedOffset = (offsets == null || pickedAtom >= offsets.length ? 
+            JC.LABEL_DEFAULT_OFFSET : offsets[pickedAtom]);
+
+        System.out.println("LABEL OFFSET=" + pickedOffset);
+
         return true;
       }
       return false;
@@ -703,15 +696,11 @@
 
   private void move2D(int pickedAtom, int x, int y) {
     int xOffset = JC.getXOffset(pickedOffset);
-    int yOffset = -JC.getYOffset(pickedOffset);
+    int yOffset = JC.getYOffset(pickedOffset);        
     xOffset += x - pickedX;
-    yOffset += pickedY - y;
-    int offset = JC.getOffset(xOffset, yOffset);
-    if (offset == 0)
-      offset = Short.MAX_VALUE;
-    else if (offset == zeroOffset)
-      offset = 0;
-    setOffsets(pickedAtom, offset, true);
+    yOffset -= y - pickedY;
+    int offset = JC.getOffset(xOffset, yOffset, true);
+    setOffsets(pickedAtom, offset);
   }
 
   public short getColix2(int i, Atom atom, boolean isBg) {

Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/ActionManager.java   2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java   2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -89,7 +89,7 @@
       int atomIndex = vwr.findNearestAtomIndex(current.x, current.y);
       if (atomIndex < 0)
         return;
-      boolean isLabel = (getAtomPickingMode() == PICKING_LABEL && bnd(
+      boolean isLabel = (apm == PICKING_LABEL && bnd(
           Binding
               .getMouseAction(clickedCount, moved.modifiers, Event.DRAGGED),
           ACTION_dragLabel));
@@ -685,6 +685,11 @@
 
   private MeasurementPending mp;
   private int dragAtomIndex = -1;
+  
+  public void setDragAtomIndex(int iatom) {
+    dragAtomIndex = iatom;
+  }
+  
 
   private boolean rubberbandSelectionMode = false;
   private final Rectangle rectRubber = new Rectangle();
@@ -1061,8 +1066,10 @@
       if (!bnd(dragWheelAction, ACTION_rotate))
         vwr.setRotateBondIndex(-1);
     }
+    
     BS bs = null;
-    if (dragAtomIndex >= 0) {
+    if (dragAtomIndex >= 0 && apm != PICKING_LABEL) {
+      
       switch (apm) {
       case PICKING_DRAG_SELECTED:
         dragSelected(dragWheelAction, deltaX, deltaY, true);

Modified: trunk/Jmol/src/org/jmol/viewer/JC.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/JC.java      2015-06-05 23:16:38 UTC (rev 
20552)
+++ trunk/Jmol/src/org/jmol/viewer/JC.java      2015-06-06 17:03:31 UTC (rev 
20553)
@@ -219,29 +219,6 @@
   public final static int ENV_CALC_MAX_LEVEL = 3;//Geodesic.standardLevel;
 
 
-  public final static int LABEL_FRONT_FLAG    = 0x20;
-  public final static int LABEL_GROUP_FLAG    = 0x10;
-  public final static int LABEL_POINTER_FLAGS = 0x03;
-  public final static int LABEL_ALIGN_FLAGS   = 0x0C;
-  public final static int LABEL_ZPOS_FLAGS    = 0x30;
-  public final static int LABEL_SCALE_FLAG    = 0x40;
-  public final static int LABEL_EXACT_OFFSET_FLAG = 0x80;
-  public final static int LABEL_FLAGS         = 0xFF;
-  public final static int LABEL_FLAG_OFFSET   = 8;
-
-  //entry is just xxxxxxxxyyyyyyyy
-  //  3         2         1        
-  // 10987654321098765432109876543210
-  //         xxxxxxxxyyyyyyyytsfgaabp
-  //          x-align y-align||||| ||_pointer on
-  //                         ||||| |_background pointer color
-  //                         |||||_text alignment 0xC 
-  //                         ||||_labels group 0x10
-  //                         |||_labels front  0x20
-  //                         ||_scaled
-  //                         |_exact offset
-
-
   public final static int MOUSE_NONE = -1;
 
   public final static byte MULTIBOND_NEVER =     0;
@@ -602,12 +579,6 @@
   public final static String DEFAULT_FONTFACE = "SansSerif";
   public final static String DEFAULT_FONTSTYLE = "Plain";
 
-  public final static int LABEL_MINIMUM_FONTSIZE = 6;
-  public final static int LABEL_MAXIMUM_FONTSIZE = 63;
-  public final static int LABEL_DEFAULT_FONTSIZE = 13;
-  public final static int LABEL_DEFAULT_X_OFFSET = 4;
-  public final static int LABEL_DEFAULT_Y_OFFSET = 4;
-
   public final static int MEASURE_DEFAULT_FONTSIZE = 15;
   public final static int AXES_DEFAULT_FONTSIZE = 14;
 
@@ -863,36 +834,107 @@
     }
   }
 
-  public static int getOffset(int xOffset, int yOffset) {
-    xOffset = Math.min(Math.max(xOffset, -127), 127);
-    yOffset = Math.min(Math.max(yOffset, -127), 127);
-    return ((xOffset & 0xFF) << 8) | (yOffset & 0xFF);
+  public final static int LABEL_MINIMUM_FONTSIZE = 6;
+  public final static int LABEL_MAXIMUM_FONTSIZE = 63;
+  public final static int LABEL_DEFAULT_FONTSIZE = 13;
+  public final static int LABEL_DEFAULT_X_OFFSET = 4;
+  public final static int LABEL_DEFAULT_Y_OFFSET = 4;
+  public final static int LABEL_OFFSET_MAX       = 0x1F4; // 500 
+  private final static int LABEL_OFFSET_MASK     = 0x3FF; 
+  
+  
+  public final static int LABEL_FRONT_FLAG        = 0x020;
+  public final static int LABEL_GROUP_FLAG        = 0x010;
+  public final static int LABEL_POINTER_FLAGS     = 0x003;
+  public final static int LABEL_ALIGN_FLAGS       = 0x00C;
+  public final static int LABEL_ZPOS_FLAGS        = 0x030;
+  public final static int LABEL_SCALE_FLAG        = 0x040;
+  public final static int LABEL_FLAGS             = 0x07F;
+  
+  private final static int LABEL_EXPLICIT_OFFSET_FLAG = 0x080;
+  private final static int LABEL_CENTERED_FLAG     = 0x100;
+  private final static int LABEL_FLAGY_OFFSET = 9;
+  private final static int LABEL_FLAGX_OFFSET = 19;
+  
+  public static int LABEL_DEFAULT_OFFSET = 
+     (LABEL_DEFAULT_X_OFFSET << LABEL_FLAGX_OFFSET)
+   | (LABEL_DEFAULT_Y_OFFSET << LABEL_FLAGY_OFFSET);
+
+  
+  // note that the y offset is positive upward
+  
+  //  3         2         1        
+  // 10987654321098765432109876543210
+  //    -x-offset--y-offset-ntsfgaabp
+  //                        |||||| ||_pointer on
+  //                        |||||| |_background pointer color
+  //                        ||||||_text alignment 0xC 
+  //                        |||||_labels group 0x10
+  //                        ||||_labels front  0x20
+  //                        |||_scaled
+  //                        ||_explicit offset
+  //                        |_no_offset
+
+  public static boolean isOffsetExplicit(int offset) {
+    return ((offset & JC.LABEL_EXPLICIT_OFFSET_FLAG) != 0);
   }
 
+  /**
+   * Construct an 32-bit integer packed with 10-byte x and y offsets (-500 to 
500)
+   * along with flags to indicate if exact and, if not, a flag to indicate that
+   * the 0 in x or y indicates "centered". The non-exact default offset of 
[4,4] is 
+   * represented as 0 so that new array elements do not have to be 
initialized. 
+   * 
+   * @param xOffset
+   * @param yOffset
+   * @param isAbsolute
+   * @return packed offset x and y with positioning flags
+   */
+  public static int getOffset(int xOffset, int yOffset, boolean isAbsolute) {
+    xOffset = Math.min(Math.max(xOffset, -LABEL_OFFSET_MAX), LABEL_OFFSET_MAX);
+    yOffset = (Math.min(Math.max(yOffset, -LABEL_OFFSET_MAX), 
LABEL_OFFSET_MAX));
+    int offset = ((xOffset & LABEL_OFFSET_MASK) << LABEL_FLAGX_OFFSET)
+         | ((yOffset & LABEL_OFFSET_MASK) << LABEL_FLAGY_OFFSET)
+         | (isAbsolute ? LABEL_EXPLICIT_OFFSET_FLAG : 0);
+    if (offset == JC.LABEL_DEFAULT_OFFSET)
+      offset = 0;
+    else if (!isAbsolute && (xOffset == 0 || yOffset == 0))
+      offset |= JC.LABEL_CENTERED_FLAG;
+    return offset;
+  }
+
+  /**
+   * X offset in pixels. 
+   * 
+   * negative of this is the actual screen offset
+   * 
+   * @param offset  0 for an offset indicates "not set" and delivers the 
default offset
+   * @return screen offset from left
+   */
   public static int getXOffset(int offset) {
-    // ----48------FF--
-    switch (offset) {
-    case 0:
+    if (offset == 0)
       return LABEL_DEFAULT_X_OFFSET;
-    case Short.MAX_VALUE:
-      return 0;
-    default:
-      return (int) (((long) offset << 48) >> 56);
-    }
+    int x = (offset >> LABEL_FLAGX_OFFSET) & LABEL_OFFSET_MASK;
+    if (x > LABEL_OFFSET_MAX)
+      x -= LABEL_OFFSET_MASK + 1;
+    return x;
   }
 
+  /**
+   * Y offset in pixels; negative of this is the actual screen offset
+   * 
+   * @param offset  0 for an offset indicates "not set" and delivers the 
default offset
+   * @return screen offset from bottom
+   */
   public static int getYOffset(int offset) {
-    // ----56--------FF
-    switch (offset) {
-    case 0:
-      return -LABEL_DEFAULT_Y_OFFSET;
-    case Short.MAX_VALUE:
-      return 0;
-    default:
-      return -(int) (((long) offset << 56) >> 56);
-    }
+    if (offset == 0)
+      return LABEL_DEFAULT_Y_OFFSET;
+    int y = (offset >> LABEL_FLAGY_OFFSET) & LABEL_OFFSET_MASK;
+    if (y > LABEL_OFFSET_MAX)
+      y -= LABEL_OFFSET_MASK + 1;
+    return y;
   }
-
+  
   public static String getAlignmentName(int align) {
     return JC.hAlignNames[align & 3];
   }

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -16,6 +16,15 @@
 
 Jmol.___JmolVersion="14.3.14_2015.06.05"
 
+new feature: set labelOffsetAbsolute x y  
+ -- was undocumented as "set labelOffsetExact" but used in state (still 
available)
+ -- sets label to specific value; same as set labelOffset, but allows 0 in x 
or y
+ 
+bug fix: dragging labels not working properly
+bug fix: axisangle not resetting angle to 0 --> wrong default orientation 
saved to state after RESET (broken in 14.1.6_dev_2014.01.16c)
+
+JmolVersion="14.3.14_2015.06.05"
+
 new feature: load "...." FILL BOUNDBOX
 new feature: load "...." FILL UNITCELL
 new feature: load "...." FILL [o va vb vc]

Modified: trunk/Jmol/src/org/jmol/viewer/StateCreator.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2015-06-05 23:16:38 UTC 
(rev 20552)
+++ trunk/Jmol/src/org/jmol/viewer/StateCreator.java    2015-06-06 17:03:31 UTC 
(rev 20553)
@@ -706,7 +706,7 @@
         l.defaultColix, l.translucentAllowed));
     app(s, "background label " + Shape.encodeColor(l.defaultBgcolix));
     app(s, "set labelOffset " + JC.getXOffset(l.defaultOffset)
-        + " " + (-JC.getYOffset(l.defaultOffset)));
+        + " " + (JC.getYOffset(l.defaultOffset)));
     String align = JC.getAlignmentName(l.defaultAlignment);
     app(s, "set labelAlignment " + (align.length() < 5 ? "left" : align));
     String pointer = JC.getPointer(l.defaultPointer);
@@ -1214,11 +1214,11 @@
                   i,
                   i,
                   "set "
-                      + ((offsetFull & JC.LABEL_EXACT_OFFSET_FLAG) == 
JC.LABEL_EXACT_OFFSET_FLAG ? "labelOffsetExact "
+                      + (JC.isOffsetExplicit(offsetFull) ? 
"labelOffsetAbsolute "
                           : "labelOffset ")
-                      + JC.getXOffset(offsetFull >> JC.LABEL_FLAG_OFFSET)
+                      + JC.getXOffset(offsetFull)
                       + " "
-                      + (-JC.getYOffset(offsetFull >> JC.LABEL_FLAG_OFFSET)));
+                      + JC.getYOffset(offsetFull));
           String align = JC.getAlignmentName(offsetFull >> 2);
           String pointer = JC.getPointer(offsetFull);
           if (pointer.length() > 0)

Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Viewer.java  2015-06-05 23:16:38 UTC (rev 
20552)
+++ trunk/Jmol/src/org/jmol/viewer/Viewer.java  2015-06-06 17:03:31 UTC (rev 
20553)
@@ -3332,7 +3332,7 @@
                    boolean isExport, boolean isReset) {
     if (!isImageWrite && creatingImage)
       return;
-    if (!isExport && !isImageWrite)
+    if (!isExport && !isImageWrite && width > 0)
       setShapeProperty(JC.SHAPE_LABELS, "clearBoxes", null);
     antialiased = (isReset ? g.antialiasDisplay
         && checkMotionRendering(T.antialiasdisplay)

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