@FXML
  private void onOkButtonClicked() {

    if (!headerTextField.getText().isEmpty() || picturePreview.getImage() != null) {
      HTMLHeader header;
      if (!headerTextField.getText().isEmpty() && picturePreview.getImage() == null) {
        header = new HTMLHeader(headerTextField.getText());
        System.out.println("Header only has text.");
      } else if (headerTextField.getText().isEmpty() && picturePreview.getImage() != null) {
        header = new HTMLHeader(picturePreview.getImage());
        System.out.println("Header only has image.");
      } else {
        header = new HTMLHeader(headerTextField.getText(), picturePreview.getImage());
        System.out.println("Header has both image and text.");
      }

      ApplicationManager.getInstance().setWebPageHeader(header);
      System.out.println("Attempting to set header to webpage.");
      // --------------------Added By James------------------------------------------------
      // JavaToHTML HTML = new JavaToHTML();
      // ApplicationManager.getInstance().getHtmlGenerator().setHeaderFromGUI(headerTextField.getText(),picturePath.getText());
      // writeAndRefresh();
      // --------------------End Added By James------------------------------------------------
    } else {
      System.out.println("Header has nothing. Not creating an object.");
    }
    Stage stage = (Stage) okButton.getScene().getWindow();

    stage.close();
  }
  @FXML
  void dragDetected(MouseEvent event) {
    /* drag was detected, start drag-and-drop gesture*/

    /* allow any transfer mode */
    Dragboard db = imageView.startDragAndDrop(TransferMode.ANY);

    /* put a string on dragboard */
    ClipboardContent content = new ClipboardContent();
    content.putImage(imageView.getImage());
    db.setContent(content);

    event.consume();
  }
Пример #3
0
  /**
   * Computes the actual scaling of an Image in an ImageView. If the preserveRatio property on the
   * ImageView is false the scaling has no meaning so NaN is returned.
   *
   * @return The scale factor of the image in relation to display coordinates
   */
  public double computeActualScale() {

    if (!imageView.isPreserveRatio()) {
      actualScale = Double.NaN;
    } else if (doScaleRecompute) {
      Image localImage = imageView.getImage();
      Rectangle2D localViewport = imageView.getViewport();

      double w = 0;
      double h = 0;
      if (localViewport != null && localViewport.getWidth() > 0 && localViewport.getHeight() > 0) {
        w = localViewport.getWidth();
        h = localViewport.getHeight();
      } else if (localImage != null) {
        w = localImage.getWidth();
        h = localImage.getHeight();
      }

      double localFitWidth = imageView.getFitWidth();
      double localFitHeight = imageView.getFitHeight();

      if (w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) {
        if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) {
          w = w * localFitHeight / h;
        } else {
          w = localFitWidth;
        }

        actualScale = w / localImage.getWidth();
      }

      doScaleRecompute = false;
    }

    return actualScale;
  }
 public Image getImage() {
   return car.getImage();
 }
Пример #5
0
 public void changeSize(int newSize) {
   size = newSize;
   imageView.setImage(Config.getImages().get(Config.IMAGE_BALL_0 + size));
   diameter = (int) imageView.getImage().getWidth() - Config.SHADOW_WIDTH;
 }
Пример #6
0
 /**
  * If the given <i>icon</i> is an {@link Image}, that {@link Image} will be used as the icon of
  * this {@link NodeContentPart}.
  *
  * @param visual The visual of this {@link NodeContentPart}.
  * @param icon The new icon for this {@link NodeContentPart}.
  */
 protected void refreshIcon(Group visual, Object icon) {
   if (iconImageView.getImage() != icon && icon instanceof Image) {
     iconImageView.setImage((Image) icon);
   }
 }
  @Override
  public void start(Stage stage) {
    // stage.initStyle(StageStyle.UNDECORATED);
    stage.setTitle("Hello Image Clipboard");
    Scene scene = new Scene(new Group(), 1024, 768);
    scene.setFill(Color.LIGHTGREEN);

    Rectangle overlay = new Rectangle();
    overlay.setWidth(800);
    overlay.setHeight(600);
    overlay.setFill(Color.TRANSPARENT);
    EventHandler<DragEvent> drop = de -> checkBoard(de.getDragboard(), de);

    EventHandler<DragEvent> enter =
        de -> {
          if (de != null && de.getDragboard() != null && de.getDragboard().hasImage()) {
            de.acceptTransferModes(TransferMode.ANY);
          }
        };

    EventHandler<DragEvent> dragged =
        de -> {
          if (de != null && de.getDragboard() != null && de.getDragboard().hasImage()) {
            de.acceptTransferModes(TransferMode.ANY);
          }
        };

    overlay.setOnDragDropped(drop);
    overlay.setOnDragEntered(enter);
    overlay.setOnDragOver(dragged);

    clearBtn = new Button("Clear");
    clearBtn.setTranslateX(50);
    clearBtn.setTranslateY(30);

    copyBtn = new Button("Copy");
    copyBtn.setTranslateX(125);
    copyBtn.setTranslateY(30);

    pasteBtn = new Button("Paste");
    pasteBtn.setTranslateX(200);
    pasteBtn.setTranslateY(30);

    clearBtn.setOnAction(e -> clear());
    copyBtn.setOnAction(
        e -> {
          ClipboardContent content = new ClipboardContent();
          content.putImage(imageView.getImage());
          Clipboard.getSystemClipboard().setContent(content);
        });
    pasteBtn.setOnAction(e -> checkBoard(Clipboard.getSystemClipboard(), null));

    Group root = (Group) scene.getRoot();
    root.getChildren().add(overlay);
    root.getChildren().add(imageView);
    root.getChildren().add(clearBtn);
    root.getChildren().add(copyBtn);
    root.getChildren().add(pasteBtn);

    stage.setScene(scene);
    stage.show();
  }
Пример #8
0
  /**
   * @param owner
   * @param title
   * @param titleLong
   * @param message
   * @return
   */
  public Response show(Stage owner, String title, String titleLong, String message) {
    final Stage stage = new Stage();

    final BooleanProperty isOK = new SimpleBooleanProperty(false);

    stage.setTitle(title);
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initOwner(owner);

    //        BorderPane root = new BorderPane();
    VBox root = new VBox();

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setWidth(500);
    stage.setHeight(250);
    stage.initStyle(StageStyle.UTILITY);
    stage.setResizable(false);

    Node header = DialogHeader.getDialogHeader(ICON, titleLong);

    ImageView imageView = ResourceLoader.getImage(ICON, 65, 65);
    stage.getIcons().add(imageView.getImage());

    HBox buttonPanel = new HBox();

    Button ok = new Button("OK");
    ok.setDefaultButton(true);

    buttonPanel.getChildren().addAll(ok);
    buttonPanel.setAlignment(Pos.CENTER_RIGHT);
    buttonPanel.setPadding(new Insets(10, 10, 10, 10));
    buttonPanel.setSpacing(10);
    buttonPanel.setMaxHeight(25);

    HBox messagePanel = new HBox();
    messagePanel.setPadding(new Insets(30, 30, 30, 30));

    Label mewssage = new Label(message);
    messagePanel.getChildren().add(mewssage);
    mewssage.setWrapText(true);
    mewssage.setAlignment(Pos.CENTER_LEFT);

    Separator sep = new Separator(Orientation.HORIZONTAL);
    sep.setMinHeight(10);

    root.getChildren()
        .addAll(header, new Separator(Orientation.HORIZONTAL), messagePanel, buttonPanel);
    VBox.setVgrow(messagePanel, Priority.ALWAYS);
    VBox.setVgrow(buttonPanel, Priority.NEVER);
    VBox.setVgrow(header, Priority.NEVER);

    ok.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            //                System.out.println("Size: h:" + stage.getHeight() + " w:" +
            // stage.getWidth());
            stage.close();
            //                isOK.setValue(true);
            response = Response.OK;
          }
        });

    stage.showAndWait();

    return response;
  }
 private void applyImageScale() {
   rpImageView.setFitWidth(rpImageView.getImage().getWidth() * imageScale);
   rpImageView.setFitHeight(rpImageView.getImage().getHeight() * imageScale);
 }