private void createNewStage(int level, Stage owner, boolean onTop) {
    Stage stage = new Stage();
    stage.initOwner(owner);
    stage.setTitle(level == 0 ? "Root" : "Child " + level);
    stage.setAlwaysOnTop(onTop);

    VBox root = new VBox(15);
    root.setPadding(new Insets(20));
    Scene scene = new Scene(root);
    stage.setScene(scene);

    ToggleButton onTopButton = new ToggleButton(onTop ? DISABLE_ON_TOP : ENABLE_ON_TOP);
    onTopButton.setSelected(onTop);

    stage
        .alwaysOnTopProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              onTopButton.setSelected(newValue);
              onTopButton.setText(newValue ? DISABLE_ON_TOP : ENABLE_ON_TOP);
            });

    onTopButton.setOnAction(event -> stage.setAlwaysOnTop(!stage.isAlwaysOnTop()));

    CheckBox box = new CheckBox("Child stage always on top");
    box.setSelected(true);
    Button newStageButton = new Button("Open child stage");

    newStageButton.setOnAction(event -> createNewStage(level + 1, stage, box.isSelected()));

    root.getChildren().addAll(onTopButton, box, newStageButton);

    stage.show();
  }
Exemplo n.º 2
0
  private void displayConnectionPopup(Stage primaryStage) {
    Stage connectStage;

    connectStage = new Stage();
    connectStage.initModality(Modality.WINDOW_MODAL);
    connectStage.setScene(new Scene(new FxmlLoadable("/erlyberly/connection.fxml").load()));
    connectStage.setAlwaysOnTop(true);

    // javafx vertical resizing is laughably ugly, lets just disallow it
    connectStage.setResizable(false);
    connectStage.setWidth(400);

    // if the user closes the window without connecting then close the app
    connectStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent e) {
            if (!nodeAPI.connectedProperty().get()) {
              Platform.exit();
            }

            Platform.runLater(
                () -> {
                  primaryStage.setResizable(true);
                });
          }
        });

    connectStage.show();
  }
Exemplo n.º 3
0
  @FXML
  private void handleAction(ActionEvent event) {
    TextArea textarea = (TextArea) menuBar.getScene().lookup("#textarea");

    if (event.getSource() == chmiWordWrap) {
      wordWrapOn = chmiWordWrap.isSelected();
      textarea.setWrapText(wordWrapOn);

    } else if (event.getSource() == miChangeCase) {
      try {
        if (changeCaseDialog == null) {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ChangeCaseDialog.fxml"));
          Parent root = fxmlLoader.load();
          controller = fxmlLoader.getController();
          controller.setSelectedCase(prefs.get(strSelectedCase, "UPPERCASE"));
          changeCaseDialog = new Stage();
          changeCaseDialog.setResizable(false);
          changeCaseDialog.initStyle(StageStyle.UTILITY);
          changeCaseDialog.setAlwaysOnTop(true);
          changeCaseDialog.setX(prefs.getDouble(strChangeCaseX, changeCaseDialog.getX()));
          changeCaseDialog.setY(prefs.getDouble(strChangeCaseY, changeCaseDialog.getY()));
          Scene scene = new Scene(root);
          changeCaseDialog.setScene(scene);
          changeCaseDialog.setTitle("Change Case");
        }

        changeCaseDialog.toFront();
        changeCaseDialog.show();
      } catch (Exception e) {

      }
    } else if (event.getSource() == miRemoveLineBreaks) {
      if (textarea.getSelectedText().length() == 0) {
        textarea.selectAll();

        if (textarea.getSelectedText().length() == 0) {
          return;
        }
      }

      String result = TextUtilities.removeLineBreaks(textarea.getSelectedText());

      int start = textarea.getSelection().getStart();
      textarea.replaceSelection(result);
      textarea.selectRange(start, start + result.length());
    } else if (event.getSource() == miFont) {
      Font font = textarea.getFont();
      FontSelectorDialog dialog = new FontSelectorDialog(font);
      Optional<Font> op = dialog.showAndWait();
      if (op.isPresent()) {
        textarea.setFont(op.get());
      }
    }
  }
Exemplo n.º 4
0
  @Override
  public void start(Stage stage) {
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.setAlwaysOnTop(true);
    VBox box = new VBox();
    imageView = new ImageView(sprites[currentFrame]);

    box.getChildren().add(imageView);
    final Scene scene = new Scene(box, 0, 0);
    Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(currentX);
    stage.setY(currentY);
    scene.setFill(null);
    stage.setScene(scene);
    mainLoop = new Timeline();
    mainLoop.setCycleCount(Animation.INDEFINITE);
    renderFrame =
        new KeyFrame(
            frameDuration,
            new EventHandler<ActionEvent>() {
              public void handle(ActionEvent event) {
                Double currentFrameWidth = sprites[currentFrame].getWidth();
                Double currentFrameHeight = sprites[currentFrame].getHeight();
                stage.setWidth(currentFrameWidth);
                stage.setHeight(currentFrameHeight);
                currentY = screenBounds.getMinY() + screenBounds.getHeight() - currentFrameHeight;

                Double minLimitX = 0.0;
                Double maxLimitX =
                    screenBounds.getMinX() + screenBounds.getWidth() - currentFrameWidth;
                if (currentX >= maxLimitX || currentX <= minLimitX) {
                  velocity = -1 * velocity;
                  currentX = currentX >= maxLimitX ? maxLimitX - 1 : minLimitX + 1;
                  currentWalkingFrame = 0;
                } else {
                  currentX += velocity;
                }

                if (velocity > 0) {
                  currentFrame = walking_right_indexes[currentWalkingFrame];
                } else {
                  currentFrame = walking_left_indexes[currentWalkingFrame];
                }

                stage.setX(currentX);
                stage.setY(currentY);
                imageView.setImage(sprites[currentFrame]);
                currentWalkingFrame = (++currentWalkingFrame) % walking_right_indexes.length;
              }
            });
    mainLoop.getKeyFrames().add(renderFrame);
    stage.show();
    mainLoop.play();
  }
Exemplo n.º 5
0
  @Override
  public void start(Stage stage) throws Exception {
    stage.setTitle("Peppsi");
    stage.setAlwaysOnTop(true);

    FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"));
    Parent root = loader.load();
    initScene(stage, root);

    Controller controller = loader.getController();
    controller.initDropListener(stage);
  }
Exemplo n.º 6
0
  private void showMemoryWarning() {
    Logger.warning("Memory " + (MEMORY_FULL_WARNING_THRESHOLD * 100.0) + "% full.");

    ThreadHelper.runOnFxThread(
        () -> {
          Alert alert = new Alert(AlertType.WARNING);
          alert.setTitle(FxComponent.DEFAULT_RESOURCES.getString("MemoryWarningPane.title"));
          alert.setHeaderText(FxComponent.DEFAULT_RESOURCES.getString("MemoryWarningPane.header"));
          alert.setContentText(
              FxComponent.DEFAULT_RESOURCES.getString("MemoryWarningPane.message"));
          alert.show();
          Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
          stage.toFront();
          stage.setAlwaysOnTop(true);
        });
  }
Exemplo n.º 7
0
  private void updateSelectedEntry() {
    ObservableList<PolizistDaten> Nutzerauswahl = Tabelle.getSelectionModel().getSelectedItems();
    if (Nutzerauswahl.size() != 1) {
      IM.setErrorText("Es muss genau ein Element ausgewählt werden");
      return;
    }
    PolizistDaten Auswahl = Nutzerauswahl.get(0);

    // Jetzt erzeugen wir ein PopUp zum veraendern des Eintrags

    Stage PopUp = new Stage();
    PopUp.initModality(Modality.APPLICATION_MODAL);
    PopUp.setTitle("Neuer Eintrag");
    PopUp.setAlwaysOnTop(true);
    PopUp.setResizable(false);

    GridPane Gitter = new GridPane();
    Gitter.setHgap(10);
    Gitter.setVgap(10);

    Label LabelA = new Label("PersonenID");
    Label LabelAWert = new Label(Integer.toString(Auswahl.getPersonenID()));

    Label LabelB = new Label("Name");
    TextField LabelBWert = new TextField();

    Label LabelC = new Label("Geburtsdatum");
    DatePicker LabelCWert = new DatePicker();

    Label LabelD = new Label("Nationalität");
    TextField LabelDWert = new TextField();

    Label LabelE = new Label("Geschlecht");
    ComboBox LabelEWert = new ComboBox();

    Label LabelF = new Label("Todesdatum");
    DatePicker LabelFWert = new DatePicker();

    Label LabelG = new Label("Dienstgrad");
    TextField LabelGWert = new TextField();

    final Callback<DatePicker, DateCell> TagesZellenFabtrik =
        new Callback<DatePicker, DateCell>() {
          @Override
          public DateCell call(final DatePicker DP) {
            return new DateCell() {
              @Override
              public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if (item.isBefore(LabelCWert.getValue().plusDays(1))) {
                  setDisable(true);
                  setStyle("-fx-background-color: #ffc0cb;");
                }
              }
            };
          }
        };
    LabelFWert.setDayCellFactory(TagesZellenFabtrik);

    LabelEWert.getItems().addAll("m", "w");
    LabelEWert.setValue(Auswahl.getGeschlecht());

    LabelBWert.setText(Auswahl.getName());
    LabelCWert.setValue(LocalDate.parse(Auswahl.getGebDatum())); // TODO exception
    LabelDWert.setText(Auswahl.getNation());
    if (!Auswahl.getTodDatum().isEmpty()) {
      LabelFWert.setValue(LocalDate.parse(Auswahl.getTodDatum())); // TODO exception
    }
    LabelGWert.setText(Auswahl.getDienstgrad());

    Button ButtonFort = new Button("Fortfahren");
    Button ButtonAbb = new Button("Abbrechen");

    ButtonFort.defaultButtonProperty();
    ButtonAbb.cancelButtonProperty();

    ButtonFort.setMaxWidth(Double.MAX_VALUE);
    ButtonAbb.setMaxWidth(Double.MAX_VALUE);

    Gitter.addColumn(0, LabelA, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG);
    Gitter.addColumn(
        1, LabelAWert, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert);

    VBox AussenBox = new VBox(10);
    HBox InnenBox = new HBox();

    AussenBox.setSpacing(10);
    AussenBox.setPadding(new Insets(10));
    InnenBox.setSpacing(10);

    AussenBox.setAlignment(Pos.CENTER);
    InnenBox.setAlignment(Pos.BOTTOM_CENTER);

    AussenBox.getChildren().addAll(Gitter, InnenBox);
    InnenBox.getChildren().addAll(ButtonFort, ButtonAbb);

    ButtonAbb.setOnAction(event -> PopUp.close());
    ButtonFort.setOnAction(
        event -> {
          String SQLString;
          if (LabelFWert.getEditor().getText().isEmpty()) {
            SQLString =
                "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=NULL WHERE PersonenID = "
                    + Auswahl.getPersonenID();
          } else {
            SQLString =
                "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=? WHERE PersonenID = "
                    + Auswahl.getPersonenID();
          }
          try {
            PreparedStatement InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setString(1, LabelBWert.getText());
            InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception
            InsertStatement.setString(3, LabelDWert.getText());
            InsertStatement.setString(4, LabelEWert.getValue().toString());
            if (LabelFWert.getValue() != null && !LabelFWert.getEditor().getText().isEmpty()) {
              InsertStatement.setString(5, LabelFWert.getValue().toString());
            }
            InsertStatement.executeUpdate();
            SQLString =
                "UPDATE POLIZIST SET Dienstgrad = ? WHERE PersonenID = " + Auswahl.getPersonenID();
            InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setString(1, LabelGWert.getText());
            InsertStatement.execute();
            IM.setInfoText("Änderung durchgeführt");
          } catch (SQLException e) {
            IM.setErrorText("Ändern Fehlgeschlagen", e);
          }
          refreshPolizistAnsicht();
          PopUp.close();
        });

    PopUp.setScene(new Scene(AussenBox));
    PopUp.showAndWait();
  }
Exemplo n.º 8
0
  private void insertNewEntry() {
    Stage PopUp = new Stage();
    PopUp.initModality(Modality.APPLICATION_MODAL);
    PopUp.setTitle("Neuer Eintrag");
    PopUp.setAlwaysOnTop(true);
    PopUp.setResizable(false);

    GridPane Gitter = new GridPane();
    Gitter.setHgap(10);
    Gitter.setVgap(10);

    Label LabelB = new Label("Name");
    TextField LabelBWert = new TextField();

    Label LabelC = new Label("Geburtsdatum");
    DatePicker LabelCWert = new DatePicker();

    Label LabelD = new Label("Nationalität");
    TextField LabelDWert = new TextField();

    Label LabelE = new Label("Geschlecht");
    ComboBox LabelEWert = new ComboBox();

    Label LabelF = new Label("Todesdatum");
    DatePicker LabelFWert = new DatePicker();

    Label LabelG = new Label("Dienstgrad");
    TextField LabelGWert = new TextField();

    final Callback<DatePicker, DateCell> TagesZellenFabtrik =
        new Callback<DatePicker, DateCell>() {
          @Override
          public DateCell call(final DatePicker DP) {
            return new DateCell() {
              @Override
              public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if (item.isBefore(LabelCWert.getValue().plusDays(1))) {
                  setDisable(true);
                  setStyle("-fx-background-color: #ffc0cb;");
                }
              }
            };
          }
        };
    LabelFWert.setDayCellFactory(TagesZellenFabtrik);

    LabelEWert.getItems().addAll("m", "w");
    LabelEWert.setValue("m");

    Button ButtonFort = new Button("Fortfahren");
    Button ButtonAbb = new Button("Abbrechen");

    ButtonFort.defaultButtonProperty();
    ButtonAbb.cancelButtonProperty();

    ButtonFort.setMaxWidth(Double.MAX_VALUE);
    ButtonAbb.setMaxWidth(Double.MAX_VALUE);

    Gitter.addColumn(0, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG);
    Gitter.addColumn(1, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert);

    VBox AussenBox = new VBox(10);
    HBox InnenBox = new HBox();

    AussenBox.setSpacing(10);
    AussenBox.setPadding(new Insets(10));
    InnenBox.setSpacing(10);

    AussenBox.setAlignment(Pos.CENTER);
    InnenBox.setAlignment(Pos.BOTTOM_CENTER);

    AussenBox.getChildren().addAll(Gitter, InnenBox);
    InnenBox.getChildren().addAll(ButtonFort, ButtonAbb);

    ButtonAbb.setOnAction(event -> PopUp.close());
    ButtonFort.setOnAction(
        event -> {
          String SQLString;
          if (LabelFWert.getValue() != null) {
            SQLString =
                "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht, Todesdatum) VALUES (?, ?, ?, ?, ?)";
          } else {
            SQLString =
                "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht) VALUES (?, ?, ?, ?)";
          }
          try {
            PreparedStatement InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setString(1, LabelBWert.getText());
            InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception
            InsertStatement.setString(3, LabelDWert.getText());
            InsertStatement.setString(4, LabelEWert.getValue().toString());
            if (LabelFWert.getValue() != null) {
              InsertStatement.setString(5, LabelFWert.getValue().toString()); // TODO exception
            }
            InsertStatement.executeUpdate();
            ResultSet PersID = DH.getAnfrageObjekt().executeQuery("SELECT last_insert_rowid();");
            if (!PersID.next()) {
              IM.setErrorText("Konnte Primärschlüssel nicht mehr bestimmen.");
            }
            SQLString = "INSERT INTO POLIZIST (PersonenID, Dienstgrad) VALUES (?, ?)";
            InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setInt(1, PersID.getInt(1)); // TODO das hier verifizieren
            InsertStatement.setString(2, LabelGWert.getText());
            InsertStatement.executeUpdate();
            IM.setInfoText("Einfügen durchgeführt");
          } catch (SQLException e) {
            IM.setErrorText("Einfügen Fehlgeschlagen", e);
          }
          refreshPolizistAnsicht();
          PopUp.close();
        });

    PopUp.setScene(new Scene(AussenBox));
    PopUp.showAndWait();
  }
Exemplo n.º 9
0
  @FXML
  private void handleAction(ActionEvent event) {
    List<IIOImage> iioImageList = GuiController.getInstance().iioImageList;
    List<BufferedImage> imageList = GuiController.getInstance().imageList;
    int imageIndex = GuiController.getInstance().imageIndex;
    if (iioImageList == null
        && (event.getSource() != chmiScreenshotMode)
        && event.getSource() != chmiSegmentedRegions) {
      Alert alert =
          new Alert(Alert.AlertType.INFORMATION, bundle.getString("Please_load_an_image."));
      alert.show();
      return;
    }

    if (event.getSource() == miMetadata) {
      try {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ImageInfoDialog.fxml"));
        Parent root = fxmlLoader.load();
        ImageInfoDialogController controller = fxmlLoader.getController();
        controller.setImage(iioImageList.get(imageIndex));
        Stage imageInfoDialog = new Stage();
        imageInfoDialog.setResizable(false);
        imageInfoDialog.initStyle(StageStyle.UTILITY);
        imageInfoDialog.setAlwaysOnTop(true);
        //            imageInfoDialog.setX(prefs.getDouble(strChangeCaseX, imageInfoDialog.getX()));
        //            imageInfoDialog.setY(prefs.getDouble(strChangeCaseY, imageInfoDialog.getY()));
        Scene scene1 = new Scene(root);
        imageInfoDialog.setScene(scene1);
        imageInfoDialog.setTitle("Image Properties");
        imageInfoDialog.toFront();
        imageInfoDialog.show();
      } catch (Exception e) {

      }
    } else if (event.getSource() == miAutocrop) {
      menuBar.getScene().setCursor(Cursor.WAIT);

      originalImage = (BufferedImage) iioImageList.get(imageIndex).getRenderedImage();
      BufferedImage croppedImage =
          net.sourceforge.vietocr.util.ImageHelper.autoCrop(originalImage, 0.1);
      // if same image, skip
      if (originalImage != croppedImage) {
        stack.push(originalImage);
        imageList.set(imageIndex, croppedImage);
        iioImageList.get(imageIndex).setRenderedImage((BufferedImage) croppedImage);
        GuiController.getInstance().loadImage();
      }

      menuBar.getScene().setCursor(Cursor.DEFAULT);
    } else if (event.getSource() == miBrightness) {

    } else if (event.getSource() == miContrast) {

    } else if (event.getSource() == miDeskew) {
      menuBar.getScene().setCursor(Cursor.WAIT);

      Platform.runLater(
          new Runnable() {
            @Override
            public void run() {
              ImageDeskew deskew =
                  new ImageDeskew((BufferedImage) iioImageList.get(imageIndex).getRenderedImage());
              double imageSkewAngle = deskew.getSkewAngle();

              if ((imageSkewAngle > MINIMUM_DESKEW_THRESHOLD
                  || imageSkewAngle < -(MINIMUM_DESKEW_THRESHOLD))) {
                originalImage = (BufferedImage) iioImageList.get(imageIndex).getRenderedImage();
                stack.push(originalImage);
                BufferedImage rotatedImage =
                    rotateImage(originalImage, Math.toRadians(-imageSkewAngle));
                imageList.set(imageIndex, rotatedImage); // persist the rotated image
                iioImageList.get(imageIndex).setRenderedImage(rotatedImage);
                GuiController.getInstance().loadImage();
              }
              menuBar.getScene().setCursor(Cursor.DEFAULT);
            }
          });
    } else if (event.getSource() == miGrayscale) {

    } else if (event.getSource() == miInvert) {

    } else if (event.getSource() == miMonochrome) {

    } else if (event.getSource() == miSharpen) {

    } else if (event.getSource() == miSmooth) {

    } else if (event.getSource() == miUndo) {
      if (stack.isEmpty()) {
        return;
      }
      BufferedImage image = stack.pop();
      imageList.set(imageIndex, image);
      iioImageList.get(imageIndex).setRenderedImage(image);
      GuiController.getInstance().loadImage();
    } else if (event.getSource() == chmiScreenshotMode) {
      Label labelScreenShotMode = (Label) menuBar.getScene().lookup("#labelScreenShotMode");
      labelScreenShotMode.setText(this.chmiScreenshotMode.isSelected() ? "On" : "Off");
    } else if (event.getSource() == chmiSegmentedRegions) {
      Node segmentedRegionsBox = menuBar.getScene().lookup("#segmentedRegionsBox");
      segmentedRegionsBox.setVisible(chmiSegmentedRegions.isSelected());
    }
  }