Java Code Examples for javafx.scene.control.CheckBox#setGraphic()

The following examples show how to use javafx.scene.control.CheckBox#setGraphic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListImageCheckBoxCell.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void updateItem(ImageItem item, boolean empty) {
    super.updateItem(item, empty);
    setText(null);
    if (empty || item == null) {
        setGraphic(null);
        return;
    }
    try {
        CheckBox cb = (CheckBox) getGraphic();
        cb.setText(null);
        cb.setGraphic(item.makeNode(imageSize));
    } catch (Exception e) {
        setGraphic(null);
    }
}
 
Example 2
Source File: TransposedDataSetSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    // init default 2D Chart
    final XYChart chart1 = getDefaultChart();
    final ErrorDataSetRenderer renderer = (ErrorDataSetRenderer) chart1.getRenderers().get(0);
    renderer.setAssumeSortedData(false); // necessary to suppress sorted-DataSet-only optimisations

    // alternate DataSet:
    // final CosineFunction dataSet1 = new CosineFunction("test cosine", N_SAMPLES);
    final DataSet dataSet1 = test8Function(0, 4, -1, 3, (Math.PI / N_SAMPLES) * 2 * N_TURNS, 0.2, N_SAMPLES);
    final TransposedDataSet transposedDataSet1 = TransposedDataSet.transpose(dataSet1, false);
    renderer.getDatasets().add(transposedDataSet1);

    // init default 3D Chart with HeatMapRenderer
    final XYChart chart2 = getDefaultChart();
    final ContourDataSetRenderer contourRenderer = new ContourDataSetRenderer();
    chart2.getRenderers().setAll(contourRenderer);

    final DataSet dataSet2 = createTestData();
    dataSet2.getAxisDescription(DIM_X).set("x-axis", "x-unit");
    dataSet2.getAxisDescription(DIM_Y).set("y-axis", "y-unit");
    final TransposedDataSet transposedDataSet2 = TransposedDataSet.transpose(dataSet2, false);
    contourRenderer.getDatasets().add(transposedDataSet2);

    // init ToolBar items to illustrate the two different methods to flip the DataSet
    final CheckBox cbTransposed = new CheckBox("flip data set");
    final TextField textPermutation = new TextField("0,1,2");
    textPermutation.setPrefWidth(100);
    cbTransposed.setTooltip(new Tooltip("press to transpose DataSet"));
    cbTransposed.setGraphic(new Glyph(FONT_AWESOME, FONT_SYMBOL_TRANSPOSE).size(FONT_SIZE));
    final Button bApplyPermutation = new Button(null, new Glyph(FONT_AWESOME, FONT_SYMBOL_CHECK).size(FONT_SIZE));
    bApplyPermutation.setTooltip(new Tooltip("press to apply permutation"));

    // flipping method #1: via 'setTransposed(boolean)' - flips only first two axes
    cbTransposed.setOnAction(evt -> {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.atInfo().addArgument(cbTransposed.isSelected()).log("set transpose state to '{}'");
        }
        transposedDataSet1.setTransposed(cbTransposed.isSelected());
        transposedDataSet2.setTransposed(cbTransposed.isSelected());
        textPermutation.setText(Arrays.stream(transposedDataSet2.getPermutation()).boxed().map(String::valueOf).collect(Collectors.joining(",")));
    });

    // flipping method #2: via 'setPermutation(int[])' - flips arbitrary combination of axes
    final Runnable permutationAction = () -> {
        final int[] parsedInt1 = Arrays.asList(textPermutation.getText().split(","))
                                         .subList(0, transposedDataSet1.getDimension())
                                         .stream()
                                         .map(String::trim)
                                         .mapToInt(Integer::parseInt)
                                         .toArray();
        final int[] parsedInt2 = Arrays.asList(textPermutation.getText().split(","))
                                         .subList(0, transposedDataSet2.getDimension())
                                         .stream()
                                         .map(String::trim)
                                         .mapToInt(Integer::parseInt)
                                         .toArray();

        transposedDataSet1.setPermutation(parsedInt1);
        transposedDataSet2.setPermutation(parsedInt2);
    };

    textPermutation.setOnAction(evt -> permutationAction.run());
    bApplyPermutation.setOnAction(evt -> permutationAction.run());

    // the usual JavaFX Application boiler-plate code
    final ToolBar toolBar = new ToolBar(new Label("method #1 - transpose: "), cbTransposed, new Separator(),
            new Label("method #2 - permutation: "), textPermutation, bApplyPermutation);
    final HBox hBox = new HBox(chart1, chart2);

    VBox.setVgrow(hBox, Priority.ALWAYS);
    final Scene scene = new Scene(new VBox(toolBar, hBox), 800, 600);
    primaryStage.setTitle(getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.show();
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
}
 
Example 3
Source File: SnowFlakeSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final XYChart chart1 = getChristmasChart(false);
    final XYChart chart2 = getChristmasChart(true);

    final CheckBox cbTransposed = new CheckBox("flip tree");
    cbTransposed.setTooltip(new Tooltip("press to flip tree"));
    cbTransposed.setGraphic(new Glyph(FONT_AWESOME, FONT_SYMBOL_TRANSPOSE).size(FONT_SIZE));
    cbTransposed.selectedProperty().bindBidirectional(flipProperty);

    final CheckBox cbSnow = new CheckBox("snow");
    cbSnow.setTooltip(new Tooltip("press to switch on/off snow"));
    cbSnow.setGraphic(new Glyph(FONT_AWESOME, FONT_SYMBOL_SNOW).size(FONT_SIZE));
    cbSnow.selectedProperty().bindBidirectional(snowProperty);

    Slider nFlakeSpeed = new Slider(0.0, 2, velocityProperty.get());
    nFlakeSpeed.setBlockIncrement(0.1);
    nFlakeSpeed.setMajorTickUnit(0.1);
    velocityProperty.bind(nFlakeSpeed.valueProperty());

    Spinner<Integer> nSnowFlakes = new Spinner<>(10, 1000, 200, numberOfFlakesProperty.get());
    numberOfFlakesProperty.bind(nSnowFlakes.valueProperty());

    Spinner<Double> meanFlakeSize = new Spinner<>(0.1, 20.0, meanSizeProperty.get(), 0.1);
    meanSizeProperty.bind(meanFlakeSize.valueProperty());

    Spinner<Double> rmsFlakeSize = new Spinner<>(0.1, 20.0, rmsSizeProperty.get(), 0.1);
    rmsSizeProperty.bind(rmsFlakeSize.valueProperty());

    final ToolBar toolBar = new ToolBar(cbTransposed, cbSnow, new Label("speed:"), nFlakeSpeed, //
            new Label("n-flakes:"), nSnowFlakes, new Label("mean-size:"), meanFlakeSize, //
            new Label("rms-size:"), rmsFlakeSize);
    final HBox hBox = new HBox(chart1, chart2);

    VBox.setVgrow(hBox, Priority.ALWAYS);
    final Scene scene = new Scene(new VBox(toolBar, hBox), WIDTH, HEIGHT);

    primaryStage.setTitle(SnowFlakeSample.class.getSimpleName());
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
    primaryStage.setScene(scene);
    primaryStage.show();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.atDebug().log("scene initialised");
    }
}
 
Example 4
Source File: PdfDestinationPane.java    From pdfsam with GNU Affero General Public License v3.0 4 votes vote down vote up
public PdfDestinationPane(BrowsableField destination, String ownerModule, UserContext userContext,
        boolean expandAdvanced, DestinationPanelFields... optionalFields) {
    super(destination);
    destination.setId(ownerModule + ".destination");
    requireNotNullArg(userContext, "UserContext cannot be null");
    this.userContext = userContext;
    this.ownerModule = defaultString(ownerModule);
    VBox advancedPanel = new VBox();
    advancedPanel.getStyleClass().addAll(Style.CONTAINER.css());
    version = new PdfVersionCombo(ownerModule);
    compress = new PdfVersionConstrainedCheckBox(PdfVersion.VERSION_1_5, ownerModule);
    compress.setText(DefaultI18nContext.getInstance().i18n("Compress output file/files"));
    compress.setSelected(userContext.isCompressionEnabled());
    compress.setId("compressField");
    compress.getStyleClass().addAll(Style.VITEM.css());

    if (asList(optionalFields).contains(DestinationPanelFields.DISCARD_BOOKMARKS)) {
        CheckBox discardBookmarksField = new CheckBox(DefaultI18nContext.getInstance().i18n("Discard bookmarks"));
        discardBookmarksField.setGraphic(helpIcon(DefaultI18nContext.getInstance()
                .i18n("Tick the box if you don't want to retain any bookmark from the original PDF document")));
        discardBookmarksField.getStyleClass().addAll(Style.WITH_HELP.css());
        discardBookmarksField.getStyleClass().addAll(Style.VITEM.css());
        discardBookmarksField.setId("discardBookmarksField");
        discardBookmarks = Optional.of(discardBookmarksField);
    }
    HBox versionPane = new HBox(new Label(DefaultI18nContext.getInstance().i18n("Output PDF version:")), version);
    versionPane.getStyleClass().addAll(Style.VITEM.css());
    versionPane.getStyleClass().addAll(Style.HCONTAINER.css());
    advancedPanel.getChildren().add(compress);
    discardBookmarks.ifPresent(advancedPanel.getChildren()::add);
    advancedPanel.getChildren().add(versionPane);
    TitledPane titledAdvanced = Views.titledPane(DefaultI18nContext.getInstance().i18n("Show advanced settings"),
            advancedPanel);
    titledAdvanced.getStyleClass().add("advanced-destination-pane");
    titledAdvanced.setExpanded(expandAdvanced);
    titledAdvanced.expandedProperty().addListener((o, oldval, newVal) -> {
        if (newVal) {
            titledAdvanced.setText(DefaultI18nContext.getInstance().i18n("Hide advanced settings"));
        } else {
            titledAdvanced.setText(DefaultI18nContext.getInstance().i18n("Show advanced settings"));
        }
    });
    getChildren().add(titledAdvanced);
    eventStudio().addAnnotatedListeners(this);
}
 
Example 5
Source File: MergeOptionsPane.java    From pdfsam with GNU Affero General Public License v3.0 4 votes vote down vote up
MergeOptionsPane() {
    super(5);
    I18nContext i18n = DefaultI18nContext.getInstance();
    blankIfOdd = new CheckBox(i18n.i18n("Add a blank page if page number is odd"));
    blankIfOdd.setGraphic(helpIcon(
            i18n.i18n("Adds a blank page after each merged document if the document has an odd number of pages")));
    blankIfOdd.getStyleClass().addAll(Style.WITH_HELP.css());
    blankIfOdd.setId("blankIfOddCheck");

    footer = new CheckBox(i18n.i18n("Add a footer"));
    footer.setGraphic(helpIcon(i18n.i18n("Adds a page footer with the name of the file the page belonged to.")));
    footer.getStyleClass().addAll(Style.WITH_HELP.css());
    footer.setId("footerCheck");

    normalize = new CheckBox(i18n.i18n("Normalize pages size"));
    normalize.setGraphic(helpIcon(i18n.i18n("Resizes all pages to have the same width as the first page.")));
    normalize.getStyleClass().addAll(Style.WITH_HELP.css());
    normalize.setId("normalizeCheck");

    GridPane options = new GridPane();

    acroForms.getItems().add(keyValue(AcroFormPolicy.MERGE, i18n.i18n("Merge fields")));
    acroForms.getItems().add(
            keyValue(AcroFormPolicy.MERGE_RENAMING_EXISTING_FIELDS, i18n.i18n("Merge renaming existing fields")));
    acroForms.getItems().add(keyValue(AcroFormPolicy.FLATTEN, i18n.i18n("Flatten")));
    acroForms.getItems().add(keyValue(AcroFormPolicy.DISCARD, i18n.i18n("Discard forms")));
    acroForms.setId("acroFormsCombo");
    options.add(new Label(i18n.i18n("Interactive forms (AcroForms):")), 0, 0);
    acroForms.setMaxWidth(Double.POSITIVE_INFINITY);
    options.add(acroForms, 1, 0);
    options.add(helpIcon(i18n.i18n("What to do in case one or more input documents contain Acro Forms")), 2, 0);

    outline.getItems().add(keyValue(OutlinePolicy.RETAIN, i18n.i18n("Retain bookmarks")));
    outline.getItems().add(keyValue(OutlinePolicy.DISCARD, i18n.i18n("Discard bookmarks")));
    outline.getItems().add(
            keyValue(OutlinePolicy.ONE_ENTRY_EACH_DOC, i18n.i18n("Create one entry for each merged document")));
    outline.getItems().add(keyValue(OutlinePolicy.RETAIN_AS_ONE_ENTRY,
            i18n.i18n("Retain bookmarks as one entry for each merged document")));

    outline.setId("outlineCombo");
    options.add(new Label(i18n.i18n("Bookmarks handling:")), 0, 1);
    outline.setMaxWidth(Double.POSITIVE_INFINITY);
    options.add(outline, 1, 1);
    options.add(helpIcon(i18n.i18n("What to do in case one or more input documents contain bookmarks")), 2, 1);

    toc.getItems().add(keyValue(ToCPolicy.NONE, i18n.i18n("Don't generate")));
    toc.getItems().add(keyValue(ToCPolicy.FILE_NAMES, i18n.i18n("Generate from file names")));
    toc.getItems().add(keyValue(ToCPolicy.DOC_TITLES, i18n.i18n("Generate from documents titles")));

    toc.setId("tocCombo");
    options.add(new Label(i18n.i18n("Table of contents:")), 0, 2);
    toc.setMaxWidth(Double.POSITIVE_INFINITY);
    options.add(toc, 1, 2);
    options.add(helpIcon(i18n.i18n("Set if a table of contents should be added to the generated PDF document")), 2,
            2);
    options.getStyleClass().addAll(Style.GRID.css());

    getStyleClass().addAll(Style.CONTAINER.css());
    resetView();
    getChildren().addAll(blankIfOdd, footer, normalize, options);
}