protected Node getContentNode() {
    Node taskView = getTaskView();

    if (SettingsUtil.loadSettings().isShowStatistics()) {
      LOGGER.debug("Statistics enabled in settings");
      statisticsView = new VBox(20);

      // wrap statistics in scrollpane
      ScrollPane scrollPane = new ScrollPane(statisticsView);
      scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
      scrollPane.setFitToWidth(true);
      scrollPane.setPadding(new Insets(7));

      // both statistics and task view present
      // show both in a split pane
      SplitPane splitPane = new SplitPane();
      splitPane.setOrientation(Orientation.HORIZONTAL);
      splitPane.setDividerPosition(0, 0.8);
      splitPane.getItems().addAll(taskView, scrollPane);
      return splitPane;
    } else {
      LOGGER.debug("Statistics disabled in settings");
      return taskView;
    }
  }
예제 #2
0
  public void addImageTab(Path imagePath) {

    TabPane previewTabPane = controller.getPreviewTabPane();

    ImageTab tab = new ImageTab();
    tab.setPath(imagePath);
    tab.setText(imagePath.getFileName().toString());

    if (previewTabPane.getTabs().contains(tab)) {
      previewTabPane.getSelectionModel().select(tab);
      return;
    }

    Image image = new Image(IOHelper.pathToUrl(imagePath));
    ImageView imageView = new ImageView(image);
    imageView.setPreserveRatio(true);

    imageView.setFitWidth(previewTabPane.getWidth());

    previewTabPane
        .widthProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              imageView.setFitWidth(previewTabPane.getWidth());
            });

    Tooltip tip = new Tooltip(imagePath.toString());
    Tooltip.install(tab.getGraphic(), tip);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setContent(imageView);
    scrollPane.addEventFilter(
        ScrollEvent.SCROLL,
        e -> {
          if (e.isControlDown() && e.getDeltaY() > 0) {
            // zoom in
            imageView.setFitWidth(imageView.getFitWidth() + 16.0);
          } else if (e.isControlDown() && e.getDeltaY() < 0) {
            // zoom out
            imageView.setFitWidth(imageView.getFitWidth() - 16.0);
          }
        });

    tab.setContent(scrollPane);

    TabPane tabPane = previewTabPane;
    tabPane.getTabs().add(tab);
    tabPane.getSelectionModel().select(tab);
  }