/** Draw atom */ void drawAtom(Graphics g, int iz) { int i = zOrder[iz]; Atom atom = atoms[i]; if (atom == null) return; double zMin = screenXYZ[zOrder[0]][2]; // fartherest from the viewer double zMax = screenXYZ[zOrder[np - 1]][2]; // closest to the viewer int greyScale = Atom.nBalls - 1; if (zMin != zMax) // zMin == zMax means the two-dimensional case greyScale = (int) (Atom.nBalls * (screenXYZ[i][2] - zMin) / (zMax - zMin) - 1e-6); // the atom closest to the viewer has a greyScale of Atom.nBalls - 1 // the atom fartherest from the viewer has a greyScale of 0 double radius = ballSize * atom.relRadius * real2Screen; atom.paint(g, screenXYZ[i][0], screenXYZ[i][1], greyScale, radius); }