void colorShape(int shapeType, int itoken) throws ScriptException {
		if (itoken >= statementLength)
			badArgumentCount();
		String translucentOrOpaque = null;
		Object colorvalue = null;
		String colorOrBgcolor = "color";
		int tok = statement[itoken].tok;
		if (tok == Token.background) {
			colorOrBgcolor = "bgcolor";
			++itoken;
			tok = statement[itoken].tok;
		}
		if (tok == Token.translucent || tok == Token.opaque) {
			translucentOrOpaque = (String) (statement[itoken].value);
			++itoken;
		}
		String modifier = "";
		if (shapeType < 0) {
			// geosurface
			shapeType = -shapeType;
			modifier = "Surface";
		}
		if (itoken < statementLength) {
			tok = statement[itoken].tok;
			if (tok == Token.colorRGB) {
				int argb = getArgbParam(itoken);
				colorvalue = (argb == 0 ? null : new Integer(argb));
			}
			else {
				// "cpk" value would be "spacefill"
				byte pid = (tok == Token.cpk ? JmolConstants.PALETTE_CPK : JmolConstants
						.getPaletteID((String) statement[itoken].value));
				if (pid == JmolConstants.PALETTE_UNKNOWN || pid == JmolConstants.PALETTE_TYPE
						&& shapeType != JmolConstants.SHAPE_HSTICKS)
					invalidArgument();
				colorvalue = new Byte(pid);
			}
			// ok, the following five options require precalculation.
			// the state must not save them as paletteIDs, only as pure
			// color values.

			switch (tok) {
			case Token.surfacedistance:
				if (viewer.getFrame().getSurfaceDistanceMax() == 0)
					dots(statementLength, Dots.DOTS_MODE_CALCONLY);
				break;
			case Token.temperature:
				if (viewer.isRangeSelected())
					viewer.clearBfactorRange();
				break;
			case Token.group:
				viewer.calcSelectedGroupsCount();
				break;
			case Token.monomer:
				viewer.calcSelectedMonomersCount();
				break;
			case Token.molecule:
				viewer.calcSelectedMoleculesCount();
				break;
			}
			viewer.loadShape(shapeType);
			if (shapeType == JmolConstants.SHAPE_STICKS)
				viewer.setShapeProperty(shapeType, colorOrBgcolor + modifier, colorvalue, viewer
						.getSelectedAtomsOrBonds());
			else viewer.setShapeProperty(shapeType, colorOrBgcolor + modifier, colorvalue);
		}
		if (translucentOrOpaque != null)
			viewer.setShapeProperty(shapeType, "translucency" + modifier, translucentOrOpaque);
	}