* There is a one-to-one relationship between a {@code PopupControl} and its * {@code Skin}. Every {@code Skin} maintains a back reference to the * {@code PopupControl}. *
* A skin may be null.
*/
@Override public final ObjectProperty
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Defaults to the
* Defaults to the
* Defaults to the
* Defaults to the
* Defaults to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* Defaults to the
* Setting this value to the
* If this parent is either a layout root or unmanaged, then it will be
* added directly to the scene's dirty layout list, otherwise requestLayout
* will be invoked on its parent.
*/
@Override public void requestLayout() {
prefWidthCache = -1;
prefHeightCache = -1;
minWidthCache = -1;
minHeightCache = -1;
maxWidthCache = -1;
maxHeightCache = -1;
//skinSizeComputed = false; -- RT-33073 disabled this
super.requestLayout();
}
/**
* This method should be treated as final and should not be overridden by any subclasses of CSSBridge.
* @return the styleable parent
*/
@Override
public Styleable getStyleableParent() {
return PopupControl.this.getStyleableParent();
}
@Override
public ListUSE_COMPUTED_SIZE
flag, which means that
* getMinWidth(forHeight)
will return the control's internally
* computed minimum width.
* USE_PREF_SIZE
flag will cause
* getMinWidth(forHeight)
to return the control's preferred width,
* enabling applications to easily restrict the resizability of the control.
*/
private DoubleProperty minWidth;
/**
* Property for overriding the control's computed minimum width.
* This should only be set if the control's internally computed minimum width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMinWidth(forHeight)
will return the control's internally
* computed minimum width.
* USE_PREF_SIZE
flag will cause
* getMinWidth(forHeight)
to return the control's preferred width,
* enabling applications to easily restrict the resizability of the control.
* @param value the minimum width
*/
public final void setMinWidth(double value) { minWidthProperty().set(value); }
/**
* Property for overriding the control's computed minimum width.
* This should only be set if the control's internally computed minimum width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMinWidth(forHeight)
will return the control's internally
* computed minimum width.
* USE_PREF_SIZE
flag will cause
* getMinWidth(forHeight)
to return the control's preferred width,
* enabling applications to easily restrict the resizability of the control.
* @return the minimum width
*/
public final double getMinWidth() { return minWidth == null ? USE_COMPUTED_SIZE : minWidth.get(); }
public final DoubleProperty minWidthProperty() {
if (minWidth == null) {
minWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
@Override public void invalidated() {
if (isShowing()) bridge.requestLayout();
}
@Override
public Object getBean() {
return PopupControl.this;
}
@Override
public String getName() {
return "minWidth";
}
};
}
return minWidth;
}
/**
* Property for overriding the control's computed minimum height.
* This should only be set if the control's internally computed minimum height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMinHeight(forWidth)
will return the control's internally
* computed minimum height.
* USE_PREF_SIZE
flag will cause
* getMinHeight(forWidth)
to return the control's preferred height,
* enabling applications to easily restrict the resizability of the control.
*
*/
private DoubleProperty minHeight;
/**
* Property for overriding the control's computed minimum height.
* This should only be set if the control's internally computed minimum height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMinHeight(forWidth)
will return the control's internally
* computed minimum height.
* USE_PREF_SIZE
flag will cause
* getMinHeight(forWidth)
to return the control's preferred height,
* enabling applications to easily restrict the resizability of the control.
*
* @param value the minimum height
*/
public final void setMinHeight(double value) { minHeightProperty().set(value); }
/**
* Property for overriding the control's computed minimum height.
* This should only be set if the control's internally computed minimum height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMinHeight(forWidth)
will return the control's internally
* computed minimum height.
* USE_PREF_SIZE
flag will cause
* getMinHeight(forWidth)
to return the control's preferred height,
* enabling applications to easily restrict the resizability of the control.
*
* @return the minimum height
*/
public final double getMinHeight() { return minHeight == null ? USE_COMPUTED_SIZE : minHeight.get(); }
public final DoubleProperty minHeightProperty() {
if (minHeight == null) {
minHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
@Override public void invalidated() {
if (isShowing()) bridge.requestLayout();
}
@Override
public Object getBean() {
return PopupControl.this;
}
@Override
public String getName() {
return "minHeight";
}
};
}
return minHeight;
}
/**
* Convenience method for overriding the control's computed minimum width and height.
* This should only be called if the control's internally computed minimum size
* doesn't meet the application's layout needs.
*
* @see #setMinWidth
* @see #setMinHeight
* @param minWidth the override value for minimum width
* @param minHeight the override value for minimum height
*/
public void setMinSize(double minWidth, double minHeight) {
setMinWidth(minWidth);
setMinHeight(minHeight);
}
/**
* Property for overriding the control's computed preferred width.
* This should only be set if the control's internally computed preferred width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getPrefWidth(forHeight)
will return the control's internally
* computed preferred width.
*/
private DoubleProperty prefWidth;
/**
* Property for overriding the control's computed preferred width.
* This should only be set if the control's internally computed preferred width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getPrefWidth(forHeight)
will return the control's internally
* computed preferred width.
* @param value the preferred width
*/
public final void setPrefWidth(double value) { prefWidthProperty().set(value); }
/**
* Property for overriding the control's computed preferred width.
* This should only be set if the control's internally computed preferred width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getPrefWidth(forHeight)
will return the control's internally
* computed preferred width.
* @return the preferred width
*/
public final double getPrefWidth() { return prefWidth == null ? USE_COMPUTED_SIZE : prefWidth.get(); }
public final DoubleProperty prefWidthProperty() {
if (prefWidth == null) {
prefWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
@Override public void invalidated() {
if (isShowing()) bridge.requestLayout();
}
@Override
public Object getBean() {
return PopupControl.this;
}
@Override
public String getName() {
return "prefWidth";
}
};
}
return prefWidth;
}
/**
* Property for overriding the control's computed preferred height.
* This should only be set if the control's internally computed preferred height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getPrefHeight(forWidth)
will return the control's internally
* computed preferred width.
*
*/
private DoubleProperty prefHeight;
/**
* Property for overriding the control's computed preferred height.
* This should only be set if the control's internally computed preferred height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getPrefHeight(forWidth)
will return the control's internally
* computed preferred width.
*
* @param value the preferred height
*/
public final void setPrefHeight(double value) { prefHeightProperty().set(value); }
/**
* Property for overriding the control's computed preferred height.
* This should only be set if the control's internally computed preferred height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getPrefHeight(forWidth)
will return the control's internally
* computed preferred width.
*
* @return the preferred height
*/
public final double getPrefHeight() { return prefHeight == null ? USE_COMPUTED_SIZE : prefHeight.get(); }
public final DoubleProperty prefHeightProperty() {
if (prefHeight == null) {
prefHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
@Override public void invalidated() {
if (isShowing()) bridge.requestLayout();
}
@Override
public Object getBean() {
return PopupControl.this;
}
@Override
public String getName() {
return "prefHeight";
}
};
}
return prefHeight;
}
/**
* Convenience method for overriding the control's computed preferred width and height.
* This should only be called if the control's internally computed preferred size
* doesn't meet the application's layout needs.
*
* @see #setPrefWidth
* @see #setPrefHeight
* @param prefWidth the override value for preferred width
* @param prefHeight the override value for preferred height
*/
public void setPrefSize(double prefWidth, double prefHeight) {
setPrefWidth(prefWidth);
setPrefHeight(prefHeight);
}
/**
* Property for overriding the control's computed maximum width.
* This should only be set if the control's internally computed maximum width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMaxWidth(forHeight)
will return the control's internally
* computed maximum width.
* USE_PREF_SIZE
flag will cause
* getMaxWidth(forHeight)
to return the control's preferred width,
* enabling applications to easily restrict the resizability of the control.
*/
private DoubleProperty maxWidth;
/**
* Property for overriding the control's computed maximum width.
* This should only be set if the control's internally computed maximum width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMaxWidth(forHeight)
will return the control's internally
* computed maximum width.
* USE_PREF_SIZE
flag will cause
* getMaxWidth(forHeight)
to return the control's preferred width,
* enabling applications to easily restrict the resizability of the control.
* @param value the maximum width
*/
public final void setMaxWidth(double value) { maxWidthProperty().set(value); }
/**
* Property for overriding the control's computed maximum width.
* This should only be set if the control's internally computed maximum width
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMaxWidth(forHeight)
will return the control's internally
* computed maximum width.
* USE_PREF_SIZE
flag will cause
* getMaxWidth(forHeight)
to return the control's preferred width,
* enabling applications to easily restrict the resizability of the control.
* @return the maximum width
*/
public final double getMaxWidth() { return maxWidth == null ? USE_COMPUTED_SIZE : maxWidth.get(); }
public final DoubleProperty maxWidthProperty() {
if (maxWidth == null) {
maxWidth = new DoublePropertyBase(USE_COMPUTED_SIZE) {
@Override public void invalidated() {
if (isShowing()) bridge.requestLayout();
}
@Override
public Object getBean() {
return PopupControl.this;
}
@Override
public String getName() {
return "maxWidth";
}
};
}
return maxWidth;
}
/**
* Property for overriding the control's computed maximum height.
* This should only be set if the control's internally computed maximum height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMaxHeight(forWidth)
will return the control's internally
* computed maximum height.
* USE_PREF_SIZE
flag will cause
* getMaxHeight(forWidth)
to return the control's preferred height,
* enabling applications to easily restrict the resizability of the control.
*
*/
private DoubleProperty maxHeight;
/**
* Property for overriding the control's computed maximum height.
* This should only be set if the control's internally computed maximum height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMaxHeight(forWidth)
will return the control's internally
* computed maximum height.
* USE_PREF_SIZE
flag will cause
* getMaxHeight(forWidth)
to return the control's preferred height,
* enabling applications to easily restrict the resizability of the control.
*
* @param value the maximum height
*/
public final void setMaxHeight(double value) { maxHeightProperty().set(value); }
/**
* Property for overriding the control's computed maximum height.
* This should only be set if the control's internally computed maximum height
* doesn't meet the application's layout needs.
* USE_COMPUTED_SIZE
flag, which means that
* getMaxHeight(forWidth)
will return the control's internally
* computed maximum height.
* USE_PREF_SIZE
flag will cause
* getMaxHeight(forWidth)
to return the control's preferred height,
* enabling applications to easily restrict the resizability of the control.
*
* @return the maximum height
*/
public final double getMaxHeight() { return maxHeight == null ? USE_COMPUTED_SIZE : maxHeight.get(); }
public final DoubleProperty maxHeightProperty() {
if (maxHeight == null) {
maxHeight = new DoublePropertyBase(USE_COMPUTED_SIZE) {
@Override public void invalidated() {
if (isShowing()) bridge.requestLayout();
}
@Override
public Object getBean() {
return PopupControl.this;
}
@Override
public String getName() {
return "maxHeight";
}
};
}
return maxHeight;
}
/**
* Convenience method for overriding the control's computed maximum width and height.
* This should only be called if the control's internally computed maximum size
* doesn't meet the application's layout needs.
*
* @see #setMaxWidth
* @see #setMaxHeight
* @param maxWidth the override value for maximum width
* @param maxHeight the override value for maximum height
*/
public void setMaxSize(double maxWidth, double maxHeight) {
setMaxWidth(maxWidth);
setMaxHeight(maxHeight);
}
/**
* Cached prefWidth, prefHeight, minWidth, minHeight. These
* results are repeatedly sought during the layout pass,
* and caching the results leads to a significant decrease
* in overhead.
*/
private double prefWidthCache = -1;
private double prefHeightCache = -1;
private double minWidthCache = -1;
private double minHeightCache = -1;
private double maxWidthCache = -1;
private double maxHeightCache = -1;
private boolean skinSizeComputed = false;
/**
* Called during layout to determine the minimum width for this node.
* Returns the value from minWidth(forHeight)
unless
* the application overrode the minimum width by setting the minWidth property.
*
* @param height the height
* @see #setMinWidth
* @return the minimum width that this node should be resized to during layout
*/
public final double minWidth(double height) {
double override = getMinWidth();
if (override == USE_COMPUTED_SIZE) {
if (minWidthCache == -1) minWidthCache = recalculateMinWidth(height);
return minWidthCache;
} else if (override == USE_PREF_SIZE) {
return prefWidth(height);
}
return override;
}
/**
* Called during layout to determine the minimum height for this node.
* Returns the value from minHeight(forWidth)
unless
* the application overrode the minimum height by setting the minHeight property.
*
* @param width The width
* @see #setMinHeight
* @return the minimum height that this node should be resized to during layout
*/
public final double minHeight(double width) {
double override = getMinHeight();
if (override == USE_COMPUTED_SIZE) {
if (minHeightCache == -1) minHeightCache = recalculateMinHeight(width);
return minHeightCache;
} else if (override == USE_PREF_SIZE) {
return prefHeight(width);
}
return override;
}
/**
* Called during layout to determine the preferred width for this node.
* Returns the value from prefWidth(forHeight)
unless
* the application overrode the preferred width by setting the prefWidth property.
*
* @param height the height
* @see #setPrefWidth
* @return the preferred width that this node should be resized to during layout
*/
public final double prefWidth(double height) {
double override = getPrefWidth();
if (override == USE_COMPUTED_SIZE) {
if (prefWidthCache == -1) prefWidthCache = recalculatePrefWidth(height);
return prefWidthCache;
} else if (override == USE_PREF_SIZE) {
return prefWidth(height);
}
return override;
}
/**
* Called during layout to determine the preferred height for this node.
* Returns the value from prefHeight(forWidth)
unless
* the application overrode the preferred height by setting the prefHeight property.
*
* @param width the width
* @see #setPrefHeight
* @return the preferred height that this node should be resized to during layout
*/
public final double prefHeight(double width) {
double override = getPrefHeight();
if (override == USE_COMPUTED_SIZE) {
if (prefHeightCache == -1) prefHeightCache = recalculatePrefHeight(width);
return prefHeightCache;
} else if (override == USE_PREF_SIZE) {
return prefHeight(width);
}
return override;
}
/**
* Called during layout to determine the maximum width for this node.
* Returns the value from maxWidth(forHeight)
unless
* the application overrode the maximum width by setting the maxWidth property.
*
* @param height the height
* @see #setMaxWidth
* @return the maximum width that this node should be resized to during layout
*/
public final double maxWidth(double height) {
double override = getMaxWidth();
if (override == USE_COMPUTED_SIZE) {
if (maxWidthCache == -1) maxWidthCache = recalculateMaxWidth(height);
return maxWidthCache;
} else if (override == USE_PREF_SIZE) {
return prefWidth(height);
}
return override;
}
/**
* Called during layout to determine the maximum height for this node.
* Returns the value from maxHeight(forWidth)
unless
* the application overrode the maximum height by setting the maxHeight property.
*
* @param width the width
* @see #setMaxHeight
* @return the maximum height that this node should be resized to during layout
*/
public final double maxHeight(double width) {
double override = getMaxHeight();
if (override == USE_COMPUTED_SIZE) {
if (maxHeightCache == -1) maxHeightCache = recalculateMaxHeight(width);
return maxHeightCache;
} else if (override == USE_PREF_SIZE) {
return prefHeight(width);
}
return override;
}
// Implementation of the Resizable interface.
// Because only the skin can know the min, pref, and max sizes, these
// functions are implemented to delegate to skin. If there is no skin then
// we simply return 0 for all the values since a Control without a Skin
// doesn't render
private double recalculateMinWidth(double height) {
recomputeSkinSize();
return getSkinNode() == null ? 0 : getSkinNode().minWidth(height);
}
private double recalculateMinHeight(double width) {
recomputeSkinSize();
return getSkinNode() == null ? 0 : getSkinNode().minHeight(width);
}
private double recalculateMaxWidth(double height) {
recomputeSkinSize();
return getSkinNode() == null ? 0 : getSkinNode().maxWidth(height);
}
private double recalculateMaxHeight(double width) {
recomputeSkinSize();
return getSkinNode() == null ? 0 : getSkinNode().maxHeight(width);
}
private double recalculatePrefWidth(double height) {
recomputeSkinSize();
return getSkinNode() == null? 0 : getSkinNode().prefWidth(height);
}
private double recalculatePrefHeight(double width) {
recomputeSkinSize();
return getSkinNode() == null? 0 : getSkinNode().prefHeight(width);
}
private void recomputeSkinSize() {
if (!skinSizeComputed) {
// RT-14094, RT-16754: We need the skins of the popup
// and it children before the stage is visible so we
// can calculate the popup position based on content
// size.
bridge.applyCss();
skinSizeComputed = true;
}
}
// public double getBaselineOffset() { return getSkinNode() == null? 0 : getSkinNode().getBaselineOffset(); }
/**
* Create a new instance of the default skin for this control. This is called to create a skin for the control if
* no skin is provided via CSS {@code -fx-skin} or set explicitly in a sub-class with {@code setSkin(...)}.
*
* @return new instance of default skin for this control. If null then the control will have no skin unless one
* is provided by css.
* @since JavaFX 8.0
*/
protected Skin> createDefaultSkin() {
return null;
}
/***************************************************************************
* *
* StyleSheet Handling *
* *
**************************************************************************/
private static final CssMetaData