Top Description Fields Constructors Methods
javafx.scene.layout

public final Class BorderWidths

extends Object
implements Interpolatable<BorderWidths>
Class Inheritance
All Implemented Interfaces
javafx.animation.Interpolatable
Imports
com.sun.javafx.util.InterpolationUtils, javafx.animation.Interpolatable, javafx.beans.NamedArg, java.util.Objects

Defines widths for four components (top, right, bottom, and left). Each width is defined as a non-negative value. This value might be interpreted either as an literal value, or as a percentage of the width or height of the Region, depending on the values for topAsPercentage, rightAsPercentage, bottomAsPercentage, leftAsPercentage. The only allowable negative value for top, right, bottom, and left is AUTO.

Because the BorderWidths is immutable, it can safely be used in any cache, and can safely be reused among multiple Regions.

Since
JavaFX 8.0

Field Summary

Modifier and TypeField and Description
public static final double
AUTO

When used by a BorderStroke, the value of AUTO is interpreted as the value of BorderStroke#MEDIUM for the corresponding side.

private final double
private final boolean
public static final BorderWidths
DEFAULT

The default BorderWidths that is used by a BorderImage when null is specified.

public static final BorderWidths
EMPTY

An empty set of widths, such that all values are 0 and are literal values.

public static final BorderWidths
FULL

A set of widths representing 100% on each side.

private final int
hash

A cached hash code for faster secondary usage.

private final double
private final boolean
private final double
private final boolean
private final double
private final boolean

Constructor Summary

AccessConstructor and Description
public
BorderWidths(double
The border width. This cannot be negative.
width
)

Creates a new BorderWidths using the given width for all four borders, and treating this width as a literal value, and not a percentage.

public
BorderWidths(double
The thickness of the border on the top. Must be non-negative.
top
,
double
The thickness of the border on the right. Must be non-negative.
right
,
double
The thickness of the border on the bottom. Must be non-negative.
bottom
,
double
The thickness of the border on the left. Must be non-negative.
left
)

Creates a new BorderWidths with the specified widths for top, right, bottom, and left.

public
BorderWidths(double
The thickness of the border on the top. Must be non-negative.
top
,
double
The thickness of the border on the right. Must be non-negative.
right
,
double
The thickness of the border on the bottom. Must be non-negative.
bottom
,
double
The thickness of the border on the left. Must be non-negative.
left
,
boolean
Whether the top should be treated as a percentage.
topAsPercentage
,
boolean
Whether the right should be treated as a percentage.
rightAsPercentage
,
boolean
Whether the bottom should be treated as a percentage.
bottomAsPercentage
,
boolean
Whether the left should be treated as a percentage.
leftAsPercentage
)

Creates a new BorderWidths.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public final double

Returns:

the border thickness on the bottom of the border
getBottom
()

The non-negative value (with the exception of AUTO) indicating the border thickness on the bottom of the border.

public final double

Returns:

the border thickness on the left of the border
getLeft
()

The non-negative value (with the exception of AUTO) indicating the border thickness on the left of the border.

public final double

Returns:

the border thickness on the right of the border
getRight
()

The non-negative value (with the exception of AUTO) indicating the border thickness on the right of the border.

public final double

Returns:

the border thickness on the top of the border
getTop
()

A non-negative value (with the exception of AUTO) indicating the border thickness on the top of the border.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public BorderWidths
interpolate(BorderWidths
the target value
endValue
,
double
the interpolation factor
t
)

Implements javafx.animation.Interpolatable.interpolate.

Returns an intermediate value between the value of this Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive).

private static double
interpolate(double start, double end, double t)

public final boolean

Returns:

true if bottom should be interpreted as a percentage of the region height, otherwise false
isBottomAsPercentage
()

Specifies whether the bottom property should be interpreted as a percentage (true) of the region height or not (false).

public final boolean

Returns:

true if left should be interpreted as a percentage of the region width, otherwise false
isLeftAsPercentage
()

Specifies whether the left property should be interpreted as a percentage (true) of the region width or not (false).

public final boolean

Returns:

true if right should be interpreted as a percentage of the region width, otherwise false
isRightAsPercentage
()

Specifies whether the right property should be interpreted as a percentage (true) of the region width or not (false).

private boolean
isSame(double top, double right, double bottom, double left, boolean topAsPercentage, boolean rightAsPercentage, boolean bottomAsPercentage, boolean leftAsPercentage)

public final boolean

Returns:

true if top should be interpreted as a percentage of the region height, otherwise false
isTopAsPercentage
()

Specifies whether the top property should be interpreted as a percentage (true) of the region height or not (false).

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

AUTOback to summary
public static final double AUTO

When used by a BorderStroke, the value of AUTO is interpreted as the value of BorderStroke#MEDIUM for the corresponding side. When used with a BorderImage, the value of AUTO means to read the corresponding value from the BorderStroke(s), and not to specify it manually.

bottomback to summary
private final double bottom
bottomAsPercentageback to summary
private final boolean bottomAsPercentage
DEFAULTback to summary
public static final BorderWidths DEFAULT

The default BorderWidths that is used by a BorderImage when null is specified. This width is a single 1 pixel top, right, bottom, and left, all interpreted as literal values.

EMPTYback to summary
public static final BorderWidths EMPTY

An empty set of widths, such that all values are 0 and are literal values.

FULLback to summary
public static final BorderWidths FULL

A set of widths representing 100% on each side.

hashback to summary
private final int hash

A cached hash code for faster secondary usage. It is expected that BorderWidths will be pulled from a cache in many cases.

leftback to summary
private final double left
leftAsPercentageback to summary
private final boolean leftAsPercentage
rightAsPercentageback to summary
private final boolean rightAsPercentage
topback to summary
private final double top
topAsPercentageback to summary
private final boolean topAsPercentage

Constructor Detail

BorderWidthsback to summary
public BorderWidths(double width)

Creates a new BorderWidths using the given width for all four borders, and treating this width as a literal value, and not a percentage.

Parameters
width:double

The border width. This cannot be negative.

BorderWidthsback to summary
public BorderWidths(double top, double right, double bottom, double left)

Creates a new BorderWidths with the specified widths for top, right, bottom, and left. None of these values may be negative. Each of these values is interpreted as a literal value, not as a percentage.

Parameters
top:double

The thickness of the border on the top. Must be non-negative.

right:double

The thickness of the border on the right. Must be non-negative.

bottom:double

The thickness of the border on the bottom. Must be non-negative.

left:double

The thickness of the border on the left. Must be non-negative.

BorderWidthsback to summary
public BorderWidths(double top, double right, double bottom, double left, boolean topAsPercentage, boolean rightAsPercentage, boolean bottomAsPercentage, boolean leftAsPercentage)

Creates a new BorderWidths. None of the values for top, right, bottom, or left can be non-negative.

Parameters
top:double

The thickness of the border on the top. Must be non-negative.

right:double

The thickness of the border on the right. Must be non-negative.

bottom:double

The thickness of the border on the bottom. Must be non-negative.

left:double

The thickness of the border on the left. Must be non-negative.

topAsPercentage:boolean

Whether the top should be treated as a percentage.

rightAsPercentage:boolean

Whether the right should be treated as a percentage.

bottomAsPercentage:boolean

Whether the bottom should be treated as a percentage.

leftAsPercentage:boolean

Whether the left should be treated as a percentage.

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

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.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getBottomback to summary
public final double getBottom()

The non-negative value (with the exception of AUTO) indicating the border thickness on the bottom of the border. This value can be a literal value, or can be treated as a percentage, based on the value of the bottomAsPercentage property.

Returns:double

the border thickness on the bottom of the border

getLeftback to summary
public final double getLeft()

The non-negative value (with the exception of AUTO) indicating the border thickness on the left of the border. This value can be an literal value, or can be treated as a percentage, based on the value of the leftAsPercentage property.

Returns:double

the border thickness on the left of the border

getRightback to summary
public final double getRight()

The non-negative value (with the exception of AUTO) indicating the border thickness on the right of the border. This value can be a literal value, or can be treated as a percentage, based on the value of the rightAsPercentage property.

Returns:double

the border thickness on the right of the border

getTopback to summary
public final double getTop()

A non-negative value (with the exception of AUTO) indicating the border thickness on the top of the border. This value can be a literal value, or can be treated as a percentage, based on the value of the topAsPercentage property.

Returns:double

the border thickness on the top of the border

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
interpolateback to summary
public BorderWidths interpolate(BorderWidths endValue, double t)

Implements javafx.animation.Interpolatable.interpolate.

Doc from javafx.animation.Interpolatable.interpolate.

Returns an intermediate value between the value of this Interpolatable and the specified endValue using the linear interpolation factor t, ranging from 0 (inclusive) to 1 (inclusive).

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.

Parameters
endValue:BorderWidths

the target value

t:double

the interpolation factor

Returns:BorderWidths

the intermediate value

Annotations
@Override
Exceptions
NullPointerException:
if endValue is null
Since
24
interpolateback to summary
private static double interpolate(double start, double end, double t)
isBottomAsPercentageback to summary
public final boolean isBottomAsPercentage()

Specifies whether the bottom property should be interpreted as a percentage (true) of the region height or not (false).

Returns:boolean

true if bottom should be interpreted as a percentage of the region height, otherwise false

isLeftAsPercentageback to summary
public final boolean isLeftAsPercentage()

Specifies whether the left property should be interpreted as a percentage (true) of the region width or not (false).

Returns:boolean

true if left should be interpreted as a percentage of the region width, otherwise false

isRightAsPercentageback to summary
public final boolean isRightAsPercentage()

Specifies whether the right property should be interpreted as a percentage (true) of the region width or not (false).

Returns:boolean

true if right should be interpreted as a percentage of the region width, otherwise false

isSameback to summary
private boolean isSame(double top, double right, double bottom, double left, boolean topAsPercentage, boolean rightAsPercentage, boolean bottomAsPercentage, boolean leftAsPercentage)
isTopAsPercentageback to summary
public final boolean isTopAsPercentage()

Specifies whether the top property should be interpreted as a percentage (true) of the region height or not (false).

Returns:boolean

true if top should be interpreted as a percentage of the region height, otherwise false