Search in sources :

Example 66 with GridPane

use of javafx.scene.layout.GridPane in project POL-POM-5 by PlayOnLinux.

the class AboutPanelSkin method createAboutGrid.

/**
 * Creates the "about" {@link GridPane} containing the application name, version, git revision and build timestamp
 *
 * @return The "about" {@link GridPane} containing the application name, version, git revision and build timestamp
 */
private GridPane createAboutGrid() {
    final GridPane aboutGrid = new GridPane();
    aboutGrid.getStyleClass().add("grid");
    aboutGrid.setHgap(20);
    aboutGrid.setVgap(10);
    final Text nameDescription = new Text(tr("Name:"));
    nameDescription.getStyleClass().add("captionTitle");
    final Label nameLabel = new Label();
    nameLabel.textProperty().bind(Bindings.createStringBinding(() -> Optional.ofNullable(getControl().getBuildInformation()).map(ApplicationBuildInformation::getApplicationName).orElse(null), getControl().buildInformationProperty()));
    aboutGrid.addRow(0, nameDescription, nameLabel);
    final Text versionDescription = new Text(tr("Version:"));
    versionDescription.getStyleClass().add("captionTitle");
    final Label versionLabel = new Label();
    versionLabel.textProperty().bind(Bindings.createStringBinding(() -> Optional.ofNullable(getControl().getBuildInformation()).map(ApplicationBuildInformation::getApplicationVersion).orElse(null), getControl().buildInformationProperty()));
    aboutGrid.addRow(1, versionDescription, versionLabel);
    final Text gitRevisionDescription = new Text(tr("Git Revision:"));
    gitRevisionDescription.getStyleClass().add("captionTitle");
    final Hyperlink gitRevisionHyperlink = createGitRevisionHyperlink();
    aboutGrid.addRow(2, gitRevisionDescription, gitRevisionHyperlink);
    final Text buildTimestampDescription = new Text(tr("Build Timestamp:"));
    buildTimestampDescription.getStyleClass().add("captionTitle");
    final Label buildTimestampLabel = new Label();
    buildTimestampLabel.textProperty().bind(Bindings.createStringBinding(() -> Optional.ofNullable(getControl().getBuildInformation()).map(ApplicationBuildInformation::getApplicationBuildTimestamp).orElse(null), getControl().buildInformationProperty()));
    aboutGrid.addRow(3, buildTimestampDescription, buildTimestampLabel);
    return aboutGrid;
}
Also used : GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text) Hyperlink(javafx.scene.control.Hyperlink)

Example 67 with GridPane

use of javafx.scene.layout.GridPane in project DistributedFractalNetwork by Budder21.

the class GradientMenus method displayOpacityMenu.

/**
 * Creates an opacity display menu and allows the user to edit the opacity data
 * @param button the button whose opacity data is being modified
 * @param gradient the gradient who called this method
 * @return the new opacity value
 */
public static double displayOpacityMenu(ArrowButton button, Window gradient) {
    // TODO this isn't working correctly
    Slider opacityLevel = new Slider(0, 1, (Double) button.getData());
    Label opacityCaption = new Label("Opacity Level:");
    Label opacityValue = new Label(Double.toString(opacityLevel.getValue()));
    opacityValue.setText(String.format("%.2f", opacityLevel.getValue()));
    double prevVal = (double) button.getData();
    Stage window = new Stage();
    window.setTitle("Opacity Picker");
    window.setMinWidth(450);
    window.setMinHeight(100);
    window.initModality(Modality.APPLICATION_MODAL);
    Group root = new Group();
    Scene scene = new Scene(root);
    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(10);
    grid.setHgap(70);
    scene.setRoot(grid);
    GridPane.setConstraints(opacityCaption, 0, 1);
    grid.getChildren().add(opacityCaption);
    opacityLevel.valueProperty().addListener(new ChangeListener<Number>() {

        public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
            button.setData(new_val.doubleValue());
            DecimalFormat df = new DecimalFormat("0.00");
            opacityValue.setText((df.format((double) button.getData())));
            gradient.repaint();
        }
    });
    GridPane.setConstraints(opacityLevel, 1, 1);
    grid.getChildren().add(opacityLevel);
    GridPane.setConstraints(opacityValue, 2, 1);
    grid.getChildren().add(opacityValue);
    Button b = new Button("Submit");
    b.setOnAction(e -> {
        window.close();
    });
    Button d = new Button("Delete");
    d.setOnAction(e -> {
        gradient.getPalette().getOpacityList().remove(button);
        gradient.repaint();
        window.close();
    });
    GridPane.setConstraints(d, 3, 2);
    grid.getChildren().add(d);
    GridPane.setConstraints(b, 2, 2);
    grid.getChildren().add(b);
    window.setOnCloseRequest(e -> {
        button.setData(prevVal);
        gradient.repaint();
    });
    window.setScene(scene);
    window.show();
    return opacityLevel.getValue();
}
Also used : Group(javafx.scene.Group) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Slider(javafx.scene.control.Slider) DecimalFormat(java.text.DecimalFormat) Label(javafx.scene.control.Label) Scene(javafx.scene.Scene) Button(javafx.scene.control.Button) JButton(javax.swing.JButton) Stage(javafx.stage.Stage)

Example 68 with GridPane

use of javafx.scene.layout.GridPane in project DistributedFractalNetwork by Budder21.

the class NetworkCreationTool method displayDialog2.

private Pair<Integer, Integer> displayDialog2() {
    Dialog<Pair<String, String>> dialog2 = new Dialog<>();
    dialog2.setTitle("Create Network");
    dialog2.setHeaderText("Step 2");
    dialog2.setContentText("Choose an image resolution:");
    dialog2.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));
    TextField widthField = new TextField("1920");
    widthField.textProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                widthField.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });
    TextField heightField = new TextField("1080");
    heightField.textProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            if (!newValue.matches("\\d*")) {
                heightField.setText(newValue.replaceAll("[^\\d]", ""));
            }
        }
    });
    grid.add(new Label("Width:"), 0, 0);
    grid.add(widthField, 1, 0);
    grid.add(new Label("Height:"), 0, 1);
    grid.add(heightField, 1, 1);
    dialog2.getDialogPane().setContent(grid);
    dialog2.setResultConverter(dialogButton -> {
        if (dialogButton == ButtonType.OK)
            return new Pair<String, String>(widthField.getText(), heightField.getText());
        return null;
    });
    Optional<Pair<String, String>> result = dialog2.showAndWait();
    int width = 0;
    int height = 0;
    try {
        width = Integer.valueOf(result.get().getKey());
        height = Integer.valueOf(result.get().getValue());
    } catch (NumberFormatException e) {
        AlertMenu aMenu = new AlertMenu("INVALID INPUT: Must be an integer.", "Please try again");
        return displayDialog2();
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return new Pair<Integer, Integer>(width, height);
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) Dialog(javafx.scene.control.Dialog) ChoiceDialog(javafx.scene.control.ChoiceDialog) TextInputDialog(javafx.scene.control.TextInputDialog) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair)

Example 69 with GridPane

use of javafx.scene.layout.GridPane in project DistributedFractalNetwork by Budder21.

the class NetworkCreationTool method getParams.

private Pair<Double, Double> getParams() {
    Dialog<Pair<String, String>> dialog3 = new Dialog<>();
    dialog3.setTitle("Create Network");
    dialog3.setHeaderText("Step 3");
    dialog3.setContentText("Choose Parameters:");
    dialog3.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    GridPane grid = new GridPane();
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(20, 150, 10, 10));
    TextField zoomField = new TextField(".25");
    TextField zoomSpeedField = new TextField("1.05");
    grid.add(new Label("Zoom Level:"), 0, 0);
    grid.add(zoomField, 1, 0);
    grid.add(new Label("Zoom Speed:"), 0, 1);
    grid.add(zoomSpeedField, 1, 1);
    dialog3.getDialogPane().setContent(grid);
    dialog3.setResultConverter(dialogButton -> {
        if (dialogButton == ButtonType.OK)
            return new Pair<String, String>(zoomField.getText(), zoomSpeedField.getText());
        return null;
    });
    Optional<Pair<String, String>> result = dialog3.showAndWait();
    // Traditional way to get the response value.
    Double speed = null;
    try {
        speed = Double.valueOf(result.get().getValue());
    } catch (NumberFormatException e) {
        AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom speed must be a real number.", "Please try again.");
        return getParams();
    } catch (Exception e) {
        return null;
    }
    if (speed <= 0) {
        AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom speed must be greater than 0.", "Please try again");
        return getParams();
    }
    Double zoom = null;
    try {
        zoom = Double.valueOf(result.get().getKey());
    } catch (NumberFormatException e) {
        AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom level must be a real number.", "Please try again.");
        return getParams();
    } catch (Exception e) {
        return null;
    }
    if (zoom <= 0) {
        AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom level must be greater than 0.", "Please try again");
        return getParams();
    }
    return new Pair<Double, Double>(zoom, speed);
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) Dialog(javafx.scene.control.Dialog) ChoiceDialog(javafx.scene.control.ChoiceDialog) TextInputDialog(javafx.scene.control.TextInputDialog) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair)

Example 70 with GridPane

use of javafx.scene.layout.GridPane in project aic-praise by aic-sri-international.

the class FXUtil method exception.

public static void exception(Throwable throwable) {
    System.err.println("Exception being directed to FXUtil.exception, which is not showing anything at this point because it is not being invoked by the JavaFX thread");
    throwable.printStackTrace(System.err);
    Dialog<ButtonType> dialog = new Dialog<ButtonType>();
    dialog.setTitle("Program exception");
    final DialogPane dialogPane = dialog.getDialogPane();
    dialogPane.setContentText("Details of the problem:");
    dialogPane.getButtonTypes().addAll(ButtonType.OK);
    dialogPane.setContentText(throwable.getMessage());
    dialog.initModality(Modality.APPLICATION_MODAL);
    Label label = new Label("Exception stacktrace:");
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    throwable.printStackTrace(pw);
    pw.close();
    TextArea textArea = new TextArea(sw.toString());
    textArea.setEditable(false);
    textArea.setWrapText(true);
    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);
    GridPane root = new GridPane();
    root.setVisible(false);
    root.setMaxWidth(Double.MAX_VALUE);
    root.add(label, 0, 0);
    root.add(textArea, 0, 1);
    dialogPane.setExpandableContent(root);
    dialog.showAndWait();
}
Also used : DialogPane(javafx.scene.control.DialogPane) GridPane(javafx.scene.layout.GridPane) StringWriter(java.io.StringWriter) TextArea(javafx.scene.control.TextArea) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) ButtonType(javafx.scene.control.ButtonType) PrintWriter(java.io.PrintWriter)

Aggregations

GridPane (javafx.scene.layout.GridPane)147 Label (javafx.scene.control.Label)83 Insets (javafx.geometry.Insets)67 Button (javafx.scene.control.Button)46 TextField (javafx.scene.control.TextField)42 VBox (javafx.scene.layout.VBox)37 Scene (javafx.scene.Scene)36 HBox (javafx.scene.layout.HBox)26 ButtonType (javafx.scene.control.ButtonType)25 Text (javafx.scene.text.Text)24 Node (javafx.scene.Node)23 Dialog (javafx.scene.control.Dialog)23 ColumnConstraints (javafx.scene.layout.ColumnConstraints)18 Stage (javafx.stage.Stage)18 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17 List (java.util.List)16 CheckBox (javafx.scene.control.CheckBox)16 ImageView (javafx.scene.image.ImageView)14 ActionEvent (javafx.event.ActionEvent)13 ComboBox (javafx.scene.control.ComboBox)13