public class CSSBorder extends Border
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:
This class also supports background images and gradients, but these are not well-tested and are not currently used by the CSS compiler.
Modifier and Type | Field and Description |
---|---|
static byte |
HPOSITION_CENTER
Constant indicating background-position center (horizontal).
|
static byte |
HPOSITION_LEFT
Constant indicating background-position left.
|
static byte |
HPOSITION_OTHER |
static byte |
HPOSITION_RIGHT
Constant indicating background-position right.
|
static byte |
REPEAT_BOTH
Constant indicating repeating on both x and y for background images.
|
static byte |
REPEAT_NONE
Constant indicating no-repeat for background images.
|
static byte |
REPEAT_X
Constant indicating repeat-x for background images.
|
static byte |
REPEAT_Y
Constant indicating repeat-y for background images.
|
static byte |
SIZE_AUTO |
static byte |
SIZE_CONTAIN |
static byte |
SIZE_COVER |
static byte |
SIZE_OTHER |
static byte |
STYLE_DASHED
Constant for border-style dashed
|
static byte |
STYLE_DOTTED
Constant for border-style dotted
|
static byte |
STYLE_HIDDEN
Constant for border-style hidden
|
static byte |
STYLE_NONE
Constant for border-style none
|
static byte |
STYLE_SOLID
Constant for border-style solid
|
static byte |
UNIT_EM
Constant for unit em
|
static byte |
UNIT_MM
Constant for unit mm
|
static byte |
UNIT_PERCENT
Constant for unit %
|
static byte |
UNIT_PIXELS
Constant for unit px
|
static byte |
VPOSITION_BOTTOM
Constant indicating background-position bottom.
|
static byte |
VPOSITION_CENTER
Constant indicating background-position center.
|
static byte |
VPOSITION_OTHER |
static byte |
VPOSITION_TOP
Constant indicating background-position top.
|
Constructor and Description |
---|
CSSBorder()
Creates a new empty CSS border.
|
CSSBorder(Resources res)
Creates an empty border.
|
CSSBorder(Resources res,
String css)
Creates a new CSS border with the provided CSS styles.
|
CSSBorder(String css)
Creates a new CSS border with the provided CSS styles.
|
Modifier and Type | Method and Description |
---|---|
CSSBorder |
backgroundColor(String color)
Sets the background color of the border.
|
CSSBorder |
backgroundImage(Image... images)
Sets the background image of the border.
|
CSSBorder |
backgroundImage(String cssDirective)
Adds one or more background images from a CSS background-image property.
|
CSSBorder |
backgroundPosition(String... pos)
Sets the background position.
|
CSSBorder |
backgroundRepeat(String... repeat)
Sets the background-repeat for the background images.
|
CSSBorder |
borderColor(String... colors)
Sets the border colors.
|
CSSBorder |
borderImage(Image borderImage,
double... slicePoints)
Creates a 9-piece image border.
|
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.
|
CSSBorder |
borderRadius(String radius)
Sets the border radius for rounded corners.
|
CSSBorder |
borderStroke(String... strokeStrs)
Sets the border stroke.
|
CSSBorder |
borderStyle(String... styles)
Sets the border styles.
|
CSSBorder |
borderWidth(String... widths)
Sets the border widths.
|
boolean |
equals(Object obj)
{Indicates whether some other object is "equal to" this one.}
|
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.
|
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.
|
boolean |
isBackgroundPainter()
Returns true if installing this border will override the painting of the component background
|
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.
|
String |
toCSSString()
Converts this border to a CSS string.
|
addOuterBorder, clearImageBorderSpecialTile, createBevelLowered, createBevelLowered, createBevelRaised, createBevelRaised, createCompoundBorder, createDashedBorder, createDashedBorder, createDottedBorder, createDottedBorder, createDoubleBorder, createDoubleBorder, createEmpty, createEtchedLowered, createEtchedLowered, createEtchedRaised, createEtchedRaised, createGrooveBorder, createGrooveBorder, createHorizonalImageBorder, createImageBorder, createImageBorder, createImageScaledBorder, createImageSplicedBorder, createInsetBorder, createInsetBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createLineBorder, createOutsetBorder, createOutsetBorder, createPressedVersion, createRidgeBorder, createRidgeBorder, createRoundBorder, createRoundBorder, createRoundBorder, createRoundBorder, createUndelineBorder, createUndelineBorder, createUnderlineBorder, createUnderlineBorder, createUnderlineBorder, createUnderlineBorder, createVerticalImageBorder, getCompoundBorders, getDefaultBorder, getEmpty, getFocusedInstance, getPressedInstance, getProperty, getThickness, getTrackComponent, isEmptyBorder, isPaintOuterBorderFirst, isRectangleType, lock, mirrorBorder, paint, setDefaultBorder, setFocusedInstance, setImageBorderSpecialTile, setImageBorderSpecialTile, setPaintOuterBorderFirst, setPressedInstance, setThickness, setTrackComponent, setTrackComponent, unlock
public static final byte REPEAT_NONE
public static final byte REPEAT_BOTH
public static final byte REPEAT_X
public static final byte REPEAT_Y
public static final byte VPOSITION_TOP
public static final byte VPOSITION_BOTTOM
public static final byte VPOSITION_CENTER
public static final byte VPOSITION_OTHER
public static final byte HPOSITION_LEFT
public static final byte HPOSITION_RIGHT
public static final byte HPOSITION_CENTER
public static final byte HPOSITION_OTHER
public static final byte SIZE_AUTO
public static final byte SIZE_CONTAIN
public static final byte SIZE_COVER
public static final byte SIZE_OTHER
public static final byte STYLE_NONE
public static final byte STYLE_HIDDEN
public static final byte STYLE_DOTTED
public static final byte STYLE_DASHED
public static final byte STYLE_SOLID
public static final byte UNIT_PIXELS
public static final byte UNIT_MM
public static final byte UNIT_PERCENT
public static final byte UNIT_EM
public CSSBorder()
public CSSBorder(Resources res)
res
- Theme resource file from which images can be referenced.public CSSBorder(String css)
css
- CSS to parse.IllegalArgumentException
- If it fails to parse the style.public CSSBorder(Resources res, String css)
res
- Theme resource file from which images can be loaded.css
- CSS to parse.IllegalArgumentException
- If it fails to parse the style.public boolean equals(Object obj)
Border
public String toCSSString()
public boolean isBackgroundPainter()
isBackgroundPainter
in class Border
public void paintBorderBackground(Graphics g, Component c)
paintBorderBackground
in class Border
g
- graphics context to draw ontoc
- component whose border should be drawnpublic int getMinimumHeight()
getMinimumHeight
in class Border
public int getMinimumWidth()
getMinimumWidth
in class Border
public CSSBorder borderImage(Image borderImage, double... slicePoints)
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.
borderImage
- The border image.slicePoints
- The slice points. Accepts 1 - 4 values:
borderImageWithName(java.lang.String, double...)
public CSSBorder borderImageWithName(String borderImageName, double... slicePoints)
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.
borderImageName
- The image name.slicePoints
- The slice points. Accepts 1 - 4 values:
borderImage(com.codename1.ui.Image, double...)
public CSSBorder borderRadius(String radius)
radius
- public CSSBorder borderStroke(String... strokeStrs)
strokeStrs
- public CSSBorder borderColor(String... colors)
colors
- 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.public CSSBorder borderWidth(String... widths)
widths
- 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.public CSSBorder borderStyle(String... styles)
styles
- 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.public CSSBorder backgroundColor(String color)
color
- A color string.public CSSBorder backgroundImage(String cssDirective)
cssDirective
- The value of the background-image property.public CSSBorder backgroundImage(Image... images)
images
- Images to use as background images.public CSSBorder backgroundRepeat(String... repeat)
repeat
- Repeat options for respective background images.