Class RoundBorder
A border that can either be a circle or a circular rectangle which is a rectangle whose sides are circles. This border can optionally have a drop shadow associated with it.
IMPORTANT: RoundRectBorder instances can't be reused
you would need to create a separate instance for each style object!
See this issue for further details.
Form hi = new Form("Round", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER));
Button ok = new Button("OK");
Button cancel = new Button("Cancel");
Label loginLabel = new Label("Login", "Container");
loginLabel.getAllStyles().setAlignment(Component.CENTER);
Label passwordLabel = new Label("Password", "Container");
passwordLabel.getAllStyles().setAlignment(Component.CENTER);
TextField login = new TextField("", "Login", 20, TextArea.ANY);
TextField password = new TextField("", "Password", 20, TextArea.PASSWORD);
Style loginStyle = login.getAllStyles();
Stroke borderStroke = new Stroke(2, Stroke.CAP_SQUARE, Stroke.JOIN_MITER, 1);
loginStyle.setBorder(RoundBorder.create().
rectangle(true).
color(0xffffff).
strokeColor(0).
strokeOpacity(120).
stroke(borderStroke));
loginStyle.setMarginUnit(Style.UNIT_TYPE_DIPS);
loginStyle.setMargin(Component.BOTTOM, 3);
Style passwordStyle = password.getAllStyles();
passwordStyle.setBorder(RoundBorder.create().
rectangle(true).
color(0xffffff).
strokeColor(0).
strokeOpacity(120).
stroke(borderStroke));
Container box = BoxLayout.encloseY(
loginLabel,
login,
passwordLabel,
password,
GridLayout.encloseIn(2, cancel, ok));
Button closeButton = new Button();
Style closeStyle = closeButton.getAllStyles();
closeStyle.setFgColor(0xffffff);
closeStyle.setBgTransparency(0);
closeStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
closeStyle.setPadding(3, 3, 3, 3);
closeStyle.setBorder(RoundBorder.create().shadowOpacity(100));
FontImage.setMaterialIcon(closeButton, FontImage.MATERIAL_CLOSE);
Container layers = LayeredLayout.encloseIn(box, FlowLayout.encloseRight(closeButton));
Style boxStyle = box.getUnselectedStyle();
boxStyle.setBgTransparency(255);
boxStyle.setBgColor(0xeeeeee);
boxStyle.setMarginUnit(Style.UNIT_TYPE_DIPS);
boxStyle.setPaddingUnit(Style.UNIT_TYPE_DIPS);
boxStyle.setMargin(4, 3, 3, 3);
boxStyle.setPadding(2, 2, 2, 2);
hi.add(BorderLayout.CENTER, layers);
hi.show();
-
Method Summary
Modifier and TypeMethodDescriptioncolor(int color) Sets the background color of the circle/rectanglestatic RoundBordercreate()Creates a flat round border with no stroke and no shadow and the default color, this call can be chained with the other calls to mutate the color/opacity etc.boolean{{}intgetColor()The color of the border backgroundintReturns 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.intReturns 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.intThe opacity (transparency) of the border backgroundfloatThe Gaussian blur sizeintThe opacity of the shadow between 0 and 255intThe spread of the shadow in pixels of millimetersfloatX axis bias of the shadow between 0 and 1 where 0 is to the top and 1 is to the bottom, defaults to 0.5floatY axis bias of the shadow between 0 and 1 where 0 is to the left and 1 is to the right, defaults to 0.5intThe color of the edge of the border if applicableintThe opacity of the edge of the border if applicablefloatThe thickness of the edge of the border if applicable, 0 if no stroke is neededbooleangetUIID()True is we use the background of the component setting to drawinthashCode()booleanReturns true if installing this border will override the painting of the component backgroundbooleanChecks if only left side is rounded.booleanChecks if only right side is rounded.booleanTrue if this border grows into a rectangle horizontally or keeps growing as a circlebooleanTrue if the shadow spread is in millimetersbooleanTrue if the thickness of the stroke is in millimetersonlyLeftRounded(boolean onlyLeftRounded) Forces a special case of the rectangle mode that renders the right side as square.onlyRightRounded(boolean onlyRightRounded) Forces a special case of the rectangle mode that renders the left side as square.opacity(int opacity) Sets the background opacity of the circle/rectanglevoidHas 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.rectangle(boolean rectangle) When set to true this border grows into a rectangle when the space isn't perfectly circularshadowBlur(float shadowBlur) The blur on the shadow this is the standard Gaussian blur radiusshadowOpacity(int shadowOpacity) Sets the opacity of the shadow from 0 - 255 where 0 means no shadow and 255 means opaque black shadowshadowSpread(int shadowSpread) Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangleshadowSpread(int shadowSpread, boolean mm) Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangleshadowX(float shadowX) The position of the shadow on the X axis where 0.5f means the center and higher values draw it to the right sideshadowY(float shadowY) The position of the shadow on the Y axis where 0.5f means the center and higher values draw it to the bottomstroke(float stroke, boolean mm) Sets the stroke of the circle/rectangleSets the stroke of the circle/rectanglestrokeAngle(int strokeAngle) Sets the stroke angle of the circle, this only applies to circular versionsstrokeColor(int strokeColor) Sets the stroke color of the circle/rectanglestrokeOpacity(int strokeOpacity) Sets the opacity of the stroke line around the circle/rectangleuiid(boolean uiid) Uses the style of the components UIID to draw the background of the border, this effectively overrides all other style settings but allows the full power of UIID drawing including gradients, background images etc.Methods inherited from class Border
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
-
Method Details
-
create
Creates a flat round border with no stroke and no shadow and the default color, this call can be chained with the other calls to mutate the color/opacity etc.
Returns
a border instance
-
uiid
Uses the style of the components UIID to draw the background of the border, this effectively overrides all other style settings but allows the full power of UIID drawing including gradients, background images etc.
**Notice: **this flag will only work when shaped clipping is supported. That feature isn't available in all platforms...
Parameters
uiid: true to use the background of the component setting
Returns
border instance so these calls can be chained
-
getUIID
public boolean getUIID()True is we use the background of the component setting to draw
Returns
true if we draw based on the component UIID
-
color
Sets the background color of the circle/rectangle
Parameters
color: the color
Returns
border instance so these calls can be chained
-
opacity
Sets the background opacity of the circle/rectangle
Parameters
opacity: the background opacity from 0-255 where 255 is completely opaque
Returns
border instance so these calls can be chained
-
strokeOpacity
Sets the opacity of the stroke line around the circle/rectangle
Parameters
strokeOpacity: the opacity from 0-255 where 255 is completely opaque
Returns
border instance so these calls can be chained
-
strokeColor
Sets the stroke color of the circle/rectangle
Parameters
strokeColor: the color
Returns
border instance so these calls can be chained
-
stroke
Sets the stroke of the circle/rectangle
Parameters
stroke: the stroke object
Returns
border instance so these calls can be chained
-
stroke
Sets the stroke of the circle/rectangle
Parameters
-
stroke: the thickness of the stroke object -
mm: set to true to indicate the value is in millimeters, false indicates pixels
Returns
border instance so these calls can be chained
-
-
strokeAngle
Sets the stroke angle of the circle, this only applies to circular versions
Parameters
strokeAngle: the stroke angle in degrees
Returns
border instance so these calls can be chained
-
shadowSpread
Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle
Parameters
-
shadowSpread: the amount in pixels representing the size of the shadow -
mm: set to true to indicate the value is in millimeters, false indicates pixels
Returns
border instance so these calls can be chained
-
-
shadowSpread
Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle
Parameters
shadowSpread: the amount in pixels representing the size of the shadow
Returns
border instance so these calls can be chained
-
shadowOpacity
Sets the opacity of the shadow from 0 - 255 where 0 means no shadow and 255 means opaque black shadow
Parameters
shadowOpacity: the opacity of the shadow
Returns
border instance so these calls can be chained
-
shadowX
The position of the shadow on the X axis where 0.5f means the center and higher values draw it to the right side
Parameters
shadowX: the position of the shadow between 0 - 1 where 0 equals left and 1 equals right
Returns
border instance so these calls can be chained
-
shadowY
The position of the shadow on the Y axis where 0.5f means the center and higher values draw it to the bottom
Parameters
shadowY: the position of the shadow between 0 - 1 where 0 equals top and 1 equals bottom
Returns
border instance so these calls can be chained
-
shadowBlur
The blur on the shadow this is the standard Gaussian blur radius
Parameters
shadowBlur: The blur on the shadow this is the standard Gaussian blur radius
Returns
border instance so these calls can be chained
-
rectangle
When set to true this border grows into a rectangle when the space isn't perfectly circular
Parameters
rectangle: When set to true this border grows into a rectangle when the space isn't perfectly circular
Returns
border instance so these calls can be chained
-
onlyLeftRounded
Forces a special case of the rectangle mode that renders the right side as square. This is ignored when the rectangle mode is false
Parameters
onlyLeftRounded: the new state of this mode
Returns
border instance so these calls can be chained
-
isOnlyLeftRounded
public boolean isOnlyLeftRounded()Checks if only left side is rounded.
Returns
True if only left side is rounded.
Since
7.0
-
onlyRightRounded
Forces a special case of the rectangle mode that renders the left side as square. This is ignored when the rectangle mode is false
Parameters
onlyRightRounded: the new state of this mode
Returns
border instance so these calls can be chained
-
isOnlyRightRounded
public boolean isOnlyRightRounded()Checks if only right side is rounded.
Returns
True if only right side is rounded.
Since
7.0
-
paintBorderBackground
Description copied from class:BorderHas 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.
Parameters
-
g: graphics context to draw onto -
c: component whose border should be drawn
- Overrides:
paintBorderBackgroundin classBorder
-
-
getMinimumHeight
public int getMinimumHeight()Description copied from class:BorderReturns 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 minimum width would be left+right
Returns
0 if not applicable or a dimension if it is.
- Overrides:
getMinimumHeightin classBorder
-
getMinimumWidth
public int getMinimumWidth()Description copied from class:BorderReturns 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 minimum width would be left+right
Returns
0 if not applicable or a dimension if it is.
- Overrides:
getMinimumWidthin classBorder
-
isBackgroundPainter
public boolean isBackgroundPainter()Description copied from class:BorderReturns true if installing this border will override the painting of the component background
Returns
true if this border replaces the painter
- Overrides:
isBackgroundPainterin classBorder
-
getColor
public int getColor()The color of the border background
Returns
the color
-
getOpacity
public int getOpacity()The opacity (transparency) of the border background
Returns
the opacity
-
getStrokeColor
public int getStrokeColor()The color of the edge of the border if applicable
Returns
the strokeColor
-
getStrokeOpacity
public int getStrokeOpacity()The opacity of the edge of the border if applicable
Returns
the strokeOpacity
-
getStrokeThickness
public float getStrokeThickness()The thickness of the edge of the border if applicable, 0 if no stroke is needed
Returns
the strokeThickness
-
isStrokeMM
public boolean isStrokeMM()True if the thickness of the stroke is in millimeters
Returns
the strokeMM
-
getShadowSpread
public int getShadowSpread()The spread of the shadow in pixels of millimeters
Returns
the shadowSpread
-
getShadowOpacity
public int getShadowOpacity()The opacity of the shadow between 0 and 255
Returns
the shadowOpacity
-
getShadowX
public float getShadowX()X axis bias of the shadow between 0 and 1 where 0 is to the top and 1 is to the bottom, defaults to 0.5
Returns
the shadowX
-
getShadowY
public float getShadowY()Y axis bias of the shadow between 0 and 1 where 0 is to the left and 1 is to the right, defaults to 0.5
Returns
the shadowY
-
getShadowBlur
public float getShadowBlur()The Gaussian blur size
Returns
the shadowBlur
-
isShadowMM
public boolean isShadowMM()True if the shadow spread is in millimeters
Returns
the shadowMM
-
isRectangle
public boolean isRectangle()True if this border grows into a rectangle horizontally or keeps growing as a circle
Returns
the rectangle
-
equals
-
hashCode
-