use of javafx.scene.layout.Pane in project trex-stateless-gui by cisco-system-traffic-generator.
the class PortHardwareCounters method update.
private void update() {
try {
String xStatsNames = ConnectionManager.getInstance().sendPortXStatsNamesRequest(port);
String xStatsValues = ConnectionManager.getInstance().sendPortXStatsValuesRequest(port);
Map<String, Long> loadedXStatsList = Util.getXStatsFromJSONString(xStatsNames, xStatsValues);
port.setXstats(loadedXStatsList);
Pane pane = statsTableGenerator.generateXStatPane(true, port, statXTableNotEmpty.isSelected(), statXTableFilter.getText(), resetCountersRequested);
statXTableContainer.setContent(pane);
statXTableContainer.setVisible(true);
if (resetCountersRequested) {
resetCountersRequested = false;
}
} catch (Exception ignored) {
}
}
use of javafx.scene.layout.Pane in project trex-stateless-gui by cisco-system-traffic-generator.
the class PortInfoTabXstats method update.
public void update(boolean full) {
if (statXTableNotEmpty_changed) {
statXTableNotEmpty_changed = false;
full = true;
}
if (statXTableFilter_changed) {
statXTableFilter_changed = false;
full = true;
}
textTabConfigPortNameTitle.setText("Port " + port.getIndex());
Pane pane = statsTableGenerator.generateXStatPane(full, port, statXTableNotEmpty.isSelected(), statXTableFilter.getText(), false);
statXTableContainer.setContent(pane);
statXTableContainer.setVisible(true);
}
use of javafx.scene.layout.Pane in project JFoenix by jfoenixadmin.
the class JFXMasonryPane method layoutChildren.
/***************************************************************************
* *
* Override/Inherited methods *
* *
**************************************************************************/
/**
* {@inheritDoc}
*/
@Override
protected void layoutChildren() {
performingLayout = true;
if (!valid) {
int col, row;
col = (int) Math.floor(this.getWidth() / (getCellWidth() + 2 * 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 = 100;
row = getLimitRow() != -1 && row > getLimitRow() ? getLimitRow() : row;
matrix = new int[row][col];
double minWidth = -1;
double minHeight = -1;
List<BoundingBox> newBoxes;
List<Region> childs = new ArrayList<>();
for (int i = 0; i < getChildren().size(); i++) if (getChildren().get(i) instanceof Region)
childs.add((Region) getChildren().get(i));
newBoxes = layoutMode.get().fillGrid(matrix, childs, getCellWidth(), getCellHeight(), row, col, getHSpacing(), getVSpacing());
if (newBoxes == null) {
performingLayout = false;
return;
}
for (int i = 0; i < getChildren().size() && i < newBoxes.size(); i++) {
Region block = (Region) getChildren().get(i);
if (!(block instanceof GridPane)) {
double blockX, blockY, blockWidth, blockHeight;
if (newBoxes.get(i) != null) {
blockX = newBoxes.get(i).getMinY() * getCellWidth() + ((newBoxes.get(i).getMinY() + 1) * 2 - 1) * getHSpacing();
blockY = newBoxes.get(i).getMinX() * getCellHeight() + ((newBoxes.get(i).getMinX() + 1) * 2 - 1) * getVSpacing();
blockWidth = newBoxes.get(i).getWidth() * getCellWidth() + (newBoxes.get(i).getWidth() - 1) * 2 * getHSpacing();
blockHeight = newBoxes.get(i).getHeight() * getCellHeight() + (newBoxes.get(i).getHeight() - 1) * 2 * getVSpacing();
} else {
blockX = block.getLayoutX();
blockY = block.getLayoutY();
blockWidth = -1;
blockHeight = -1;
}
if (animationMap == null) {
// init static children
block.setLayoutX(blockX);
block.setLayoutY(blockY);
block.setPrefSize(blockWidth, blockHeight);
block.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
} else {
if (oldBoxes == null || i >= oldBoxes.size()) {
// handle new children
block.setOpacity(0);
block.setLayoutX(blockX);
block.setLayoutY(blockY);
block.setPrefSize(blockWidth, blockHeight);
block.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
}
if (newBoxes.get(i) != null) {
// handle children repositioning
animationMap.put(block, new CachedTransition(block, new Timeline(new KeyFrame(Duration.millis(2000), new KeyValue(block.opacityProperty(), 1, Interpolator.LINEAR), new KeyValue(block.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(block.layoutYProperty(), blockY, Interpolator.LINEAR)))) {
{
setCycleDuration(Duration.seconds(0.320));
setDelay(Duration.seconds(0));
setOnFinished((finish) -> {
block.setLayoutX(blockX);
block.setLayoutY(blockY);
block.setOpacity(1);
});
}
});
} else {
// handle children is being hidden ( cause it can't fit in the pane )
animationMap.put(block, new CachedTransition(block, new Timeline(new KeyFrame(Duration.millis(2000), new KeyValue(block.opacityProperty(), 0, Interpolator.LINEAR), new KeyValue(block.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(block.layoutYProperty(), blockY, Interpolator.LINEAR)))) {
{
setCycleDuration(Duration.seconds(0.320));
setDelay(Duration.seconds(0));
setOnFinished((finish) -> {
block.setLayoutX(blockX);
block.setLayoutY(blockY);
block.setOpacity(0);
});
}
});
}
}
if (newBoxes.get(i) != null) {
if (blockX + blockWidth > minWidth)
minWidth = blockX + blockWidth;
if (blockY + blockHeight > minHeight)
minHeight = blockY + blockHeight;
}
}
}
this.setMinSize(minWidth, minHeight);
if (animationMap == null)
animationMap = new HashMap<>();
trans.stop();
ParallelTransition newTransition = new ParallelTransition();
newTransition.getChildren().addAll(animationMap.values());
newTransition.play();
trans = newTransition;
oldBoxes = newBoxes;
// FOR DEGBBUGING
// root.getChildren().clear();
// for(int y = 0; y < matrix.length; y++){
// for(int x = 0; x < matrix[0].length; x++){
//
// // Create a new TextField in each Iteration
// Label tf = new Label();
// tf.setStyle(matrix[y][x] == 0 ? colors[0] : colors[matrix[y][x]%4+1]);
// tf.setMinWidth(getCellWidth());
// tf.setMinHeight(getCellHeight());
// tf.setAlignment(Pos.CENTER);
// tf.setText(matrix[y][x] + "");
// // Iterate the Index using the loops
// root.setRowIndex(tf,y);
// root.setColumnIndex(tf,x);
// root.setMargin(tf, new Insets(getVSpacing(),getHSpacing(),getVSpacing(),getHSpacing()));
// root.getChildren().add(tf);
// }
// }
valid = true;
}
// FOR DEGBBUGING
// if(!getChildren().contains(root)) getChildren().add(root);
// root.resizeRelocate(0, 0, this.getWidth(), this.getHeight());
performingLayout = false;
}
use of javafx.scene.layout.Pane in project JFoenix by jfoenixadmin.
the class JFXResponsiveHandler method scanAllNodes.
/**
* scans all nodes in the scene and apply the css pseduoClass to them.
*
* @param parent stage parent node
* @param pseudoClass css class for certain device
*/
private void scanAllNodes(Parent parent, PseudoClass pseudoClass) {
parent.getChildrenUnmodifiable().addListener(new ListChangeListener<Node>() {
@Override
public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
while (c.next()) if (!c.wasPermutated() && !c.wasUpdated())
for (Node addedNode : c.getAddedSubList()) if (addedNode instanceof Parent)
scanAllNodes((Parent) addedNode, pseudoClass);
}
});
for (Node component : parent.getChildrenUnmodifiable()) {
if (component instanceof Pane) {
((Pane) component).getChildren().addListener(new ListChangeListener<Node>() {
@Override
public void onChanged(javafx.collections.ListChangeListener.Change<? extends Node> c) {
while (c.next()) {
if (!c.wasPermutated() && !c.wasUpdated()) {
for (Node addedNode : c.getAddedSubList()) {
if (addedNode instanceof Parent)
scanAllNodes((Parent) addedNode, pseudoClass);
}
}
}
}
});
//if the component is a container, scan its children
scanAllNodes((Pane) component, pseudoClass);
} else if (component instanceof ScrollPane) {
((ScrollPane) component).contentProperty().addListener((o, oldVal, newVal) -> {
scanAllNodes((Parent) newVal, pseudoClass);
});
//if the component is a container, scan its children
if (((ScrollPane) component).getContent() instanceof Parent) {
scanAllNodes((Parent) ((ScrollPane) component).getContent(), pseudoClass);
}
} else if (component instanceof Control) {
//if the component is an instance of IInputControl, add to list
((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_EX_SMALL, pseudoClass == PSEUDO_CLASS_EX_SMALL);
((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_SMALL, pseudoClass == PSEUDO_CLASS_SMALL);
((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_MEDIUM, pseudoClass == PSEUDO_CLASS_MEDIUM);
((Control) component).pseudoClassStateChanged(PSEUDO_CLASS_LARGE, pseudoClass == PSEUDO_CLASS_LARGE);
}
}
}
use of javafx.scene.layout.Pane in project JFoenix by jfoenixadmin.
the class JFXDepthManager method createMaterialNode.
/**
* this method will generate a new container node that prevent
* control transformation to be applied to the shadow effect
* (which makes it looks as a real shadow)
*/
public static Node createMaterialNode(Node control, int level) {
Node container = new Pane(control);
container.getStyleClass().add("depth-container");
level = level < 0 ? 0 : level;
level = level > 5 ? 5 : level;
container.setEffect(new DropShadow(BlurType.GAUSSIAN, depth[level].getColor(), depth[level].getRadius(), depth[level].getSpread(), depth[level].getOffsetX(), depth[level].getOffsetY()));
return container;
}
Aggregations