public final 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();
Methods
public static RoundBorder 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. |
public RoundBorder uiid(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. |
public boolean getUIID() | True is we use the background of the component setting to draw |
public RoundBorder color(int color) | Sets the background color of the circle/rectangle |
public RoundBorder opacity(int opacity) | Sets the background opacity of the circle/rectangle |
public RoundBorder strokeOpacity(int strokeOpacity) | Sets the opacity of the stroke line around the circle/rectangle |
public RoundBorder strokeColor(int strokeColor) | Sets the stroke color of the circle/rectangle |
public RoundBorder strokeColor2(int strokeColor2) | Turns the stroke into a two-colour linear gradient running from strokeColor to the supplied end colour. |
public RoundBorder strokeGradientAngle(float strokeGradientAngle) | Sets the direction of the gradient stroke. |
public RoundBorder strokeGradient(boolean strokeGradient) | Explicitly enables/disables the gradient stroke without changing the colours. |
public RoundBorder stroke(Stroke stroke) | Sets the stroke of the circle/rectangle |
public RoundBorder stroke(float stroke, boolean mm) | Sets the stroke of the circle/rectangle |
public RoundBorder strokeAngle(int strokeAngle) | Sets the stroke angle of the circle, this only applies to circular versions |
public RoundBorder shadowSpread(int shadowSpread, boolean mm) | Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle |
public RoundBorder shadowSpread(int shadowSpread) | Sets the spread in pixels of the shadow i.e how much bigger is it than the actual circle/rectangle |
public RoundBorder shadowOpacity(int shadowOpacity) | Sets the opacity of the shadow from 0 - 255 where 0 means no shadow and 255 means opaque black shadow |
public RoundBorder shadowX(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 side |
public RoundBorder shadowY(float shadowY) | The position of the shadow on the Y axis where 0.5f means the center and higher values draw it to the bottom |
public RoundBorder shadowBlur(float shadowBlur) | The blur on the shadow this is the standard Gaussian blur radius |
public RoundBorder rectangle(boolean rectangle) | When set to true this border grows into a rectangle when the space isn’t perfectly circular |
public RoundBorder onlyLeftRounded(boolean onlyLeftRounded) | Forces a special case of the rectangle mode that renders the right side as square. |
public boolean isOnlyLeftRounded() | Checks if only left side is rounded. |
public RoundBorder onlyRightRounded(boolean onlyRightRounded) | Forces a special case of the rectangle mode that renders the left side as square. |
public boolean isOnlyRightRounded() | Checks if only right side is rounded. |
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 boolean isBackgroundPainter() | Returns true if installing this border will override the painting of the component background |
public int getColor() | The color of the border background |
public int getOpacity() | The opacity (transparency) of the border background |
public int getStrokeColor() | The color of the edge of the border if applicable |
public boolean isStrokeGradient() | True if the stroke is painted as a two-colour gradient |
public int getStrokeColor2() | The end colour of the gradient stroke when #isStrokeGradient is true |
public float getStrokeGradientAngle() | The angle of the gradient stroke in degrees |
public int getStrokeOpacity() | The opacity of the edge of the border if applicable |
public float getStrokeThickness() | The thickness of the edge of the border if applicable, 0 if no stroke is needed |
public boolean isStrokeMM() | True if the thickness of the stroke is in millimeters |
public int getShadowSpread() | The spread of the shadow in pixels of millimeters |
public int getShadowOpacity() | The opacity of the shadow between 0 and 255 |
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 |
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 |
public float getShadowBlur() | The Gaussian blur size |
public boolean isShadowMM() | True if the shadow spread is in millimeters |
public boolean isRectangle() | True if this border grows into a rectangle horizontally or keeps growing as a circle |
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. |
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
Method details
create
public static RoundBorder create()Returns
uiid
public RoundBorder uiid(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.
**Notice: **this flag will only work when shaped clipping is supported. That feature isn’t available in all platforms…
Parameters
uiidboolean- true to use the background of the component setting
Returns
getUIID
public boolean getUIID()Returns
color
public RoundBorder color(int color)Parameters
colorint- the color
Returns
opacity
public RoundBorder opacity(int opacity)Parameters
opacityint- the background opacity from 0-255 where 255 is completely opaque
Returns
strokeOpacity
public RoundBorder strokeOpacity(int strokeOpacity)Parameters
strokeOpacityint- the opacity from 0-255 where 255 is completely opaque
Returns
strokeColor
public RoundBorder strokeColor(int strokeColor)Parameters
strokeColorint- the color
Returns
strokeColor2
public RoundBorder strokeColor2(int strokeColor2)strokeColor
to the supplied end colour. The stroke thickness/opacity keep applying; only
the colour along the rim changes. Requires shape-clip support (all modern
ports); on ports without it the stroke falls back to the solid strokeColor.Parameters
strokeColor2int- the end colour of the gradient stroke
Returns
strokeGradientAngle
public RoundBorder strokeGradientAngle(float strokeGradientAngle)Parameters
strokeGradientAnglefloat- the angle in degrees, 0 = top-to-bottom, increasing clockwise
Returns
strokeGradient
public RoundBorder strokeGradient(boolean strokeGradient)Parameters
strokeGradientboolean- true to paint the stroke as a gradient
Returns
stroke
public RoundBorder stroke(Stroke stroke)Parameters
strokeStroke- the stroke object
Returns
stroke
public RoundBorder stroke(float stroke, boolean mm)Parameters
strokefloat- the thickness of the stroke object
mmboolean- set to true to indicate the value is in millimeters, false indicates pixels
Returns
strokeAngle
public RoundBorder strokeAngle(int strokeAngle)Parameters
strokeAngleint- the stroke angle in degrees
Returns
shadowSpread
public RoundBorder shadowSpread(int shadowSpread, boolean mm)Parameters
shadowSpreadint- the amount in pixels representing the size of the shadow
mmboolean- set to true to indicate the value is in millimeters, false indicates pixels
Returns
shadowSpread
public RoundBorder shadowSpread(int shadowSpread)Parameters
shadowSpreadint- the amount in pixels representing the size of the shadow
Returns
shadowOpacity
public RoundBorder shadowOpacity(int shadowOpacity)Parameters
shadowOpacityint- the opacity of the shadow
Returns
shadowX
public RoundBorder shadowX(float shadowX)Parameters
shadowXfloat- the position of the shadow between 0 - 1 where 0 equals left and 1 equals right
Returns
shadowY
public RoundBorder shadowY(float shadowY)Parameters
shadowYfloat- the position of the shadow between 0 - 1 where 0 equals top and 1 equals bottom
Returns
shadowBlur
public RoundBorder shadowBlur(float shadowBlur)Parameters
shadowBlurfloat- The blur on the shadow this is the standard Gaussian blur radius
Returns
rectangle
public RoundBorder rectangle(boolean rectangle)Parameters
rectangleboolean- When set to true this border grows into a rectangle when the space isn’t perfectly circular
Returns
onlyLeftRounded
public RoundBorder onlyLeftRounded(boolean onlyLeftRounded)Parameters
onlyLeftRoundedboolean- the new state of this mode
Returns
isOnlyLeftRounded
public boolean isOnlyLeftRounded()Returns
onlyRightRounded
public RoundBorder onlyRightRounded(boolean onlyRightRounded)Parameters
onlyRightRoundedboolean- the new state of this mode
Returns
isOnlyRightRounded
public boolean isOnlyRightRounded()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
isBackgroundPainter
public boolean isBackgroundPainter()Returns
getColor
public int getColor()Returns
getOpacity
public int getOpacity()Returns
getStrokeColor
public int getStrokeColor()Returns
isStrokeGradient
public boolean isStrokeGradient()Returns
getStrokeColor2
public int getStrokeColor2()#isStrokeGradient is trueReturns
getStrokeGradientAngle
public float getStrokeGradientAngle()Returns
getStrokeOpacity
public int getStrokeOpacity()Returns
getStrokeThickness
public float getStrokeThickness()Returns
isStrokeMM
public boolean isStrokeMM()Returns
getShadowSpread
public int getShadowSpread()Returns
getShadowOpacity
public int getShadowOpacity()Returns
getShadowX
public float getShadowX()Returns
getShadowY
public float getShadowY()Returns
getShadowBlur
public float getShadowBlur()Returns
isShadowMM
public boolean isShadowMM()Returns
isRectangle
public boolean isRectangle()Returns
equals
public boolean equals(Object obj)hashCode
public int hashCode()