From: <ha...@us...> - 2007-03-08 04:31:06
|
Revision: 7053 http://svn.sourceforge.net/jmol/?rev=7053&view=rev Author: hansonr Date: 2007-03-07 20:31:03 -0800 (Wed, 07 Mar 2007) Log Message: ----------- 11.1.19 full coloring flexibility for all atom properties, variables, and datasets propertyColorScheme = "rwb" select * color atoms property temperature propertyColorScheme = "roygb" x = {*:1}.temperature.all select * color atoms variable x x = load("mydata.txt") select * data "property_whatever @x" color atoms property_whatever Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/AtomShape.java trunk/Jmol/src/org/jmol/viewer/Bond.java trunk/Jmol/src/org/jmol/viewer/ColorManager.java trunk/Jmol/src/org/jmol/viewer/Compiler.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Isosurface.java trunk/Jmol/src/org/jmol/viewer/JmolConstants.java trunk/Jmol/src/org/jmol/viewer/StateManager.java trunk/Jmol/src/org/jmol/viewer/Token.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/viewer/AtomShape.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/AtomShape.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/AtomShape.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -70,9 +70,9 @@ if ("color" == propertyName) { isActive = true; short colix = Graphics3D.getColix(value); + byte pid = JmolConstants.pidOf(value); if (bsColixSet == null) bsColixSet = new BitSet(); - byte pid = JmolConstants.pidOf(value); for (int i = atomCount; --i >= 0; ) if (bs.get(i)) setColixAndPalette(colix, pid, i); Modified: trunk/Jmol/src/org/jmol/viewer/Bond.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Bond.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/Bond.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -70,8 +70,8 @@ label = TextFormat.formatString(label, "ORDER", getOrderNumber()); label = TextFormat.formatString(label, "TYPE", getOrderName()); label = TextFormat.formatString(label, "LENGTH", atom1.distance(atom2)); - label = atom1.formatLabel(label, (char)('0' + 1), indices); - label = atom2.formatLabel(label, (char)('0' + 2), indices); + label = atom1.formatLabel(label, '1', indices); + label = atom2.formatLabel(label, '2', indices); return label; } Modified: trunk/Jmol/src/org/jmol/viewer/ColorManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -24,7 +24,7 @@ package org.jmol.viewer; import org.jmol.util.Logger; - +import java.util.BitSet; import org.jmol.g3d.*; class ColorManager { @@ -125,6 +125,8 @@ Frame frame; float lo, hi; switch (pid) { + case JmolConstants.PALETTE_PROPERTY: + return getPropertyColix(atom.atomIndex); case JmolConstants.PALETTE_JMOL: id = atom.getAtomicAndIsotopeNumber(); argb = getJmolOrRasmolArgb(id, Token.jmol); @@ -305,6 +307,35 @@ return q; } + private float colorHi, colorLo; + private String colorPalette; + private float[] colorData; + void setCurrentColorRange(float[] data, BitSet bs, String palette) { + colorData = data; + colorPalette = palette; + colorHi = Float.MIN_VALUE; + colorLo = Float.MAX_VALUE; + if (data == null) + return; + for (int i = data.length; --i >= 0;) + if (bs == null || bs.get(i)) { + float d = data[i]; + if (Float.isNaN(d)) + continue; + colorHi = Math.max(colorHi, d); + colorLo = Math.min(colorLo, d); + } + System.out.println ("colormanager--setcurrentcolorrange "+colorHi+" " + colorLo); + } + + short getPropertyColix(int iAtom) { + if (colorData == null || iAtom >= colorData.length) + return Graphics3D.GRAY; + System.out.println ("\ngetPropertyColix-- "+iAtom+" "+colorData[iAtom]); + + return getColixFromPalette(colorData[iAtom], colorLo, colorHi, colorPalette); + } + short getColixFromPalette(float val, float lo, float hi, String palette) { if (palette.equals("rwb")) { int index = quantize(val, lo, hi, JmolConstants.argbsRwbScale.length); @@ -316,6 +347,13 @@ } if (palette.equals("roygb")) { int index = quantize(val, lo, hi, JmolConstants.argbsRoygbScale.length); + int c = JmolConstants.argbsRoygbScale[index]; + System.out.println ("roygb val="+val + " lo=" + lo + " hi=" + hi + " index = " + index + " / " + JmolConstants.argbsRoygbScale.length + " " + Integer.toHexString(c)); + + return Graphics3D.getColix(c); + } + if (palette.equals("bgyor")) { + int index = quantize(-val, -hi, -lo, JmolConstants.argbsRoygbScale.length); return Graphics3D.getColix(JmolConstants.argbsRoygbScale[index]); } int ihalf = JmolConstants.argbsRoygbScale.length/2; Modified: trunk/Jmol/src/org/jmol/viewer/Compiler.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Compiler.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/Compiler.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -220,7 +220,8 @@ if (nTokens == 0) { isNewSet = false; } else { - if (nTokens == 1 && script.charAt(ichToken) == '=' && tokAttr(tokCommand, Token.setparam)) { + if (nTokens == 1 && script.charAt(ichToken) == '=' + && tokAttr(tokCommand, Token.setparam)) { tokenCommand = Token.getTokenFromName("set"); tokCommand = Token.set; ltoken.add(0, tokenCommand); @@ -363,8 +364,12 @@ ident = ident.toLowerCase(); token = (Token) Token.map.get(ident); } - if (token == null) - token = new Token(Token.identifier, ident); + if (token == null) { + if (ident.indexOf("property_") == 0) + token = new Token(Token.property, ident.toLowerCase()); + else + token = new Token(Token.identifier, ident); + } int tok = token.tok; switch (tokCommand) { // special cases @@ -402,11 +407,17 @@ return compileError("ERROR IN Token.java or JmolConstants.java -- the following term was used in JmolConstants.java but not listed as predefinedset in Token.java: " + ident); } else if (tokAttr(tok, Token.predefinedset)) { - Logger.warn("WARNING: predefined term '" + Logger + .warn("WARNING: predefined term '" + ident + "' has been redefined by the user until the next file load."); } else { - Logger.warn("WARNING: redefining " + ident + "; was " + token + "not all commands may continue to be functional for the life of the applet!"); + Logger + .warn("WARNING: redefining " + + ident + + "; was " + + token + + "not all commands may continue to be functional for the life of the applet!"); tok = token.tok = Token.identifier; Token.map.put(ident, token); } @@ -414,8 +425,8 @@ } else if (nTokens == 2 && tok == Token.opEQ) { // we are looking at @x =.... just insert a SET command // and ignore the =. It's the same as set @x ... - ltoken.add(0, Token.getTokenFromName("set")); - continue; + ltoken.add(0, Token.getTokenFromName("set")); + continue; } else { // we are looking at the expression if (tok != Token.identifier && tok != Token.set @@ -1219,11 +1230,8 @@ return true; //fall through for identifier specifically default: - if (tokAttr(tok, Token.atomproperty)) - return clauseComparator(false); - if (tokAttr(tok, Token.identifier) && clauseComparator(true)) - return true; - + if (tokAttrOr(tok, Token.property, Token.atomproperty)) + return clauseComparator(); if (!tokAttr(tok, Token.predefinedset)) break; // fall into the code and below and just add the token @@ -1523,16 +1531,11 @@ return true; } - private boolean clauseComparator(boolean isIdentifier) { + private boolean clauseComparator() { Token tokenAtomProperty = tokenNext(); Token tokenComparator = tokenNext(); - if (!tokenAttr(tokenComparator, Token.comparator)) { - if (isIdentifier) { - returnToken(); - returnToken(); - } + if (!tokenAttr(tokenComparator, Token.comparator)) return comparisonOperatorExpected(); - } if (getToken() == null) return unrecognizedExpressionToken(); boolean isNegative = (isToken(Token.hyphen)); @@ -1551,7 +1554,7 @@ } addTokenToPostfix(new Token(tokenComparator.tok, tokenAtomProperty.tok, tokenComparator.value + (isNegative ? " -" : ""))); - if (tokenAtomProperty.tok == Token.identifier) + if (tokenAtomProperty.tok == Token.property) addTokenToPostfix(tokenAtomProperty); if (isToken(Token.leftbrace)) { returnToken(); @@ -1690,9 +1693,6 @@ if (!isToken(Token.identifier)) return identifierOrResidueSpecificationExpected(); - - if (((String)theValue).toLowerCase().indexOf("property_") == 0) - return returnToken(); //check for a * in the next token, which //would indicate this must be a name with wildcard Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -1275,7 +1275,7 @@ val = code[++pc].value; int tokOperator = instruction.tok; int tokWhat = instruction.intValue; - String property = (tokWhat == Token.identifier ? (String)val : null); + String property = (tokWhat == Token.property ? (String)val : null); if (property != null) val = code[++pc].value; if (isSyntaxCheck) { @@ -1319,7 +1319,7 @@ invalidArgument(); if (((String) value).indexOf("-") >= 0) comparisonValue = -comparisonValue; - float[] data = (tokWhat == Token.identifier ? Viewer.getDataFloat(property) : null); + float[] data = (tokWhat == Token.property ? Viewer.getDataFloat(property) : null); rpn.addX(comparatorInstruction(instruction, tokWhat, data, tokOperator, comparisonValue, comparisonFloat)); break; @@ -1484,7 +1484,7 @@ if (propertyValue == Integer.MAX_VALUE) continue; break; - case Token.identifier: + case Token.property: if (data == null || data.length <= i) continue; propertyFloat = data[i]; @@ -3070,6 +3070,7 @@ case Token.jmol: case Token.rasmol: case Token.user: + case Token.property: colorObject(Token.atom, 1); return; case Token.bitset: @@ -3199,15 +3200,44 @@ checkStatementLength(index + 1); } } else { + // must not be a color, but rather a color SCHEME + // this could be a problem for properties, which can't be + // checked later -- they must be turned into a color NOW. + // "cpk" value would be "spacefill" + + String name = parameterAsString(index).toLowerCase(); byte pid = (tok == Token.spacefill ? JmolConstants.PALETTE_CPK - : JmolConstants.getPaletteID(parameterAsString(index))); + : JmolConstants.getPaletteID(name)); if (pid == JmolConstants.PALETTE_UNKNOWN || pid == JmolConstants.PALETTE_TYPE && shapeType != JmolConstants.SHAPE_HSTICKS) invalidArgument(); + if (pid == JmolConstants.PALETTE_PROPERTY) { + if (name.equals("property") + && Compiler.tokAttr(getToken(++index).tok, Token.atomproperty)) { + if (!isSyntaxCheck) { + Object data = getBitsetProperty(null, + getToken(index).tok | Token.minmaxmask, null, null, null, + null, false); + if (data instanceof float[]) + viewer.setCurrentColorRange((float[])data, null); + else + invalidArgument(); + } + } else if (!isSyntaxCheck) { + viewer.setCurrentColorRange(name); + } + } + if (pid == JmolConstants.PALETTE_VARIABLE) { + name = parameterAsString(++index); + float[] data = new float[viewer.getAtomCount()]; + Parser.parseFloatArray("" + viewer.getParameter(name), null, data); + viewer.setCurrentColorRange(data, null); + pid = JmolConstants.PALETTE_PROPERTY; + } + colorvalue = new Byte((byte) pid); checkStatementLength(index + 1); - colorvalue = new Byte((byte) pid); } if (isSyntaxCheck) return; @@ -3248,7 +3278,7 @@ } Hashtable variables = new Hashtable(); - Object[] dataLabelString; + Object[] data; void data() throws ScriptException { String dataString = null; @@ -3264,7 +3294,7 @@ dataLabel = parameterAsString(1); if (dataLabel.equalsIgnoreCase("clear")) { if (!isSyntaxCheck) - Viewer.setData(null, null, null, 0); + Viewer.setData(null, null, 0); return; } if ((i = dataLabel.indexOf("@")) >= 0) { @@ -3277,16 +3307,16 @@ } String dataType = dataLabel + " "; dataType = dataType.substring(0, dataType.indexOf(" ")); - dataLabelString = new Object[2]; - dataLabelString[0] = dataLabel; - dataLabelString[1] = dataString; + data = new Object[3]; + data[0] = dataLabel; + data[1] = dataString; boolean isModel = dataType.equalsIgnoreCase("model"); if (!isSyntaxCheck || isScriptCheck && isModel && fileOpenCheck) { if (dataType.toLowerCase().indexOf("property_") == 0) { - Viewer.setData(dataType, dataLabelString, viewer - .getSelectedAtomsOrBonds(), viewer.getAtomCount()); + data[2] = viewer.getSelectedAtomsOrBonds(); + Viewer.setData(dataType, data, viewer.getAtomCount()); } else { - Viewer.setData(dataType, dataLabelString, null, 0); + Viewer.setData(dataType, data, 0); } } if (isModel && (!isSyntaxCheck || isScriptCheck && fileOpenCheck)) { @@ -5635,9 +5665,13 @@ case Token.dot: Token token = getBitsetPropertySelector(i); //check for added min/max modifier - if (tokAt(iToken + 1) == Token.dot - && Compiler.tokAttrOr(tokAt(iToken + 2), Token.min, Token.max)) { - token.intValue |= getToken(iToken + 2).tok; + if (tokAt(iToken + 1) == Token.dot) { + if (tokAt(iToken + 2) == Token.all) { + token.intValue |= Token.minmaxmask; + getToken(iToken + 2); + } + if (Compiler.tokAttrOr(tokAt(iToken + 2), Token.min, Token.max)) + token.intValue |= getToken(iToken + 2).tok; } if (!rpn.addOp(token)) invalidArgument(); @@ -5789,10 +5823,20 @@ str = TextFormat.formatString(str, props[k], propArray[k][j]); } } else { + Bond bond = frame.getBondAt(j); if (str == null) - str = frame.getBondAt(j).getIdentity(); - else - str = frame.getBondAt(j).formatLabel(str, indices); + str = bond.getIdentity(); + else { + str = bond.formatLabel(str, indices); + int ia1 = bond.atom1.atomIndex; + int ia2 = bond.atom2.atomIndex; + for (int k = 0; k < nProp; k++) + if (ia1 < propArray[k].length) + str = TextFormat.formatString(str, props[k]+"1", propArray[k][ia1]); + for (int k = 0; k < nProp; k++) + if (ia2 < propArray[k].length) + str = TextFormat.formatString(str, props[k]+"2", propArray[k][ia2]); + } } str = TextFormat.formatString(str, "#", ++n); if (n > 1) @@ -5817,8 +5861,6 @@ tok = Token.atomY; else if (s.equals("z")) tok = Token.atomZ; - else if (s.indexOf("property_") == 0) - tok = Token.property; else invalidArgument(); break; @@ -5832,8 +5874,11 @@ boolean isAtoms = !(tokenValue instanceof BondSet); boolean isMin = Compiler.tokAttr(tok, Token.min); boolean isMax = Compiler.tokAttr(tok, Token.max); + boolean isAll = Compiler.tokAttr(tok, Token.minmaxmask); tok &= ~Token.minmaxmask; + float[] list = null; BitSet bsNew = null; + if (tok == Token.atom) bsNew = (!isAtoms && !isSyntaxCheck ? getAtomBitsetFromBonds(bs) : bs); if (tok == Token.bonds) @@ -5878,15 +5923,17 @@ if (isAtoms) { int atomCount = (isSyntaxCheck ? 0 : viewer.getAtomCount()); + if (isAll) + list = new float[atomCount]; for (int i = 0; i < atomCount; i++) - if (bs.get(i)) { + if (bs == null || bs.get(i)) { n++; Atom atom = frame.getAtomAt(i); if (isInt) { int iv = 0; switch (tok) { case Token.atomno: - iv += atom.getAtomNumber(); + iv = atom.getAtomNumber(); break; case Token.atomIndex: iv = i; @@ -5958,7 +6005,9 @@ break; } if (isInt) { - if (isMin) + if (isAll) + list[i] = iv; + else if (isMin) ivMin = Math.min(ivMin, iv); else if (isMax) ivMax = Math.max(ivMax, iv); @@ -6023,7 +6072,9 @@ } if (fv != Float.MAX_VALUE) { - if (isMin) + if (isAll) + list[i] = fv; + else if (isMin) fvMin = Math.min(fvMin, fv); else if (isMax) fvMax = Math.max(fvMax, fv); @@ -6033,8 +6084,10 @@ } } else { int bondCount = viewer.getBondCount(); + if (isAll) + list = new float[bondCount]; for (int i = 0; i < bondCount; i++) - if (bs.get(i)) { + if (bs == null || bs.get(i)) { n++; Bond bond = frame.getBondAt(i); switch (tok) { @@ -6043,6 +6096,8 @@ fvMin = Math.min(fvMin, fv); fvMax = Math.max(fvMax, fv); fvAvg += fv; + if (isAll) + list[i] = fv; break; case Token.xyz: pt.add(bond.atom1); @@ -6073,6 +6128,10 @@ ivAvg = ivMax; fvAvg = fvMax; } + if (isAll && opValue == null) //not operating + return list; + if (isAll) + return StateManager.escape(list); if (isInt && (ivAvg / n) * n == ivAvg) return new Integer(ivAvg / n); return new Float((isInt ? ivAvg * 1f : fvAvg) / n); @@ -6875,7 +6934,7 @@ case Token.data: String type = ((len = statementLength) == 3 ? parameterAsString(2) : null); if (!isSyntaxCheck) { - Object[] data = (type == null ? dataLabelString : Viewer.getData(type)); + Object[] data = (type == null ? this.data : Viewer.getData(type)); msg = (data == null ? "no data" : "data \"" + data[0] + "\"\n" @@ -7725,6 +7784,17 @@ switch (getToken(i).tok) { case Token.property: propertyName = "property"; + str = parameterAsString(i); + if (str.toLowerCase().indexOf("property_") == 0) { + data = new float[viewer.getAtomCount()]; + if (isSyntaxCheck) + continue; + data = Viewer.getDataFloat(str); + if (data == null) + invalidArgument(); + propertyValue = data; + break; + } int atomCount = viewer.getAtomCount(); int tokProperty = getToken(++i).tok; data = new float[atomCount]; @@ -7993,15 +8063,6 @@ propertyValue = new Float(1.4); break; } - if (str.toLowerCase().indexOf("property_") == 0) { - propertyName = "property"; - data = new float[viewer.getAtomCount()]; - if (!isSyntaxCheck) { - data = Viewer.getDataFloat(str); - } - propertyValue = data; - break; - } if (str.equalsIgnoreCase("VARIABLE")) { propertyName = "property"; data = new float[viewer.getAtomCount()]; @@ -8464,7 +8525,7 @@ case Token.opLT: case Token.opNE: //not quite right -- for "inmath" - if (token.intValue == Token.identifier) { + if (token.intValue == Token.property) { sb.append((String)statement[++i].value + " "); } else if (token.intValue != Integer.MAX_VALUE) sb.append(Token.nameOf(token.intValue) + " "); @@ -8679,6 +8740,7 @@ return true; case Token.min: case Token.max: + case Token.minmaxmask: tok = oPt < 0 ? Token.nada : oStack[oPt].tok; if (!wasX || !(tok == Token.propselector || tok == Token.bonds || tok == Token.atom)) @@ -9092,12 +9154,11 @@ if (isSyntaxCheck) return addX(""); String selected = Token.sValue(args[0]); - String type = (args.length == 2 ? Token.sValue(args[1]).toLowerCase() - : ""); + String type = (args.length == 2 ? Token.sValue(args[1]) : ""); // parallel addition of float property data sets - if (selected.toLowerCase().indexOf("property_") == 0) { + if (selected.indexOf("property_") == 0) { float[] f1 = Viewer.getDataFloat(selected); if (f1 == null) return addX(""); Modified: trunk/Jmol/src/org/jmol/viewer/Isosurface.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Isosurface.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/Isosurface.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -4759,7 +4759,7 @@ Point3f ptY0 = new Point3f(), ptZ0 = new Point3f(); Point3i pt0 = new Point3i(), pt1 = new Point3i(); float maxValue = Float.MAX_VALUE; - int propMax = 0; + int propMax = 0, solvMax = 0, iPt; for (int x = 0; x < nPointsX; ++x) for (int y = 0; y < nPointsY; ++y) for (int z = 0; z < nPointsZ; ++z) @@ -4776,6 +4776,7 @@ property[x][y][z] = maxValue; isProperty = true; propMax = theProperty.length; + solvMax = solvent_atomNo.length; } float maxRadius = 0; for (int iAtom = 0; iAtom < solvent_nAtoms; iAtom++) { @@ -4794,8 +4795,9 @@ float v = ptXyzTemp.distance(ptA) - rA; if (v < voxelData[i][j][k]) { voxelData[i][j][k] = (isNearby ? Float.NaN : v); - if (isProperty && iAtom < propMax && solvent_atomNo[iAtom] >= 0) - property[i][j][k] = theProperty[solvent_atomNo[iAtom]]; + if (isProperty && iAtom < solvMax + && (iPt = solvent_atomNo[iAtom]) >= 0 && iPt < propMax) + property[i][j][k] = theProperty[iPt]; } ptXyzTemp.add(volumetricVectors[2]); } Modified: trunk/Jmol/src/org/jmol/viewer/JmolConstants.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/JmolConstants.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -1778,7 +1778,7 @@ : PALETTE_UNKNOWN); } - public final static byte PALETTE_VARIABLE = 0x40; + public final static byte PALETTE_VOLATILE = 0x40; public final static byte PALETTE_STATIC = 0x3F; public final static byte PALETTE_UNKNOWN = (byte) 0xFF; @@ -1786,31 +1786,34 @@ public final static byte PALETTE_CPK = 1; public final static byte PALETTE_PARTIAL_CHARGE = 2; public final static byte PALETTE_FORMAL_CHARGE = 3; - public final static byte PALETTE_TEMP = 4 | PALETTE_VARIABLE; + public final static byte PALETTE_TEMP = 4 | PALETTE_VOLATILE; public final static byte PALETTE_FIXEDTEMP = 5; - public final static byte PALETTE_SURFACE = 6 | PALETTE_VARIABLE; + public final static byte PALETTE_SURFACE = 6 | PALETTE_VOLATILE; public final static byte PALETTE_STRUCTURE = 7; public final static byte PALETTE_AMINO = 8; public final static byte PALETTE_SHAPELY = 9; public final static byte PALETTE_CHAIN = 10; - public final static byte PALETTE_GROUP = 11 | PALETTE_VARIABLE; - public final static byte PALETTE_MONOMER = 12 | PALETTE_VARIABLE; - public final static byte PALETTE_MOLECULE = 13 | PALETTE_VARIABLE; + public final static byte PALETTE_GROUP = 11 | PALETTE_VOLATILE; + public final static byte PALETTE_MONOMER = 12 | PALETTE_VOLATILE; + public final static byte PALETTE_MOLECULE = 13 | PALETTE_VOLATILE; public final static byte PALETTE_ALTLOC = 14; public final static byte PALETTE_INSERTION = 15; public final static byte PALETTE_JMOL = 16; public final static byte PALETTE_RASMOL = 17; public final static byte PALETTE_TYPE = 18; //b0001 0010 + public final static byte PALETTE_PROPERTY = 19 | PALETTE_VOLATILE; //b0001 0011 + public final static byte PALETTE_VARIABLE = 20 | PALETTE_VOLATILE; //b0001 0011 private final static String[] paletteNames = { - /* 0 */ "none", "cpk", "partialCharge", "formalCharge", "temperature", - /* 5 */ "fixedTemperature", "surfaceDistance", "structure", "amino", + /* 0 */ "none", "cpk", "partialcharge", "formalcharge", "temperature", + /* 5 */ "fixedtemperature", "surfacedistance", "structure", "amino", /* 9 */ "shapely", "chain", "group", "monomer", "molecule", "altloc", /*15 */ "insertion", "jmol", "rasmol", - /*18 */ "type" // hbonds only + /*18 */ "type" /* hbonds only */, + /*19 */ "property", "variable", }; private final static byte[] paletteIDs = { @@ -1835,19 +1838,25 @@ PALETTE_INSERTION, PALETTE_JMOL, PALETTE_RASMOL, - PALETTE_TYPE }; + PALETTE_TYPE, + + PALETTE_PROPERTY, + PALETTE_VARIABLE, + }; + private final static int paletteCount = paletteNames.length; public static boolean isPaletteVariable(byte pid) { - return ((pid & PALETTE_VARIABLE) != 0); + return ((pid & PALETTE_VOLATILE) != 0); } public final static byte getPaletteID(String paletteName) { for (int i = 0; i < paletteCount; i++) - if (paletteNames[i].equalsIgnoreCase(paletteName)) + if (paletteNames[i].equals(paletteName)) return paletteIDs[i]; - return PALETTE_UNKNOWN; + return (paletteName.indexOf("property_") == 0 ? PALETTE_PROPERTY + : PALETTE_UNKNOWN); } public final static String getPaletteName(byte pid) { Modified: trunk/Jmol/src/org/jmol/viewer/StateManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/StateManager.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -476,6 +476,7 @@ int hoverDelayMs = 500; boolean hideNavigationPoint = false; boolean showNavigationPointAlways = false; + String propertyColorScheme = "roygb"; // window @@ -516,7 +517,6 @@ String helpPath = null; String defaultHelpPath = JmolConstants.DEFAULT_HELP_PATH; - String propertyStyleString = ""; //testing @@ -807,7 +807,7 @@ setParameterValue("navigationSpeed",navigationSpeed); setParameterValue("percentVdwAtom",percentVdwAtom); setParameterValue("pickingSpinRate",pickingSpinRate); - setParameterValue("propertyStyleString",propertyStyleString); + setParameterValue("propertyColorScheme",propertyColorScheme); setParameterValue("rangeSelected",rangeSelected); setParameterValue("selectHetero",rasmolHeteroSetting); setParameterValue("selectHydrogen",rasmolHydrogenSetting); Modified: trunk/Jmol/src/org/jmol/viewer/Token.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Token.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/Token.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -796,8 +796,7 @@ "spin", new Token(spin, varArgCount), "frame", new Token(frame, varArgCount), "frames", null, - - "structure", new Token(structure), + "animation", new Token(animation), "anim", null, Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-03-07 21:30:09 UTC (rev 7052) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2007-03-08 04:31:03 UTC (rev 7053) @@ -938,6 +938,14 @@ setBackgroundArgb(Graphics3D.getArgbFromString(colorName)); } + void setPropertyColorScheme(String scheme) { + global.propertyColorScheme = scheme; + } + + String getPropertyColorScheme() { + return global.propertyColorScheme; + } + short getColixBackgroundContrast() { return colorManager.colixBackgroundContrast; } @@ -1992,15 +2000,21 @@ static Hashtable dataValues = new Hashtable(); - static void setData(String type, Object[] data, BitSet bsSelected, int atomCount) { + static void setData(String type, Object[] data, int atomCount) { //Eval + /* + * data[0] -- label + * data[1] -- string or float[] + * data[2] -- selection bitset + * + */ if (type == null) { dataValues.clear(); return; } - if (type.toLowerCase().indexOf("property_") == 0 && bsSelected != null) { + if (data[2] != null) { float[] f = new float[atomCount]; - Parser.parseFloatArray((String) data[1], bsSelected, f); + Parser.parseFloatArray((String) data[1], (BitSet)data[2], f); data[1] = f; } dataValues.put(type, data); @@ -2022,6 +2036,16 @@ return (Object[]) dataValues.get(type); } + void setCurrentColorRange(String label) { + float[] data = getDataFloat(label); + BitSet bs = (data == null ? null : (BitSet) ((Object[]) getData(label))[2]); + setCurrentColorRange(data, bs); + } + + void setCurrentColorRange(float[] data, BitSet bs) { + colorManager.setCurrentColorRange(data, bs, global.propertyColorScheme); + } + static public float[] getDataFloat(String label) { if (dataValues == null) return null; @@ -3362,6 +3386,12 @@ //Eval while (true) { ///11.1/// + + if (key.equalsIgnoreCase("propertyColorScheme")) { + setPropertyColorScheme(value); + break; + } + if (key.equalsIgnoreCase("hoverLabel")) { setAtomHoverLabel(value); break; @@ -4204,7 +4234,8 @@ } public void setSelectionHalos(boolean TF) { - if (TF == getSelectionHaloEnabled()) + // display panel can hit this without a frame, apparently + if (TF == getSelectionHaloEnabled() || getFrame() == null) return; global.setParameterValue("selectionHalos", TF); loadShape(JmolConstants.SHAPE_HALOS); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |