public abstract class SkinBase<C extends Control> extends java.lang.Object implements Skin<C>
skin
.
A user interface control is abstracted behind the Skinnable
interface.Modifier and Type | Class and Description |
---|---|
private static class |
SkinBase.StyleableProperties
*
Specialization of CSS handling code *
*
|
Modifier and Type | Field and Description |
---|---|
private <any> |
children
A local field that directly refers to the children list inside the Control.
|
private C |
control
The
Control that is referencing this Skin. |
private LambdaMultiplePropertyChangeListenerHandler |
lambdaChangeListenerHandler
This is part of the workaround introduced during delomboking.
|
private static <any> |
mouseEventConsumer
Mouse handler used for consuming all mouse events (preventing them
from bubbling up to parent)
|
Modifier | Constructor and Description |
---|---|
protected |
SkinBase(C control)
Constructor for all SkinBase instances.
|
Modifier and Type | Method and Description |
---|---|
protected double |
computeBaselineOffset(double topInset,
double rightInset,
double bottomInset,
double leftInset)
Calculates the baseline offset based on the first managed child.
|
protected double |
computeMaxHeight(double width,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
Computes the maximum allowable height of the Skin, based on the provided
width.
|
protected double |
computeMaxWidth(double height,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
Computes the maximum allowable width of the Skin, based on the provided
height.
|
protected double |
computeMinHeight(double width,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
Computes the minimum allowable height of the Skin, based on the provided
width.
|
protected double |
computeMinWidth(double height,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
Computes the minimum allowable width of the Skin, based on the provided
height.
|
protected double |
computePrefHeight(double width,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
Calculates the preferred height of this
SkinBase . |
protected double |
computePrefWidth(double height,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
Calculates the preferred width of this
SkinBase . |
protected void |
consumeMouseEvents(boolean value)
Determines whether all mouse events should be automatically consumed.
|
void |
dispose()
Called by a Skinnable when the Skin is replaced on the Skinnable.
|
protected void |
executeAccessibleAction(AccessibleAction action,
java.lang.Object... parameters)
This method is called by the assistive technology to request the action
indicated by the argument should be executed.
|
<any> |
getChildren()
Returns the children of the skin.
|
static java.util.List<<any>> |
getClassCssMetaData()
Returns the CssMetaData associated with this class, which may include the
CssMetaData of its superclasses.
|
java.util.List<<any>> |
getCssMetaData()
This method should delegate to
Node#getClassCssMetaData() so that
a Node's CssMetaData can be accessed without the need for reflection. |
Node |
getNode()
Gets the Node which represents this Skin.
|
C |
getSkinnable()
Gets the Skinnable to which this Skin is assigned.
|
protected void |
layoutChildren(double contentX,
double contentY,
double contentWidth,
double contentHeight)
Called during the layout pass of the scenegraph.
|
protected void |
layoutInArea(Node child,
double areaX,
double areaY,
double areaWidth,
double areaHeight,
double areaBaselineOffset,
HPos halignment,
VPos valignment)
Utility method which lays out the child within an area of this
skin defined by
areaX , areaY , areaWidth x areaHeight ,
with a baseline offset relative to that area. |
protected void |
layoutInArea(Node child,
double areaX,
double areaY,
double areaWidth,
double areaHeight,
double areaBaselineOffset,
Insets margin,
boolean fillWidth,
boolean fillHeight,
HPos halignment,
VPos valignment)
Utility method which lays out the child within an area of this
skin defined by
areaX , areaY , areaWidth x areaHeight ,
with a baseline offset relative to that area. |
protected void |
layoutInArea(Node child,
double areaX,
double areaY,
double areaWidth,
double areaHeight,
double areaBaselineOffset,
Insets margin,
HPos halignment,
VPos valignment)
Utility method which lays out the child within an area of this
skin defined by
areaX , areaY , areaWidth x areaHeight ,
with a baseline offset relative to that area. |
protected void |
positionInArea(Node child,
double areaX,
double areaY,
double areaWidth,
double areaHeight,
double areaBaselineOffset,
HPos halignment,
VPos valignment)
Utility method which positions the child within an area of this
skin defined by
areaX , areaY , areaWidth x areaHeight ,
with a baseline offset relative to that area. |
protected void |
positionInArea(Node child,
double areaX,
double areaY,
double areaWidth,
double areaHeight,
double areaBaselineOffset,
Insets margin,
HPos halignment,
VPos valignment)
Utility method which positions the child within an area of this
skin defined by
areaX , areaY , areaWidth x areaHeight ,
with a baseline offset relative to that area. |
void |
pseudoClassStateChanged(PseudoClass pseudoClass,
boolean active)
Used to specify that a pseudo-class of this Node has changed.
|
protected java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters)
This method is called by the assistive technology to request
the value for an attribute.
|
protected void |
registerChangeListener(<any> property,
java.util.function.Consumer<<any>> consumer)
Subclasses can invoke this method to register that they want to listen to
property change events for the given property.
|
protected double |
snappedBottomInset()
Utility method to get the bottom inset which includes padding and border
inset.
|
protected double |
snappedLeftInset()
Utility method to get the left inset which includes padding and border
inset.
|
protected double |
snappedRightInset()
Utility method to get the right inset which includes padding and border
inset.
|
protected double |
snappedTopInset()
Utility method to get the top inset which includes padding and border
inset.
|
protected double |
snapPosition(double value)
Deprecated.
replaced by
snapPositionX() and snapPositionY() |
protected double |
snapPositionX(double value)
Convenience method for accessing the
snapPositionX()
method on the skinnable. |
protected double |
snapPositionY(double value)
Convenience method for accessing the
snapPositionY()
method on the skinnable. |
protected double |
snapSize(double value)
Deprecated.
replaced by
snapSizeX() and snapSizeY() |
protected double |
snapSizeX(double value)
Convenience method for accessing the
snapSizeX()
method on the skinnable. |
protected double |
snapSizeY(double value)
Convenience method for accessing the
snapSizeY()
method on the skinnable. |
protected double |
snapSpace(double value)
Deprecated.
replaced by
snapSpaceX() and snapSpaceY() |
protected double |
snapSpaceX(double value)
Convenience method for accessing the
snapSpaceX()
method on the skinnable. |
protected double |
snapSpaceY(double value)
Convenience method for accessing the
snapSpaceY()
method on the skinnable. |
protected java.util.function.Consumer<<any>> |
unregisterChangeListeners(<any> property)
Unregisters all change listeners that have been registered using
#registerChangeListener(ObservableValue, Consumer)
for the given property. |
private C extends Control control
Control
that is referencing this Skin. There is a
one-to-one relationship between a Skin
and a Control
.
When a Skin
is set on a Control
, this variable is
automatically updated.private <any> children
private LambdaMultiplePropertyChangeListenerHandler lambdaChangeListenerHandler
private static final <any> mouseEventConsumer
protected SkinBase(C control)
control
- The control for which this Skin should attach to.public final C getSkinnable()
Skin.dispose()
.
The caller who constructs a Skinnable must also construct a Skin and properly establish the relationship between the Control and its Skin.
getSkinnable
in interface Skin<C extends Control>
public final Node getNode()
Skin.dispose()
, and must never change except when
changing to null.public void dispose()
Skin.getSkinnable()
and Skin.getNode()
should return null following a call to dispose. Calling dispose twice
has no effect.public final <any> getChildren()
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight)
contentX
- the x positioncontentY
- the y positioncontentWidth
- the widthcontentHeight
- the heightprotected final void consumeMouseEvents(boolean value)
value
- the consume mouse events flagprotected final void registerChangeListener(<any> property, java.util.function.Consumer<<any>> consumer)
Consumer
instances
will be executed in the order in which they are registered.property
- the propertyconsumer
- the consumerprotected final java.util.function.Consumer<<any>> unregisterChangeListeners(<any> property)
#registerChangeListener(ObservableValue, Consumer)
for the given property. The end result is that the given property is no longer observed by any of the change
listeners, but it may still have additional listeners registered on it through means outside of
#registerChangeListener(ObservableValue, Consumer)
.property
- The property for which all listeners should be removed.Consumer
consisting of all consumers
registered through
#registerChangeListener(ObservableValue, Consumer)
. If no consumers have been registered on this
property, null will be returned.protected double computeMinWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
height
- The height of the Skin, in case this value might dictate
the minimum width.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
width
- The width of the Skin, in case this value might dictate
the minimum height.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
height
- The height of the Skin, in case this value might dictate
the maximum width.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
width
- The width of the Skin, in case this value might dictate
the maximum height.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
SkinBase
. The default
implementation calculates this width as the width of the area occupied
by its managed children when they are positioned at their
current positions at their preferred widths.height
- the height that should be used if preferred width depends on ittopInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
SkinBase
. The default
implementation calculates this height as the height of the area occupied
by its managed children when they are positioned at their current
positions at their preferred heights.width
- the width that should be used if preferred height depends on ittopInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset)
Node#getBaselineOffset()
.topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left insetprotected double snappedTopInset()
protected double snappedBottomInset()
protected double snappedLeftInset()
protected double snappedRightInset()
@Deprecated protected double snapSpace(double value)
snapSpaceX()
and snapSpaceY()
getSkinnable().isSnapToPixel()
is false, this method
returns the same value, else it tries to return a value rounded to
the nearest pixel, but since there is no indication if the value is
a vertical or horizontal measurement then it may be snapped to the
wrong pixel size metric on screens with different horizontal and
vertical scales.value
- the space value to be snappedprotected double snapSpaceX(double value)
snapSpaceX()
method on the skinnable.
It is equivalent to calling
getSkinnable().snapSpaceX(value)
.value
- the space value to be snappedRegion#snapSpaceX(double)
protected double snapSpaceY(double value)
snapSpaceY()
method on the skinnable.
It is equivalent to calling
getSkinnable().snapSpaceY(value)
.value
- the space value to be snappedRegion#snapSpaceY(double)
@Deprecated protected double snapSize(double value)
snapSizeX()
and snapSizeY()
getSkinnable().isSnapToPixel()
is false, this method
returns the same value, else it tries to return a value ceiled to
the nearest pixel, but since there is no indication if the value is
a vertical or horizontal measurement then it may be snapped to the
wrong pixel size metric on screens with different horizontal and
vertical scales.value
- the size value to be snappedprotected double snapSizeX(double value)
snapSizeX()
method on the skinnable.
It is equivalent to calling
getSkinnable().snapSizeX(value)
.value
- the size value to be snappedRegion#snapSizeX(double)
protected double snapSizeY(double value)
snapSizeY()
method on the skinnable.
It is equivalent to calling
getSkinnable().snapSizeY(value)
.value
- the size value to be snappedRegion#snapSizeY(double)
@Deprecated protected double snapPosition(double value)
snapPositionX()
and snapPositionY()
getSkinnable().isSnapToPixel()
is false, this method
returns the same value, else it tries to return a value rounded to
the nearest pixel, but since there is no indication if the value is
a vertical or horizontal measurement then it may be snapped to the
wrong pixel size metric on screens with different horizontal and
vertical scales.value
- the position value to be snappedprotected double snapPositionX(double value)
snapPositionX()
method on the skinnable.
It is equivalent to calling
getSkinnable().snapPositionX(value)
.value
- the position value to be snappedRegion#snapPositionX(double)
protected double snapPositionY(double value)
snapPositionY()
method on the skinnable.
It is equivalent to calling
getSkinnable().snapPositionY(value)
.value
- the position value to be snappedRegion#snapPositionY(double)
protected void positionInArea(Node child, double areaX, double areaY, double areaWidth, double areaHeight, double areaBaselineOffset, HPos halignment, VPos valignment)
areaX
, areaY
, areaWidth
x areaHeight
,
with a baseline offset relative to that area.
This function does not resize the node and uses the node's layout bounds width and height to determine how it should be positioned within the area.
If the vertical alignment is VPos.BASELINE
then it
will position the node so that its own baseline aligns with the passed in
baselineOffset
, otherwise the baseline parameter is ignored.
If snapToPixel
is true
for this skin, then the x/y position
values will be rounded to their nearest pixel boundaries.
child
- the child being positioned within this skinareaX
- the horizontal offset of the layout area relative to this skinareaY
- the vertical offset of the layout area relative to this skinareaWidth
- the width of the layout areaareaHeight
- the height of the layout areaareaBaselineOffset
- the baseline offset to be used if VPos is BASELINEhalignment
- the horizontal alignment for the child within the areavalignment
- the vertical alignment for the child within the areaprotected void positionInArea(Node child, double areaX, double areaY, double areaWidth, double areaHeight, double areaBaselineOffset, Insets margin, HPos halignment, VPos valignment)
areaX
, areaY
, areaWidth
x areaHeight
,
with a baseline offset relative to that area.
This function does not resize the node and uses the node's layout bounds width and height to determine how it should be positioned within the area.
If the vertical alignment is VPos.BASELINE
then it
will position the node so that its own baseline aligns with the passed in
baselineOffset
, otherwise the baseline parameter is ignored.
If snapToPixel
is true
for this skin, then the x/y position
values will be rounded to their nearest pixel boundaries.
If margin
is non-null, then that space will be allocated around the
child within the layout area. margin may be null.
child
- the child being positioned within this skinareaX
- the horizontal offset of the layout area relative to this skinareaY
- the vertical offset of the layout area relative to this skinareaWidth
- the width of the layout areaareaHeight
- the height of the layout areaareaBaselineOffset
- the baseline offset to be used if VPos is BASELINEmargin
- the margin of space to be allocated around the childhalignment
- the horizontal alignment for the child within the areavalignment
- the vertical alignment for the child within the areaprotected void layoutInArea(Node child, double areaX, double areaY, double areaWidth, double areaHeight, double areaBaselineOffset, HPos halignment, VPos valignment)
areaX
, areaY
, areaWidth
x areaHeight
,
with a baseline offset relative to that area.
If the child is resizable, this method will resize it to fill the specified area unless the node's maximum size prevents it. If the node's maximum size preference is less than the area size, the maximum size will be used. If node's maximum is greater than the area size, then the node will be resized to fit within the area, unless its minimum size prevents it.
If the child has a non-null contentBias, then this method will use it when resizing the child. If the contentBias is horizontal, it will set its width first to the area's width (up to the child's max width limit) and then pass that value to compute the child's height. If child's contentBias is vertical, then it will set its height to the area height (up to child's max height limit) and pass that height to compute the child's width. If the child's contentBias is null, then it's width and height have no dependencies on each other.
If the child is not resizable (Shape, Group, etc) then it will only be positioned and not resized.
If the child's resulting size differs from the area's size (either
because it was not resizable or it's sizing preferences prevented it), then
this function will align the node relative to the area using horizontal and
vertical alignment values.
If valignment is VPos.BASELINE
then the node's baseline will be aligned
with the area baseline offset parameter, otherwise the baseline parameter
is ignored.
If snapToPixel
is true
for this skin, then the resulting x,y
values will be rounded to their nearest pixel boundaries and the
width/height values will be ceiled to the next pixel boundary.
child
- the child being positioned within this skinareaX
- the horizontal offset of the layout area relative to this skinareaY
- the vertical offset of the layout area relative to this skinareaWidth
- the width of the layout areaareaHeight
- the height of the layout areaareaBaselineOffset
- the baseline offset to be used if VPos is BASELINEhalignment
- the horizontal alignment for the child within the areavalignment
- the vertical alignment for the child within the areaprotected void layoutInArea(Node child, double areaX, double areaY, double areaWidth, double areaHeight, double areaBaselineOffset, Insets margin, HPos halignment, VPos valignment)
areaX
, areaY
, areaWidth
x areaHeight
,
with a baseline offset relative to that area.
If the child is resizable, this method will resize it to fill the specified area unless the node's maximum size prevents it. If the node's maximum size preference is less than the area size, the maximum size will be used. If node's maximum is greater than the area size, then the node will be resized to fit within the area, unless its minimum size prevents it.
If the child has a non-null contentBias, then this method will use it when resizing the child. If the contentBias is horizontal, it will set its width first to the area's width (up to the child's max width limit) and then pass that value to compute the child's height. If child's contentBias is vertical, then it will set its height to the area height (up to child's max height limit) and pass that height to compute the child's width. If the child's contentBias is null, then it's width and height have no dependencies on each other.
If the child is not resizable (Shape, Group, etc) then it will only be positioned and not resized.
If the child's resulting size differs from the area's size (either
because it was not resizable or it's sizing preferences prevented it), then
this function will align the node relative to the area using horizontal and
vertical alignment values.
If valignment is VPos.BASELINE
then the node's baseline will be aligned
with the area baseline offset parameter, otherwise the baseline parameter
is ignored.
If margin
is non-null, then that space will be allocated around the
child within the layout area. margin may be null.
If snapToPixel
is true
for this skin, then the resulting x,y
values will be rounded to their nearest pixel boundaries and the
width/height values will be ceiled to the next pixel boundary.
child
- the child being positioned within this skinareaX
- the horizontal offset of the layout area relative to this skinareaY
- the vertical offset of the layout area relative to this skinareaWidth
- the width of the layout areaareaHeight
- the height of the layout areaareaBaselineOffset
- the baseline offset to be used if VPos is BASELINEmargin
- the margin of space to be allocated around the childhalignment
- the horizontal alignment for the child within the areavalignment
- the vertical alignment for the child within the areaprotected void layoutInArea(Node child, double areaX, double areaY, double areaWidth, double areaHeight, double areaBaselineOffset, Insets margin, boolean fillWidth, boolean fillHeight, HPos halignment, VPos valignment)
areaX
, areaY
, areaWidth
x areaHeight
,
with a baseline offset relative to that area.
If the child is resizable, this method will use fillWidth
and fillHeight
to determine whether to resize it to fill the area or keep the child at its
preferred dimension. If fillWidth/fillHeight are true, then this method
will only resize the child up to its max size limits. If the node's maximum
size preference is less than the area size, the maximum size will be used.
If node's maximum is greater than the area size, then the node will be
resized to fit within the area, unless its minimum size prevents it.
If the child has a non-null contentBias, then this method will use it when resizing the child. If the contentBias is horizontal, it will set its width first and then pass that value to compute the child's height. If child's contentBias is vertical, then it will set its height first and pass that value to compute the child's width. If the child's contentBias is null, then it's width and height have no dependencies on each other.
If the child is not resizable (Shape, Group, etc) then it will only be positioned and not resized.
If the child's resulting size differs from the area's size (either
because it was not resizable or it's sizing preferences prevented it), then
this function will align the node relative to the area using horizontal and
vertical alignment values.
If valignment is VPos.BASELINE
then the node's baseline will be aligned
with the area baseline offset parameter, otherwise the baseline parameter
is ignored.
If margin
is non-null, then that space will be allocated around the
child within the layout area. margin may be null.
If snapToPixel
is true
for this skin, then the resulting x,y
values will be rounded to their nearest pixel boundaries and the
width/height values will be ceiled to the next pixel boundary.
child
- the child being positioned within this skinareaX
- the horizontal offset of the layout area relative to this skinareaY
- the vertical offset of the layout area relative to this skinareaWidth
- the width of the layout areaareaHeight
- the height of the layout areaareaBaselineOffset
- the baseline offset to be used if VPos is BASELINEmargin
- the margin of space to be allocated around the childfillWidth
- whether or not the child should be resized to fill the area width or kept to its preferred widthfillHeight
- whether or not the child should e resized to fill the area height or kept to its preferred heighthalignment
- the horizontal alignment for the child within the areavalignment
- the vertical alignment for the child within the areapublic static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getCssMetaData()
Node#getClassCssMetaData()
so that
a Node's CssMetaData can be accessed without the need for reflection.public final void pseudoClassStateChanged(PseudoClass pseudoClass, boolean active)
invalidated
method of a property that is used as a pseudo-class. For example:
private static final PseudoClass MY_PSEUDO_CLASS_STATE = PseudoClass.getPseudoClass("my-state");
BooleanProperty myPseudoClassState = new BooleanPropertyBase(false) {
@Override public void invalidated() {
pseudoClassStateChanged(MY_PSEUDO_CLASS_STATE, get());
}
@Override public Object getBean() {
return MyControl.this;
}
@Override public String getName() {
return "myPseudoClassState";
}
};
pseudoClass
- the pseudo-class that has changed stateactive
- whether or not the state is activeNode#pseudoClassStateChanged
protected java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
This method is commonly overridden by subclasses to implement
attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation
must be called.
attribute
- the requested attributeparameters
- optional list of parametersAccessibleAttribute
,
Node#queryAccessibleAttribute
protected void executeAccessibleAction(AccessibleAction action, java.lang.Object... parameters)
This method is commonly overridden by subclasses to implement
action that are required for a specific role.
If a particular action is not handled, the superclass implementation
must be called.
action
- the action to executeparameters
- optional list of parametersAccessibleAction
,
Node#executeAccessibleAction