From: <mig...@us...> - 2006-03-13 02:57:29
|
Revision: 4585 Author: migueljmol Date: 2006-03-12 18:57:25 -0800 (Sun, 12 Mar 2006) ViewCVS: http://svn.sourceforge.net/jmol/?rev=4585&view=rev Log Message: ----------- more pruning and getting rid of java.awt.Color Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/ColorManager.java trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/viewer/ColorManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2006-03-13 02:23:19 UTC (rev 4584) +++ trunk/Jmol/src/org/jmol/viewer/ColorManager.java 2006-03-13 02:57:25 UTC (rev 4585) @@ -44,8 +44,8 @@ System.out.println("setting color scheme to:" + colorScheme); if (colorScheme.equals("jmol")) { argbsCpk = JmolConstants.argbsCpk; - viewer.setColorBackground(Color.black); - viewer.setShapeColorProperty(JmolConstants.SHAPE_DOTS, null); + viewer.setColorBackground("black"); + viewer.setShapeColorProperty(JmolConstants.SHAPE_DOTS, 0); } else if (colorScheme.equals("rasmol")) { copyArgbsCpk(); int argb = JmolConstants.argbsCpkRasmol[0] | 0xFF000000; @@ -57,9 +57,8 @@ argb |= 0xFF000000; argbsCpk[atomNo] = argb; } - viewer.setColorBackground(Color.black); - setMeasurementColix(Graphics3D.WHITE); - viewer.setShapeColorProperty(JmolConstants.SHAPE_DOTS, null); + viewer.setColorBackground("black"); + viewer.setShapeColorProperty(JmolConstants.SHAPE_DOTS, 0); } else { System.out.println("unrecognized color scheme"); return; @@ -87,22 +86,10 @@ } short colixRubberband = Graphics3D.HOTPINK; - - void setColorRubberband(Color color) { - if (color == null) - color = Color.pink; - colixRubberband = Graphics3D.getColix(color); + void setRubberbandArgb(int argb) { + colixRubberband = (argb == 0 ? 0 : Graphics3D.getColix(argb)); } - short colixMeasurement = 0; - void setMeasurementArgb(int argb) { - colixMeasurement = Graphics3D.getColix(argb); - } - - void setMeasurementColix(short colix) { - colixMeasurement = colix; - } - short colixBackground = Graphics3D.BLACK; void setBackgroundArgb(int argb) { colixBackground = Graphics3D.getColix(argb | 0xFF000000); @@ -297,14 +284,13 @@ flushCaches(); } - void setElementColor(int elementNumber, Color color) { - int argb; - if (color == null) { + void setElementArgb(int elementNumber, int argb) { + if (argb == 0) { if (argbsCpk == JmolConstants.argbsCpk) return; argb = JmolConstants.argbsCpk[elementNumber]; } else - argb = color.getRGB() | 0xFF000000; + argb |= 0xFF000000; if (argbsCpk == JmolConstants.argbsCpk) copyArgbsCpk(); argbsCpk[elementNumber] = argb; Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-03-13 02:23:19 UTC (rev 4584) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-03-13 02:57:25 UTC (rev 4585) @@ -1545,6 +1545,14 @@ return new Color(statement[itoken].intValue); } + int getArgbParam(int itoken) throws ScriptException { + if (itoken >= statementLength) + colorExpected(); + if (statement[itoken].tok != Token.colorRGB) + colorExpected(); + return statement[itoken].intValue; + } + Color getColorOrNoneParam(int itoken) throws ScriptException { if (itoken >= statementLength) colorExpected(); @@ -1555,12 +1563,22 @@ return null; } + int getArgbOrNoneParam(int itoken) throws ScriptException { + if (itoken >= statementLength) + colorExpected(); + if (statement[itoken].tok == Token.colorRGB) + return statement[itoken].intValue; + if (statement[itoken].tok != Token.none) + colorExpected(); + return 0; + } + void background() throws ScriptException { if (statementLength < 2 || statementLength > 3) badArgumentCount(); int tok = statement[1].tok; if (tok == Token.colorRGB) - viewer.setColorBackground(getColorParam(1)); + viewer.setBackgroundArgb(getArgbParam(1)); else viewer.setShapeProperty(getShapeType(tok), "bgcolor", getColorOrNoneParam(2)); @@ -1598,10 +1616,10 @@ colorObject(Token.atom, 1); break; case Token.rubberband: - viewer.setColorRubberband(getColorParam(2)); + viewer.setRubberbandArgb(getArgbParam(2)); break; case Token.background: - viewer.setColorBackground(getColorParam(2)); + viewer.setBackgroundArgb(getArgbParam(2)); break; case Token.identifier: case Token.hydrogen: @@ -1626,14 +1644,14 @@ } for (int i = JmolConstants.elementNames.length; --i >= 0;) { if (str.equalsIgnoreCase(JmolConstants.elementNames[i])) { - viewer.setElementColor(i, getColorParam(2)); + viewer.setElementArgb(i, getArgbParam(2)); return; } } for (int i = JmolConstants.alternateElementNames.length; --i >= 0;) { if (str.equalsIgnoreCase(JmolConstants.alternateElementNames[i])) { - viewer.setElementColor(JmolConstants.alternateElementNumbers[i], - getColorParam(2)); + viewer.setElementArgb(JmolConstants.alternateElementNumbers[i], + getArgbParam(2)); return; } } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-03-13 02:23:19 UTC (rev 4584) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-03-13 02:57:25 UTC (rev 4585) @@ -663,16 +663,16 @@ return colorManager.getColixSelection(); } - void setColorRubberband(Color color) { - colorManager.setColorRubberband(color); + void setRubberbandArgb(int argb) { + colorManager.setRubberbandArgb(argb); } short getColixRubberband() { return colorManager.colixRubberband; } - void setElementColor(int elementNumber, Color color) { - colorManager.setElementColor(elementNumber, color); + void setElementArgb(int elementNumber, int argb) { + colorManager.setElementArgb(elementNumber, argb); } float getVectorScale() { @@ -700,24 +700,11 @@ return g3d.getColixArgb(colorManager.colixBackground); } - public void setColorBackground(Color bg) { - setBackgroundArgb(bg == null ? 0 : bg.getRGB()); - refresh(0, "Viewer:setCOlorBackground()"); - } - - public Color getColorBackground() { - return new Color(getBackgroundArgb()); - } - public void setColorBackground(String colorName) { colorManager.setColorBackground(colorName); refresh(0, "Viewer:setColorBackground()"); } - Color getColorFromString(String colorName) { - return Graphics3D.getColorFromString(colorName); - } - int getArgbFromString(String colorName) { return Graphics3D.getArgbFromString(colorName); } @@ -1962,10 +1949,6 @@ refresh(0, "Viewer:setShapeProperty()"); } - void setShapeColorProperty(int shapeType, Color color) { - setShapeProperty(shapeType, "color", color); - } - void setShapeColorProperty(int shapeType, int argb) { setShapeProperty(shapeType, "color", argb == 0 ? null : new Color(argb|0xFF000000)); @@ -1980,24 +1963,12 @@ return modelManager.getShapeProperty(shapeType, propertyName, index); } - Color getShapePropertyAsColor(int shapeID, String propertyName) { - return (Color) getShapeProperty(shapeID, propertyName); - } - int getShapePropertyAsInt(int shapeID, String propertyName) { Object value = getShapeProperty(shapeID, propertyName); return value == null || !(value instanceof Integer) ? Integer.MIN_VALUE : ((Integer) value).intValue(); } - Color getColorShape(int shapeID) { - return (Color) getShapeProperty(shapeID, "color"); - } - - short getColixShape(int shapeID) { - return Graphics3D.getColix(getColorShape(shapeID)); - } - int getShapeID(String shapeName) { for (int i = JmolConstants.SHAPE_MAX; --i >= 0;) if (JmolConstants.shapeClassBases[i].equals(shapeName)) @@ -2007,10 +1978,6 @@ throw new NullPointerException(msg); } - short getColix(Color color) { - return Graphics3D.getColix(color); - } - short getColix(Object object) { return Graphics3D.getColix(object); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |