Пример #1
0
  public void openImageFile(Resource resource) {
    Tab tab = new Tab();
    tab.setClosable(true);
    if (resource == null) {
      Dialogs.create()
          .owner(tabPane)
          .title("Datei nicht vorhanden")
          .message(
              "Die angeforderte Datei ist nicht vorhanden und kann deshalb nicht geöffnet werden.")
          .showError();
      return;
    }
    tab.setText(resource.getFileName());

    ImageResource imageResource = (ImageResource) resource;
    ImageViewerPane pane = new ImageViewerPane();
    pane.setImageResource(imageResource);

    ImageView imageView = pane.getImageView();
    imageView.setImage(imageResource.asNativeFormat());
    imageView.setFitHeight(-1);
    imageView.setFitWidth(-1);

    Label imagePropertiesLabel = pane.getImagePropertiesLabel();
    imagePropertiesLabel.setText(imageResource.getImageDescription());

    tab.setContent(pane);
    tab.setUserData(resource);
    tabPane.getTabs().add(tab);
    tabPane.getSelectionModel().select(tab);
  }
Пример #2
0
  public void refreshImageViewer(Resource resourceToUpdate) {
    List<Tab> tabs = tabPane.getTabs();
    for (Tab tab : tabs) {
      Resource resource = (Resource) tab.getUserData();
      if (resourceToUpdate.equals(resource)) {
        ImageResource imageResource = (ImageResource) resourceToUpdate;
        logger.info("refreshing image resource");
        ImageViewerPane imageViewerPane = (ImageViewerPane) tab.getContent();
        ImageView imageView = imageViewerPane.getImageView();
        imageView.setImage(imageResource.asNativeFormat());
        imageView.setFitHeight(-1);
        imageView.setFitWidth(-1);

        Label imagePropertiesLabel = imageViewerPane.getImagePropertiesLabel();
        imagePropertiesLabel.setText(imageResource.getImageDescription());
      }
    }
  }