From c27282041fb104498b799501da07f5332b9b2b31 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 7 Jun 2024 09:28:33 +0200 Subject: [PATCH] [FEAT] use Maven a build system root tool --- .classpath | 30 ++--- .project | 18 +-- lutin_org-atriasoft-iogami.py | 2 +- pom.xml | 138 +++++++++++++++++++++ src/module-info.java | 3 +- src/org/atriasoft/iogami/IOgami.java | 45 ++++--- src/org/atriasoft/iogami/internal/Log.java | 76 ------------ 7 files changed, 176 insertions(+), 136 deletions(-) create mode 100644 pom.xml delete mode 100644 src/org/atriasoft/iogami/internal/Log.java diff --git a/.classpath b/.classpath index 43ab06e..3083ca1 100644 --- a/.classpath +++ b/.classpath @@ -1,35 +1,27 @@ - - + - + + - + + + - + - + - + - + - - - - - - - - - - - + diff --git a/.project b/.project index 32e351f..610de38 100644 --- a/.project +++ b/.project @@ -1,9 +1,8 @@ - atriasoft-io-gami + io-gami - atriasoft-io-gami @@ -12,24 +11,13 @@ - net.sf.eclipsecs.core.CheckstyleBuilder + org.eclipse.m2e.core.maven2Builder org.eclipse.jdt.core.javanature - net.sf.eclipsecs.core.CheckstyleNature + org.eclipse.m2e.core.maven2Nature - - - 1646149232196 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - diff --git a/lutin_org-atriasoft-iogami.py b/lutin_org-atriasoft-iogami.py index a5156b5..bc6cba0 100644 --- a/lutin_org-atriasoft-iogami.py +++ b/lutin_org-atriasoft-iogami.py @@ -33,7 +33,7 @@ def configure(target, my_module): my_module.add_src_file([ 'src/module-info.java', 'src/org/atriasoft/iogami/IOgami.java', - 'src/org/atriasoft/iogami/internal/Log.java', + 'src/org/atriasoft/iogami/internal/LOGGER.java', ]) my_module.add_path('src/', type='java') diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b529265 --- /dev/null +++ b/pom.xml @@ -0,0 +1,138 @@ + + 4.0.0 + org.atriasoft + io-gami + 0.1.0 + + 3.13.0 + 21 + 21 + 3.1.1 + + + + + gitea + https://gitea.atria-soft.org/api/packages/org.atriasoft/maven + + + + + gitea + https://gitea.atria-soft.org/api/packages/org.atriasoft/maven + + + gitea + https://gitea.atria-soft.org/api/packages/org.atriasoft/maven + + + + + + org.atriasoft + png-decoder + 0.1.0 + + + org.atriasoft + png-encoder + 0.1.0 + + + org.atriasoft + esvg + 0.1.0 + + + org.atriasoft + egami + 0.1.0 + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + org.slf4j + slf4j-simple + 2.0.7 + test + + + + + src + test/src + ${project.basedir}/out/maven/ + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + maven-assembly-plugin + + + + fully.qualified.MainClass + + + + jar-with-dependencies + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + private + true + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + public + + + + + + diff --git a/src/module-info.java b/src/module-info.java index 27b3a74..5f8831c 100644 --- a/src/module-info.java +++ b/src/module-info.java @@ -4,10 +4,9 @@ open module org.atriasoft.iogami { exports org.atriasoft.iogami; - + requires transitive org.atriasoft.etk; requires org.atriasoft.esvg; - requires transitive org.atriasoft.reggol; requires org.atriasoft.pngdecoder; requires org.atriasoft.pngencoder; requires transitive org.atriasoft.egami; diff --git a/src/org/atriasoft/iogami/IOgami.java b/src/org/atriasoft/iogami/IOgami.java index 5e02a44..54c3aa5 100644 --- a/src/org/atriasoft/iogami/IOgami.java +++ b/src/org/atriasoft/iogami/IOgami.java @@ -1,29 +1,28 @@ package org.atriasoft.iogami; -import org.atriasoft.etk.Uri; -import org.atriasoft.etk.math.Vector2i; - import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; +import org.atriasoft.egami.Image; +import org.atriasoft.egami.ImageByte; import org.atriasoft.egami.ImageByteRGB; import org.atriasoft.egami.ImageByteRGBA; import org.atriasoft.egami.ToolImage; import org.atriasoft.esvg.EsvgDocument; -import org.atriasoft.egami.Image; -import org.atriasoft.egami.ImageByte; -import org.atriasoft.iogami.internal.Log; - -import org.atriasoft.pngencoder.PngEncoder; - +import org.atriasoft.etk.Uri; +import org.atriasoft.etk.math.Vector2i; import org.atriasoft.pngdecoder.PNGDecoder; import org.atriasoft.pngdecoder.PNGDecoder.Format; +import org.atriasoft.pngencoder.PngEncoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class IOgami { - + static final Logger LOGGER = LoggerFactory.getLogger(IOgami.class); + public static ImageByte load(final Uri uri, final Vector2i size) { - Log.todo("Load image : " + uri + " size=" + size); + LOGGER.info("TODO: Load image : " + uri + " size=" + size); if (uri.get().endsWith(".png")) { return IOgami.loadPNG(uri); } @@ -32,7 +31,7 @@ public class IOgami { } return null; } - + private static ImageByte loadPNG(final Uri filename) { ByteBuffer buf = null; int tWidth = 0; @@ -62,10 +61,10 @@ public class IOgami { System.err.println("try to load texture " + filename + ", didn't work"); System.exit(-1); } - byte[] elemData = new byte[buf.remaining()]; + final byte[] elemData = new byte[buf.remaining()]; buf.get(elemData); if (hasAlpha) { - ImageByteRGBA img = new ImageByteRGBA(tWidth, tHeight); + final ImageByteRGBA img = new ImageByteRGBA(tWidth, tHeight); for (int yyy = 0; yyy < tHeight; yyy++) { for (int xxx = 0; xxx < tWidth; xxx++) { img.setRByte(xxx, yyy, elemData[(yyy * tWidth + xxx) * 4 + 0]); @@ -76,7 +75,7 @@ public class IOgami { } return img; } - ImageByteRGB img = new ImageByteRGB(tWidth, tHeight); + final ImageByteRGB img = new ImageByteRGB(tWidth, tHeight); for (int yyy = 0; yyy < tHeight; yyy++) { for (int xxx = 0; xxx < tWidth; xxx++) { img.setAFloat(xxx, yyy, 0xFF); @@ -87,20 +86,20 @@ public class IOgami { } return img; } - + private static ImageByte loadSVG(final Uri filename, final Vector2i size) { - EsvgDocument doc = new EsvgDocument(); + final EsvgDocument doc = new EsvgDocument(); doc.load(filename); return ToolImage.convertImageByte(doc.renderImageFloatRGBA(size)); - + } - + public static void storePNG(final Uri uri, final Image data) { - Log.info("Store image : " + uri + " size=" + data.getSize()); - Log.warning("Save file in " + uri.getPath()); + LOGGER.info("Store image : " + uri + " size=" + data.getSize()); + LOGGER.warn("Save file in " + uri.getPath()); new PngEncoder().withBufferedImage(data).withCompressionLevel(9).toFile(uri.getPath()); - + } - + private IOgami() {} } diff --git a/src/org/atriasoft/iogami/internal/Log.java b/src/org/atriasoft/iogami/internal/Log.java deleted file mode 100644 index ee6d845..0000000 --- a/src/org/atriasoft/iogami/internal/Log.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.atriasoft.iogami.internal; - -import org.atriasoft.reggol.LogLevel; -import org.atriasoft.reggol.Logger; - -public class Log { - private static final boolean FORCE_ALL = false; - private static final String LIB_NAME = "iogami"; - private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME); - private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL); - private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG); - private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR); - private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO); - private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT); - private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO); - private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE); - private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING); - - public static void critical(final Exception e, final String data) { - e.printStackTrace(); - if (PRINT_CRITICAL || FORCE_ALL) { - Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage()); - } - } - - public static void critical(final String data, final Object... objects) { - if (PRINT_CRITICAL || FORCE_ALL) { - Logger.critical(LIB_NAME_DRAW, data, objects); - } - } - - public static void debug(final String data, final Object... objects) { - if (PRINT_DEBUG || FORCE_ALL) { - Logger.debug(LIB_NAME_DRAW, data, objects); - } - } - - public static void error(final String data, final Object... objects) { - if (PRINT_ERROR || FORCE_ALL) { - Logger.error(LIB_NAME_DRAW, data, objects); - } - } - - public static void info(final String data, final Object... objects) { - if (PRINT_INFO || FORCE_ALL) { - Logger.info(LIB_NAME_DRAW, data, objects); - } - } - - public static void print(final String data, final Object... objects) { - if (PRINT_PRINT || FORCE_ALL) { - Logger.print(LIB_NAME_DRAW, data, objects); - } - } - - public static void todo(final String data, final Object... objects) { - if (PRINT_TODO || FORCE_ALL) { - Logger.todo(LIB_NAME_DRAW, data, objects); - } - } - - public static void verbose(final String data, final Object... objects) { - if (PRINT_VERBOSE || FORCE_ALL) { - Logger.verbose(LIB_NAME_DRAW, data, objects); - } - } - - public static void warning(final String data, final Object... objects) { - if (PRINT_WARNING || FORCE_ALL) { - Logger.warning(LIB_NAME_DRAW, data, objects); - } - } - - private Log() {} - -}