Compare commits
2 Commits
0067726c33
...
c5046bbb4b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c5046bbb4b | ||
![]() |
a49ac11f66 |
49
pom.xml
49
pom.xml
@ -1,15 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.atriasoft</groupId>
|
<groupId>org.atriasoft</groupId>
|
||||||
<artifactId>etk</artifactId>
|
<artifactId>etk</artifactId>
|
||||||
<version>0.1.0</version>
|
<version>0.1.0</version>
|
||||||
<properties>
|
<licenses>
|
||||||
<maven.compiler.version>3.13.0</maven.compiler.version>
|
<license>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<name>Mozilla Public License 2.0</name>
|
||||||
<maven.compiler.target>21</maven.compiler.target>
|
<url>https://opensource.org/licenses/MPL-2.0</url>
|
||||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
<distribution>repo</distribution>
|
||||||
</properties>
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>dev1</id>
|
||||||
|
<name>Edouard DUPIN</name>
|
||||||
|
<email>edouard.dupin@proton.me</email>
|
||||||
|
<roles>
|
||||||
|
<role>Lead Developer</role>
|
||||||
|
</roles>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>gitea</id>
|
<id>gitea</id>
|
||||||
@ -37,35 +49,34 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
<artifactId>spotbugs-annotations</artifactId>
|
<artifactId>spotbugs-annotations</artifactId>
|
||||||
<version>4.8.5</version>
|
<version>4.8.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.11.0-M2</version>
|
<version>5.11.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src/main</sourceDirectory>
|
||||||
<testSourceDirectory>test/src</testSourceDirectory>
|
<testSourceDirectory>src/test</testSourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven.compiler.version}</version>
|
<version>3.14.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${maven.compiler.source}</source>
|
<source>21</source>
|
||||||
<target>${maven.compiler.target}</target>
|
<target>21</target>
|
||||||
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Create the source bundle -->
|
<!-- Create the source bundle -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>4.0.0-beta-1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
@ -79,7 +90,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.0.0-M5</version>
|
<version>3.2.5</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
@ -98,7 +109,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>private</show>
|
<show>private</show>
|
||||||
<nohelp>true</nohelp>
|
<nohelp>true</nohelp>
|
||||||
@ -112,7 +123,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>public</show>
|
<show>public</show>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -4,7 +4,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.atriasoft.etk.math.FMath;
|
import org.atriasoft.etk.math.FMath;
|
||||||
|
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
public record Color(
|
public record Color(
|
||||||
float r,
|
float r,
|
||||||
@ -332,35 +331,35 @@ public record Color(
|
|||||||
// #RGBA
|
// #RGBA
|
||||||
// #RRGGBB
|
// #RRGGBB
|
||||||
// #RRGGBBAA
|
// #RRGGBBAA
|
||||||
switch (color.length()) {
|
return switch (color.length()) {
|
||||||
case 4 -> {
|
case 4 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 2), 16) / 15.0f;
|
final float r = Integer.parseInt(color.substring(1, 2), 16) / 15.0f;
|
||||||
final float g = Integer.parseInt(color.substring(2, 3), 16) / 15.0f;
|
final float g = Integer.parseInt(color.substring(2, 3), 16) / 15.0f;
|
||||||
final float b = Integer.parseInt(color.substring(3, 4), 16) / 15.0f;
|
final float b = Integer.parseInt(color.substring(3, 4), 16) / 15.0f;
|
||||||
return new Color(r, g, b);
|
yield new Color(r, g, b);
|
||||||
}
|
}
|
||||||
case 5 -> {
|
case 5 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 2), 16) / 15.0f;
|
final float r = Integer.parseInt(color.substring(1, 2), 16) / 15.0f;
|
||||||
final float g = Integer.parseInt(color.substring(2, 3), 16) / 15.0f;
|
final float g = Integer.parseInt(color.substring(2, 3), 16) / 15.0f;
|
||||||
final float b = Integer.parseInt(color.substring(3, 4), 16) / 15.0f;
|
final float b = Integer.parseInt(color.substring(3, 4), 16) / 15.0f;
|
||||||
final float a = Integer.parseInt(color.substring(4, 5), 16) / 15.0f;
|
final float a = Integer.parseInt(color.substring(4, 5), 16) / 15.0f;
|
||||||
return new Color(r, g, b, a);
|
yield new Color(r, g, b, a);
|
||||||
}
|
}
|
||||||
case 7 -> {
|
case 7 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 3), 16) / 255.0f;
|
final float r = Integer.parseInt(color.substring(1, 3), 16) / 255.0f;
|
||||||
final float g = Integer.parseInt(color.substring(3, 5), 16) / 255.0f;
|
final float g = Integer.parseInt(color.substring(3, 5), 16) / 255.0f;
|
||||||
final float b = Integer.parseInt(color.substring(5, 7), 16) / 255.0f;
|
final float b = Integer.parseInt(color.substring(5, 7), 16) / 255.0f;
|
||||||
return new Color(r, g, b);
|
yield new Color(r, g, b);
|
||||||
}
|
}
|
||||||
case 9 -> {
|
case 9 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 3), 16) / 255.0f;
|
final float r = Integer.parseInt(color.substring(1, 3), 16) / 255.0f;
|
||||||
final float g = Integer.parseInt(color.substring(3, 5), 16) / 255.0f;
|
final float g = Integer.parseInt(color.substring(3, 5), 16) / 255.0f;
|
||||||
final float b = Integer.parseInt(color.substring(5, 7), 16) / 255.0f;
|
final float b = Integer.parseInt(color.substring(5, 7), 16) / 255.0f;
|
||||||
final float a = Integer.parseInt(color.substring(7, 9), 16) / 255.0f;
|
final float a = Integer.parseInt(color.substring(7, 9), 16) / 255.0f;
|
||||||
return new Color(r, g, b, a);
|
yield new Color(r, g, b, a);
|
||||||
}
|
}
|
||||||
default -> throw new Exception("Can not parse color ... '" + colorBase + "'");
|
default -> throw new Exception("Can not parse color ... '" + colorBase + "'");
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
// Model: r.r,g.g,b.b
|
// Model: r.r,g.g,b.b
|
||||||
// r.r,g.g,b.b,a.a
|
// r.r,g.g,b.b,a.a
|
||||||
@ -416,35 +415,35 @@ public record Color(
|
|||||||
// #RGBA
|
// #RGBA
|
||||||
// #RRGGBB
|
// #RRGGBB
|
||||||
// #RRGGBBAA
|
// #RRGGBBAA
|
||||||
switch (color.length()) {
|
return switch (color.length()) {
|
||||||
case 4 -> {
|
case 4 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 2), 16) * 255.0f * 16.0f;
|
final float r = Integer.parseInt(color.substring(1, 2), 16) * 255.0f * 16.0f;
|
||||||
final float g = Integer.parseInt(color.substring(2, 3), 16) * 255.0f * 16.0f;
|
final float g = Integer.parseInt(color.substring(2, 3), 16) * 255.0f * 16.0f;
|
||||||
final float b = Integer.parseInt(color.substring(3, 4), 16) * 255.0f * 16.0f;
|
final float b = Integer.parseInt(color.substring(3, 4), 16) * 255.0f * 16.0f;
|
||||||
return new Color(r, g, b);
|
yield new Color(r, g, b);
|
||||||
}
|
}
|
||||||
case 5 -> {
|
case 5 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 2), 16) * 255.0f * 16.0f;
|
final float r = Integer.parseInt(color.substring(1, 2), 16) * 255.0f * 16.0f;
|
||||||
final float g = Integer.parseInt(color.substring(2, 3), 16) * 255.0f * 16.0f;
|
final float g = Integer.parseInt(color.substring(2, 3), 16) * 255.0f * 16.0f;
|
||||||
final float b = Integer.parseInt(color.substring(3, 4), 16) * 255.0f * 16.0f;
|
final float b = Integer.parseInt(color.substring(3, 4), 16) * 255.0f * 16.0f;
|
||||||
final float a = Integer.parseInt(color.substring(4, 5), 16) * 255.0f * 16.0f;
|
final float a = Integer.parseInt(color.substring(4, 5), 16) * 255.0f * 16.0f;
|
||||||
return new Color(r, g, b, a);
|
yield new Color(r, g, b, a);
|
||||||
}
|
}
|
||||||
case 7 -> {
|
case 7 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 3), 16) * 255.0f;
|
final float r = Integer.parseInt(color.substring(1, 3), 16) * 255.0f;
|
||||||
final float g = Integer.parseInt(color.substring(3, 5), 16) * 255.0f;
|
final float g = Integer.parseInt(color.substring(3, 5), 16) * 255.0f;
|
||||||
final float b = Integer.parseInt(color.substring(5, 7), 16) * 255.0f;
|
final float b = Integer.parseInt(color.substring(5, 7), 16) * 255.0f;
|
||||||
return new Color(r, g, b);
|
yield new Color(r, g, b);
|
||||||
}
|
}
|
||||||
case 9 -> {
|
case 9 -> {
|
||||||
final float r = Integer.parseInt(color.substring(1, 3), 16) * 255.0f;
|
final float r = Integer.parseInt(color.substring(1, 3), 16) * 255.0f;
|
||||||
final float g = Integer.parseInt(color.substring(3, 5), 16) * 255.0f;
|
final float g = Integer.parseInt(color.substring(3, 5), 16) * 255.0f;
|
||||||
final float b = Integer.parseInt(color.substring(5, 7), 16) * 255.0f;
|
final float b = Integer.parseInt(color.substring(5, 7), 16) * 255.0f;
|
||||||
final float a = Integer.parseInt(color.substring(7, 9), 16) * 255.0f;
|
final float a = Integer.parseInt(color.substring(7, 9), 16) * 255.0f;
|
||||||
return new Color(r, g, b, a);
|
yield new Color(r, g, b, a);
|
||||||
}
|
}
|
||||||
default -> throw new Exception("Can not parse color ... '" + colorBase + "'");
|
default -> throw new Exception("Can not parse color ... '" + colorBase + "'");
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
// Model: r.r,g.g,b.b
|
// Model: r.r,g.g,b.b
|
||||||
// r.r,g.g,b.b,a.a
|
// r.r,g.g,b.b,a.a
|
||||||
@ -513,6 +512,18 @@ public record Color(
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "rgba(" + this.r + ", " + this.g + ", " + this.b + ", " + this.a + ")";
|
return "rgba(" + this.r + ", " + this.g + ", " + this.b + ", " + this.a + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toStringSharp() {
|
||||||
|
final StringBuilder out = new StringBuilder();
|
||||||
|
out.append("#");
|
||||||
|
out.append(String.format("%02X", Math.round(this.r * 255)));
|
||||||
|
out.append(String.format("%02X", Math.round(this.g * 255)));
|
||||||
|
out.append(String.format("%02X", Math.round(this.b * 255)));
|
||||||
|
if (this.a <= 0.999999) {
|
||||||
|
out.append(String.format("%02X", Math.round(this.a * 255)));
|
||||||
|
}
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public Color withR(final float value) {
|
public Color withR(final float value) {
|
||||||
return new Color(value, this.g, this.b, this.a);
|
return new Color(value, this.g, this.b, this.a);
|
@ -67,6 +67,14 @@ public class Uri {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAllDataString(final Uri resourceName) {
|
||||||
|
final byte[] data = getAllData(resourceName);
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new String(data);
|
||||||
|
}
|
||||||
|
|
||||||
private static List<String> getResourceFiles(final Class<?> clazz, final String path) throws IOException {
|
private static List<String> getResourceFiles(final Class<?> clazz, final String path) throws IOException {
|
||||||
final List<String> filenames = new ArrayList<>();
|
final List<String> filenames = new ArrayList<>();
|
||||||
|
|
||||||
@ -121,7 +129,7 @@ public class Uri {
|
|||||||
out = Uri.applicationClass.getResourceAsStream("/" + tmpPath);
|
out = Uri.applicationClass.getResourceAsStream("/" + tmpPath);
|
||||||
|
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
LOGGER.error("(appl) ==> element does not exist ... {}", uri);
|
LOGGER.trace("(appl) ==> element does not exist ... {} => {}", uri, tmpPath);
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
LOGGER.warn("elements: " + getResourceFiles(applicationClass,
|
LOGGER.warn("elements: " + getResourceFiles(applicationClass,
|
@ -1,12 +0,0 @@
|
|||||||
/** Basic module interface.
|
|
||||||
*
|
|
||||||
* @author Edouard DUPIN */
|
|
||||||
|
|
||||||
open module org.atriasoft.etk {
|
|
||||||
exports org.atriasoft.etk;
|
|
||||||
exports org.atriasoft.etk.math;
|
|
||||||
exports org.atriasoft.etk.util;
|
|
||||||
|
|
||||||
requires transitive org.slf4j;
|
|
||||||
requires com.github.spotbugs.annotations;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user