Java Code Examples for javafx.scene.Node#prefHeight()
The following examples show how to use
javafx.scene.Node#prefHeight() .
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: FxIconBuilder.java From FxDock with Apache License 2.0 | 8 votes |
/** auto fit last node, useful for svg paths */ public void autoFitLastElement() { Node n = last(); double w = n.prefHeight(width); double h = n.prefWidth(height); double sx = width / w; double sy = height / h; double sc = Math.min(sx, sy); n.setScaleX(sc); n.setScaleY(sc); Bounds b = n.getBoundsInLocal(); double dx = (width / 2.0) - b.getMinX() - (b.getWidth() / 2.0); double dy = (height / 2.0) - b.getMinY() - (b.getHeight() / 2.0); n.setTranslateX(dx); n.setTranslateY(dy); }
Example 2
Source File: FlowSafeVBox.java From marathonv5 with Apache License 2.0 | 6 votes |
@Override protected void layoutChildren() { double top = getPadding().getTop(); double left = getPadding().getLeft(); double right = getPadding().getRight(); double w = getWidth() - left - right; double y = top; for(Node child:getChildren()) { double prefH = child.prefHeight(w); child.resizeRelocate( snapPosition(left), snapPosition(y), snapSize(w), snapSize(prefH) ); y += vgap + prefH; } }
Example 3
Source File: FlowSafeVBox.java From marathonv5 with Apache License 2.0 | 6 votes |
@Override protected void layoutChildren() { double top = getPadding().getTop(); double left = getPadding().getLeft(); double right = getPadding().getRight(); double w = getWidth() - left - right; double y = top; for(Node child:getChildren()) { double prefH = child.prefHeight(w); child.resizeRelocate( snapPosition(left), snapPosition(y), snapSize(w), snapSize(prefH) ); y += vgap + prefH; } }
Example 4
Source File: BottomSlidePane.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 6 votes |
@Override protected void layoutChildren() { double width = getWidth(); double height = getHeight(); Node center = getCenter(); Node bottom = getBottom(); double bottomHeight = 0; if (bottom != null) { double bottomPrefHeight = bottom.prefHeight(-1); bottomHeight = bottomPrefHeight * bottomVisibility.get(); layoutInArea(bottom, 0, height - bottomHeight, width, bottomPrefHeight, 0, HPos.LEFT, VPos.BOTTOM); } if (center != null) layoutInArea(center, 0, 0, width, height - bottomHeight, 0, HPos.CENTER, VPos.CENTER); }
Example 5
Source File: ConversationBox.java From constellation with Apache License 2.0 | 5 votes |
@Override protected double computePrefHeight(double width) { final Node graphic = getGraphic(); if (graphic == null) { return super.computePrefHeight(width); } else { final Insets padding = getPadding(); width -= padding.getLeft() + padding.getRight(); return graphic.prefHeight(width) + padding.getTop() + padding.getBottom(); } }
Example 6
Source File: ListMenuSkin.java From tornadofx-controls with Apache License 2.0 | 5 votes |
protected void layoutChildren(double x, double y, double w, double h) { for (Node node : getChildren()) { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { double prefHeight = node.prefHeight(-1); node.resizeRelocate(x, y, w, prefHeight); y += prefHeight; } else { double prefWidth = node.prefWidth(-1); node.resizeRelocate(x, y, prefWidth, h); x += prefWidth; } } }
Example 7
Source File: FlowBox.java From FxDock with Apache License 2.0 | 5 votes |
public Helper() { Insets m = getInsets(); top = m.getTop(); bottom = m.getBottom(); left = m.getLeft(); right = m.getRight(); double lh = 0.0; children = getChildren(); sz = children.size(); widths = new double[sz]; for(int i=0; i<sz; i++) { Node ch = children.get(i); if(ch.isManaged()) { double w = ch.prefWidth(-1); widths[i] = w; double h = ch.prefHeight(-1); if(h > lh) { lh = h; } } } lineHeight = lh; }
Example 8
Source File: NodeDetailPaneInfo.java From scenic-view with GNU General Public License v3.0 | 4 votes |
@Override protected void updateAllDetails() { final Node node = (Node) getTarget(); // No property change events on these resizableDetail.setValue(node != null ? Boolean.toString(node.isResizable()) : "-"); // boolean showResizable = node != null && node.isResizable(); resizableDetail.setIsDefault(node == null); Orientation bias = null; if (node != null) { bias = node.getContentBias(); contentBiasDetail.setValue(bias != null ? bias.toString() : "none"); } else { contentBiasDetail.setValue("-"); } contentBiasDetail.setIsDefault(node == null || node.getContentBias() == null); baselineDetail.setValue(node != null ? f.format(node.getBaselineOffset()) : "-"); baselineDetail.setIsDefault(node == null); if (node != null) { double minw = 0; double minh = 0; double prefw = 0; double prefh = 0; double maxw = 0; double maxh = 0; if (bias == null) { minSizeDetail.setLabel("minWidth(-1)/minHeight(-1):"); prefSizeDetail.setLabel("prefWidth(-1)/prefHeight(-1):"); maxSizeDetail.setLabel("maxWidth(-1)/maxHeight(-1):"); minw = node.minWidth(-1); minh = node.minHeight(-1); prefw = node.prefWidth(-1); prefh = node.prefHeight(-1); maxw = node.maxWidth(-1); maxh = node.maxHeight(-1); } else if (bias == Orientation.HORIZONTAL) { minSizeDetail.setLabel("minWidth(-1)/minHeight(w):"); prefSizeDetail.setLabel("prefWidth(-1)/prefHeight(w):"); maxSizeDetail.setLabel("maxWidth(-1)/maxHeight(w):"); minw = node.minWidth(-1); minh = node.minHeight(minw); prefw = node.prefWidth(-1); prefh = node.prefHeight(prefw); maxw = node.maxWidth(-1); maxh = node.maxHeight(maxw); } else { // VERTICAL minSizeDetail.setLabel("minWidth(h)/minHeight(-1):"); prefSizeDetail.setLabel("prefWidth(h)/prefHeight(-1):"); maxSizeDetail.setLabel("maxWidth(h)/maxHeight(-1):"); minh = node.minHeight(-1); minw = node.minWidth(minh); prefh = node.prefHeight(-1); prefw = node.prefWidth(prefh); maxh = node.maxHeight(-1); maxw = node.maxWidth(maxh); } minSizeDetail.setValue(f.format(minw) + " x " + f.format(minh)); prefSizeDetail.setValue(f.format(prefw) + " x " + f.format(prefh)); maxSizeDetail.setValue((maxw >= Double.MAX_VALUE ? "MAXVALUE" : f.format(maxw)) + " x " + (maxh >= Double.MAX_VALUE ? "MAXVALUE" : f.format(maxh))); } else { minSizeDetail.setValue("-"); prefSizeDetail.setValue("-"); maxSizeDetail.setValue("-"); } final boolean fade = node == null || !node.isResizable(); minSizeDetail.setIsDefault(fade); prefSizeDetail.setIsDefault(fade); maxSizeDetail.setIsDefault(fade); @SuppressWarnings("rawtypes") final ObservableMap map = node != null && node.hasProperties() ? node.getProperties() : null; constraintsDetail.setValue(ConnectorUtils.serializePropertyMap(map)); constraintsDetail.setIsDefault(map == null || map.size() == 0); updateDetail("*"); }
Example 9
Source File: FlowSafeVBox.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override protected double computePrefHeight(double width) { double height = 0; for(Node child:getChildren()) height += vgap + child.prefHeight(width); if (!getChildren().isEmpty()) height -= vgap; return getPadding().getTop() + height + getPadding().getBottom(); }
Example 10
Source File: FlowSafeVBox.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override protected double computePrefHeight(double width) { double height = 0; for(Node child:getChildren()) height += vgap + child.prefHeight(width); if (!getChildren().isEmpty()) height -= vgap; return getPadding().getTop() + height + getPadding().getBottom(); }
Example 11
Source File: OrientationHelper.java From Flowless with BSD 2-Clause "Simplified" License | 4 votes |
@Override public double prefBreadth(Node node) { return node.prefHeight(-1); }
Example 12
Source File: OrientationHelper.java From Flowless with BSD 2-Clause "Simplified" License | 4 votes |
@Override public double prefLength(Node node, double breadth) { return node.prefHeight(breadth); }