Search in sources :

Example 96 with Region

use of javafx.scene.layout.Region in project POL-POM-5 by PlayOnLinux.

the class DetailsPanelSkin method createHeader.

/**
 * Creates the header for the details panel.
 * The header contains an optional title and a close button
 *
 * @return The header
 */
private HBox createHeader() {
    final Label titleLabel = new Label();
    titleLabel.getStyleClass().add("descriptionTitle");
    titleLabel.textProperty().bind(getControl().titleProperty());
    final Button closeButton = new Button();
    closeButton.getStyleClass().add("closeIcon");
    closeButton.setOnAction(event -> Optional.ofNullable(getControl().getOnClose()).ifPresent(Runnable::run));
    final Region filler = new Region();
    HBox.setHgrow(filler, Priority.ALWAYS);
    return new HBox(titleLabel, filler, closeButton);
}
Also used : HBox(javafx.scene.layout.HBox) Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) Region(javafx.scene.layout.Region)

Example 97 with Region

use of javafx.scene.layout.Region in project tilesfx by HanSolo.

the class PercentageTileSkin method initGraphics.

// ******************** Initialization ************************************
@Override
protected void initGraphics() {
    super.initGraphics();
    barColor = tile.getBarColor();
    barBackground = new Region();
    barBackground.setBackground(new Background(new BackgroundFill(tile.getBarBackgroundColor(), new CornerRadii(0.0, 0.0, 0.025, 0.025, true), Insets.EMPTY)));
    barClip = new Rectangle();
    bar = new Rectangle();
    bar.setFill(tile.getBarColor());
    bar.setStroke(null);
    bar.setClip(barClip);
    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());
    valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100)));
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());
    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());
    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);
    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setWrapText(true);
    description.setTextFill(tile.getTextColor());
    Helper.enableNode(description, !tile.getDescription().isEmpty());
    percentageText = new Text();
    percentageText.setFill(tile.getBarColor());
    percentageUnitText = new Text("%");
    percentageUnitText.setFill(tile.getBarColor());
    maxValueRect = new Rectangle();
    maxValueRect.setFill(tile.getThresholdColor());
    maxValueText = new Text();
    maxValueText.setFill(tile.getBackgroundColor());
    maxValueUnitText = new Text(tile.getUnit());
    maxValueUnitText.setFill(tile.getBackgroundColor());
    getPane().getChildren().addAll(barBackground, bar, titleText, valueUnitFlow, description, percentageText, percentageUnitText, maxValueRect, maxValueText, maxValueUnitText);
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) Rectangle(javafx.scene.shape.Rectangle) Label(javafx.scene.control.Label) Region(javafx.scene.layout.Region) Text(javafx.scene.text.Text) TextFlow(javafx.scene.text.TextFlow) CornerRadii(javafx.scene.layout.CornerRadii)

Example 98 with Region

use of javafx.scene.layout.Region in project aic-praise by aic-sri-international.

the class FXUtil method setButtonStackedIcons.

public static void setButtonStackedIcons(Button button, GlyphIcons icon1, GlyphIcons icon2) {
    Region saveAsImg = GlyphsStack.create().add(GlyphsBuilder.create(FontAwesomeIcon.class).glyph(icon1).size(iconSize(_buttonDefaultIconSize)).build()).add(GlyphsBuilder.create(FontAwesomeIcon.class).glyph(icon2).size(iconSize(_iconSmallSize)).build());
    button.setGraphic(saveAsImg);
    button.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
    fixButtonSize(button, _buttonDefaultIconSize);
}
Also used : Region(javafx.scene.layout.Region) FontAwesomeIcon(de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon)

Example 99 with Region

use of javafx.scene.layout.Region in project JFoenix by jfoenixadmin.

the class JFXListCell method updateItem.

/**
 * {@inheritDoc}
 */
@Override
protected void updateItem(T item, boolean empty) {
    super.updateItem(item, empty);
    if (empty) {
        setText(null);
        setGraphic(null);
        // remove empty (Trailing cells)
        setMouseTransparent(true);
        setStyle("-fx-background-color:TRANSPARENT;");
    } else {
        setMouseTransparent(false);
        setStyle(null);
        if (item instanceof Node) {
            setText(null);
            Node currentNode = getGraphic();
            Node newNode = (Node) item;
            if (currentNode == null || !currentNode.equals(newNode)) {
                cellContent = newNode;
                cellRippler.rippler.cacheRippleClip(false);
                // RIPPLER ITEM : in case if the list item has its own rippler bind the list rippler and item rippler properties
                if (newNode instanceof JFXRippler) {
                    // build cell container from exisiting rippler
                    cellRippler.ripplerFillProperty().bind(((JFXRippler) newNode).ripplerFillProperty());
                    cellRippler.maskTypeProperty().bind(((JFXRippler) newNode).maskTypeProperty());
                    cellRippler.positionProperty().bind(((JFXRippler) newNode).positionProperty());
                    cellContent = ((JFXRippler) newNode).getControl();
                } else // SUBLIST ITEM : build the Cell node as sublist the sublist
                if (newNode instanceof JFXListView<?>) {
                    // add the sublist to the parent and style the cell as sublist item
                    ((JFXListView<?>) getListView()).addSublist((JFXListView<?>) newNode, this.getIndex());
                    this.getStyleClass().add("sublist-item");
                    if (this.getPadding() != null) {
                        this.setPadding(new Insets(this.getPadding().getTop(), 0, this.getPadding().getBottom(), 0));
                    }
                    // First build the group item used to expand / hide the sublist
                    StackPane groupNode = new StackPane();
                    groupNode.getStyleClass().add("sublist-header");
                    SVGGlyph dropIcon = new SVGGlyph(0, "ANGLE_RIGHT", "M340 548.571q0 7.429-5.714 13.143l-266.286 266.286q-5.714 5.714-13.143 5.714t-13.143-5.714l-28.571-28.571q-5.714-5.714-5.714-13.143t5.714-13.143l224.571-224.571-224.571-224.571q-5.714-5.714-5.714-13.143t5.714-13.143l28.571-28.571q5.714-5.714 13.143-5.714t13.143 5.714l266.286 266.286q5.714 5.714 5.714 13.143z", Color.BLACK);
                    dropIcon.setStyle("-fx-min-width:0.4em;-fx-max-width:0.4em;-fx-min-height:0.6em;-fx-max-height:0.6em;");
                    dropIcon.getStyleClass().add("drop-icon");
                    // alignment of the group node can be changed using the following css selector
                    // .jfx-list-view .sublist-header{ }
                    groupNode.getChildren().setAll(((JFXListView<?>) newNode).getGroupnode(), dropIcon);
                    // the margin is needed when rotating the angle
                    StackPane.setMargin(dropIcon, new Insets(0, 19, 0, 0));
                    StackPane.setAlignment(dropIcon, Pos.CENTER_RIGHT);
                    // Second build the sublist container
                    StackPane sublistContainer = new StackPane();
                    sublistContainer.setMinHeight(0);
                    sublistContainer.setMaxHeight(0);
                    sublistContainer.getChildren().setAll(newNode);
                    sublistContainer.setTranslateY(this.snappedBottomInset());
                    sublistContainer.setOpacity(0);
                    StackPane.setMargin(newNode, new Insets(-1, -1, 0, -1));
                    // Third, create container of group title and the sublist
                    VBox contentHolder = new VBox();
                    contentHolder.getChildren().setAll(groupNode, sublistContainer);
                    contentHolder.getStyleClass().add("sublist-container");
                    VBox.setVgrow(groupNode, Priority.ALWAYS);
                    cellContent = contentHolder;
                    cellRippler.ripplerPane.addEventHandler(MouseEvent.ANY, e -> e.consume());
                    contentHolder.addEventHandler(MouseEvent.ANY, e -> {
                        if (!e.isConsumed()) {
                            cellRippler.ripplerPane.fireEvent(e);
                            e.consume();
                        }
                    });
                    cellRippler.ripplerPane.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> {
                        if (!e.isConsumed()) {
                            e.consume();
                            contentHolder.fireEvent(e);
                        }
                    });
                    // cache rippler clip in subnodes
                    cellRippler.rippler.cacheRippleClip(true);
                    this.setOnMouseClicked(e -> e.consume());
                    // Finally, add sublist animation
                    contentHolder.setOnMouseClicked((click) -> {
                        click.consume();
                        // stop the animation or change the list height
                        if (expandAnimation != null && expandAnimation.getStatus() == Status.RUNNING) {
                            expandAnimation.stop();
                        }
                        // invert the expand property
                        expandedProperty.set(!expandedProperty.get());
                        double newAnimatedHeight = newNode.prefHeight(-1) * (expandedProperty.get() ? 1 : -1);
                        double newHeight = expandedProperty.get() ? this.getHeight() + newAnimatedHeight : this.prefHeight(-1);
                        // animate showing/hiding the sublist
                        double contentHeight = expandedProperty.get() ? newAnimatedHeight : 0;
                        if (expandedProperty.get()) {
                            updateClipHeight(newHeight);
                            getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight + animatedHeight);
                        }
                        // update the animated height
                        animatedHeight = newAnimatedHeight;
                        int opacity = expandedProperty.get() ? 1 : 0;
                        expandAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(sublistContainer.minHeightProperty(), contentHeight, Interpolator.EASE_BOTH), new KeyValue(sublistContainer.maxHeightProperty(), contentHeight, Interpolator.EASE_BOTH), new KeyValue(sublistContainer.opacityProperty(), opacity, Interpolator.EASE_BOTH)));
                        if (!expandedProperty.get()) {
                            expandAnimation.setOnFinished((finish) -> {
                                updateClipHeight(newHeight);
                                getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight);
                                animatedHeight = 0;
                            });
                        }
                        expandAnimation.play();
                    });
                    // animate arrow
                    expandedProperty.addListener((o, oldVal, newVal) -> {
                        if (newVal) {
                            new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 90, Interpolator.EASE_BOTH))).play();
                        } else {
                            new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(dropIcon.rotateProperty(), 0, Interpolator.EASE_BOTH))).play();
                        }
                    });
                }
                ((Region) cellContent).setMaxHeight(cellContent.prefHeight(-1));
                setGraphic(cellContent);
            }
        } else {
            setText(item == null ? "null" : item.toString());
            setGraphic(null);
        }
        boolean isJFXListView = getListView() instanceof JFXListView;
        // show cell tooltip if its toggled in JFXListView
        if (isJFXListView && ((JFXListView<?>) getListView()).isShowTooltip()) {
            if (item instanceof Label) {
                setTooltip(new Tooltip(((Label) item).getText()));
            } else if (getText() != null) {
                setTooltip(new Tooltip(getText()));
            }
        }
    }
}
Also used : Pos(javafx.geometry.Pos) ListCell(javafx.scene.control.ListCell) MouseEvent(javafx.scene.input.MouseEvent) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Tooltip(javafx.scene.control.Tooltip) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) JFXNodeUtils(com.jfoenix.utils.JFXNodeUtils) Label(javafx.scene.control.Label) Status(javafx.animation.Animation.Status) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) Set(java.util.Set) SVGGlyph(com.jfoenix.svg.SVGGlyph) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) BooleanProperty(javafx.beans.property.BooleanProperty) Duration(javafx.util.Duration) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) Shape(javafx.scene.shape.Shape) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) Tooltip(javafx.scene.control.Tooltip) Label(javafx.scene.control.Label) Timeline(javafx.animation.Timeline) SVGGlyph(com.jfoenix.svg.SVGGlyph) KeyFrame(javafx.animation.KeyFrame) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Example 100 with Region

use of javafx.scene.layout.Region in project JFoenix by jfoenixadmin.

the class JFXMasonryPane method layoutChildren.

/**
 * {@inheritDoc}
 */
@Override
protected void layoutChildren() {
    performingLayout = true;
    int col, row;
    col = (int) Math.floor((getWidth() + getHSpacing() - snappedLeftInset() - snappedRightInset()) / (getCellWidth() + getHSpacing()));
    col = getLimitColumn() != -1 && col > getLimitColumn() ? getLimitColumn() : col;
    if (matrix != null && col == matrix[0].length) {
        performingLayout = false;
        return;
    }
    // (int) Math.floor(this.getHeight() / (cellH + 2*vSpacing));
    row = getLimitRow();
    matrix = new int[row][col];
    double minWidth = -1;
    double minHeight = -1;
    List<BoundingBox> newBoxes;
    List<Region> managedChildren = getManagedChildren();
    // filter Region nodes
    for (int i = 0; i < managedChildren.size(); i++) {
        if (!(managedChildren.get(i) instanceof Region)) {
            managedChildren.remove(i);
            i--;
        }
    }
    // get bounding boxes layout
    newBoxes = layoutMode.get().fillGrid(matrix, managedChildren, getCellWidth(), getCellHeight(), row, col, getHSpacing(), getVSpacing());
    if (newBoxes == null) {
        performingLayout = false;
        return;
    }
    HashMap<Node, BoundingBox> oldBoxes = boundingBoxes;
    if (dirtyBoxes) {
        boundingBoxes = new HashMap<>();
    }
    for (int i = 0; i < managedChildren.size() && i < newBoxes.size(); i++) {
        final Region child = managedChildren.get(i);
        final BoundingBox boundingBox = newBoxes.get(i);
        if (!(child instanceof GridPane)) {
            double blockX;
            double blockY;
            double blockWidth;
            double blockHeight;
            if (boundingBox != null) {
                blockX = boundingBox.getMinY() * getCellWidth() + boundingBox.getMinY() * getHSpacing() + snappedLeftInset();
                blockY = boundingBox.getMinX() * getCellHeight() + boundingBox.getMinX() * getVSpacing() + snappedTopInset();
                blockWidth = boundingBox.getWidth() * getCellWidth() + (boundingBox.getWidth() - 1) * getHSpacing();
                blockHeight = boundingBox.getHeight() * getCellHeight() + (boundingBox.getHeight() - 1) * getVSpacing();
            } else {
                blockX = child.getLayoutX();
                blockY = child.getLayoutY();
                blockWidth = -1;
                blockHeight = -1;
            }
            if (animationMap == null) {
                // init static children
                child.setPrefSize(blockWidth, blockHeight);
                child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
            } else {
                BoundingBox oldBoundingBox = oldBoxes.get(child);
                if (oldBoundingBox == null || (!oldBoundingBox.equals(boundingBox) && dirtyBoxes)) {
                    // handle new children
                    child.setOpacity(0);
                    child.setPrefSize(blockWidth, blockHeight);
                    child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
                }
                if (boundingBox != null) {
                    // handle children repositioning
                    if (child.getWidth() != blockWidth || child.getHeight() != blockHeight) {
                        child.setOpacity(0);
                        child.setPrefSize(blockWidth, blockHeight);
                        child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
                    }
                    final KeyFrame keyFrame = new KeyFrame(Duration.millis(2000), new KeyValue(child.opacityProperty(), 1, Interpolator.LINEAR), new KeyValue(child.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(child.layoutYProperty(), blockY, Interpolator.LINEAR));
                    animationMap.put(child, new CachedTransition(child, new Timeline(keyFrame)) {

                        {
                            setCycleDuration(Duration.seconds(0.320));
                            setDelay(Duration.seconds(0));
                            setOnFinished((finish) -> {
                                child.setLayoutX(blockX);
                                child.setLayoutY(blockY);
                                child.setOpacity(1);
                            });
                        }
                    });
                } else {
                    // handle children is being hidden ( cause it can't fit in the pane )
                    final KeyFrame keyFrame = new KeyFrame(Duration.millis(2000), new KeyValue(child.opacityProperty(), 0, Interpolator.LINEAR), new KeyValue(child.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(child.layoutYProperty(), blockY, Interpolator.LINEAR));
                    animationMap.put(child, new CachedTransition(child, new Timeline(keyFrame)) {

                        {
                            setCycleDuration(Duration.seconds(0.320));
                            setDelay(Duration.seconds(0));
                            setOnFinished((finish) -> {
                                child.setLayoutX(blockX);
                                child.setLayoutY(blockY);
                                child.setOpacity(0);
                            });
                        }
                    });
                }
            }
            // update bounding box
            boundingBoxes.put(child, boundingBox);
            if (boundingBox != null) {
                if (blockX + blockWidth > minWidth) {
                    minWidth = blockX + blockWidth;
                }
                if (blockY + blockHeight > minHeight) {
                    minHeight = blockY + blockHeight;
                }
            }
        }
    }
    if (minHeight != -1) {
        minHeight += snappedBottomInset();
        setPrefHeight(minHeight);
    }
    if (animationMap == null) {
        animationMap = new HashMap<>();
    }
    trans.stop();
    ParallelTransition newTransition = new ParallelTransition();
    newTransition.getChildren().addAll(animationMap.values());
    newTransition.play();
    trans = newTransition;
    dirtyBoxes = false;
    performingLayout = false;
}
Also used : KeyFrame(javafx.animation.KeyFrame) ObjectProperty(javafx.beans.property.ObjectProperty) BoundingBox(javafx.geometry.BoundingBox) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) DoubleProperty(javafx.beans.property.DoubleProperty) HashMap(java.util.HashMap) IntegerProperty(javafx.beans.property.IntegerProperty) Transition(javafx.animation.Transition) ArrayList(java.util.ArrayList) ParallelTransition(javafx.animation.ParallelTransition) CachedTransition(com.jfoenix.transitions.CachedTransition) Duration(javafx.util.Duration) List(java.util.List) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) ListChangeListener(javafx.collections.ListChangeListener) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) WeakListChangeListener(javafx.collections.WeakListChangeListener) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) KeyValue(javafx.animation.KeyValue) GridPane(javafx.scene.layout.GridPane) Pane(javafx.scene.layout.Pane) GridPane(javafx.scene.layout.GridPane) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) BoundingBox(javafx.geometry.BoundingBox) Region(javafx.scene.layout.Region) KeyFrame(javafx.animation.KeyFrame) CachedTransition(com.jfoenix.transitions.CachedTransition) ParallelTransition(javafx.animation.ParallelTransition)

Aggregations

Region (javafx.scene.layout.Region)106 Text (javafx.scene.text.Text)25 VBox (javafx.scene.layout.VBox)22 Label (javafx.scene.control.Label)21 Pane (javafx.scene.layout.Pane)21 Button (javafx.scene.control.Button)18 InnerShadow (javafx.scene.effect.InnerShadow)17 Scene (javafx.scene.Scene)16 Node (javafx.scene.Node)15 Insets (javafx.geometry.Insets)14 HBox (javafx.scene.layout.HBox)14 DropShadow (javafx.scene.effect.DropShadow)13 ArrayList (java.util.ArrayList)12 StackPane (javafx.scene.layout.StackPane)12 Canvas (javafx.scene.canvas.Canvas)11 Color (javafx.scene.paint.Color)11 GridPane (javafx.scene.layout.GridPane)10 Group (javafx.scene.Group)9 Background (javafx.scene.layout.Background)8 BackgroundFill (javafx.scene.layout.BackgroundFill)8