partial commit

This commit is contained in:
Cavallium 2018-09-28 21:59:12 +02:00
parent 91e79b1c03
commit 1374c5598e
38 changed files with 160 additions and 124 deletions

2
Flow

@ -1 +1 @@
Subproject commit e1597fb7442120bf4722f5a412b1c5eb84ba2966
Subproject commit c58460e49af4036df9eecb8cac7be38717cbb29e

View File

@ -18,9 +18,8 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -1,2 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -9,7 +9,7 @@
<version>${project.version}</version>
</parent>
<artifactId>warppi-core</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<name>WarpPI Calculator Core</name>
<description>WarpPI Calculator core project</description>

View File

@ -133,7 +133,9 @@ public interface Platform {
@Deprecated()
File getResource(String string) throws IOException, URISyntaxException;
InputStream getResourceStream(String string) throws IOException, URISyntaxException;
boolean doesResourceExist(String string) throws IOException;
InputStream getResourceStream(String string) throws IOException;
List<String> readAllLines(File file) throws IOException;

View File

@ -293,7 +293,7 @@ public final class DisplayManager implements RenderingLoop {
}
private void load_skin() throws IOException {
guiSkin = engine.loadSkin("skin.png");
guiSkin = engine.loadSkin("/skin.png");
}
private void load_fonts() throws IOException {

View File

@ -29,27 +29,21 @@ public abstract class PngSkin implements Skin {
if (!file.startsWith("/")) {
file = "/" + file;
}
try {
if (!file.endsWith(".png")) {
final File f = File.createTempFile("picalculator-png", ".png");
f.deleteOnExit();
final BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream(file));
ImageIO.write(img, "PNG", f);
file = f.toString();
}
final PngReader r = Engine.getPlatform().getPngUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file));
if (r == null) {
skinData = new int[0];
skinSize = new int[] { 0, 0 };
System.err.println("ERROR WHILE LOADING SKIN " + file);
} else {
skinData = r.getImageMatrix();
skinSize = r.getSize();
}
} catch (final URISyntaxException e) {
final IOException ex = new IOException();
ex.initCause(e);
throw ex;
if (!file.endsWith(".png")) {
final File f = File.createTempFile("picalculator-png", ".png");
f.deleteOnExit();
final BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream(file));
ImageIO.write(img, "PNG", f);
file = f.toString();
}
final PngReader r = Engine.getPlatform().getPngUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file));
if (r == null) {
skinData = new int[0];
skinSize = new int[] { 0, 0 };
System.err.println("ERROR WHILE LOADING SKIN " + file);
} else {
skinData = r.getImageMatrix();
skinSize = r.getSize();
}
}

View File

@ -102,17 +102,10 @@ public abstract class RFTFont implements BinaryFont {
}
private void loadFont(String string) throws IOException {
InputStream res;
try {
if (!string.startsWith("/")) {
string = "/" + string;
}
res = Engine.getPlatform().getStorageUtils().getResourceStream(string);
} catch (final URISyntaxException e) {
final IOException ex = new IOException();
ex.initCause(e);
throw ex;
if (!string.startsWith("/")) {
string = "/" + string;
}
InputStream res = Engine.getPlatform().getStorageUtils().getResourceStream(string);
final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res, res.available()));
final int filelength = file.length;
if (filelength >= 16) {

View File

@ -45,19 +45,19 @@ public class MarioScreen extends Screen {
public void initialized() {
try {
if (MarioScreen.skin == null) {
MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioskin.png");
MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioskin.png");
}
if (MarioScreen.groundskin == null) {
MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioground.png");
MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("/marioground.png");
}
if (MarioScreen.gpuTest2 == null) {
try {
MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest2");
MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("/gputest2");
} catch (final Exception ex) {}
}
if (MarioScreen.gpuTest1 == null) {
try {
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest12");
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("/gputest12");
MarioScreen.gpuTest12 = true;
} catch (final Exception ex) {
MarioScreen.gpuTest12 = false;

View File

@ -178,7 +178,7 @@ public class RulesManager {
Engine.getPlatform().getStorageUtils();
Engine.getPlatform().getStorageUtils();
Engine.getPlatform().getStorageUtils().write(tFileJava, javaCode.getBytes("UTF-8"), StorageUtils.OpenOptionWrite, StorageUtils.OpenOptionCreate);
final boolean compiled = Engine.getPlatform().compile(new String[] { "-nowarn", "-1.8", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err));
final boolean compiled = Engine.getPlatform().compile(new String[] { "-nowarn", "-10", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err));
if (StaticVars.startupArguments.isUncached()) {
tFileJava.deleteOnExit();
} else {

View File

@ -18,9 +18,8 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -10,5 +10,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10

View File

@ -10,7 +10,7 @@
</parent>
<artifactId>warppi-desktop</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<name>WarpPI Calculator Desktop</name>
<description>WarpPI Calculator desktop project</description>
@ -36,9 +36,9 @@
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.14.0.v20171206-0802</version>
</dependency>
<dependency>
<groupId>ar.com.hjg</groupId>

View File

@ -91,8 +91,24 @@ public class DesktopStorageUtils implements StorageUtils {
return Paths.get(string.substring(1)).toFile();
}
@Override
public InputStream getResourceStream(String string) throws IOException, URISyntaxException {
public boolean doesResourceExist(String string) throws IOException {
final URL res = ClassUtils.classLoader.getResource(string);
final boolean isResource = res != null;
if (isResource) return true;
else {
if (string.length() > 0) {
final char ch = string.charAt(0);
if (ch == '/' || ch == File.separatorChar)
string = string.substring(1);
}
return Files.exists(Paths.get(string));
}
}
@Override
public InputStream getResourceStream(String string) throws IOException {
final URL res = ClassUtils.classLoader.getResource(string);
final boolean isResource = res != null;
if (isResource)
@ -110,6 +126,8 @@ public class DesktopStorageUtils implements StorageUtils {
return Files.newInputStream(Paths.get(uri));
} catch (final java.lang.IllegalArgumentException e) {
throw e;
} catch (URISyntaxException e) {
throw (IOException) new IOException().initCause(e);
}
else {
if (string.length() > 0) {

View File

@ -13,7 +13,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>

View File

@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

View File

@ -10,7 +10,7 @@
</parent>
<artifactId>warppi-engine-jogl</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<name>WarpPI Calculator JOGL Engine</name>
<description>WarpPI Calculator engine-jogl project</description>

View File

@ -1,12 +1,14 @@
package it.cavallium.warppi.gui.graphicengine.impl.jogl;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.texture.Texture;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLRenderer.OpenedTextureData;
@ -28,7 +30,7 @@ public class JOGLSkin implements Skin {
@Override
public void load(final String file) throws IOException {
final boolean isResource = !Files.exists(Paths.get(file));
if (isResource && this.getClass().getClassLoader().getResource(file) == null)
if (isResource && Engine.getPlatform().getStorageUtils().getResourceStream(file) == null)
throw new IOException("File '" + file + "' not found!");
texturePath = file;
this.isResource = isResource;

View File

@ -453,7 +453,7 @@ class NEWTWindow implements GLEventListener {
//gl.glEnable(GL.GL_MULTISAMPLE);
try {
renderer.currentTex = ((JOGLSkin) disp.loadSkin("test.png")).t;
renderer.currentTex = ((JOGLSkin) disp.loadSkin("/test.png")).t;
} catch (final Exception e) {
e.printStackTrace();
}

View File

@ -13,9 +13,8 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -1,3 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -10,5 +10,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10

View File

@ -10,7 +10,7 @@
</parent>
<artifactId>warppi-hardware</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<name>WarpPI Calculator Hardware</name>
<description>WarpPI Calculator hardware project</description>

View File

@ -92,7 +92,23 @@ public class HardwareStorageUtils implements StorageUtils {
}
@Override
public InputStream getResourceStream(String string) throws IOException, URISyntaxException {
public boolean doesResourceExist(String string) throws IOException {
final URL res = ClassUtils.classLoader.getResource(string);
final boolean isResource = res != null;
if (isResource)
return true;
else {
if (string.length() > 0) {
final char ch = string.charAt(0);
if (ch == '/' || ch == File.separatorChar)
string = string.substring(1);
}
return Files.exists(Paths.get(string));
}
}
@Override
public InputStream getResourceStream(String string) throws IOException {
final URL res = ClassUtils.classLoader.getResource(string);
final boolean isResource = res != null;
if (isResource)
@ -110,6 +126,8 @@ public class HardwareStorageUtils implements StorageUtils {
return Files.newInputStream(Paths.get(uri));
} catch (final java.lang.IllegalArgumentException e) {
throw e;
} catch (URISyntaxException e) {
throw (IOException) new IOException().initCause(e);
}
else {
if (string.length() > 0) {

BIN
math-rules-cache.zip Normal file

Binary file not shown.

12
pom.xml
View File

@ -29,10 +29,10 @@
<properties>
<project.version>0.9.0a0</project.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<java.version>11</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>1.8</maven.compiler.release>
<java.version>1.8</java.version>
<src.dir>src/main/java</src.dir>
<src.dir2>src/main/java</src.dir2>
<src.resdir>src/main/resources</src.resdir>
@ -45,8 +45,8 @@
<module>rules</module>
<module>hardware</module>
<module>desktop</module>
<module>teavm</module>
<module>engine-jogl</module>
<module>teavm</module>
</modules>
<repositories>
@ -134,7 +134,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>

View File

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

View File

@ -9,7 +9,7 @@
<version>${project.version}</version>
</parent>
<artifactId>warppi-rules</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<name>WarpPI Calculator Rules</name>
<description>WarpPI Calculator rules project</description>

View File

@ -16,7 +16,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/**
* Exponent rule
* (a) ^ (b+c) = a ^ b + a ^ c
* (a) ^ (b+c) = a ^ b * a ^ c
*
* @author Andrea Cavalli
*

View File

@ -13,9 +13,8 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -1,3 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -1,14 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=9
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=9
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10

View File

@ -9,8 +9,14 @@
<version>${project.version}</version>
</parent>
<artifactId>warppi-teavm</artifactId>
<packaging>pom</packaging>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>1.8</maven.compiler.release>
<java.version>1.8</java.version>
</properties>
<name>WarpPI Calculator TeaVM</name>
<description>WarpPI Calculator teavm project</description>
@ -31,12 +37,6 @@
<version>0.6.0-dev-567</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-extras-slf4j</artifactId>
<version>0.6.0-dev-567</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>

View File

@ -41,16 +41,10 @@ public class HtmlSkin implements Skin {
if (!file.startsWith("/"))
file = "/" + file;
url = Engine.getPlatform().getStorageUtils().getBasePath() + file;
try {
final InputStream stream = Engine.getPlatform().getStorageUtils().getResourceStream(file);
final PngReader r = new PngReader(stream);
skinSize = new int[] { r.imgInfo.cols, r.imgInfo.rows };
r.close();
} catch (final URISyntaxException e) {
final IOException ex = new IOException();
ex.initCause(e);
throw ex;
}
final InputStream stream = Engine.getPlatform().getStorageUtils().getResourceStream(file);
final PngReader r = new PngReader(stream);
skinSize = new int[] { r.imgInfo.cols, r.imgInfo.rows };
r.close();
}
@Override

View File

@ -4,12 +4,8 @@ import it.cavallium.warppi.boot.Boot;
public class TeaVMBoot {
public static void main(final String[] args) {
try {
Boot.boot(new TeaVMPlatform(), args);
} catch (Exception e) {
e.printStackTrace();
}
public static void main(final String[] args) throws Exception {
Boot.boot(new TeaVMPlatform(), args);
}
}

View File

@ -79,7 +79,7 @@ public class TeaVMStorageUtils implements StorageUtils {
}
@Override
public InputStream getResourceStream(final String path) throws IOException, URISyntaxException {
public InputStream getResourceStream(final String path) throws IOException {
try {
File targetFile;
if (TeaVMStorageUtils.resourcesCache.containsKey(path))
@ -104,6 +104,21 @@ public class TeaVMStorageUtils implements StorageUtils {
}
}
@Override
public boolean doesResourceExist(final String path) throws IOException {
try {
File targetFile;
if (TeaVMStorageUtils.resourcesCache.containsKey(path))
if ((targetFile = TeaVMStorageUtils.resourcesCache.get(path)).exists())
return true;
else
TeaVMStorageUtils.resourcesCache.remove(path);
return true;
} catch (final java.lang.IllegalArgumentException e) {
throw e;
}
}
@Override
public List<String> readAllLines(final File file) throws IOException {
final Reader reader_ = new InputStreamReader(new FileInputStream(file), Charset.defaultCharset());