public class Border extends Object
This class can be extended to provide additional border types and custom made border types.
A border can optionally paint the background of the component, this depends on the border type and is generally required for rounded borders that "know" the area that should be filled.
Modifier | Constructor and Description |
---|---|
protected |
Border()
Prevents usage of new operator, use the factory methods in the class or subclass
to create new border types.
|
Modifier and Type | Method and Description |
---|---|
void |
addOuterBorder(Border outer)
Ads a border that wraps this border
|
void |
clearImageBorderSpecialTile()
Cleans the tile tracking state allowing the garbage collector to pick up the component and the image data
|
static Border |
createBevelLowered()
Creates a lowered bevel border with default colors, highlight is derived
from the component and shadow is a plain dark color
|
static Border |
createBevelLowered(int highlightOuter,
int highlightInner,
int shadowOuter,
int shadowInner)
Creates a raised bevel border with the given colors
|
static Border |
createBevelRaised()
Creates a lowered bevel border with default colors, highlight is derived
from the component and shadow is a plain dark color
|
static Border |
createBevelRaised(int highlightOuter,
int highlightInner,
int shadowOuter,
int shadowInner)
Creates a raised bevel border with the given colors
|
static Border |
createCompoundBorder(Border top,
Border bottom,
Border left,
Border right)
Creates a border that is comprised of multiple border types so one border type can be used on top
while another one can be used at the bottom.
|
static Border |
createDashedBorder(int thickness)
Creates a dashed border with the specified thickness and the theme colors
|
static Border |
createDashedBorder(int thickness,
int color)
Creates a dashed border with the specified thickness and color
|
static Border |
createDottedBorder(int thickness)
Creates a dotted border with the specified thickness and the theme colors
|
static Border |
createDottedBorder(int thickness,
int color)
Creates a dotted border with the specified thickness and color
|
static Border |
createDoubleBorder(int thickness)
Creates a double border with the specified thickness and color
|
static Border |
createDoubleBorder(int thickness,
int color)
Creates a double border with the specified thickness and color
|
static Border |
createEmpty()
Creates an empty border, this is useful where we don't want a border for a
component but want a focus border etc...
|
static Border |
createEtchedLowered()
Creates a lowered etched border with default colors, highlight is derived
from the component and shadow is a plain dark color
|
static Border |
createEtchedLowered(int highlight,
int shadow)
Creates a raised etched border with the given colors
|
static Border |
createEtchedRaised()
Creates a lowered etched border with default colors, highlight is derived
from the component and shadow is a plain dark color
|
static Border |
createEtchedRaised(int highlight,
int shadow)
Creates a raised etched border with the given colors
|
static Border |
createGrooveBorder(int thickness)
Creates a groove border with the specified thickness and theme colors
|
static Border |
createGrooveBorder(int thickness,
int color)
Creates a groove border with the specified thickness and color
|
static Border |
createHorizonalImageBorder(Image left,
Image right,
Image center)
This is an image border that can only grow horizontally
|
static Border |
createImageBorder(Image top,
Image topLeft,
Image background)
The given images are tiled appropriately across the matching side of the border, rotated and placed
as expected in the four corners.
|
static Border |
createImageBorder(Image top,
Image bottom,
Image left,
Image right,
Image topLeft,
Image topRight,
Image bottomLeft,
Image bottomRight,
Image background)
The given top/bottom/left/right images are tiled appropriately across the matching sides of the border and the corners are placed
as expected in the four corners.
|
static Border |
createImageScaledBorder(Image top,
Image bottom,
Image left,
Image right,
Image topLeft,
Image topRight,
Image bottomLeft,
Image bottomRight,
Image background)
The given top/bottom/left/right images are scaled appropriately across the matching sides of the border and the corners are placed
as expected in the four corners.
|
static Border |
createImageSplicedBorder(Image img,
double topInset,
double rightInset,
double bottomInset,
double leftInset)
The given image is spliced into 9 pieces based on the provided top, right, bottom, and left insets, and the resulting
sub-images are used to form a 9-piece image border via
createImageBorder(com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image) |
static Border |
createInsetBorder(int thickness)
Creates an inset border with the specified thickness and theme colors
|
static Border |
createInsetBorder(int thickness,
int color)
Creates an inset border with the specified thickness and color
|
static Border |
createLineBorder(float thickness)
Creates a line border that uses the color of the component foreground for drawing
|
static Border |
createLineBorder(float thickness,
int color)
Creates a line border that uses the given color for the component
|
static Border |
createLineBorder(int thickness)
Creates a line border that uses the color of the component foreground for drawing
|
static Border |
createLineBorder(int thickness,
int color)
Creates a line border that uses the given color for the component
|
static Border |
createLineBorder(int thickness,
int color,
String title)
Creates a line border that uses the given color for the component
|
static Border |
createLineBorder(int thickness,
String title)
Creates a line border with the specified title
|
static Border |
createOutsetBorder(int thickness)
Creates an outset border with the specified thickness and theme colors
|
static Border |
createOutsetBorder(int thickness,
int color)
Creates an outset border with the specified thickness and color
|
Border |
createPressedVersion()
When applied to buttons borders produce a version that reverses the effects
of the border providing a pressed feel
|
static Border |
createRidgeBorder(int thickness)
Creates a ridge border with the specified thickness and theme colors
|
static Border |
createRidgeBorder(int thickness,
int color)
Creates a ridge border with the specified thickness and color
|
static Border |
createRoundBorder(int arcWidth,
int arcHeight)
Deprecated.
the performance of round rect borders is REALLY slow, we recommend people use image borders
which are faster, more portable and better looking
|
static Border |
createRoundBorder(int arcWidth,
int arcHeight,
boolean outline)
Deprecated.
the performance of round rect borders is REALLY slow, we recommend people use image borders
which are faster, more portable and better looking
|
static Border |
createRoundBorder(int arcWidth,
int arcHeight,
int color)
Deprecated.
the performance of round rect borders is REALLY slow, we recommend people use image borders
which are faster, more portable and better looking
|
static Border |
createRoundBorder(int arcWidth,
int arcHeight,
int color,
boolean outline)
Deprecated.
the performance of round rect borders is REALLY slow, we recommend people use image borders
which are faster, more portable and better looking
|
static Border |
createUndelineBorder(float thickness)
Deprecated.
due to a spelling mistake. Use
createUnderlineBorder(float thickness) |
static Border |
createUndelineBorder(int thickness)
Deprecated.
due to a spelling mistake. Use
createUnderlineBorder(int thickness) |
static Border |
createUnderlineBorder(float thickness)
Creates an underline border that uses the color of the component foreground for drawing
|
static Border |
createUnderlineBorder(float thickness,
int color)
Creates an underline border that uses the given color
|
static Border |
createUnderlineBorder(int thickness)
Creates an underline border that uses the color of the component foreground for drawing
|
static Border |
createUnderlineBorder(int thickness,
int color)
Creates an underline border that uses the given color
|
static Border |
createVerticalImageBorder(Image top,
Image bottom,
Image center)
This is an image border that can only grow vertically
|
boolean |
equals(Object obj)
{Indicates whether some other object is "equal to" this one.}
|
Border[] |
getCompoundBorders()
This method returns the Compound Borders array.
|
static Border |
getDefaultBorder()
Gets the default border to the given value
|
static Border |
getEmpty()
Deprecated.
use createEmpty instead
|
Border |
getFocusedInstance()
Deprecated.
use the getSelectedStyle() method in the component class
|
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.
|
Border |
getPressedInstance()
Returns the pressed version of the border if one is set by the user
|
Object |
getProperty(String n)
This method is for internal usage only!
|
int |
getThickness()
This method returns how thick is the border in pixels, notice this doesn't apply to most border types
|
protected Rectangle |
getTrackComponent()
The track component is an area to which an arrow based border should point at.
|
boolean |
isBackgroundPainter()
Returns true if installing this border will override the painting of the component background
|
boolean |
isEmptyBorder()
Indicates whether this is an empty border
|
boolean |
isPaintOuterBorderFirst()
Allows toggling the order in which the outer and inner borders are painted for the Outer border type
|
boolean |
isRectangleType()
Returns true if this border type is a rectangle border.
|
void |
lock()
This callback indicates that a component pointing at this border is initialized, this
method is useful for image borders whose lock methods are implicitly invoked.
|
Border |
mirrorBorder()
If a border is a horizontal image border it can be mirrored which is useful for an RTL scenario
|
void |
paint(Graphics g,
Component c)
Draws the border for the given component, this method is called before a call to
background painting is made.
|
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.
|
static void |
setDefaultBorder(Border border)
Sets the default border to the given value
|
void |
setFocusedInstance(Border focused)
Deprecated.
use the getSelectedStyle() method in the component class
|
void |
setImageBorderSpecialTile(Image tileTop,
Image tileBottom,
Image tileLeft,
Image tileRight,
Component trackComponent)
This method is designed mainly for the purpose of creating an arrow that will track a specific component using the image border
the tile given would be an arrow like image just like the ones used for the top/bottom/left/right images.
|
void |
setImageBorderSpecialTile(Image tileTop,
Image tileBottom,
Image tileLeft,
Image tileRight,
Rectangle trackComponent)
This method is designed mainly for the purpose of creating an arrow that will track a specific component using the image border
the tile given would be an arrow like image just like the ones used for the top/bottom/left/right images.
|
void |
setPaintOuterBorderFirst(boolean paintOuterBorderFirst)
Allows toggling the order in which the outer and inner borders are painted for the Outer border type
|
void |
setPressedInstance(Border pressed)
Allows us to define a border that will act as the pressed version of this border
|
void |
setThickness(int thickness)
This method returns sets the border thickness in pixels, notice this doesn't apply to most border types
|
void |
setTrackComponent(Component trackComponent)
In the case of an arrow border the track component lets us track the position
to which the border is pointing
|
void |
setTrackComponent(Rectangle trackComponent)
In the case of an arrow border the track component lets us track the position
to which the border is pointing
|
void |
unlock()
This callback indicates that a component pointing at this border is now deinitilized
This method may be invoked multiple times.
|
protected Border()
public Border mirrorBorder()
public void setImageBorderSpecialTile(Image tileTop, Image tileBottom, Image tileLeft, Image tileRight, Component trackComponent)
tileTop
- an image that will replace one of the tiles on the top if the track component is theretileBottom
- an image that will replace one of the tiles on the bottom if the track component is theretileLeft
- an image that will replace one of the tiles on the left if the track component is theretileRight
- an image that will replace one of the tiles on the right if the track component is theretrackComponent
- the component that will be tracked for the positioning of the tileprotected Rectangle getTrackComponent()
public void setTrackComponent(Component trackComponent)
trackComponent
- the track componentpublic void setTrackComponent(Rectangle trackComponent)
trackComponent
- the track componentpublic void setImageBorderSpecialTile(Image tileTop, Image tileBottom, Image tileLeft, Image tileRight, Rectangle trackComponent)
tileTop
- an image that will replace one of the tiles on the top if the track component is theretileBottom
- an image that will replace one of the tiles on the bottom if the track component is theretileLeft
- an image that will replace one of the tiles on the left if the track component is theretileRight
- an image that will replace one of the tiles on the right if the track component is theretrackComponent
- the component that will be tracked for the positioning of the tilepublic void clearImageBorderSpecialTile()
public void addOuterBorder(Border outer)
outer
- The outer borderpublic int getMinimumHeight()
public int getMinimumWidth()
public static Border getEmpty()
public static Border createEmpty()
public boolean isEmptyBorder()
public static Border createImageBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background)
By default this border does not override background unless a background image is specified
top
- the image of the top linebottom
- the image of the bottom lineleft
- the image of the left lineright
- the image of the right linetopLeft
- the image of the top left cornertopRight
- the image of the top right cornerbottomLeft
- the image of the bottom left cornerbottomRight
- the image of the bottom right cornerbackground
- the image of the background (optional)public static Border createImageSplicedBorder(Image img, double topInset, double rightInset, double bottomInset, double leftInset)
createImageBorder(com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image, com.codename1.ui.Image)
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.
img
- The image to be used as a background image and spliced.topInset
- rightInset
- bottomInset
- leftInset
- public static Border createImageScaledBorder(Image top, Image bottom, Image left, Image right, Image topLeft, Image topRight, Image bottomLeft, Image bottomRight, Image background)
By default this border does not override background unless a background image is specified
top
- the image of the top linebottom
- the image of the bottom lineleft
- the image of the left lineright
- the image of the right linetopLeft
- the image of the top left cornertopRight
- the image of the top right cornerbottomLeft
- the image of the bottom left cornerbottomRight
- the image of the bottom right cornerbackground
- the image of the background (optional)public static Border createHorizonalImageBorder(Image left, Image right, Image center)
left
- the image of the left sideright
- the image of the right sidecenter
- the image of the centerpublic static Border createVerticalImageBorder(Image top, Image bottom, Image center)
top
- the image of the topbottom
- the image of the bottomcenter
- the image of the centerpublic static Border createImageBorder(Image top, Image topLeft, Image background)
By default this border does not override background unless a background image is specified.
Notice that this version of the method is potentially much more efficient since images are rotated internally and this might save quite a bit of memory!
The top and topLeft images must be square! The width and height of these images must be equal otherwise rotation won't work as you expect.
top
- the image of the top linetopLeft
- the image of the top left cornerbackground
- the image of the background (optional)public static Border createLineBorder(int thickness)
thickness
- thickness of the border in pixelspublic static Border createLineBorder(float thickness)
thickness
- thickness of the border in millimeterspublic static Border createUndelineBorder(int thickness)
createUnderlineBorder(int thickness)
thickness
- thickness of the border in pixelspublic static Border createUnderlineBorder(int thickness)
thickness
- thickness of the border in pixelspublic static Border createUndelineBorder(float thickness)
createUnderlineBorder(float thickness)
thickness
- thickness of the border in millimeterspublic static Border createUnderlineBorder(float thickness)
thickness
- thickness of the border in millimeterspublic static Border createUnderlineBorder(int thickness, int color)
thickness
- thickness of the border in pixelscolor
- the colorpublic static Border createUnderlineBorder(float thickness, int color)
thickness
- thickness of the border in millimeterscolor
- the colorpublic static Border createDottedBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createDashedBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createDoubleBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createDottedBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createDashedBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createDoubleBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createOutsetBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createOutsetBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createInsetBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createInsetBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createGrooveBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createGrooveBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createRidgeBorder(int thickness)
thickness
- The border thickness in pixelspublic static Border createRidgeBorder(int thickness, int color)
thickness
- The border thickness in pixelscolor
- The border colorpublic static Border createLineBorder(int thickness, String title)
thickness
- thickness of the border in pixelstitle
- The borders titlepublic static Border createLineBorder(int thickness, int color, String title)
thickness
- thickness of the border in pixelscolor
- the color for the bordertitle
- The borders titlepublic static Border createLineBorder(int thickness, int color)
thickness
- thickness of the border in pixelscolor
- the color for the borderpublic static Border createLineBorder(float thickness, int color)
thickness
- thickness of the border in millimeterscolor
- the color for the borderpublic static Border createRoundBorder(int arcWidth, int arcHeight)
This border overrides any painter used on the component and would ignor such a painter.
arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.public static Border createRoundBorder(int arcWidth, int arcHeight, boolean outline)
This border overrides any painter used on the component and would ignor such a painter.
arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.outline
- whether the round rect border outline should be drawnpublic static Border createRoundBorder(int arcWidth, int arcHeight, int color)
This border overrides any painter used on the component and would ignor such a painter.
arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.color
- the color for the borderpublic static Border createRoundBorder(int arcWidth, int arcHeight, int color, boolean outline)
This border overrides any painter used on the component and would ignor such a painter.
arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.color
- the color for the borderoutline
- whether the round rect border outline should be drawnpublic static Border createEtchedLowered()
public static Border createEtchedLowered(int highlight, int shadow)
highlight
- color RGB valueshadow
- color RGB valuepublic static Border createEtchedRaised()
public static Border createEtchedRaised(int highlight, int shadow)
highlight
- color RGB valueshadow
- color RGB valuepublic boolean equals(Object obj)
public static Border createCompoundBorder(Border top, Border bottom, Border left, Border right)
top
- the top borderbottom
- the bottom borderleft
- the left borderright
- the right borderpublic boolean isBackgroundPainter()
public boolean isRectangleType()
public static Border createBevelLowered()
public static Border createBevelLowered(int highlightOuter, int highlightInner, int shadowOuter, int shadowInner)
highlightOuter
- RGB of the outer edge of the highlight areahighlightInner
- RGB of the inner edge of the highlight areashadowOuter
- RGB of the outer edge of the shadow areashadowInner
- RGB of the inner edge of the shadow areapublic static Border createBevelRaised()
public static Border createBevelRaised(int highlightOuter, int highlightInner, int shadowOuter, int shadowInner)
highlightOuter
- RGB of the outer edge of the highlight areahighlightInner
- RGB of the inner edge of the highlight areashadowOuter
- RGB of the outer edge of the shadow areashadowInner
- RGB of the inner edge of the shadow areapublic void setPressedInstance(Border pressed)
pressed
- a border that will be returned by the pressed version methodpublic void setFocusedInstance(Border focused)
focused
- a border that will be returned by the focused version methodpublic Border getFocusedInstance()
public Border getPressedInstance()
public Border createPressedVersion()
public void paintBorderBackground(Graphics g, Component c)
g
- graphics context to draw ontoc
- component whose border should be drawnpublic void paint(Graphics g, Component c)
g
- graphics context to draw ontoc
- component whose border should be drawnpublic static void setDefaultBorder(Border border)
border
- new border valuepublic static Border getDefaultBorder()
public int getThickness()
public void setThickness(int thickness)
thickness
- the Border thicknesspublic void setPaintOuterBorderFirst(boolean paintOuterBorderFirst)
paintOuterBorderFirst
- whether the outside border should be painter firstpublic boolean isPaintOuterBorderFirst()
public Border[] getCompoundBorders()
public void lock()
public void unlock()