Search in sources :

Example 1 with BorderPane

use of javafx.scene.layout.BorderPane in project JFoenix by jfoenixadmin.

the class HamburgerSlideCloseTransition method starting.

@Override
protected void starting() {
    super.starting();
    if (node.getParent() instanceof JFXRippler) {
        JFXRippler rippler = (JFXRippler) node.getParent();
        BorderPane p = new BorderPane(node);
        p.setMaxWidth(((JFXHamburger) node).getWidth());
        p.setMinWidth(((JFXHamburger) node).getWidth());
        p.addEventHandler(MouseEvent.ANY, (event) -> {
            if (!event.isConsumed()) {
                event.consume();
                node.fireEvent(event);
            }
        });
        rippler.setControl(p);
    }
    if (this.getRate() == -1) {
        ((JFXHamburger) node).getChildren().get(1).setVisible(true);
    }
}
Also used : BorderPane(javafx.scene.layout.BorderPane) JFXRippler(com.jfoenix.controls.JFXRippler) JFXHamburger(com.jfoenix.controls.JFXHamburger)

Example 2 with BorderPane

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

the class OsmRoutePlannerApp method createRootPane.

/**
     * Simple pane to control the game.
     */
@Override
public Pane createRootPane() {
    routeCalculator = createRouteCalculator();
    BorderPane root = new BorderPane();
    ToolBar toolBar = new ToolBar();
    clearBtn = new Button("Clear");
    clearBtn.setOnAction(ev -> initialize());
    taskCombo = new ComboBox<>();
    taskCombo.getItems().addAll(routeCalculator.getTaskSelectionOptions());
    taskCombo.getSelectionModel().select(0);
    calcBtn = new Button("Calculate Route");
    calcBtn.setOnAction(ev -> calculateRoute());
    toolBar.getItems().addAll(clearBtn, new Separator(), taskCombo, calcBtn);
    root.setTop(toolBar);
    StackPane mapPane = new StackPane();
    mapPaneCtrl = new MapPaneCtrl(mapPane);
    mapPaneCtrl.getMap().addMapDataEventListener(ev -> updateEnabledState());
    mapPaneCtrl.loadMap(DataResource.getULMFileResource());
    root.setCenter(mapPane);
    statusLabel = new Label();
    statusLabel.setMaxWidth(Double.MAX_VALUE);
    statusLabel.setMaxWidth(Double.MAX_VALUE);
    statusLabel.setAlignment(Pos.CENTER);
    statusLabel.setFont(Font.font(16));
    root.setBottom(statusLabel);
    return root;
}
Also used : BorderPane(javafx.scene.layout.BorderPane) MapPaneCtrl(aimax.osm.gui.fx.viewer.MapPaneCtrl) StackPane(javafx.scene.layout.StackPane)

Example 3 with BorderPane

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

the class OsmLRTAStarAgentApp method createRootPane.

/**
	 * Defines state view, parameters, and call-back functions and calls the
	 * simulation pane builder to create layout and controller objects.
	 */
@Override
public Pane createRootPane() {
    BorderPane root = new BorderPane();
    List<Parameter> params = createParameters();
    StackPane mapPane = new StackPane();
    mapPaneCtrl = new MapPaneCtrl(mapPane);
    loadMap();
    SimulationPaneBuilder builder = new SimulationPaneBuilder();
    builder.defineParameters(params);
    builder.defineStateView(mapPane);
    builder.defineInitMethod(this::initialize);
    builder.defineSimMethod(this::simulate);
    simPaneCtrl = builder.getResultFor(root);
    simPaneCtrl.setParam(SimulationPaneCtrl.PARAM_SIM_SPEED, 0);
    return root;
}
Also used : BorderPane(javafx.scene.layout.BorderPane) MapPaneCtrl(aimax.osm.gui.fx.viewer.MapPaneCtrl) SimulationPaneBuilder(aima.gui.fx.framework.SimulationPaneBuilder) Parameter(aima.gui.fx.framework.Parameter) StackPane(javafx.scene.layout.StackPane)

Example 4 with BorderPane

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

the class ConnectFourApp method createRootPane.

@Override
public Pane createRootPane() {
    model = new ConnectFourModel();
    BorderPane root = new BorderPane();
    ToolBar toolBar = new ToolBar();
    toolBar.setStyle("-fx-background-color: rgb(0, 0, 200)");
    clearBtn = new Button("Clear");
    clearBtn.setOnAction(ev -> model.initGame());
    strategyCombo = new ComboBox<>();
    strategyCombo.getItems().addAll("Iterative Deepening Alpha-Beta", "Advanced Alpha-Beta");
    strategyCombo.getSelectionModel().select(0);
    timeCombo = new ComboBox<>();
    timeCombo.getItems().addAll("2sec", "4sec", "6sec", "8sec");
    timeCombo.getSelectionModel().select(1);
    proposeBtn = new Button("Propose Move");
    proposeBtn.setOnAction(ev -> model.proposeMove((timeCombo.getSelectionModel().getSelectedIndex() + 1) * 2, strategyCombo.getSelectionModel().getSelectedIndex()));
    toolBar.getItems().addAll(clearBtn, new Separator(), strategyCombo, timeCombo, proposeBtn);
    root.setTop(toolBar);
    final int rows = model.getRows();
    final int cols = model.getCols();
    BorderPane boardPane = new BorderPane();
    ColumnConstraints colCons = new ColumnConstraints();
    colCons.setPercentWidth(100.0 / cols);
    GridPane btnPane = new GridPane();
    GridPane diskPane = new GridPane();
    btnPane.setHgap(10);
    btnPane.setPadding(new Insets(10, 10, 0, 10));
    btnPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    diskPane.setPadding(new Insets(10, 10, 10, 10));
    diskPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    colBtns = new Button[cols];
    for (int i = 0; i < cols; i++) {
        Button colBtn = new Button("" + (i + 1));
        colBtn.setId("" + (i + 1));
        colBtn.setMaxWidth(Double.MAX_VALUE);
        colBtn.setOnAction(ev -> {
            String id = ((Button) ev.getSource()).getId();
            int col = Integer.parseInt(id);
            model.makeMove(col - 1);
        });
        colBtns[i] = colBtn;
        btnPane.add(colBtn, i, 0);
        GridPane.setHalignment(colBtn, HPos.CENTER);
        btnPane.getColumnConstraints().add(colCons);
        diskPane.getColumnConstraints().add(colCons);
    }
    boardPane.setTop(btnPane);
    diskPane.setMinSize(0, 0);
    diskPane.setPrefSize(cols * 100, rows * 100);
    RowConstraints rowCons = new RowConstraints();
    rowCons.setPercentHeight(100.0 / rows);
    for (int i = 0; i < rows; i++) diskPane.getRowConstraints().add(rowCons);
    disks = new Circle[rows * cols];
    for (int i = 0; i < rows * cols; i++) {
        Circle disk = new Circle(30);
        disk.radiusProperty().bind(Bindings.min(Bindings.divide(diskPane.widthProperty(), cols * 3), Bindings.divide(diskPane.heightProperty(), rows * 3)));
        disks[i] = disk;
        diskPane.add(disk, i % cols, i / cols);
        GridPane.setHalignment(disk, HPos.CENTER);
    }
    boardPane.setCenter(diskPane);
    root.setCenter(boardPane);
    statusBar = new Label();
    statusBar.setMaxWidth(Double.MAX_VALUE);
    statusBar.setStyle("-fx-background-color: rgb(0, 0, 200); -fx-font-size: 20");
    root.setBottom(statusBar);
    model.addObserver(this::update);
    return root;
}
Also used : Circle(javafx.scene.shape.Circle) BorderPane(javafx.scene.layout.BorderPane) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Label(javafx.scene.control.Label) RowConstraints(javafx.scene.layout.RowConstraints) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Example 5 with BorderPane

use of javafx.scene.layout.BorderPane 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)

Aggregations

BorderPane (javafx.scene.layout.BorderPane)93 Scene (javafx.scene.Scene)56 Button (javafx.scene.control.Button)19 Label (javafx.scene.control.Label)16 FXMLLoader (javafx.fxml.FXMLLoader)14 Stage (javafx.stage.Stage)13 StackPane (javafx.scene.layout.StackPane)12 IOException (java.io.IOException)11 Parameter (aima.gui.fx.framework.Parameter)10 SimulationPaneBuilder (aima.gui.fx.framework.SimulationPaneBuilder)10 File (java.io.File)10 HashMap (java.util.HashMap)8 TableView (javafx.scene.control.TableView)8 HBox (javafx.scene.layout.HBox)8 Insets (javafx.geometry.Insets)7 TextField (javafx.scene.control.TextField)7 Map (java.util.Map)6 MenuItem (javafx.scene.control.MenuItem)6 TableColumn (javafx.scene.control.TableColumn)6 FXML (javafx.fxml.FXML)5