Search in sources :

Example 1 with Spinner

use of javafx.scene.control.Spinner in project org.csstudio.display.builder by kasemir.

the class SpinnerDemo method start.

@Override
public void start(final Stage stage) {
    final Label label = new Label("Demo:");
    SpinnerValueFactory<Double> svf = new SpinnerValueFactory.DoubleSpinnerValueFactory(0, 1000);
    Spinner<Double> spinner = new Spinner<>();
    spinner.setValueFactory(svf);
    spinner.editorProperty().getValue().setStyle("-fx-text-fill:" + "black");
    spinner.editorProperty().getValue().setBackground(new Background(new BackgroundFill(Color.AZURE, CornerRadii.EMPTY, Insets.EMPTY)));
    // spinner.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
    // int x = spinner.getStyleClass().indexOf(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
    // if (x > 0) spinner.getStyleClass().remove(x);
    spinner.setEditable(true);
    spinner.setPrefWidth(80);
    spinner.valueProperty().addListener((prop, old, value) -> {
        System.out.println("Value: " + value);
    });
    final HBox root = new HBox(label, spinner);
    final Scene scene = new Scene(root, 800, 700);
    stage.setScene(scene);
    stage.setTitle("Spinner Demo");
    stage.show();
}
Also used : HBox(javafx.scene.layout.HBox) Background(javafx.scene.layout.Background) Spinner(javafx.scene.control.Spinner) BackgroundFill(javafx.scene.layout.BackgroundFill) Label(javafx.scene.control.Label) Scene(javafx.scene.Scene)

Example 2 with Spinner

use of javafx.scene.control.Spinner in project org.csstudio.display.builder by kasemir.

the class PropertyPanelSection method createPropertyUI.

/**
 * Add UI items for displaying or editing property
 *  @param property Property (on primary widget)
 *  @param other Zero or more additional widgets that have same type of property
 *  @param structureIndex Index of the array structure (element) being added. It is meaningful
 *                        only for properties instance of {@link StructuredWidgetProperty}.
 */
private void createPropertyUI(final UndoableActionManager undo, final WidgetProperty<?> property, final List<Widget> other, final int structureIndex, final int indentationLevel) {
    // Skip runtime properties
    if (property.getCategory() == WidgetPropertyCategory.RUNTIME)
        return;
    final Label label = new Label(property.getDescription());
    label.setMaxWidth(Double.MAX_VALUE);
    final String tooltip = property.getDescription() + " (" + property.getPath() + ")";
    label.setTooltip(new Tooltip(tooltip));
    // setGridLinesVisible(true); // For debugging the layout
    Node field = bindSimplePropertyField(undo, bindings, property, other);
    if (field != null) {
    // do nothing
    } else if (property instanceof MacrosWidgetProperty) {
        final MacrosWidgetProperty macros_prop = (MacrosWidgetProperty) property;
        final Button macros_field = new Button();
        macros_field.setMaxWidth(Double.MAX_VALUE);
        final MacrosPropertyBinding binding = new MacrosPropertyBinding(undo, macros_field, macros_prop, other);
        bindings.add(binding);
        binding.bind();
        field = macros_field;
    } else if (property instanceof ActionsWidgetProperty) {
        final ActionsWidgetProperty actions_prop = (ActionsWidgetProperty) property;
        final Button actions_field = new Button();
        actions_field.setMaxWidth(Double.MAX_VALUE);
        final ActionsPropertyBinding binding = new ActionsPropertyBinding(undo, actions_field, actions_prop, other, autocomplete_menu);
        bindings.add(binding);
        binding.bind();
        field = actions_field;
    } else if (property instanceof ScriptsWidgetProperty) {
        final ScriptsWidgetProperty scripts_prop = (ScriptsWidgetProperty) property;
        final Button scripts_field = new Button();
        scripts_field.setMaxWidth(Double.MAX_VALUE);
        final ScriptsPropertyBinding binding = new ScriptsPropertyBinding(undo, scripts_field, scripts_prop, other, autocomplete_menu);
        bindings.add(binding);
        binding.bind();
        field = scripts_field;
    } else if (property instanceof RulesWidgetProperty) {
        final RulesWidgetProperty rules_prop = (RulesWidgetProperty) property;
        final Button rules_field = new Button();
        rules_field.setMaxWidth(Double.MAX_VALUE);
        final RulesPropertyBinding binding = new RulesPropertyBinding(undo, rules_field, rules_prop, other, autocomplete_menu);
        bindings.add(binding);
        binding.bind();
        field = rules_field;
    } else if (property instanceof StructuredWidgetProperty) {
        // Don't allow editing structures and their elements in class mode
        if (class_mode)
            return;
        final StructuredWidgetProperty struct = (StructuredWidgetProperty) property;
        final Label header = new Label(struct.getDescription() + (structureIndex > 0 ? " " + String.valueOf(1 + structureIndex) : ""));
        header.getStyleClass().add("structure_property_name");
        header.setMaxWidth(Double.MAX_VALUE);
        final int row = getNextGridRow();
        fillIndent(indentationLevel, row);
        add(header, 0 + indentationLevel, row, 7 - 2 * indentationLevel, 1);
        final Separator separator = new Separator();
        separator.getStyleClass().add("property_separator");
        add(separator, 0 + indentationLevel, getNextGridRow(), 7 - 2 * indentationLevel, 1);
        for (WidgetProperty<?> elem : struct.getValue()) this.createPropertyUI(undo, elem, other, -1, indentationLevel);
        return;
    } else if (property instanceof ArrayWidgetProperty) {
        // Don't allow editing arrays and their elements in class mode
        if (class_mode)
            return;
        @SuppressWarnings("unchecked") final ArrayWidgetProperty<WidgetProperty<?>> array = (ArrayWidgetProperty<WidgetProperty<?>>) property;
        // UI for changing array size
        final Spinner<Integer> spinner = new Spinner<>(array.getMinimumSize(), 100, 0);
        final ArraySizePropertyBinding count_binding = new ArraySizePropertyBinding(this, undo, spinner, array, other);
        bindings.add(count_binding);
        count_binding.bind();
        // set size of array
        int row = getNextGridRow();
        label.getStyleClass().add("array_property_name");
        label.setMaxWidth(Double.MAX_VALUE);
        label.setMaxHeight(Double.MAX_VALUE);
        spinner.getStyleClass().add("array_property_value");
        spinner.setMaxWidth(Double.MAX_VALUE);
        fillHeaderIndent(indentationLevel, row);
        add(label, indentationLevel, row, 4 - indentationLevel, 1);
        add(spinner, 4, row, 2 - indentationLevel, 1);
        Separator separator = new Separator();
        separator.getStyleClass().add("property_separator");
        add(separator, 1 + indentationLevel, getNextGridRow(), 5 - 2 * indentationLevel, 1);
        // array elements
        final List<WidgetProperty<?>> wpeList = array.getValue();
        for (int i = 0; i < wpeList.size(); i++) {
            final WidgetProperty<?> elem = wpeList.get(i);
            createPropertyUI(undo, elem, other, i, indentationLevel + 1);
        }
        // mark end of array
        row = getNextGridRow();
        final Label endlabel = new Label();
        endlabel.setMaxWidth(Double.MAX_VALUE);
        GridPane.setHgrow(endlabel, Priority.ALWAYS);
        endlabel.getStyleClass().add("array_property_end");
        fillIndent(indentationLevel, row);
        add(endlabel, 0 + indentationLevel, row, 7 - 2 * indentationLevel, 1);
        separator = new Separator();
        separator.getStyleClass().add("property_separator");
        add(separator, 0 + indentationLevel, getNextGridRow(), 7 - 2 * indentationLevel, 1);
        return;
    } else // As new property types are added, they might need to be handled:
    // else if (property instanceof SomeNewWidgetProperty) { ... }
    {
        // Fallback for unknown property: read-only
        final TextField text = new TextField();
        text.setText(String.valueOf(property.getValue()));
        text.setEditable(false);
        field = text;
    }
    // Display Label, Class indicator/checkbox, field
    final int row = getNextGridRow();
    label.getStyleClass().add("property_name");
    field.getStyleClass().add("property_value");
    // Allow label to shrink (can use tooltip to see),
    // but show the value
    // GridPane.setHgrow(label, Priority.ALWAYS);
    GridPane.setHgrow(field, Priority.ALWAYS);
    fillIndent(indentationLevel, row);
    add(label, indentationLevel, row, 3 - indentationLevel, 1);
    final Widget widget = property.getWidget();
    if (!(property == widget.getProperty("type") || property == widget.getProperty("name"))) {
        if (class_mode) {
            // Class definition mode:
            // Check box for 'use_class'
            final CheckBox check = new CheckBox();
            check.setTooltip(use_class_tooltip);
            final WidgetPropertyBinding<?, ?> binding = new UseWidgetClassBinding(undo, check, field, property, other);
            bindings.add(binding);
            binding.bind();
            add(check, 3, row);
        } else {
            // Display file mode:
            // Show if property is set by the class, not editable.
            final Label indicator = new Label();
            indicator.setTooltip(using_class_tooltip);
            final WidgetPropertyBinding<?, ?> binding = new ShowWidgetClassBinding(field, property, indicator);
            bindings.add(binding);
            binding.bind();
            add(indicator, 3, row);
        }
    }
    add(field, 4, row, 3 - indentationLevel, 1);
    final Separator separator = new Separator();
    separator.getStyleClass().add("property_separator");
    add(separator, 0 + indentationLevel, getNextGridRow(), 7 - 2 * indentationLevel, 1);
}
Also used : RulesWidgetProperty(org.csstudio.display.builder.model.properties.RulesWidgetProperty) ScriptsWidgetProperty(org.csstudio.display.builder.model.properties.ScriptsWidgetProperty) Spinner(javafx.scene.control.Spinner) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Widget(org.csstudio.display.builder.model.Widget) ArrayWidgetProperty(org.csstudio.display.builder.model.ArrayWidgetProperty) Button(javafx.scene.control.Button) ToggleButton(javafx.scene.control.ToggleButton) TextField(javafx.scene.control.TextField) MacrosWidgetProperty(org.csstudio.display.builder.model.properties.MacrosWidgetProperty) Tooltip(javafx.scene.control.Tooltip) ScriptsWidgetProperty(org.csstudio.display.builder.model.properties.ScriptsWidgetProperty) StructuredWidgetProperty(org.csstudio.display.builder.model.StructuredWidgetProperty) MacrosWidgetProperty(org.csstudio.display.builder.model.properties.MacrosWidgetProperty) EnumWidgetProperty(org.csstudio.display.builder.model.properties.EnumWidgetProperty) WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) BooleanWidgetProperty(org.csstudio.display.builder.model.properties.BooleanWidgetProperty) MacroizedWidgetProperty(org.csstudio.display.builder.model.MacroizedWidgetProperty) ColorWidgetProperty(org.csstudio.display.builder.model.properties.ColorWidgetProperty) PointsWidgetProperty(org.csstudio.display.builder.model.properties.PointsWidgetProperty) PVNameWidgetProperty(org.csstudio.display.builder.model.properties.PVNameWidgetProperty) FilenameWidgetProperty(org.csstudio.display.builder.model.properties.FilenameWidgetProperty) RulesWidgetProperty(org.csstudio.display.builder.model.properties.RulesWidgetProperty) ArrayWidgetProperty(org.csstudio.display.builder.model.ArrayWidgetProperty) FontWidgetProperty(org.csstudio.display.builder.model.properties.FontWidgetProperty) ColorMapWidgetProperty(org.csstudio.display.builder.model.properties.ColorMapWidgetProperty) ActionsWidgetProperty(org.csstudio.display.builder.model.properties.ActionsWidgetProperty) ActionsWidgetProperty(org.csstudio.display.builder.model.properties.ActionsWidgetProperty) CheckBox(javafx.scene.control.CheckBox) StructuredWidgetProperty(org.csstudio.display.builder.model.StructuredWidgetProperty) Separator(javafx.scene.control.Separator)

Example 3 with Spinner

use of javafx.scene.control.Spinner in project KNOBS by ESSICS.

the class StopListEditorController method getNewStop.

private Stop getNewStop(Stop previous) {
    Dialog<Stop> dialog = new Dialog<>();
    dialog.setTitle("Stop Editor");
    dialog.setHeaderText(previous == null ? "Define a new Stop" : "Edit the selected Stop");
    dialog.getDialogPane().getButtonTypes().addAll(OK, CANCEL);
    Spinner<Double> offsetSpinner = new Spinner<>(0.0, 1.0, previous == null ? 0.0 : previous.getOffset(), 0.01);
    ColorPicker colorPicker = new ColorPicker(previous == null ? Color.GOLDENROD : previous.getColor());
    GridPane grid = new GridPane();
    offsetSpinner.setEditable(true);
    offsetSpinner.setPrefWidth(USE_COMPUTED_SIZE);
    colorPicker.setPrefWidth(USE_COMPUTED_SIZE);
    grid.setHgap(6);
    grid.setVgap(12);
    grid.setPadding(new Insets(12, 12, 12, 12));
    grid.getColumnConstraints().add(0, new ColumnConstraints(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.RIGHT, true));
    grid.getColumnConstraints().add(1, new ColumnConstraints(USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.LEFT, true));
    grid.add(new Label("Offset:"), 0, 0);
    grid.add(offsetSpinner, 1, 0);
    grid.add(new Label("Color:"), 0, 1);
    grid.add(colorPicker, 1, 1);
    dialog.initOwner(stopsTable.getScene().getWindow());
    dialog.getDialogPane().getScene().getStylesheets().add("/styles/dark-style.css");
    dialog.getDialogPane().setContent(grid);
    dialog.setResultConverter(b -> {
        if (b == OK) {
            return new Stop(offsetSpinner.getValue(), colorPicker.getValue());
        } else {
            return null;
        }
    });
    Platform.runLater(() -> offsetSpinner.requestFocus());
    return dialog.showAndWait().orElse(null);
}
Also used : GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) Stop(javafx.scene.paint.Stop) ColorPicker(javafx.scene.control.ColorPicker) Dialog(javafx.scene.control.Dialog) Spinner(javafx.scene.control.Spinner) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Label(javafx.scene.control.Label)

Example 4 with Spinner

use of javafx.scene.control.Spinner in project FXGL by AlmasB.

the class ParticleSystemSample method initUI.

@Override
protected void initUI() {
    Spinner<Integer> spinnerNumParticles = new Spinner<>(0, 100, 15, 1);
    emitter.numParticlesProperty().bind(spinnerNumParticles.valueProperty());
    Spinner<Double> spinnerRate = new Spinner<>(0.0, 1.0, 1.0, 0.05);
    emitter.emissionRateProperty().bind(spinnerRate.valueProperty());
    Spinner<Double> spinnerMinSize = new Spinner<>(1.0, 100.0, 9.0, 1);
    emitter.minSizeProperty().bind(spinnerMinSize.valueProperty());
    Spinner<Double> spinnerMaxSize = new Spinner<>(1.0, 100.0, 12.0, 1);
    emitter.maxSizeProperty().bind(spinnerMaxSize.valueProperty());
    Spinner<Double> spinnerVelX = new Spinner<>(-500.0, 500.0, 0.0, 10);
    Spinner<Double> spinnerVelY = new Spinner<>(-500.0, 500.0, -30.0, 10);
    spinnerVelX.setPrefWidth(65);
    spinnerVelY.setPrefWidth(65);
    spinnerVelX.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setVelocityFunction((i, x, y) -> new Point2D(newValue, spinnerVelY.getValue()));
    });
    spinnerVelY.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setVelocityFunction((i, x, y) -> new Point2D(spinnerVelX.getValue(), newValue));
    });
    Spinner<Double> spinnerAccelX = new Spinner<>(-150.0, 150.0, 0.0, 10);
    Spinner<Double> spinnerAccelY = new Spinner<>(-150.0, 150.0, 0.0, 10);
    spinnerAccelX.setPrefWidth(65);
    spinnerAccelY.setPrefWidth(65);
    spinnerAccelX.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setAccelerationFunction(() -> new Point2D(newValue, spinnerAccelY.getValue()));
    });
    spinnerAccelY.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setAccelerationFunction(() -> new Point2D(spinnerAccelX.getValue(), newValue));
    });
    ChoiceBox<BlendMode> choiceBlend = getUIFactory().newChoiceBox(FXCollections.observableArrayList(BlendMode.values()));
    emitter.blendModeProperty().bind(choiceBlend.valueProperty());
    choiceBlend.setValue(BlendMode.ADD);
    ChoiceBox<EasingInterpolator> choiceInterpolator = getUIFactory().newChoiceBox(FXCollections.observableArrayList(Interpolators.values()));
    choiceInterpolator.setValue(Interpolators.LINEAR);
    choiceInterpolator.valueProperty().addListener((observable, oldValue, newValue) -> {
        emitter.setInterpolator(newValue.EASE_OUT());
    });
    ColorPicker startColor = new ColorPicker((Color) emitter.getStartColor());
    ColorPicker endColor = new ColorPicker((Color) emitter.getEndColor());
    emitter.startColorProperty().bind(startColor.valueProperty());
    emitter.endColorProperty().bind(endColor.valueProperty());
    VBox vbox = new VBox(10);
    vbox.setTranslateX(700);
    vbox.getChildren().addAll(new HBox(10, new Text("Vel X and Y"), spinnerVelX, spinnerVelY), new HBox(10, new Text("Acc X and Y"), spinnerAccelX, spinnerAccelY), new Text("Number of Particles:"), spinnerNumParticles, new Text("Min Size:"), spinnerMinSize, new Text("Max Size:"), spinnerMaxSize, new Text("Emission Rate:"), spinnerRate, new Text("Start Color:"), startColor, new Text("End Color:"), endColor, choiceBlend, choiceInterpolator);
    getGameScene().addUINode(vbox);
}
Also used : HBox(javafx.scene.layout.HBox) EasingInterpolator(com.almasb.fxgl.animation.EasingInterpolator) ColorPicker(javafx.scene.control.ColorPicker) Spinner(javafx.scene.control.Spinner) BlendMode(javafx.scene.effect.BlendMode) Text(javafx.scene.text.Text) Point2D(javafx.geometry.Point2D) VBox(javafx.scene.layout.VBox)

Example 5 with Spinner

use of javafx.scene.control.Spinner in project jvarkit by lindenb.

the class IndexCovJfx method doWork.

@Override
public int doWork(final Stage primaryStage, final List<String> args) {
    final Rectangle2D screen = Screen.getPrimary().getVisualBounds();
    final Pattern tab = Pattern.compile("[\t]");
    BufferedReader r = null;
    try {
        final File inputFile;
        if (args.isEmpty()) {
            // open gui
            final FileChooser fc = new FileChooser();
            inputFile = fc.showOpenDialog(null);
            if (inputFile == null) {
                return 0;
            }
        } else if (args.size() == 1) {
            inputFile = new File(args.get(0));
        } else {
            LOG.error("Illegal Number of arguments: " + args);
            return -1;
        }
        r = IOUtils.openFileForBufferedReading(inputFile);
        String line = r.readLine();
        if (line == null) {
            new Alert(AlertType.ERROR, "Cannot read first line of " + inputFile, ButtonType.OK).showAndWait();
            return -1;
        }
        String[] tokens = tab.split(line);
        if (tokens.length < 4 || !tokens[0].equals("#chrom") || !tokens[1].equals("start") || !tokens[2].equals("end")) {
            new Alert(AlertType.ERROR, "bad first line " + line + " in " + inputFile, ButtonType.OK).showAndWait();
            return -1;
        }
        this.sampleNames.addAll(Arrays.asList(tokens).subList(3, tokens.length).stream().map(S -> new Sample(S)).collect(Collectors.toList()));
        this.sampleListView = new ListView<>(this.sampleNames);
        final MultipleSelectionModel<Sample> sampleSelectionModel = this.sampleListView.getSelectionModel();
        sampleSelectionModel.setSelectionMode(SelectionMode.MULTIPLE);
        // this.sampleListView.setPrefWidth(200);
        final SmartComparator smartCmp = new SmartComparator();
        this.orignalndexCovRows.addAll(r.lines().filter(L -> !StringUtil.isBlank(L)).map(L -> Arrays.asList(tab.split(L))).map(T -> new IndexCovRow(T)).sorted((A, B) -> {
            int i = smartCmp.compare(A.getContig(), B.getContig());
            if (i != 0)
                return i;
            return A.getStart() - B.getStart();
        }).collect(Collectors.toList()));
        this.visibleIndexCovRows.addAll(orignalndexCovRows);
        String lastContig = null;
        for (final IndexCovRow row : this.visibleIndexCovRows) {
            if (lastContig == null || !lastContig.equals(row.getContig())) {
                this.contig2color.put(row.getContig(), this.contig2color.size() % 2 == 0 ? gray(0.96) : gray(0.98));
                lastContig = row.getContig();
            }
        }
        this.canvas = new Canvas(screen.getWidth() - 400, screen.getHeight() - 200);
        this.canvasSrollPane = new ScrollPane(canvas);
        this.canvasSrollPane.setFitToHeight(true);
        this.canvasSrollPane.setFitToWidth(true);
        this.canvasSrollPane.setHbarPolicy(ScrollBarPolicy.ALWAYS);
        this.canvasSrollPane.setHmin(0);
        // NOT HERE: see adjustScollPane();
        // this.canvasSrollPane.setHmax(this.visibleIndexCovRows.size()*CHUNK_WIDTH);
        // this.canvasSrollPane.setHvalue(0);
        this.canvasSrollPane.hvalueProperty().addListener(E -> repaintCanvas());
        final VBox root = new VBox();
        final MenuBar menuBar = new MenuBar();
        Menu menu = new Menu("Tools");
        MenuItem item = new MenuItem("Goto");
        item.setOnAction(AE -> askGoto());
        item.setAccelerator(new KeyCodeCombination(KeyCode.G, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        // 
        item = new MenuItem("Cleanup: remove data > DEL && data < DUP");
        item.setOnAction(AE -> askCleanup());
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: remove ALL samples <= DEL or ALL samples >= DUP");
        item.setOnAction(AE -> askEveryWhere());
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: keep selected samples having <= DEL or ALL samples >= DUP");
        item.setOnAction(AE -> filterForSampleSet(false));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Cleanup: keep selected samples having <= DEL or ALL samples >= DUP and only those samples.");
        item.setOnAction(AE -> filterForSampleSet(true));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Filter: Keep data overlapping BED file");
        item.setOnAction(AE -> filterBed(false));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Filter: Keep data NOT overlapping BED file");
        item.setOnAction(AE -> filterBed(true));
        menu.getItems().add(item);
        // 
        item = new MenuItem("Revert: Restore original data");
        item.setOnAction(AE -> doRestoreOriginalData());
        item.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        item = new MenuItem("Next Interesting");
        item.setOnAction(AE -> goToNextInteresting(1));
        item.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        item = new MenuItem("Previous Interesting");
        item.setOnAction(AE -> goToNextInteresting(-1));
        item.setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN));
        menu.getItems().add(item);
        menu.getItems().add(new SeparatorMenuItem());
        item = new MenuItem("Quit");
        menu.getItems().add(item);
        item.setOnAction(AE -> {
            Platform.exit();
        });
        menuBar.getMenus().add(menu);
        root.getChildren().add(menuBar);
        final HBox toolboxPane = new HBox();
        Label label = new Label("DEL when \u2264 :");
        toolboxPane.getChildren().add(label);
        this.deletionSpinner = new Spinner<>(0.0, 0.9, DEFAULT_deletionTreshold, 0.05);
        label.setLabelFor(this.deletionSpinner);
        this.deletionSpinner.valueProperty().addListener((a, b, c) -> repaintCanvas());
        toolboxPane.getChildren().add(this.deletionSpinner);
        label = new Label("DUP when \u2265 :");
        toolboxPane.getChildren().add(label);
        this.duplicationSpinner = new Spinner<>(1.1, 10.0, DEFAULT_duplicationTreshold, 0.05);
        this.duplicationSpinner.valueProperty().addListener((a, b, c) -> repaintCanvas());
        label.setLabelFor(this.duplicationSpinner);
        toolboxPane.getChildren().add(this.duplicationSpinner);
        label = new Label(" Jump to :");
        toolboxPane.getChildren().add(label);
        final TextField jumpToTextField = new TextField();
        jumpToTextField.setPromptText("chrom:pos");
        jumpToTextField.setPrefColumnCount(15);
        toolboxPane.getChildren().add(jumpToTextField);
        label.setLabelFor(jumpToTextField);
        jumpToTextField.setOnAction(AE -> askGoto(jumpToTextField.getText()));
        final Button goButton = new Button("Go");
        toolboxPane.getChildren().add(goButton);
        goButton.setOnAction(AE -> askGoto(jumpToTextField.getText()));
        root.getChildren().add(toolboxPane);
        // HBox hbox = new HBox(sampleListView,this.canvasSrollPane);
        final GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(5, 5, 5, 5));
        grid.add(this.sampleListView, 0, 0, 1, 1);
        grid.add(this.canvasSrollPane, 1, 0, 9, 1);
        // final StackPane root = new StackPane();
        root.getChildren().add(grid);
        final Scene scene = new Scene(root);
        primaryStage.setTitle(IndexCovJfx.class.getSimpleName() + " " + this.sampleNames.size() + " Sample(s) " + this.visibleIndexCovRows.size() + " Point(s).");
        primaryStage.setOnShown(E -> {
            adjustScollPane();
            this.canvasSrollPane.requestFocus();
            repaintCanvas();
            if (this.isUnitText()) {
                Platform.exit();
            }
        });
        this.canvasSrollPane.setOnKeyPressed(e -> {
            if (e.getCode() == KeyCode.LEFT) {
                canvasSrollPane.setHvalue(Math.max(canvasSrollPane.getHmin(), canvasSrollPane.getHvalue() - CHUNK_WIDTH));
            }
            if (e.getCode() == KeyCode.RIGHT) {
                canvasSrollPane.setHvalue(Math.min(canvasSrollPane.getHmax(), canvasSrollPane.getHvalue() + CHUNK_WIDTH));
            }
        });
        primaryStage.setScene(scene);
        primaryStage.show();
        /*sampleSelectionModel.selectedItemProperty().addListener(E->{
	        	repaintCanvas();
				});
	        sampleSelectionModel.selectedItemProperty().addListener(E->repaintCanvas());*/
        sampleSelectionModel.getSelectedIndices().addListener(new ListChangeListener<Integer>() {

            @Override
            public void onChanged(Change<? extends Integer> c) {
                repaintCanvas();
            }
        });
    } catch (final Exception err) {
        LOG.error(err);
        new Alert(AlertType.ERROR, "Error " + err, ButtonType.OK).showAndWait();
        return -1;
    } finally {
        CloserUtil.close(r);
    }
    return 0;
}
Also used : Button(javafx.scene.control.Button) Arrays(java.util.Arrays) Program(com.github.lindenb.jvarkit.util.jcommander.Program) AbstractList(java.util.AbstractList) VBox(javafx.scene.layout.VBox) MultipleSelectionModel(javafx.scene.control.MultipleSelectionModel) KeyCombination(javafx.scene.input.KeyCombination) Application(javafx.application.Application) ScrollPane(javafx.scene.control.ScrollPane) StringUtil(htsjdk.samtools.util.StringUtil) ListChangeListener(javafx.collections.ListChangeListener) AlertType(javafx.scene.control.Alert.AlertType) Locale(java.util.Locale) Map(java.util.Map) Hershey(com.github.lindenb.jvarkit.util.Hershey) CloserUtil(htsjdk.samtools.util.CloserUtil) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) GraphicsContext(javafx.scene.canvas.GraphicsContext) JfxLauncher(com.github.lindenb.jvarkit.util.jcommander.JfxLauncher) Logger(com.github.lindenb.jvarkit.util.log.Logger) Set(java.util.Set) Canvas(javafx.scene.canvas.Canvas) Spinner(javafx.scene.control.Spinner) Screen(javafx.stage.Screen) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) List(java.util.List) SmartComparator(com.github.lindenb.jvarkit.lang.SmartComparator) ScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy) TextInputDialog(javafx.scene.control.TextInputDialog) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) ObservableList(javafx.collections.ObservableList) IntStream(java.util.stream.IntStream) Scene(javafx.scene.Scene) ListView(javafx.scene.control.ListView) ButtonType(javafx.scene.control.ButtonType) BedLineCodec(com.github.lindenb.jvarkit.util.bio.bed.BedLineCodec) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) Interval(htsjdk.samtools.util.Interval) Insets(javafx.geometry.Insets) IOUtils(com.github.lindenb.jvarkit.io.IOUtils) GridPane(javafx.scene.layout.GridPane) Locatable(htsjdk.samtools.util.Locatable) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) File(java.io.File) Menu(javafx.scene.control.Menu) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) FileChooser(javafx.stage.FileChooser) SelectionMode(javafx.scene.control.SelectionMode) Stage(javafx.stage.Stage) BufferedReader(java.io.BufferedReader) HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) Button(javafx.scene.control.Button) FileChooser(javafx.stage.FileChooser) TextField(javafx.scene.control.TextField) Menu(javafx.scene.control.Menu) Pattern(java.util.regex.Pattern) GridPane(javafx.scene.layout.GridPane) Canvas(javafx.scene.canvas.Canvas) Rectangle2D(javafx.geometry.Rectangle2D) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) Scene(javafx.scene.Scene) SmartComparator(com.github.lindenb.jvarkit.lang.SmartComparator) ScrollPane(javafx.scene.control.ScrollPane) BufferedReader(java.io.BufferedReader) Alert(javafx.scene.control.Alert) File(java.io.File) VBox(javafx.scene.layout.VBox)

Aggregations

Spinner (javafx.scene.control.Spinner)6 Label (javafx.scene.control.Label)3 HBox (javafx.scene.layout.HBox)3 Insets (javafx.geometry.Insets)2 Scene (javafx.scene.Scene)2 VBox (javafx.scene.layout.VBox)2 EasingInterpolator (com.almasb.fxgl.animation.EasingInterpolator)1 IOUtils (com.github.lindenb.jvarkit.io.IOUtils)1 SmartComparator (com.github.lindenb.jvarkit.lang.SmartComparator)1 Hershey (com.github.lindenb.jvarkit.util.Hershey)1 BedLineCodec (com.github.lindenb.jvarkit.util.bio.bed.BedLineCodec)1 JfxLauncher (com.github.lindenb.jvarkit.util.jcommander.JfxLauncher)1 Program (com.github.lindenb.jvarkit.util.jcommander.Program)1 Logger (com.github.lindenb.jvarkit.util.log.Logger)1 CloserUtil (htsjdk.samtools.util.CloserUtil)1 Interval (htsjdk.samtools.util.Interval)1 Locatable (htsjdk.samtools.util.Locatable)1 StringUtil (htsjdk.samtools.util.StringUtil)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1