Search in sources :

Example 1 with Separator

use of javafx.scene.control.Separator 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 2 with Separator

use of javafx.scene.control.Separator 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 3 with Separator

use of javafx.scene.control.Separator in project aic-praise by aic-sri-international.

the class SGSolverDemoController method configureSettingsContent.

private Node configureSettingsContent() {
    VBox configureMenu = new VBox(2);
    configureMenu.setPadding(new Insets(3, 3, 3, 3));
    HBox displayPrecisionHBox = newButtonHBox();
    displayPrecisionSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 80, _displayPrecision.get()));
    displayPrecisionSpinner.setPrefWidth(60);
    _displayPrecision.bind(displayPrecisionSpinner.valueProperty());
    displayPrecisionHBox.getChildren().addAll(new Label("Display Numeric Precision:"), displayPrecisionSpinner);
    displayExactCheckBox.setSelected(_isDisplayExact.get());
    displayExactCheckBox.setText("Display Numerics Exactly");
    _isDisplayExact.bind(displayExactCheckBox.selectedProperty());
    HBox displayScientificHBox = newButtonHBox();
    displayScientificGreater.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(2, 80, _displayScientificGreater.get()));
    displayScientificGreater.setPrefWidth(60);
    _displayScientificGreater.bind(displayScientificGreater.valueProperty());
    displayScientificAfter.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(2, 80, _displayScientificAfter.get()));
    displayScientificAfter.setPrefWidth(60);
    _displayScientificAfter.bind(displayScientificAfter.valueProperty());
    displayScientificHBox.getChildren().addAll(new Label("Use Scientific When Outside Range:"), displayScientificGreater, new Label("."), displayScientificAfter);
    debugModeCheckBox.setSelected(_inDebugMode.get());
    debugModeCheckBox.setText("In Debug Mode");
    _inDebugMode.bind(debugModeCheckBox.selectedProperty());
    configureMenu.getChildren().addAll(displayPrecisionHBox, displayScientificHBox, displayExactCheckBox, new Separator(Orientation.HORIZONTAL), debugModeCheckBox);
    return configureMenu;
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) VBox(javafx.scene.layout.VBox) Separator(javafx.scene.control.Separator) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory)

Example 4 with Separator

use of javafx.scene.control.Separator in project bitsquare by bitsquare.

the class Overlay method addSeparator.

protected void addSeparator() {
    if (headLine != null) {
        Separator separator = new Separator();
        separator.setMouseTransparent(true);
        separator.setOrientation(Orientation.HORIZONTAL);
        separator.setStyle("-fx-background: #ccc;");
        GridPane.setHalignment(separator, HPos.CENTER);
        GridPane.setRowIndex(separator, ++rowIndex);
        GridPane.setColumnSpan(separator, 2);
        gridPane.getChildren().add(separator);
    }
}
Also used : Separator(javafx.scene.control.Separator)

Example 5 with Separator

use of javafx.scene.control.Separator in project trex-stateless-gui by cisco-system-traffic-generator.

the class MultiplierView method buildUI.

/**
     * Build UI
     */
private void buildUI() {
    // add slider area
    addLabel("Bandwidth", 7, 336);
    addLabel("0", 22, 287);
    addLabel("100", 22, 454);
    slider = new Slider(0, 100, 1);
    slider.setDisable(true);
    getChildren().add(slider);
    MultiplierView.setTopAnchor(slider, 22d);
    MultiplierView.setLeftAnchor(slider, 304d);
    slider.valueProperty().addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            // check min value for slider
            if ((double) newValue < MultiplierType.percentage.getMinRate(rate)) {
                slider.setValue(MultiplierType.percentage.getMinRate(rate));
            }
            updateOptionsValues(slider.getValue(), updateAll);
            if (fireUpdateCommand) {
                optionValueChangeHandler.optionValueChanged();
            }
        }
    });
    // add separator
    Separator separator = new Separator(Orientation.HORIZONTAL);
    separator.setPrefHeight(1);
    getChildren().add(separator);
    MultiplierView.setTopAnchor(separator, 50d);
    MultiplierView.setLeftAnchor(separator, 15d);
    MultiplierView.setRightAnchor(separator, 15d);
    group = new ToggleGroup();
    int index = 0;
    double prevComponentWidth = 0;
    AnchorPane optionContainer = new AnchorPane();
    getChildren().add(optionContainer);
    MultiplierView.setTopAnchor(optionContainer, 51d);
    MultiplierView.setLeftAnchor(optionContainer, 15d);
    MultiplierView.setRightAnchor(optionContainer, 150d);
    for (MultiplierType type : MultiplierType.values()) {
        MultiplierOption option = new MultiplierOption(type.getTitle(), group, type, this);
        option.setMultiplierSelectionEvent(this);
        optionContainer.getChildren().add(option);
        double leftSpace = prevComponentWidth + (index * 15);
        MultiplierView.setLeftAnchor(option, leftSpace);
        MultiplierView.setTopAnchor(option, 0d);
        MultiplierView.setBottomAnchor(option, 0d);
        multiplierOptionMap.put(type, option);
        index++;
        prevComponentWidth += option.getComponentWidth();
    }
    multiplierOptionMap.get(MultiplierType.pps).setSelected();
    // add suration
    Separator vSeparator = new Separator(Orientation.VERTICAL);
    vSeparator.setPrefWidth(1);
    getChildren().add(vSeparator);
    MultiplierView.setTopAnchor(vSeparator, 93d);
    MultiplierView.setLeftAnchor(vSeparator, 560d);
    MultiplierView.setBottomAnchor(vSeparator, 15d);
    addLabel("Duration", 70, 606);
    durationCB = new CheckBox();
    getChildren().add(durationCB);
    MultiplierView.setTopAnchor(durationCB, 94d);
    MultiplierView.setLeftAnchor(durationCB, 581d);
    MultiplierView.setBottomAnchor(durationCB, 20d);
    durationTF = new TextField("0");
    durationTF.setPrefSize(70, 22);
    durationTF.setDisable(true);
    getChildren().add(durationTF);
    MultiplierView.setTopAnchor(durationTF, 93d);
    MultiplierView.setLeftAnchor(durationTF, 606d);
    MultiplierView.setBottomAnchor(durationTF, 15d);
    durationTF.disableProperty().bind(durationCB.selectedProperty().not());
    durationTF.setTextFormatter(Util.getNumberFilter(4));
}
Also used : Slider(javafx.scene.control.Slider) MultiplierOption(com.exalttech.trex.ui.components.MultiplierOption) MultiplierType(com.exalttech.trex.ui.MultiplierType) CheckBox(javafx.scene.control.CheckBox) ToggleGroup(javafx.scene.control.ToggleGroup) TextField(javafx.scene.control.TextField) AnchorPane(javafx.scene.layout.AnchorPane) Separator(javafx.scene.control.Separator)

Aggregations

Separator (javafx.scene.control.Separator)7 Label (javafx.scene.control.Label)4 Insets (javafx.geometry.Insets)3 Button (javafx.scene.control.Button)3 ToolBar (javafx.scene.control.ToolBar)2 BorderPane (javafx.scene.layout.BorderPane)2 HBox (javafx.scene.layout.HBox)2 VBox (javafx.scene.layout.VBox)2 MultiplierType (com.exalttech.trex.ui.MultiplierType)1 MultiplierOption (com.exalttech.trex.ui.components.MultiplierOption)1 ArrayList (java.util.ArrayList)1 Node (javafx.scene.Node)1 Canvas (javafx.scene.canvas.Canvas)1 CheckBox (javafx.scene.control.CheckBox)1 ComboBox (javafx.scene.control.ComboBox)1 Slider (javafx.scene.control.Slider)1 SpinnerValueFactory (javafx.scene.control.SpinnerValueFactory)1 TextField (javafx.scene.control.TextField)1 ToggleGroup (javafx.scene.control.ToggleGroup)1 AnchorPane (javafx.scene.layout.AnchorPane)1