width, height, contain, and cover. Both width
and height are independent of each other, however both interact with
contain and cover.
From the CSS Specification, cover is defined to:
Scale the image, while preserving its intrinsic aspect ratio (if any), to the smallest size such that both its width and its height can completely cover the background positioning area.
contain is defined to:
Scale the image, while preserving its intrinsic aspect ratio (if any), to the largest size such that both its width and its height can fit inside the background positioning area.And width and height both specify (in absolute values or percentages) the size to use. These two properties only apply if both cover and contain are false. If both cover and contain are true, then
cover will be used.
The width and height may also be set to AUTO, indicating that the area should be sized
so as to use the image's intrinsic size, or if it cannot be determined, 100%.
| Modifier and Type | Field and Description |
|---|---|
| public static final double | AUTO
From the CSS Specification: An "auto" value for one dimension is resolved by using the image's intrinsic ratio and the size of the other dimension, or failing that, using the image's intrinsic size, or failing that, treating it as 100%. |
| pack-priv final boolean | |
| pack-priv final boolean | |
| public static final BackgroundSize | DEFAULT
The default BackgroundSize used by BackgroundImages when an explicit size is not defined. |
| private final int | hash
A cached hash code value |
| pack-priv final double | |
| pack-priv final boolean | |
| pack-priv final double | |
| pack-priv final boolean |
| Access | Constructor and Description |
|---|---|
| public | BackgroundSize(double
The width. Cannot be less than 0, except for the value of AUTO. width, double The height. Cannot be less than 0, except for the value of AUTO. height, boolean Whether the width is to be interpreted as a percentage widthAsPercentage, boolean Whether the height is to be interpreted as a percentage heightAsPercentage, boolean Whether the image should be sized to fit within the Region maximally contain, boolean Whether the image should be sized to "cover" the Region cover)Create a new BackgroundSize. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. o)Overrides java. Indicates whether some other object is "equal to" this one. |
| public final double | Returns: the height of the area within the Region where the associated BackgroundImage should renderThe height of the area within the Region where the associated BackgroundImage should render. |
| public final double | Returns: the width of the area within the Region where the associated BackgroundImage should renderThe width of the area within the Region where the associated BackgroundImage should render. |
| public int | |
| public final boolean | Returns: true if the image can fit inside the background positioning areaIf true, scale the image, while preserving its intrinsic aspect ratio (if any), to the largest size such that both its width and its height can fit inside the background positioning area. |
| public final boolean | Returns: true if image can completely cover the background positioning areaIf true, scale the image, while preserving its intrinsic aspect ratio (if any), to the smallest size such that both its width and its height can completely cover the background positioning area. |
| public final boolean | Returns: true if height should be interpreted as a percentageSpecifies whether the value contained in |
| public final boolean | Returns: true if width should be interpreted as a percentageSpecifies whether the value contained in |
| AUTO | back to summary |
|---|---|
| public static final double AUTO From the CSS Specification: An "auto" value for one dimension is resolved by using the image's intrinsic ratio and the size of the other dimension, or failing that, using the image's intrinsic size, or failing that, treating it as 100%.When set to AUTO, the values for widthAsPercentage and heightAsPercentage are ignored. | |
| contain | back to summary |
|---|---|
| pack-priv final boolean contain | |
| cover | back to summary |
|---|---|
| pack-priv final boolean cover | |
| DEFAULT | back to summary |
|---|---|
| public static final BackgroundSize DEFAULT The default BackgroundSize used by BackgroundImages when an explicit size is not defined. By default, the BackgroundSize is AUTO, AUTO for the width and height, and is neither cover nor contain. | |
| hash | back to summary |
|---|---|
| private final int hash A cached hash code value | |
| height | back to summary |
|---|---|
| pack-priv final double height | |
| heightAsPercentage | back to summary |
|---|---|
| pack-priv final boolean heightAsPercentage | |
| width | back to summary |
|---|---|
| pack-priv final double width | |
| widthAsPercentage | back to summary |
|---|---|
| pack-priv final boolean widthAsPercentage | |
| BackgroundSize | back to summary |
|---|---|
| public BackgroundSize(double width, double height, boolean widthAsPercentage, boolean heightAsPercentage, boolean contain, boolean cover) Create a new BackgroundSize.
| |
| 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. | |
| getHeight | back to summary |
|---|---|
| public final double getHeight() The height of the area within the Region where the associated BackgroundImage should
render. If set to AUTO, then
| |
| getWidth | back to summary |
|---|---|
| public final double getWidth() The width of the area within the Region where the associated BackgroundImage should
render. If set to AUTO, then
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isContain | back to summary |
|---|---|
| public final boolean isContain() If true, scale the image, while preserving its intrinsic aspect ratio (if any), to the largest size such that both its width and its height can fit inside the background positioning area.
| |
| isCover | back to summary |
|---|---|
| public final boolean isCover() If true, scale the image, while preserving its intrinsic aspect ratio (if any), to the smallest size such that both its width and its height can completely cover the background positioning area.
| |
| isHeightAsPercentage | back to summary |
|---|---|
| public final boolean isHeightAsPercentage() Specifies whether the value contained in
| |
| isWidthAsPercentage | back to summary |
|---|---|
| public final boolean isWidthAsPercentage() Specifies whether the value contained in
| |