public class CSSBorder
A border that can be configured using a limited subset of CSS directives. This class is designed as a stop-gap to deal with common CSS style patterns that aren’t well-covered by existing borders. As time goes on this class will be enhanced to support more CSS styles. At present, it is used by the CSS compiler for compound borders. E.g. If one side has a different border style, color, or thickness than other sides.
The follow types of borders are well-supported with this class:
border-radius - can support different x and y radii for each corner.
border-width - can support different widths for each side.
border-color - can support different colors for each side
background-color
This class also supports background images and gradients, but these are not well-tested and are not currently used by the CSS compiler.
Fields
Constructors
public CSSBorder() | Creates a new empty CSS border. |
public CSSBorder(Resources res) | Creates an empty border. |
public CSSBorder(String css) | Creates a new CSS border with the provided CSS styles. |
public CSSBorder(Resources res, String css) | Creates a new CSS border with the provided CSS styles. |
Methods
public boolean equals(Object obj) | {Indicates whether some other object is “equal to” this one. |
public int hashCode() | Returns a hash code value for the object. |
public String toCSSString() | Converts this border to a CSS string. |
public boolean isBackgroundPainter() | Returns true if installing this border will override the painting of the component background |
public void paintBorderBackground(Graphics g, Component c) | Has effect when the border demands responsibility for background painting normally the painter will perform this work but in this case the border might do it instead. |
public int getMinimumHeight() | Returns the minimum size required to properly display this border, normally this is 0 but a border might deem itself undisplayable with too small a size e.g. for the case of an image border the minimum height would be top + bottom and the m… |
public int getMinimumWidth() | Returns the minimum size required to properly display this border, normally this is 0 but a border might deem itself undisplayable with too small a size e.g. for the case of an image border the minimum height would be top + bottom and the m… |
public CSSBorder borderImage(Image borderImage, double... slicePoints) | Creates a 9-piece image border. |
public CSSBorder borderImageWithName(String borderImageName, double... slicePoints) | Adds a 9-piece image border using the provided image name, which should exist in the theme resource file. |
public CSSBorder boxShadow(String value) | |
public CSSBorder borderRadius(String radius) | Sets the border radius for rounded corners. |
public CSSBorder borderStroke(String... strokeStrs) | Sets the border stroke. |
public CSSBorder borderColor(String... colors) | Sets the border colors. |
public CSSBorder borderWidth(String... widths) | Sets the border widths. |
public CSSBorder borderStyle(String... styles) | Sets the border styles. |
public CSSBorder backgroundColor(String color) | Sets the background color of the border. |
public CSSBorder backgroundImage(String cssDirective) | Adds one or more background images from a CSS background-image property. |
public CSSBorder backgroundImage(Image... images) | Sets the background image of the border. |
public CSSBorder backgroundRepeat(String... repeat) | Sets the background-repeat for the background images. |
public CSSBorder backgroundPosition(String... pos) | Sets the background position. |
Inherited methods
From Border
getEmpty, createEmpty, createImageBorder, createImageSplicedBorder, createImageScaledBorder, createHorizonalImageBorder, createVerticalImageBorder, createImageBorder, createLineBorder, createLineBorder, createUndelineBorder, createUnderlineBorder, createUndelineBorder, createUnderlineBorder, createUnderlineBorder, createUnderlineBorder, createDottedBorder, createDashedBorder, createDoubleBorder, createDottedBorder, createDashedBorder, createDoubleBorder, createOutsetBorder, createOutsetBorder, createInsetBorder, createInsetBorder, createGrooveBorder, createGrooveBorder, createRidgeBorder, createRidgeBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createRoundBorder, createRoundBorder, createRoundBorder, createRoundBorder, createEtchedLowered, createEtchedLowered, createEtchedRaised, createEtchedRaised, createCompoundBorder, createBevelLowered, createBevelLowered, createBevelRaised, createBevelRaised, getDefaultBorder, setDefaultBorder, mirrorBorder, setImageBorderSpecialTile, getTrackComponent, setTrackComponent, setTrackComponent, setImageBorderSpecialTile, clearImageBorderSpecialTile, addOuterBorder, isEmptyBorder, isRectangleType, getFocusedInstance, setFocusedInstance, getPressedInstance, setPressedInstance, createPressedVersion, paint, getThickness, setThickness, isPaintOuterBorderFirst, setPaintOuterBorderFirst, getCompoundBorders, lock, unlock, getProperty
Field details
REPEAT_NONE
public static final byte REPEAT_NONE = 0REPEAT_BOTH
public static final byte REPEAT_BOTH = 1REPEAT_X
public static final byte REPEAT_X = 2REPEAT_Y
public static final byte REPEAT_Y = 3VPOSITION_TOP
public static final byte VPOSITION_TOP = 0VPOSITION_BOTTOM
public static final byte VPOSITION_BOTTOM = 1VPOSITION_CENTER
public static final byte VPOSITION_CENTER = 2VPOSITION_OTHER
public static final byte VPOSITION_OTHER = 99HPOSITION_LEFT
public static final byte HPOSITION_LEFT = 0HPOSITION_RIGHT
public static final byte HPOSITION_RIGHT = 1HPOSITION_CENTER
public static final byte HPOSITION_CENTER = 2HPOSITION_OTHER
public static final byte HPOSITION_OTHER = 99SIZE_AUTO
public static final byte SIZE_AUTO = 0SIZE_CONTAIN
public static final byte SIZE_CONTAIN = 1SIZE_COVER
public static final byte SIZE_COVER = 2SIZE_OTHER
public static final byte SIZE_OTHER = 99STYLE_NONE
public static final byte STYLE_NONE = 0STYLE_HIDDEN
public static final byte STYLE_HIDDEN = 1STYLE_DOTTED
public static final byte STYLE_DOTTED = 2STYLE_DASHED
public static final byte STYLE_DASHED = 3STYLE_SOLID
public static final byte STYLE_SOLID = 4UNIT_PIXELS
public static final byte UNIT_PIXELS = 0UNIT_MM
public static final byte UNIT_MM = 2UNIT_PERCENT
public static final byte UNIT_PERCENT = 1UNIT_EM
public static final byte UNIT_EM = 4Constructor details
CSSBorder
public CSSBorder()CSSBorder
public CSSBorder(Resources res)Parameters
resResources- Theme resource file from which images can be referenced.
CSSBorder
public CSSBorder(String css)Creates a new CSS border with the provided CSS styles. This currenlty only supports a subset of CSS. The following properties are currently supported:
background-color
background-image
background-position
background-repeat
border-color
border-radius
border-stroke
border-style
border-width
border-image
Parameters
cssString- CSS to parse.
Throws
IllegalArgumentException- If it fails to parse the style.
CSSBorder
public CSSBorder(Resources res, String css)Creates a new CSS border with the provided CSS styles. This currenlty only supports a subset of CSS. The following properties are currently supported:
background-color
background-image
background-position
background-repeat
border-color
border-radius
border-stroke
border-style
border-width
border-image
Parameters
resResources- Theme resource file from which images can be loaded.
cssString- CSS to parse.
Throws
IllegalArgumentException- If it fails to parse the style.
Method details
equals
public boolean equals(Object obj)hashCode
public int hashCode()toCSSString
public String toCSSString()Returns
isBackgroundPainter
public boolean isBackgroundPainter()Returns
paintBorderBackground
public void paintBorderBackground(Graphics g, Component c)Parameters
gGraphics- graphics context to draw onto
cComponent- component whose border should be drawn
getMinimumHeight
public int getMinimumHeight()Returns
getMinimumWidth
public int getMinimumWidth()Returns
borderImage
public CSSBorder borderImage(Image borderImage, double... slicePoints)Creates a 9-piece image border.
Insets are all given in a (u,v) coordinate space where (0,0) is the top-left corner of the image, and (1.0, 1.0) is the bottom-right corner of the image.
If a border image is set for the CSS border, it will override all other border types, and will result in only the 9-piece border being rendered.
Parameters
borderImageImage- The border image.
slicePointsdouble...- The slice points. Accepts 1 - 4 values:
Returns
borderImageWithName
public CSSBorder borderImageWithName(String borderImageName, double... slicePoints)Adds a 9-piece image border using the provided image name, which should exist in the theme resource file.
Insets are all given in a (u,v) coordinate space where (0,0) is the top-left corner of the image, and (1.0, 1.0) is the bottom-right corner of the image.
If a border image is set for the CSS border, it will override all other border types, and will result in only the 9-piece border being rendered.
Parameters
borderImageNameString- The image name.
slicePointsdouble...- The slice points. Accepts 1 - 4 values:
Returns
boxShadow
public CSSBorder boxShadow(String value)borderRadius
public CSSBorder borderRadius(String radius)borderStroke
public CSSBorder borderStroke(String... strokeStrs)borderColor
public CSSBorder borderColor(String... colors)Parameters
colorsString...- The colors. 1 value sets all borders. 2 sets top/bottom, left/right. 3 sets top, left/right, bottom. 4 sets top, right, bottom, left.
Returns
borderWidth
public CSSBorder borderWidth(String... widths)Parameters
widthsString...- The widths. 1 value sets all borders. 2 sets top/bottom, left/right. 3 sets top, left/right, bottom. 4 sets top, right, bottom, left.
Returns
borderStyle
public CSSBorder borderStyle(String... styles)Parameters
stylesString...- The border styles. 1 value sets all borders. 2 sets top/bottom, left/right. 3 sets top, left/right, bottom. 4 sets top, right, bottom, left.
Returns
backgroundColor
public CSSBorder backgroundColor(String color)Parameters
colorString- A color string.
Returns
backgroundImage
public CSSBorder backgroundImage(String cssDirective)Parameters
cssDirectiveString- The value of the background-image property.
Returns
backgroundImage
public CSSBorder backgroundImage(Image... images)Parameters
imagesImage...- Images to use as background images.
Returns
backgroundRepeat
public CSSBorder backgroundRepeat(String... repeat)Parameters
repeatString...- Repeat options for respective background images.
Returns
backgroundPosition
public CSSBorder backgroundPosition(String... pos)Parameters
posString...- The background positions of background images.