- java.lang.Object
-
- javafx.scene.layout.BorderStroke
-
public class BorderStroke extends Object
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
topis used, while the other attributes are ignored.- Since:
- JavaFX 8.0
-
-
Field Summary
Fields Modifier and Type Field Description static BorderWidthsDEFAULT_WIDTHSThe default Insets to be used with a BorderStroke that does not otherwise define any.static BorderWidthsMEDIUMThe default insets when "medium" is specifiedstatic BorderWidthsTHICKThe default insets when "thick" is specifiedstatic BorderWidthsTHINThe default insets when "thin" is specified.
-
Constructor Summary
Constructors Constructor Description BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths)Creates a new BorderStroke.BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths, Insets insets)Creates a new BorderStroke.BorderStroke(Paint topStroke, Paint rightStroke, Paint bottomStroke, Paint leftStroke, BorderStrokeStyle topStyle, BorderStrokeStyle rightStyle, BorderStrokeStyle bottomStyle, BorderStrokeStyle leftStyle, CornerRadii radii, BorderWidths widths, Insets insets)Create a new BorderStroke, specifying all construction parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Indicates whether some other object is "equal to" this one.PaintgetBottomStroke()Defines the fill of bottom side of this border.BorderStrokeStylegetBottomStyle()Defines the style of bottom side of this border.InsetsgetInsets()Defines the insets of each side of the BorderStroke.PaintgetLeftStroke()Defines the fill of left side of this border.BorderStrokeStylegetLeftStyle()Defines the style of left side of this border.CornerRadiigetRadii()Defines the radii for each corner of this BorderStroke.PaintgetRightStroke()Defines the fill of right side of this border.BorderStrokeStylegetRightStyle()Defines the style of right side of this border.PaintgetTopStroke()Defines the fill of top side of this border.BorderStrokeStylegetTopStyle()Defines the style of top side of this border.BorderWidthsgetWidths()Defines the thickness of each side of the BorderStroke.inthashCode()Returns a hash code value for the object.booleanisStrokeUniform()An uniform stroke has all (top, bottom, left, right) strokes of same color, width and style
-
-
-
Field Detail
-
THIN
public static final BorderWidths THIN
The default insets when "thin" is specified.
-
MEDIUM
public static final BorderWidths MEDIUM
The default insets when "medium" is specified
-
THICK
public static final BorderWidths THICK
The default insets when "thick" is specified
-
DEFAULT_WIDTHS
public static final BorderWidths DEFAULT_WIDTHS
The default Insets to be used with a BorderStroke that does not otherwise define any.
-
-
Constructor Detail
-
BorderStroke
public BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths)
Creates a new BorderStroke.- Parameters:
stroke- The stroke to use for all sides. If null, we default to Color.BLACK.style- The style to use for all sides. If null, we default to BorderStrokeStyle.NONEradii- The radii to use. If null, we default to CornerRadii.EMPTYwidths- The widths to use. If null, we default to DEFAULT_WIDTHS
-
BorderStroke
public BorderStroke(Paint stroke, BorderStrokeStyle style, CornerRadii radii, BorderWidths widths, Insets insets)
Creates a new BorderStroke.- Parameters:
stroke- The stroke to use for all sides. If null, we default to Color.BLACK.style- The style to use for all sides. If null, we default to BorderStrokeStyle.NONEradii- The radii to use. If null, we default to CornerRadii.EMPTYwidths- The widths to use. If null, we default to DEFAULT_WIDTHSinsets- The insets indicating where to draw the border relative to the region edges.
-
BorderStroke
public BorderStroke(Paint topStroke, Paint rightStroke, Paint bottomStroke, Paint leftStroke, BorderStrokeStyle topStyle, BorderStrokeStyle rightStyle, BorderStrokeStyle bottomStyle, BorderStrokeStyle leftStyle, CornerRadii radii, BorderWidths widths, Insets insets)
Create a new BorderStroke, specifying all construction parameters.- Parameters:
topStroke- The fill to use on the top. If null, defaults to BLACK.rightStroke- The fill to use on the right. If null, defaults to the same value as topStrokebottomStroke- The fill to use on the bottom. If null, defaults to the same value as bottomStrokeleftStroke- The fill to use on the left. If null, defaults to the same value as rightStroketopStyle- The style to use on the top. If null, defaults to BorderStrokeStyle.NONErightStyle- The style to use on the right. If null, defaults to the same value as topStylebottomStyle- The style to use on the bottom. If null, defaults to the same value as topStyleleftStyle- The style to use on the left. If null, defaults to the same value as rightStyleradii- The radii. If null, we default to square corners by using CornerRadii.EMPTYwidths- The thickness of each side. If null, we default to DEFAULT_WIDTHS.insets- The insets indicating where to draw the border relative to the region edges.
-
-
Method Detail
-
getTopStroke
public final Paint getTopStroke()
Defines the fill of top side of this border.- Default value:
- black
- Returns:
- the fill of top side of this border
-
getRightStroke
public final Paint getRightStroke()
Defines the fill of right side of this border. Ifnullthen the topFill is used.- Default value:
- null = same as topFill
- Returns:
- the fill of right side of this border
-
getBottomStroke
public final Paint getBottomStroke()
Defines the fill of bottom side of this border. Ifnullthen the topFill is used.- Default value:
- null = same as topFill
- Returns:
- the fill of bottom side of this border
-
getLeftStroke
public final Paint getLeftStroke()
Defines the fill of left side of this border. Ifnullthen the rightFill is used.- Default value:
- null = same sa rightFill
- Returns:
- the fill of left side of this border
-
getTopStyle
public final BorderStrokeStyle getTopStyle()
Defines the style of top side of this border.- Default value:
- none
- Returns:
- the style of top side of this border
-
getRightStyle
public final BorderStrokeStyle getRightStyle()
Defines the style of right side of this border. Ifnullthen topStyle is used;- Default value:
- null = same as topStyle
- Returns:
- the style of right side of this border
-
getBottomStyle
public final BorderStrokeStyle getBottomStyle()
Defines the style of bottom side of this border. Ifnullthen topStyle is used; Use BorderStyle.NONE to set the border to have no border style.- Default value:
- null = same as topStyle
- Returns:
- the style of bottom side of this border
-
getLeftStyle
public final BorderStrokeStyle getLeftStyle()
Defines the style of left side of this border. Ifnullthen rightStyle is used. Use BorderStyle.NONE to set the border to have no border style.- Default value:
- null = same as rightStyle
- Returns:
- the style of left side of this border
-
getWidths
public final BorderWidths getWidths()
Defines the thickness of each side of the BorderStroke. This will never be null, and defaults to DEFAULT_WIDTHS.- Returns:
- the thickness of each side of the BorderStroke
-
getInsets
public final Insets getInsets()
Defines the insets of each side of the BorderStroke. This will never be null, and defaults to EMPTY.- Returns:
- the insets of each side of the BorderStroke
-
getRadii
public final CornerRadii getRadii()
Defines the radii for each corner of this BorderStroke. This will never be null, and defaults to CornerRadii.EMPTY.- Returns:
- the radii for each corner of this BorderStroke
-
isStrokeUniform
public final boolean isStrokeUniform()
An uniform stroke has all (top, bottom, left, right) strokes of same color, width and style- Returns:
- true if border stroke is uniform as defined above
-
equals
public boolean equals(Object o)
Indicates whether some other object is "equal to" this one.The
equalsmethod implements an equivalence relation on non-null object references:- It is reflexive: for any non-null reference value
x,x.equals(x)should returntrue. - It is symmetric: for any non-null reference values
xandy,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any non-null reference values
x,y, andz, ifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue. - It is consistent: for any non-null reference values
xandy, multiple invocations ofx.equals(y)consistently returntrueor consistently returnfalse, provided no information used inequalscomparisons on the objects is modified. - For any non-null reference value
x,x.equals(null)should returnfalse.
The
equalsmethod for classObjectimplements the most discriminating possible equivalence relation on objects; that is, for any non-null reference valuesxandy, this method returnstrueif and only ifxandyrefer to the same object (x == yhas the valuetrue).Note that it is generally necessary to override the
hashCodemethod whenever this method is overridden, so as to maintain the general contract for thehashCodemethod, which states that equal objects must have equal hash codes.- Overrides:
equalsin classObject- Parameters:
o- the reference object with which to compare.- Returns:
trueif this object is the same as the obj argument;falseotherwise.- See Also:
Object.hashCode(),HashMap
- It is reflexive: for any non-null reference value
-
hashCode
public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided byHashMap.The general contract of
hashCodeis:- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCodemethod must consistently return the same integer, provided no information used inequalscomparisons 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(Object)method, then calling thehashCodemethod 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
Object.equals(java.lang.Object)method, then calling thehashCodemethod 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.
As much as is reasonably practical, the hashCode method defined by class
Objectdoes return distinct integers for distinct objects. (The hashCode may or may not be implemented as some function of an object's memory address at some point in time.)- Overrides:
hashCodein classObject- Returns:
- a hash code value for this object.
- See Also:
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
-
-