public Controller(View root, Stage stage) {
    this.root = root;

    root.openFile.setOnAction(
        (value) -> {
          root.pdbObjects.getChildren().clear();
          File file = root.fileChooser.showOpenDialog(stage);
          readPDB(file.getAbsolutePath());
          root.fileLabel.setText(file.getName());
        });

    scene = new Scene(root, 700, 700, true);
    root.threeDView.widthProperty().bind(scene.widthProperty());
    root.threeDView.heightProperty().bind(Bindings.add(-50.0, scene.heightProperty()));

    scene.setOnMousePressed(
        (event) -> {
          mouseStartX = event.getSceneX();
          mouseStartY = event.getSceneY();
        });

    scene.setOnMouseDragged(
        (event) -> {
          double deltaX = event.getSceneX() - mouseStartX;
          double deltaY = event.getSceneY() - mouseStartY;
          if (event.isShiftDown()) {
            root.camera.setTranslateZ(root.getTranslateZ() + deltaY * 10);
          } else {
            worldRotateY.setAngle(deltaX);
            worldRotateZ.setAngle(deltaY);
          }
        });
  }
Beispiel #2
0
 private void rotateNeedle(final double VALUE) {
   double needleStartAngle = angleRange * 0.5;
   double targetAngle = (VALUE - minValue) * angleStep - needleStartAngle;
   targetAngle = Helper.clamp(-needleStartAngle, -needleStartAngle + angleRange, targetAngle);
   needleRotate.setAngle(targetAngle);
   bar.setLength(-(getSkinnable().getCurrentValue() - minValue) * angleStep);
   setBarColor(VALUE);
 }