Browse Source

Parser: Change inline prefix from `#` to '%'

Previously inline color declarations would need to be declared with two leading `#` being error prone to forgetting the second `#`.
modulesv2
weisj 3 years ago
parent
commit
bea1b8c55e
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 2
      core/src/test/resources/com/github/weisj/darklaf/icon/addEntry.svg
  2. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/errorDialog.svg
  3. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/informationDialog.svg
  4. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/questionDialog.svg
  5. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/warningDialog.svg
  6. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/drive.svg
  7. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/folder.svg
  8. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/general.svg
  9. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/image.svg
  10. 6
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/missingImage.svg
  11. 6
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/pendingImage.svg
  12. 4
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/text.svg
  13. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/upFolder.svg
  14. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/menu/helpHighlight.svg
  15. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/misc/pipetteRollover.svg
  16. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/arrowDivider.svg
  17. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/close.svg
  18. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/closeDisabled.svg
  19. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/closeHovered.svg
  20. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/collapse.svg
  21. 2
      iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/moreTabs.svg
  22. 6
      property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconColorMapper.java
  23. 3
      property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserUtil.java
  24. 7
      utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java

2
core/src/test/resources/com/github/weisj/darklaf/icon/addEntry.svg

@ -4,7 +4,7 @@
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
<linearGradient id="informationIconColor" fallback="#0000FF">
<linearGradient id="informationIconColor" fallback="%#0000FF">
<stop offset="0" stop-color="#3592C4"/>
<stop offset="1" stop-color="#3592C4"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 790 B

After

Width:  |  Height:  |  Size: 791 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/errorDialog.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<defs id="colors">
<linearGradient id="errorIconColor" fallback="#FF0000">
<linearGradient id="errorIconColor" fallback="%#FF0000">
<stop offset="0" stop-color="#C75450"/>
<stop offset="1" stop-color="#C75450"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 604 B

After

Width:  |  Height:  |  Size: 605 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/informationDialog.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<defs id="colors">
<linearGradient id="informationIconColor" fallback="#0000FF">
<linearGradient id="informationIconColor" fallback="%#0000FF">
<stop offset="0" stop-color="#3592C4"/>
<stop offset="1" stop-color="#3592C4"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 656 B

After

Width:  |  Height:  |  Size: 657 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/questionDialog.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<defs id="colors">
<linearGradient id="questionIconColor" fallback="#00FF00">
<linearGradient id="questionIconColor" fallback="%#00FF00">
<stop offset="0" stop-color="#3592C4"/>
<stop offset="1" stop-color="#3592C4"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 773 B

After

Width:  |  Height:  |  Size: 774 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/dialog/warningDialog.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<defs id="colors">
<linearGradient id="warningIconColor" fallback="#FFFF00">
<linearGradient id="warningIconColor" fallback="%#FFFF00">
<stop offset="0" stop-color="#F0A732"/>
<stop offset="1" stop-color="#F0A732"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 500 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/drive.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 1015 B

After

Width:  |  Height:  |  Size: 1015 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/folder.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 635 B

After

Width:  |  Height:  |  Size: 635 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/general.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 628 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/image.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

6
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/missingImage.svg

@ -1,6 +1,6 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>
@ -12,12 +12,12 @@
<stop offset="0" stop-color="#62B543"/>
<stop offset="1" stop-color="#62B543"/>
</linearGradient>
<linearGradient id="errorIconColor" fallback="#FF0000">
<linearGradient id="errorIconColor" fallback="%#FF0000">
<stop offset="0" stop-color="#DB5860"/>
<stop offset="1" stop-color="#DB5860"/>
</linearGradient>
<linearGradient id="fileIconForeground" fallback="Label.background"
opacity="fileIconOpacity" opacity-fallback="#100">
opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#231F20" stop-opacity=".8"/>
<stop offset="1" stop-color="#231F20" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

6
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/pendingImage.svg

@ -1,6 +1,6 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>
@ -12,12 +12,12 @@
<stop offset="0" stop-color="#62B543"/>
<stop offset="1" stop-color="#62B543"/>
</linearGradient>
<linearGradient id="warningIconColor" fallback="#FFFF00">
<linearGradient id="warningIconColor" fallback="%FFFF00">
<stop offset="0" stop-color="#e2a53a"/>
<stop offset="1" stop-color="#e2a53a"/>
</linearGradient>
<linearGradient id="fileIconForeground" fallback="Label.background"
opacity="fileIconOpacity" opacity-fallback="#100">
opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#231F20" stop-opacity=".8"/>
<stop offset="1" stop-color="#231F20" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

4
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/text.svg

@ -1,10 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>
<linearGradient id="fileIconForeground" fallback="Label.background" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconForeground" fallback="Label.background" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#231F20" stop-opacity=".8"/>
<stop offset="1" stop-color="#231F20" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/files/upFolder.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="#100">
<linearGradient id="fileIconBackground" fallback="Label.foreground" opacity="fileIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#9AA7B0" stop-opacity=".8"/>
<stop offset="1" stop-color="#9AA7B0" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 952 B

After

Width:  |  Height:  |  Size: 952 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/menu/helpHighlight.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="questionIconColor" fallback="#00FF00">
<linearGradient id="questionIconColor" fallback="%#00FF00">
<stop offset="0" stop-color="#3592C4"/>
<stop offset="1" stop-color="#3592C4"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 545 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/misc/pipetteRollover.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="errorIconColor" fallback="#FF0000">
<linearGradient id="errorIconColor" fallback="%#FF0000">
<stop offset="0" stop-color="#C75450"/>
<stop offset="1" stop-color="#C75450"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 900 B

After

Width:  |  Height:  |  Size: 901 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/arrowDivider.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="menuIconOpacity" opacity-fallback="#100">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="menuIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#AFB1B3" stop-opacity=".8"/>
<stop offset="1" stop-color="#AFB1B3" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/close.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="navigationIconOpacity" opacity-fallback="#100">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="navigationIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#7F8B91" stop-opacity=".5"/>
<stop offset="1" stop-color="#7F8B91" stop-opacity=".5"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/closeDisabled.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="menuIconDisabled" fallback="Label.disabledForeground" opacity="menuIconOpacity" opacity-fallback="#100">
<linearGradient id="menuIconDisabled" fallback="Label.disabledForeground" opacity="menuIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#AFB1B3" stop-opacity=".8"/>
<stop offset="1" stop-color="#AFB1B3" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 624 B

After

Width:  |  Height:  |  Size: 624 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/closeHovered.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="navigationIconOpacity" opacity-fallback="#100">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="navigationIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#7F8B91" stop-opacity=".5"/>
<stop offset="1" stop-color="#7F8B91" stop-opacity=".5"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 645 B

After

Width:  |  Height:  |  Size: 645 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/collapse.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="menuIconOpacity" opacity-fallback="#100">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="menuIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#AFB1B3" stop-opacity=".8"/>
<stop offset="1" stop-color="#AFB1B3" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

2
iconset/src/main/resources/com/github/weisj/darklaf/iconset/navigation/moreTabs.svg

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="menuIconOpacity" opacity-fallback="#100">
<linearGradient id="menuIconEnabled" fallback="Label.foreground" opacity="menuIconOpacity" opacity-fallback="%100">
<stop offset="0" stop-color="#AFB1B3" stop-opacity=".8"/>
<stop offset="1" stop-color="#AFB1B3" stop-opacity=".8"/>
</linearGradient>

Before

Width:  |  Height:  |  Size: 816 B

After

Width:  |  Height:  |  Size: 816 B

6
property-loader/src/main/java/com/github/weisj/darklaf/properties/icons/IconColorMapper.java

@ -44,7 +44,7 @@ import com.kitfox.svg.xml.StyleAttribute;
/** @author Jannis Weis */
public final class IconColorMapper {
private static final String INLINE_VALUE_PREFIX = "#";
private static final String INLINE_VALUE_PREFIX = "%";
private static final Logger LOGGER = LogUtil.getLogger(IconLoader.class);
private static final Color FALLBACK_COLOR = Color.RED;
@ -129,8 +129,8 @@ public final class IconColorMapper {
finalOpacity2, opacity2);
themedDefs.loaderAddChild(null, result.gradient);
result.finalizer.run();
int resultRGB = result.gradient.getStopColors()[0].getRGB();
int expectedRGB = result.color.getRGB();
int resultRGB = ColorUtil.rgbNoAlpha(result.gradient.getStopColors()[0]);
int expectedRGB = ColorUtil.rgbNoAlpha(result.color);
if (expectedRGB != resultRGB) {
throw new IllegalStateException("Color not applied. Expected " + result.color + " but received "
+ result.gradient.getStopColors()[0] + " (rgb " + expectedRGB + " != " + resultRGB + ")");

3
property-loader/src/main/java/com/github/weisj/darklaf/properties/parser/ParserUtil.java

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
@ -46,7 +47,7 @@ final class ParserUtil implements Delimiters {
}
static void warning(final String message) {
LOGGER.warning(message);
LOGGER.log(Level.WARNING, message, new RuntimeException(message));
}
static ParseResult apply(final PropertyParser parser, final ParseResult p, final ParserContext c) {

7
utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java

@ -115,6 +115,13 @@ public final class ColorUtil {
return toAlpha(color, 255);
}
public static int rgbNoAlpha(final Color color) {
return ((0) << 24) |
((color.getRed() & 0xFF) << 16) |
((color.getGreen() & 0xFF) << 8) |
((color.getBlue() & 0xFF));
}
/**
* Calculate the perceived brightness of a color.
*

Loading…
Cancel
Save