Search in sources :

Example 1 with Pane

use of javafx.scene.layout.Pane in project PayFile by mikehearn.

the class ClickableBitcoinAddress method showQRCode.

@FXML
protected void showQRCode(MouseEvent event) {
    // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling
    // lazy tonight.
    final byte[] imageBytes = QRCode.from(uri()).withSize(320, 240).to(ImageType.PNG).stream().toByteArray();
    Image qrImage = new Image(new ByteArrayInputStream(imageBytes));
    ImageView view = new ImageView(qrImage);
    view.setEffect(new DropShadow());
    // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird.
    // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being
    // non-centered on the screen. Finally fade/blur it in.
    Pane pane = new Pane(view);
    pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight());
    final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this);
    view.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            overlay.done();
        }
    });
}
Also used : MouseEvent(javafx.scene.input.MouseEvent) ByteArrayInputStream(java.io.ByteArrayInputStream) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image) Pane(javafx.scene.layout.Pane) AnchorPane(javafx.scene.layout.AnchorPane) Main(net.plan99.payfile.gui.Main) DropShadow(javafx.scene.effect.DropShadow) FXML(javafx.fxml.FXML)

Example 2 with Pane

use of javafx.scene.layout.Pane in project PayFile by mikehearn.

the class GuiUtils method runAlert.

public static void runAlert(BiConsumer<Stage, AlertWindowController> setup) {
    // JavaFX doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
    // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
    // an odd sort of way.
    Stage dialogStage = new Stage();
    dialogStage.initModality(Modality.APPLICATION_MODAL);
    FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
    Pane pane = evalUnchecked(() -> (Pane) loader.load());
    AlertWindowController controller = loader.getController();
    setup.accept(dialogStage, controller);
    dialogStage.setScene(new Scene(pane));
    dialogStage.showAndWait();
}
Also used : Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) Pane(javafx.scene.layout.Pane)

Example 3 with Pane

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

the class HOGMPageEditorController method initialize.

// END-ModelPageEditor
//
@FXML
private void initialize() throws IOException {
    FXUtil.anchor(modelCodeArea);
    modelEditorPane.getChildren().add(modelCodeArea);
    FXMLLoader queryLoader = QueryController.newLoader();
    Pane queryPane = queryLoader.load();
    queryController = queryLoader.getController();
    queryController.setModelPageEditor(this);
    FXUtil.anchor(queryPane);
    queryOutputPane.getChildren().add(queryPane);
}
Also used : FXMLLoader(javafx.fxml.FXMLLoader) AnchorPane(javafx.scene.layout.AnchorPane) Pane(javafx.scene.layout.Pane) FXML(javafx.fxml.FXML)

Example 4 with Pane

use of javafx.scene.layout.Pane in project aima-java by aimacode.

the class SimulationPaneBuilder method getResultFor.

/**
	 * Adds a toolbar, a state view, and a status label to the provided pane and returns
	 * a controller class instance. The toolbar contains combo boxes to control parameter settings
	 * and buttons for simulation control. The controller class instance handles user events and provides
	 * access to user settings (parameter settings, simulation speed, status text, ...).
	 */
public SimulationPaneCtrl getResultFor(BorderPane pane) {
    List<ComboBox<String>> combos = new ArrayList<>();
    parameters.add(createSimSpeedParam());
    for (Parameter param : parameters) {
        ComboBox<String> combo = new ComboBox<>();
        combo.setId(param.getName());
        combo.getItems().addAll(param.getValueNames());
        combo.getSelectionModel().select(param.getDefaultValueIndex());
        combos.add(combo);
    }
    Button simBtn = new Button();
    Node[] tools = new Node[combos.size() + 2];
    for (int i = 0; i < combos.size() - 1; i++) tools[i] = combos.get(i);
    tools[combos.size() - 1] = new Separator();
    tools[combos.size() + 0] = combos.get(combos.size() - 1);
    tools[combos.size() + 1] = simBtn;
    ToolBar toolBar = new ToolBar(tools);
    Label statusLabel = new Label();
    statusLabel.setMaxWidth(Double.MAX_VALUE);
    statusLabel.setAlignment(Pos.CENTER);
    statusLabel.setFont(Font.font(16));
    pane.setTop(toolBar);
    if (stateView.isPresent()) {
        if (stateView.get() instanceof Canvas) {
            // make canvas resizable
            Canvas canvas = (Canvas) stateView.get();
            Pane canvasPane = new Pane();
            canvasPane.getChildren().add(canvas);
            canvas.widthProperty().bind(canvasPane.widthProperty());
            canvas.heightProperty().bind(canvasPane.heightProperty());
            pane.setCenter(canvasPane);
            pane.setStyle("-fx-background-color: white");
        } else
            pane.setCenter(stateView.get());
    }
    pane.setBottom(statusLabel);
    if (!initMethod.isPresent())
        throw new IllegalStateException("No initialization method defined.");
    if (!simMethod.isPresent())
        throw new IllegalStateException("No simulation method defined.");
    return new SimulationPaneCtrl(parameters, combos, initMethod.get(), simMethod.get(), simBtn, statusLabel);
}
Also used : ComboBox(javafx.scene.control.ComboBox) Node(javafx.scene.Node) Canvas(javafx.scene.canvas.Canvas) ArrayList(java.util.ArrayList) Label(javafx.scene.control.Label) BorderPane(javafx.scene.layout.BorderPane) Pane(javafx.scene.layout.Pane) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Example 5 with Pane

use of javafx.scene.layout.Pane in project bitsquare by bitsquare.

the class Transitions method blur.

public void blur(Node node, int duration, double brightness, boolean removeNode, double blurRadius) {
    if (removeEffectTimeLine != null)
        removeEffectTimeLine.stop();
    node.setMouseTransparent(true);
    GaussianBlur blur = new GaussianBlur(0.0);
    Timeline timeline = new Timeline();
    KeyValue kv1 = new KeyValue(blur.radiusProperty(), blurRadius);
    KeyFrame kf1 = new KeyFrame(Duration.millis(getDuration(duration)), kv1);
    ColorAdjust darken = new ColorAdjust();
    darken.setBrightness(0.0);
    blur.setInput(darken);
    KeyValue kv2 = new KeyValue(darken.brightnessProperty(), brightness);
    KeyFrame kf2 = new KeyFrame(Duration.millis(getDuration(duration)), kv2);
    timeline.getKeyFrames().addAll(kf1, kf2);
    node.setEffect(blur);
    if (removeNode)
        timeline.setOnFinished(actionEvent -> UserThread.execute(() -> ((Pane) (node.getParent())).getChildren().remove(node)));
    timeline.play();
}
Also used : EventHandler(javafx.event.EventHandler) Inject(javax.inject.Inject) Preferences(io.bitsquare.user.Preferences) ActionEvent(javafx.event.ActionEvent) Duration(javafx.util.Duration) UserThread(io.bitsquare.common.UserThread) Node(javafx.scene.Node) javafx.animation(javafx.animation) ColorAdjust(javafx.scene.effect.ColorAdjust) GaussianBlur(javafx.scene.effect.GaussianBlur) Pane(javafx.scene.layout.Pane) GaussianBlur(javafx.scene.effect.GaussianBlur) ColorAdjust(javafx.scene.effect.ColorAdjust) Pane(javafx.scene.layout.Pane)

Aggregations

Pane (javafx.scene.layout.Pane)34 StackPane (javafx.scene.layout.StackPane)13 IOException (java.io.IOException)12 FXMLLoader (javafx.fxml.FXMLLoader)12 Node (javafx.scene.Node)7 BorderPane (javafx.scene.layout.BorderPane)6 Scene (javafx.scene.Scene)5 Label (javafx.scene.control.Label)5 ArrayList (java.util.ArrayList)4 AnchorPane (javafx.scene.layout.AnchorPane)4 Stage (javafx.stage.Stage)4 HashMap (java.util.HashMap)3 List (java.util.List)3 FXML (javafx.fxml.FXML)3 ScrollPane (javafx.scene.control.ScrollPane)3 UserThread (io.bitsquare.common.UserThread)2 Insets (javafx.geometry.Insets)2 Parent (javafx.scene.Parent)2 Button (javafx.scene.control.Button)2 TabPane (javafx.scene.control.TabPane)2