Region. A Background is an immutable object which
encapsulates the entire set of data required to render the background
of a Region. Because this class is immutable, you can freely reuse the same
Background on many different Regions. Please refer to
JavaFX CSS Reference Guide for a
complete description of the CSS rules for styling the background of a Region.
Every Background is comprised of fills and / or
images. Neither list will ever be null, but either or
both may be empty. Each defined BackgroundFill is rendered in order,
followed by each defined BackgroundImage.
The Background's outsets define any extension of the drawing area of a Region
which is necessary to account for all background drawing. These outsets are strictly
defined by the BackgroundFills that are specified on this Background, if any, because
all BackgroundImages are clipped to the drawing area, and do not define it. The
outsets values are strictly non-negative.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final CssMetaData | |
| pack-priv static final CssMetaData | |
| pack-priv static final CssMetaData | |
| pack-priv static final CssMetaData | |
| pack-priv static final CssMetaData | |
| pack-priv static final CssMetaData | |
| pack-priv static final CssMetaData | |
| public static final Background | EMPTY
An empty Background, useful to use instead of null. |
| private final List | |
| private final int | hash
The cached hash code computation for the Background. |
| private final boolean | hasOpaqueFill
Specifies whether the Background has at least one opaque fill. |
| private final boolean | hasPercentageBasedFills
True if there are any fills that are in some way based on the size of the region. |
| private final boolean | |
| private final List | |
| private final double | opaqueFillBottom
The opaque insets of this Background. |
| private final double | opaqueFillLeft
The opaque insets of this Background. |
| private final double | opaqueFillRight
The opaque insets of this Background. |
| private final double | opaqueFillTop
The opaque insets of this Background. |
| private final Insets | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| public | Background(final BackgroundFill...
The fills. This may be null, and may contain nulls. Any
contained nulls are filtered out and not included in the
final List of fills. A null array becomes an empty List. fills)Create a new Background by supplying an array of BackgroundFills. |
| public | Background(final BackgroundImage...
The images. This may be null, and may contain nulls. Any
contained nulls are filtered out and not included in the
final List of images. A null array becomes an empty List. images)Create a new Background by supplying an array of BackgroundImages. |
| public | Background(final List<BackgroundFill>
The fills. This may be null, and may contain nulls. Any
contained nulls are filtered out and not included in the
final List of fills. A null List becomes an empty List. fills, final List<BackgroundImage> The images. This may be null, and may contain nulls. Any
contained nulls are filtered out and not included in the
final List of images. A null List becomes an empty List. images)Create a new Background supply two Lists, one for background fills and one for background images. |
| public | Background(final BackgroundFill[]
The fills. This may be null, and may contain nulls. Any
contained nulls are filtered out and not included in the
final List of fills. A null array becomes an empty List. fills, final BackgroundImage[] The images. This may be null, and may contain nulls. Any
contained nulls are filtered out and not included in the
final List of images. A null array becomes an empty List. images)Create a new Background by supplying two arrays, one for background fills, and one for background images. |
| private | Background(List<BackgroundFill>
the fills, not fills, List<BackgroundImage> nullthe images, not images, int ignored)nullCreates a new Background with the specified fills and images. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | computeOpaqueInsets(double
The width of the region width, double The height of the region height, double[] A four-element array of doubles in order: top, right, bottom, left. trbl)Computes the opaque insets for a region with the specified width and height. |
| private void | computeOpaqueInsets(double
The width of the region width, double The height of the region height, boolean Whether this is being called from the constructor firstTime, double[] A four-element array of doubles in order: top, right, bottom, left. trbl)Computes the opaque insets. |
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public static Background | |
| public static List | Returns: theCssMetaDataGets the |
| public final List | Returns: the list of BackgroundFillsThe list of BackgroundFills which together define the filled portion of this Background. |
| public final List | Returns: the list of BackgroundImagesThe list of BackgroundImages which together define the image portion of this Background. |
| public final Insets | |
| public int | |
| public Background | interpolate(Background endValue, double t)
Implements javafx. Returns an intermediate value between the value of this |
| public final boolean | Returns: true if the Background is empty, false otherwise.Gets whether the background is empty. |
| public boolean | Returns: True if any CornerRadii of any BackgroundFill on this background would return true, false otherwise.Gets whether the fill of this Background is based on percentages (that is, relative to the size of the region being styled). |
| BACKGROUND_COLOR | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, Paint[]> BACKGROUND_COLOR | |
| BACKGROUND_IMAGE | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, Image[]> BACKGROUND_IMAGE | |
| BACKGROUND_INSETS | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, Insets[]> BACKGROUND_INSETS | |
| BACKGROUND_POSITION | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, BackgroundPosition[]> BACKGROUND_POSITION | |
| BACKGROUND_RADIUS | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, CornerRadii[]> BACKGROUND_RADIUS | |
| BACKGROUND_REPEAT | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, RepeatStruct[]> BACKGROUND_REPEAT | |
| BACKGROUND_SIZE | back to summary |
|---|---|
| pack-priv static final CssMetaData<Node, BackgroundSize[]> BACKGROUND_SIZE | |
| EMPTY | back to summary |
|---|---|
| public static final Background EMPTY An empty Background, useful to use instead of null. | |
| fills | back to summary |
|---|---|
| private final List<BackgroundFill> fills | |
| hash | back to summary |
|---|---|
| private final int hash The cached hash code computation for the Background. One very big reason for making Background immutable was to make it possible to cache and reuse the same Background instance for multiple Regions (for example, every un-hovered Button should have the same Background instance). To enable efficient caching, we cache the hash. | |
| hasOpaqueFill | back to summary |
|---|---|
| private final boolean hasOpaqueFill Specifies whether the Background has at least one opaque fill. | |
| hasPercentageBasedFills | back to summary |
|---|---|
| private final boolean hasPercentageBasedFills True if there are any fills that are in some way based on the size of the region. For example, if a CornerRadii on the fill is percentage based in either or both dimensions. | |
| hasPercentageBasedOpaqueFills | back to summary |
|---|---|
| private final boolean hasPercentageBasedOpaqueFills | |
| images | back to summary |
|---|---|
| private final List<BackgroundImage> images | |
| opaqueFillBottom | back to summary |
|---|---|
| private final double opaqueFillBottom The opaque insets of this Background. | |
| opaqueFillLeft | back to summary |
|---|---|
| private final double opaqueFillLeft The opaque insets of this Background. | |
| opaqueFillRight | back to summary |
|---|---|
| private final double opaqueFillRight The opaque insets of this Background. | |
| opaqueFillTop | back to summary |
|---|---|
| private final double opaqueFillTop The opaque insets of this Background. | |
| outsets | back to summary |
|---|---|
| private final Insets outsets | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| Background | back to summary |
|---|---|
| public Background(final BackgroundFill... fills) Create a new Background by supplying an array of BackgroundFills.
This array may be null, or may contain null values. Any null values
will be ignored and will not contribute to the
| |
| Background | back to summary |
|---|---|
| public Background(final BackgroundImage... images) Create a new Background by supplying an array of BackgroundImages.
This array may be null, or may contain null values. Any null values will
be ignored and will not contribute to the
| |
| Background | back to summary |
|---|---|
| public Background(final List<BackgroundFill> fills, final List<BackgroundImage> images) Create a new Background supply two Lists, one for background fills and
one for background images. Either list may be null, and may contain nulls.
Any null values in these lists will be ignored and will not
contribute to the
| |
| Background | back to summary |
|---|---|
| public Background(final BackgroundFill[] fills, final BackgroundImage[] images) Create a new Background by supplying two arrays, one for background fills,
and one for background images. Either array may be null, and may contain null
values. Any null values in these arrays will be ignored and will not
contribute to the
| |
| Background | back to summary |
|---|---|
| private Background(List<BackgroundFill> fills, List<BackgroundImage> images, int ignored) Creates a new Background with the specified fills and images. This constructor requires that both lists do not contain null values, and that the lists are immutable. The purpose of this constructor is to prevent an unnecessary array creation when the caller already knows that the specified lists satisfy the non-null precondition and preserve the immutability invariant.
| |
| computeOpaqueInsets | back to summary |
|---|---|
| pack-priv void computeOpaqueInsets(double width, double height, double[] trbl) Computes the opaque insets for a region with the specified width and height. This call must be made whenever the width or height of the region change, because the opaque insets are based on background fills, and the corner radii of a background fill can be percentage based. Thus, we need to potentially recompute the opaque insets whenever the width or height of the region change. On the other hand, if there are no percentage based corner radii, then we can simply return the pre-computed and cached answers.
| |
| computeOpaqueInsets | back to summary |
|---|---|
| private void computeOpaqueInsets(double width, double height, boolean firstTime, double[] trbl) Computes the opaque insets. The first time this is called from the constructor we want to take the long route through and compute everything, whether there are percentage based insets or not (the constructor ensures not to call it in the case that it has percentage based insets!). All other times, this is called by the other computeOpaqueInsets method with "firstTime" set to false, such that if we have percentage based insets, then we will bail early. This method takes into account both fills and images. Because images can be lazy loaded, we cannot pre-compute a bunch of things in the constructor for images the way we can with fills. Instead, each time the method is called, we have to inspect the images. However, we do have fast paths for cases where fills are used and not images.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| fill | back to summary |
|---|---|
| public static Background fill(Paint fill) A convenience factory method for creating a Implementation Specification This call is equivalent to
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Gets the
| |
| getFills | back to summary |
|---|---|
| public final List The list of BackgroundFills which together define the filled portion of this Background. This List is unmodifiable and immutable. It will never be null. The elements of this list will also never be null.
| |
| getImages | back to summary |
|---|---|
| public final List The list of BackgroundImages which together define the image portion of this Background. This List is unmodifiable and immutable. It will never be null. The elements of this list will also never be null.
| |
| getOutsets | back to summary |
|---|---|
| public final Insets getOutsets() The outsets of this Background. This represents the largest bounding rectangle within which all drawing for the Background will take place. The outsets will never be negative, and represent the distance from the edge of the Region outward. Any BackgroundImages which would extend beyond the outsets will be clipped. Only the BackgroundFills contribute to the outsets.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| interpolate | back to summary |
|---|---|
| public Background interpolate(Background endValue, double t) Implements javafx. Doc from javafx. Returns an intermediate value between the value of this The returned value might not be a new instance; the implementation might also return one of the two existing instances if the intermediate value would be equal to one of the existing values. However, this is an optimization and applications should not assume any particular identity of the returned value.
| |
| isEmpty | back to summary |
|---|---|
| public final boolean isEmpty() Gets whether the background is empty. It is empty if there are no fills or images.
| |
| isFillPercentageBased | back to summary |
|---|---|
| public boolean isFillPercentageBased() Gets whether the fill of this Background is based on percentages (that is, relative to the size of the region being styled). Specifically, this returns true if any of the CornerRadii on any of the fills on this Background has a radius that is based on percentages.
| |