Java Code Examples for javafx.scene.layout.HBox#setHgrow()

The following examples show how to use javafx.scene.layout.HBox#setHgrow() . 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: CheckListFormNode.java    From marathonv5 with Apache License 2.0 8 votes vote down vote up
private VBox createDescriptionField() {
    VBox descriptionFieldBox = new VBox();
    TextArea descriptionArea = new TextArea();
    descriptionArea.setPrefRowCount(4);
    descriptionArea.textProperty().addListener((observable, oldValue, newValue) -> {
        fireContentChanged();
        checkList.setDescription(descriptionArea.getText());
    });
    descriptionArea.setEditable(mode.isSelectable());
    descriptionFieldBox.getChildren().addAll(new Label("Description"), descriptionArea);
    HBox.setHgrow(descriptionArea, Priority.ALWAYS);
    VBox.setMargin(descriptionFieldBox, new Insets(5, 10, 5, 5));
    descriptionArea.setText(checkList.getDescription());
    HBox.setHgrow(descriptionArea, Priority.ALWAYS);
    HBox.setHgrow(descriptionFieldBox, Priority.ALWAYS);
    return descriptionFieldBox;
}
 
Example 2
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, Button, Button> addTopLabel2Buttons(GridPane gridPane,
                                                                int rowIndex,
                                                                String labelText,
                                                                String title1,
                                                                String title2,
                                                                double top) {
    HBox hBox = new HBox();
    hBox.setSpacing(10);

    Button button1 = new AutoTooltipButton(title1);
    button1.setDefaultButton(true);
    button1.getStyleClass().add("action-button");
    button1.setDefaultButton(true);
    button1.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button1, Priority.ALWAYS);

    Button button2 = new AutoTooltipButton(title2);
    button2.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(button2, Priority.ALWAYS);

    hBox.getChildren().addAll(button1, button2);

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, labelText, hBox, top);

    return new Tuple3<>(topLabelWithVBox.first, button1, button2);
}
 
Example 3
Source File: SingleSelectionPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public SingleSelectionPane(String ownerModule) {
    this.getStyleClass().add("single-selection-pane");
    this.ownerModule = defaultString(ownerModule);
    this.details.getStyleClass().add("-pdfsam-selection-details");
    SelectButton selectButton = new SelectButton(getOwnerModule());
    field = new BrowsableFileField(FileType.PDF, OpenType.OPEN, selectButton);
    field.enforceValidation(true, false);
    passwordPopup = new PasswordFieldPopup(this.ownerModule);
    encryptionIndicator.getStyleClass().addAll("encryption-status");
    encryptionIndicator.addEventFilter(MouseEvent.MOUSE_CLICKED, e -> {
        if (descriptor.loadingStatus().getValue() == ENCRYPTED) {
            showPasswordFieldPopup();
        } else if (descriptor.loadingStatus().getValue() == WITH_ERRORS) {
            eventStudio().broadcast(ShowStageRequest.INSTANCE, "LogStage");
        }
    });
    HBox.setMargin(encryptionIndicator, new Insets(0, 0, 0, 2));
    field.setGraphic(encryptionIndicator);
    field.getStyleClass().add("single-selection-top");
    HBox.setHgrow(field, Priority.ALWAYS);
    getChildren().addAll(new SingleSelectionPaneToolbar(selectButton, getOwnerModule()), field, details);
    field.getTextField().validProperty().addListener(onValidState);
    initContextMenu();
    eventStudio().addAnnotatedListeners(this);
}
 
Example 4
Source File: EditAxis.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private Pane getAutoRangeCheckBoxes(final Axis axis) {
    final Pane boxMax = new VBox();
    VBox.setVgrow(boxMax, Priority.ALWAYS);

    final CheckBox autoRanging = new CheckBox("auto ranging");
    HBox.setHgrow(autoRanging, Priority.ALWAYS);
    VBox.setVgrow(autoRanging, Priority.ALWAYS);
    autoRanging.setMaxWidth(Double.MAX_VALUE);
    autoRanging.setSelected(axis.isAutoRanging());
    autoRanging.selectedProperty().bindBidirectional(axis.autoRangingProperty());
    boxMax.getChildren().add(autoRanging);

    final CheckBox autoGrow = new CheckBox("auto grow");
    HBox.setHgrow(autoGrow, Priority.ALWAYS);
    VBox.setVgrow(autoGrow, Priority.ALWAYS);
    autoGrow.setMaxWidth(Double.MAX_VALUE);
    autoGrow.setSelected(axis.isAutoGrowRanging());
    autoGrow.selectedProperty().bindBidirectional(axis.autoGrowRangingProperty());
    boxMax.getChildren().add(autoGrow);

    return boxMax;
}
 
Example 5
Source File: BrowsableField.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public BrowsableField(Button browseButton) {
    this.browseButton = browseButton;
    HBox.setHgrow(textField, Priority.ALWAYS);
    this.getStyleClass().add("browsable-field");
    validableContainer = new HBox(textField);
    validableContainer.getStyleClass().add("validable-container");
    textField.getStyleClass().add("validable-container-field");
    HBox.setHgrow(validableContainer, Priority.ALWAYS);
    textField.validProperty().addListener((o, oldValue, newValue) -> {
        if (newValue == ValidationState.INVALID) {
            validableContainer.getStyleClass().addAll(Style.INVALID.css());
        } else {
            validableContainer.getStyleClass().removeAll(Style.INVALID.css());
        }
    });
    textField.focusedProperty().addListener(
            (o, oldVal, newVal) -> validableContainer.pseudoClassStateChanged(SELECTED_PSEUDOCLASS_STATE, newVal));
    getChildren().add(validableContainer);
}
 
Example 6
Source File: ButtonFXControlAdapterSnippet.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Scene createScene() {
	HBox hbox = new HBox();
	VBox col1 = new VBox();
	VBox col2 = new VBox();
	HBox.setMargin(col1, new Insets(10.0));
	HBox.setMargin(col2, new Insets(10.0));
	hbox.getChildren().addAll(col1, col2);
	HBox.setHgrow(col1, Priority.ALWAYS);
	HBox.setHgrow(col2, Priority.ALWAYS);

	col1.getChildren().addAll(new Button("JavaFX Button 1"),
			shape(new Arc(0, 0, 50, 50, 15, 120) {
				{
					setType(ArcType.ROUND);
				}
			}, 0.52, 0.49, 0.15), createButtonAdapter("SWT Button 1"));

	col2.getChildren().addAll(
			shape(new Rectangle(0, 0, 100, 50), 0.49, 0.36, 0.20),
			createButtonAdapter("SWT Button 2"),
			shape(new Rectangle(0, 0, 100, 100) {
				{
					setArcHeight(20);
					setArcWidth(20);
				}
			}, 0.87, 0.83, 0.49), new Button("JavaFX Button 2"));

	return new Scene(hbox, 400, 300);
}
 
Example 7
Source File: PercentSliderControl.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void layoutParts() {
    node.getChildren().addAll(slider, valueLabel);
    HBox.setHgrow(slider, Priority.ALWAYS);
    valueLabel.setAlignment(Pos.CENTER);
    valueLabel.setMinWidth(VALUE_LABEL_PADDING);
    node.setSpacing(VALUE_LABEL_PADDING);
    HBox.setMargin(valueLabel, new Insets(0, VALUE_LABEL_PADDING, 0, 0));
}
 
Example 8
Source File: WebBrowserDemo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public BrowserWithToolbar(String url)
{
    super(url);
    locationChanged(null, null, webEngine.getLocation());
    //assemble toolbar controls
    backButton.setOnAction(this::handleBackButton);
    foreButton.setOnAction(this::handleForeButton);
    stop.setOnAction(this::handleStop);
    refresh.setOnAction(this::handleRefresh);
    addressBar.setOnAction(this::handleGo);
    go.setOnAction(this::handleGo);

    foreButton.setDisable(true);
    backButton.setDisable(true);

    addressBar.setEditable(true);
    //addressBar.setOnShowing(this::handleShowing);
    webEngine.locationProperty().addListener(this::locationChanged);
    history.getEntries().addListener(this::entriesChanged);

    for (int i = 0; i < controls.length; i++)
    {
        Control control = controls[i];
        if (control instanceof ButtonBase)
        {
            HBox.setHgrow(control, Priority.NEVER);
            ((ButtonBase)control).setGraphic(new ImageView(new Image(ModelPlugin.class.getResource("/icons/browser/" + iconFiles[i]).toExternalForm())));
        }
        else
            HBox.setHgrow(control, Priority.ALWAYS);
    }

    //add toolbar component
    toolbar = new HBox(controls);
    toolbar.getStyleClass().add("browser-toolbar");
    getChildren().add(toolbar);
}
 
Example 9
Source File: MainView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@NotNull
private Separator getNavigationSeparator() {
    final Separator separator = new Separator(Orientation.VERTICAL);
    HBox.setHgrow(separator, Priority.ALWAYS);
    separator.setMaxHeight(22);
    separator.setMaxWidth(Double.MAX_VALUE);
    return separator;
}
 
Example 10
Source File: EpidemicReportsChartController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected LabeledBarChart addVerticalBarChart() {
        chartBox.getChildren().clear();
//        boolean intValue = !message("HealedRatio").equals(valueName)
//                && !message("DeadRatio").equals(valueName);
        LabeledBarChart barChart
                = LabeledBarChart.create(categoryAxisCheck.isSelected(), chartCoordinate)
                        .setIntValue(false)
                        .setLabelType(labelType)
                        .setTextSize(textSize);
        barChart.setAlternativeRowFillVisible(false);
        barChart.setAlternativeColumnFillVisible(false);
        barChart.setBarGap(0.0);
        barChart.setCategoryGap(0.0);
        barChart.setAnimated(false);
        barChart.getXAxis().setAnimated(false);
        barChart.getYAxis().setAnimated(false);
        barChart.getXAxis().setTickLabelRotation(90);
        barChart.setVerticalGridLinesVisible(vlinesCheck.isSelected());
        barChart.setHorizontalGridLinesVisible(hlinesCheck.isSelected());
        barChart.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
        VBox.setVgrow(barChart, Priority.ALWAYS);
        HBox.setHgrow(barChart, Priority.ALWAYS);
        if (legendSide == null) {
            barChart.setLegendVisible(false);
        } else {
            barChart.setLegendVisible(true);
            barChart.setLegendSide(legendSide);
        }
        chartBox.getChildren().add(barChart);
        return barChart;
    }
 
Example 11
Source File: LBGradeTab.java    From PDF4Teachers with Apache License 2.0 4 votes vote down vote up
public void setup(){

        fontTiers.put(0, Map.entry(Font.loadFont(FontUtils.getFontFile("Open Sans", false, false), 28), Map.entry(Color.valueOf("#990000"), true)));
        fontTiers.put(1, Map.entry(Font.loadFont(FontUtils.getFontFile("Open Sans", false, false), 24), Map.entry(Color.valueOf("#b31a1a"), false)));
        fontTiers.put(2, Map.entry(Font.loadFont(FontUtils.getFontFile("Open Sans", false, false), 18), Map.entry(Color.valueOf("#cc3333"), false)));
        fontTiers.put(3, Map.entry(Font.loadFont(FontUtils.getFontFile("Open Sans", false, false), 18), Map.entry(Color.valueOf("#e64d4d"), false)));
        fontTiers.put(4, Map.entry(Font.loadFont(FontUtils.getFontFile("Open Sans", false, false), 18), Map.entry(Color.valueOf("#ff6666"), false)));

        lockRatingPotitions.setSelected(false);

        Builders.setHBoxPosition(lockGradeScale, 45, 35, 0);
        lockGradeScale.setCursor(Cursor.HAND);
        lockGradeScale.setSelected(false);
        lockGradeScale.setGraphic(Builders.buildImage(getClass().getResource("/img/GradesTab/cadenas.png") + "", 0, 0));
        lockGradeScale.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
            if(newValue) lockGradeScale.setGraphic(Builders.buildImage(getClass().getResource("/img/GradesTab/cadenas-ferme.png") + "", 0, 0));
            else lockGradeScale.setGraphic(Builders.buildImage(getClass().getResource("/img/GradesTab/cadenas.png") + "", 0, 0));

            // Update the selected cell
            if(treeView.getSelectionModel().getSelectedItem() != null){
                int selected = treeView.getSelectionModel().getSelectedIndex();
                treeView.getSelectionModel().select(null);
                treeView.getSelectionModel().select(selected);
            }
        });
        lockGradeScale.setTooltip(Builders.genToolTip(TR.tr("Vérouiller le barème, il ne pourra plus être modifié.")));

        Builders.setHBoxPosition(settings, 45, 35, 0);
        settings.setCursor(Cursor.HAND);
        settings.setGraphic(Builders.buildImage(getClass().getResource("/img/GradesTab/engrenage.png")+"", 0, 0));
        settings.setOnAction((e) -> new GradeSettingsWindow());
        settings.setTooltip(Builders.genToolTip(TR.tr("Modifier les polices, couleurs et préfixe de chaque niveau de grades.")));

        Builders.setHBoxPosition(link, 45, 35, 0);
        link.setCursor(Cursor.HAND);
        link.setGraphic(Builders.buildImage(getClass().getResource("/img/GradesTab/link.png")+"", 0, 0));
        link.disableProperty().bind(MainWindow.mainScreen.statusProperty().isNotEqualTo(MainScreen.Status.OPEN));
        link.setOnAction((e) -> new GradeCopyGradeScaleDialog());
        link.setTooltip(Builders.genToolTip(TR.tr("Envoyer le barème sur d'autres éditions.")));

        Builders.setHBoxPosition(export, 45, 35, 0);
        export.setCursor(Cursor.HAND);
        export.setGraphic(Builders.buildImage(getClass().getResource("/img/GradesTab/exporter.png")+"", 0, 0));
        export.disableProperty().bind(MainWindow.mainScreen.statusProperty().isNotEqualTo(MainScreen.Status.OPEN));
        export.setOnAction((e) -> new GradeExportWindow());
        export.setTooltip(Builders.genToolTip(TR.tr("Exporter les notes d'une ou plusieurs copies, dans un ou plusieurs fichier CSV. Ceci permet ensuite d'importer les notes dans un logiciel tableur")));

        optionPane.setStyle("-fx-padding: 5 0 5 0;");
        Region spacer = new Region(); HBox.setHgrow(spacer, Priority.ALWAYS);
        optionPane.getChildren().addAll(spacer, lockGradeScale, settings, link, export);

        treeView = new GradeTreeView(this);
        pane.getChildren().addAll(optionPane, treeView);

    }
 
Example 12
Source File: ShortTimeFourierTransformSample.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
@Override
public Node getContent() {
    // rawData chart
    chart3 = new XYChart();
    chart3.getXAxis().setAutoUnitScaling(true);
    chart3.getPlugins().add(new UpdateAxisLabels());
    chart3.getPlugins().add(new Zoomer());
    chart3.getPlugins().add(new EditAxis());
    chart3.getRenderers().add(new MetaDataRenderer(chart3));
    chart3.getDatasets().add(rawData);

    rawData.addListener(evt -> stft(rawData, stftData));
    // Short Time Fourier Transform chart
    chart1 = new XYChart();
    final ContourDataSetRenderer contourChartRenderer1 = new ContourDataSetRenderer();
    chart1.getRenderers().set(0, contourChartRenderer1);
    chart1.getRenderers().add(new MetaDataRenderer(chart1));
    final DefaultNumericAxis xAxis1 = new DefaultNumericAxis();
    xAxis1.setAutoUnitScaling(true);
    xAxis1.setSide(Side.BOTTOM);
    final DefaultNumericAxis yAxis1 = new DefaultNumericAxis();
    yAxis1.setSide(Side.LEFT);
    contourChartRenderer1.getAxes().addAll(xAxis1, yAxis1);
    final Axis zAxis1 = contourChartRenderer1.getZAxis();
    zAxis1.setName("Amplitude"); // TODO: fix label updater to respect z-axis
    zAxis1.setUnit("dB");
    chart1.getAxes().addAll(xAxis1, yAxis1, zAxis1);
    // Add plugins after all axes are correctly set up
    chart1.getPlugins().add(new UpdateAxisLabels());
    chart1.getPlugins().add(new Zoomer());
    chart1.getPlugins().add(new EditAxis());
    chart1.getDatasets().add(TransposedDataSet.transpose(stftData, true));

    rawData.addListener(evt -> wavelet(rawData, waveletData));
    // Wavelet Transform Chart
    chart2 = new XYChart();
    final ContourDataSetRenderer contourChartRenderer2 = new ContourDataSetRenderer();
    chart2.getRenderers().set(0, contourChartRenderer2);
    final DefaultNumericAxis xAxis2 = new DefaultNumericAxis();
    xAxis2.setAutoUnitScaling(true);
    xAxis2.setSide(Side.BOTTOM);
    final DefaultNumericAxis yAxis2 = new DefaultNumericAxis();
    yAxis2.setSide(Side.LEFT);
    contourChartRenderer2.getAxes().addAll(xAxis2, yAxis2);
    final Axis zAxis2 = contourChartRenderer2.getZAxis();
    zAxis2.setName("Amplitude");
    zAxis2.setUnit("dB");
    chart2.getAxes().addAll(xAxis2, yAxis2, zAxis2);
    chart2.getRenderers().add(new MetaDataRenderer(chart2));
    chart2.getPlugins().add(new UpdateAxisLabels());
    chart2.getPlugins().add(new Zoomer());
    chart2.getPlugins().add(new EditAxis());
    chart2.getDatasets().add(waveletData);

    AxisSynchronizer synTime = new AxisSynchronizer();
    synTime.add(xAxis1);
    synTime.add(xAxis2);
    synTime.add(chart3.getXAxis());
    AxisSynchronizer synFreq = new AxisSynchronizer();
    synFreq.add(yAxis1);
    synFreq.add(yAxis2);

    final Node content = new VBox(5, chart3, new HBox(5, chart1, chart2),
            new HBox(20, rawDataSettingsPane(), stftSettingsPane(), waveletSettingsPane()));

    HBox.setHgrow(chart1, Priority.ALWAYS);
    HBox.setHgrow(chart2, Priority.ALWAYS);

    updateRawData(rawData);
    stft(rawData, stftData);
    wavelet(rawData, waveletData);

    return content;
}
 
Example 13
Source File: MainView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@NotNull
private Region getNavigationSpacer() {
    final Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    return spacer;
}
 
Example 14
Source File: EditStatus.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Node constructContent() {
    
    StackPane stackpaneroot = new StackPane();
    
    boxview = new HBox();
    boxview.setSpacing(6.0);
    
    statusview = new TextField();
    statusview.setEditable(false);
    statusview.setFocusTraversable(false);
    statusview.getStyleClass().add("unitinputview");
    HBox.setHgrow(statusview, Priority.SOMETIMES);
    
    editaction = new Button();
    editaction.setFocusTraversable(false);
    editaction.setMnemonicParsing(false);
    editaction.getStyleClass().add("unitbutton");
    editaction.setOnAction(this::onEditEvent);
    
    boxview.getChildren().addAll(statusview, editaction);
    
    boxedit = new HBox();
    boxedit.setSpacing(6.0);
    boxedit.setVisible(false);
    
    statusedit = new TextField();
    statusedit.getStyleClass().add("unitinput");
    HBox.setHgrow(statusedit, Priority.SOMETIMES);
    ((TextField) statusedit).setOnAction(this::onEnterEvent);
    
    okaction = new Button();
    okaction.setFocusTraversable(false);
    okaction.setMnemonicParsing(false);
    okaction.getStyleClass().add("unitbutton");
    okaction.setOnAction(this::onOkEvent);
    
    cancelaction = new Button();
    cancelaction.setFocusTraversable(false);
    cancelaction.setMnemonicParsing(false);
    cancelaction.getStyleClass().add("unitbutton");
    cancelaction.setOnAction(this::onCancelEvent);
    
    boxedit.getChildren().addAll(statusedit, okaction, cancelaction);
    
    stackpaneroot.getChildren().addAll(boxview, boxedit);

    initialize();
    return stackpaneroot;
}
 
Example 15
Source File: MessageItem.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
public MessageItem(EventMessage message) {
    getStyleClass().add("message");
    setMaxSize(Double.MAX_VALUE, 60.0);
    setMinSize(Control.USE_COMPUTED_SIZE, 60.0);
    setPrefSize(Control.USE_COMPUTED_SIZE, 60.0);
    HBox.setHgrow(this, Priority.SOMETIMES);   
    
    StringFormat format = StringFormatIdentity.INSTANCE;
    String txt = format.format(format.value(message.getMessage()));
    
    Label messageview = new Label(txt);
    messageview.setTextOverrun(OverrunStyle.ELLIPSIS);
    messageview.getStyleClass().add("unitinputview");
    BorderPane.setAlignment(messageview, Pos.CENTER_LEFT);

    setCenter(messageview);
    
    HBox footer = new HBox();
    
    Label topictext = new Label(message.getTopic());
    topictext.setTextOverrun(OverrunStyle.ELLIPSIS);
    topictext.getStyleClass().add("messagefooter");
    topictext.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(topictext, Priority.ALWAYS);
    footer.getChildren().add(topictext);        
    
    DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
    Label datetext = new Label(LocalDateTime.now().format(dtf));
    datetext.getStyleClass().add("messagefooter");
    footer.getChildren().add(datetext);
    
    MiniVar v2 = message.getProperty("mqtt.retained");
    if (v2 != null && v2.asBoolean()) {
        Label retainedtext = new Label(resources.getString("badge.retained"));
        retainedtext.getStyleClass().addAll("badge", "badgeretained");
        footer.getChildren().add(retainedtext);            
    }    
    
    MiniVar v = message.getProperty("mqtt.qos");
    if (v != null) {
        Label qostext = new Label(String.format(resources.getString("badge.qos"), v.asInt()));
        qostext.getStyleClass().addAll("badge", "badgeqos");
        footer.getChildren().add(qostext);            
    }

    setBottom(footer);
}
 
Example 16
Source File: EpidemicReportsSettingsController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
protected void makeLocationsColors() {
    try {
        colorRects.clear();
        locationColorsBox.getChildren().clear();
        List<GeographyCode> locations = chartController.chartLocations;
        if (locations == null || locationColors == null) {
            return;
        }
        Collections.sort(locations, (GeographyCode p1, GeographyCode p2)
                -> p1.getFullName().compareTo(p2.getFullName()));
        for (int i = 0; i < locations.size(); i++) {
            GeographyCode location = locations.get(i);
            String name = location.getFullName();
            String color = locationColors.get(name);
            Label label = new Label(name);
            Rectangle rect = new Rectangle();
            rect.setWidth(15);
            rect.setHeight(15);
            Color c = Color.web(color);
            rect.setFill(c);
            FxmlControl.setTooltip(rect, new Tooltip(FxmlColor.colorNameDisplay(c)));
            rect.setUserData(name);
            colorRects.add(rect);

            Button button = new Button();
            ImageView image = new ImageView(ControlStyle.getIcon("iconPalette.png"));
            image.setFitWidth(AppVariables.iconSize);
            image.setFitHeight(AppVariables.iconSize);
            button.setGraphic(image);
            button.setOnAction((ActionEvent event) -> {
                showPalette(button, message("Settings") + " - " + name);
            });
            button.setUserData(i);
            VBox.setMargin(button, new Insets(0, 0, 0, 15));
            FxmlControl.setTooltip(button, message("Palette"));

            HBox line = new HBox();
            line.setAlignment(Pos.CENTER_LEFT);
            line.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            line.setSpacing(5);
            VBox.setVgrow(line, Priority.ALWAYS);
            HBox.setHgrow(line, Priority.ALWAYS);
            line.getChildren().addAll(label, rect, button);

            locationColorsBox.getChildren().add(line);
        }
    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example 17
Source File: GraphqlRequestEditor.java    From milkman with MIT License 4 votes vote down vote up
public GraphqlRequestEditorFxml(GraphqlRequestEditor controller) {
	this.controller = controller;
	HBox.setHgrow(this, Priority.ALWAYS);
	controller.requestUrl = add(new JFXTextField(), true);
	controller.requestUrl.setId("requestUrl");
}
 
Example 18
Source File: SearchView.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** Create search view
 *
 *  <p>While technically a {@link SplitPane},
 *  should be treated as generic {@link Node},
 *  using only the API defined in here
 *
 *  @param model
 *  @param undo
 */
public SearchView(final Model model, final UndoableActionManager undo)
{
    this.model = model;
    this.undo = undo;

    // Archive List

    // Pattern: ____________ [Search]
    pattern.setTooltip(new Tooltip(Messages.SearchPatternTT));
    pattern.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(pattern, Priority.ALWAYS);
    final Button search = new Button(Messages.Search);
    search.setTooltip(new Tooltip(Messages.SearchTT));
    final HBox search_row = new HBox(5.0, new Label(Messages.SearchPattern), pattern, search);
    search_row.setAlignment(Pos.CENTER_LEFT);
    pattern.setOnAction(event -> searchForChannels());
    search.setOnAction(event -> searchForChannels());

    //  ( ) Add .. (x) Replace search result
    final RadioButton result_add = new RadioButton(Messages.AppendSearchResults);
    result_add.setTooltip(new Tooltip(Messages.AppendSearchResultsTT));
    result_replace = new RadioButton(Messages.ReplaceSearchResults);
    result_replace.setTooltip(new Tooltip(Messages.ReplaceSearchResultsTT));
    final ToggleGroup result_handling = new ToggleGroup();
    result_add.setToggleGroup(result_handling);
    result_replace.setToggleGroup(result_handling);
    result_replace.setSelected(true);
    final HBox replace_row = new HBox(5.0, result_add, result_replace);
    replace_row.setAlignment(Pos.CENTER_RIGHT);

    // PV Name  |  Source
    // ---------+--------
    //          |
    final TableColumn<ChannelInfo, String> pv_col = new TableColumn<>(Messages.PVName);
    pv_col.setCellValueFactory(cell ->  new SimpleStringProperty(cell.getValue().getName()));
    pv_col.setReorderable(false);
    channel_table.getColumns().add(pv_col);

    final TableColumn<ChannelInfo, String> archive_col = new TableColumn<>(Messages.ArchiveName);
    archive_col.setCellValueFactory(cell ->  new SimpleStringProperty(cell.getValue().getArchiveDataSource().getName()));
    archive_col.setReorderable(false);
    channel_table.getColumns().add(archive_col);
    channel_table.setPlaceholder(new Label(Messages.SearchPatternTT));

    // PV name column uses most of the space, archive column the rest
    pv_col.prefWidthProperty().bind(channel_table.widthProperty().multiply(0.8));
    archive_col.prefWidthProperty().bind(channel_table.widthProperty().subtract(pv_col.widthProperty()));

    channel_table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    VBox.setVgrow(channel_table, Priority.ALWAYS);
    search_row.setPadding(new Insets(5, 5, 0, 5));
    replace_row.setPadding(new Insets(5, 5, 0, 5));
    final VBox bottom = new VBox(5, search_row,
                                    replace_row,
                                    channel_table);
    setOrientation(Orientation.VERTICAL);
    getItems().setAll(archive_list, bottom);
    setDividerPositions(0.2f);

    final ContextMenu menu = new ContextMenu();
    channel_table.setContextMenu(menu);
    channel_table.setOnContextMenuRequested(this::updateContextMenu);

    setupDrag();

    Platform.runLater(() -> pattern.requestFocus());
}
 
Example 19
Source File: EditAxis.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
private final TextField getBoundField(final Axis axis, final boolean isLowerBound) {
    final TextField textField = new TextField();

    // ValidationSupport has a slow memory leak
    // final ValidationSupport support = new ValidationSupport();
    // final Validator<String> validator = (final Control control, final
    // String value) -> {
    // boolean condition = value == null ? true :
    // !value.matches(NUMBER_REGEX);
    //
    // // additional check in case of logarithmic axis
    // if (!condition && axis.isLogAxis() && Double.parseDouble(value)
    // <= 0) {
    // condition = true;
    // }
    // // change text colour depending on validity as a number
    // textField.setStyle(condition ? "-fx-text-inner-color: red;" :
    // "-fx-text-inner-color: black;");
    // return ValidationResult.fromMessageIf(control, "not a number",
    // Severity.ERROR, condition);
    // };
    // support.registerValidator(textField, true, validator);

    final Runnable lambda = () -> {
        final double value;
        final boolean isInverted = axis.isInvertedAxis();
        if (isLowerBound) {
            value = isInverted ? axis.getMax() : axis.getMin();
        } else {
            value = isInverted ? axis.getMin() : axis.getMax();
        }
        textField.setText(Double.toString(value));
    };

    axis.invertAxisProperty().addListener((ch, o, n) -> lambda.run());
    axis.minProperty().addListener((ch, o, n) -> lambda.run());
    axis.maxProperty().addListener((ch, o, n) -> lambda.run());

    // force the field to be numeric only
    textField.textProperty().addListener((observable, oldValue, newValue) -> {
        if ((newValue != null) && !newValue.matches("\\d*")) {
            final double val;
            try {
                val = Double.parseDouble(newValue);
            } catch (NullPointerException | NumberFormatException e) {
                // not a parsable number
                textField.setText(oldValue);
                return;
            }

            if (axis.isLogAxis() && (val <= 0)) {
                textField.setText(oldValue);
                return;
            }
            textField.setText(Double.toString(val));
        }
    });

    textField.setOnKeyPressed(ke -> {
        if (ke.getCode().equals(KeyCode.ENTER)) {
            final double presentValue = Double.parseDouble(textField.getText());
            if (isLowerBound && !axis.isInvertedAxis()) {
                axis.setMin(presentValue);
            } else {
                axis.setMax(presentValue);
            }
            axis.setAutoRanging(false);

            if (axis instanceof AbstractAxis) {
                // ((AbstractAxis) axis).recomputeTickMarks();
                axis.setTickUnit(((AbstractAxis) axis).computePreferredTickUnit(axis.getLength()));
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("recompute axis tick unit to {}",
                            ((AbstractAxis) axis).computePreferredTickUnit(axis.getLength()));
                }
            }
        }
    });

    HBox.setHgrow(textField, Priority.ALWAYS);
    VBox.setVgrow(textField, Priority.ALWAYS);

    return textField;
}
 
Example 20
Source File: FilterPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initialize() {
    HBox.setHgrow(searchField, Priority.ALWAYS);
}