Java Code Examples for javafx.scene.layout.ColumnConstraints#setHalignment()

The following examples show how to use javafx.scene.layout.ColumnConstraints#setHalignment() . 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: EasyGridPane.java    From constellation with Apache License 2.0 6 votes vote down vote up
public void addColumnConstraint(boolean fillWidth, HPos alignment, Priority grow, double maxWidth, double minWidth, double prefWidth, double percentWidth) {
    ColumnConstraints constraint = new ColumnConstraints();
    constraint.setFillWidth(fillWidth);
    constraint.setHalignment(alignment);
    constraint.setHgrow(grow);
    constraint.setMaxWidth(maxWidth);
    constraint.setMinWidth(minWidth);
    constraint.setPrefWidth(prefWidth);

    if (percentWidth >= 0) {
        constraint.setPercentWidth(percentWidth);
    }

    getColumnConstraints().add(constraint);
}
 
Example 2
Source File: ConversationBox.java    From constellation with Apache License 2.0 5 votes vote down vote up
public BubbleBox(final ConversationMessage message) {
    setVgap(3);

    final ColumnConstraints spaceColumn = new ColumnConstraints();
    spaceColumn.setHgrow(Priority.ALWAYS);
    spaceColumn.setMinWidth(50);
    spaceColumn.setPrefWidth(50);

    final ColumnConstraints contentColumn = new ColumnConstraints();
    contentColumn.setHalignment(message.getConversationSide() == ConversationSide.LEFT ? HPos.LEFT : HPos.RIGHT);
    contentColumn.setFillWidth(false);
    contentColumn.setHgrow(Priority.NEVER);

    final RowConstraints contentRow = new RowConstraints();
    contentRow.setFillHeight(true);
    contentRow.setMaxHeight(Double.MAX_VALUE);
    contentRow.setValignment(VPos.TOP);

    getRowConstraints().addAll(contentRow);

    if (message.getConversationSide() == ConversationSide.LEFT) {
        contentColumnIndex = 0;
        getColumnConstraints().addAll(contentColumn, spaceColumn);
    } else {
        contentColumnIndex = 1;
        getColumnConstraints().addAll(spaceColumn, contentColumn);
    }

    update(message);
}
 
Example 3
Source File: AttributeEditorPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void updateItem(Object item, boolean empty) {
    super.updateItem(item, empty);

    AbstractAttributeInteraction<?> interaction = AbstractAttributeInteraction.getInteraction(attrDataType);
    final String displayText;
    final List<Node> displayNodes;
    if (item == null) {
        displayText = NO_VALUE_TEXT;
        displayNodes = Collections.emptyList();
    } else {
        displayText = interaction.getDisplayText(item);
        displayNodes = interaction.getDisplayNodes(item, -1, CELL_HEIGHT - 1);
    }

    GridPane gridPane = new GridPane();
    gridPane.setHgap(CELL_ITEM_SPACING);
    ColumnConstraints displayNodeConstraint = new ColumnConstraints(CELL_HEIGHT - 1);
    displayNodeConstraint.setHalignment(HPos.CENTER);

    for (int i = 0; i < displayNodes.size(); i++) {
        final Node displayNode = displayNodes.get(i);
        gridPane.add(displayNode, i, 0);
        gridPane.getColumnConstraints().add(displayNodeConstraint);
    }

    setGraphic(gridPane);
    setPrefHeight(CELL_HEIGHT);
    setText(displayText);
}
 
Example 4
Source File: Util.java    From pattypan with MIT License 5 votes vote down vote up
public static ColumnConstraints newColumn(int value, String unit, HPos position) {
  ColumnConstraints col = new ColumnConstraints();
  if (unit.equals("%")) {
    col.setPercentWidth(value);
  }
  if (unit.equals("px")) {
    col.setMaxWidth(value);
    col.setMinWidth(value);
  }

  if (position != null) {
    col.setHalignment(position);
  }
  return col;
}
 
Example 5
Source File: Overlay.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void createGridPane() {
    gridPane = new GridPane();
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    gridPane.setPadding(new Insets(64, 64, 64, 64));
    gridPane.setPrefWidth(width);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
}
 
Example 6
Source File: ProposalResultsWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private GridPane createVotesTable() {
    GridPane votesGridPane = new GridPane();
    votesGridPane.setHgap(5);
    votesGridPane.setVgap(5);
    votesGridPane.setPadding(new Insets(15));

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.ALWAYS);
    votesGridPane.getColumnConstraints().addAll(columnConstraints1);

    int gridRow = 0;

    TableGroupHeadline votesTableHeader = new TableGroupHeadline(Res.get("dao.results.proposals.voting.detail.header"));
    GridPane.setRowIndex(votesTableHeader, gridRow);
    GridPane.setMargin(votesTableHeader, new Insets(8, 0, 0, 0));
    GridPane.setColumnSpan(votesTableHeader, 2);
    votesGridPane.getChildren().add(votesTableHeader);

    TableView<VoteListItem> votesTableView = new TableView<>();
    votesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
    votesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    createColumns(votesTableView);
    GridPane.setRowIndex(votesTableView, gridRow);
    GridPane.setMargin(votesTableView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
    GridPane.setColumnSpan(votesTableView, 2);
    GridPane.setVgrow(votesTableView, Priority.ALWAYS);
    votesGridPane.getChildren().add(votesTableView);

    votesTableView.setItems(sortedVotes);

    addCloseButton(votesGridPane, ++gridRow);

    return votesGridPane;
}
 
Example 7
Source File: CandleTooltip.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
CandleTooltip(StringConverter<Number> priceStringConverter) {
    this.priceStringConverter = priceStringConverter;

    setHgap(Layout.GRID_GAP);

    setVgap(2);

    Label open = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.open"));
    Label close = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.close"));
    Label high = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.high"));
    Label low = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.low"));
    Label average = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.average"));
    Label median = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.median"));
    Label date = new AutoTooltipLabel(Res.get("market.trades.tooltip.candle.date"));
    setConstraints(open, 0, 0);
    setConstraints(openValue, 1, 0);
    setConstraints(close, 0, 1);
    setConstraints(closeValue, 1, 1);
    setConstraints(high, 0, 2);
    setConstraints(highValue, 1, 2);
    setConstraints(low, 0, 3);
    setConstraints(lowValue, 1, 3);
    setConstraints(average, 0, 4);
    setConstraints(averageValue, 1, 4);
    setConstraints(median, 0, 5);
    setConstraints(medianValue, 1, 5);
    setConstraints(date, 0, 6);
    setConstraints(dateValue, 1, 6);

    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    getColumnConstraints().addAll(columnConstraints1, columnConstraints2);

    getChildren().addAll(open, openValue, close, closeValue, high, highValue, low, lowValue, average, averageValue, median, medianValue, date, dateValue);
}
 
Example 8
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addGridPane() {
    gridPane = new GridPane();
    gridPane.getStyleClass().add("content-pane");
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    scrollPane.setContent(gridPane);
}
 
Example 9
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addGridPane() {
    gridPane = new GridPane();
    gridPane.getStyleClass().add("content-pane");
    gridPane.setPadding(new Insets(15, 15, -1, 15));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.NEVER);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    scrollPane.setContent(gridPane);
}
 
Example 10
Source File: AttributeEditorPanel.java    From constellation with Apache License 2.0 4 votes vote down vote up
private Node createAttributeValueNode(final Object[] values, final AttributeData attribute, final AttributeTitledPane parent, final boolean multiValue) {

        boolean noneSelected = values == null;
        boolean isNull = !noneSelected && (values[0] == null);
        parent.setAttribute(attribute);

        AbstractAttributeInteraction<?> interaction = AbstractAttributeInteraction.getInteraction(attribute.getDataType());

        final String displayText;
        final List<Node> displayNodes;
        if (multiValue) {
            displayText = "<Multiple Values>";
            displayNodes = Collections.emptyList();
        } else if (isNull) {
            displayText = NO_VALUE_TEXT;
            displayNodes = Collections.emptyList();
        } else if (noneSelected) {
            displayText = "<Nothing Selected>";
            displayNodes = Collections.emptyList();
        } else {
            displayText = interaction.getDisplayText(values[0]);
            displayNodes = interaction.getDisplayNodes(values[0], -1, CELL_ITEM_HEIGHT);
        }

        parent.setAttributeValue(displayText);
        final TextField attributeValueText = new TextField(displayText);
        attributeValueText.setEditable(false);
        if (noneSelected || isNull || multiValue) {
            attributeValueText.getStyleClass().add("undisplayedValue");
        }

        if (displayNodes.isEmpty()) {
            return attributeValueText;
        }

        GridPane gridPane = new GridPane();
        gridPane.setAlignment(Pos.CENTER_RIGHT);
        gridPane.setPadding(Insets.EMPTY);
        gridPane.setHgap(CELL_ITEM_SPACING);
        ColumnConstraints displayNodeConstraint = new ColumnConstraints(CELL_ITEM_HEIGHT);
        displayNodeConstraint.setHalignment(HPos.LEFT);
        ColumnConstraints displayTextConstraint = new ColumnConstraints();
        displayTextConstraint.setHalignment(HPos.RIGHT);
        displayTextConstraint.setHgrow(Priority.ALWAYS);
        displayTextConstraint.setFillWidth(true);

        for (int i = 0; i < displayNodes.size(); i++) {
            final Node displayNode = displayNodes.get(i);
            gridPane.add(displayNode, i, 0);
            gridPane.getColumnConstraints().add(displayNodeConstraint);
        }

        gridPane.add(attributeValueText, displayNodes.size(), 0);
        gridPane.getColumnConstraints().add(displayTextConstraint);

        return gridPane;
    }
 
Example 11
Source File: IconEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
public void updateItem(String item, boolean empty) {
    super.updateItem(item, empty);
    if (item != null) {
        final GridPane gridPane = new GridPane();
        gridPane.setHgap(0);
        gridPane.setAlignment(Pos.TOP_LEFT);

        // icon
        final ConstellationIcon icon = IconManager.getIcon(item);
        final Image iconImage = icon.buildImage();
        final ImageView imageView = new ImageView(iconImage);
        imageView.setPreserveRatio(true);
        imageView.setFitHeight(RECT_SIZE);
        final ColumnConstraints titleConstraint = new ColumnConstraints(RECT_SIZE);
        titleConstraint.setHalignment(HPos.CENTER);
        gridPane.getColumnConstraints().addAll(titleConstraint);
        gridPane.add(imageView, 0, 0);

        // dimension text
        if (iconImage != null) {
            final int width = (int) (iconImage.getWidth());
            final int height = (int) (iconImage.getHeight());
            final Text dimensionText = new Text(String.format("(%dx%d)", width, height));
            dimensionText.setFill(Color.web("#d3d3d3"));
            gridPane.add(dimensionText, 0, 1);
        }

        // icon name
        final String displayableItem = icon.getExtendedName();
        final String[] splitItem = displayableItem.split("\\.");
        String iconName = splitItem[splitItem.length - 1];
        if (iconName.isEmpty()) {
            iconName = "(no icon)";
        }
        this.setText(iconName);

        // tooltip
        final Tooltip tt = new Tooltip(item);
        this.setTooltip(tt);

        this.setGraphic(gridPane);
        this.setPrefHeight(RECT_SIZE + SPACING);
    } else {
        this.setText(null);
        this.setGraphic(null);
    }
}
 
Example 12
Source File: PreferencesController.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
private void collectIpCamInfo() {
	final Stage ipcamStage = new Stage();
	final GridPane ipcamPane = new GridPane();

	final ColumnConstraints cc = new ColumnConstraints(400);
	cc.setHalignment(HPos.CENTER);
	ipcamPane.getColumnConstraints().addAll(new ColumnConstraints(), cc);

	final TextField nameTextField = new TextField();
	ipcamPane.add(new Label("IPCam Name:"), 0, 0);
	ipcamPane.add(nameTextField, 1, 0);

	final TextField userTextField = new TextField();
	userTextField.setPromptText("Optional Username");
	ipcamPane.add(new Label("Username:"), 0, 1);
	ipcamPane.add(userTextField, 1, 1);

	final PasswordField passwordField = new PasswordField();
	passwordField.setPromptText("Optional Password");
	ipcamPane.add(new Label("Password:"), 0, 2);
	ipcamPane.add(passwordField, 1, 2);

	final TextField urlTextField = new TextField("http://");
	ipcamPane.add(new Label("IPCam URL:"), 0, 3);
	ipcamPane.add(urlTextField, 1, 3);

	final Button okButton = new Button("OK");
	okButton.setDefaultButton(true);
	ipcamPane.add(okButton, 1, 4);

	okButton.setOnAction((e) -> {
		if (nameTextField.getText().isEmpty() || urlTextField.getText().isEmpty()) {
			final Alert ipcamInfoAlert = new Alert(AlertType.ERROR);
			ipcamInfoAlert.setTitle("Missing Information");
			ipcamInfoAlert.setHeaderText("Missing Required IPCam Information!");
			ipcamInfoAlert.setResizable(true);
			ipcamInfoAlert.setContentText("Please fill in both the IPCam name and the URL.");
			ipcamInfoAlert.showAndWait();
			return;
		}

		Optional<String> username = Optional.empty();
		Optional<String> password = Optional.empty();

		if (!userTextField.getText().isEmpty() || !passwordField.getText().isEmpty()) {
			username = Optional.of(userTextField.getText());
			password = Optional.of(passwordField.getText());
		}

		final Optional<Camera> cam = config.registerIpCam(nameTextField.getText(), urlTextField.getText(), username,
				password);

		if (cam.isPresent()) {
			CheckableImageListCell.cacheCamera(cam.get(), PreferencesController.this);

			if (!configuredCameras.contains(cam.get())) {
				Platform.runLater(() -> {
					webcamListView.setItems(null);
					cameras.add(cam.get().getName());
					webcamListView.setItems(cameras);
				});
			}
		}

		ipcamStage.close();
	});

	final Scene scene = new Scene(ipcamPane);
	ipcamStage.initOwner(preferencesPane.getScene().getWindow());
	ipcamStage.initModality(Modality.WINDOW_MODAL);
	ipcamStage.setTitle("Register IPCam");
	ipcamStage.setScene(scene);
	ipcamStage.showAndWait();
}
 
Example 13
Source File: BouncingTargets.java    From ShootOFF with GNU General Public License v3.0 4 votes vote down vote up
private void addSettingControls() {
	final GridPane bouncingTargetsPane = new GridPane();

	final ColumnConstraints cc = new ColumnConstraints(100);
	cc.setHalignment(HPos.CENTER);
	bouncingTargetsPane.getColumnConstraints().addAll(new ColumnConstraints(), cc);

	final int MAX_TARGETS = 10;
	final int MAX_VELOCITY = 30;

	final int SHOOT_DEFAULT_COUNT = 4 - 1;
	final int DONT_SHOOT_DEFAULT_COUNT = 1 - 1;
	final int DEFAULT_MAX_VELOCITY = 10;

	final ObservableList<String> targetCounts = FXCollections.observableArrayList();
	for (int i = 1; i <= MAX_TARGETS; i++)
		targetCounts.add(Integer.toString(i));
	final ComboBox<String> shootTargetsComboBox = new ComboBox<>(targetCounts);
	shootTargetsComboBox.getSelectionModel().select(SHOOT_DEFAULT_COUNT);
	shootTargetsComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
		shootCount = Integer.parseInt(newValue);
		stopExercise();
		startExercise();
	});
	bouncingTargetsPane.add(new Label("Shoot Targets:"), 0, 0);
	bouncingTargetsPane.add(shootTargetsComboBox, 1, 0);

	final ComboBox<String> dontShootTargetsComboBox = new ComboBox<>(targetCounts);
	dontShootTargetsComboBox.getSelectionModel().select(DONT_SHOOT_DEFAULT_COUNT);
	dontShootTargetsComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
		dontShootCount = Integer.parseInt(newValue);
		stopExercise();
		startExercise();
	});
	bouncingTargetsPane.add(new Label("Don't Shoot Targets:"), 0, 1);
	bouncingTargetsPane.add(dontShootTargetsComboBox, 1, 1);

	final ObservableList<String> maxVelocity = FXCollections.observableArrayList();
	for (int i = 1; i <= MAX_VELOCITY; i++)
		maxVelocity.add(Integer.toString(i));
	final ComboBox<String> maxVelocityComboBox = new ComboBox<>(maxVelocity);
	maxVelocityComboBox.getSelectionModel().select(DEFAULT_MAX_VELOCITY - 1);
	maxVelocityComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
		BouncingTargets.maxVelocity = Integer.parseInt(newValue);
		stopExercise();
		startExercise();
	});
	bouncingTargetsPane.add(new Label("Max Target Speed:"), 0, 2);
	bouncingTargetsPane.add(maxVelocityComboBox, 1, 2);

	final CheckBox removeTargets = new CheckBox();
	removeTargets.setOnAction((event) -> removeShootTargets = removeTargets.isSelected());
	bouncingTargetsPane.add(new Label("Remove Hit Shoot Targets:"), 0, 3);
	bouncingTargetsPane.add(removeTargets, 1, 3);

	super.addExercisePane(bouncingTargetsPane);
}
 
Example 14
Source File: WalletPasswordWindow.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void addButtons() {
    BusyAnimation busyAnimation = new BusyAnimation(false);
    Label deriveStatusLabel = new AutoTooltipLabel();

    unlockButton = new AutoTooltipButton(Res.get("shared.unlock"));
    unlockButton.setDefaultButton(true);
    unlockButton.getStyleClass().add("action-button");
    unlockButton.setDisable(true);
    unlockButton.setOnAction(e -> {
        String password = passwordTextField.getText();
        checkArgument(password.length() < 500, Res.get("password.tooLong"));
        KeyCrypterScrypt keyCrypterScrypt = walletsManager.getKeyCrypterScrypt();
        if (keyCrypterScrypt != null) {
            busyAnimation.play();
            deriveStatusLabel.setText(Res.get("password.deriveKey"));
            ScryptUtil.deriveKeyWithScrypt(keyCrypterScrypt, password, aesKey -> {
                if (walletsManager.checkAESKey(aesKey)) {
                    if (aesKeyHandler != null)
                        aesKeyHandler.onAesKey(aesKey);

                    hide();
                } else {
                    busyAnimation.stop();
                    deriveStatusLabel.setText("");

                    UserThread.runAfter(() -> new Popup()
                            .warning(Res.get("password.wrongPw"))
                            .onClose(this::blurAgain).show(), Transitions.DEFAULT_DURATION, TimeUnit.MILLISECONDS);
                }
            });
        } else {
            log.error("wallet.getKeyCrypter() is null, that must not happen.");
        }
    });

    forgotPasswordButton = new AutoTooltipButton(Res.get("password.forgotPassword"));
    forgotPasswordButton.setOnAction(e -> {
        forgotPasswordButton.setDisable(true);
        unlockButton.setDefaultButton(false);
        showRestoreScreen();
    });

    Button cancelButton = new AutoTooltipButton(Res.get("shared.cancel"));
    cancelButton.setOnAction(event -> {
        hide();
        closeHandlerOptional.ifPresent(Runnable::run);
    });

    HBox hBox = new HBox();
    hBox.setMinWidth(560);
    hBox.setPadding(new Insets(0, 0, 0, 0));
    hBox.setSpacing(10);
    GridPane.setRowIndex(hBox, ++rowIndex);
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.getChildren().add(unlockButton);
    if (!hideForgotPasswordButton)
        hBox.getChildren().add(forgotPasswordButton);
    if (!hideCloseButton)
        hBox.getChildren().add(cancelButton);
    hBox.getChildren().addAll(busyAnimation, deriveStatusLabel);
    gridPane.getChildren().add(hBox);


    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.LEFT);
    columnConstraints1.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1);
}