Skip to content

Commit d10c5ee

Browse files
Refactor instance inner classes to static to fix SpotBugs warnings.
1 parent a53c384 commit d10c5ee

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

CodenameOne/src/com/codename1/ui/Display.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5274,7 +5274,7 @@ private void throwRoot(Throwable cause) {
52745274
* if an exception occurs, it is easier to track it back to the original
52755275
* source.
52765276
*/
5277-
private class DebugRunnable implements Runnable {
5277+
private static class DebugRunnable implements Runnable {
52785278
private final Runnable internal;
52795279
private final EdtException exceptionWrapper;
52805280
private DebugRunnable parentContext;

CodenameOne/src/com/codename1/ui/plaf/CSSBorder.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static byte parseRepeat(String repeat) {
360360

361361
}
362362

363-
private void setAlpha(Graphics g, Color c) {
363+
private static void setAlpha(Graphics g, Color c) {
364364
g.setAlpha(c == null ? 0 : c.alpha);
365365
}
366366

@@ -445,11 +445,11 @@ public String toCSSString() {
445445
return sb.toString();
446446
}
447447

448-
private float floatPx(ScalarUnit u) {
448+
private static float floatPx(ScalarUnit u) {
449449
return u == null ? 0 : u.floatPx();
450450
}
451451

452-
private float floatPx(ScalarUnit u, Component c, Rectangle2D contentRect, boolean horizontal) {
452+
private static float floatPx(ScalarUnit u, Component c, Rectangle2D contentRect, boolean horizontal) {
453453
return u == null ? 0 : u.floatPx(c, contentRect, horizontal);
454454
}
455455

@@ -665,7 +665,7 @@ public void paintBorderBackground(Graphics g, Component c) {
665665
);
666666

667667
if (boxShadow != null) {
668-
boxShadow.paint(g, c, contentRect);
668+
boxShadow.paint(g, c, contentRect, this);
669669
}
670670
if (s.getBgTransparency() != 0) {
671671
g.setColor(s.getBgColor());
@@ -826,7 +826,7 @@ public int getMinimumWidth() {
826826
* @since 7.0
827827
*/
828828
public CSSBorder borderImage(Image borderImage, double... slicePoints) {
829-
this.borderImage = new BorderImage(borderImage, slicePoints);
829+
this.borderImage = new BorderImage(res, borderImage, slicePoints);
830830
return this;
831831
}
832832

@@ -850,7 +850,7 @@ public CSSBorder borderImage(Image borderImage, double... slicePoints) {
850850
* @since 7.0
851851
*/
852852
public CSSBorder borderImageWithName(String borderImageName, double... slicePoints) {
853-
this.borderImage = new BorderImage(borderImageName, slicePoints);
853+
this.borderImage = new BorderImage(res, borderImageName, slicePoints);
854854
return this;
855855
}
856856

@@ -1693,7 +1693,7 @@ Stroke getStroke(Component c, Rectangle2D contentRect, boolean horizontal) {
16931693

16941694
}
16951695

1696-
private class BoxShadow {
1696+
private static class BoxShadow {
16971697
ScalarUnit hOffset, vOffset, blurRadius, spread;
16981698
boolean inset;
16991699
Color color;
@@ -1715,20 +1715,20 @@ int hOffsetPx() {
17151715
}
17161716

17171717

1718-
void paint(Graphics g, Component c, Rectangle2D contentRect) {
1718+
void paint(Graphics g, Component c, Rectangle2D contentRect, CSSBorder border) {
17191719
int alpha = g.getAlpha();
17201720
int color = g.getColor();
17211721
boolean antialiased = g.isAntiAliased();
1722-
setColor(g, this.color);
1722+
border.setColor(g, this.color);
17231723
GeneralPath p = GeneralPath.createFromPool();
17241724
try {
1725-
createShape(
1725+
border.createShape(
17261726
p,
17271727
contentRect.getX(),
17281728
contentRect.getY(),
17291729
contentRect.getWidth(),
17301730
contentRect.getHeight(),
1731-
createArrow(c)
1731+
border.createArrow(c)
17321732
);
17331733
p.transform(Transform.makeTranslation(hOffset.floatPx(c, contentRect, true), vOffset.floatPx(c, contentRect, false)));
17341734
g.fillShape(p);
@@ -1747,7 +1747,7 @@ private String toCSSString() {
17471747

17481748
}
17491749

1750-
private class BorderRadius {
1750+
private static class BorderRadius {
17511751
private final ScalarUnit topLeftX;
17521752
private final ScalarUnit topRightX;
17531753
private final ScalarUnit bottomLeftX;
@@ -1971,7 +1971,7 @@ private String toCSSString() {
19711971

19721972
}
19731973

1974-
private class ColorStop {
1974+
private static class ColorStop {
19751975
Color color = new Color("#000000");
19761976
int position = 0;
19771977

@@ -1987,7 +1987,7 @@ public String toCSSString() {
19871987

19881988
}
19891989

1990-
private class LinearGradient {
1990+
private static class LinearGradient {
19911991
float angle;
19921992
ColorStop[] colors = new ColorStop[0];
19931993

@@ -2015,7 +2015,7 @@ private String toCSSString() {
20152015
}
20162016
}
20172017

2018-
private class RadialGradient {
2018+
private static class RadialGradient {
20192019
byte shape;
20202020
byte size;
20212021
float xPos, yPos;
@@ -2026,13 +2026,15 @@ private String toCSSString() {
20262026
}
20272027
}
20282028

2029-
private class BorderImage {
2029+
private static class BorderImage {
20302030
Image image;
20312031
double[] slices;
20322032
Border internal;
20332033
String imageName;
2034+
final Resources res;
20342035

2035-
BorderImage(String imageName, double... slces) {
2036+
BorderImage(Resources res, String imageName, double... slces) {
2037+
this.res = res;
20362038
this.imageName = imageName;
20372039
slices = new double[4];
20382040
if (slces.length == 4) {
@@ -2051,7 +2053,8 @@ private class BorderImage {
20512053
}
20522054
}
20532055

2054-
BorderImage(Image img, double... slces) {
2056+
BorderImage(Resources res, Image img, double... slces) {
2057+
this.res = res;
20552058
image = img;
20562059
slices = new double[4];
20572060
if (slces.length == 4) {
@@ -2106,7 +2109,7 @@ String toCSSString() {
21062109
}
21072110
}
21082111

2109-
private class BackgroundImage {
2112+
private static class BackgroundImage {
21102113
LinearGradient linearGradient;
21112114
RadialGradient radialGradient;
21122115
byte verticalPositionType, horizontalPositionType, verticalSizeType, horizontalSizeType;

0 commit comments

Comments
 (0)