Java Code Examples for javafx.scene.layout.GridPane#setValignment()

The following examples show how to use javafx.scene.layout.GridPane#setValignment() . 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: UiFormantGrid.java    From EWItool with GNU General Public License v3.0 6 votes vote down vote up
UiFormantGrid( EWI4000sPatch editPatch, MidiHandler midiHandler ) {
  
  setId( "editor-grid" );
  
  Label mainLabel = new Label( "Formant Filter" );
  mainLabel.setId( "editor-section-label" );
  GridPane.setValignment( mainLabel, VPos.TOP );
  add( mainLabel, 0, 0 );

  formantChoice = new ChoiceBox<String>();
  formantChoice.getItems().addAll( "Off", "Woodwind", "Strings" );
  formantChoice.setOnAction( (event) -> {
    midiHandler.sendLiveControl( 5, 81, formantChoice.getSelectionModel().getSelectedIndex() );
    editPatch.formantFilter = formantChoice.getSelectionModel().getSelectedIndex(); 
  });
  add( formantChoice, 0, 1 );
}
 
Example 2
Source File: RadioButtonDrivenTextFieldsPane.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public void addRow(RadioButton radio, Region field, Text helpIcon) {
    requireNotNullArg(radio, "Cannot add a null radio");
    requireNotNullArg(field, "Cannot add a null field");
    GridPane.setValignment(radio, VPos.BOTTOM);
    GridPane.setValignment(field, VPos.BOTTOM);
    GridPane.setHalignment(radio, HPos.LEFT);
    GridPane.setHalignment(field, HPos.LEFT);
    GridPane.setFillWidth(field, true);
    field.setPrefWidth(300);
    field.setDisable(true);
    radio.selectedProperty().addListener((o, oldVal, newVal) -> {
        field.setDisable(!newVal);
        if (newVal) {
            field.requestFocus();
        }
    });
    radio.setToggleGroup(group);
    add(radio, 0, rows);
    add(field, 1, rows);
    if (nonNull(helpIcon)) {
        add(helpIcon, 2, rows);
    }
    rows++;

}
 
Example 3
Source File: FormPane.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public FormPane addFormField(String text, Node... fields) {
    Label label = new Label(text);
    String labelId = idText(text);
    label.setId(labelId);
    GridPane.setValignment(label, VPos.TOP);
    int column = 0;
    add(label, column++, currentRow, 1, 1);
    int colspan = columns - fields.length;
    int fieldIndex = 1;
    for (Node field : fields) {
        field.setId(labelId + "-field-" + fieldIndex);
        setFormConstraints(field);
        GridPane.setValignment(field, VPos.TOP);
        add(field, column++, currentRow, colspan, 1);
        fieldIndex++;
    }
    currentRow++;
    column = 0;
    return this;
}
 
Example 4
Source File: AlertCell.java    From DashboardFx with GNU General Public License v3.0 6 votes vote down vote up
private void config(){
    this.getStyleClass().add("alert-cell");
    this.setAlignment(Pos.CENTER_LEFT);
    this.setPrefHeight(40D);
    this.title.setStyle("-fx-font-size : 14;");
    this.text.getStyleClass().addAll("h6");
    this.text.setStyle("-fx-fill : -text-color;");
    this.time.setStyle("-fx-text-fill : -text-color; -fx-font-style : italic; ");
    textFlow.getChildren().addAll(text);
    this.content.getChildren().addAll(this.title, textFlow, this.time);
    this.content.setAlignment(Pos.CENTER_LEFT);
    this.getChildren().add(content);
    this.setAlignment(Pos.CENTER);
    HBox.setHgrow(content, Priority.ALWAYS);
    GridPane.setHalignment(this.time, HPos.RIGHT);
    GridPane.setValignment(this.time, VPos.CENTER);
    GridPane.setHgrow(this.time, Priority.ALWAYS);
    HBox.setMargin(this.content, new Insets(0,0,0,10));
}
 
Example 5
Source File: PatientView.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void layoutParts() {
  setSpacing(20);

  GridPane dashboard = new GridPane();
  RowConstraints growingRow = new RowConstraints();
  growingRow.setVgrow(Priority.ALWAYS);
  ColumnConstraints growingCol = new ColumnConstraints();
  growingCol.setHgrow(Priority.ALWAYS);
  dashboard.getRowConstraints().setAll(growingRow, growingRow);
  dashboard.getColumnConstraints().setAll(growingCol, growingCol);

  dashboard.setVgap(60);

  dashboard.setPrefHeight(800);
  dashboard.addRow(0, bloodPressureSystolicControl, bloodPressureDiastolicControl);
  dashboard.addRow(1, weightControl, tallnessControl);


  setHgrow(dashboard, Priority.ALWAYS);

  GridPane form = new GridPane();
  form.setHgap(10);
  form.setVgap(25);
  form.setMaxWidth(410);

  GridPane.setVgrow(imageView, Priority.ALWAYS);
  GridPane.setValignment(imageView, VPos.BOTTOM);

  form.add(firstNameField, 0, 0);
  form.add(lastNameField, 1, 0);
  form.add(yearOfBirthField, 0, 1);
  form.add(genderField, 1, 1);
  form.add(imageView, 0, 2, 2, 1);
  form.add(imgURLField, 0, 3, 2, 1);

  getChildren().addAll(form, dashboard);

}
 
Example 6
Source File: FormPane.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public FormPane addFormField(String text, Node field, int colSpan, int rowSpan) {
    Label label = new Label(text);
    String labelId = idText(text);
    label.setId(labelId);
    GridPane.setValignment(label, VPos.TOP);
    int column = 0;
    add(label, column++, currentRow, 1, 1);
    field.setId(labelId + "-field-1");
    setFormConstraints(field);
    GridPane.setValignment(field, VPos.TOP);
    add(field, column++, currentRow, colSpan, rowSpan);
    currentRow += rowSpan;
    column = 0;
    return this;
}
 
Example 7
Source File: Properties.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private void setCommand(final TreeItem<ScanCommand> tree_item)
{
    final GridPane prop_grid = new GridPane();
    prop_grid.setPadding(new Insets(5));
    prop_grid.setHgap(5);
    prop_grid.setVgap(5);

    if (tree_item != null)
    {
        int row = 0;
        for (ScanCommandProperty prop : tree_item.getValue().getProperties())
        {
            final Label label = new Label(prop.getName());
            prop_grid.add(label, 0, row);

            try
            {
                final Node editor = createEditor(tree_item, prop);
                GridPane.setHgrow(editor, Priority.ALWAYS);
                GridPane.setFillWidth(editor, true);

                // Label defaults to vertical center,
                // which is good for one-line editors.
                if (editor instanceof StringArrayEditor)
                    GridPane.setValignment(label, VPos.TOP);

                prop_grid.add(editor, 1, row++);
            }
            catch (Exception ex)
            {
                logger.log(Level.WARNING, "Cannot create editor for " + prop, ex);
            }
            ++row;
        }
    }

    scroll.setContent(prop_grid);
}
 
Example 8
Source File: ShortcutInformationPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Updates the shortcutProperties of the shortcut in the given {@link GridPane propertiesGrid}
 *
 * @param propertiesGrid The shortcutProperties grid
 */
private void updateProperties(final GridPane propertiesGrid) {
    propertiesGrid.getChildren().clear();

    for (Map.Entry<String, Object> entry : shortcutProperties.entrySet()) {
        final int row = propertiesGrid.getRowCount();

        if (!entry.getKey().equals("environment")) {
            final Label keyLabel = new Label(tr(decamelize(entry.getKey())) + ":");
            keyLabel.getStyleClass().add("captionTitle");
            GridPane.setValignment(keyLabel, VPos.TOP);

            final Label valueLabel = new Label(entry.getValue().toString());
            valueLabel.setWrapText(true);

            propertiesGrid.addRow(row, keyLabel, valueLabel);
        }
    }

    // set the environment
    this.environmentAttributes.clear();

    if (shortcutProperties.containsKey("environment")) {
        final Map<String, String> environment = (Map<String, String>) shortcutProperties.get("environment");

        this.environmentAttributes.putAll(environment);
    }
}
 
Example 9
Source File: Exercise_14_07.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a GridPane and set its properties
	GridPane pane = new GridPane();
	pane.setPadding(new Insets(5, 5, 5, 5));
	pane.setHgap(5);
	pane.setVgap(5);

	// Place text fields containing a centered, 
	// randomly generated string of 0 or 1 in the pane
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			TextField text = new TextField();
			text.setPrefColumnCount(1);
			text.setText(String.valueOf((int)(Math.random() * 2)));
			pane.add(text, i, j);
			pane.setHalignment(text, HPos.CENTER);
			pane.setValignment(text, VPos.CENTER);
		}
	}

	// Create a scene and plane it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_14_07"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 10
Source File: SignPaymentAccountsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addSuccessContent() {
    removeContent();
    GridPane.setVgrow(descriptionLabel, Priority.ALWAYS);
    GridPane.setValignment(descriptionLabel, VPos.TOP);

    closeButton.setVisible(false);
    closeButton.setManaged(false);
    headLineLabel.setText(Res.get("popup.accountSigning.success.headline"));
    descriptionLabel.setText(Res.get("popup.accountSigning.success.description", selectedPaymentAccountsList.getItems().size()));
    ((AutoTooltipButton) actionButton).updateText(Res.get("shared.ok"));
    actionButton.setOnAction(a -> hide());
}
 
Example 11
Source File: BaseInfoTab.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
protected static Label createTitleLabel(String text) {
    Label ret = new Label(DefaultI18nContext.getInstance().i18n(text) + ":");
    ret.getStyleClass().add("info-property");
    GridPane.setHalignment(ret, HPos.RIGHT);
    GridPane.setValignment(ret, VPos.TOP);
    return ret;
}
 
Example 12
Source File: PreferencesFxGroupRenderer.java    From PreferencesFX with Apache License 2.0 4 votes vote down vote up
/**
 * Defines the layout of the rendered group.
 */
public void layoutParts() {
  StringBuilder styleClass = new StringBuilder("group");

  // if there are no rows yet, getRowCount returns -1, in this case the next row is 0
  int nextRow = PreferencesFxUtils.getRowCount(grid) + 1;

  // Only when the preferencesGroup has a title
  if (preferencesGroup.getTitle() != null) {
    grid.add(titleLabel, 0, nextRow++, 2, 1);
    styleClass.append("-title");
    titleLabel.getStyleClass().add("group-title");
  }

  List<Element> elements = preferencesGroup.getElements().stream()
      .map(Element.class::cast)
      .collect(Collectors.toList());
  styleClass.append("-setting");

  int rowAmount = nextRow;
  for (int i = 0; i < elements.size(); i++) {
    // add to GridPane
    Element element = elements.get(i);
    if (element instanceof Field) {
      SimpleControl c = (SimpleControl) ((Field)element).getRenderer();
      c.setField((Field)element);
      grid.add(c.getFieldLabel(), 0, i + rowAmount, 1, 1);
      grid.add(c.getNode(), 1, i + rowAmount, 1, 1);

      // Styling
      GridPane.setHgrow(c.getNode(), Priority.SOMETIMES);
      GridPane.setValignment(c.getNode(), VPos.CENTER);
      GridPane.setValignment(c.getFieldLabel(), VPos.CENTER);

      // additional styling for the last setting
      if (i == elements.size() - 1) {
        styleClass.append("-last");
        GridPane.setMargin(
            c.getNode(),
            new Insets(0, 0, PreferencesFxFormRenderer.SPACING * 4, 0)
        );
        GridPane.setMargin(
            c.getFieldLabel(),
            new Insets(0, 0, PreferencesFxFormRenderer.SPACING * 4, 0)
        );
      }

      c.getFieldLabel().getStyleClass().add(styleClass.toString() + "-label");
      c.getNode().getStyleClass().add(styleClass.toString() + "-node");
    }
    if (element instanceof NodeElement) {
      NodeElement nodeElement = (NodeElement) element;
      grid.add(nodeElement.getNode(), 0, i + rowAmount, GridPane.REMAINING, 1);
    }
  }
}
 
Example 13
Source File: PluginParametersPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public Pane getParamPane(final PluginParametersNode node) {
    if (node.getChildren().isEmpty()) {
        return null;
    }

    final GridPane paramGroupPane = new PluginParametersPane();
    paramGroupPane.setMinHeight(0);
    GridPane.setHalignment(paramGroupPane, HPos.LEFT);
    paramGroupPane.setPadding(Insets.EMPTY);

    int row = 0;
    final DoubleProperty descriptionWidth = new SimpleDoubleProperty();
    DoubleProperty maxLabelWidth = new SimpleDoubleProperty();

    for (final PluginParametersNode child : node.getChildren()) {
        while (child.getFormatter().nextElement(child)) {
            final RowConstraints rowConstraints = new RowConstraints();
            rowConstraints.setVgrow(Priority.NEVER);
            rowConstraints.setFillHeight(true);
            paramGroupPane.getRowConstraints().addAll(rowConstraints);

            final LabelDescriptionBox label = child.getFormatter().getParamLabel(child);
            if (label != null) {
                paramGroupPane.add(label, 0, row);
                GridPane.setValignment(label, VPos.TOP);
                GridPane.setHgrow(label, Priority.ALWAYS);
                GridPane.setFillHeight(label, false);

                label.bindDescriptionToProperty(descriptionWidth);
                maxLabelWidth = label.updateBindingWithLabelWidth(maxLabelWidth);
            }

            final Pane paramPane = child.getFormatter().getParamPane(child);
            if (paramPane != null) {
                paramPane.setStyle("-fx-padding: " + PADDING);
                GridPane.setValignment(paramPane, VPos.TOP);
                GridPane.setFillHeight(paramPane, false);
                if (label == null) {
                    paramGroupPane.add(paramPane, 0, row, 2, 1);
                } else {
                    paramGroupPane.add(paramPane, 1, row);
                }
            }

            final Button paramHelp = child.getFormatter().getParamHelp(child);
            if (paramHelp != null) {
                paramGroupPane.add(paramHelp, 2, row);
                GridPane.setMargin(paramHelp, new Insets(PADDING, PADDING, 0, 0));
                GridPane.setValignment(paramHelp, VPos.TOP);
                GridPane.setFillHeight(paramHelp, false);
            }

            row++;
        }
    }

    descriptionWidth.bind(Bindings.max(50, maxLabelWidth));

    return paramGroupPane;
}
 
Example 14
Source File: SignPaymentAccountsWindow.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addECKeyField() {
    privateKey = addInputTextField(gridPane, ++rowIndex, Res.get("popup.accountSigning.signAccounts.ECKey"));
    GridPane.setVgrow(privateKey, Priority.ALWAYS);
    GridPane.setValignment(privateKey, VPos.TOP);
}
 
Example 15
Source File: AgentRegistrationView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    columnConstraints1.setMaxWidth(500);
    gridPane.getColumnConstraints().addAll(columnConstraints1);
    root.getChildren().add(gridPane);

    addTitledGroupBg(gridPane, gridRow, 4, Res.get("account.arbitratorRegistration.registration", getRole()));
    TextField pubKeyTextField = addTopLabelTextField(gridPane, gridRow, Res.get("account.arbitratorRegistration.pubKey"),
            model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;

    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);

    Tuple3<Label, ListView<String>, VBox> tuple = FormBuilder.addTopLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
    GridPane.setValignment(tuple.first, VPos.TOP);
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<>() {
        @Override
        public ListCell<String> call(ListView<String> list) {
            return new ListCell<>() {
                final Label label = new AutoTooltipLabel();
                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);
                final Button removeButton = new AutoTooltipButton("", icon);
                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });

    languageComboBox = FormBuilder.addComboBox(gridPane, ++gridRow);
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText(Res.get("shared.addLanguage"));
    languageComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());

    Tuple2<Button, Button> buttonButtonTuple2 = add2ButtonsAfterGroup(gridPane, ++gridRow,
            Res.get("account.arbitratorRegistration.register"), Res.get("account.arbitratorRegistration.revoke"));
    Button registerButton = buttonButtonTuple2.first;
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());

    Button revokeButton = buttonButtonTuple2.second;
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());

    final TitledGroupBg titledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 2,
            Res.get("shared.information"), Layout.GROUP_DISTANCE);

    titledGroupBg.getStyleClass().add("last");

    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText(Res.get("account.arbitratorRegistration.info.msg", getRole().toLowerCase()));
}
 
Example 16
Source File: OfferBookView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void initialize() {
    root.setPadding(new Insets(15, 15, 5, 15));

    final TitledGroupBg titledGroupBg = addTitledGroupBg(root, gridRow, 2, Res.get("offerbook.availableOffers"));
    titledGroupBg.getStyleClass().add("last");

    HBox hBox = new HBox();
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.setSpacing(35);
    hBox.setPadding(new Insets(10, 0, 0, 0));

    final Tuple3<VBox, Label, AutocompleteComboBox<TradeCurrency>> currencyBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
            Res.get("offerbook.filterByCurrency"));
    final Tuple3<VBox, Label, AutocompleteComboBox<PaymentMethod>> paymentBoxTuple = FormBuilder.addTopLabelAutocompleteComboBox(
            Res.get("offerbook.filterByPaymentMethod"));

    createOfferButton = new AutoTooltipButton();
    createOfferButton.setMinHeight(40);
    createOfferButton.setGraphicTextGap(10);
    AnchorPane.setRightAnchor(createOfferButton, 0d);
    AnchorPane.setBottomAnchor(createOfferButton, 0d);

    hBox.getChildren().addAll(currencyBoxTuple.first, paymentBoxTuple.first, createOfferButton);
    AnchorPane.setLeftAnchor(hBox, 0d);
    AnchorPane.setTopAnchor(hBox, 0d);
    AnchorPane.setBottomAnchor(hBox, 0d);

    AnchorPane anchorPane = new AnchorPane();
    anchorPane.getChildren().addAll(hBox, createOfferButton);

    GridPane.setHgrow(anchorPane, Priority.ALWAYS);
    GridPane.setRowIndex(anchorPane, gridRow);
    GridPane.setColumnSpan(anchorPane, 2);
    GridPane.setMargin(anchorPane, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    root.getChildren().add(anchorPane);

    currencyComboBox = currencyBoxTuple.third;

    paymentMethodComboBox = paymentBoxTuple.third;
    paymentMethodComboBox.setCellFactory(GUIUtil.getPaymentMethodCellFactory());

    tableView = new TableView<>();

    GridPane.setRowIndex(tableView, ++gridRow);
    GridPane.setColumnIndex(tableView, 0);
    GridPane.setColumnSpan(tableView, 2);
    GridPane.setMargin(tableView, new Insets(10, 0, -10, 0));
    GridPane.setVgrow(tableView, Priority.ALWAYS);
    root.getChildren().add(tableView);

    marketColumn = getMarketColumn();

    priceColumn = getPriceColumn();
    tableView.getColumns().add(priceColumn);
    amountColumn = getAmountColumn();
    tableView.getColumns().add(amountColumn);
    volumeColumn = getVolumeColumn();
    tableView.getColumns().add(volumeColumn);
    paymentMethodColumn = getPaymentMethodColumn();
    tableView.getColumns().add(paymentMethodColumn);
    signingStateColumn = getSigningStateColumn();
    tableView.getColumns().add(signingStateColumn);
    avatarColumn = getAvatarColumn();
    tableView.getColumns().add(getActionColumn());
    tableView.getColumns().add(avatarColumn);

    tableView.getSortOrder().add(priceColumn);
    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    marketColumn.setComparator(Comparator.comparing(
            o -> CurrencyUtil.getCurrencyPair(o.getOffer().getCurrencyCode()),
            Comparator.nullsFirst(Comparator.naturalOrder())
    ));
    priceColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPrice(), Comparator.nullsFirst(Comparator.naturalOrder())));
    amountColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinAmount()));
    volumeColumn.setComparator(Comparator.comparing(o -> o.getOffer().getMinVolume(), Comparator.nullsFirst(Comparator.naturalOrder())));
    paymentMethodColumn.setComparator(Comparator.comparing(o -> o.getOffer().getPaymentMethod()));
    avatarColumn.setComparator(Comparator.comparing(o -> o.getOffer().getOwnerNodeAddress().getFullAddress()));

    nrOfOffersLabel = new AutoTooltipLabel("");
    nrOfOffersLabel.setId("num-offers");
    GridPane.setHalignment(nrOfOffersLabel, HPos.LEFT);
    GridPane.setVgrow(nrOfOffersLabel, Priority.NEVER);
    GridPane.setValignment(nrOfOffersLabel, VPos.TOP);
    GridPane.setRowIndex(nrOfOffersLabel, ++gridRow);
    GridPane.setColumnIndex(nrOfOffersLabel, 0);
    GridPane.setMargin(nrOfOffersLabel, new Insets(10, 0, 0, 0));
    root.getChildren().add(nrOfOffersLabel);

    offerListListener = c -> nrOfOffersLabel.setText(Res.get("offerbook.nrOffers", model.getOfferList().size()));

    // Fixes incorrect ordering of Available offers:
    // https://github.com/bisq-network/bisq-desktop/issues/588
    priceFeedUpdateCounterListener = (observable, oldValue, newValue) -> tableView.sort();
}
 
Example 17
Source File: InfoDisplay.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
public InfoDisplay() {
    icon.setId("non-clickable-icon");
    icon.visibleProperty().bind(visibleProperty());

    GridPane.setValignment(icon, VPos.TOP);
    GridPane.setMargin(icon, new Insets(-2, 0, 0, 0));
    GridPane.setRowSpan(icon, 2);

    label = new AutoTooltipLabel();
    label.textProperty().bind(text);
    label.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    // width is set a frame later so we hide it first
    label.setVisible(false);

    link = new Hyperlink(Res.get("shared.readMore"));
    link.setPadding(new Insets(0, 0, 0, -2));

    // We need that to know if we have a wrapping or not.
    // Did not find a way to get that from the API.
    Label testLabel = new AutoTooltipLabel();
    testLabel.textProperty().bind(text);

    textFlow = new TextFlow();
    textFlow.visibleProperty().bind(visibleProperty());
    textFlow.getChildren().addAll(testLabel);

    testLabel.widthProperty().addListener((ov, o, n) -> {
        useReadMore = (double) n > textFlow.getWidth();
        link.setText(Res.get(useReadMore ? "shared.readMore" : "shared.openHelp"));
        UserThread.execute(() -> textFlow.getChildren().setAll(label, link));
    });

    // update the width when the window gets resized
    ChangeListener<Number> listener = (ov2, oldValue2, windowWidth) -> {
        if (label.prefWidthProperty().isBound())
            label.prefWidthProperty().unbind();
        label.setPrefWidth((double) windowWidth - localToScene(0, 0).getX() - 35);
    };


    // when clicking "Read more..." we expand and change the link to the Help
    link.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            if (useReadMore) {

                label.setWrapText(true);
                link.setText(Res.get("shared.openHelp"));
                getScene().getWindow().widthProperty().removeListener(listener);
                if (label.prefWidthProperty().isBound())
                    label.prefWidthProperty().unbind();
                label.prefWidthProperty().bind(textFlow.widthProperty());
                link.setVisited(false);
                // focus border is a bit confusing here so we remove it
                link.getStyleClass().add("hide-focus");
                link.setOnAction(onAction.get());
                getParent().layout();
            } else {
                onAction.get().handle(actionEvent);
            }
        }
    });

    sceneProperty().addListener((ov, oldValue, newValue) -> {
        if (oldValue == null && newValue != null && newValue.getWindow() != null) {
            newValue.getWindow().widthProperty().addListener(listener);
            // localToScene does deliver 0 instead of the correct x position when scene property gets set,
            // so we delay for 1 render cycle
            UserThread.execute(() -> {
                label.setVisible(true);
                label.prefWidthProperty().unbind();
                label.setPrefWidth(newValue.getWindow().getWidth() - localToScene(0, 0).getX() - 35);
            });
        }
    });
}
 
Example 18
Source File: ConstraintsDisplay.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
public void setPropertiesMap(final Map<String, Object> value) {
    getChildren().clear();

    propMap = value;

    if (propMap != null) {
        final Object keys[] = propMap.keySet().toArray();
        int row = 0;
        for (int i = 0; i < keys.length; i++) {
            if (keys[i] instanceof String) {
                final String propkey = (String) keys[i];
                if (propkey.contains("pane-") || propkey.contains("box-")) {
                    final Object keyvalue = propMap.get(propkey);
                    final Label label = new Label(propkey + ":");
                    label.getStyleClass().add("key");
                    GridPane.setConstraints(label, 0, row);
                    GridPane.setValignment(label, VPos.TOP);
                    GridPane.setHalignment(label, HPos.RIGHT);
                    getChildren().add(label);
                    
                    if (propkey.endsWith("margin")) {
                        final InsetsDisplay marginDisplay = new InsetsDisplay();
                        marginDisplay.setInsetsTarget((Insets) keyvalue);
                        GridPane.setConstraints(marginDisplay, 1, row++);
                        GridPane.setHalignment(marginDisplay, HPos.LEFT);
                        getChildren().add(marginDisplay);
                    } else {
                        final Label valueLabel = new Label(keyvalue.toString());
                        valueLabel.getStyleClass().add("value");
                        GridPane.setConstraints(valueLabel, 1, row++);
                        GridPane.setHalignment(valueLabel, HPos.LEFT);
                        getChildren().add(valueLabel);
                    }
                }
            }
        }
    } else {
        final Text novalue = new Text("-");
        GridPane.setConstraints(novalue, 0, 0);
        getChildren().add(novalue);
    }

    // FIXME without this we have ghost text appearing where the layout
    // constraints should be
    if (getChildren().isEmpty()) {
        getChildren().add(new Rectangle(1, 1, Color.TRANSPARENT));
    }

    requestLayout();
}