Compare commits
No commits in common. "c5046bbb4bdf9c04f1ca394d54017132bd49f9ec" and "0067726c33d5baaf4249ab644c6732827f90879a" have entirely different histories.
c5046bbb4b
...
0067726c33
49
pom.xml
49
pom.xml
@ -1,27 +1,15 @@
|
|||||||
<?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>
|
||||||
<licenses>
|
<properties>
|
||||||
<license>
|
<maven.compiler.version>3.13.0</maven.compiler.version>
|
||||||
<name>Mozilla Public License 2.0</name>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<url>https://opensource.org/licenses/MPL-2.0</url>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
<distribution>repo</distribution>
|
<maven.dependency.version>3.1.1</maven.dependency.version>
|
||||||
</license>
|
</properties>
|
||||||
</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>
|
||||||
@ -49,34 +37,35 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.spotbugs</groupId>
|
<groupId>com.github.spotbugs</groupId>
|
||||||
<artifactId>spotbugs-annotations</artifactId>
|
<artifactId>spotbugs-annotations</artifactId>
|
||||||
<version>4.8.6</version>
|
<version>4.8.5</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</version>
|
<version>5.11.0-M2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<testSourceDirectory>src/test</testSourceDirectory>
|
<testSourceDirectory>test/src</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>3.14.0</version>
|
<version>${maven.compiler.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>21</source>
|
<source>${maven.compiler.source}</source>
|
||||||
<target>21</target>
|
<target>${maven.compiler.target}</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>4.0.0-beta-1</version>
|
<version>3.3.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
@ -90,7 +79,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.2.5</version>
|
<version>3.0.0-M5</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
@ -109,7 +98,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.3.0</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>private</show>
|
<show>private</show>
|
||||||
<nohelp>true</nohelp>
|
<nohelp>true</nohelp>
|
||||||
@ -123,7 +112,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.3.0</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>public</show>
|
<show>public</show>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
12
src/module-info.java
Normal file
12
src/module-info.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/** 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;
|
||||||
|
}
|
@ -4,6 +4,7 @@ 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,
|
||||||
@ -331,35 +332,35 @@ public record Color(
|
|||||||
// #RGBA
|
// #RGBA
|
||||||
// #RRGGBB
|
// #RRGGBB
|
||||||
// #RRGGBBAA
|
// #RRGGBBAA
|
||||||
return switch (color.length()) {
|
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;
|
||||||
yield new Color(r, g, b);
|
return 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;
|
||||||
yield new Color(r, g, b, a);
|
return 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;
|
||||||
yield new Color(r, g, b);
|
return 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;
|
||||||
yield new Color(r, g, b, a);
|
return 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
|
||||||
@ -415,35 +416,35 @@ public record Color(
|
|||||||
// #RGBA
|
// #RGBA
|
||||||
// #RRGGBB
|
// #RRGGBB
|
||||||
// #RRGGBBAA
|
// #RRGGBBAA
|
||||||
return switch (color.length()) {
|
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;
|
||||||
yield new Color(r, g, b);
|
return 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;
|
||||||
yield new Color(r, g, b, a);
|
return 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;
|
||||||
yield new Color(r, g, b);
|
return 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;
|
||||||
yield new Color(r, g, b, a);
|
return 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
|
||||||
@ -512,18 +513,6 @@ 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,14 +67,6 @@ 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<>();
|
||||||
|
|
||||||
@ -129,7 +121,7 @@ public class Uri {
|
|||||||
out = Uri.applicationClass.getResourceAsStream("/" + tmpPath);
|
out = Uri.applicationClass.getResourceAsStream("/" + tmpPath);
|
||||||
|
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
LOGGER.trace("(appl) ==> element does not exist ... {} => {}", uri, tmpPath);
|
LOGGER.error("(appl) ==> element does not exist ... {}", uri);
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
LOGGER.warn("elements: " + getResourceFiles(applicationClass,
|
LOGGER.warn("elements: " + getResourceFiles(applicationClass,
|
Loading…
x
Reference in New Issue
Block a user