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);
}
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);
}
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);
}
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()));
}
}
}
}
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;
}
Aggregations