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
on:
push:
branches:
- '*'
paths:
- '**.properties'
pull_request:
paths:
- '**.properties'
jobs:
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,
final float shadowOpacity, final int cornerSize, final boolean showTopShadow,
final boolean showLeftShadow, final boolean showBottomShadow, final boolean showRightShadow) {
this.shadowColor = shadowColor;
this.shadowSize = shadowSize;
this.shadowOpacity = shadowOpacity;
this.cornerSize = cornerSize;
this.showTopShadow = showTopShadow;
this.showLeftShadow = showLeftShadow;
this.showBottomShadow = showBottomShadow;
this.showRightShadow = showRightShadow;
setShadowColor(shadowColor);
setShadowSize(shadowSize);
setShadowOpacity(shadowOpacity);
setCornerSize(cornerSize);
setShowTopShadow(showTopShadow);
setShowLeftShadow(showLeftShadow);
setShowBottomShadow(showBottomShadow);
setShowRightShadow(showRightShadow);
}
@ -411,6 +411,7 @@ public class DropShadowBorder implements Border, Serializable {
public DropShadowBorder setShadowColor(final Color shadowColor) {
this.shadowColor = shadowColor;
if (shadowColor == null) this.shadowColor = Color.BLACK;
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.checkIcon = empty(7,7)
Menu.checkIcon = empty(7,7)
CheckBoxMenuItem.checkIcon = empty(19,19)
CheckBoxMenuItem.arrowIcon = empty(16,16)
CheckBoxMenuItem.dashIcon = empty(0,0)
RadioButtonMenuItem.checkIcon = empty(19,19)
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) {
String stringRepresentation = parseValue(value).replaceAll(" ", "");
String path;
Dimension size = new Dimension(SAMPLE_WIDTH, SAMPLE_HEIGHT);
try {
if (!(value instanceof Icon)) {
path = createImage(value, stringRepresentation);
path = createImage(value, stringRepresentation, size);
} else {
path = createImage(value, key);
path = createImage(value, key, size);
}
} catch (IOException ignored) {
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);
}
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();
String fileName = "img/" + name + ".png";
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);
BufferedImage image = ImageUtil.createCompatibleTranslucentImage(SAMPLE_WIDTH, SAMPLE_HEIGHT);
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)) {
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.paint(g);
g.dispose();

Loading…
Cancel
Save