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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.atriasoft</groupId>
|
||||
<artifactId>etk</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<properties>
|
||||
<maven.compiler.version>3.13.0</maven.compiler.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
||||
</properties>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Mozilla Public License 2.0</name>
|
||||
<url>https://opensource.org/licenses/MPL-2.0</url>
|
||||
<distribution>repo</distribution>
|
||||
</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>
|
||||
<repository>
|
||||
<id>gitea</id>
|
||||
@ -37,35 +49,34 @@
|
||||
<dependency>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-annotations</artifactId>
|
||||
<version>4.8.5</version>
|
||||
<version>4.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.11.0-M2</version>
|
||||
<version>5.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test/src</testSourceDirectory>
|
||||
<sourceDirectory>src/main</sourceDirectory>
|
||||
<testSourceDirectory>src/test</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven.compiler.version}</version>
|
||||
<version>3.14.0</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<!--<encoding>${project.build.sourceEncoding}</encoding>-->
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Create the source bundle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>4.0.0-beta-1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
@ -79,7 +90,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
@ -98,7 +109,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<show>private</show>
|
||||
<nohelp>true</nohelp>
|
||||
@ -112,7 +123,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
|
@ -4,7 +4,6 @@ import java.util.Map;
|
||||
|
||||
import org.atriasoft.etk.math.FMath;
|
||||
|
||||
|
||||
//@formatter:off
|
||||
public record Color(
|
||||
float r,
|
||||
@ -332,35 +331,35 @@ public record Color(
|
||||
// #RGBA
|
||||
// #RRGGBB
|
||||
// #RRGGBBAA
|
||||
switch (color.length()) {
|
||||
return switch (color.length()) {
|
||||
case 4 -> {
|
||||
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 b = Integer.parseInt(color.substring(3, 4), 16) / 15.0f;
|
||||
return new Color(r, g, b);
|
||||
yield new Color(r, g, b);
|
||||
}
|
||||
case 5 -> {
|
||||
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 b = Integer.parseInt(color.substring(3, 4), 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 -> {
|
||||
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 b = Integer.parseInt(color.substring(5, 7), 16) / 255.0f;
|
||||
return new Color(r, g, b);
|
||||
yield new Color(r, g, b);
|
||||
}
|
||||
case 9 -> {
|
||||
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 b = Integer.parseInt(color.substring(5, 7), 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 + "'");
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// Model: r.r,g.g,b.b
|
||||
// r.r,g.g,b.b,a.a
|
||||
@ -416,35 +415,35 @@ public record Color(
|
||||
// #RGBA
|
||||
// #RRGGBB
|
||||
// #RRGGBBAA
|
||||
switch (color.length()) {
|
||||
return switch (color.length()) {
|
||||
case 4 -> {
|
||||
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 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 -> {
|
||||
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 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;
|
||||
return new Color(r, g, b, a);
|
||||
yield new Color(r, g, b, a);
|
||||
}
|
||||
case 7 -> {
|
||||
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 b = Integer.parseInt(color.substring(5, 7), 16) * 255.0f;
|
||||
return new Color(r, g, b);
|
||||
yield new Color(r, g, b);
|
||||
}
|
||||
case 9 -> {
|
||||
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 b = Integer.parseInt(color.substring(5, 7), 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 + "'");
|
||||
}
|
||||
};
|
||||
} else {
|
||||
// Model: r.r,g.g,b.b
|
||||
// r.r,g.g,b.b,a.a
|
||||
@ -513,6 +512,18 @@ public record Color(
|
||||
public String toString() {
|
||||
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) {
|
||||
return new Color(value, this.g, this.b, this.a);
|
@ -67,6 +67,14 @@ public class Uri {
|
||||
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 {
|
||||
final List<String> filenames = new ArrayList<>();
|
||||
|
||||
@ -121,7 +129,7 @@ public class Uri {
|
||||
out = Uri.applicationClass.getResourceAsStream("/" + tmpPath);
|
||||
|
||||
if (out == null) {
|
||||
LOGGER.error("(appl) ==> element does not exist ... {}", uri);
|
||||
LOGGER.trace("(appl) ==> element does not exist ... {} => {}", uri, tmpPath);
|
||||
/*
|
||||
try {
|
||||
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