short getColixAtomPalette(Atom atom, byte pid) {
int argb = 0;
int index;
short id;
ModelSet modelSet;
int modelIndex;
float lo, hi;
switch (pid) {
case JmolConstants.PALETTE_PROPERTY:
return (colorData == null || atom.index >= colorData.length
? Graphics3D.GRAY : getColixForPropertyValue(colorData[atom.index]));
case JmolConstants.PALETTE_NONE:
case JmolConstants.PALETTE_CPK:
// Note that CPK colors can be changed based upon user preference
// therefore, a changeable colix is allocated in this case
id = atom.getAtomicAndIsotopeNumber();
if (id < Elements.elementNumberMax)
return g3d.getChangeableColix(id, argbsCpk[id]);
id = (short) Elements.altElementIndexFromNumber(id);
return g3d.getChangeableColix((short) (Elements.elementNumberMax + id),
altArgbsCpk[id]);
case JmolConstants.PALETTE_PARTIAL_CHARGE:
// This code assumes that the range of partial charges is [-1, 1].
index = ColorEncoder.quantize(atom.getPartialCharge(), -1, 1,
JmolConstants.PARTIAL_CHARGE_RANGE_SIZE);
return g3d.getChangeableColix(
(short) (JmolConstants.PARTIAL_CHARGE_COLIX_RED + index),
JmolConstants.argbsRwbScale[index]);
case JmolConstants.PALETTE_FORMAL_CHARGE:
index = atom.getFormalCharge() - JmolConstants.FORMAL_CHARGE_MIN;
return g3d.getChangeableColix(
(short) (JmolConstants.FORMAL_CHARGE_COLIX_RED + index),
JmolConstants.argbsFormalCharge[index]);
case JmolConstants.PALETTE_TEMP:
case JmolConstants.PALETTE_FIXEDTEMP:
if (pid == JmolConstants.PALETTE_TEMP) {
modelSet = viewer.getModelSet();
lo = modelSet.getBfactor100Lo();
hi = modelSet.getBfactor100Hi();
} else {
lo = 0;
hi = 100 * 100; // scaled by 100
}
return propertyColorEncoder.getColorIndexFromPalette(
atom.getBfactor100(), lo, hi, ColorEncoder.BWR, false);
case JmolConstants.PALETTE_STRAIGHTNESS:
return propertyColorEncoder.getColorIndexFromPalette(atom
.getGroupParameter(Token.straightness), -1, 1, ColorEncoder.BWR,
false);
case JmolConstants.PALETTE_SURFACE:
hi = viewer.getSurfaceDistanceMax();
return propertyColorEncoder.getColorIndexFromPalette(atom
.getSurfaceDistance100(), 0, hi, ColorEncoder.BWR, false);
case JmolConstants.PALETTE_AMINO:
return propertyColorEncoder.getColorIndexFromPalette(atom.getGroupID(),
0, 0, ColorEncoder.AMINO, false);
case JmolConstants.PALETTE_SHAPELY:
return propertyColorEncoder.getColorIndexFromPalette(atom.getGroupID(),
0, 0, ColorEncoder.SHAPELY, false);
case JmolConstants.PALETTE_GROUP:
// viewer.calcSelectedGroupsCount() must be called first ...
// before we call getSelectedGroupCountWithinChain()
// or getSelectedGropuIndexWithinChain
// however, do not call it here because it will get recalculated
// for each atom
// therefore, we call it in Eval.colorObject();
return propertyColorEncoder.getColorIndexFromPalette(atom
.getSelectedGroupIndexWithinChain(), 0, atom
.getSelectedGroupCountWithinChain() - 1, ColorEncoder.BGYOR, false);
case JmolConstants.PALETTE_POLYMER:
Model m = viewer.getModelSet().getModels()[atom.modelIndex];
return propertyColorEncoder.getColorIndexFromPalette(atom
.getPolymerIndexInModel(), 0, m.getBioPolymerCount() - 1,
ColorEncoder.BGYOR, false);
case JmolConstants.PALETTE_MONOMER:
// viewer.calcSelectedMonomersCount() must be called first ...
return propertyColorEncoder.getColorIndexFromPalette(atom
.getSelectedMonomerIndexWithinPolymer(), 0, atom
.getSelectedMonomerCountWithinPolymer() - 1, ColorEncoder.BGYOR,
false);
case JmolConstants.PALETTE_MOLECULE:
modelSet = viewer.getModelSet();
return propertyColorEncoder.getColorIndexFromPalette(modelSet
.getMoleculeIndex(atom.getIndex()), 0, modelSet
.getMoleculeCountInModel(atom.getModelIndex()) - 1,
ColorEncoder.ROYGB, false);
case JmolConstants.PALETTE_ALTLOC:
modelSet = viewer.getModelSet();
//very inefficient!
modelIndex = atom.getModelIndex();
return propertyColorEncoder
.getColorIndexFromPalette(modelSet.getAltLocIndexInModel(modelIndex,
atom.getAlternateLocationID()), 0, modelSet
.getAltLocCountInModel(modelIndex), ColorEncoder.ROYGB, false);
case JmolConstants.PALETTE_INSERTION:
modelSet = viewer.getModelSet();
//very inefficient!
modelIndex = atom.getModelIndex();
return propertyColorEncoder.getColorIndexFromPalette(modelSet
.getInsertionCodeIndexInModel(modelIndex, atom.getInsertionCode()),
0, modelSet.getInsertionCountInModel(modelIndex), ColorEncoder.ROYGB,
false);
case JmolConstants.PALETTE_JMOL:
id = atom.getAtomicAndIsotopeNumber();
argb = getJmolOrRasmolArgb(id, Token.jmol);
break;