Browse Source

Avoid shadowing class variables

pull/323/head
Jannis Weis 3 years ago
parent
commit
ef4deb1e8b
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 18
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java
  2. 6
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

18
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonBorder.java

@ -108,21 +108,21 @@ public class DarkButtonBorder implements Border, UIResource, VisualPaddingProvid
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
g2.translate(x, y); g2.translate(x, y);
int arc = getArc(c); int arcSize = getArc(c);
int focusArc = getFocusArc(c); int focusArcSize = getFocusArc(c);
GraphicsContext config = new GraphicsContext(g); GraphicsContext config = new GraphicsContext(g);
AlignmentExt corner = getCornerFlag(c); AlignmentExt corner = getCornerFlag(c);
boolean paintShadow = showDropShadow(corner); boolean paintShadow = showDropShadow(corner);
boolean focus = paintFocus(c); boolean focus = paintFocus(c);
int shadowHeight = paintShadow ? getShadowSize() : 0; int shadowHeight = paintShadow ? getShadowSize() : 0;
int borderSize = getBorderSize(); int bs = getBorderSize();
Insets insetMask = new Insets(borderSize, borderSize, Math.max(borderSize, shadowHeight), borderSize); Insets insetMask = new Insets(bs, bs, Math.max(bs, shadowHeight), bs);
Insets focusIns = new Insets(0, 0, 0, 0); Insets focusIns = new Insets(0, 0, 0, 0);
if (corner != null) { if (corner != null) {
focusIns = corner.maskInsets(focusIns, -borderSize - focusArc); focusIns = corner.maskInsets(focusIns, -bs - focusArcSize);
insetMask = corner.maskInsets(insetMask, -arc); insetMask = corner.maskInsets(insetMask, -arcSize);
} }
int bx = insetMask.left; int bx = insetMask.left;
@ -132,13 +132,13 @@ public class DarkButtonBorder implements Border, UIResource, VisualPaddingProvid
int fx = focusIns.left; int fx = focusIns.left;
int fy = focusIns.top; int fy = focusIns.top;
int fw = width - focusIns.left - focusIns.right; int fw = width - focusIns.left - focusIns.right;
int fh = by + bh + borderSize - focusIns.top - focusIns.bottom; int fh = by + bh + bs - focusIns.top - focusIns.bottom;
if (paintFocus(c)) { if (paintFocus(c)) {
paintFocusBorder(g2, focusArc, borderSize, fx, fy, fw, fh); paintFocusBorder(g2, focusArcSize, bs, fx, fy, fw, fh);
} }
paintLineBorder(c, g2, arc, focus, bx, by, bw, bh); paintLineBorder(c, g2, arcSize, focus, bx, by, bw, bh);
if (corner != null) { if (corner != null) {
paintNeighbourFocus(g2, c, width, height); paintNeighbourFocus(g2, c, width, height);

6
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -209,7 +209,7 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
AbstractButton b = (AbstractButton) c; AbstractButton b = (AbstractButton) c;
if (shouldDrawBackground(b)) { if (shouldDrawBackground(b)) {
int arc = getArc(c); int arcSize = getArc(c);
int width = c.getWidth(); int width = c.getWidth();
int height = c.getHeight(); int height = c.getHeight();
Insets margin = b.getMargin(); Insets margin = b.getMargin();
@ -217,9 +217,9 @@ public class DarkButtonUI extends BasicButtonUI implements ButtonConstants {
margin = null; margin = null;
} }
if (ButtonConstants.isBorderlessVariant(c)) { if (ButtonConstants.isBorderlessVariant(c)) {
paintBorderlessBackground(b, g2, arc, width, height, margin); paintBorderlessBackground(b, g2, arcSize, width, height, margin);
} else if (b.getBorder() instanceof DarkButtonBorder) { } else if (b.getBorder() instanceof DarkButtonBorder) {
paintDarklafBorderBackground(b, g2, arc, width, height); paintDarklafBorderBackground(b, g2, arcSize, width, height);
} else { } else {
paintDefaultBackground(b, g2, width, height); paintDefaultBackground(b, g2, width, height);
} }

Loading…
Cancel
Save