Browse Source

Use fallback values in DropShadowBorder

Use icon size when creating image table value.
Only run documentation action when properties have changed.
pull/127/head
weisj 5 years ago
parent
commit
10523302c8
  1. 7
      .github/workflows/documentation.yml
  2. 17
      core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java
  3. 4
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties
  4. 16
      core/src/test/java/documentation/CreateUITable.java

7
.github/workflows/documentation.yml

@ -1,8 +1,11 @@
name: Documentation name: Documentation
on: on:
push: push:
branches: paths:
- '*' - '**.properties'
pull_request:
paths:
- '**.properties'
jobs: jobs:
gradle: gradle:

17
core/src/main/java/com/github/weisj/darklaf/components/border/DropShadowBorder.java

@ -78,14 +78,14 @@ public class DropShadowBorder implements Border, Serializable {
public DropShadowBorder(final Color shadowColor, final int shadowSize, public DropShadowBorder(final Color shadowColor, final int shadowSize,
final float shadowOpacity, final int cornerSize, final boolean showTopShadow, final float shadowOpacity, final int cornerSize, final boolean showTopShadow,
final boolean showLeftShadow, final boolean showBottomShadow, final boolean showRightShadow) { final boolean showLeftShadow, final boolean showBottomShadow, final boolean showRightShadow) {
this.shadowColor = shadowColor; setShadowColor(shadowColor);
this.shadowSize = shadowSize; setShadowSize(shadowSize);
this.shadowOpacity = shadowOpacity; setShadowOpacity(shadowOpacity);
this.cornerSize = cornerSize; setCornerSize(cornerSize);
this.showTopShadow = showTopShadow; setShowTopShadow(showTopShadow);
this.showLeftShadow = showLeftShadow; setShowLeftShadow(showLeftShadow);
this.showBottomShadow = showBottomShadow; setShowBottomShadow(showBottomShadow);
this.showRightShadow = showRightShadow; setShowRightShadow(showRightShadow);
} }
@ -411,6 +411,7 @@ public class DropShadowBorder implements Border, Serializable {
public DropShadowBorder setShadowColor(final Color shadowColor) { public DropShadowBorder setShadowColor(final Color shadowColor) {
this.shadowColor = shadowColor; this.shadowColor = shadowColor;
if (shadowColor == null) this.shadowColor = Color.BLACK;
return this; return this;
} }

4
core/src/main/resources/com/github/weisj/darklaf/properties/ui/menuItem.properties

@ -53,7 +53,11 @@ MenuItem.arrowIcon = navigation/arrowRight.svg[t
MenuItem.arrowHover.icon = navigation/arrowRightHover.svg[themed] MenuItem.arrowHover.icon = navigation/arrowRightHover.svg[themed]
MenuItem.checkIcon = empty(7,7) MenuItem.checkIcon = empty(7,7)
Menu.checkIcon = empty(7,7) Menu.checkIcon = empty(7,7)
CheckBoxMenuItem.checkIcon = empty(19,19) CheckBoxMenuItem.checkIcon = empty(19,19)
CheckBoxMenuItem.arrowIcon = empty(16,16) CheckBoxMenuItem.arrowIcon = empty(16,16)
CheckBoxMenuItem.dashIcon = empty(0,0)
RadioButtonMenuItem.checkIcon = empty(19,19) RadioButtonMenuItem.checkIcon = empty(19,19)
RadioButtonMenuItem.arrowIcon = empty(16,16) RadioButtonMenuItem.arrowIcon = empty(16,16)
RadioButtonMenuItem.dashIcon = empty(0,0)

16
core/src/test/java/documentation/CreateUITable.java

@ -239,11 +239,12 @@ public class CreateUITable {
private String parseImage(final String key, final Object value, final int ident) { private String parseImage(final String key, final Object value, final int ident) {
String stringRepresentation = parseValue(value).replaceAll(" ", ""); String stringRepresentation = parseValue(value).replaceAll(" ", "");
String path; String path;
Dimension size = new Dimension(SAMPLE_WIDTH, SAMPLE_HEIGHT);
try { try {
if (!(value instanceof Icon)) { if (!(value instanceof Icon)) {
path = createImage(value, stringRepresentation); path = createImage(value, stringRepresentation, size);
} else { } else {
path = createImage(value, key); path = createImage(value, key, size);
} }
} catch (IOException ignored) { } catch (IOException ignored) {
return StringUtil.repeat(IDENT, ident) + "<td></td>\n"; return StringUtil.repeat(IDENT, ident) + "<td></td>\n";
@ -252,7 +253,7 @@ public class CreateUITable {
+ String.format("<td style=\"padding:0px\" align=\"center\"><img src=\"%s\" alt=\"%s\"></td>\n", path, key); + String.format("<td style=\"padding:0px\" align=\"center\"><img src=\"%s\" alt=\"%s\"></td>\n", path, key);
} }
private String createImage(final Object value, final String name) throws IOException { private String createImage(final Object value, final String name, final Dimension size) throws IOException {
new File(workingFolder + "img/").mkdirs(); new File(workingFolder + "img/").mkdirs();
String fileName = "img/" + name + ".png"; String fileName = "img/" + name + ".png";
File imageFile = new File(workingFolder + fileName); File imageFile = new File(workingFolder + fileName);
@ -260,11 +261,16 @@ public class CreateUITable {
JComponent comp = (JComponent) new SampleRenderer().getTableCellRendererComponent(null, value, false, false, 0, 0); JComponent comp = (JComponent) new SampleRenderer().getTableCellRendererComponent(null, value, false, false, 0, 0);
BufferedImage image = ImageUtil.createCompatibleTranslucentImage(SAMPLE_WIDTH, SAMPLE_HEIGHT); BufferedImage image = ImageUtil.createCompatibleTranslucentImage(SAMPLE_WIDTH, SAMPLE_HEIGHT);
Graphics g = image.getGraphics(); Graphics g = image.getGraphics();
if (value instanceof Icon) {
size.width = Math.max(size.width, ((Icon) value).getIconWidth());
size.height = Math.max(size.height, ((Icon) value).getIconHeight());
}
if (!(value instanceof Icon) && !(value instanceof DropShadowBorder)) { if (!(value instanceof Icon) && !(value instanceof DropShadowBorder)) {
g.setColor(new JPanel().getBackground()); g.setColor(new JPanel().getBackground());
g.fillRect(0, 0, SAMPLE_WIDTH, SAMPLE_HEIGHT); g.fillRect(0, 0, size.width, size.height);
} }
comp.setBounds(0, 0, SAMPLE_WIDTH, SAMPLE_HEIGHT); comp.setBounds(0, 0, size.width, size.height);
comp.setOpaque(false); comp.setOpaque(false);
comp.paint(g); comp.paint(g);
g.dispose(); g.dispose();

Loading…
Cancel
Save