public void centerResidues() { double globalCenterX = 0d; double globalCenterY = 0d; double globalCenterZ = 0d; int count = 0; for (Residue res : residueList) { for (Atom atom : res.getAtomList()) { globalCenterX += atom.getCoordinates()[0]; globalCenterY += atom.getCoordinates()[1]; globalCenterZ += atom.getCoordinates()[2]; } count += res.getAtomList().size(); } globalCenterX /= count; globalCenterY /= count; globalCenterZ /= count; for (Node node : root.pdbObjects.getChildren()) { node.setTranslateX(node.getTranslateX() - globalCenterX); node.setTranslateY(node.getTranslateY() - globalCenterY); node.setTranslateZ(node.getTranslateZ() - globalCenterZ); } }