下面列出了javafx.scene.Node#minHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected double sizeHeight(boolean pref, Node n)
{
double d = n.minHeight(-1);
if(pref)
{
d = Math.max(d, n.prefHeight(-1));
}
return d;
}
@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("*");
}
@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());
}
@Override
public double minBreadth(Node node) {
return node.minHeight(-1);
}