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;
}
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();
}
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);
}
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);
}
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();
}
Aggregations