コード例 #1
0
  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);
    }
  }
コード例 #2
0
  private static SubScene createSubScene(
      String title, Node node, Paint fillPaint, Camera camera, boolean msaa) {
    Group root = new Group();

    PointLight light = new PointLight(Color.WHITE);
    light.setTranslateX(50);
    light.setTranslateY(-300);
    light.setTranslateZ(-400);
    PointLight light2 = new PointLight(Color.color(0.6, 0.3, 0.4));
    light2.setTranslateX(400);
    light2.setTranslateY(0);
    light2.setTranslateZ(-400);

    AmbientLight ambientLight = new AmbientLight(Color.color(0.2, 0.2, 0.2));
    node.setRotationAxis(new Point3D(2, 1, 0).normalize());
    node.setTranslateX(180);
    node.setTranslateY(180);
    root.getChildren().addAll(setTitle(title), ambientLight, light, light2, node);

    SubScene subScene =
        new SubScene(
            root, 500, 400, true, msaa ? SceneAntialiasing.BALANCED : SceneAntialiasing.DISABLED);
    subScene.setFill(fillPaint);
    subScene.setCamera(camera);

    return subScene;
  }