Top Description Fields Constructors Methods
javafx.scene.layout

public final Class BorderStroke

extends Object
implements Interpolatable<BorderStroke>
Class Inheritance
All Implemented Interfaces
javafx.animation.Interpolatable
Imports
com.sun.javafx.util.InterpolationUtils, javafx.animation.Interpolatable, javafx.beans.NamedArg, javafx.geometry.Insets, javafx.scene.paint.Color, .Paint, javafx.scene.shape.StrokeType, java.util.Objects

Defines the stroke to use on a Border for styling a Region. The stroke is a vector-based rendering that outlines the border area. It can be inset (or outset) from the Region's edge, and the values of the stroke are taken into account when computing the Region's insets (for defining the content area). The stroke visuals are not used when any BorderImages are in use.

When applied to a Region with a defined shape, the border width and stroking information for the top is used, while the other attributes are ignored.

Since
JavaFX 8.0

Field Summary

Modifier and TypeField and Description
private final Paint
private final BorderStrokeStyle
public static final BorderWidths
DEFAULT_WIDTHS

The default Insets to be used with a BorderStroke that does not otherwise define any.

private final int
hash

A cached hash code

pack-priv final Insets
private final Insets
private final Paint
private final BorderStrokeStyle
public static final BorderWidths
MEDIUM

The default insets when "medium" is specified

pack-priv final Insets
private final CornerRadii
private final Paint
private final BorderStrokeStyle
private final boolean
public static final BorderWidths
THICK

The default insets when "thick" is specified

public static final BorderWidths
THIN

The default insets when "thin" is specified.

private final Paint
private final BorderStrokeStyle
private final BorderWidths

Constructor Summary

AccessConstructor and Description
public
BorderStroke(Paint
The stroke to use for all sides. If null, defaults to Color.BLACK.
stroke
,
BorderStrokeStyle
The style to use for all sides. If null, defaults to BorderStrokeStyle.NONE.
style
,
CornerRadii
The radii to use. If null, defaults to CornerRadii.EMPTY.
radii
,
BorderWidths
The widths to use. If null, defaults to DEFAULT_WIDTHS.
widths
)

Creates a new BorderStroke.

public
BorderStroke(Paint
The stroke to use for all sides. If null, defaults to Color.BLACK.
stroke
,
BorderStrokeStyle
The style to use for all sides. If null, defaults to BorderStrokeStyle.NONE.
style
,
CornerRadii
The radii to use. If null, defaults to CornerRadii.EMPTY.
radii
,
BorderWidths
The widths to use. If null, defaults to DEFAULT_WIDTHS.
widths
,
Insets
The insets indicating where to draw the border relative to the region edges. If null, defaults to Insets.EMPTY.
insets
)

Creates a new BorderStroke.

public
BorderStroke(Paint
The fill to use on the top. If null, defaults to Color.BLACK.
topStroke
,
Paint
The fill to use on the right. If null, defaults to the same value as topStroke.
rightStroke
,
Paint
The fill to use on the bottom. If null, defaults to the same value as topStroke.
bottomStroke
,
Paint
The fill to use on the left. If null, defaults to the same value as rightStroke.
leftStroke
,
BorderStrokeStyle
The style to use on the top. If null, defaults to BorderStrokeStyle.NONE.
topStyle
,
BorderStrokeStyle
The style to use on the right. If null, defaults to the same value as topStyle.
rightStyle
,
BorderStrokeStyle
The style to use on the bottom. If null, defaults to the same value as topStyle.
bottomStyle
,
BorderStrokeStyle
The style to use on the left. If null, defaults to the same value as rightStyle.
leftStyle
,
CornerRadii
The radii. If null, defaults to square corners by using CornerRadii.EMPTY.
radii
,
BorderWidths
The thickness of each side. If null, defaults to DEFAULT_WIDTHS.
widths
,
Insets
The insets indicating where to draw the border relative to the region edges. If null, defaults to Insets.EMPTY.
insets
)

Creates a new BorderStroke, specifying all construction parameters.

Method Summary

Modifier and TypeMethod and Description
private double
computeInside(StrokeType type, double width)

private double
computeOutside(StrokeType type, double width)

public boolean
equals(Object o)

Overrides java.lang.Object.equals.

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

public final Paint

Returns:

the fill of bottom side of this border
getBottomStroke
()

Defines the fill of bottom side of this border.

public final BorderStrokeStyle

Returns:

the style of bottom side of this border
getBottomStyle
()

Defines the style of bottom side of this border.

public final Insets

Returns:

the insets of each side of the BorderStroke
getInsets
()

Defines the insets of each side of the BorderStroke.

public final Paint

Returns:

the fill of left side of this border
getLeftStroke
()

Defines the fill of left side of this border.

public final BorderStrokeStyle

Returns:

the style of left side of this border
getLeftStyle
()

Defines the style of left side of this border.

public final CornerRadii

Returns:

the radii for each corner of this BorderStroke
getRadii
()

Defines the radii for each corner of this BorderStroke.

public final Paint

Returns:

the fill of right side of this border
getRightStroke
()

Defines the fill of right side of this border.

public final BorderStrokeStyle

Returns:

the style of right side of this border
getRightStyle
()

Defines the style of right side of this border.

public final Paint

Returns:

the fill of top side of this border
getTopStroke
()

Defines the fill of top side of this border.

public final BorderStrokeStyle

Returns:

the style of top side of this border
getTopStyle
()

Defines the style of top side of this border.

public final BorderWidths

Returns:

the thickness of each side of the BorderStroke
getWidths
()

Defines the thickness of each side of the BorderStroke.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public BorderStroke
interpolate(BorderStroke endValue, double 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 boolean
isSame(Paint topStroke, Paint rightStroke, Paint bottomStroke, Paint leftStroke, BorderStrokeStyle topStyle, BorderStrokeStyle rightStyle, BorderStrokeStyle bottomStyle, BorderStrokeStyle leftStyle, CornerRadii radii, BorderWidths widths, Insets insets)

public final boolean

Returns:

true if border stroke is uniform
isStrokeUniform
()

Checks if the stroke of this region is uniform.

private int
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

bottomStrokeback to summary
private final Paint bottomStroke
bottomStyleback to summary
private final BorderStrokeStyle bottomStyle
DEFAULT_WIDTHSback to summary
public static final BorderWidths DEFAULT_WIDTHS

The default Insets to be used with a BorderStroke that does not otherwise define any.

hashback to summary
private final int hash

A cached hash code

innerEdgeback to summary
pack-priv final Insets innerEdge
insetsback to summary
private final Insets insets
leftStrokeback to summary
private final Paint leftStroke
leftStyleback to summary
private final BorderStrokeStyle leftStyle
MEDIUMback to summary
public static final BorderWidths MEDIUM

The default insets when "medium" is specified

outerEdgeback to summary
pack-priv final Insets outerEdge
radiiback to summary
private final CornerRadii radii
rightStrokeback to summary
private final Paint rightStroke
rightStyleback to summary
private final BorderStrokeStyle rightStyle
strokeUniformback to summary
private final boolean strokeUniform
THICKback to summary
public static final BorderWidths THICK

The default insets when "thick" is specified

THINback to summary
public static final BorderWidths THIN

The default insets when "thin" is specified.

topStrokeback to summary
private final Paint topStroke
topStyleback to summary
private final BorderStrokeStyle topStyle
widthsback to summary
private final BorderWidths widths

Constructor Detail

BorderStrokeback to summary
public BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths)

Creates a new BorderStroke.

Parameters
stroke:Paint

The stroke to use for all sides. If null, defaults to Color.BLACK.

style:BorderStrokeStyle

The style to use for all sides. If null, defaults to BorderStrokeStyle.NONE.

radii:CornerRadii

The radii to use. If null, defaults to CornerRadii.EMPTY.

widths:BorderWidths

The widths to use. If null, defaults to DEFAULT_WIDTHS.

BorderStrokeback to summary
public BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths, Insets insets)

Creates a new BorderStroke.

Parameters
stroke:Paint

The stroke to use for all sides. If null, defaults to Color.BLACK.

style:BorderStrokeStyle

The style to use for all sides. If null, defaults to BorderStrokeStyle.NONE.

radii:CornerRadii

The radii to use. If null, defaults to CornerRadii.EMPTY.

widths:BorderWidths

The widths to use. If null, defaults to DEFAULT_WIDTHS.

insets:Insets

The insets indicating where to draw the border relative to the region edges. If null, defaults to Insets.EMPTY.

BorderStrokeback to summary
public BorderStroke(Paint topStroke, Paint rightStroke, Paint bottomStroke, Paint leftStroke, BorderStrokeStyle topStyle, BorderStrokeStyle rightStyle, BorderStrokeStyle bottomStyle, BorderStrokeStyle leftStyle, CornerRadii radii, BorderWidths widths, Insets insets)

Creates a new BorderStroke, specifying all construction parameters.

Parameters
topStroke:Paint

The fill to use on the top. If null, defaults to Color.BLACK.

rightStroke:Paint

The fill to use on the right. If null, defaults to the same value as topStroke.

bottomStroke:Paint

The fill to use on the bottom. If null, defaults to the same value as topStroke.

leftStroke:Paint

The fill to use on the left. If null, defaults to the same value as rightStroke.

topStyle:BorderStrokeStyle

The style to use on the top. If null, defaults to BorderStrokeStyle.NONE.

rightStyle:BorderStrokeStyle

The style to use on the right. If null, defaults to the same value as topStyle.

bottomStyle:BorderStrokeStyle

The style to use on the bottom. If null, defaults to the same value as topStyle.

leftStyle:BorderStrokeStyle

The style to use on the left. If null, defaults to the same value as rightStyle.

radii:CornerRadii

The radii. If null, defaults to square corners by using CornerRadii.EMPTY.

widths:BorderWidths

The thickness of each side. If null, defaults to DEFAULT_WIDTHS.

insets:Insets

The insets indicating where to draw the border relative to the region edges. If null, defaults to Insets.EMPTY.

Method Detail

computeInsideback to summary
private double computeInside(StrokeType type, double width)
computeOutsideback to summary
private double computeOutside(StrokeType type, double width)
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.

Annotations
@Override
getBottomStrokeback to summary
public final Paint getBottomStroke()

Defines the fill of bottom side of this border. If null, then the topFill is used.

Returns:Paint

the fill of bottom side of this border

Default Value
null (same as topFill)
getBottomStyleback to summary
public final BorderStrokeStyle getBottomStyle()

Defines the style of bottom side of this border. If null, then topStyle is used; Use BorderStyle.NONE to set the border to have no border style.

Returns:BorderStrokeStyle

the style of bottom side of this border

Default Value
null (same as topStyle)
getInsetsback to summary
public final Insets getInsets()

Defines the insets of each side of the BorderStroke. This will never be null, and defaults to Insets.EMPTY.

Returns:Insets

the insets of each side of the BorderStroke

getLeftStrokeback to summary
public final Paint getLeftStroke()

Defines the fill of left side of this border. If null, then the rightFill is used.

Returns:Paint

the fill of left side of this border

Default Value
null (same as rightFill)
getLeftStyleback to summary
public final BorderStrokeStyle getLeftStyle()

Defines the style of left side of this border. If null, then rightStyle is used. Use BorderStyle.NONE to set the border to have no border style.

Returns:BorderStrokeStyle

the style of left side of this border

Default Value
null (same as rightStyle)
getRadiiback to summary
public final CornerRadii getRadii()

Defines the radii for each corner of this BorderStroke. This will never be null, and defaults to CornerRadii.EMPTY.

Returns:CornerRadii

the radii for each corner of this BorderStroke

getRightStrokeback to summary
public final Paint getRightStroke()

Defines the fill of right side of this border. If null, then the topFill is used.

Returns:Paint

the fill of right side of this border

Default Value
null (same as topFill)
getRightStyleback to summary
public final BorderStrokeStyle getRightStyle()

Defines the style of right side of this border. If null, then topStyle is used;

Returns:BorderStrokeStyle

the style of right side of this border

Default Value
null (same as topStyle)
getTopStrokeback to summary
public final Paint getTopStroke()

Defines the fill of top side of this border.

Returns:Paint

the fill of top side of this border

Default Value
Color.BLACK
getTopStyleback to summary
public final BorderStrokeStyle getTopStyle()

Defines the style of top side of this border.

Returns:BorderStrokeStyle

the style of top side of this border

Default Value
BorderStrokeStyle.NONE
getWidthsback to summary
public final BorderWidths getWidths()

Defines the thickness of each side of the BorderStroke. This will never be null, and defaults to DEFAULT_WIDTHS.

Returns:BorderWidths

the thickness of each side of the BorderStroke

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.
Annotations
@Override
interpolateback to summary
public BorderStroke interpolate(BorderStroke 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.

Annotations
@Override
Exceptions
NullPointerException:
if endValue is null
Since
24
isSameback to summary
private boolean isSame(Paint topStroke, Paint rightStroke, Paint bottomStroke, Paint leftStroke, BorderStrokeStyle topStyle, BorderStrokeStyle rightStyle, BorderStrokeStyle bottomStyle, BorderStrokeStyle leftStyle, CornerRadii radii, BorderWidths widths, Insets insets)
isStrokeUniformback to summary
public final boolean isStrokeUniform()

Checks if the stroke of this region is uniform. A uniform stroke has all its side strokes (top, bottom, left, right) of same color, width and style.

Returns:boolean

true if border stroke is uniform

preComputeHashback to summary
private int preComputeHash()