Java Code Examples for javafx.scene.Node#minWidth()

The following examples show how to use javafx.scene.Node#minWidth() . 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: CPane.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected double sizeWidth(boolean pref, Node n)
{
	double d = n.minWidth(-1);
	if(pref)
	{
		d = Math.max(d, n.prefWidth(-1));
	}
	return d;
}
 
Example 2
Source File: NodeDetailPaneInfo.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
@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 3
Source File: FlowSafeVBox.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override protected double computeMinHeight(double width) {
    double minHeight = 0;
    for(Node child:getChildren()) minHeight += child.minWidth(-1) + vgap;
    if (!getChildren().isEmpty()) minHeight -= vgap;
    return getPadding().getTop() + minHeight + getPadding().getBottom();
}
 
Example 4
Source File: FlowSafeVBox.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override protected double computeMinHeight(double width) {
    double minHeight = 0;
    for(Node child:getChildren()) minHeight += child.minWidth(-1) + vgap;
    if (!getChildren().isEmpty()) minHeight -= vgap;
    return getPadding().getTop() + minHeight + getPadding().getBottom();
}
 
Example 5
Source File: NodeLayoutBehavior.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void preLayout() {
	org.eclipse.gef.graph.Node content = getHost().getContent();

	Node visual = getHost().getVisual();
	Bounds hostBounds = visual.getLayoutBounds();
	double minx = hostBounds.getMinX();
	double miny = hostBounds.getMinY();
	double maxx = hostBounds.getMaxX();
	double maxy = hostBounds.getMaxY();
	Affine transform = getHost().getVisualTransform();

	// initialize size
	if (ZestProperties.getSize(content) != null) {
		// no model information available yet, use visual location
		preLayoutSize = ZestProperties.getSize(content).getCopy();
	} else {
		preLayoutSize = new Dimension(maxx - minx, maxy - miny);
	}

	// constrain to visual's min-size
	{
		double minWidth = visual.minWidth(-1);
		double minHeight = visual.minHeight(-1);
		if (preLayoutSize.width < minWidth) {
			preLayoutSize.width = minWidth;
		}
		if (preLayoutSize.height < minHeight) {
			preLayoutSize.height = minHeight;
		}
	}

	// System.out.println("pre layout size of " + content + ": " +
	// preLayoutSize);
	LayoutProperties.setSize(content, preLayoutSize.getCopy());

	// initialize location (layout location is center while visual position
	// is top-left)
	if (ZestProperties.getPosition(content) != null) {
		LayoutProperties.setLocation(content,
				ZestProperties.getPosition(content).getTranslated(preLayoutSize.getScaled(0.5)));
	} else {
		// no model information available yet, use visual location
		LayoutProperties.setLocation(content, new Point(transform.getTx() + minx + (maxx - minx) / 2,
				transform.getTy() + miny + (maxy - miny) / 2));
	}

	// additional information inferred from visual
	LayoutProperties.setResizable(content, visual.isResizable());
}
 
Example 6
Source File: OrientationHelper.java    From Flowless with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public double minBreadth(Node node) {
    return node.minWidth(-1);
}