use of javafx.scene.Node in project JFoenix by jfoenixadmin.
the class JFXTreeTableRowSkin method layoutChildren.
// @Override protected void updateChildren() {
// super.updateChildren();
// if(getSkinnable().getIndex() > -1){
// if(oldSkin != this){
// if( (!(expandedIndex == getSkinnable().getIndex() || expandTriggered) || rippler == null)
// || !getSkinnable().isSelected()){
// rippler = new JFXRippler(new StackPane());
// }else{
// this.rippler = oldSkin.rippler;
// }
// }else{
// if(!expandTriggered){
// rippler = new JFXRippler(new StackPane());
// }else if(!getSkinnable().isSelected()){
// rippler = new JFXRippler(new StackPane());
// }
// }
// getChildren().add(0,rippler);
// }
// }
@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
// allow custom skin to grouped rows
getSkinnable().getStyleClass().remove("tree-table-row-group");
if (getSkinnable().getTreeItem() != null && getSkinnable().getTreeItem().getValue() instanceof RecursiveTreeObject && getSkinnable().getTreeItem().getValue().getClass() == RecursiveTreeObject.class)
getSkinnable().getStyleClass().add("tree-table-row-group");
if (getSkinnable().getIndex() > -1 && getSkinnable().getTreeTableView().getTreeItem(getSkinnable().getIndex()) != null) {
super.layoutChildren(x, y, w, h);
// disclosure row case
if (getSkinnable().getTreeItem() != null && !getSkinnable().getTreeItem().isLeaf()) {
// Control c = getVirtualFlowOwner();
// final double defaultDisclosureWidth = disclosureWidthMap.containsKey(c) ? disclosureWidthMap.get(c) : 0;
// double disclosureWidth = getDisclosureNode().prefWidth(h);
// if (disclosureWidth > defaultDisclosureWidth) {
// disclosureWidthMap.put(c, disclosureWidth);
// Parent p = getSkinnable();
// while (p != null) {
// if (p instanceof VirtualFlow)
// break;
// p = p.getParent();
// }
// if(p!=null){
// final VirtualFlow<?> flow = (VirtualFlow<?>) p;
// for (int i = flow.getFirstVisibleCell().getIndex() ; i <= flow.getLastVisibleCell().getIndex(); i++) {
// IndexedCell<?> cell = flow.getCell(i);
// if (cell == null || cell.isEmpty() || cell.getIndex() >= getSkinnable().getIndex()) continue;
// cell.requestLayout();
// cell.layout();
// }
// }
// }
Node arrow = ((Parent) getDisclosureNode()).getChildrenUnmodifiable().get(0);
// relocating the disclosure node according to the grouping column
if (((RecursiveTreeObject<?>) getSkinnable().getItem()).getGroupedColumn() != null) {
Node col = getChildren().get((getSkinnable().getTreeTableView().getTreeItemLevel(getSkinnable().getTreeItem()) + 1));
if (getSkinnable().getItem() instanceof RecursiveTreeObject) {
int index = getSkinnable().getTreeTableView().getColumns().indexOf(((RecursiveTreeObject<?>) getSkinnable().getItem()).getGroupedColumn());
// getSkinnable().getTreeTableView().getColumns().get(index).getText();
// index + 2 , if the rippler was added
col = getChildren().get(index + 1);
}
arrow.getParent().setTranslateX(col.getBoundsInParent().getMinX());
arrow.getParent().setLayoutX(0);
} else {
arrow.getParent().setTranslateX(0);
arrow.getParent().setLayoutX(0);
}
// add disclosure node animation
if (expandedAnimation == null || !expandedAnimation.getStatus().equals(Status.RUNNING)) {
expandedAnimation = new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(arrow.rotateProperty(), 90, Interpolator.EASE_BOTH)));
expandedAnimation.setOnFinished((finish) -> arrow.setRotate(90));
}
if (collapsedAnimation == null || !collapsedAnimation.getStatus().equals(Status.RUNNING)) {
collapsedAnimation = new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(arrow.rotateProperty(), 0, Interpolator.EASE_BOTH)));
collapsedAnimation.setOnFinished((finish) -> arrow.setRotate(0));
}
getSkinnable().getTreeItem().expandedProperty().removeListener(expandedListener);
getSkinnable().getTreeItem().expandedProperty().addListener(expandedListener);
if (expandTriggered) {
if (getSkinnable().getTreeTableView().getTreeItem(getSkinnable().getIndex()).isExpanded()) {
arrow.setRotate(0);
expandedAnimation.play();
} else {
arrow.setRotate(90);
collapsedAnimation.play();
}
expandTriggered = false;
} else {
if (getSkinnable().getTreeTableView().getTreeItem(getSkinnable().getIndex()).isExpanded()) {
if (!expandedAnimation.getStatus().equals(Status.RUNNING))
arrow.setRotate(90);
} else {
if (!collapsedAnimation.getStatus().equals(Status.RUNNING))
arrow.setRotate(0);
}
}
}
}
}
use of javafx.scene.Node in project JFoenix by jfoenixadmin.
the class JFXNodesList method animateList.
/**
* animates the list to show/hide the nodes
*/
public void animateList() {
expanded = !expanded;
if (animateTimeline.getStatus().equals(Status.RUNNING))
animateTimeline.stop();
animateTimeline.getKeyFrames().clear();
double duration = 120 / (double) this.getChildren().size();
// show child nodes
if (expanded)
this.getChildren().forEach(child -> child.setVisible(true));
// add child nodes animation
for (int i = 1; i < this.getChildren().size(); i++) {
Node child = this.getChildren().get(i);
ArrayList<KeyValue> keyValues = animationsMap.get(child).call(expanded);
animateTimeline.getKeyFrames().add(new KeyFrame(Duration.millis(i * duration), keyValues.toArray(new KeyValue[keyValues.size()])));
}
// add 1st element animation
ArrayList<KeyValue> keyValues = animationsMap.get(this.getChildren().get(0)).call(expanded);
animateTimeline.getKeyFrames().add(new KeyFrame(Duration.millis(160), keyValues.toArray(new KeyValue[keyValues.size()])));
// hide child nodes to allow mouse events on the nodes behind them
if (!expanded) {
animateTimeline.setOnFinished((finish) -> {
for (int i = 1; i < this.getChildren().size(); i++) this.getChildren().get(i).setVisible(false);
});
} else {
animateTimeline.setOnFinished(null);
}
animateTimeline.play();
}
use of javafx.scene.Node in project JFoenix by jfoenixadmin.
the class JFXNodesList method addAnimatedNode.
/**
* add node to list with a specified callback that is triggered after the node animation is finished.
* Note: this method must be called instead of getChildren().add().
*
* @param node
*/
public void addAnimatedNode(Region node, Callback<Boolean, ArrayList<KeyValue>> animationCallBack) {
// create container for the node if it's a sub nodes list
if (node instanceof JFXNodesList) {
StackPane container = new StackPane(node);
container.setPickOnBounds(false);
addAnimatedNode(container, animationCallBack);
return;
}
// init node property
node.setVisible(false);
node.minWidthProperty().bind(node.prefWidthProperty());
node.minHeightProperty().bind(node.prefHeightProperty());
if (this.getChildren().size() > 0)
initNode(node);
else {
if (node instanceof Button)
((Button) node).setOnAction((action) -> this.animateList());
else
node.setOnMouseClicked((click) -> this.animateList());
node.getStyleClass().add("trigger-node");
}
// init the list height and width
if (this.getChildren().size() == 0) {
node.setVisible(true);
this.minHeightProperty().bind(node.prefHeightProperty());
this.maxHeightProperty().bind(node.prefHeightProperty());
this.minWidthProperty().bind(node.prefWidthProperty());
this.maxWidthProperty().bind(node.prefWidthProperty());
}
// add the node and its listeners
this.getChildren().add(node);
this.rotateProperty().addListener((o, oldVal, newVal) -> node.setRotate(newVal.doubleValue() % 180 == 0 ? newVal.doubleValue() : -newVal.doubleValue()));
if (animationCallBack == null && this.getChildren().size() != 1)
animationCallBack = (expanded) -> {
return initDefaultAnimation(node, expanded);
};
else if (animationCallBack == null && this.getChildren().size() == 1)
animationCallBack = (expanded) -> {
return new ArrayList<KeyValue>();
};
animationsMap.put(node, animationCallBack);
}
use of javafx.scene.Node in project JFoenix by jfoenixadmin.
the class JFXRippler method getMask.
// methods that can be changed by extending the rippler class
/**
* generate the clipping mask
* @return the mask node
*/
protected Node getMask() {
double borderWidth = ripplerPane.getBorder() != null ? ripplerPane.getBorder().getInsets().getTop() : 0;
Bounds bounds = control.getBoundsInParent();
double width = control.getLayoutBounds().getWidth();
double height = control.getLayoutBounds().getHeight();
double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
double diffMaxX = Math.abs(control.getBoundsInLocal().getMaxX() - control.getLayoutBounds().getMaxX());
double diffMaxY = Math.abs(control.getBoundsInLocal().getMaxY() - control.getLayoutBounds().getMaxY());
Node mask;
switch(getMaskType()) {
case RECT:
// -0.1 to prevent resizing the anchor pane
mask = new Rectangle(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY, width - 0.1 - 2 * borderWidth, height - 0.1 - 2 * borderWidth);
break;
case CIRCLE:
double radius = Math.min((width / 2) - 0.1 - 2 * borderWidth, (height / 2) - 0.1 - 2 * borderWidth);
mask = new Circle((bounds.getMinX() + diffMinX + bounds.getMaxX() - diffMaxX) / 2, (bounds.getMinY() + diffMinY + bounds.getMaxY() - diffMaxY) / 2, radius, Color.BLUE);
break;
default:
// -0.1 to prevent resizing the anchor pane
mask = new Rectangle(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY, width - 0.1 - 2 * borderWidth, height - 0.1 - 2 * borderWidth);
break;
}
if (control instanceof Shape || (control instanceof Region && ((Region) control).getShape() != null)) {
mask = new StackPane();
((Region) mask).setShape((control instanceof Shape) ? (Shape) control : ((Region) control).getShape());
((Region) mask).setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
mask.resize(width, height);
mask.relocate(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY);
}
return mask;
}
use of javafx.scene.Node in project JFoenix by jfoenixadmin.
the class JFXTextAreaOldSkin method showError.
private void showError(ValidatorBase validator) {
// set text in error label
errorLabel.setText(validator.getMessage());
// show error icon
Node awsomeIcon = validator.getIcon();
errorIcon.getChildren().clear();
if (awsomeIcon != null) {
errorIcon.getChildren().add(awsomeIcon);
StackPane.setAlignment(awsomeIcon, Pos.TOP_RIGHT);
}
// init only once, to fix the text pane from resizing
if (initYlayout == -1) {
mainPane.setMaxHeight(mainPane.getHeight());
initYlayout = mainPane.getBoundsInParent().getMinY();
initHeight = getSkinnable().getHeight();
currentFieldHeight = initHeight;
}
errorContainer.setVisible(true);
errorShown = true;
}
Aggregations