From: <ha...@us...> - 2012-09-12 11:46:04
|
Revision: 17557 http://jmol.svn.sourceforge.net/jmol/?rev=17557&view=rev Author: hansonr Date: 2012-09-12 11:45:51 +0000 (Wed, 12 Sep 2012) Log Message: ----------- Refactoring for JavaScript Modified Paths: -------------- trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java trunk/Jmol/src/org/jmol/modelset/Atom.java trunk/Jmol/src/org/jmol/modelset/AtomCollection.java trunk/Jmol/src/org/jmol/modelset/Group.java trunk/Jmol/src/org/jmol/modelset/ModelCollection.java trunk/Jmol/src/org/jmol/modelset/ModelLoader.java trunk/Jmol/src/org/jmol/modelsetbio/Resolver.java trunk/Jmol/src/org/jmol/script/ScriptCompiler.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/script/ScriptFunction.java trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java trunk/Jmol/src/org/jmol/script/ScriptVariable.java trunk/Jmol/src/org/jmol/script/Token.java trunk/Jmol/src/org/jmol/util/JmolFont.java trunk/Jmol/src/org/jmol/viewer/PropertyManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/script/ScriptVariableInt.java Modified: trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java =================================================================== --- trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/minimize/forcefield/ForceFieldUFF.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -332,20 +332,20 @@ private final static Token[][] tokenTypes = new Token[][] { /*0*/ new Token[]{ Token.tokenExpressionBegin, - new Token(Token.opEQ, Token.elemno), + Token.newToken(Token.opEQ, Token.elemno), Token.intToken(0), //2 Token.tokenExpressionEnd}, /*1*/ new Token[]{ Token.tokenExpressionBegin, - new Token(Token.opEQ, Token.elemno), + Token.newToken(Token.opEQ, Token.elemno), Token.intToken(0), //2 Token.tokenAnd, - new Token(Token.opEQ, Token.formalcharge), + Token.newToken(Token.opEQ, Token.formalcharge), Token.intToken(0), //5 Token.tokenExpressionEnd}, /*2*/ new Token[]{ Token.tokenExpressionBegin, - new Token(Token.opEQ, Token.elemno), + Token.newToken(Token.opEQ, Token.elemno), Token.intToken(0) , // 2 Token.tokenAnd, Token.tokenConnected, @@ -359,7 +359,7 @@ Token.tokenExpressionEnd}, /*4*/ new Token[]{ //sp == connected(1,"triple") or connected(2, "double") Token.tokenExpressionBegin, - new Token(Token.opEQ, Token.elemno), + Token.newToken(Token.opEQ, Token.elemno), Token.intToken(0) , // 2 Token.tokenAnd, Token.tokenLeftParen, @@ -380,7 +380,7 @@ Token.tokenExpressionEnd}, /*5*/ new Token[]{ // sp2 == connected(1, double) Token.tokenExpressionBegin, - new Token(Token.opEQ, Token.elemno), + Token.newToken(Token.opEQ, Token.elemno), Token.intToken(0) , // 2 Token.tokenAnd, new Token(Token.connected, "connected"), @@ -392,7 +392,7 @@ Token.tokenExpressionEnd}, /*6*/ new Token[]{ //Nv vinylic == connected(3) && connected(connected("double")) Token.tokenExpressionBegin, - new Token(Token.opEQ, Token.elemno), + Token.newToken(Token.opEQ, Token.elemno), Token.intToken(0) , // 2 Token.tokenAnd, Token.tokenConnected, Modified: trunk/Jmol/src/org/jmol/modelset/Atom.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Atom.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/modelset/Atom.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -58,7 +58,7 @@ public static final int RADIUS_MAX = 16; - char alternateLocationID; + char alternateLocationID = '\0'; public byte atomID; int atomSite; Group group; @@ -108,7 +108,7 @@ float x, float y, float z, float radius, BitSet atomSymmetry, int atomSite, short atomicAndIsotopeNumber, int formalCharge, - boolean isHetero, char alternateLocationID) { + boolean isHetero) { this.modelIndex = (short)modelIndex; this.atomSymmetry = atomSymmetry; this.atomSite = atomSite; @@ -117,11 +117,18 @@ if (isHetero) formalChargeAndFlags = IS_HETERO_FLAG; setFormalCharge(formalCharge); - this.alternateLocationID = alternateLocationID; userDefinedVanDerWaalRadius = radius; set(x, y, z); } + public void setAltLoc(String altLoc) { + alternateLocationID = altLoc.charAt(0); + } + + public void setAltLoc(char altLoc) { + alternateLocationID = altLoc; + } + public final void setShapeVisibilityFlags(int flag) { shapeVisibilityFlags = flag; } Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -1903,9 +1903,6 @@ // categorization is done simply by listing // the number of 90, 120, and 180 angles. n = ntypes[_90] * 100 + ntypes[_120] * 10 + ntypes[_180]; - if (Logger.debugging) - Logger.debug("lcaoCartoon type is " + n); - if (z == null) { // just return geometry switch (n) { Modified: trunk/Jmol/src/org/jmol/modelset/Group.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Group.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/modelset/Group.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -303,7 +303,20 @@ return getSeqcodeString(seqcode); } + /** + * necessary for JavaScript due to problem with char + * @param sequenceNumber + * @param insertionCode + * @return seqcode << 8 + insertionCode + */ + public static int getSeqcode(int sequenceNumber, String insertionCode) { + return getSeqcode2(sequenceNumber, insertionCode.charAt(0)); + } + public static int getSeqcode(int sequenceNumber, char insertionCode) { + return getSeqcode2(sequenceNumber, insertionCode); + } + public static int getSeqcode2(int sequenceNumber, char insertionCode) { if (sequenceNumber == Integer.MIN_VALUE) return sequenceNumber; if (! ((insertionCode >= 'A' && insertionCode <= 'Z') || Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -4069,7 +4069,7 @@ int atomSerial, int atomSite, float x, float y, float z) { return addAtom(modelIndex, group, atomicAndIsotopeNumber, atomName, atomSerial, atomSite, x, y, z, Float.NaN, Float.NaN, Float.NaN, - Float.NaN, 0, 0, 100, Float.NaN, null, false, '\0', (byte) 0, null); + Float.NaN, 0, 0, 100, Float.NaN, null, false, (byte) 0, null); } public Atom addAtom(int modelIndex, Group group, @@ -4078,11 +4078,9 @@ float radius, float vectorX, float vectorY, float vectorZ, int formalCharge, float partialCharge, int occupancy, float bfactor, Quadric[] ellipsoid, - boolean isHetero, char alternateLocationID, - byte specialAtomID, BitSet atomSymmetry) { + boolean isHetero, byte specialAtomID, BitSet atomSymmetry) { Atom atom = new Atom(modelIndex, atomCount, x, y, z, radius, atomSymmetry, - atomSite, atomicAndIsotopeNumber, formalCharge, isHetero, - alternateLocationID); + atomSite, atomicAndIsotopeNumber, formalCharge, isHetero); models[modelIndex].atomCount++; models[modelIndex].bsAtoms.set(atomCount); if (atomicAndIsotopeNumber % 128 == 1) Modified: trunk/Jmol/src/org/jmol/modelset/ModelLoader.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/modelset/ModelLoader.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -835,7 +835,8 @@ Atom atom = modelSet.addAtom(currentModelIndex, nullGroup, atomicAndIsotopeNumber, atomName, atomSerial, atomSite, x, y, z, radius, vectorX, vectorY, vectorZ, formalCharge, partialCharge, occupancy, bfactor, ellipsoid, - isHetero, alternateLocationID, specialAtomID, atomSymmetry); + isHetero, specialAtomID, atomSymmetry); + atom.setAltLoc(alternateLocationID); htAtomMap.put(atomUid, atom); } Modified: trunk/Jmol/src/org/jmol/modelsetbio/Resolver.java =================================================================== --- trunk/Jmol/src/org/jmol/modelsetbio/Resolver.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/modelsetbio/Resolver.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -226,7 +226,7 @@ for (int i = 0; i < nH; i++) modelSet.addAtom(modelSet.atoms[iFirst].modelIndex, modelSet.atoms[iFirst].getGroup(), (short) 1, "H", 0, 0, Float.NaN, Float.NaN, Float.NaN, Float.NaN, Float.NaN, Float.NaN, Float.NaN, 0, 0, 1, 0, - null, isHetero, '\0', (byte) 0, null).delete(null); + null, isHetero, (byte) 0, null).delete(null); } public void getBondInfo(JmolAdapter adapter, String group3, Object model) { Modified: trunk/Jmol/src/org/jmol/script/ScriptCompiler.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/script/ScriptCompiler.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -993,7 +993,7 @@ if (iident == Integer.MIN_VALUE || Math.abs(iident) < 1000) addTokenToPrefix(new Token(Token.identifier, ident)); else - addTokenToPrefix(new Token(Token.integer, iident)); + addTokenToPrefix(Token.intToken(iident)); return CONTINUE; } switch (tokCommand) { Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -847,7 +847,7 @@ break; case Token.spec_seqcode: case Token.integer: - rpn.addXNum(ScriptVariable.intVariable(theToken.intValue)); + rpn.addXNum(new ScriptVariableInt(theToken.intValue)); break; // these next are for the within() command case Token.plane: @@ -2069,8 +2069,7 @@ ScriptContext sc = getScriptContext(); if (isTry) { - contextVariables.put("_breakval", ScriptVariable - .intVariable(Integer.MAX_VALUE)); + contextVariables.put("_breakval", new ScriptVariableInt(Integer.MAX_VALUE)); contextVariables.put("_errorval", ScriptVariable.getVariable("")); viewer.resetError(); parallelProcessor.addProcess("try", sc); @@ -3397,7 +3396,7 @@ private boolean isBondSet; private Object expressionResult; - private BitSet atomExpression(int index) throws ScriptException { + private BitSet atomExpressionAt(int index) throws ScriptException { if (!checkToken(index)) error(ERROR_badArgumentCount, index); return atomExpression(statement, index, 0, true, false, true, true); @@ -3628,16 +3627,16 @@ break; case Token.spec_seqcode: if (isInMath) - rpn.addXNum(ScriptVariable.intVariable(instruction.intValue)); + rpn.addXNum(new ScriptVariableInt(instruction.intValue)); else rpn.addXBs(getAtomBits(Token.spec_seqcode, new Integer( getSeqCode(instruction)))); break; case Token.spec_seqcode_range: if (isInMath) { - rpn.addXNum(ScriptVariable.intVariable(instruction.intValue)); + rpn.addXNum(new ScriptVariableInt(instruction.intValue)); rpn.addXObj(Token.tokenMinus); - rpn.addXNum(ScriptVariable.intVariable(code[++pc].intValue)); + rpn.addXNum(new ScriptVariableInt(code[++pc].intValue)); break; } int chainID = (pc + 3 < code.length && code[pc + 2].tok == Token.opAND @@ -5952,7 +5951,7 @@ case Token.in: nSkip -= 2; if (tokAt(++i) == Token.expressionBegin || tokAt(i) == Token.bitset) { - bsOrList = atomExpression(i); + bsOrList = atomExpressionAt(i); if (isBondSet) bsOrList = new BondSet((BitSet) bsOrList); } else { @@ -6256,7 +6255,7 @@ if (isSyntaxCheck) return; if (tv == null) - tv = (v == null ? ScriptVariable.intVariable(0) : v); + tv = (v == null ? new ScriptVariableInt(0) : v); t.value = tv.value; t.intValue = tv.intValue; t.tok = tv.tok; @@ -6628,7 +6627,7 @@ case Token.trace: Point3f[][] pathGuide; List<Point3f[]> vp = new ArrayList<Point3f[]>(); - BitSet bs = atomExpression(++i); + BitSet bs = atomExpressionAt(++i); i = iToken; if (isSyntaxCheck) return; @@ -6832,8 +6831,8 @@ BitSet bsAtoms1 = null, bsAtoms2 = null; List<BitSet[]> vAtomSets = null; List<Object[]> vQuatSets = null; - BitSet bsFrom = (tokAt(1) == Token.subset ? null : atomExpression(1)); - BitSet bsTo = (tokAt(++iToken) == Token.subset ? null : atomExpression(iToken)); + BitSet bsFrom = (tokAt(1) == Token.subset ? null : atomExpressionAt(1)); + BitSet bsTo = (tokAt(++iToken) == Token.subset ? null : atomExpressionAt(iToken)); if (bsFrom == null || bsTo == null) error(ERROR_invalidArgument); BitSet bsSubset = null; @@ -6863,16 +6862,16 @@ case Token.comma: break; case Token.subset: - bsSubset = atomExpression(++i); + bsSubset = atomExpressionAt(++i); i = iToken; break; case Token.bitset: case Token.expressionBegin: if (vQuatSets != null) error(ERROR_invalidArgument); - bsAtoms1 = atomExpression(iToken); + bsAtoms1 = atomExpressionAt(iToken); int tok = (isToSubsetOfFrom ? 0 : tokAt(iToken + 1)); - bsAtoms2 = (tok == Token.bitset || tok == Token.expressionBegin ? atomExpression(++iToken) + bsAtoms2 = (tok == Token.bitset || tok == Token.expressionBegin ? atomExpressionAt(++iToken) : BitSetUtil.copy(bsAtoms1)); if (bsSubset != null) { bsAtoms1.and(bsSubset); @@ -7268,7 +7267,7 @@ error(ERROR_badArgumentCount); if (haveType || isColorOrRadius) error(ERROR_invalidParameterOrder); - atomSets[nAtomSets++] = atomExpression(i); + atomSets[nAtomSets++] = atomExpressionAt(i); isBonds = isBondSet; if (nAtomSets == 2) { int pt = iToken; @@ -7428,7 +7427,7 @@ .nextSetBit(atom1 + 1)) { bs.set(atom1); result = viewer.makeConnections(distances[0], distances[1], bondOrder, - operation, bs, atomExpression(expression2), bsBonds, isBonds, + operation, bs, atomExpressionAt(expression2), bsBonds, isBonds, false, 0); nNew += Math.abs(result[0]); nModified += result[1]; @@ -7486,7 +7485,7 @@ int propertyID = PropertyManager.getPropertyNumber(name); String param = optParameterAsString(2); int tok = tokAt(2); - BitSet bs = (tok == Token.expressionBegin || tok == Token.bitset ? atomExpression(2) + BitSet bs = (tok == Token.expressionBegin || tok == Token.bitset ? atomExpressionAt(2) : null); if (property.length() > 0 && propertyID < 0) { // no such property @@ -7822,7 +7821,7 @@ boolean doClearBondSet = false; float translucentLevel = Float.MAX_VALUE; if (index < 0) { - bs = atomExpression(-index); + bs = atomExpressionAt(-index); index = iToken + 1; if (isBondSet) { doClearBondSet = true; @@ -7852,7 +7851,7 @@ bs = (BondSet) theToken.value; prefix = "vertex"; } else { - bs = atomExpression(index); + bs = atomExpressionAt(index); // don't allow isosurface partial translucency (yet) prefix = "atom"; } @@ -8133,15 +8132,15 @@ while (true) { if (tokAt(1) == Token.selected) { bsFrom = viewer.getSelectionSet(false); - bsTo = atomExpression(2); + bsTo = atomExpressionAt(2); property1 = property2 = "selected"; } else { - bsFrom = atomExpression(1); + bsFrom = atomExpressionAt(1); if (tokAt(++iToken) != Token.per || !Token.tokAttr(tokProp1 = tokAt(++iToken), Token.atomproperty)) break; property1 = parameterAsString(iToken); - bsTo = atomExpression(++iToken); + bsTo = atomExpressionAt(++iToken); if (tokAt(++iToken) != Token.per || !Token.tokAttr(tokProp2 = tokAt(++iToken), Token.settable)) break; @@ -8407,7 +8406,7 @@ //if (!isSite) //viewer.addStateScript(thisCommand, false, true); removed for 12.1.16 } else { - BitSet bs = atomExpression(2); + BitSet bs = atomExpressionAt(2); definedAtomSets.put(setName, bs); if (!isSyntaxCheck) viewer.setUserVariable("@" + setName, ScriptVariable.getVariable(bs)); @@ -10030,7 +10029,7 @@ case Token.dollarsign: if (tok == Token.bitset || tok == Token.expressionBegin) { if (translation != null || q != null || nPoints == 2) { - bsAtoms = atomExpression(i); + bsAtoms = atomExpressionAt(i); ptsB = null; isSelected = true; break; @@ -10131,8 +10130,8 @@ break; case Token.branch: haveRotation = true; - int iAtom1 = atomExpression(++i).nextSetBit(0); - int iAtom2 = atomExpression(++iToken).nextSetBit(0); + int iAtom1 = atomExpressionAt(++i).nextSetBit(0); + int iAtom2 = atomExpressionAt(++iToken).nextSetBit(0); if (iAtom1 < 0 || iAtom2 < 0) return; bsAtoms = viewer.getBranchBitSet(iAtom2, iAtom1); @@ -10190,7 +10189,7 @@ case Token.matrix3f: haveRotation = true; if (tok == Token.compare) { - bsCompare = atomExpression(++i); + bsCompare = atomExpressionAt(++i); ptsA = viewer.getAtomPointVector(bsCompare); if (ptsA == null) error(ERROR_invalidArgument, i); @@ -10360,7 +10359,7 @@ return data; } if (i > 0) - return viewer.getAtomPointVector(atomExpression(i)); + return viewer.getAtomPointVector(atomExpressionAt(i)); return null; } @@ -10652,7 +10651,7 @@ bs = new BondSet(BitSetUtil.newBitSet(0, viewer.getModelSet() .getBondCount())); else - bs = atomExpression(i); + bs = atomExpressionAt(i); } if (isSyntaxCheck) return; @@ -10717,7 +10716,7 @@ checkLength(3); } else { while (n < 4 && !isFloatParameter(i)) { - aList[++n] = atomExpression(i).nextSetBit(0); + aList[++n] = atomExpressionAt(i).nextSetBit(0); i = iToken + 1; } aList[0] = n; @@ -10738,7 +10737,7 @@ case Token.fixed: if (i != 1) error(ERROR_invalidArgument); - bsFixed = atomExpression(++i); + bsFixed = atomExpressionAt(++i); if (bsFixed.nextSetBit(0) < 0) bsFixed = null; i = iToken; @@ -10748,7 +10747,7 @@ return; continue; case Token.select: - bsSelected = atomExpression(++i); + bsSelected = atomExpressionAt(++i); i = iToken; continue; case Token.silent: @@ -10816,7 +10815,7 @@ isGroup = (tok == Token.group); if (isGroup) tok = tokAt(++i); - bs = atomExpression(i); + bs = atomExpressionAt(i); } if (isSyntaxCheck) return; @@ -10839,7 +10838,7 @@ viewer.setSelectionSubset(null); if (statementLength != 1 && (statementLength != 4 || !getToken(2).value.equals("off"))) - bs = atomExpression(1); + bs = atomExpressionAt(1); if (!isSyntaxCheck) viewer.setSelectionSubset(bs); } @@ -10862,9 +10861,9 @@ viewer.invertAtomCoord(pt, bs); return; case Token.stereo: - iAtom = atomExpression(2).nextSetBit(0); + iAtom = atomExpressionAt(2).nextSetBit(0); // and only these: - bs = atomExpression(iToken + 1); + bs = atomExpressionAt(iToken + 1); break; case Token.point: pt = centerParameter(2); @@ -10902,7 +10901,7 @@ } if (isPoint3f(i)) { Point3f pt = getPoint3f(i, true); - bs = (!isSelected && iToken + 1 < statementLength ? atomExpression(++iToken) + bs = (!isSelected && iToken + 1 < statementLength ? atomExpressionAt(++iToken) : null); checkLast(iToken); if (!isSyntaxCheck) @@ -10927,7 +10926,7 @@ return; iToken = i0 + (type == '\0' ? 2 : 3); bs = (isSelected ? viewer.getSelectionSet(false) - : iToken + 1 < statementLength ? atomExpression(++iToken) : null); + : iToken + 1 < statementLength ? atomExpressionAt(++iToken) : null); checkLast(iToken); if (!isSyntaxCheck) viewer.translate(xyz, amount, type, bs); @@ -10939,7 +10938,7 @@ refresh(); return; } - BitSet bs = atomExpression(1); + BitSet bs = atomExpressionAt(1); if (isSyntaxCheck) return; int nDeleted = viewer.deleteAtoms(bs, true); @@ -11024,7 +11023,7 @@ if (!viewer.isWindowCentered()) { // do a smooth zoom only if not windowCentered if (center != null) { - BitSet bs = atomExpression(ptCenter); + BitSet bs = atomExpressionAt(ptCenter); if (!isSyntaxCheck) viewer.setCenterBitSet(bs, false); } @@ -11538,7 +11537,7 @@ switch (tokAt(2)) { case Token.bitset: case Token.expressionBegin: - bs = atomExpression(2); + bs = atomExpressionAt(2); checkLast(iToken); break; default: @@ -11710,7 +11709,7 @@ case Token.expressionBegin: if (propertyName == null) propertyName = (iHaveAtoms || iHaveCoord ? "endSet" : "startSet"); - propertyValue = atomExpression(i); + propertyValue = atomExpressionAt(i); i = iToken; iHaveAtoms = true; break; @@ -11905,23 +11904,23 @@ if (asDSSP) bs1 = viewer.getSelectionSet(false); else - bs1 = atomExpression(iToken); + bs1 = atomExpressionAt(iToken); if (!asDSSP && !(asDSSP = (tokAt(++iToken) == Token.structure))) - bs2 = atomExpression(iToken); + bs2 = atomExpressionAt(iToken); if (!isSyntaxCheck) { n = viewer.autoHbond(bs1, bs2, false); break; } return; case Token.hydrogen: - bs = (statementLength == 2 ? null : atomExpression(2)); + bs = (statementLength == 2 ? null : atomExpressionAt(2)); checkLast(iToken); if (!isSyntaxCheck) viewer.addHydrogens(bs, false, false); return; case Token.partialcharge: iToken = 1; - bs = (statementLength == 2 ? null : atomExpression(2)); + bs = (statementLength == 2 ? null : atomExpressionAt(2)); checkLast(iToken); if (!isSyntaxCheck) viewer.calculatePartialCharges(bs); @@ -11939,7 +11938,7 @@ } return; case Token.structure: - bs = (statementLength < 4 ? null : atomExpression(2)); + bs = (statementLength < 4 ? null : atomExpressionAt(2)); switch (tokAt(++iToken)) { case Token.ramachandran: break; @@ -11956,8 +11955,8 @@ showString(viewer.calculateStructures(bs, asDSSP, true)); return; case Token.struts: - bs = (iToken + 1 < statementLength ? atomExpression(++iToken) : null); - bs2 = (iToken + 1 < statementLength ? atomExpression(++iToken) : null); + bs = (iToken + 1 < statementLength ? atomExpressionAt(++iToken) : null); + bs2 = (iToken + 1 < statementLength ? atomExpressionAt(++iToken) : null); checkLength(++iToken); if (!isSyntaxCheck) { n = viewer.calculateStruts(bs, bs2); @@ -11993,7 +11992,7 @@ default: isFrom = true; } - bs = (iToken + 1 < statementLength ? atomExpression(++iToken) : viewer + bs = (iToken + 1 < statementLength ? atomExpressionAt(++iToken) : viewer .getSelectionSet(false)); checkLength(++iToken); if (!isSyntaxCheck) @@ -12164,13 +12163,13 @@ private void assign() throws ScriptException { int atomsOrBonds = tokAt(1); - int index = atomExpression(2).nextSetBit(0); + int index = atomExpressionAt(2).nextSetBit(0); int index2 = -1; String type = null; if (index < 0) error(ERROR_invalidArgument); if (atomsOrBonds == Token.connect) { - index2 = atomExpression(++iToken).nextSetBit(0); + index2 = atomExpressionAt(++iToken).nextSetBit(0); } else { type = parameterAsString(++iToken); } @@ -12210,7 +12209,7 @@ } private void fixed() throws ScriptException { - BitSet bs = (statementLength == 1 ? null : atomExpression(1)); + BitSet bs = (statementLength == 1 ? null : atomExpressionAt(1)); if (isSyntaxCheck) return; viewer.setMotionFixedAtoms(bs); @@ -12231,7 +12230,7 @@ switch (tokAt(1)) { case Token.expressionBegin: case Token.bitset: - int i = atomExpression(1).nextSetBit(0); + int i = atomExpressionAt(1).nextSetBit(0); checkLength(iToken + 1); if (isSyntaxCheck || i < 0) return; @@ -12269,7 +12268,7 @@ return; case Token.align: BitSet bs = (statementLength == 2 || tokAt(2) == Token.none ? null - : atomExpression(2)); + : atomExpressionAt(2)); if (!isSyntaxCheck) viewer.setFrameOffsets(bs); return; @@ -12630,7 +12629,7 @@ case Token.highlight: shapeManager.loadShape(JmolConstants.SHAPE_HALOS); setShapeProperty(JmolConstants.SHAPE_HALOS, "highlight", - (tokAt(2) == Token.off ? null : atomExpression(2))); + (tokAt(2) == Token.off ? null : atomExpressionAt(2))); return; case Token.display:// deprecated case Token.selectionhalos: @@ -13266,7 +13265,7 @@ } if (str.equals("toggle")) { iToken = 1; - BitSet bs = (statementLength == 2 ? null : atomExpression(2)); + BitSet bs = (statementLength == 2 ? null : atomExpressionAt(2)); checkLast(iToken); if (!isSyntaxCheck) viewer.togglePickingLabel(bs); @@ -13291,7 +13290,7 @@ } return false; } - BitSet bs = (iToken + 1 < statementLength ? atomExpression(++iToken) : null); + BitSet bs = (iToken + 1 < statementLength ? atomExpressionAt(++iToken) : null); checkLast(iToken); if (isSyntaxCheck) return true; @@ -13578,7 +13577,7 @@ ScriptVariable t = (settingData ? null : getContextVariableAsVariable(key)); boolean isUserVariable = (t != null); if (pt > 0 && tokAt(pt - 1) == Token.expressionBegin) { - bs = atomExpression(pt - 1); + bs = atomExpressionAt(pt - 1); pt = iToken + 1; isExpression = true; } @@ -15159,9 +15158,9 @@ iConnect = 0; connections = new int[] { -1, -1, -1, -1 }; } - connections[iConnect++] = atomExpression(++i).nextSetBit(0); + connections[iConnect++] = atomExpressionAt(++i).nextSetBit(0); i = iToken; - connections[iConnect++] = (theTok == Token.bonds ? atomExpression(++i) + connections[iConnect++] = (theTok == Token.bonds ? atomExpressionAt(++i) .nextSetBit(0) : -1); i = iToken; havePoints = true; @@ -15276,7 +15275,7 @@ // draw ID xxx symop [n or "x,-y,-z"] [optional {center}] // so we also check here for the atom set to get the right model bsAtoms = (tokAt(i) == Token.bitset - || tokAt(i) == Token.expressionBegin ? atomExpression(i) : null); + || tokAt(i) == Token.expressionBegin ? atomExpressionAt(i) : null); i = iToken + 1; } checkLast(iToken); @@ -15346,7 +15345,7 @@ case Token.bitset: case Token.expressionBegin: propertyName = "atomSet"; - propertyValue = atomExpression(i); + propertyValue = atomExpressionAt(i); if (isFrame) center = centerParameter(i); i = iToken; @@ -15659,7 +15658,7 @@ needsGenerating = true; propertyName = setPropertyName; setPropertyName = "to"; - propertyValue = atomExpression(i); + propertyValue = atomExpressionAt(i); i = iToken; break; case Token.to: @@ -15668,7 +15667,7 @@ if (tokAt(i + 1) == Token.bitset || tokAt(i + 1) == Token.expressionBegin && !needsGenerating) { propertyName = "toBitSet"; - propertyValue = atomExpression(++i); + propertyValue = atomExpressionAt(++i); i = iToken; needsGenerating = true; break; @@ -15916,7 +15915,7 @@ case Token.expressionBegin: if (isWild || bsB != null) error(ERROR_invalidArgument); - bs = BitSetUtil.copy(atomExpression(i)); + bs = BitSetUtil.copy(atomExpressionAt(i)); i = iToken; if (bsA == null) bsA = bs; @@ -16120,7 +16119,7 @@ case Token.bitset: case Token.expressionBegin: propertyName = "select"; - propertyValue = atomExpression(i); + propertyValue = atomExpressionAt(i); i = iToken; break; case Token.color: @@ -16153,7 +16152,7 @@ if (tokAt(i + 1) == Token.bitset || tokAt(i + 1) == Token.expressionBegin) { propertyName = "select"; - propertyValue = atomExpression(i + 1); + propertyValue = atomExpressionAt(i + 1); i = iToken; } else { propertyName = "selectType"; @@ -16256,7 +16255,7 @@ switch (tok) { case Token.bitset: case Token.expressionBegin: - data = atomExpression(i + 1); + data = atomExpressionAt(i + 1); tok = Token.decimal; iToken++; break; @@ -16849,12 +16848,12 @@ case Token.intersection: // isosurface intersection {A} {B} VDW.... // isosurface intersection {A} {B} function "a-b" VDW.... - bsSelect = atomExpression(++i); + bsSelect = atomExpressionAt(++i); if (isSyntaxCheck) { bs = new BitSet(); } else if (tokAt(iToken + 1) == Token.expressionBegin || tokAt(iToken + 1) == Token.bitset) { - bs = atomExpression(++iToken); + bs = atomExpressionAt(++iToken); bs.and(viewer.getAtomsWithin(5.0f, bsSelect, false, null)); } else { // default is "within(5.0, selected) and not within(molecule,selected)" @@ -17059,7 +17058,7 @@ // we PREPEND the selection to the command if no surface object // has been seen yet, and APPEND it if it has. propertyName = "select"; - BitSet bs1 = atomExpression(++i); + BitSet bs1 = atomExpressionAt(++i); propertyValue = bs1; i = iToken; boolean isOnly = (tokAt(i + 1) == Token.only); @@ -17245,7 +17244,7 @@ break; } catch (ScriptException e) { } - bs = atomExpression(i); + bs = atomExpressionAt(i); sbCommand.append(" ellipsoid ").append(Escape.escape(bs)); int iAtom = bs.nextSetBit(0); Atom[] atoms = viewer.getModelSet().atoms; @@ -17276,7 +17275,7 @@ case Token.expressionBegin: // automatically selects just the model of the first atom in the set. propertyName = "lcaoCartoon"; - bs = atomExpression(i); + bs = atomExpressionAt(i); i = iToken; if (isSyntaxCheck) continue; @@ -17729,7 +17728,7 @@ break; case Token.ignore: propertyName = "ignore"; - propertyValue = bsIgnore = atomExpression(++i); + propertyValue = bsIgnore = atomExpressionAt(++i); sbCommand.append(" ignore ").append(Escape.escape(propertyValue)); i = iToken; break; @@ -18060,7 +18059,7 @@ switch (tokAt(++i)) { case Token.bitset: case Token.expressionBegin: - propertyValue = new int[] { atomExpression(i).nextSetBit(0) }; + propertyValue = new int[] { atomExpressionAt(i).nextSetBit(0) }; break; default: propertyValue = new int[] { (int) floatParameterSet(i, 1, 1)[0] }; Modified: trunk/Jmol/src/org/jmol/script/ScriptFunction.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptFunction.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/script/ScriptFunction.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -82,7 +82,7 @@ contextVariables.put(name, (var == null ? (new ScriptVariable(Token.string, "")).setName(name) : var)); } - contextVariables.put("_retval", ScriptVariable.intVariable(tok == Token.trycmd ? Integer.MAX_VALUE : 0)); + contextVariables.put("_retval", new ScriptVariableInt(tok == Token.trycmd ? Integer.MAX_VALUE : 0)); } public void unsetVariables(Map<String, ScriptVariable> contextVariables, List<ScriptVariable> params) { Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -213,7 +213,7 @@ case Token.integer: if (x.intValue < 0) { addOp(Token.tokenMinus); - x = ScriptVariable.intVariable(-x.intValue); + x = new ScriptVariableInt(-x.intValue); } break; case Token.decimal: @@ -235,7 +235,7 @@ private boolean addXInt(int x) { // no check for unary minus - putX(ScriptVariable.intVariable(x)); + putX(new ScriptVariableInt(x)); return wasX = true; } @@ -949,7 +949,7 @@ y.add(count); counts.add(ScriptVariable.getVariable(y)); } - count = ScriptVariable.intVariable(1); + count = new ScriptVariableInt(1); last = a; } if (match == null) Modified: trunk/Jmol/src/org/jmol/script/ScriptVariable.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptVariable.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/script/ScriptVariable.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -80,10 +80,6 @@ super(tok, value); } - public ScriptVariable(int tok, int intValue) { - super(tok, intValue); - } - public ScriptVariable(BitSet bs, int index) { value = bs; this.index = index; @@ -150,10 +146,6 @@ } } - public static ScriptVariable intVariable(int intValue) { - return new ScriptVariable(integer, intValue); - } - static public boolean isVariableType(Object x) { return (x instanceof ScriptVariable || x instanceof BitSet @@ -199,7 +191,7 @@ if (x instanceof Boolean) return getBoolean(((Boolean) x).booleanValue()); if (x instanceof Integer) - return new ScriptVariable(integer, ((Integer) x).intValue()); + return new ScriptVariableInt(((Integer) x).intValue()); if (x instanceof Float) return new ScriptVariable(decimal, x); if (x instanceof String) { @@ -564,15 +556,14 @@ case bitset: return Escape.escapeBs(bsSelectToken(x), !(x.value instanceof BondSet)); case varray: + List<ScriptVariable> sv = ((ScriptVariable) x).getList(); + i = x.intValue; + if (i <= 0) + i = sv.size() - i; + if (i != Integer.MAX_VALUE) + return (i < 1 || i > sv.size() ? "" : sValue(sv.get(i - 1))); + //$FALL-THROUGH$ case hash: - if (x.tok == Token.varray) { - List<ScriptVariable> sv = ((ScriptVariable) x).getList(); - i = x.intValue; - if (i <= 0) - i = sv.size() - i; - if (i != Integer.MAX_VALUE) - return (i < 1 || i > sv.size() ? "" : sValue(sv.get(i - 1))); - } sb = new StringBuffer(); map = new Hashtable<Object, Boolean>(); sValueArray(sb, (ScriptVariable) x, map, 0, false); @@ -790,7 +781,7 @@ } int len = 0; boolean isInputSelected = (tokenIn instanceof ScriptVariable && ((ScriptVariable) tokenIn).index != Integer.MAX_VALUE); - ScriptVariable tokenOut = new ScriptVariable(tokenIn.tok, Integer.MAX_VALUE); + ScriptVariable tokenOut = new ScriptVariableInt(Integer.MAX_VALUE); switch (tokenIn.tok) { case bitset: Added: trunk/Jmol/src/org/jmol/script/ScriptVariableInt.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptVariableInt.java (rev 0) +++ trunk/Jmol/src/org/jmol/script/ScriptVariableInt.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -0,0 +1,33 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2009-06-05 07:42:12 -0500 (Fri, 05 Jun 2009) $ + * $Revision: 10958 $ + * + * Copyright (C) 2003-2005 The Jmol Development Team + * + * Contact: jmo...@li... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jmol.script; + +public class ScriptVariableInt extends ScriptVariable { + public ScriptVariableInt(int intValue) { + super(Token.integer); + this.intValue = intValue; + } + +} Modified: trunk/Jmol/src/org/jmol/script/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/script/Token.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/script/Token.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -60,18 +60,21 @@ this.tok = tok; } - public Token(int tok, int intValue) { - this.tok = tok; - this.intValue = intValue; - } - public Token(int tok, Object value) { this.tok = tok; this.value = value; } + public final static Token newToken(int tok, int intValue) { + Token token = new Token(tok); + token.intValue = intValue; + return token; + } + public final static Token intToken(int intValue) { - return new Token(integer, intValue); + Token token = new Token(integer); + token.intValue = intValue; + return token; } public final static int nada = 0; @@ -101,11 +104,11 @@ }; public static boolean tokAttr(int a, int b) { - return (a & b) == b; + return (a & b) == (b & b); } public static boolean tokAttrOr(int a, int b1, int b2) { - return (a & b1) == b1 || (a & b2) == b2; + return (a & b1) == (b1 & b1) || (a & b2) == (b2 & b2); } @@ -1305,7 +1308,7 @@ final static Token tokenCoordinateBegin = new Token(leftbrace, "{"); final static Token tokenRightBrace = new Token(rightbrace, "}"); final static Token tokenCoordinateEnd = tokenRightBrace; - final static Token tokenColon = new Token(colon, ':'); + final static Token tokenColon = new Token(colon, ":"); final static Token tokenSetCmd = new Token(set, "set"); final static Token tokenSet = new Token(set, '=', ""); final static Token tokenSetArray = new Token(set, '[', ""); Modified: trunk/Jmol/src/org/jmol/util/JmolFont.java =================================================================== --- trunk/Jmol/src/org/jmol/util/JmolFont.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/util/JmolFont.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -47,7 +47,7 @@ public final int idFontStyle; public final float fontSize; public final Object font; - public final Object fontMetrics; + private final Object fontMetrics; private ApiPlatform apiPlatform; private JmolFont(ApiPlatform apiPlatform, byte fid, int idFontFace, int idFontStyle, float fontSize, Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -35,6 +35,7 @@ import org.jmol.script.ScriptEvaluator; import org.jmol.script.ScriptVariable; +import org.jmol.script.ScriptVariableInt; import org.jmol.script.Token; import org.jmol.util.Escape; import org.jmol.util.Logger; @@ -200,7 +201,7 @@ int n; for (int i = 1; i < names.length; i++) { if ((n = Parser.parseInt(names[i])) != Integer.MIN_VALUE) - args[i] = new ScriptVariable(Token.integer, n); + args[i] = new ScriptVariableInt(n); else args[i] = new ScriptVariable(Token.string, names[i]); } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-09-12 00:29:26 UTC (rev 17556) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-09-12 11:45:51 UTC (rev 17557) @@ -30,6 +30,7 @@ import org.jmol.script.ScriptEvaluator; import org.jmol.script.ScriptFunction; import org.jmol.script.ScriptVariable; +import org.jmol.script.ScriptVariableInt; import org.jmol.script.Token; import org.jmol.shape.Shape; import org.jmol.i18n.GT; @@ -447,7 +448,7 @@ o = info.get("repaintManager"); if (o == null) o = (Interface.getOptionInterface("render.RepaintManager")); - if (o != null) + if (o != null && !o.equals("")) (repaintManager = (JmolRepaintInterface) o).set(this, shapeManager); initialize(true); fileManager = new FileManager(this); @@ -6477,7 +6478,7 @@ default: // stateversion is not tokenized if (!global.htNonbooleanParameterValues.containsKey(key)) { - global.setUserVariable(key, ScriptVariable.intVariable(value)); + global.setUserVariable(key, new ScriptVariableInt(value)); return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |