diff --git a/.cproject b/.cproject deleted file mode 100644 index 54283f51..00000000 --- a/.cproject +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - TestJNI.h - true - true - true - - - make - all - true - true - true - - - make - clean - true - true - true - - - make - - picalculatornative.dll - true - true - true - - - - diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index a1a0f1a1..00000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index b26911bd..00000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 4b661a5f..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.project b/.project index dd8fa3fe..01adb0b1 100644 --- a/.project +++ b/.project @@ -1,35 +1,17 @@ - - - PICalculator - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - org.eclipse.jdt.core.javanature - - + + + WarpPI + + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 5e5c7a26..4824b802 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,9 +1,2 @@ eclipse.preferences.version=1 -encoding//src/jar-specific/java=UTF-8 -encoding//src/main/java=UTF-8 -encoding//src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesis.java=UTF-8 -encoding//src/main/java/it/cavallium/warppi/math/MathematicalSymbols.java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/main/rules=UTF-8 -encoding//src/teavm-specific/java=UTF-8 -encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 588e59de..00000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -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.source=1.8 -org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 7800136e..00000000 --- a/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,60 +0,0 @@ -cleanup.add_default_serial_version_id=false -cleanup.add_generated_serial_version_id=true -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=true -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=true -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=true -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_functional_interfaces=true -cleanup.convert_to_enhanced_for_loop=true -cleanup.correct_indentation=true -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.insert_inferred_type_arguments=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=true -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=false -cleanup.organize_imports=false -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_redundant_type_arguments=true -cleanup.remove_trailing_whitespaces=false -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_anonymous_class_creation=false -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_lambda=true -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=true -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=_Drake's Cleanup -cleanup_settings_version=2 -eclipse.preferences.version=1 -formatter_settings_version=12 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs index c679d9b2..14b697b7 100644 --- a/.settings/org.eclipse.m2e.core.prefs +++ b/.settings/org.eclipse.m2e.core.prefs @@ -1,4 +1,4 @@ -activeProfiles=jarprofile +activeProfiles= eclipse.preferences.version=1 resolveWorkspaceProjects=true version=1 diff --git a/.classpath b/core/.classpath similarity index 63% rename from .classpath rename to core/.classpath index db6fc7c7..906bfcec 100644 --- a/.classpath +++ b/core/.classpath @@ -1,15 +1,26 @@ - + + + + + + + - + + + + + + @@ -17,28 +28,5 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/.gitignore b/core/.gitignore new file mode 100644 index 00000000..b83d2226 --- /dev/null +++ b/core/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/core/.project b/core/.project new file mode 100644 index 00000000..a3e2fff8 --- /dev/null +++ b/core/.project @@ -0,0 +1,23 @@ + + + warppi-core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/core/.settings/org.eclipse.core.resources.prefs b/core/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..cf6931b9 --- /dev/null +++ b/core/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/core/.settings/org.eclipse.jdt.core.prefs b/core/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f494d1de --- /dev/null +++ b/core/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/core/.settings/org.eclipse.m2e.core.prefs b/core/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..14b697b7 --- /dev/null +++ b/core/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/core/pom.xml b/core/pom.xml new file mode 100644 index 00000000..1486d180 --- /dev/null +++ b/core/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + + + it.cavallium + warppi + ${project.version} + + warppi-core + bundle + + WarpPI Calculator Core + WarpPI Calculator core project + + + + it.unimi.dsi + fastutil + + + com.google.code.gson + gson + + + commons-io + commons-io + + + org.apache.commons + commons-lang3 + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + it.cavallium.warppi.* + warppi-core + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + diff --git a/src/main/java/cz/adamh/utils/NativeUtils.java b/core/src/main/java/cz/adamh/utils/NativeUtils.java similarity index 100% rename from src/main/java/cz/adamh/utils/NativeUtils.java rename to core/src/main/java/cz/adamh/utils/NativeUtils.java diff --git a/src/main/java/it/cavallium/warppi/BMPFile.java b/core/src/main/java/it/cavallium/warppi/BMPFile.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/BMPFile.java rename to core/src/main/java/it/cavallium/warppi/BMPFile.java diff --git a/src/main/java/it/cavallium/warppi/CacheUtils.java b/core/src/main/java/it/cavallium/warppi/CacheUtils.java similarity index 100% rename from src/main/java/it/cavallium/warppi/CacheUtils.java rename to core/src/main/java/it/cavallium/warppi/CacheUtils.java diff --git a/src/main/java/it/cavallium/warppi/ClassUtils.java b/core/src/main/java/it/cavallium/warppi/ClassUtils.java similarity index 100% rename from src/main/java/it/cavallium/warppi/ClassUtils.java rename to core/src/main/java/it/cavallium/warppi/ClassUtils.java diff --git a/src/main/java/it/cavallium/warppi/Engine.java b/core/src/main/java/it/cavallium/warppi/Engine.java old mode 100755 new mode 100644 similarity index 69% rename from src/main/java/it/cavallium/warppi/Engine.java rename to core/src/main/java/it/cavallium/warppi/Engine.java index aef45ade..803b2f4b --- a/src/main/java/it/cavallium/warppi/Engine.java +++ b/core/src/main/java/it/cavallium/warppi/Engine.java @@ -3,8 +3,8 @@ package it.cavallium.warppi; import java.io.IOException; import it.cavallium.warppi.boot.StartupArguments; -import it.cavallium.warppi.deps.DGpio; -import it.cavallium.warppi.deps.DSystem; +import it.cavallium.warppi.deps.Platform; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.HardwareTouchDevice; import it.cavallium.warppi.device.InputManager; @@ -18,17 +18,19 @@ import it.cavallium.warppi.gui.screens.Screen; public class Engine { public static final Engine INSTANCE = new Engine(); + private static Platform platform; private static boolean running = false; private static BehaviorSubject loadPhase = BehaviorSubject.create(); private BehaviorSubject loaded = BehaviorSubject.create(false); private Engine() { - } /** * Start an instance of the calculator. * + * @param platform + * Platform implementation * @param screen * Default screen to show at startup * @param disp @@ -40,24 +42,25 @@ public class Engine { * @throws InterruptedException * @throws IOException */ - public static void start(Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud, + public static void start(Platform platform, Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud, StartupArguments args) throws InterruptedException, IOException { if (running) { throw new RuntimeException("Already running!"); } else { running = true; - INSTANCE.startInstance(screen, disp, touchdevice, hud, args); + INSTANCE.startInstance(platform, screen, disp, touchdevice, hud, args); } } - private void startInstance(Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud, + private void startInstance(final Platform platform, Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud, StartupArguments args) throws InterruptedException, IOException { - ConsoleUtils.out.println("WarpPI Calculator"); + Engine.platform = platform; + platform.getConsoleUtils().out().println("WarpPI Calculator"); initializeEnvironment(args); Thread currentThread = Thread.currentThread(); currentThread.setPriority(Thread.MAX_PRIORITY); - PlatformUtils.setThreadName(currentThread, "Main thread"); + Engine.getPlatform().setThreadName(currentThread, "Main thread"); DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)"); Keyboard k = new Keyboard(); @@ -68,11 +71,11 @@ public class Engine { } private void onShutdown() { - ConsoleUtils.out.println(1, "Shutdown..."); + Engine.platform.getConsoleUtils().out().println(1, "Shutdown..."); beforeShutdown(); - ConsoleUtils.out.println(1, ""); - ConsoleUtils.out.println(1, "Closed."); - DSystem.exit(0); + Engine.platform.getConsoleUtils().out().println(1, ""); + Engine.platform.getConsoleUtils().out().println(1, "Closed."); + Engine.getPlatform().exit(0); } private void initializeEnvironment(StartupArguments args) throws IOException { @@ -83,11 +86,11 @@ public class Engine { if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) { StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE; } - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args); + Engine.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args); checkDeviceType(); if (Utils.isRunningOnRaspberry() && args.isRaspberryModeAllowed()) { - DGpio.wiringPiSetupPhys(); - DGpio.pinMode(12, DGpio.PWM_OUTPUT); + Engine.getPlatform().getGpio().wiringPiSetupPhys(); + Engine.getPlatform().getGpio().pinMode(12, Engine.getPlatform().getGpio().valuePwmOutput()); } else { StaticVars.screenPos = new int[] { 0, 0 }; StaticVars.debugOn = true; @@ -110,6 +113,10 @@ public class Engine { public Observable getLoadPhase() { return loadPhase; } + + public static Platform getPlatform() { + return platform; + } public static class LoadingStatus { protected LoadingStatus() { diff --git a/src/main/java/it/cavallium/warppi/Error.java b/core/src/main/java/it/cavallium/warppi/Error.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/Error.java rename to core/src/main/java/it/cavallium/warppi/Error.java diff --git a/src/main/java/it/cavallium/warppi/Errors.java b/core/src/main/java/it/cavallium/warppi/Errors.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/Errors.java rename to core/src/main/java/it/cavallium/warppi/Errors.java diff --git a/src/main/java/it/cavallium/warppi/IntegerObj.java b/core/src/main/java/it/cavallium/warppi/IntegerObj.java similarity index 100% rename from src/main/java/it/cavallium/warppi/IntegerObj.java rename to core/src/main/java/it/cavallium/warppi/IntegerObj.java diff --git a/src/main/java/it/cavallium/warppi/MmapByteBuffer.java b/core/src/main/java/it/cavallium/warppi/MmapByteBuffer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/MmapByteBuffer.java rename to core/src/main/java/it/cavallium/warppi/MmapByteBuffer.java diff --git a/src/main/java/it/cavallium/warppi/ScriptUtils.java b/core/src/main/java/it/cavallium/warppi/ScriptUtils.java similarity index 100% rename from src/main/java/it/cavallium/warppi/ScriptUtils.java rename to core/src/main/java/it/cavallium/warppi/ScriptUtils.java diff --git a/src/main/java/it/cavallium/warppi/StaticVars.java b/core/src/main/java/it/cavallium/warppi/StaticVars.java similarity index 100% rename from src/main/java/it/cavallium/warppi/StaticVars.java rename to core/src/main/java/it/cavallium/warppi/StaticVars.java diff --git a/src/main/java/it/cavallium/warppi/TestDrivers.java b/core/src/main/java/it/cavallium/warppi/TestDrivers.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/TestDrivers.java rename to core/src/main/java/it/cavallium/warppi/TestDrivers.java diff --git a/src/main/java/it/cavallium/warppi/TestJNI.java b/core/src/main/java/it/cavallium/warppi/TestJNI.java similarity index 100% rename from src/main/java/it/cavallium/warppi/TestJNI.java rename to core/src/main/java/it/cavallium/warppi/TestJNI.java diff --git a/src/main/java/it/cavallium/warppi/Utils.java b/core/src/main/java/it/cavallium/warppi/Utils.java old mode 100755 new mode 100644 similarity index 88% rename from src/main/java/it/cavallium/warppi/Utils.java rename to core/src/main/java/it/cavallium/warppi/Utils.java index 96e35a5d..520118d4 --- a/src/main/java/it/cavallium/warppi/Utils.java +++ b/core/src/main/java/it/cavallium/warppi/Utils.java @@ -1,6 +1,7 @@ package it.cavallium.warppi; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.management.ManagementFactory; @@ -11,19 +12,19 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.net.URISyntaxException; +import java.nio.file.Files; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; +import org.apache.commons.io.FileUtils; import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.Rational; -import it.cavallium.warppi.deps.DGpio; -import it.cavallium.warppi.deps.StorageUtils; -import it.cavallium.warppi.deps.nio.DFiles; -import it.cavallium.warppi.deps.nio.DPath; -import it.cavallium.warppi.deps.nio.DPaths; import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.gui.graphicengine.BinaryFont; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.FunctionOperator; import it.cavallium.warppi.math.FunctionSingle; @@ -154,7 +155,7 @@ public class Utils { return c; } - public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(ObjectArrayList fl) { + public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(List fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (fl.get(i) instanceof FunctionSingle) { @@ -173,8 +174,7 @@ public class Utils { return true; } - public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems( - ObjectArrayList fl) { + public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems(List fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Multiplication || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (fl.get(i) instanceof FunctionSingle) { @@ -193,7 +193,7 @@ public class Utils { return true; } - public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(ObjectArrayList fl) { + public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(List fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (fl.get(i) instanceof FunctionSingle) { @@ -212,7 +212,7 @@ public class Utils { return true; } - public static boolean areThereOnlySettedUpFunctionsAndSystems(ObjectArrayList fl) { + public static boolean areThereOnlySettedUpFunctionsAndSystems(List fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { if (fl.get(i) instanceof FunctionSingle) { @@ -231,7 +231,7 @@ public class Utils { return true; } - public static boolean areThereOnlyEmptySNFunctions(ObjectArrayList fl) { + public static boolean areThereOnlyEmptySNFunctions(List fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof FunctionSingle) { if (((FunctionSingle) fl.get(i)).getParameter() == null) { @@ -242,7 +242,7 @@ public class Utils { return false; } - public static boolean areThereOnlyEmptyNSNFunctions(ObjectArrayList fl) { + public static boolean areThereOnlyEmptyNSNFunctions(List fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof FunctionOperator && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof SumSubtraction) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof Division)) { if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) { @@ -253,7 +253,7 @@ public class Utils { return false; } - public static boolean areThereEmptyMultiplications(ObjectArrayList fl) { + public static boolean areThereEmptyMultiplications(List fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division) { if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) { @@ -264,7 +264,7 @@ public class Utils { return false; } - public static boolean areThereEmptySums(ObjectArrayList fl) { + public static boolean areThereEmptySums(List fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Subtraction) { if (((FunctionOperator) fl.get(i)).getParameter1() == null && ((FunctionOperator) fl.get(i)).getParameter2() == null) { @@ -275,7 +275,7 @@ public class Utils { return false; } - public static boolean areThereEmptySystems(ObjectArrayList fl) { + public static boolean areThereEmptySystems(List fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof EquationsSystemPart) { if (((EquationsSystemPart) fl.get(i)).getParameter() == null) { @@ -286,7 +286,7 @@ public class Utils { return false; } - public static boolean areThereOtherSettedUpFunctions(ObjectArrayList fl) { + public static boolean areThereOtherSettedUpFunctions(List fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Variable || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Expression || fl.get(i) instanceof FunctionSingle || fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division)) { if (fl.get(i) instanceof FunctionSingle) { @@ -369,7 +369,7 @@ public class Utils { return BigDecimalMath.divideRound(new BigDecimal(r.numer()).setScale(Utils.scale, Utils.scaleMode), new BigDecimal(r.denom()).setScale(Utils.scale, Utils.scaleMode)); } - public static boolean equalsVariables(ObjectArrayList variables, ObjectArrayList variables2) { + public static boolean equalsVariables(List variables, List variables2) { if (variables.size() != variables2.size()) { return false; } else { @@ -602,7 +602,7 @@ public class Utils { if (displayName.endsWith("MemorySize")) { mb = true; } - final ObjectArrayList arr = new ObjectArrayList<>(); + final List arr = new ArrayList<>(); arr.add("getFreePhysicalMemorySize"); arr.add("getProcessCpuLoad"); arr.add("getSystemCpuLoad"); @@ -631,17 +631,17 @@ public class Utils { public static boolean isRunningOnRaspberry() { return CacheUtils.get("isRunningOnRaspberry", 24 * 60 * 60 * 1000, () -> { - if (PlatformUtils.isJavascript) + if (Engine.getPlatform().isJavascript()) return false; try { // Check if it's a raspberry using pi4j - return DGpio.getBoardType() != DGpio.UnknownBoardType; + return Engine.getPlatform().getGpio().getBoardType() != Engine.getPlatform().getGpio().valueUnknownBoardType(); } catch (final Exception e) { // Check if it's a raspberry using other methods - if (PlatformUtils.osName.equals("Linux")) { + if (Engine.getPlatform().getOsName().equals("Linux")) { try { - final DPath osRelease = DPaths.get("/etc", "os-release"); - return DFiles.readAllLines(osRelease).stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name")); + final File osRelease = new File("/etc", "os-release"); + return FileUtils.readLines(osRelease, "UTF-8").stream().map(String::toLowerCase).anyMatch(line -> line.contains("raspbian") && line.contains("name")); } catch (IOException readException) { return false; } @@ -654,7 +654,7 @@ public class Utils { } public static boolean isWindows() { - return (PlatformUtils.osName.indexOf("win") >= 0); + return (Engine.getPlatform().getOsName().indexOf("win") >= 0); } public static ObjectArrayList newArrayList(T o) { @@ -665,13 +665,21 @@ public class Utils { public static InputStream getResourceStreamSafe(String string) throws IOException, URISyntaxException { try { - return StorageUtils.getResourceStream(string); + return Engine.getPlatform().getStorageUtils().getResourceStream(string); } catch (final Exception ex) { return null; } } - public static DPath getJarDirectory() { - return DPaths.get("").toAbsolutePath(); + public static File getJarDirectory() { + return new File("").getAbsoluteFile(); + } + + public static U getOrDefault(Map enginesList, T key, U object) { + if (enginesList.containsKey(key)) { + return enginesList.get(key); + } else { + return object; + } } } diff --git a/src/main/java/it/cavallium/warppi/boot/WarpPI.java b/core/src/main/java/it/cavallium/warppi/boot/Boot.java similarity index 80% rename from src/main/java/it/cavallium/warppi/boot/WarpPI.java rename to core/src/main/java/it/cavallium/warppi/boot/Boot.java index c8e711e5..ada26c82 100644 --- a/src/main/java/it/cavallium/warppi/boot/WarpPI.java +++ b/core/src/main/java/it/cavallium/warppi/boot/Boot.java @@ -2,10 +2,10 @@ package it.cavallium.warppi.boot; import java.util.Arrays; -import it.cavallium.warppi.ConsoleUtils; import it.cavallium.warppi.Engine; import it.cavallium.warppi.Engine.LoadingStatus; import it.cavallium.warppi.Error; +import it.cavallium.warppi.deps.Platform; import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.PIHardwareDisplay; import it.cavallium.warppi.device.PIHardwareTouchDevice; @@ -13,10 +13,11 @@ import it.cavallium.warppi.gui.CalculatorHUD; import it.cavallium.warppi.gui.screens.LoadingScreen; import it.cavallium.warppi.math.rules.RulesManager; -public class WarpPI { - public static void main(String[] args) throws Exception { - Engine.start(new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), parseStartupArguments(args)); - Engine.INSTANCE.getLoadPhase().subscribe(WarpPI::loadCalculator); +public class Boot { + + public static void boot(Platform platform, String[] args) throws Exception { + Engine.start(platform, new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), parseStartupArguments(args)); + Engine.INSTANCE.getLoadPhase().subscribe(Boot::loadCalculator); } private static void loadCalculator(LoadingStatus loading) { @@ -86,7 +87,7 @@ public class WarpPI { args.setUncached(true); break; default: - ConsoleUtils.out.println("Unrecognized argument " + arg); + Engine.getPlatform().getConsoleUtils().out().println("Unrecognized argument " + arg); break; } } diff --git a/src/main/java/it/cavallium/warppi/boot/StartupArguments.java b/core/src/main/java/it/cavallium/warppi/boot/StartupArguments.java similarity index 100% rename from src/main/java/it/cavallium/warppi/boot/StartupArguments.java rename to core/src/main/java/it/cavallium/warppi/boot/StartupArguments.java diff --git a/src/main/java/it/cavallium/warppi/boot/StartupArgumentsImpl.java b/core/src/main/java/it/cavallium/warppi/boot/StartupArgumentsImpl.java similarity index 100% rename from src/main/java/it/cavallium/warppi/boot/StartupArgumentsImpl.java rename to core/src/main/java/it/cavallium/warppi/boot/StartupArgumentsImpl.java diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/jogamp/DJogamp.java b/core/src/main/java/it/cavallium/warppi/deps/DJogamp.java similarity index 96% rename from src/jar-specific/java/it/cavallium/warppi/deps/jogamp/DJogamp.java rename to core/src/main/java/it/cavallium/warppi/deps/DJogamp.java index 2f175ae1..0e62caa1 100644 --- a/src/jar-specific/java/it/cavallium/warppi/deps/jogamp/DJogamp.java +++ b/core/src/main/java/it/cavallium/warppi/deps/DJogamp.java @@ -1,6 +1,6 @@ -package it.cavallium.warppi.deps.jogamp; +package it.cavallium.warppi.deps; -public class DJogamp { +public interface DJogamp { // // Unicode: Non printable controls: [0x00 - 0x1F] diff --git a/core/src/main/java/it/cavallium/warppi/deps/Platform.java b/core/src/main/java/it/cavallium/warppi/deps/Platform.java new file mode 100644 index 00000000..4f384aba --- /dev/null +++ b/core/src/main/java/it/cavallium/warppi/deps/Platform.java @@ -0,0 +1,159 @@ +package it.cavallium.warppi.deps; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.List; +import java.util.Map; +import it.cavallium.warppi.Error; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.Skin; + +public interface Platform { + + public ConsoleUtils getConsoleUtils(); + public Gpio getGpio(); + public StorageUtils getStorageUtils(); + public PngUtils getPngUtils(); + + public void setThreadName(Thread t, String name); + public void setThreadDaemon(Thread t); + public void setThreadDaemon(Thread t, boolean value); + + public void exit(int value); + public void gc(); + + public boolean isJavascript(); + + public String getOsName(); + + public void alphaChanged(boolean val); + public void shiftChanged(boolean val); + + public Semaphore newSemaphore(); + public Semaphore newSemaphore(int i); + + public URLClassLoader newURLClassLoader(URL[] urls); + + public Map getEnginesList(); + public GraphicEngine getEngine(String string) throws NullPointerException; + + public void throwNewExceptionInInitializerError(String text); + public String[] stacktraceToString(Error e); + + public void loadPlatformRules(); + public void zip(String targetPath, String destinationFilePath, String password); + public void unzip(String targetZipFilePath, String destinationFolderPath, String password); + + public boolean compile(String[] command, PrintWriter printWriter, PrintWriter errors); + + public interface Gpio { + public int valueOutput(); + public int valuePwmOutput(); + public int valueInput(); + public int valueHigh(); + public int valueLow(); + public Object valueUnknownBoardType(); + + public void wiringPiSetupPhys(); + + public void pinMode(int i, int type); + + public void digitalWrite(int pin, int val); + + public void digitalWrite(int pin, boolean val); + + public void pwmWrite(int pin, int val); + + public void delayMicroseconds(int t); + + public int digitalRead(int pin); + + public Object getBoardType(); + } + + public interface ConsoleUtils { + public static final int OUTPUTLEVEL_NODEBUG = 0; + public static final int OUTPUTLEVEL_DEBUG_MIN = 1; + public static final int OUTPUTLEVEL_DEBUG_VERBOSE = 4; + + public AdvancedOutputStream out(); + + public interface AdvancedOutputStream { + public void println(Object str); + + public void println(int level); + + public void println(int level, Object str); + + public void print(int level, String str); + + public void println(int level, String prefix, String str); + + public void println(int level, String... parts); + } + } + + public interface StorageUtils { + int OpenOptionWrite = 0; + int OpenOptionCreate = 1; + + public boolean exists(File f); + + public File get(String path); + + public File get(String... path); + + @Deprecated() + public File getResource(String string) throws IOException, URISyntaxException; + + public InputStream getResourceStream(String string) throws IOException, URISyntaxException; + + public List readAllLines(File file) throws IOException; + + public String read(InputStream input) throws IOException; + + public List walk(File dir) throws IOException; + + public File relativize(File rulesPath, File f); + + public File resolve(File file, String string); + + public File getParent(File f); + + public void createDirectories(File dir) throws IOException; + + public void write(File f, byte[] bytes, int... options) throws IOException; + + public List readAllLines(InputStream input) throws IOException; + + public String getBasePath(); + } + + public interface Semaphore { + void release(); + void acquire() throws InterruptedException; + } + + public interface URLClassLoader { + public Class loadClass(String name) throws ClassNotFoundException; + void close() throws IOException; + } + + public interface PngUtils { + + public PngReader load(InputStream resourceStream); + + public interface PngReader { + + int[] getImageMatrix(); + + int[] getSize(); + + } + + } +} diff --git a/src/main/java/it/cavallium/warppi/device/CacheFile.java b/core/src/main/java/it/cavallium/warppi/device/CacheFile.java old mode 100755 new mode 100644 similarity index 81% rename from src/main/java/it/cavallium/warppi/device/CacheFile.java rename to core/src/main/java/it/cavallium/warppi/device/CacheFile.java index af795dd5..2488dec9 --- a/src/main/java/it/cavallium/warppi/device/CacheFile.java +++ b/core/src/main/java/it/cavallium/warppi/device/CacheFile.java @@ -1,5 +1,6 @@ package it.cavallium.warppi.device; +import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -8,8 +9,6 @@ import java.io.ObjectOutputStream; import java.util.UUID; import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.deps.nio.DFiles; -import it.cavallium.warppi.deps.nio.DPaths; public class CacheFile { private String path; @@ -21,9 +20,9 @@ public class CacheFile { public CacheFile() { do { path = UUID.randomUUID().toString() + ".ser"; - } while (DFiles.exists(DPaths.get(path))); + } while (new File(path).exists()); try { - DFiles.createTempFile(StaticVars.calculatorNameLOWER, ""); + File.createTempFile(StaticVars.calculatorNameLOWER, ""); } catch (final IOException e) { e.printStackTrace(); } @@ -80,8 +79,8 @@ public class CacheFile { public void dispose() { closeStreams(); try { - DFiles.deleteIfExists(DPaths.get(path)); - } catch (final IOException e) { + new File(path).delete(); + } catch (final Exception e) { e.printStackTrace(); } } diff --git a/src/main/java/it/cavallium/warppi/device/HardwareDevice.java b/core/src/main/java/it/cavallium/warppi/device/HardwareDevice.java similarity index 77% rename from src/main/java/it/cavallium/warppi/device/HardwareDevice.java rename to core/src/main/java/it/cavallium/warppi/device/HardwareDevice.java index efbe1007..d9c84f59 100644 --- a/src/main/java/it/cavallium/warppi/device/HardwareDevice.java +++ b/core/src/main/java/it/cavallium/warppi/device/HardwareDevice.java @@ -1,6 +1,6 @@ package it.cavallium.warppi.device; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.gui.DisplayManager; public class HardwareDevice { @@ -26,8 +26,8 @@ public class HardwareDevice { displayManager.initialize(); inputManager.getKeyboard().startKeyboard(); Thread t = new Thread(r); - PlatformUtils.setDaemon(t, false); - PlatformUtils.setThreadName(t, "Main thread (after setup)"); + Engine.getPlatform().setThreadDaemon(t, false); + Engine.getPlatform().setThreadName(t, "Main thread (after setup)"); t.start(); } diff --git a/src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java b/core/src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java similarity index 100% rename from src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java rename to core/src/main/java/it/cavallium/warppi/device/HardwareTouchDevice.java diff --git a/src/main/java/it/cavallium/warppi/device/InputManager.java b/core/src/main/java/it/cavallium/warppi/device/InputManager.java similarity index 100% rename from src/main/java/it/cavallium/warppi/device/InputManager.java rename to core/src/main/java/it/cavallium/warppi/device/InputManager.java diff --git a/src/main/java/it/cavallium/warppi/device/Keyboard.java b/core/src/main/java/it/cavallium/warppi/device/Keyboard.java old mode 100755 new mode 100644 similarity index 89% rename from src/main/java/it/cavallium/warppi/device/Keyboard.java rename to core/src/main/java/it/cavallium/warppi/device/Keyboard.java index 976b94bc..99b7a119 --- a/src/main/java/it/cavallium/warppi/device/Keyboard.java +++ b/core/src/main/java/it/cavallium/warppi/device/Keyboard.java @@ -2,11 +2,10 @@ package it.cavallium.warppi.device; import java.awt.event.KeyEvent; -import it.cavallium.warppi.ConsoleUtils; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.deps.DGpio; -import it.cavallium.warppi.deps.jogamp.DJogamp; +import it.cavallium.warppi.deps.DJogamp; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; import it.cavallium.warppi.device.chip.ParallelToSerial; import it.cavallium.warppi.device.chip.SerialToParallel; import it.cavallium.warppi.event.Key; @@ -58,19 +57,19 @@ public class Keyboard { } } catch (final InterruptedException e) {} } else { - DGpio.pinMode(CLK_INH_pin, DGpio.OUTPUT); - DGpio.pinMode(RCK_pin, DGpio.OUTPUT); - DGpio.pinMode(SER_pin, DGpio.OUTPUT); - DGpio.pinMode(SH_LD_pin, DGpio.OUTPUT); - DGpio.pinMode(SCK_and_CLK_pin, DGpio.OUTPUT); - DGpio.pinMode(QH_pin, DGpio.INPUT); + Engine.getPlatform().getGpio().pinMode(CLK_INH_pin, Engine.getPlatform().getGpio().valueOutput()); + Engine.getPlatform().getGpio().pinMode(RCK_pin, Engine.getPlatform().getGpio().valueOutput()); + Engine.getPlatform().getGpio().pinMode(SER_pin, Engine.getPlatform().getGpio().valueOutput()); + Engine.getPlatform().getGpio().pinMode(SH_LD_pin, Engine.getPlatform().getGpio().valueOutput()); + Engine.getPlatform().getGpio().pinMode(SCK_and_CLK_pin, Engine.getPlatform().getGpio().valueOutput()); + Engine.getPlatform().getGpio().pinMode(QH_pin, Engine.getPlatform().getGpio().valueInput()); - DGpio.digitalWrite(CLK_INH_pin, false); - DGpio.digitalWrite(RCK_pin, false); - DGpio.digitalWrite(SER_pin, false); - DGpio.digitalWrite(SH_LD_pin, false); - DGpio.digitalWrite(SCK_and_CLK_pin, false); - DGpio.digitalWrite(QH_pin, false); + Engine.getPlatform().getGpio().digitalWrite(CLK_INH_pin, false); + Engine.getPlatform().getGpio().digitalWrite(RCK_pin, false); + Engine.getPlatform().getGpio().digitalWrite(SER_pin, false); + Engine.getPlatform().getGpio().digitalWrite(SH_LD_pin, false); + Engine.getPlatform().getGpio().digitalWrite(SCK_and_CLK_pin, false); + Engine.getPlatform().getGpio().digitalWrite(QH_pin, false); final SerialToParallel chip1 = new SerialToParallel(RCK_pin, SCK_and_CLK_pin /*SCK*/, SER_pin); final ParallelToSerial chip2 = new ParallelToSerial(SH_LD_pin, CLK_INH_pin, QH_pin, SCK_and_CLK_pin/*CLK*/); @@ -101,9 +100,9 @@ public class Keyboard { } } }); - PlatformUtils.setThreadName(kt, "Keyboard thread"); + Engine.getPlatform().setThreadName(kt, "Keyboard thread"); kt.setPriority(Thread.NORM_PRIORITY + 1); - PlatformUtils.setDaemon(kt); + Engine.getPlatform().setThreadDaemon(kt); kt.start(); } @@ -761,12 +760,12 @@ public class Keyboard { public static void stopKeyboard() { if (StaticVars.debugOn == false) { - DGpio.digitalWrite(33, false); - DGpio.digitalWrite(35, false); - DGpio.digitalWrite(36, false); - DGpio.digitalWrite(37, false); - DGpio.digitalWrite(38, false); - DGpio.digitalWrite(40, false); + Engine.getPlatform().getGpio().digitalWrite(33, false); + Engine.getPlatform().getGpio().digitalWrite(35, false); + Engine.getPlatform().getGpio().digitalWrite(36, false); + Engine.getPlatform().getGpio().digitalWrite(37, false); + Engine.getPlatform().getGpio().digitalWrite(38, false); + Engine.getPlatform().getGpio().digitalWrite(40, false); } } @@ -809,7 +808,7 @@ public class Keyboard { case ZOOM_MODE: float newZoom = (StaticVars.windowZoom.getLastValue() % 3) + 1; StaticVars.windowZoom.onNext(newZoom); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Keyboard", "Zoom: " + newZoom); // StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f; refresh = true; case HISTORY_BACK: @@ -827,22 +826,22 @@ public class Keyboard { switch (k) { case SHIFT: if (Keyboard.alpha) - PlatformUtils.alphaChanged(Keyboard.alpha = false); - PlatformUtils.shiftChanged(Keyboard.shift = !Keyboard.shift); + Engine.getPlatform().alphaChanged(Keyboard.alpha = false); + Engine.getPlatform().shiftChanged(Keyboard.shift = !Keyboard.shift); refresh = true; break; case ALPHA: if (Keyboard.shift) - PlatformUtils.shiftChanged(Keyboard.shift = false); - PlatformUtils.alphaChanged(Keyboard.alpha = !Keyboard.alpha); + Engine.getPlatform().shiftChanged(Keyboard.shift = false); + Engine.getPlatform().alphaChanged(Keyboard.alpha = !Keyboard.alpha); refresh = true; break; default: if (k != Key.NONE) { if (Keyboard.shift) - PlatformUtils.shiftChanged(Keyboard.shift = false); + Engine.getPlatform().shiftChanged(Keyboard.shift = false); if (Keyboard.alpha) - PlatformUtils.alphaChanged(Keyboard.alpha = false); + Engine.getPlatform().alphaChanged(Keyboard.alpha = false); } break; } @@ -850,7 +849,7 @@ public class Keyboard { refreshRequest = true; } } else if (!done) { - ConsoleUtils.out.println(1, "Key " + k.toString() + " ignored."); + Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored."); } } @@ -876,7 +875,7 @@ public class Keyboard { refreshRequest = true; } } else if (!done) { - ConsoleUtils.out.println(1, "Key " + k.toString() + " ignored."); + Engine.getPlatform().getConsoleUtils().out().println(1, "Key " + k.toString() + " ignored."); } } diff --git a/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java b/core/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java similarity index 66% rename from src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java rename to core/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java index 610210b0..e5db0d21 100644 --- a/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java +++ b/core/src/main/java/it/cavallium/warppi/device/PIHardwareDisplay.java @@ -1,8 +1,7 @@ package it.cavallium.warppi.device; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.deps.DGpio; import it.cavallium.warppi.gui.HardwareDisplay; public class PIHardwareDisplay implements HardwareDisplay { @@ -16,10 +15,10 @@ public class PIHardwareDisplay implements HardwareDisplay { @Override public void setBrightness(double value) { if (StaticVars.debugOn == false) { - DGpio.pwmWrite(12, (int) Math.ceil(value * 1024f)); + Engine.getPlatform().getGpio().pwmWrite(12, (int) Math.ceil(value * 1024f)); // SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10))); } else { - ConsoleUtils.out.println(1, "Brightness: " + value); + Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness: " + value); } } diff --git a/src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java b/core/src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java similarity index 100% rename from src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java rename to core/src/main/java/it/cavallium/warppi/device/PIHardwareTouchDevice.java diff --git a/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java b/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java new file mode 100644 index 00000000..51f815c9 --- /dev/null +++ b/core/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java @@ -0,0 +1,35 @@ +package it.cavallium.warppi.device.chip; + +import it.cavallium.warppi.Engine; + +public class ParallelToSerial { + + private final int SH_LD; + private final int CLK_INH; + private final int QH; + private final int CLK; + + public ParallelToSerial(int SH_LD_pin, int CLK_INH_pin, int QH_pin, int CLK_pin) { + SH_LD = SH_LD_pin; + CLK_INH = CLK_INH_pin; + QH = QH_pin; + CLK = CLK_pin; + } + + public boolean[] read() { + final boolean[] data = new boolean[8]; + Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueHigh()); + Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueLow()); + Engine.getPlatform().getGpio().delayMicroseconds(1); + Engine.getPlatform().getGpio().digitalWrite(SH_LD, Engine.getPlatform().getGpio().valueHigh()); + Engine.getPlatform().getGpio().digitalWrite(CLK_INH, Engine.getPlatform().getGpio().valueLow()); + + for (int i = 7; i >= 0; i--) { + Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueHigh()); + Engine.getPlatform().getGpio().digitalWrite(CLK, Engine.getPlatform().getGpio().valueLow()); + data[i] = Engine.getPlatform().getGpio().digitalRead(QH) == Engine.getPlatform().getGpio().valueHigh() ? true : false; + } + + return data; + } +} diff --git a/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java b/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java new file mode 100644 index 00000000..56e53027 --- /dev/null +++ b/core/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java @@ -0,0 +1,31 @@ +package it.cavallium.warppi.device.chip; + +import it.cavallium.warppi.Engine; + +public class SerialToParallel { + private final int RCK; //Storage register clock pin (latch pin) + private final int SCK; //Shift register clock pin + private final int SER; //Serial data input + + public SerialToParallel(int RCK_pin, int SCK_pin, int SER_pin) { + RCK = RCK_pin; + SCK = SCK_pin; + SER = SER_pin; + } + + public void write(boolean[] data) { + if (data.length != 8) { + return; + } else { + Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueLow()); + + for (int i = 7; i >= 0; i--) { + Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueLow()); + Engine.getPlatform().getGpio().digitalWrite(SER, data[i]); + Engine.getPlatform().getGpio().digitalWrite(SCK, Engine.getPlatform().getGpio().valueHigh()); + } + + Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueHigh()); + } + } +} diff --git a/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java b/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java old mode 100755 new mode 100644 similarity index 95% rename from src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java rename to core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java index d581bc92..4e298720 --- a/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java +++ b/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java @@ -12,8 +12,8 @@ import java.util.logging.Logger; import javax.imageio.ImageIO; import it.cavallium.warppi.ClassUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.Utils; -import it.cavallium.warppi.deps.DSystem; /** * @@ -36,7 +36,7 @@ public class RAWFont { loadFont("/font_" + name + ".rft"); } catch (final IOException e) { e.printStackTrace(); - DSystem.exit(1); + Engine.getPlatform().exit(1); } chars32 = new int[(maxBound - minBound) * charIntCount]; for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) { @@ -114,7 +114,7 @@ public class RAWFont { } catch (final Exception ex) { ex.printStackTrace(); System.out.println(string); - DSystem.exit(-1); + Engine.getPlatform().exit(-1); } } } else { diff --git a/src/main/java/it/cavallium/warppi/event/Event.java b/core/src/main/java/it/cavallium/warppi/event/Event.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/Event.java rename to core/src/main/java/it/cavallium/warppi/event/Event.java diff --git a/src/main/java/it/cavallium/warppi/event/Key.java b/core/src/main/java/it/cavallium/warppi/event/Key.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/Key.java rename to core/src/main/java/it/cavallium/warppi/event/Key.java diff --git a/src/main/java/it/cavallium/warppi/event/KeyEvent.java b/core/src/main/java/it/cavallium/warppi/event/KeyEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/KeyEvent.java rename to core/src/main/java/it/cavallium/warppi/event/KeyEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/KeyPressedEvent.java b/core/src/main/java/it/cavallium/warppi/event/KeyPressedEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/KeyPressedEvent.java rename to core/src/main/java/it/cavallium/warppi/event/KeyPressedEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/KeyReleasedEvent.java b/core/src/main/java/it/cavallium/warppi/event/KeyReleasedEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/KeyReleasedEvent.java rename to core/src/main/java/it/cavallium/warppi/event/KeyReleasedEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/KeyboardEventListener.java b/core/src/main/java/it/cavallium/warppi/event/KeyboardEventListener.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/KeyboardEventListener.java rename to core/src/main/java/it/cavallium/warppi/event/KeyboardEventListener.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchCancelEvent.java b/core/src/main/java/it/cavallium/warppi/event/TouchCancelEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchCancelEvent.java rename to core/src/main/java/it/cavallium/warppi/event/TouchCancelEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchEndEvent.java b/core/src/main/java/it/cavallium/warppi/event/TouchEndEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchEndEvent.java rename to core/src/main/java/it/cavallium/warppi/event/TouchEndEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchEvent.java b/core/src/main/java/it/cavallium/warppi/event/TouchEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchEvent.java rename to core/src/main/java/it/cavallium/warppi/event/TouchEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchEventListener.java b/core/src/main/java/it/cavallium/warppi/event/TouchEventListener.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchEventListener.java rename to core/src/main/java/it/cavallium/warppi/event/TouchEventListener.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchMoveEvent.java b/core/src/main/java/it/cavallium/warppi/event/TouchMoveEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchMoveEvent.java rename to core/src/main/java/it/cavallium/warppi/event/TouchMoveEvent.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchPoint.java b/core/src/main/java/it/cavallium/warppi/event/TouchPoint.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchPoint.java rename to core/src/main/java/it/cavallium/warppi/event/TouchPoint.java diff --git a/src/main/java/it/cavallium/warppi/event/TouchStartEvent.java b/core/src/main/java/it/cavallium/warppi/event/TouchStartEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/event/TouchStartEvent.java rename to core/src/main/java/it/cavallium/warppi/event/TouchStartEvent.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/MarioBlock.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioBlock.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/MarioBlock.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/MarioBlock.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/MarioEnemy.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioEnemy.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/MarioEnemy.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/MarioEnemy.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/MarioEntity.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioEntity.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/MarioEntity.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/MarioEntity.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/MarioEvent.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/MarioEvent.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/MarioEvent.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/MarioGame.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioGame.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/MarioGame.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/MarioGame.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/MarioWorld.java b/core/src/main/java/it/cavallium/warppi/extra/mario/MarioWorld.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/MarioWorld.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/MarioWorld.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/PlayerEntity.java b/core/src/main/java/it/cavallium/warppi/extra/mario/PlayerEntity.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/PlayerEntity.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/PlayerEntity.java diff --git a/src/main/java/it/cavallium/warppi/extra/mario/PositionEvent.java b/core/src/main/java/it/cavallium/warppi/extra/mario/PositionEvent.java similarity index 100% rename from src/main/java/it/cavallium/warppi/extra/mario/PositionEvent.java rename to core/src/main/java/it/cavallium/warppi/extra/mario/PositionEvent.java diff --git a/src/main/java/it/cavallium/warppi/flow/Action0.java b/core/src/main/java/it/cavallium/warppi/flow/Action0.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Action0.java rename to core/src/main/java/it/cavallium/warppi/flow/Action0.java diff --git a/src/main/java/it/cavallium/warppi/flow/Action1.java b/core/src/main/java/it/cavallium/warppi/flow/Action1.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Action1.java rename to core/src/main/java/it/cavallium/warppi/flow/Action1.java diff --git a/src/main/java/it/cavallium/warppi/flow/Action2.java b/core/src/main/java/it/cavallium/warppi/flow/Action2.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Action2.java rename to core/src/main/java/it/cavallium/warppi/flow/Action2.java diff --git a/src/main/java/it/cavallium/warppi/flow/BehaviorSubject.java b/core/src/main/java/it/cavallium/warppi/flow/BehaviorSubject.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/BehaviorSubject.java rename to core/src/main/java/it/cavallium/warppi/flow/BehaviorSubject.java diff --git a/src/main/java/it/cavallium/warppi/flow/Consumer.java b/core/src/main/java/it/cavallium/warppi/flow/Consumer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Consumer.java rename to core/src/main/java/it/cavallium/warppi/flow/Consumer.java diff --git a/src/main/java/it/cavallium/warppi/flow/Disposable.java b/core/src/main/java/it/cavallium/warppi/flow/Disposable.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Disposable.java rename to core/src/main/java/it/cavallium/warppi/flow/Disposable.java diff --git a/src/main/java/it/cavallium/warppi/flow/IntervalsManager.java b/core/src/main/java/it/cavallium/warppi/flow/IntervalsManager.java similarity index 81% rename from src/main/java/it/cavallium/warppi/flow/IntervalsManager.java rename to core/src/main/java/it/cavallium/warppi/flow/IntervalsManager.java index 6138dcb1..ae58b3f8 100644 --- a/src/main/java/it/cavallium/warppi/flow/IntervalsManager.java +++ b/core/src/main/java/it/cavallium/warppi/flow/IntervalsManager.java @@ -3,7 +3,7 @@ package it.cavallium.warppi.flow; import java.util.LinkedList; import java.util.List; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; public class IntervalsManager { private static List intervals = new LinkedList<>(); @@ -41,8 +41,8 @@ public class IntervalsManager { e.printStackTrace(); } }); - PlatformUtils.setDaemon(t); - PlatformUtils.setThreadName(t, "Intervals Manager"); + Engine.getPlatform().setThreadDaemon(t); + Engine.getPlatform().setThreadName(t, "Intervals Manager"); t.start(); } } diff --git a/src/main/java/it/cavallium/warppi/flow/Observable.java b/core/src/main/java/it/cavallium/warppi/flow/Observable.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Observable.java rename to core/src/main/java/it/cavallium/warppi/flow/Observable.java diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableCombinedChanged.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableCombinedChanged.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/ObservableCombinedChanged.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableCombinedChanged.java diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableCombinedLatest.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableCombinedLatest.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/ObservableCombinedLatest.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableCombinedLatest.java diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableInterval.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableInterval.java similarity index 88% rename from src/main/java/it/cavallium/warppi/flow/ObservableInterval.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableInterval.java index fe328c7c..9530ca5e 100644 --- a/src/main/java/it/cavallium/warppi/flow/ObservableInterval.java +++ b/core/src/main/java/it/cavallium/warppi/flow/ObservableInterval.java @@ -1,6 +1,6 @@ package it.cavallium.warppi.flow; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; public class ObservableInterval extends Observable { private final long interval; @@ -50,7 +50,7 @@ public class ObservableInterval extends Observable { } catch (InterruptedException e) {} timeThread = null; }); - PlatformUtils.setThreadName(timeThread, "ObservableTimer"); + Engine.getPlatform().setThreadName(timeThread, "ObservableTimer"); timeThread.start(); running = true; } diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableMap.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableMap.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/ObservableMap.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableMap.java diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableMerged.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableMerged.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/ObservableMerged.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableMerged.java diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableSource.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableSource.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/ObservableSource.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableSource.java diff --git a/src/main/java/it/cavallium/warppi/flow/ObservableZipped.java b/core/src/main/java/it/cavallium/warppi/flow/ObservableZipped.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/ObservableZipped.java rename to core/src/main/java/it/cavallium/warppi/flow/ObservableZipped.java diff --git a/src/main/java/it/cavallium/warppi/flow/Observer.java b/core/src/main/java/it/cavallium/warppi/flow/Observer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Observer.java rename to core/src/main/java/it/cavallium/warppi/flow/Observer.java diff --git a/src/main/java/it/cavallium/warppi/flow/SimpleSubject.java b/core/src/main/java/it/cavallium/warppi/flow/SimpleSubject.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/SimpleSubject.java rename to core/src/main/java/it/cavallium/warppi/flow/SimpleSubject.java diff --git a/src/main/java/it/cavallium/warppi/flow/Subject.java b/core/src/main/java/it/cavallium/warppi/flow/Subject.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Subject.java rename to core/src/main/java/it/cavallium/warppi/flow/Subject.java diff --git a/src/main/java/it/cavallium/warppi/flow/Subscriber.java b/core/src/main/java/it/cavallium/warppi/flow/Subscriber.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Subscriber.java rename to core/src/main/java/it/cavallium/warppi/flow/Subscriber.java diff --git a/src/main/java/it/cavallium/warppi/flow/Subscription.java b/core/src/main/java/it/cavallium/warppi/flow/Subscription.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/Subscription.java rename to core/src/main/java/it/cavallium/warppi/flow/Subscription.java diff --git a/src/main/java/it/cavallium/warppi/flow/TestFlow.java b/core/src/main/java/it/cavallium/warppi/flow/TestFlow.java similarity index 100% rename from src/main/java/it/cavallium/warppi/flow/TestFlow.java rename to core/src/main/java/it/cavallium/warppi/flow/TestFlow.java diff --git a/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java b/core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java similarity index 95% rename from src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java rename to core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java index 574797e0..7b56ad63 100644 --- a/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java +++ b/core/src/main/java/it/cavallium/warppi/gui/CalculatorHUD.java @@ -1,6 +1,6 @@ package it.cavallium.warppi.gui; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.Utils; import it.cavallium.warppi.device.HardwareDevice; @@ -84,7 +84,7 @@ public class CalculatorHUD extends HUD { if (brightness <= 10) { renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16); } else { - ConsoleUtils.out.println(1, "Brightness error"); + Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness error"); } padding += 18 + 6; diff --git a/src/main/java/it/cavallium/warppi/gui/DisplayManager.java b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java old mode 100755 new mode 100644 similarity index 85% rename from src/main/java/it/cavallium/warppi/gui/DisplayManager.java rename to core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java index 8af5f62b..41b4078b --- a/src/main/java/it/cavallium/warppi/gui/DisplayManager.java +++ b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java @@ -6,12 +6,11 @@ import java.util.List; import org.apache.commons.lang3.tuple.Pair; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.Utils; -import it.cavallium.warppi.deps.DEngine; -import it.cavallium.warppi.deps.DSemaphore; -import it.cavallium.warppi.deps.DSystem; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; +import it.cavallium.warppi.deps.Platform.Semaphore; import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.gui.graphicengine.BinaryFont; @@ -44,7 +43,7 @@ public final class DisplayManager implements RenderingLoop { private final HUD hud; private final String initialTitle; private Screen initialScreen; - public DSemaphore screenChange = new DSemaphore(0); + public Semaphore screenChange; public String displayDebugString; public ObjectArrayList errorMessages; /** @@ -53,6 +52,7 @@ public final class DisplayManager implements RenderingLoop { public boolean forceRefresh; public DisplayManager(HardwareDisplay monitor, HUD hud, Screen screen, String title) { + screenChange = Engine.getPlatform().newSemaphore(); engine = chooseGraphicEngine(); supportsPauses = engine.doesRefreshPauses(); @@ -77,7 +77,7 @@ public final class DisplayManager implements RenderingLoop { } } catch (final Exception e) { e.printStackTrace(); - DSystem.exit(0); + Engine.getPlatform().exit(0); } try { @@ -123,45 +123,45 @@ public final class DisplayManager implements RenderingLoop { private GraphicEngine chooseGraphicEngine() { GraphicEngine d; if (!StaticVars.debugOn) { - d = DEngine.newFBEngine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "framebuffer engine", null); if (d != null && d.isSupported()) { - ConsoleUtils.out.println(1, "Using FB Graphic Engine"); + Engine.getPlatform().getConsoleUtils().out().println(1, "Using FB Graphic Engine"); return d; } } - d = DEngine.newGPUEngine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "GPU engine", null); if (d != null && d.isSupported()) { - ConsoleUtils.out.println(1, "Using GPU Graphic Engine"); + Engine.getPlatform().getConsoleUtils().out().println(1, "Using GPU Graphic Engine"); return d; } - d = DEngine.newCPUEngine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "CPU engine", null); if (d != null && d.isSupported()) { - ConsoleUtils.out.println(1, "Using CPU Graphic Engine"); + Engine.getPlatform().getConsoleUtils().out().println(1, "Using CPU Graphic Engine"); return d; } - d = DEngine.newHeadless24bitEngine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 24 bit engine", null); if (d != null && d.isSupported()) { System.err.println("Using Headless 24 bit Engine! This is a problem! No other graphic engines are available."); return d; } - d = DEngine.newHeadless256Engine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 256 colors engine", null); if (d != null && d.isSupported()) { System.err.println("Using Headless 256 Engine! This is a problem! No other graphic engines are available."); return d; } - d = DEngine.newHeadless8Engine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "headless 8 colors engine", null); if (d != null && d.isSupported()) { System.err.println("Using Headless basic Engine! This is a problem! No other graphic engines are available."); return d; } - d = DEngine.newHtmlEngine(); + d = Utils.getOrDefault(Engine.getPlatform().getEnginesList(), "HTML5 engine", null); if (d != null && d.isSupported()) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "Using Html Graphic Engine"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "Using Html Graphic Engine"); return d; } d = new NoGuiEngine(); if (d != null && d.isSupported()) { - ConsoleUtils.out.println(1, "Using NoGui Graphic Engine"); + Engine.getPlatform().getConsoleUtils().out().println(1, "Using NoGui Graphic Engine"); return d; } throw new UnsupportedOperationException("No graphic engines available."); @@ -193,7 +193,7 @@ public final class DisplayManager implements RenderingLoop { } } catch (final Exception e) { e.printStackTrace(); - DSystem.exit(0); + Engine.getPlatform().exit(0); } } @@ -218,7 +218,7 @@ public final class DisplayManager implements RenderingLoop { } } catch (final Exception e) { e.printStackTrace(); - DSystem.exit(0); + Engine.getPlatform().exit(0); } } @@ -385,7 +385,7 @@ public final class DisplayManager implements RenderingLoop { screen.initialize(); } catch (final Exception e) { e.printStackTrace(); - DSystem.exit(0); + Engine.getPlatform().exit(0); } Observable workTimer = Observable.interval(tickDuration); diff --git a/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java b/core/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java rename to core/src/main/java/it/cavallium/warppi/gui/GUIErrorMessage.java diff --git a/src/main/java/it/cavallium/warppi/gui/GraphicUtils.java b/core/src/main/java/it/cavallium/warppi/gui/GraphicUtils.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/GraphicUtils.java rename to core/src/main/java/it/cavallium/warppi/gui/GraphicUtils.java diff --git a/src/main/java/it/cavallium/warppi/gui/GraphicalElement.java b/core/src/main/java/it/cavallium/warppi/gui/GraphicalElement.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/GraphicalElement.java rename to core/src/main/java/it/cavallium/warppi/gui/GraphicalElement.java diff --git a/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java b/core/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java rename to core/src/main/java/it/cavallium/warppi/gui/GraphicalInterface.java diff --git a/src/main/java/it/cavallium/warppi/gui/HUD.java b/core/src/main/java/it/cavallium/warppi/gui/HUD.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/HUD.java rename to core/src/main/java/it/cavallium/warppi/gui/HUD.java diff --git a/src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java b/core/src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java rename to core/src/main/java/it/cavallium/warppi/gui/HardwareDisplay.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/Caret.java b/core/src/main/java/it/cavallium/warppi/gui/expression/Caret.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/Caret.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/Caret.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/CaretState.java b/core/src/main/java/it/cavallium/warppi/gui/expression/CaretState.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/CaretState.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/CaretState.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java b/core/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/ExtraMenu.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/InputContext.java b/core/src/main/java/it/cavallium/warppi/gui/expression/InputContext.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/InputContext.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/InputContext.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/Block.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockChar.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java old mode 100755 new mode 100644 similarity index 94% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java index 96112828..217c6fb5 --- a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java +++ b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockContainer.java @@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.expression.blocks; import it.cavallium.warppi.Error; import it.cavallium.warppi.Errors; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.gui.GraphicalElement; import it.cavallium.warppi.gui.expression.Caret; import it.cavallium.warppi.gui.expression.CaretState; @@ -352,7 +352,7 @@ public class BlockContainer implements GraphicalElement { private static void checkInitialized() { if (!initialized) { - PlatformUtils.throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!"); + Engine.getPlatform().throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!"); } } diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockDivision.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockExponentialNotation.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockLogarithm.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockNumericChar.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockNumericChar.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockNumericChar.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockNumericChar.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesis.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesis.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesis.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesis.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockParenthesisAbstract.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockPower.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockReference.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockReference.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockReference.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockReference.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSine.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSine.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSine.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSine.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockSquareRoot.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockUndefined.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java b/core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/blocks/BlockVariable.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/containers/InlineInputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/InlineInputContainer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/containers/InlineInputContainer.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/containers/InlineInputContainer.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/containers/InputContainer.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/containers/NormalInputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/NormalInputContainer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/containers/NormalInputContainer.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/containers/NormalInputContainer.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/containers/NormalOutputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/NormalOutputContainer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/containers/NormalOutputContainer.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/containers/NormalOutputContainer.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java b/core/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/containers/OutputContainer.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/layouts/InputLayout.java b/core/src/main/java/it/cavallium/warppi/gui/expression/layouts/InputLayout.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/layouts/InputLayout.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/layouts/InputLayout.java diff --git a/src/main/java/it/cavallium/warppi/gui/expression/layouts/OutputLayout.java b/core/src/main/java/it/cavallium/warppi/gui/expression/layouts/OutputLayout.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/expression/layouts/OutputLayout.java rename to core/src/main/java/it/cavallium/warppi/gui/expression/layouts/OutputLayout.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/BinaryFont.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/BinaryFont.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/BinaryFont.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/BinaryFont.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/GraphicEngine.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/Renderer.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/RenderingLoop.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/Skin.java diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/common/PngSkin.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/common/PngSkin.java new file mode 100644 index 00000000..6ea05608 --- /dev/null +++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/common/PngSkin.java @@ -0,0 +1,77 @@ +package it.cavallium.warppi.gui.graphicengine.common; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; + +import javax.imageio.ImageIO; + +import it.cavallium.warppi.Engine; +import it.cavallium.warppi.deps.Platform.PngUtils.PngReader; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.Skin; + +public abstract class PngSkin implements Skin { + + public int[] skinData; + public int[] skinSize; + @SuppressWarnings("unused") + private final boolean isResource; + + public PngSkin(String file) throws IOException { + isResource = !new File(file).exists(); + load(file); + } + + @SuppressWarnings("unused") + @Override + public void load(String file) throws IOException { + if (!file.startsWith("/")) + file = "/" + file; + try { + if (!file.endsWith(".png")) { + File f = File.createTempFile("picalculator-png", ".png"); + f.deleteOnExit(); + BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream(file)); + ImageIO.write(img, "PNG", f); + file = f.toString(); + } + 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 (URISyntaxException e) { + IOException ex = new IOException(); + ex.initCause(e); + throw ex; + } + } + + @Override + public void initialize(GraphicEngine d) { + // TODO Auto-generated method stub + + } + + @Override + public boolean isInitialized() { + return true; + } + + @Override + public int getSkinWidth() { + return skinSize[0]; + } + + @Override + public int getSkinHeight() { + return skinSize[1]; + } + +} diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUFont.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/common/RFTFont.java old mode 100755 new mode 100644 similarity index 85% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUFont.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/common/RFTFont.java index b6f616cd..af1b7196 --- a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUFont.java +++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/common/RFTFont.java @@ -1,4 +1,4 @@ -package it.cavallium.warppi.gui.graphicengine.cpu; +package it.cavallium.warppi.gui.graphicengine.common; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -12,15 +12,13 @@ import java.util.logging.Logger; import javax.imageio.ImageIO; -import it.cavallium.warppi.ConsoleUtils; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.Utils; -import it.cavallium.warppi.deps.DSystem; -import it.cavallium.warppi.deps.StorageUtils; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -public class CPUFont implements BinaryFont { +public abstract class RFTFont implements BinaryFont { public boolean[][] rawchars; public int[] chars32; @@ -36,30 +34,30 @@ public class CPUFont implements BinaryFont { @SuppressWarnings("unused") private final boolean isResource; - public CPUFont(String fontName) throws IOException { + public RFTFont(String fontName) throws IOException { this(fontName, false); } - CPUFont(String fontName, boolean onlyRaw) throws IOException { + RFTFont(String fontName, boolean onlyRaw) throws IOException { isResource = true; load("/font_" + fontName + ".rft", onlyRaw); } - public CPUFont(String path, String fontName) throws IOException { + public RFTFont(String path, String fontName) throws IOException { this(path, fontName, false); } - CPUFont(String path, String fontName, boolean onlyRaw) throws IOException { + RFTFont(String path, String fontName, boolean onlyRaw) throws IOException { isResource = false; load(path + "/font_" + fontName + ".rft", onlyRaw); } - public static CPUFont loadTemporaryFont(String name) throws IOException { - return new CPUFont(name, true); + public static RFTFont loadTemporaryFont(String name) throws IOException { + return new BlankRFTFont(name, true); } - public static CPUFont loadTemporaryFont(String path, String name) throws IOException { - return new CPUFont(path, name, true); + public static RFTFont loadTemporaryFont(String path, String name) throws IOException { + return new BlankRFTFont(path, name, true); } @Override @@ -68,7 +66,7 @@ public class CPUFont implements BinaryFont { } private void load(String path, boolean onlyRaw) throws IOException { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Loading font " + path); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Loading font " + path); loadFont(path); if (!onlyRaw) { chars32 = new int[(intervalsTotalSize) * charIntCount]; @@ -100,7 +98,7 @@ public class CPUFont implements BinaryFont { } } - PlatformUtils.gc(); + Engine.getPlatform().gc(); } private void loadFont(String string) throws IOException { @@ -108,7 +106,7 @@ public class CPUFont implements BinaryFont { try { if (!string.startsWith("/")) string = "/" + string; - res = StorageUtils.getResourceStream(string); + res = Engine.getPlatform().getStorageUtils().getResourceStream(string); } catch (URISyntaxException e) { IOException ex = new IOException(); ex.initCause(e); @@ -152,7 +150,7 @@ public class CPUFont implements BinaryFont { } catch (final Exception ex) { ex.printStackTrace(); System.out.println(string); - DSystem.exit(-1); + Engine.getPlatform().exit(-1); } } } else { @@ -292,13 +290,6 @@ public class CPUFont implements BinaryFont { @Override public void initialize(GraphicEngine d) {} - @Override - public void use(GraphicEngine d) { - if (d.getRenderer() instanceof CPURenderer) { - ((CPURenderer) d.getRenderer()).currentFont = this; - } - } - @Override public int getStringWidth(String text) { final int w = charW * text.length(); @@ -333,5 +324,22 @@ public class CPUFont implements BinaryFont { public int getSkinHeight() { return -1; } + + private static class BlankRFTFont extends RFTFont { + + BlankRFTFont(String fontName, boolean onlyRaw) throws IOException { + super(fontName, onlyRaw); + } + + public BlankRFTFont(String path, String name, boolean b) throws IOException { + super(path, name, b); + } + + @Override + public void use(GraphicEngine d) { + + } + + } } diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/nogui/NoGuiEngine.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/nogui/NoGuiEngine.java similarity index 92% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/nogui/NoGuiEngine.java rename to core/src/main/java/it/cavallium/warppi/gui/graphicengine/nogui/NoGuiEngine.java index 8f9b5967..6c93d9dd 100644 --- a/src/main/java/it/cavallium/warppi/gui/graphicengine/nogui/NoGuiEngine.java +++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/nogui/NoGuiEngine.java @@ -2,7 +2,8 @@ package it.cavallium.warppi.gui.graphicengine.nogui; import java.io.IOException; -import it.cavallium.warppi.deps.DSemaphore; +import it.cavallium.warppi.Engine; +import it.cavallium.warppi.deps.Platform.Semaphore; import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.GraphicEngine; @@ -13,7 +14,7 @@ import it.cavallium.warppi.gui.graphicengine.Skin; public class NoGuiEngine implements GraphicEngine { private boolean initialized; - public DSemaphore exitSemaphore = new DSemaphore(0); + public Semaphore exitSemaphore = Engine.getPlatform().newSemaphore(0); @Override public int[] getSize() { diff --git a/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/ChooseVariableValueScreen.java diff --git a/src/main/java/it/cavallium/warppi/gui/screens/EmptyScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/EmptyScreen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/EmptyScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/EmptyScreen.java diff --git a/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/KeyboardDebugScreen.java diff --git a/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/LoadingScreen.java diff --git a/src/main/java/it/cavallium/warppi/gui/screens/MarioScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/MarioScreen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/MarioScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/MarioScreen.java diff --git a/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java old mode 100755 new mode 100644 similarity index 92% rename from src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java index 94239c70..9a58d84e --- a/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java +++ b/core/src/main/java/it/cavallium/warppi/gui/screens/MathInputScreen.java @@ -2,13 +2,12 @@ package it.cavallium.warppi.gui.screens; import java.io.IOException; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.Error; import it.cavallium.warppi.Errors; -import it.cavallium.warppi.PlatformUtils; import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.Utils; -import it.cavallium.warppi.deps.DSystem; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; import it.cavallium.warppi.device.HardwareDevice; import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.event.Key; @@ -71,7 +70,7 @@ public class MathInputScreen extends Screen { BlockContainer.initializeFonts(HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("norm"), HardwareDevice.INSTANCE.getDisplayManager().engine.loadFont("smal")); } catch (final IOException e) { e.printStackTrace(); - DSystem.exit(1); + Engine.getPlatform().exit(1); } userInput = new NormalInputContainer(ic); @@ -172,7 +171,7 @@ public class MathInputScreen extends Screen { @Override public boolean onKeyPressed(KeyPressedEvent k) { - ConsoleUtils.out.println(1, k.toString()); + Engine.getPlatform().getConsoleUtils().out().println(1, k.toString()); try { switch (k.getKey()) { case OK: @@ -202,7 +201,7 @@ public class MathInputScreen extends Screen { } if (HardwareDevice.INSTANCE.getDisplayManager().error != null) { //TODO: make the error management a global API rather than being relegated to this screen. - ConsoleUtils.out.println(1, "Resetting after error..."); + Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error..."); HardwareDevice.INSTANCE.getDisplayManager().error = null; calc.f = null; calc.f2 = null; @@ -224,13 +223,13 @@ public class MathInputScreen extends Screen { calc.f2.clear(); } calc.f.add(expr); - ConsoleUtils.out.println(2, "INPUT: " + expr); + Engine.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr); final MathSolver ms = new MathSolver(expr); final ObjectArrayList> resultSteps = ms.solveAllSteps(); resultSteps.add(0, Utils.newArrayList(expr)); final ObjectArrayList resultExpressions = resultSteps.get(resultSteps.size() - 1); for (final Function rr : resultExpressions) { - ConsoleUtils.out.println(0, "RESULT: " + rr.toString()); + Engine.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString()); } final ObjectArrayList> resultBlocks = MathParser.parseOutput(calc, resultExpressions); result.setContentAsMultipleGroups(resultBlocks); @@ -240,7 +239,7 @@ public class MathInputScreen extends Screen { // }); } } catch (final InterruptedException ex) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped."); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped."); } catch (final Exception ex) { if (StaticVars.debugOn) { ex.printStackTrace(); @@ -248,14 +247,14 @@ public class MathInputScreen extends Screen { throw new Error(Errors.SYNTAX_ERROR); } } catch (final Error e) { - d.errorStackTrace = PlatformUtils.stacktraceToString(e); + d.errorStackTrace = Engine.getPlatform().stacktraceToString(e); HardwareDevice.INSTANCE.getDisplayManager().error = e.id.toString(); System.err.println(e.id); } computingResult = false; }); - PlatformUtils.setThreadName(computingThread, "Computing Thread"); - PlatformUtils.setDaemon(computingThread); + Engine.getPlatform().setThreadName(computingThread, "Computing Thread"); + Engine.getPlatform().setThreadDaemon(computingThread); computingThread.setPriority(Thread.NORM_PRIORITY + 3); computingThread.start(); return true; @@ -388,7 +387,7 @@ public class MathInputScreen extends Screen { result.clear(); currentStep = 0; if (HardwareDevice.INSTANCE.getDisplayManager().error != null) { - ConsoleUtils.out.println(1, "Resetting after error..."); + Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error..."); HardwareDevice.INSTANCE.getDisplayManager().error = null; } return true; @@ -662,9 +661,9 @@ public class MathInputScreen extends Screen { } } }); - PlatformUtils.setThreadName(ct, "Variables user-input queue thread"); + Engine.getPlatform().setThreadName(ct, "Variables user-input queue thread"); ct.setPriority(Thread.MIN_PRIORITY); - PlatformUtils.setDaemon(ct); + Engine.getPlatform().setThreadDaemon(ct); ct.start(); } diff --git a/src/main/java/it/cavallium/warppi/gui/screens/Screen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/Screen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/Screen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/Screen.java diff --git a/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java b/core/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java rename to core/src/main/java/it/cavallium/warppi/gui/screens/SolveForXScreen.java diff --git a/src/main/java/it/cavallium/warppi/math/AngleMode.java b/core/src/main/java/it/cavallium/warppi/math/AngleMode.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/AngleMode.java rename to core/src/main/java/it/cavallium/warppi/math/AngleMode.java diff --git a/src/main/java/it/cavallium/warppi/math/Function.java b/core/src/main/java/it/cavallium/warppi/math/Function.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/Function.java rename to core/src/main/java/it/cavallium/warppi/math/Function.java diff --git a/src/main/java/it/cavallium/warppi/math/FunctionDynamic.java b/core/src/main/java/it/cavallium/warppi/math/FunctionDynamic.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/FunctionDynamic.java rename to core/src/main/java/it/cavallium/warppi/math/FunctionDynamic.java diff --git a/src/main/java/it/cavallium/warppi/math/FunctionOperator.java b/core/src/main/java/it/cavallium/warppi/math/FunctionOperator.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/FunctionOperator.java rename to core/src/main/java/it/cavallium/warppi/math/FunctionOperator.java diff --git a/src/main/java/it/cavallium/warppi/math/FunctionSingle.java b/core/src/main/java/it/cavallium/warppi/math/FunctionSingle.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/FunctionSingle.java rename to core/src/main/java/it/cavallium/warppi/math/FunctionSingle.java diff --git a/src/main/java/it/cavallium/warppi/math/MathContext.java b/core/src/main/java/it/cavallium/warppi/math/MathContext.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/MathContext.java rename to core/src/main/java/it/cavallium/warppi/math/MathContext.java diff --git a/src/main/java/it/cavallium/warppi/math/MathematicalSymbols.java b/core/src/main/java/it/cavallium/warppi/math/MathematicalSymbols.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/MathematicalSymbols.java rename to core/src/main/java/it/cavallium/warppi/math/MathematicalSymbols.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Division.java b/core/src/main/java/it/cavallium/warppi/math/functions/Division.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Division.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Division.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/EmptyNumber.java b/core/src/main/java/it/cavallium/warppi/math/functions/EmptyNumber.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/EmptyNumber.java rename to core/src/main/java/it/cavallium/warppi/math/functions/EmptyNumber.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Expression.java b/core/src/main/java/it/cavallium/warppi/math/functions/Expression.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Expression.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Expression.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Joke.java b/core/src/main/java/it/cavallium/warppi/math/functions/Joke.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Joke.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Joke.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Logarithm.java b/core/src/main/java/it/cavallium/warppi/math/functions/Logarithm.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Logarithm.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Logarithm.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Multiplication.java b/core/src/main/java/it/cavallium/warppi/math/functions/Multiplication.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Multiplication.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Multiplication.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Negative.java b/core/src/main/java/it/cavallium/warppi/math/functions/Negative.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Negative.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Negative.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Number.java b/core/src/main/java/it/cavallium/warppi/math/functions/Number.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Number.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Number.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Power.java b/core/src/main/java/it/cavallium/warppi/math/functions/Power.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Power.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Power.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Root.java b/core/src/main/java/it/cavallium/warppi/math/functions/Root.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Root.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Root.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/RootSquare.java b/core/src/main/java/it/cavallium/warppi/math/functions/RootSquare.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/RootSquare.java rename to core/src/main/java/it/cavallium/warppi/math/functions/RootSquare.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Subtraction.java b/core/src/main/java/it/cavallium/warppi/math/functions/Subtraction.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Subtraction.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Subtraction.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Sum.java b/core/src/main/java/it/cavallium/warppi/math/functions/Sum.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Sum.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Sum.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/SumSubtraction.java b/core/src/main/java/it/cavallium/warppi/math/functions/SumSubtraction.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/SumSubtraction.java rename to core/src/main/java/it/cavallium/warppi/math/functions/SumSubtraction.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Undefined.java b/core/src/main/java/it/cavallium/warppi/math/functions/Undefined.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Undefined.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Undefined.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/Variable.java b/core/src/main/java/it/cavallium/warppi/math/functions/Variable.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/Variable.java rename to core/src/main/java/it/cavallium/warppi/math/functions/Variable.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/equations/Equation.java b/core/src/main/java/it/cavallium/warppi/math/functions/equations/Equation.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/equations/Equation.java rename to core/src/main/java/it/cavallium/warppi/math/functions/equations/Equation.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/equations/EquationResult.java b/core/src/main/java/it/cavallium/warppi/math/functions/equations/EquationResult.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/equations/EquationResult.java rename to core/src/main/java/it/cavallium/warppi/math/functions/equations/EquationResult.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystem.java b/core/src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystem.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystem.java rename to core/src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystem.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystemPart.java b/core/src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystemPart.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystemPart.java rename to core/src/main/java/it/cavallium/warppi/math/functions/equations/EquationsSystemPart.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcCosine.java b/core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcCosine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcCosine.java rename to core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcCosine.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcSine.java b/core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcSine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcSine.java rename to core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcSine.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcTangent.java b/core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcTangent.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcTangent.java rename to core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/ArcTangent.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Cosine.java b/core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Cosine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/trigonometry/Cosine.java rename to core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Cosine.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Sine.java b/core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Sine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/trigonometry/Sine.java rename to core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Sine.java diff --git a/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Tangent.java b/core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Tangent.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/functions/trigonometry/Tangent.java rename to core/src/main/java/it/cavallium/warppi/math/functions/trigonometry/Tangent.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/MathParser.java b/core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java old mode 100755 new mode 100644 similarity index 89% rename from src/main/java/it/cavallium/warppi/math/parser/MathParser.java rename to core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java index 9f5d8f17..ab938543 --- a/src/main/java/it/cavallium/warppi/math/parser/MathParser.java +++ b/core/src/main/java/it/cavallium/warppi/math/parser/MathParser.java @@ -1,10 +1,11 @@ package it.cavallium.warppi.math.parser; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.Error; import it.cavallium.warppi.Errors; import it.cavallium.warppi.IntegerObj; import it.cavallium.warppi.StaticVars; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; import it.cavallium.warppi.gui.expression.blocks.Block; import it.cavallium.warppi.gui.expression.containers.InputContainer; import it.cavallium.warppi.math.Function; @@ -84,16 +85,16 @@ public class MathParser { Function lastElement; if (StaticVars.debugOn) { - ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: "); + Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: "); for (final Function f : functionsList) { - ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString()); + Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString()); } - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE); } for (final MathParserStep step : steps) { if (StaticVars.debugOn) { - ConsoleUtils.out.println(2, "Stack fixing step \"" + step.getStepName() + "\""); + Engine.getPlatform().getConsoleUtils().out().println(2, "Stack fixing step \"" + step.getStepName() + "\""); } final int stepQty = step.requiresReversedIteration() ? -1 : 1, initialIndex = step.requiresReversedIteration() ? functionsList.size() - 1 : 0; @@ -115,11 +116,11 @@ public class MathParser { } while (lastLoopDidSomething); if (StaticVars.debugOn) { - ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: "); + Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: "); for (final Function f : functionsList) { - ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString()); + Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString()); } - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE); } } diff --git a/src/main/java/it/cavallium/warppi/math/parser/MathParserStep.java b/core/src/main/java/it/cavallium/warppi/math/parser/MathParserStep.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/MathParserStep.java rename to core/src/main/java/it/cavallium/warppi/math/parser/MathParserStep.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureChar.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureChar.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureChar.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureChar.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureDivision.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureDivision.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureDivision.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureDivision.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureDoubleImpl.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureDoubleImpl.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureDoubleImpl.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureDoubleImpl.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureLogarithm.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureLogarithm.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureLogarithm.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureLogarithm.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureMultiplication.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureMultiplication.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureMultiplication.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureMultiplication.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureNumber.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureNumber.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureNumber.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureNumber.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureParenthesis.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureParenthesis.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureParenthesis.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureParenthesis.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeaturePower.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeaturePower.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeaturePower.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeaturePower.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeaturePowerChar.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeaturePowerChar.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeaturePowerChar.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeaturePowerChar.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSine.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSine.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureSine.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSine.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSingleImpl.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSingleImpl.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureSingleImpl.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSingleImpl.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSquareRoot.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSquareRoot.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureSquareRoot.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSquareRoot.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSubtraction.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSubtraction.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureSubtraction.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSubtraction.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSum.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSum.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureSum.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSum.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSumSubtraction.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSumSubtraction.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureSumSubtraction.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureSumSubtraction.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/FeatureVariable.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureVariable.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/FeatureVariable.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/FeatureVariable.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/Feature.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/Feature.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/interfaces/Feature.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/Feature.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureBasic.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureBasic.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureBasic.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureBasic.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureDouble.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureDouble.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureDouble.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureDouble.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureMultiple.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureMultiple.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureMultiple.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureMultiple.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureSingle.java b/core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureSingle.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureSingle.java rename to core/src/main/java/it/cavallium/warppi/math/parser/features/interfaces/FeatureSingle.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/steps/AddImplicitMultiplications.java b/core/src/main/java/it/cavallium/warppi/math/parser/steps/AddImplicitMultiplications.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/steps/AddImplicitMultiplications.java rename to core/src/main/java/it/cavallium/warppi/math/parser/steps/AddImplicitMultiplications.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/steps/FixMultiplicationsAndDivisions.java b/core/src/main/java/it/cavallium/warppi/math/parser/steps/FixMultiplicationsAndDivisions.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/steps/FixMultiplicationsAndDivisions.java rename to core/src/main/java/it/cavallium/warppi/math/parser/steps/FixMultiplicationsAndDivisions.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/steps/FixSingleFunctionArgs.java b/core/src/main/java/it/cavallium/warppi/math/parser/steps/FixSingleFunctionArgs.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/steps/FixSingleFunctionArgs.java rename to core/src/main/java/it/cavallium/warppi/math/parser/steps/FixSingleFunctionArgs.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/steps/FixSumsAndSubtractions.java b/core/src/main/java/it/cavallium/warppi/math/parser/steps/FixSumsAndSubtractions.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/steps/FixSumsAndSubtractions.java rename to core/src/main/java/it/cavallium/warppi/math/parser/steps/FixSumsAndSubtractions.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/steps/JoinNumberAndVariables.java b/core/src/main/java/it/cavallium/warppi/math/parser/steps/JoinNumberAndVariables.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/steps/JoinNumberAndVariables.java rename to core/src/main/java/it/cavallium/warppi/math/parser/steps/JoinNumberAndVariables.java diff --git a/src/main/java/it/cavallium/warppi/math/parser/steps/RemoveParentheses.java b/core/src/main/java/it/cavallium/warppi/math/parser/steps/RemoveParentheses.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/parser/steps/RemoveParentheses.java rename to core/src/main/java/it/cavallium/warppi/math/parser/steps/RemoveParentheses.java diff --git a/src/main/java/it/cavallium/warppi/math/rules/Rule.java b/core/src/main/java/it/cavallium/warppi/math/rules/Rule.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/rules/Rule.java rename to core/src/main/java/it/cavallium/warppi/math/rules/Rule.java diff --git a/src/main/java/it/cavallium/warppi/math/rules/RuleType.java b/core/src/main/java/it/cavallium/warppi/math/rules/RuleType.java similarity index 100% rename from src/main/java/it/cavallium/warppi/math/rules/RuleType.java rename to core/src/main/java/it/cavallium/warppi/math/rules/RuleType.java diff --git a/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java b/core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java similarity index 62% rename from src/main/java/it/cavallium/warppi/math/rules/RulesManager.java rename to core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java index f5245e0d..d2db609a 100644 --- a/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java +++ b/core/src/main/java/it/cavallium/warppi/math/rules/RulesManager.java @@ -10,17 +10,13 @@ import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import java.util.zip.ZipFile; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.Error; -import it.cavallium.warppi.PlatformUtils; import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.ZipUtils; -import it.cavallium.warppi.deps.DJDTCompiler; -import it.cavallium.warppi.deps.DStandardOpenOption; -import it.cavallium.warppi.deps.DSystem; -import it.cavallium.warppi.deps.DURLClassLoader; -import it.cavallium.warppi.deps.StorageUtils; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; +import it.cavallium.warppi.deps.Platform.URLClassLoader; import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.MathContext; import it.cavallium.warppi.math.functions.Expression; @@ -37,7 +33,7 @@ public class RulesManager { @SuppressWarnings({ "unchecked", "unused" }) public static void initialize() { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules"); rules = new ObjectArrayList[RuleType.values().length]; for (final RuleType val : RuleType.values()) { rules[val.ordinal()] = new ObjectArrayList<>(); @@ -46,25 +42,25 @@ public class RulesManager { boolean compiledSomething = false; InputStream defaultRulesList; try { - defaultRulesList = StorageUtils.getResourceStream("/default-rules.lst"); + defaultRulesList = Engine.getPlatform().getStorageUtils().getResourceStream("/default-rules.lst"); } catch (IOException ex) { throw new FileNotFoundException("default-rules.lst not found!"); } final List ruleLines = new ArrayList<>(); - final File rulesPath = StorageUtils.get("rules/"); + final File rulesPath = Engine.getPlatform().getStorageUtils().get("rules/"); if (rulesPath.exists()) { - for (File f : StorageUtils.walk(rulesPath)) { + for (File f : Engine.getPlatform().getStorageUtils().walk(rulesPath)) { if (f.toString().endsWith(".java")) { - String path = StorageUtils.relativize(rulesPath, f).toString(); + String path = Engine.getPlatform().getStorageUtils().relativize(rulesPath, f).toString(); path = path.substring(0, path.length() - ".java".length()); ruleLines.add(path); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Found external rule: " + f.getAbsolutePath()); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Found external rule: " + f.getAbsolutePath()); } } } - ruleLines.addAll(StorageUtils.readAllLines(defaultRulesList)); + ruleLines.addAll(Engine.getPlatform().getStorageUtils().readAllLines(defaultRulesList)); - final File tDir = StorageUtils.resolve(StorageUtils.get(System.getProperty("java.io.tmpdir"), "WarpPi-Calculator"), "rules-rt"); + final File tDir = Engine.getPlatform().getStorageUtils().resolve(Engine.getPlatform().getStorageUtils().get(System.getProperty("java.io.tmpdir"), "WarpPi-Calculator"), "rules-rt"); // try { // final Path defaultResource = Utils.getResource("/math-rules-cache.zip"); // } @@ -72,15 +68,15 @@ public class RulesManager { File cacheFilePath = null; cacheFilePath = new File("math-rules-cache.zip"); boolean cacheFileExists = false; - if (PlatformUtils.isJavascript) { - PlatformUtils.loadPlatformRules(); + if (Engine.getPlatform().isJavascript()) { + Engine.getPlatform().loadPlatformRules(); } else { if (cacheFilePath.exists()) { cacheFileExists = true; cacheFileStream = new FileInputStream(cacheFilePath); } else { try { - cacheFileStream = StorageUtils.getResourceStream("/math-rules-cache.zip");//Paths.get(Utils.getJarDirectory().toString()).resolve("math-rules-cache.zip").toAbsolutePath( + cacheFileStream = Engine.getPlatform().getStorageUtils().getResourceStream("/math-rules-cache.zip");//Paths.get(Utils.getJarDirectory().toString()).resolve("math-rules-cache.zip").toAbsolutePath( org.apache.commons.io.FileUtils.copyInputStreamToFile(cacheFileStream, cacheFilePath); cacheFileExists = true; } catch (IOException ex) { //File does not exists. @@ -92,7 +88,7 @@ public class RulesManager { if (tDir.exists()) { tDir.delete(); } - ZipUtils.unzip(cacheFilePath.toString(), tDir.getParent().toString(), ""); + Engine.getPlatform().unzip(cacheFilePath.toString(), tDir.getParent().toString(), ""); useCache = !StaticVars.startupArguments.isUncached(); } catch (final Exception ex) { ex.printStackTrace(); @@ -104,28 +100,28 @@ public class RulesManager { final String[] ruleDetails = rulesLine.split(",", 1); final String ruleName = ruleDetails[0]; final String ruleNameEscaped = ruleName.replace(".", "_"); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Evaluating /rules/" + ruleNameEscaped + ".java"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Evaluating /rules/" + ruleNameEscaped + ".java"); final String pathWithoutExtension = "/rules/" + ruleNameEscaped; final String scriptFile = pathWithoutExtension + ".java"; - final InputStream resourcePath = StorageUtils.getResourceStream(scriptFile); + final InputStream resourcePath = Engine.getPlatform().getStorageUtils().getResourceStream(scriptFile); if (resourcePath == null) { System.err.println(new FileNotFoundException("/rules/" + ruleName + ".java not found!")); } else { Rule r = null; if (useCache) { try { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Trying to load cached rule"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Trying to load cached rule"); r = loadClassRuleFromSourceFile(scriptFile, tDir); if (r != null) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Loaded cached rule"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Loaded cached rule"); } } catch (final Exception e) { e.printStackTrace(); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", ruleName, "Can't load the rule!"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", ruleName, "Can't load the rule!"); } } if (r == null || !useCache) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "This rule is not cached. Compiling"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "This rule is not cached. Compiling"); try { r = compileJavaRule(scriptFile, tDir); compiledSomething = true; @@ -141,27 +137,27 @@ public class RulesManager { } } } - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loaded all the rules successfully"); - if (!PlatformUtils.isJavascript && compiledSomething) { + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loaded all the rules successfully"); + if (!Engine.getPlatform().isJavascript() && compiledSomething) { if (cacheFileExists || cacheFilePath.exists()) { cacheFilePath.delete(); } - ZipUtils.zip(tDir.toString(), cacheFilePath.toString(), ""); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Cached the compiled rules"); + Engine.getPlatform().zip(tDir.toString(), cacheFilePath.toString(), ""); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Cached the compiled rules"); } if (cacheFileStream != null) { cacheFileStream.close(); } } catch (URISyntaxException | IOException e) { e.printStackTrace(); - DSystem.exit(1); + Engine.getPlatform().exit(1); } } public static Rule compileJavaRule(String scriptFile, File tDir) throws IOException, URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException { - final InputStream resource = StorageUtils.getResourceStream(scriptFile); - final String text = StorageUtils.read(resource); + final InputStream resource = Engine.getPlatform().getStorageUtils().getResourceStream(scriptFile); + final String text = Engine.getPlatform().getStorageUtils().read(resource); final String[] textArray = text.split("\\n", 6); if (textArray[3].contains("PATH=")) { final String javaClassDeclaration = textArray[3].substring(6); @@ -170,17 +166,17 @@ public class RulesManager { final String javaClassNameAndPath = new StringBuilder("it.cavallium.warppi.math.rules.").append(javaClassDeclaration).toString(); extIndex = javaClassNameAndPath.lastIndexOf('.'); final String javaCode = new StringBuilder("package ").append(javaClassNameAndPath.substring(0, extIndex >= 0 ? extIndex : javaClassNameAndPath.length())).append(";\n").append(textArray[5]).toString(); - final File tDirPath = StorageUtils.getParent(StorageUtils.resolve(tDir, javaClassNameAndPath.replace('.', File.separatorChar))); - final File tFileJava = StorageUtils.resolve(tDirPath, javaClassNameOnly + ".java"); - final File tFileClass = StorageUtils.resolve(tDirPath, javaClassNameOnly + ".class"); + final File tDirPath = Engine.getPlatform().getStorageUtils().getParent(Engine.getPlatform().getStorageUtils().resolve(tDir, javaClassNameAndPath.replace('.', File.separatorChar))); + final File tFileJava = Engine.getPlatform().getStorageUtils().resolve(tDirPath, javaClassNameOnly + ".java"); + final File tFileClass = Engine.getPlatform().getStorageUtils().resolve(tDirPath, javaClassNameOnly + ".class"); if (!tDirPath.exists()) { - StorageUtils.createDirectories(tDirPath); + Engine.getPlatform().getStorageUtils().createDirectories(tDirPath); } if (tFileJava.exists()) { tFileJava.delete(); } - StorageUtils.write(tFileJava, javaCode.getBytes("UTF-8"), DStandardOpenOption.WRITE, DStandardOpenOption.CREATE); - final boolean compiled = DJDTCompiler.compile(new String[] { "-nowarn", "-1.8", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err)); + Engine.getPlatform().getStorageUtils().write(tFileJava, javaCode.getBytes("UTF-8"), Engine.getPlatform().getStorageUtils().OpenOptionWrite, Engine.getPlatform().getStorageUtils().OpenOptionCreate); + final boolean compiled = Engine.getPlatform().compile(new String[] { "-nowarn", "-1.8", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err)); if (StaticVars.startupArguments.isUncached()) { tFileJava.deleteOnExit(); } else { @@ -199,8 +195,8 @@ public class RulesManager { public static Rule loadClassRuleFromSourceFile(String scriptFile, File tDir) throws IOException, URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException { - final InputStream resource = StorageUtils.getResourceStream(scriptFile); - final String text = StorageUtils.read(resource); + final InputStream resource = Engine.getPlatform().getStorageUtils().getResourceStream(scriptFile); + final String text = Engine.getPlatform().getStorageUtils().read(resource); final String[] textArray = text.split("\\n", 6); if (textArray[3].contains("PATH=")) { final String javaClassName = textArray[3].substring(6); @@ -219,7 +215,7 @@ public class RulesManager { public static Rule loadClassRuleDirectly(String javaClassNameAndPath, File tDir) throws IOException, URISyntaxException, InstantiationException, IllegalAccessException, ClassNotFoundException { - final DURLClassLoader cl = new DURLClassLoader(new URL[] { tDir.toURI().toURL() }); + final URLClassLoader cl = Engine.getPlatform().newURLClassLoader(new URL[] { tDir.toURI().toURL() }); final Class aClass = cl.loadClass(javaClassNameAndPath); cl.close(); return (Rule) aClass.newInstance(); @@ -261,6 +257,6 @@ public class RulesManager { public static void addRule(Rule rule) { rules[rule.getRuleType().ordinal()].add(rule); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule"); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule"); } } diff --git a/src/main/java/it/cavallium/warppi/math/rules/methods/DivisionRule1.java b/core/src/main/java/it/cavallium/warppi/math/rules/methods/DivisionRule1.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/rules/methods/DivisionRule1.java rename to core/src/main/java/it/cavallium/warppi/math/rules/methods/DivisionRule1.java diff --git a/src/main/java/it/cavallium/warppi/math/rules/methods/MultiplicationMethod1.java b/core/src/main/java/it/cavallium/warppi/math/rules/methods/MultiplicationMethod1.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/rules/methods/MultiplicationMethod1.java rename to core/src/main/java/it/cavallium/warppi/math/rules/methods/MultiplicationMethod1.java diff --git a/src/main/java/it/cavallium/warppi/math/rules/methods/SumMethod1.java b/core/src/main/java/it/cavallium/warppi/math/rules/methods/SumMethod1.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/rules/methods/SumMethod1.java rename to core/src/main/java/it/cavallium/warppi/math/rules/methods/SumMethod1.java diff --git a/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java b/core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java similarity index 69% rename from src/main/java/it/cavallium/warppi/math/solver/MathSolver.java rename to core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java index e96c9137..dc26c807 100644 --- a/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java +++ b/core/src/main/java/it/cavallium/warppi/math/solver/MathSolver.java @@ -1,11 +1,12 @@ package it.cavallium.warppi.math.solver; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.Error; import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.deps.DAtomicInteger; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; import it.cavallium.warppi.math.Function; import it.cavallium.warppi.math.rules.Rule; import it.cavallium.warppi.math.rules.RuleType; @@ -14,7 +15,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; public class MathSolver { private final Function initialFunction; - private final DAtomicInteger stepState = new DAtomicInteger(0); + private final AtomicInteger stepState = new AtomicInteger(0); private int stepStateRepetitions = 0; private int consecutiveNullSteps = 0; @@ -34,11 +35,11 @@ public class MathSolver { public ObjectArrayList> solveAllSteps() throws InterruptedException, Error { final ObjectArrayList> steps = new ObjectArrayList<>(); ObjectArrayList lastFnc = null, currFnc = new ObjectArrayList<>(); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString()); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString()); currFnc.add(initialFunction); long stepNumber = 0; int initStepState = 0, endStepState = 0; - final DAtomicInteger stepState = new DAtomicInteger(0); + final AtomicInteger stepState = new AtomicInteger(0); do { final ObjectArrayList[] currFncHistory = new ObjectArrayList[stepStates.length]; final String stepName = "Step " + stepNumber; @@ -60,11 +61,11 @@ public class MathSolver { } lastFnc = currFnc; initStepState = stepState.get(); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc); final ObjectArrayList stepResult = solveStep(lastFnc, stepState); if (stepResult != null) { for (final Function result : stepResult) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString()); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString()); } currFnc = stepResult; steps.add(currFnc); @@ -72,22 +73,22 @@ public class MathSolver { endStepState = stepState.get(); stepNumber++; - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications."); - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications."); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]); if (StaticVars.debugOn) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]); } if (StaticVars.debugOn) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]); } } while (consecutiveNullSteps < stepStates.length && !checkEquals(currFnc, lastFunctions[0][endStepState]) && !checkEquals(currFnc, lastFunctions[1][endStepState])); if (consecutiveNullSteps >= stepStates.length) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length); } else if (checkEquals(currFnc, lastFunctions[0][endStepState])) { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]); } else { - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]); } return steps; } @@ -116,7 +117,7 @@ public class MathSolver { return solveStep(fncs, stepState); } - private ObjectArrayList solveStep(ObjectArrayList fncs, DAtomicInteger stepState) + private ObjectArrayList solveStep(ObjectArrayList fncs, AtomicInteger stepState) throws InterruptedException, Error { final ObjectArrayList processedFncs = applyRules(fncs, RuleType.EXISTENCE); // Apply existence rules before everything if (processedFncs != null) { @@ -242,7 +243,7 @@ public class MathSolver { if (rulesStr.length() > 0) { rulesStr.setLength(rulesStr.length() - 1); } - ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr); + Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr); } return results; } diff --git a/src/main/java/it/cavallium/warppi/math/solver/SolveMethod.java b/core/src/main/java/it/cavallium/warppi/math/solver/SolveMethod.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/math/solver/SolveMethod.java rename to core/src/main/java/it/cavallium/warppi/math/solver/SolveMethod.java diff --git a/src/main/java/org/nevec/rjm/Bernoulli.java b/core/src/main/java/org/nevec/rjm/Bernoulli.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Bernoulli.java rename to core/src/main/java/org/nevec/rjm/Bernoulli.java diff --git a/src/main/java/org/nevec/rjm/BigComplex.java b/core/src/main/java/org/nevec/rjm/BigComplex.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/BigComplex.java rename to core/src/main/java/org/nevec/rjm/BigComplex.java diff --git a/src/main/java/org/nevec/rjm/BigDecimalMath.java b/core/src/main/java/org/nevec/rjm/BigDecimalMath.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/BigDecimalMath.java rename to core/src/main/java/org/nevec/rjm/BigDecimalMath.java diff --git a/src/main/java/org/nevec/rjm/BigIntegerMath.java b/core/src/main/java/org/nevec/rjm/BigIntegerMath.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/BigIntegerMath.java rename to core/src/main/java/org/nevec/rjm/BigIntegerMath.java diff --git a/src/main/java/org/nevec/rjm/BigIntegerPoly.java b/core/src/main/java/org/nevec/rjm/BigIntegerPoly.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/BigIntegerPoly.java rename to core/src/main/java/org/nevec/rjm/BigIntegerPoly.java diff --git a/src/main/java/org/nevec/rjm/BigSurd.java b/core/src/main/java/org/nevec/rjm/BigSurd.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/BigSurd.java rename to core/src/main/java/org/nevec/rjm/BigSurd.java diff --git a/src/main/java/org/nevec/rjm/BigSurdVec.java b/core/src/main/java/org/nevec/rjm/BigSurdVec.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/BigSurdVec.java rename to core/src/main/java/org/nevec/rjm/BigSurdVec.java diff --git a/src/main/java/org/nevec/rjm/Euler.java b/core/src/main/java/org/nevec/rjm/Euler.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Euler.java rename to core/src/main/java/org/nevec/rjm/Euler.java diff --git a/src/main/java/org/nevec/rjm/EulerPhi.java b/core/src/main/java/org/nevec/rjm/EulerPhi.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/EulerPhi.java rename to core/src/main/java/org/nevec/rjm/EulerPhi.java diff --git a/src/main/java/org/nevec/rjm/Factorial.java b/core/src/main/java/org/nevec/rjm/Factorial.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Factorial.java rename to core/src/main/java/org/nevec/rjm/Factorial.java diff --git a/src/main/java/org/nevec/rjm/Harmonic.java b/core/src/main/java/org/nevec/rjm/Harmonic.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Harmonic.java rename to core/src/main/java/org/nevec/rjm/Harmonic.java diff --git a/src/main/java/org/nevec/rjm/Ifactor.java b/core/src/main/java/org/nevec/rjm/Ifactor.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Ifactor.java rename to core/src/main/java/org/nevec/rjm/Ifactor.java diff --git a/src/main/java/org/nevec/rjm/PartitionsP.java b/core/src/main/java/org/nevec/rjm/PartitionsP.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/PartitionsP.java rename to core/src/main/java/org/nevec/rjm/PartitionsP.java diff --git a/src/main/java/org/nevec/rjm/Prime.java b/core/src/main/java/org/nevec/rjm/Prime.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Prime.java rename to core/src/main/java/org/nevec/rjm/Prime.java diff --git a/src/main/java/org/nevec/rjm/RatPoly.java b/core/src/main/java/org/nevec/rjm/RatPoly.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/RatPoly.java rename to core/src/main/java/org/nevec/rjm/RatPoly.java diff --git a/src/main/java/org/nevec/rjm/Rational.java b/core/src/main/java/org/nevec/rjm/Rational.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Rational.java rename to core/src/main/java/org/nevec/rjm/Rational.java diff --git a/src/main/java/org/nevec/rjm/SafeMathContext.java b/core/src/main/java/org/nevec/rjm/SafeMathContext.java similarity index 52% rename from src/main/java/org/nevec/rjm/SafeMathContext.java rename to core/src/main/java/org/nevec/rjm/SafeMathContext.java index c2b3932a..408da332 100644 --- a/src/main/java/org/nevec/rjm/SafeMathContext.java +++ b/core/src/main/java/org/nevec/rjm/SafeMathContext.java @@ -3,13 +3,14 @@ package org.nevec.rjm; import java.math.MathContext; import java.math.RoundingMode; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; +import it.cavallium.warppi.deps.Platform.ConsoleUtils; public final class SafeMathContext { public static MathContext newMathContext(int precision) { if (precision <= 0) { - ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")"); + Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")"); precision = 1; } return new MathContext(precision); @@ -17,7 +18,7 @@ public final class SafeMathContext { public static MathContext newMathContext(int precision, RoundingMode roundingMode) { if (precision <= 0) { - ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")"); + Engine.getPlatform().getConsoleUtils().out().print(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")"); precision = 1; } return new MathContext(precision, roundingMode); diff --git a/src/main/java/org/nevec/rjm/Wigner3j.java b/core/src/main/java/org/nevec/rjm/Wigner3j.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Wigner3j.java rename to core/src/main/java/org/nevec/rjm/Wigner3j.java diff --git a/src/main/java/org/nevec/rjm/Wigner3jGUI.java b/core/src/main/java/org/nevec/rjm/Wigner3jGUI.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/org/nevec/rjm/Wigner3jGUI.java rename to core/src/main/java/org/nevec/rjm/Wigner3jGUI.java diff --git a/src/main/jni/.gitignore b/core/src/main/jni/.gitignore similarity index 100% rename from src/main/jni/.gitignore rename to core/src/main/jni/.gitignore diff --git a/src/main/jni/CMakeLists.txt b/core/src/main/jni/CMakeLists.txt similarity index 100% rename from src/main/jni/CMakeLists.txt rename to core/src/main/jni/CMakeLists.txt diff --git a/src/main/jni/TestJNI.cpp b/core/src/main/jni/TestJNI.cpp similarity index 100% rename from src/main/jni/TestJNI.cpp rename to core/src/main/jni/TestJNI.cpp diff --git a/src/main/jni/TestJNI.h b/core/src/main/jni/TestJNI.h similarity index 100% rename from src/main/jni/TestJNI.h rename to core/src/main/jni/TestJNI.h diff --git a/src/main/jni/libpicalc.so b/core/src/main/jni/libpicalc.so similarity index 100% rename from src/main/jni/libpicalc.so rename to core/src/main/jni/libpicalc.so diff --git a/src/main/jni/makefileOLD b/core/src/main/jni/makefileOLD similarity index 100% rename from src/main/jni/makefileOLD rename to core/src/main/jni/makefileOLD diff --git a/src/main/resources/.gitignore b/core/src/main/resources/.gitignore similarity index 100% rename from src/main/resources/.gitignore rename to core/src/main/resources/.gitignore diff --git a/src/main/resources/algebra variable type.gif b/core/src/main/resources/algebra variable type.gif similarity index 100% rename from src/main/resources/algebra variable type.gif rename to core/src/main/resources/algebra variable type.gif diff --git a/src/main/resources/algebra.png b/core/src/main/resources/algebra.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/algebra.png rename to core/src/main/resources/algebra.png diff --git a/src/main/resources/algebra_input.gif b/core/src/main/resources/algebra_input.gif old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/algebra_input.gif rename to core/src/main/resources/algebra_input.gif diff --git a/src/main/resources/decimal.png b/core/src/main/resources/decimal.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/decimal.png rename to core/src/main/resources/decimal.png diff --git a/src/main/resources/default-rules.lst b/core/src/main/resources/default-rules.lst similarity index 100% rename from src/main/resources/default-rules.lst rename to core/src/main/resources/default-rules.lst diff --git a/src/main/resources/draft.png b/core/src/main/resources/draft.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/draft.png rename to core/src/main/resources/draft.png diff --git a/src/main/resources/draft2.png b/core/src/main/resources/draft2.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/draft2.png rename to core/src/main/resources/draft2.png diff --git a/src/main/resources/font_norm.rft b/core/src/main/resources/font_norm.rft similarity index 100% rename from src/main/resources/font_norm.rft rename to core/src/main/resources/font_norm.rft diff --git a/src/main/resources/font_smal.rft b/core/src/main/resources/font_smal.rft similarity index 100% rename from src/main/resources/font_smal.rft rename to core/src/main/resources/font_smal.rft diff --git a/src/main/resources/font_smallest.rft b/core/src/main/resources/font_smallest.rft similarity index 100% rename from src/main/resources/font_smallest.rft rename to core/src/main/resources/font_smallest.rft diff --git a/src/main/resources/font_square.rft b/core/src/main/resources/font_square.rft old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/font_square.rft rename to core/src/main/resources/font_square.rft diff --git a/src/main/resources/icons/calculator-016.png b/core/src/main/resources/icons/calculator-016.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-016.png rename to core/src/main/resources/icons/calculator-016.png diff --git a/src/main/resources/icons/calculator-018.png b/core/src/main/resources/icons/calculator-018.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-018.png rename to core/src/main/resources/icons/calculator-018.png diff --git a/src/main/resources/icons/calculator-024.png b/core/src/main/resources/icons/calculator-024.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-024.png rename to core/src/main/resources/icons/calculator-024.png diff --git a/src/main/resources/icons/calculator-032.png b/core/src/main/resources/icons/calculator-032.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-032.png rename to core/src/main/resources/icons/calculator-032.png diff --git a/src/main/resources/icons/calculator-048.png b/core/src/main/resources/icons/calculator-048.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-048.png rename to core/src/main/resources/icons/calculator-048.png diff --git a/src/main/resources/icons/calculator-064.png b/core/src/main/resources/icons/calculator-064.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-064.png rename to core/src/main/resources/icons/calculator-064.png diff --git a/src/main/resources/icons/calculator-128.png b/core/src/main/resources/icons/calculator-128.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-128.png rename to core/src/main/resources/icons/calculator-128.png diff --git a/src/main/resources/icons/calculator-256.png b/core/src/main/resources/icons/calculator-256.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/icons/calculator-256.png rename to core/src/main/resources/icons/calculator-256.png diff --git a/src/main/resources/keypad-preview.jpg b/core/src/main/resources/keypad-preview.jpg similarity index 100% rename from src/main/resources/keypad-preview.jpg rename to core/src/main/resources/keypad-preview.jpg diff --git a/src/main/resources/libpicalc.so b/core/src/main/resources/libpicalc.so similarity index 100% rename from src/main/resources/libpicalc.so rename to core/src/main/resources/libpicalc.so diff --git a/src/main/resources/marioground.png b/core/src/main/resources/marioground.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/marioground.png rename to core/src/main/resources/marioground.png diff --git a/src/main/resources/marioground.xcf b/core/src/main/resources/marioground.xcf old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/marioground.xcf rename to core/src/main/resources/marioground.xcf diff --git a/src/main/resources/marioskin.png b/core/src/main/resources/marioskin.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/marioskin.png rename to core/src/main/resources/marioskin.png diff --git a/src/main/resources/marioskin.xcf b/core/src/main/resources/marioskin.xcf old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/marioskin.xcf rename to core/src/main/resources/marioskin.xcf diff --git a/src/main/resources/old_font_big_2x.rft b/core/src/main/resources/old_font_big_2x.rft similarity index 100% rename from src/main/resources/old_font_big_2x.rft rename to core/src/main/resources/old_font_big_2x.rft diff --git a/src/main/resources/old_font_small_2x.rft b/core/src/main/resources/old_font_small_2x.rft similarity index 100% rename from src/main/resources/old_font_small_2x.rft rename to core/src/main/resources/old_font_small_2x.rft diff --git a/src/main/resources/picalculatornative.dll b/core/src/main/resources/picalculatornative.dll similarity index 100% rename from src/main/resources/picalculatornative.dll rename to core/src/main/resources/picalculatornative.dll diff --git a/src/main/resources/skin.png b/core/src/main/resources/skin.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/skin.png rename to core/src/main/resources/skin.png diff --git a/src/main/resources/skin.xcf b/core/src/main/resources/skin.xcf old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/skin.xcf rename to core/src/main/resources/skin.xcf diff --git a/src/main/resources/test.png b/core/src/main/resources/test.png old mode 100755 new mode 100644 similarity index 100% rename from src/main/resources/test.png rename to core/src/main/resources/test.png diff --git a/desktop/.classpath b/desktop/.classpath new file mode 100644 index 00000000..e1938397 --- /dev/null +++ b/desktop/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/desktop/.gitignore b/desktop/.gitignore new file mode 100644 index 00000000..b83d2226 --- /dev/null +++ b/desktop/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/desktop/.project b/desktop/.project new file mode 100644 index 00000000..2b2a50c2 --- /dev/null +++ b/desktop/.project @@ -0,0 +1,23 @@ + + + warppi-desktop + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/desktop/.settings/org.eclipse.core.resources.prefs b/desktop/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..654c1750 --- /dev/null +++ b/desktop/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding/=UTF-8 diff --git a/desktop/.settings/org.eclipse.jdt.core.prefs b/desktop/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f494d1de --- /dev/null +++ b/desktop/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/desktop/.settings/org.eclipse.m2e.core.prefs b/desktop/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..14b697b7 --- /dev/null +++ b/desktop/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/desktop/pom.xml b/desktop/pom.xml new file mode 100644 index 00000000..cc3c14f6 --- /dev/null +++ b/desktop/pom.xml @@ -0,0 +1,122 @@ + + 4.0.0 + + + it.cavallium + warppi + ${project.version} + + warppi-desktop + + bundle + + WarpPI Calculator Desktop + WarpPI Calculator desktop project + + + it.cavallium + warppi-core + ${project.version} + + + org.jogamp.jogl + jogl-all-main + 2.3.2 + + + org.jogamp.gluegen + gluegen-rt-main + 2.3.2 + + + com.pi4j + pi4j-core + 1.2-SNAPSHOT + + + org.fusesource.jansi + jansi + 1.17.1 + + + net.lingala.zip4j + zip4j + 1.3.2 + + + org.eclipse.jdt.core.compiler + ecj + 4.6.1 + + + + + + src/main/resources + + + ../rules/src/main/java + + + + + org.apache.felix + maven-bundle-plugin + true + + + it.cavallium.warppi.* + warppi-desktop + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4.1 + + + + jar-with-dependencies + + + + + it.cavallium.warppi.desktop.DesktopBoot + + + + + + + make-assembly + + package + + single + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + UTF-8 + + + + + diff --git a/src/jar-specific/java/ar/com/hjg/pngj/BufferedStreamFeeder.java b/desktop/src/main/java/ar/com/hjg/pngj/BufferedStreamFeeder.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/BufferedStreamFeeder.java rename to desktop/src/main/java/ar/com/hjg/pngj/BufferedStreamFeeder.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ChunkReader.java b/desktop/src/main/java/ar/com/hjg/pngj/ChunkReader.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ChunkReader.java rename to desktop/src/main/java/ar/com/hjg/pngj/ChunkReader.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqBuffering.java b/desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqBuffering.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqBuffering.java rename to desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqBuffering.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqReader.java b/desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqReader.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqReader.java rename to desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqReader.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java b/desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java rename to desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqSkipping.java b/desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqSkipping.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ChunkSeqSkipping.java rename to desktop/src/main/java/ar/com/hjg/pngj/ChunkSeqSkipping.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/DeflatedChunkReader.java b/desktop/src/main/java/ar/com/hjg/pngj/DeflatedChunkReader.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/DeflatedChunkReader.java rename to desktop/src/main/java/ar/com/hjg/pngj/DeflatedChunkReader.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/DeflatedChunksSet.java b/desktop/src/main/java/ar/com/hjg/pngj/DeflatedChunksSet.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/DeflatedChunksSet.java rename to desktop/src/main/java/ar/com/hjg/pngj/DeflatedChunksSet.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/Deinterlacer.java b/desktop/src/main/java/ar/com/hjg/pngj/Deinterlacer.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/Deinterlacer.java rename to desktop/src/main/java/ar/com/hjg/pngj/Deinterlacer.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/FilterType.java b/desktop/src/main/java/ar/com/hjg/pngj/FilterType.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/FilterType.java rename to desktop/src/main/java/ar/com/hjg/pngj/FilterType.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IBytesConsumer.java b/desktop/src/main/java/ar/com/hjg/pngj/IBytesConsumer.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IBytesConsumer.java rename to desktop/src/main/java/ar/com/hjg/pngj/IBytesConsumer.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IChunkFactory.java b/desktop/src/main/java/ar/com/hjg/pngj/IChunkFactory.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IChunkFactory.java rename to desktop/src/main/java/ar/com/hjg/pngj/IChunkFactory.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IDatChunkWriter.java b/desktop/src/main/java/ar/com/hjg/pngj/IDatChunkWriter.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IDatChunkWriter.java rename to desktop/src/main/java/ar/com/hjg/pngj/IDatChunkWriter.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IImageLine.java b/desktop/src/main/java/ar/com/hjg/pngj/IImageLine.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IImageLine.java rename to desktop/src/main/java/ar/com/hjg/pngj/IImageLine.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IImageLineArray.java b/desktop/src/main/java/ar/com/hjg/pngj/IImageLineArray.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IImageLineArray.java rename to desktop/src/main/java/ar/com/hjg/pngj/IImageLineArray.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IImageLineFactory.java b/desktop/src/main/java/ar/com/hjg/pngj/IImageLineFactory.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IImageLineFactory.java rename to desktop/src/main/java/ar/com/hjg/pngj/IImageLineFactory.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IImageLineSet.java b/desktop/src/main/java/ar/com/hjg/pngj/IImageLineSet.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IImageLineSet.java rename to desktop/src/main/java/ar/com/hjg/pngj/IImageLineSet.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IImageLineSetFactory.java b/desktop/src/main/java/ar/com/hjg/pngj/IImageLineSetFactory.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IImageLineSetFactory.java rename to desktop/src/main/java/ar/com/hjg/pngj/IImageLineSetFactory.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IPngWriterFactory.java b/desktop/src/main/java/ar/com/hjg/pngj/IPngWriterFactory.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IPngWriterFactory.java rename to desktop/src/main/java/ar/com/hjg/pngj/IPngWriterFactory.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/IdatSet.java b/desktop/src/main/java/ar/com/hjg/pngj/IdatSet.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/IdatSet.java rename to desktop/src/main/java/ar/com/hjg/pngj/IdatSet.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ImageInfo.java b/desktop/src/main/java/ar/com/hjg/pngj/ImageInfo.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ImageInfo.java rename to desktop/src/main/java/ar/com/hjg/pngj/ImageInfo.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ImageLineByte.java b/desktop/src/main/java/ar/com/hjg/pngj/ImageLineByte.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ImageLineByte.java rename to desktop/src/main/java/ar/com/hjg/pngj/ImageLineByte.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ImageLineHelper.java b/desktop/src/main/java/ar/com/hjg/pngj/ImageLineHelper.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ImageLineHelper.java rename to desktop/src/main/java/ar/com/hjg/pngj/ImageLineHelper.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ImageLineInt.java b/desktop/src/main/java/ar/com/hjg/pngj/ImageLineInt.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ImageLineInt.java rename to desktop/src/main/java/ar/com/hjg/pngj/ImageLineInt.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java b/desktop/src/main/java/ar/com/hjg/pngj/ImageLineSetDefault.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java rename to desktop/src/main/java/ar/com/hjg/pngj/ImageLineSetDefault.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngHelperInternal.java b/desktop/src/main/java/ar/com/hjg/pngj/PngHelperInternal.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngHelperInternal.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngHelperInternal.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngHelperInternal2.java b/desktop/src/main/java/ar/com/hjg/pngj/PngHelperInternal2.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngHelperInternal2.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngHelperInternal2.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngReader.java b/desktop/src/main/java/ar/com/hjg/pngj/PngReader.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngReader.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngReader.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngReaderApng.java b/desktop/src/main/java/ar/com/hjg/pngj/PngReaderApng.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngReaderApng.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngReaderApng.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngReaderByte.java b/desktop/src/main/java/ar/com/hjg/pngj/PngReaderByte.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngReaderByte.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngReaderByte.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngReaderFilter.java b/desktop/src/main/java/ar/com/hjg/pngj/PngReaderFilter.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngReaderFilter.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngReaderFilter.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngReaderInt.java b/desktop/src/main/java/ar/com/hjg/pngj/PngReaderInt.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngReaderInt.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngReaderInt.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngWriter.java b/desktop/src/main/java/ar/com/hjg/pngj/PngWriter.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngWriter.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngWriter.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngWriterHc.java b/desktop/src/main/java/ar/com/hjg/pngj/PngWriterHc.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngWriterHc.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngWriterHc.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngjBadCrcException.java b/desktop/src/main/java/ar/com/hjg/pngj/PngjBadCrcException.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngjBadCrcException.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngjBadCrcException.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngjException.java b/desktop/src/main/java/ar/com/hjg/pngj/PngjException.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngjException.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngjException.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngjExceptionInternal.java b/desktop/src/main/java/ar/com/hjg/pngj/PngjExceptionInternal.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngjExceptionInternal.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngjExceptionInternal.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngjInputException.java b/desktop/src/main/java/ar/com/hjg/pngj/PngjInputException.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngjInputException.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngjInputException.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngjOutputException.java b/desktop/src/main/java/ar/com/hjg/pngj/PngjOutputException.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngjOutputException.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngjOutputException.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/PngjUnsupportedException.java b/desktop/src/main/java/ar/com/hjg/pngj/PngjUnsupportedException.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/PngjUnsupportedException.java rename to desktop/src/main/java/ar/com/hjg/pngj/PngjUnsupportedException.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/RowInfo.java b/desktop/src/main/java/ar/com/hjg/pngj/RowInfo.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/RowInfo.java rename to desktop/src/main/java/ar/com/hjg/pngj/RowInfo.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkFactory.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkFactory.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkFactory.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkFactory.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkHelper.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkHelper.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkHelper.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkHelper.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkRaw.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkRaw.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunkRaw.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunkRaw.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunksList.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunksList.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunksList.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunksList.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunk.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunk.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/PngMetadata.java b/desktop/src/main/java/ar/com/hjg/pngj/chunks/PngMetadata.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/PngMetadata.java rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/PngMetadata.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/chunks/package.html b/desktop/src/main/java/ar/com/hjg/pngj/chunks/package.html similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/chunks/package.html rename to desktop/src/main/java/ar/com/hjg/pngj/chunks/package.html diff --git a/src/jar-specific/java/ar/com/hjg/pngj/package.html b/desktop/src/main/java/ar/com/hjg/pngj/package.html similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/package.html rename to desktop/src/main/java/ar/com/hjg/pngj/package.html diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/CompressorStream.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/CompressorStream.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/CompressorStream.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/CompressorStream.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriter.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriter.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriter.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriter.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java b/desktop/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java diff --git a/src/jar-specific/java/ar/com/hjg/pngj/pixels/package.html b/desktop/src/main/java/ar/com/hjg/pngj/pixels/package.html similarity index 100% rename from src/jar-specific/java/ar/com/hjg/pngj/pixels/package.html rename to desktop/src/main/java/ar/com/hjg/pngj/pixels/package.html diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopBoot.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopBoot.java new file mode 100644 index 00000000..58f2da1a --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopBoot.java @@ -0,0 +1,11 @@ +package it.cavallium.warppi.desktop; + +import it.cavallium.warppi.boot.Boot; + +public class DesktopBoot { + + public static void main(String[] args) throws Exception { + Boot.boot(new DesktopPlatform(), args); + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopConsoleUtils.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopConsoleUtils.java new file mode 100644 index 00000000..5776ea4e --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopConsoleUtils.java @@ -0,0 +1,115 @@ +package it.cavallium.warppi.desktop; + +import java.io.PrintStream; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import it.cavallium.warppi.StaticVars; +import it.cavallium.warppi.math.MathematicalSymbols; + +public class DesktopConsoleUtils implements it.cavallium.warppi.deps.Platform.ConsoleUtils { + + private AdvancedOutputStream os; + + public DesktopConsoleUtils() { + os = new AdvancedOutputStream() { + private void print(PrintStream stream, String str) { + stream.print(fixString(str)); + } + + private void println(PrintStream stream, String str) { + stream.println(fixString(str)); + } + + private void println(PrintStream stream) { + stream.println(); + } + + private String fixString(String str) { + + return str.replace("" + MathematicalSymbols.NTH_ROOT, "root").replace("" + MathematicalSymbols.SQUARE_ROOT, "sqrt").replace("" + MathematicalSymbols.POWER, "powerOf").replace("" + MathematicalSymbols.POWER_OF_TWO, "powerOfTwo").replace("" + MathematicalSymbols.SINE, "sine").replace("" + MathematicalSymbols.COSINE, "cosine").replace("" + MathematicalSymbols.TANGENT, "tangent").replace("" + MathematicalSymbols.ARC_SINE, "asin").replace("" + MathematicalSymbols.ARC_COSINE, "acos").replace("" + MathematicalSymbols.ARC_TANGENT, "atan").replace("" + MathematicalSymbols.UNDEFINED, "undefined").replace("" + MathematicalSymbols.PI, "PI").replace("" + MathematicalSymbols.EULER_NUMBER, "EULER_NUMBER").replace("" + MathematicalSymbols.X, "X").replace("" + MathematicalSymbols.Y, "Y"); + } + + public void println(Object str) { + println(0, str); + } + + public void println(int level) { + if (StaticVars.outputLevel >= level) { + if (StaticVars.outputLevel == 0) { + println(System.out); + } else { + println(System.out); + } + } + } + + public void println(int level, Object str) { + if (StaticVars.outputLevel >= level) { + final String time = getTimeString(); + if (StaticVars.outputLevel == 0) { + println(System.out, "[" + time + "] " + str); + } else { + println(System.out, "[" + time + "] " + str); + } + } + } + + public void print(int level, String str) { + if (StaticVars.outputLevel >= level) { + if (StaticVars.outputLevel == 0) { + print(System.out, str); + } else { + print(System.out, str); + } + } + } + + public void println(int level, String prefix, String str) { + if (StaticVars.outputLevel >= level) { + final String time = getTimeString(); + if (StaticVars.outputLevel == 0) { + println(System.out, "[" + time + "][" + prefix + "] " + str); + } else { + println(System.out, "[" + time + "][" + prefix + "] " + str); + } + } + } + + public void println(int level, String... parts) { + if (StaticVars.outputLevel >= level) { + final String time = getTimeString(); + StringBuilder output = new StringBuilder(); + for (int i = 0; i < parts.length; i++) { + if (i + 1 == parts.length) { + output.append(' '); + output.append(parts[i]); + } else { + output.append('['); + output.append(parts[i]); + output.append(']'); + } + } + output.insert(0, '['); + output.insert(1, time); + output.insert(time.length() + 1, ']'); + if (StaticVars.outputLevel == 0) { + println(System.out, output.toString()); + } else { + println(System.out, output.toString()); + } + } + } + + private String getTimeString() { + return LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss.SSS")); + } + }; + } + + @Override + public AdvancedOutputStream out() { + return os; + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopGpio.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopGpio.java new file mode 100644 index 00000000..393bfb04 --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopGpio.java @@ -0,0 +1,78 @@ +package it.cavallium.warppi.desktop; + +import it.cavallium.warppi.ClassUtils; + +public class DesktopGpio implements it.cavallium.warppi.deps.Platform.Gpio { + + @Override + public int valueOutput() { + return com.pi4j.wiringpi.Gpio.OUTPUT; + } + + @Override + public int valuePwmOutput() { + return com.pi4j.wiringpi.Gpio.PWM_OUTPUT; + } + + @Override + public int valueInput() { + return com.pi4j.wiringpi.Gpio.INPUT; + } + + @Override + public int valueHigh() { + return com.pi4j.wiringpi.Gpio.HIGH; + } + + @Override + public int valueLow() { + return com.pi4j.wiringpi.Gpio.LOW; + } + + @Override + public Object valueUnknownBoardType() { + return com.pi4j.system.SystemInfo.BoardType.UNKNOWN; + } + + @Override + public void wiringPiSetupPhys() { + com.pi4j.wiringpi.Gpio.wiringPiSetupPhys(); + } + + @Override + public void pinMode(int i, int type) { + com.pi4j.wiringpi.Gpio.pinMode(i, type); + + } + + @Override + public void digitalWrite(int pin, int val) { + com.pi4j.wiringpi.Gpio.digitalWrite(pin, val); + } + + @Override + public void digitalWrite(int pin, boolean val) { + com.pi4j.wiringpi.Gpio.digitalWrite(pin, val); + } + + @Override + public void pwmWrite(int pin, int val) { + com.pi4j.wiringpi.Gpio.pwmWrite(pin, val); + } + + @Override + public void delayMicroseconds(int t) { + com.pi4j.wiringpi.Gpio.delayMicroseconds(t); + } + + @Override + public int digitalRead(int pin) { + return com.pi4j.wiringpi.Gpio.digitalRead(pin); + } + + @Override + public Object getBoardType() { + return ClassUtils.invokeStaticMethod("com.pi4j.system.SystemInfo.getBoardType"); + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java new file mode 100644 index 00000000..0df737e4 --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java @@ -0,0 +1,193 @@ +package it.cavallium.warppi.desktop; + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import it.cavallium.warppi.Error; +import it.cavallium.warppi.deps.Platform; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.cpu.CPUEngine; +import it.cavallium.warppi.gui.graphicengine.gpu.GPUEngine; +import net.lingala.zip4j.core.ZipFile; +import net.lingala.zip4j.model.ZipParameters; +import net.lingala.zip4j.util.Zip4jConstants; + +public class DesktopPlatform implements Platform { + + private final DesktopConsoleUtils cu; + private final DesktopGpio gi; + private final DesktopStorageUtils su; + private final PngUtils pu; + private final String on; + private final Map el; + + public DesktopPlatform() { + cu = new DesktopConsoleUtils(); + gi = new DesktopGpio(); + su = new DesktopStorageUtils(); + pu = new DesktopPngUtils(); + on = System.getProperty("os.name").toLowerCase(); + el = new HashMap<>(); + el.put("CPU engine", new CPUEngine()); + el.put("GPU engine", new GPUEngine()); + } + + @Override + public ConsoleUtils getConsoleUtils() { + return cu; + } + + @Override + public Gpio getGpio() { + return gi; + } + + @Override + public StorageUtils getStorageUtils() { + return su; + } + + @Override + public PngUtils getPngUtils() { + return pu; + } + + @Override + public void setThreadName(Thread t, String name) { + t.setName(name); + } + + @Override + public void setThreadDaemon(Thread t) { + t.setDaemon(true); + } + + @Override + public void setThreadDaemon(Thread t, boolean value) { + t.setDaemon(value); + } + + @Override + public void exit(int value) { + System.exit(value); + } + + @Override + public void gc() { + System.gc(); + } + + @Override + public boolean isJavascript() { + return false; + } + + @Override + public String getOsName() { + return on; + } + + @Override + public void alphaChanged(boolean val) { + + } + + @Override + public void shiftChanged(boolean val) { + } + + @Override + public Semaphore newSemaphore() { + return new DesktopSemaphore(0); + } + + @Override + public Semaphore newSemaphore(int i) { + return new DesktopSemaphore(i); + } + + @Override + public URLClassLoader newURLClassLoader(URL[] urls) { + return new DesktopURLClassLoader(urls); + } + + @Override + public Map getEnginesList() { + return el; + } + + @Override + public GraphicEngine getEngine(String string) throws NullPointerException { + return el.get(string); + } + + @Override + public void throwNewExceptionInInitializerError(String text) { + throw new ExceptionInInitializerError(); + } + + @Override + public String[] stacktraceToString(Error e) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + return sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n"); + } + + @Override + public void loadPlatformRules() { + + } + + @Override + public void zip(String targetPath, String destinationFilePath, String password) { + try { + final ZipParameters parameters = new ZipParameters(); + parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); + parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); + + if (password.length() > 0) { + parameters.setEncryptFiles(true); + parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES); + parameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256); + parameters.setPassword(password); + } + + final ZipFile zipFile = new ZipFile(destinationFilePath); + + final File targetFile = new File(targetPath); + if (targetFile.isFile()) { + zipFile.addFile(targetFile, parameters); + } else if (targetFile.isDirectory()) { + zipFile.addFolder(targetFile, parameters); + } + + } catch (final Exception e) { + e.printStackTrace(); + } + } + + @Override + public void unzip(String targetZipFilePath, String destinationFolderPath, String password) { + try { + final ZipFile zipFile = new ZipFile(targetZipFilePath); + if (zipFile.isEncrypted()) { + zipFile.setPassword(password); + } + zipFile.extractAll(destinationFolderPath); + + } catch (final Exception e) { + e.printStackTrace(); + } + } + + @Override + public boolean compile(String[] command, PrintWriter printWriter, PrintWriter errors) { + return org.eclipse.jdt.internal.compiler.batch.Main.compile(command, printWriter, errors, null); + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngReader.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngReader.java new file mode 100644 index 00000000..5b9609d6 --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngReader.java @@ -0,0 +1,61 @@ +package it.cavallium.warppi.desktop; + +import java.io.InputStream; + +import ar.com.hjg.pngj.ImageLineInt; +import it.cavallium.warppi.deps.Platform.PngUtils.PngReader; + +public class DesktopPngReader implements PngReader { + + private ar.com.hjg.pngj.PngReader r; + + public DesktopPngReader(InputStream resourceStream) { + r = new ar.com.hjg.pngj.PngReader(resourceStream); + } + + @Override + public int[] getImageMatrix() { + final int width = r.imgInfo.cols; + final int height = r.imgInfo.rows; + final int channels = r.imgInfo.channels; + final int[] pixels = new int[width * height]; + int pi = 0; + ImageLineInt lint; + while (r.hasMoreRows()) { + lint = (ImageLineInt) r.readRow(); + int[] scanLine = lint.getScanline(); + + for (int i = 0; i < width; i++) { + int offset = i * channels; + + // Adjust the following code depending on your source image. + // I need the to set the alpha channel to 0xFF000000 since my destination image + // is TRANSLUCENT : BufferedImage bi = CONFIG.createCompatibleImage( width, height, Transparency.TRANSLUCENT ); + // my source was 3 channels RGB without transparency + int nextPixel; + if (channels == 4) { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (scanLine[offset + 3] << 24); + } else if (channels == 3) { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (0xFF << 24); + } else if (channels == 2) { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24); + } else { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset] << 8) | scanLine[offset] | (0xFF << 24); + } + + // I'm placing the pixels on a memory mapped file + pixels[pi] = nextPixel; + pi++; + } + + } + + return pixels; + } + + @Override + public int[] getSize() { + return new int[] {r.imgInfo.cols, r.imgInfo.rows}; + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java new file mode 100644 index 00000000..6aac1564 --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java @@ -0,0 +1,14 @@ +package it.cavallium.warppi.desktop; + +import java.io.InputStream; + +import it.cavallium.warppi.deps.Platform.PngUtils; + +public class DesktopPngUtils implements PngUtils { + + @Override + public PngReader load(InputStream resourceStream) { + return new DesktopPngReader(resourceStream); + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopSemaphore.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopSemaphore.java new file mode 100644 index 00000000..1c7a206e --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopSemaphore.java @@ -0,0 +1,16 @@ +package it.cavallium.warppi.desktop; + +import java.util.concurrent.Semaphore; + +public class DesktopSemaphore extends Semaphore implements it.cavallium.warppi.deps.Platform.Semaphore { + + private static final long serialVersionUID = -2362314723921013871L; + + public DesktopSemaphore(int arg0) { + super(arg0); + } + + public DesktopSemaphore(int permits, boolean fair) { + super(permits, fair); + } +} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/StorageUtils.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopStorageUtils.java similarity index 68% rename from src/jar-specific/java/it/cavallium/warppi/deps/StorageUtils.java rename to desktop/src/main/java/it/cavallium/warppi/desktop/DesktopStorageUtils.java index c99f5b69..56e5ac90 100644 --- a/src/jar-specific/java/it/cavallium/warppi/deps/StorageUtils.java +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopStorageUtils.java @@ -1,4 +1,4 @@ -package it.cavallium.warppi.deps; +package it.cavallium.warppi.desktop; import java.io.BufferedReader; import java.io.File; @@ -16,6 +16,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -26,28 +27,29 @@ import java.util.stream.Stream; import org.apache.commons.io.IOUtils; import it.cavallium.warppi.ClassUtils; +import it.cavallium.warppi.deps.Platform.StorageUtils; -public class StorageUtils { - public static final boolean exists(Path f) { - return Files.exists(f); - } - - public static final boolean exists(File f) { +public class DesktopStorageUtils implements StorageUtils { + public boolean exists(File f) { return f.exists(); } - public static File get(String path) { + public File get(String path) { return Paths.get(path).toFile(); } - public static File get(String path, String... others) { - return Paths.get(path, others).toFile(); + public File get(String... path) { + if (path.length <= 1) { + return Paths.get(path[0]).toFile(); + } else { + return Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length)).toFile(); + } } - private static Map resourcesCache = new HashMap(); + private Map resourcesCache = new HashMap(); @Deprecated() - public static File getResource(String string) throws IOException, URISyntaxException { + public File getResource(String string) throws IOException, URISyntaxException { final URL res = ClassUtils.classLoader.getResource(string); final boolean isResource = res != null; if (isResource) { @@ -89,7 +91,7 @@ public class StorageUtils { } } - public static InputStream getResourceStream(String string) throws IOException, URISyntaxException { + public InputStream getResourceStream(String string) throws IOException, URISyntaxException { final URL res = ClassUtils.classLoader.getResource(string); final boolean isResource = res != null; if (isResource) { @@ -120,17 +122,17 @@ public class StorageUtils { } } - public static List readAllLines(File file) throws IOException { + public List readAllLines(File file) throws IOException { return Files.readAllLines(file.toPath()); } - public static String read(InputStream input) throws IOException { + public String read(InputStream input) throws IOException { try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) { return buffer.lines().collect(Collectors.joining("\n")); } } - public static List walk(File dir) throws IOException { + public List walk(File dir) throws IOException { List out = new ArrayList<>(); try (Stream paths = Files.walk(dir.toPath())) { paths.filter(Files::isRegularFile).forEach((Path p) -> { @@ -140,35 +142,52 @@ public class StorageUtils { return out; } - public static File relativize(File rulesPath, File f) { + public File relativize(File rulesPath, File f) { return rulesPath.toPath().relativize(f.toPath()).toFile(); } - public static File resolve(File file, String string) { + public File resolve(File file, String string) { return file.toPath().resolve(string).toFile(); } - public static File getParent(File f) { + public File getParent(File f) { return f.toPath().getParent().toFile(); } - public static void createDirectories(File dir) throws IOException { + public void createDirectories(File dir) throws IOException { Files.createDirectories(dir.toPath()); } - public static void write(File f, byte[] bytes, DStandardOpenOption... options) throws IOException { + public void write(File f, byte[] bytes, int... options) throws IOException { StandardOpenOption[] noptions = new StandardOpenOption[options.length]; int i = 0; - for (DStandardOpenOption opt : options) { - noptions[i] = StandardOpenOption.values()[opt.ordinal()]; + for (int opt : options) { + switch (opt) { + case StorageUtils.OpenOptionCreate: { + noptions[i] = StandardOpenOption.CREATE; + break; + } + case StorageUtils.OpenOptionWrite: { + noptions[i] = StandardOpenOption.WRITE; + break; + } + default: { + break; + } + } i++; } Files.write(f.toPath(), bytes, noptions); } - public static List readAllLines(InputStream input) throws IOException { + public List readAllLines(InputStream input) throws IOException { try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) { return buffer.lines().collect(Collectors.toList()); } } + + @Override + public String getBasePath() { + return ""; + } } diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopURLClassLoader.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopURLClassLoader.java new file mode 100644 index 00000000..d236ba3c --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopURLClassLoader.java @@ -0,0 +1,13 @@ +package it.cavallium.warppi.desktop; + +import java.net.URL; + +import it.cavallium.warppi.deps.Platform.URLClassLoader; + +public class DesktopURLClassLoader extends java.net.URLClassLoader implements URLClassLoader { + + public DesktopURLClassLoader(URL[] urls) { + super(urls); + } + +} diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUEngine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUEngine.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUEngine.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUEngine.java diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUFont.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUFont.java new file mode 100644 index 00000000..b57b97bf --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUFont.java @@ -0,0 +1,24 @@ +package it.cavallium.warppi.gui.graphicengine.cpu; + +import java.io.IOException; + +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.common.RFTFont; + +public class CPUFont extends RFTFont { + + public CPUFont(String fontName) throws IOException { + super(fontName); + } + + public CPUFont(String path, String fontName) throws IOException { + super(path, fontName); + } + + @Override + public void use(GraphicEngine d) { + if (d.getRenderer() instanceof CPURenderer) { + ((CPURenderer) d.getRenderer()).currentFont = this; + } + } +} diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPURenderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPURenderer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPURenderer.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPURenderer.java diff --git a/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUSkin.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUSkin.java new file mode 100644 index 00000000..93ccfcae --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUSkin.java @@ -0,0 +1,20 @@ +package it.cavallium.warppi.gui.graphicengine.cpu; + +import java.io.IOException; + +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.common.PngSkin; + +public class CPUSkin extends PngSkin { + + public CPUSkin(String file) throws IOException { + super(file); + } + + @Override + public void use(GraphicEngine d) { + if (d.getRenderer() instanceof CPURenderer) { + ((CPURenderer) d.getRenderer()).currentSkin = this; + } + } +} diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/SwingWindow.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/SwingWindow.java old mode 100755 new mode 100644 similarity index 95% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/SwingWindow.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/SwingWindow.java index 0a8b5c18..4ad38562 --- a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/SwingWindow.java +++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/SwingWindow.java @@ -19,7 +19,7 @@ import java.awt.image.DataBufferInt; import javax.swing.JFrame; import javax.swing.JPanel; -import it.cavallium.warppi.ConsoleUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.Utils; import it.cavallium.warppi.device.HardwareDevice; @@ -176,7 +176,7 @@ public class SwingWindow extends JFrame { if (newZoomValue != mult) { mult = (int) newZoomValue.floatValue(); this.onResize.onNext(new Integer[] { getWidth(), getHeight() }); - ConsoleUtils.out.println(3, "Engine", "CPU", "Zoom changed"); + Engine.getPlatform().getConsoleUtils().out().println(3, "Engine", "CPU", "Zoom changed"); } }); } diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBEngine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBEngine.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBEngine.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBEngine.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBRenderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBRenderer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBRenderer.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/framebuffer/FBRenderer.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/DeallocationHelper.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/DeallocationHelper.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/DeallocationHelper.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/DeallocationHelper.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUEngine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUEngine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUEngine.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUEngine.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUFont.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUFont.java old mode 100755 new mode 100644 similarity index 91% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUFont.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUFont.java index 47ef84d6..8b365856 --- a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUFont.java +++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUFont.java @@ -12,9 +12,10 @@ import ar.com.hjg.pngj.ImageInfo; import ar.com.hjg.pngj.ImageLineHelper; import ar.com.hjg.pngj.ImageLineInt; import ar.com.hjg.pngj.PngWriter; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.cpu.CPUFont; public class GPUFont implements BinaryFont { @@ -50,11 +51,11 @@ public class GPUFont implements BinaryFont { } public void load(String path, String name) throws IOException { - CPUFont font; + RFTFont font; if (path == null) { - font = CPUFont.loadTemporaryFont(name); + font = RFTFont.loadTemporaryFont(name); } else { - font = CPUFont.loadTemporaryFont(path, name); + font = RFTFont.loadTemporaryFont(path, name); } charW = font.charW; charH = font.charH; @@ -64,10 +65,10 @@ public class GPUFont implements BinaryFont { intervalsTotalSize = font.intervalsTotalSize; boolean[][] rawchars = font.rawchars; font = null; - PlatformUtils.gc(); + Engine.getPlatform().gc(); pregenTexture(rawchars); rawchars = null; - PlatformUtils.gc(); + Engine.getPlatform().gc(); } public int[] getCharIndexes(String txt) { @@ -163,7 +164,7 @@ public class GPUFont implements BinaryFont { } chars = null; png.end(); - PlatformUtils.gc(); + Engine.getPlatform().gc(); try { memoryWidth = w; @@ -173,7 +174,7 @@ public class GPUFont implements BinaryFont { textureH = h; outputStream.flush(); outputStream.close(); - PlatformUtils.gc(); + Engine.getPlatform().gc(); tmpFont = f; } catch (GLException | IOException e) { e.printStackTrace(); diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPURenderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPURenderer.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPURenderer.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPURenderer.java index e466a034..73925426 --- a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPURenderer.java +++ b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPURenderer.java @@ -18,7 +18,7 @@ import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; -import it.cavallium.warppi.PlatformUtils; +import it.cavallium.warppi.Engine; import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.Renderer; @@ -278,7 +278,7 @@ public class GPURenderer implements Renderer { final int imgW = img.getWidth(); final int imgH = img.getHeight(); img = null; - PlatformUtils.gc(); + Engine.getPlatform().gc(); return new OpenedTextureData(imgW, imgH, f, isResource); } diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUSkin.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUSkin.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUSkin.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/GPUSkin.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/NEWTWindow.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/NEWTWindow.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/NEWTWindow.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/gpu/NEWTWindow.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitEngine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitEngine.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitEngine.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitEngine.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitFont.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitFont.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitFont.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitFont.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitRenderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitRenderer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitRenderer.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitRenderer.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitSkin.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitSkin.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitSkin.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless24bit/Headless24bitSkin.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Engine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Engine.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Engine.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Engine.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Font.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Font.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Font.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Font.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Renderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Renderer.java old mode 100755 new mode 100644 similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Renderer.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Renderer.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Skin.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Skin.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Skin.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless256/Headless256Skin.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Engine.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Engine.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Engine.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Engine.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Font.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Font.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Font.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Font.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Renderer.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Renderer.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Renderer.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Renderer.java diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Skin.java b/desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Skin.java similarity index 100% rename from src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Skin.java rename to desktop/src/main/java/it/cavallium/warppi/gui/graphicengine/headless8/Headless8Skin.java diff --git a/pom.xml b/pom.xml index df38ea5b..fc3110ad 100755 --- a/pom.xml +++ b/pom.xml @@ -2,13 +2,33 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - it.cavallium.warppi - warppi-calculator - jar - 0.8-SNAPSHOT + + it.cavallium + warppi + ${project.version} + pom + WarpPI Calculator - http://warp.ovh + WarpPI Calculator aggregate project + https://warp.ovh + + + + Cavallium + Andrea Cavalli + andrea@warp.ovh + +1 + + + + + https://github.com/Cavallium/WarpPI + scm:git:git@github.com:Cavallium/WarpPI.git + + + 0.8-SNAPSHOT + UTF-8 1.8 1.8 src/main/java @@ -16,6 +36,14 @@ src/main/resources veryverylongandparticularpath/abcd + + + core + rules + desktop + teavm + + teavm-dev @@ -39,16 +67,18 @@ https://jitpack.io + - - 1_teavm-dev - https://dl.bintray.com/konsoletyper/teavm - - true - - default - + + 1_teavm-dev + https://dl.bintray.com/konsoletyper/teavm + + true + + default + + aarch64 @@ -60,66 +90,6 @@ it/cavallium/warppi/gui/graphicengine/gpu/* - - jarprofile - - jar-specific - src/main/rules - - - true - - - - org.jogamp.jogl - jogl-all-main - 2.3.2 - - - org.jogamp.gluegen - gluegen-rt-main - 2.3.2 - - - com.pi4j - pi4j-core - 1.2-SNAPSHOT - - - org.fusesource.jansi - jansi - 1.17.1 - - - net.lingala.zip4j - zip4j - 1.3.2 - - - org.eclipse.jdt.core.compiler - ecj - 4.6.1 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - ${maven.compiler.source} - ${maven.compiler.target} - UTF-8 - - ${buildprops.exclude1} - - - - - - teavmprofile @@ -199,128 +169,97 @@ + + + + it.unimi.dsi + fastutil + 8.2.1 + + + com.google.code.gson + gson + 2.8.5 + + + commons-io + commons-io + 2.6 + + + org.apache.commons + commons-lang3 + 3.8 + + + ar.com.hjg + pngj + 2.1.0 + + + - - - - it.unimi.dsi - fastutil - 8.2.1 - - - com.google.code.gson - gson - 2.8.5 - - - - commons-io - commons-io - 2.6 - - - org.apache.commons - commons-lang3 - 3.8 - - - - - - src/main/resources - - - ${src.resdir} - - WarpPICalculator - - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - add-source - generate-sources - - add-source - - - - - ${basedir}/src/main/java - - - ${basedir}/src/${src.dir}/java - - - ${basedir}/${src.dir2} - - - - - - - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - true - true - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - UTF-8 - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.4.1 - - - - jar-with-dependencies - - - - - it.cavallium.warppi.boot.WarpPI - - - - - - - make-assembly - - package - - single - - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.0.0 + + + build-javadoc + + jar + + post-integration-test + + + + protected + false + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + post-integration-test + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.21.0 + + + org.apache.felix + maven-bundle-plugin + 2.5.3 + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + - diff --git a/rules/.classpath b/rules/.classpath new file mode 100644 index 00000000..e1938397 --- /dev/null +++ b/rules/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rules/.gitignore b/rules/.gitignore new file mode 100644 index 00000000..b83d2226 --- /dev/null +++ b/rules/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/rules/.project b/rules/.project new file mode 100644 index 00000000..f5fd71ae --- /dev/null +++ b/rules/.project @@ -0,0 +1,23 @@ + + + warppi-rules + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/rules/.settings/org.eclipse.core.resources.prefs b/rules/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..654c1750 --- /dev/null +++ b/rules/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding/=UTF-8 diff --git a/rules/.settings/org.eclipse.jdt.core.prefs b/rules/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f494d1de --- /dev/null +++ b/rules/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/rules/.settings/org.eclipse.m2e.core.prefs b/rules/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..14b697b7 --- /dev/null +++ b/rules/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/rules/pom.xml b/rules/pom.xml new file mode 100644 index 00000000..b3a93025 --- /dev/null +++ b/rules/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + + + it.cavallium + warppi + ${project.version} + + warppi-rules + bundle + + WarpPI Calculator Rules + WarpPI Calculator rules project + + + + it.cavallium + warppi-core + ${project.version} + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + rules.* + warppi-rules + + + + + org.apache.maven.plugins + maven-source-plugin + + + + diff --git a/src/main/rules/rules/ExpandRule1.java b/rules/src/main/java/rules/ExpandRule1.java similarity index 100% rename from src/main/rules/rules/ExpandRule1.java rename to rules/src/main/java/rules/ExpandRule1.java diff --git a/src/main/rules/rules/ExpandRule2.java b/rules/src/main/java/rules/ExpandRule2.java similarity index 100% rename from src/main/rules/rules/ExpandRule2.java rename to rules/src/main/java/rules/ExpandRule2.java diff --git a/src/main/rules/rules/ExpandRule5.java b/rules/src/main/java/rules/ExpandRule5.java similarity index 100% rename from src/main/rules/rules/ExpandRule5.java rename to rules/src/main/java/rules/ExpandRule5.java diff --git a/src/main/rules/rules/ExponentRule1.java b/rules/src/main/java/rules/ExponentRule1.java similarity index 100% rename from src/main/rules/rules/ExponentRule1.java rename to rules/src/main/java/rules/ExponentRule1.java diff --git a/src/main/rules/rules/ExponentRule15.java b/rules/src/main/java/rules/ExponentRule15.java similarity index 100% rename from src/main/rules/rules/ExponentRule15.java rename to rules/src/main/java/rules/ExponentRule15.java diff --git a/src/main/rules/rules/ExponentRule16.java b/rules/src/main/java/rules/ExponentRule16.java similarity index 100% rename from src/main/rules/rules/ExponentRule16.java rename to rules/src/main/java/rules/ExponentRule16.java diff --git a/src/main/rules/rules/ExponentRule17.java b/rules/src/main/java/rules/ExponentRule17.java similarity index 100% rename from src/main/rules/rules/ExponentRule17.java rename to rules/src/main/java/rules/ExponentRule17.java diff --git a/src/main/rules/rules/ExponentRule2.java b/rules/src/main/java/rules/ExponentRule2.java similarity index 100% rename from src/main/rules/rules/ExponentRule2.java rename to rules/src/main/java/rules/ExponentRule2.java diff --git a/src/main/rules/rules/ExponentRule3.java b/rules/src/main/java/rules/ExponentRule3.java similarity index 100% rename from src/main/rules/rules/ExponentRule3.java rename to rules/src/main/java/rules/ExponentRule3.java diff --git a/src/main/rules/rules/ExponentRule4.java b/rules/src/main/java/rules/ExponentRule4.java similarity index 100% rename from src/main/rules/rules/ExponentRule4.java rename to rules/src/main/java/rules/ExponentRule4.java diff --git a/src/main/rules/rules/ExponentRule8.java b/rules/src/main/java/rules/ExponentRule8.java similarity index 100% rename from src/main/rules/rules/ExponentRule8.java rename to rules/src/main/java/rules/ExponentRule8.java diff --git a/src/main/rules/rules/ExponentRule9.java b/rules/src/main/java/rules/ExponentRule9.java similarity index 100% rename from src/main/rules/rules/ExponentRule9.java rename to rules/src/main/java/rules/ExponentRule9.java diff --git a/src/main/rules/rules/FractionsRule1.java b/rules/src/main/java/rules/FractionsRule1.java similarity index 100% rename from src/main/rules/rules/FractionsRule1.java rename to rules/src/main/java/rules/FractionsRule1.java diff --git a/src/main/rules/rules/FractionsRule10.java b/rules/src/main/java/rules/FractionsRule10.java similarity index 100% rename from src/main/rules/rules/FractionsRule10.java rename to rules/src/main/java/rules/FractionsRule10.java diff --git a/src/main/rules/rules/FractionsRule11.java b/rules/src/main/java/rules/FractionsRule11.java similarity index 100% rename from src/main/rules/rules/FractionsRule11.java rename to rules/src/main/java/rules/FractionsRule11.java diff --git a/src/main/rules/rules/FractionsRule12.java b/rules/src/main/java/rules/FractionsRule12.java similarity index 100% rename from src/main/rules/rules/FractionsRule12.java rename to rules/src/main/java/rules/FractionsRule12.java diff --git a/src/main/rules/rules/FractionsRule14.java b/rules/src/main/java/rules/FractionsRule14.java similarity index 100% rename from src/main/rules/rules/FractionsRule14.java rename to rules/src/main/java/rules/FractionsRule14.java diff --git a/src/main/rules/rules/FractionsRule2.java b/rules/src/main/java/rules/FractionsRule2.java similarity index 100% rename from src/main/rules/rules/FractionsRule2.java rename to rules/src/main/java/rules/FractionsRule2.java diff --git a/src/main/rules/rules/FractionsRule3.java b/rules/src/main/java/rules/FractionsRule3.java similarity index 100% rename from src/main/rules/rules/FractionsRule3.java rename to rules/src/main/java/rules/FractionsRule3.java diff --git a/src/main/rules/rules/FractionsRule4.java b/rules/src/main/java/rules/FractionsRule4.java similarity index 100% rename from src/main/rules/rules/FractionsRule4.java rename to rules/src/main/java/rules/FractionsRule4.java diff --git a/src/main/rules/rules/FractionsRule5.java b/rules/src/main/java/rules/FractionsRule5.java similarity index 100% rename from src/main/rules/rules/FractionsRule5.java rename to rules/src/main/java/rules/FractionsRule5.java diff --git a/src/main/rules/rules/FractionsRule6.java b/rules/src/main/java/rules/FractionsRule6.java similarity index 100% rename from src/main/rules/rules/FractionsRule6.java rename to rules/src/main/java/rules/FractionsRule6.java diff --git a/src/main/rules/rules/FractionsRule7.java b/rules/src/main/java/rules/FractionsRule7.java similarity index 100% rename from src/main/rules/rules/FractionsRule7.java rename to rules/src/main/java/rules/FractionsRule7.java diff --git a/src/main/rules/rules/FractionsRule8.java b/rules/src/main/java/rules/FractionsRule8.java similarity index 100% rename from src/main/rules/rules/FractionsRule8.java rename to rules/src/main/java/rules/FractionsRule8.java diff --git a/src/main/rules/rules/FractionsRule9.java b/rules/src/main/java/rules/FractionsRule9.java similarity index 100% rename from src/main/rules/rules/FractionsRule9.java rename to rules/src/main/java/rules/FractionsRule9.java diff --git a/src/main/rules/rules/NumberRule1.java b/rules/src/main/java/rules/NumberRule1.java similarity index 100% rename from src/main/rules/rules/NumberRule1.java rename to rules/src/main/java/rules/NumberRule1.java diff --git a/src/main/rules/rules/NumberRule2.java b/rules/src/main/java/rules/NumberRule2.java similarity index 100% rename from src/main/rules/rules/NumberRule2.java rename to rules/src/main/java/rules/NumberRule2.java diff --git a/src/main/rules/rules/NumberRule3.java b/rules/src/main/java/rules/NumberRule3.java similarity index 100% rename from src/main/rules/rules/NumberRule3.java rename to rules/src/main/java/rules/NumberRule3.java diff --git a/src/main/rules/rules/NumberRule4.java b/rules/src/main/java/rules/NumberRule4.java similarity index 100% rename from src/main/rules/rules/NumberRule4.java rename to rules/src/main/java/rules/NumberRule4.java diff --git a/src/main/rules/rules/NumberRule5.java b/rules/src/main/java/rules/NumberRule5.java similarity index 100% rename from src/main/rules/rules/NumberRule5.java rename to rules/src/main/java/rules/NumberRule5.java diff --git a/src/main/rules/rules/NumberRule7.java b/rules/src/main/java/rules/NumberRule7.java similarity index 100% rename from src/main/rules/rules/NumberRule7.java rename to rules/src/main/java/rules/NumberRule7.java diff --git a/src/main/rules/rules/UndefinedRule1.java b/rules/src/main/java/rules/UndefinedRule1.java similarity index 100% rename from src/main/rules/rules/UndefinedRule1.java rename to rules/src/main/java/rules/UndefinedRule1.java diff --git a/src/main/rules/rules/UndefinedRule2.java b/rules/src/main/java/rules/UndefinedRule2.java similarity index 100% rename from src/main/rules/rules/UndefinedRule2.java rename to rules/src/main/java/rules/UndefinedRule2.java diff --git a/src/main/rules/rules/VariableRule1.java b/rules/src/main/java/rules/VariableRule1.java similarity index 100% rename from src/main/rules/rules/VariableRule1.java rename to rules/src/main/java/rules/VariableRule1.java diff --git a/src/main/rules/rules/VariableRule2.java b/rules/src/main/java/rules/VariableRule2.java similarity index 100% rename from src/main/rules/rules/VariableRule2.java rename to rules/src/main/java/rules/VariableRule2.java diff --git a/src/main/rules/rules/VariableRule3.java b/rules/src/main/java/rules/VariableRule3.java similarity index 100% rename from src/main/rules/rules/VariableRule3.java rename to rules/src/main/java/rules/VariableRule3.java diff --git a/src/main/rules/rules/functions/DivisionRule.java b/rules/src/main/java/rules/functions/DivisionRule.java similarity index 100% rename from src/main/rules/rules/functions/DivisionRule.java rename to rules/src/main/java/rules/functions/DivisionRule.java diff --git a/src/main/rules/rules/functions/EmptyNumberRule.java b/rules/src/main/java/rules/functions/EmptyNumberRule.java similarity index 100% rename from src/main/rules/rules/functions/EmptyNumberRule.java rename to rules/src/main/java/rules/functions/EmptyNumberRule.java diff --git a/src/main/rules/rules/functions/ExpressionRule.java b/rules/src/main/java/rules/functions/ExpressionRule.java similarity index 100% rename from src/main/rules/rules/functions/ExpressionRule.java rename to rules/src/main/java/rules/functions/ExpressionRule.java diff --git a/src/main/rules/rules/functions/JokeRule.java b/rules/src/main/java/rules/functions/JokeRule.java similarity index 100% rename from src/main/rules/rules/functions/JokeRule.java rename to rules/src/main/java/rules/functions/JokeRule.java diff --git a/src/main/rules/rules/functions/MultiplicationRule.java b/rules/src/main/java/rules/functions/MultiplicationRule.java similarity index 100% rename from src/main/rules/rules/functions/MultiplicationRule.java rename to rules/src/main/java/rules/functions/MultiplicationRule.java diff --git a/src/main/rules/rules/functions/NegativeRule.java b/rules/src/main/java/rules/functions/NegativeRule.java similarity index 100% rename from src/main/rules/rules/functions/NegativeRule.java rename to rules/src/main/java/rules/functions/NegativeRule.java diff --git a/src/main/rules/rules/functions/NumberRule.java b/rules/src/main/java/rules/functions/NumberRule.java similarity index 100% rename from src/main/rules/rules/functions/NumberRule.java rename to rules/src/main/java/rules/functions/NumberRule.java diff --git a/src/main/rules/rules/functions/PowerRule.java b/rules/src/main/java/rules/functions/PowerRule.java similarity index 100% rename from src/main/rules/rules/functions/PowerRule.java rename to rules/src/main/java/rules/functions/PowerRule.java diff --git a/src/main/rules/rules/functions/RootRule.java b/rules/src/main/java/rules/functions/RootRule.java similarity index 100% rename from src/main/rules/rules/functions/RootRule.java rename to rules/src/main/java/rules/functions/RootRule.java diff --git a/src/main/rules/rules/functions/SubtractionRule.java b/rules/src/main/java/rules/functions/SubtractionRule.java similarity index 100% rename from src/main/rules/rules/functions/SubtractionRule.java rename to rules/src/main/java/rules/functions/SubtractionRule.java diff --git a/src/main/rules/rules/functions/SumRule.java b/rules/src/main/java/rules/functions/SumRule.java similarity index 100% rename from src/main/rules/rules/functions/SumRule.java rename to rules/src/main/java/rules/functions/SumRule.java diff --git a/src/main/rules/rules/functions/SumSubtractionRule.java b/rules/src/main/java/rules/functions/SumSubtractionRule.java similarity index 100% rename from src/main/rules/rules/functions/SumSubtractionRule.java rename to rules/src/main/java/rules/functions/SumSubtractionRule.java diff --git a/src/main/rules/rules/functions/VariableRule.java b/rules/src/main/java/rules/functions/VariableRule.java similarity index 100% rename from src/main/rules/rules/functions/VariableRule.java rename to rules/src/main/java/rules/functions/VariableRule.java diff --git a/src/jar-specific/java/it/cavallium/warppi/ConsoleUtils.java b/src/jar-specific/java/it/cavallium/warppi/ConsoleUtils.java deleted file mode 100644 index 878d3339..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/ConsoleUtils.java +++ /dev/null @@ -1,116 +0,0 @@ -package it.cavallium.warppi; - -import java.io.PrintStream; -import java.io.StringWriter; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; - -import it.cavallium.warppi.math.MathematicalSymbols; - -public class ConsoleUtils { - - public static final class AdvancedOutputStream extends StringWriter { - - private void print(PrintStream stream, String str) { - stream.print(fixString(str)); - } - - private void println(PrintStream stream, String str) { - stream.println(fixString(str)); - } - - private void println(PrintStream stream) { - stream.println(); - } - - private String fixString(String str) { - - return str.replace("" + MathematicalSymbols.NTH_ROOT, "root").replace("" + MathematicalSymbols.SQUARE_ROOT, "sqrt").replace("" + MathematicalSymbols.POWER, "powerOf").replace("" + MathematicalSymbols.POWER_OF_TWO, "powerOfTwo").replace("" + MathematicalSymbols.SINE, "sine").replace("" + MathematicalSymbols.COSINE, "cosine").replace("" + MathematicalSymbols.TANGENT, "tangent").replace("" + MathematicalSymbols.ARC_SINE, "asin").replace("" + MathematicalSymbols.ARC_COSINE, "acos").replace("" + MathematicalSymbols.ARC_TANGENT, "atan").replace("" + MathematicalSymbols.UNDEFINED, "undefined").replace("" + MathematicalSymbols.PI, "PI").replace("" + MathematicalSymbols.EULER_NUMBER, "EULER_NUMBER").replace("" + MathematicalSymbols.X, "X").replace("" + MathematicalSymbols.Y, "Y"); - } - - public void println(Object str) { - println(0, str); - } - - public void println(int level) { - if (StaticVars.outputLevel >= level) { - if (StaticVars.outputLevel == 0) { - println(System.out); - } else { - println(System.out); - } - } - } - - public void println(int level, Object str) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - if (StaticVars.outputLevel == 0) { - println(System.out, "[" + time + "] " + str); - } else { - println(System.out, "[" + time + "] " + str); - } - } - } - - public void print(int level, String str) { - if (StaticVars.outputLevel >= level) { - if (StaticVars.outputLevel == 0) { - print(System.out, str); - } else { - print(System.out, str); - } - } - } - - public void println(int level, String prefix, String str) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - if (StaticVars.outputLevel == 0) { - println(System.out, "[" + time + "][" + prefix + "] " + str); - } else { - println(System.out, "[" + time + "][" + prefix + "] " + str); - } - } - } - - public void println(int level, String... parts) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - StringBuilder output = new StringBuilder(); - for (int i = 0; i < parts.length; i++) { - if (i + 1 == parts.length) { - output.append(' '); - output.append(parts[i]); - } else { - output.append('['); - output.append(parts[i]); - output.append(']'); - } - } - output.insert(0, '['); - output.insert(1, time); - output.insert(time.length() + 1, ']'); - if (StaticVars.outputLevel == 0) { - println(System.out, output.toString()); - } else { - println(System.out, output.toString()); - } - } - } - - private String getTimeString() { - return LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss.SSS")); - } - - int before = 0; - boolean due = false; - - } - - public static ConsoleUtils.AdvancedOutputStream out = new ConsoleUtils.AdvancedOutputStream(); - public static final int OUTPUTLEVEL_NODEBUG = 0; - public static final int OUTPUTLEVEL_DEBUG_MIN = 1; - public static final int OUTPUTLEVEL_DEBUG_VERBOSE = 4; - -} diff --git a/src/jar-specific/java/it/cavallium/warppi/PlatformUtils.java b/src/jar-specific/java/it/cavallium/warppi/PlatformUtils.java deleted file mode 100644 index 73b586ba..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/PlatformUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -package it.cavallium.warppi; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.lang.ref.WeakReference; - -public final class PlatformUtils { - public static final boolean isJavascript = false; - public static String osName = System.getProperty("os.name").toLowerCase(); - - public static void setThreadName(Thread t, String string) { - t.setName(string); - } - - public static void setDaemon(Thread kt) { - kt.setDaemon(true); - } - - public static void setDaemon(Thread kt, boolean val) { - kt.setDaemon(val); - } - - public static void throwNewExceptionInInitializerError(String string) { - throw new ExceptionInInitializerError(string); - } - - public static String[] stacktraceToString(Error e) { - final StringWriter sw = new StringWriter(); - final PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - return sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n"); - } - - public static void loadPlatformRules() {} - - public static void gc() { - Object obj = new Object(); - final WeakReference ref = new WeakReference<>(obj); - obj = null; - while (ref.get() != null) { - System.gc(); - } - } - - public static void shiftChanged(boolean alpha) {} - - public static void alphaChanged(boolean alpha) {} -} diff --git a/src/jar-specific/java/it/cavallium/warppi/ZipUtils.java b/src/jar-specific/java/it/cavallium/warppi/ZipUtils.java deleted file mode 100644 index d86b01e1..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/ZipUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -package it.cavallium.warppi; - -import java.io.File; - -import net.lingala.zip4j.core.ZipFile; -import net.lingala.zip4j.model.ZipParameters; -import net.lingala.zip4j.util.Zip4jConstants; - -public class ZipUtils { - public static void zip(String targetPath, String destinationFilePath, String password) { - try { - final ZipParameters parameters = new ZipParameters(); - parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); - parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); - - if (password.length() > 0) { - parameters.setEncryptFiles(true); - parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES); - parameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256); - parameters.setPassword(password); - } - - final ZipFile zipFile = new ZipFile(destinationFilePath); - - final File targetFile = new File(targetPath); - if (targetFile.isFile()) { - zipFile.addFile(targetFile, parameters); - } else if (targetFile.isDirectory()) { - zipFile.addFolder(targetFile, parameters); - } - - } catch (final Exception e) { - e.printStackTrace(); - } - } - - public static void unzip(String targetZipFilePath, String destinationFolderPath, String password) { - try { - final ZipFile zipFile = new ZipFile(targetZipFilePath); - if (zipFile.isEncrypted()) { - zipFile.setPassword(password); - } - zipFile.extractAll(destinationFolderPath); - - } catch (final Exception e) { - e.printStackTrace(); - } - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DAtomicInteger.java b/src/jar-specific/java/it/cavallium/warppi/deps/DAtomicInteger.java deleted file mode 100644 index b0f4c304..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DAtomicInteger.java +++ /dev/null @@ -1,15 +0,0 @@ -package it.cavallium.warppi.deps; - -import java.util.concurrent.atomic.AtomicInteger; - -public class DAtomicInteger extends AtomicInteger { - public DAtomicInteger() { - super(); - } - - public DAtomicInteger(int i) { - super(i); - } - - private static final long serialVersionUID = 2910383978241062566L; -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DEngine.java b/src/jar-specific/java/it/cavallium/warppi/deps/DEngine.java deleted file mode 100644 index 6e83f6f3..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DEngine.java +++ /dev/null @@ -1,40 +0,0 @@ -package it.cavallium.warppi.deps; - -import it.cavallium.warppi.ClassUtils; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.cpu.CPUEngine; -import it.cavallium.warppi.gui.graphicengine.framebuffer.FBEngine; - -public class DEngine { - public static GraphicEngine newGPUEngine() { - try { - return (GraphicEngine) ClassUtils.newClassInstance("it.cavallium.warppi.gui.graphicengine.gpu.GPUEngine"); - } catch (NullPointerException ex) { - return null; - } - } - - public static GraphicEngine newHeadless24bitEngine() { - return new it.cavallium.warppi.gui.graphicengine.headless24bit.Headless24bitEngine(); - } - - public static GraphicEngine newHeadless256Engine() { - return new it.cavallium.warppi.gui.graphicengine.headless256.Headless256Engine(); - } - - public static GraphicEngine newHeadless8Engine() { - return new it.cavallium.warppi.gui.graphicengine.headless8.Headless8Engine(); - } - - public static GraphicEngine newCPUEngine() { - return new CPUEngine(); - } - - public static GraphicEngine newFBEngine() { - return new FBEngine(); - } - - public static GraphicEngine newHtmlEngine() { - return null; - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DGpio.java b/src/jar-specific/java/it/cavallium/warppi/deps/DGpio.java deleted file mode 100644 index 989aa86d..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DGpio.java +++ /dev/null @@ -1,46 +0,0 @@ -package it.cavallium.warppi.deps; - -import it.cavallium.warppi.ClassUtils; - -public class DGpio { - - public static final int OUTPUT = com.pi4j.wiringpi.Gpio.OUTPUT; - public static final int PWM_OUTPUT = com.pi4j.wiringpi.Gpio.PWM_OUTPUT; - public static final int INPUT = com.pi4j.wiringpi.Gpio.INPUT; - public static final int HIGH = com.pi4j.wiringpi.Gpio.HIGH; - public static final int LOW = com.pi4j.wiringpi.Gpio.LOW; - public static final Object UnknownBoardType = com.pi4j.system.SystemInfo.BoardType.UNKNOWN; - - public static void wiringPiSetupPhys() { - com.pi4j.wiringpi.Gpio.wiringPiSetupPhys(); - } - - public static void pinMode(int i, int type) { - com.pi4j.wiringpi.Gpio.pinMode(i, type); - } - - public static void digitalWrite(int pin, int val) { - com.pi4j.wiringpi.Gpio.digitalWrite(pin, val); - } - - public static void digitalWrite(int pin, boolean val) { - com.pi4j.wiringpi.Gpio.digitalWrite(pin, val); - } - - public static void pwmWrite(int pin, int val) { - com.pi4j.wiringpi.Gpio.pwmWrite(pin, val); - } - - public static void delayMicroseconds(int t) { - com.pi4j.wiringpi.Gpio.delayMicroseconds(t); - } - - public static int digitalRead(int pin) { - return com.pi4j.wiringpi.Gpio.digitalRead(pin); - } - - public static Object getBoardType() { - return ClassUtils.invokeStaticMethod("com.pi4j.system.SystemInfo.getBoardType"); - } - -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DJDTCompiler.java b/src/jar-specific/java/it/cavallium/warppi/deps/DJDTCompiler.java deleted file mode 100644 index e8b91d44..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DJDTCompiler.java +++ /dev/null @@ -1,10 +0,0 @@ -package it.cavallium.warppi.deps; - -import java.io.PrintWriter; - -public class DJDTCompiler { - - public static boolean compile(String[] strings, PrintWriter printWriter, PrintWriter printWriter2) { - return org.eclipse.jdt.internal.compiler.batch.Main.compile(strings, printWriter, printWriter2, null); - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DSemaphore.java b/src/jar-specific/java/it/cavallium/warppi/deps/DSemaphore.java deleted file mode 100644 index d39b5142..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DSemaphore.java +++ /dev/null @@ -1,18 +0,0 @@ -package it.cavallium.warppi.deps; - -import java.util.concurrent.Semaphore; - -public class DSemaphore extends Semaphore { - - private static final long serialVersionUID = -2362314723921013871L; - - public DSemaphore(int arg0) { - super(arg0); - // TODO Auto-generated constructor stub - } - - public DSemaphore(int permits, boolean fair) { - super(permits, fair); - // TODO Auto-generated constructor stub - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DStandardOpenOption.java b/src/jar-specific/java/it/cavallium/warppi/deps/DStandardOpenOption.java deleted file mode 100644 index 2cdf2478..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DStandardOpenOption.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - -package it.cavallium.warppi.deps; - -import java.nio.file.LinkOption; - -/** - * Defines the standard open options. - * - * @since 1.7 - */ - -public enum DStandardOpenOption { - /** - * Open for read access. - */ - READ, - - /** - * Open for write access. - */ - WRITE, - - /** - * If the file is opened for {@link #WRITE} access then bytes will be - * written - * to the end of the file rather than the beginning. - * - *

- * If the file is opened for write access by other programs, then it - * is file system specific if writing to the end of the file is atomic. - */ - APPEND, - - /** - * If the file already exists and it is opened for {@link #WRITE} - * access, then its length is truncated to 0. This option is ignored - * if the file is opened only for {@link #READ} access. - */ - TRUNCATE_EXISTING, - - /** - * Create a new file if it does not exist. - * This option is ignored if the {@link #CREATE_NEW} option is also set. - * The check for the existence of the file and the creation of the file - * if it does not exist is atomic with respect to other file system - * operations. - */ - CREATE, - - /** - * Create a new file, failing if the file already exists. - * The check for the existence of the file and the creation of the file - * if it does not exist is atomic with respect to other file system - * operations. - */ - CREATE_NEW, - - /** - * Delete on close. When this option is present then the implementation - * makes a best effort attempt to delete the file when closed - * by the appropriate {@code close} method. If the {@code close} method is - * not invoked then a best effort attempt is made to delete the - * file when the Java virtual machine terminates (either normally, as - * defined by the Java Language Specification, or where possible, - * abnormally). - * This option is primarily intended for use with work files that - * are used solely by a single instance of the Java virtual machine. This - * option is not recommended for use when opening files that are open - * concurrently by other entities. Many of the details as to when and how - * the file is deleted are implementation specific and therefore not - * specified. In particular, an implementation may be unable to guarantee - * that it deletes the expected file when replaced by an attacker while the - * file is open. Consequently, security sensitive applications should take - * care when using this option. - * - *

- * For security reasons, this option may imply the {@link - * LinkOption#NOFOLLOW_LINKS} option. In other words, if the option is - * present - * when opening an existing file that is a symbolic link then it may fail - * (by throwing {@link java.io.IOException}). - */ - DELETE_ON_CLOSE, - - /** - * Sparse file. When used with the {@link #CREATE_NEW} option then this - * option provides a hint that the new file will be sparse. The - * option is ignored when the file system does not support the creation of - * sparse files. - */ - SPARSE, - - /** - * Requires that every update to the file's content or metadata be written - * synchronously to the underlying storage device. - * - * @see Synchronized I/O file - * integrity - */ - SYNC, - - /** - * Requires that every update to the file's content be written - * synchronously to the underlying storage device. - * - * @see Synchronized I/O file - * integrity - */ - DSYNC; -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DSystem.java b/src/jar-specific/java/it/cavallium/warppi/deps/DSystem.java deleted file mode 100644 index ef421991..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DSystem.java +++ /dev/null @@ -1,7 +0,0 @@ -package it.cavallium.warppi.deps; - -public class DSystem { - public static final void exit(int val) { - System.exit(val); - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/DURLClassLoader.java b/src/jar-specific/java/it/cavallium/warppi/deps/DURLClassLoader.java deleted file mode 100644 index 1ad355e7..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/DURLClassLoader.java +++ /dev/null @@ -1,23 +0,0 @@ -package it.cavallium.warppi.deps; - -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLStreamHandlerFactory; - -public class DURLClassLoader extends URLClassLoader { - - public DURLClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { - super(urls, parent, factory); - // TODO Auto-generated constructor stub - } - - public DURLClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); - // TODO Auto-generated constructor stub - } - - public DURLClassLoader(URL[] urls) { - super(urls); - // TODO Auto-generated constructor stub - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/nio/DFiles.java b/src/jar-specific/java/it/cavallium/warppi/deps/nio/DFiles.java deleted file mode 100644 index 428cbc59..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/nio/DFiles.java +++ /dev/null @@ -1,26 +0,0 @@ -package it.cavallium.warppi.deps.nio; - -import java.io.IOException; -import java.nio.file.Files; -import java.util.List; - -public class DFiles { - - public static boolean deleteIfExists(DPath path) throws IOException { - return Files.deleteIfExists(path.toPath()); - - } - - public static boolean exists(DPath f) { - return Files.exists(f.toPath()); - } - - public static DPath createTempFile(String prefix, String suffix) throws IOException { - return new DPath(Files.createTempFile(prefix, suffix)); - } - - public static List readAllLines(DPath p) throws IOException { - return Files.readAllLines(p.toPath()); - } - -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/nio/DPath.java b/src/jar-specific/java/it/cavallium/warppi/deps/nio/DPath.java deleted file mode 100644 index 0217e705..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/nio/DPath.java +++ /dev/null @@ -1,20 +0,0 @@ -package it.cavallium.warppi.deps.nio; - -import java.nio.file.Path; - -public class DPath { - - private final Path p; - - public DPath(Path p) { - this.p = p; - } - - Path toPath() { - return p; - } - - public DPath toAbsolutePath() { - return new DPath(p.toAbsolutePath()); - } -} diff --git a/src/jar-specific/java/it/cavallium/warppi/deps/nio/DPaths.java b/src/jar-specific/java/it/cavallium/warppi/deps/nio/DPaths.java deleted file mode 100644 index dc9a89ee..00000000 --- a/src/jar-specific/java/it/cavallium/warppi/deps/nio/DPaths.java +++ /dev/null @@ -1,11 +0,0 @@ -package it.cavallium.warppi.deps.nio; - -import java.nio.file.Paths; - -public class DPaths { - - public static DPath get(String first, String... more) { - return new DPath(Paths.get(first, more)); - } - -} diff --git a/src/main/java/it/cavallium/warppi/KeyboardTest.java b/src/main/java/it/cavallium/warppi/KeyboardTest.java deleted file mode 100755 index 76066ec1..00000000 --- a/src/main/java/it/cavallium/warppi/KeyboardTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package it.cavallium.warppi; - -import java.io.IOException; - -import it.cavallium.warppi.boot.WarpPI; -import it.cavallium.warppi.device.PIHardwareDisplay; -import it.cavallium.warppi.device.PIHardwareTouchDevice; -import it.cavallium.warppi.gui.CalculatorHUD; -import it.cavallium.warppi.gui.screens.KeyboardDebugScreen; - -public class KeyboardTest { - - public static void main(String[] args) throws InterruptedException, Error, IOException { - Engine.start(new KeyboardDebugScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), WarpPI.parseStartupArguments(args)); - } -} diff --git a/src/main/java/it/cavallium/warppi/TestGPU.java b/src/main/java/it/cavallium/warppi/TestGPU.java deleted file mode 100755 index 7d675566..00000000 --- a/src/main/java/it/cavallium/warppi/TestGPU.java +++ /dev/null @@ -1,226 +0,0 @@ -package it.cavallium.warppi; - -import java.io.IOException; - -import it.cavallium.warppi.deps.DEngine; -import it.cavallium.warppi.deps.DSystem; -import it.cavallium.warppi.device.Keyboard; -import it.cavallium.warppi.event.KeyPressedEvent; -import it.cavallium.warppi.event.KeyReleasedEvent; -import it.cavallium.warppi.event.KeyboardEventListener; -import it.cavallium.warppi.gui.expression.InputContext; -import it.cavallium.warppi.gui.expression.blocks.BlockContainer; -import it.cavallium.warppi.gui.expression.containers.NormalInputContainer; -import it.cavallium.warppi.gui.graphicengine.BinaryFont; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.Renderer; -import it.cavallium.warppi.gui.graphicengine.RenderingLoop; -import it.cavallium.warppi.gui.graphicengine.Skin; -import it.cavallium.warppi.math.MathContext; -import it.cavallium.warppi.math.MathematicalSymbols; -import it.cavallium.warppi.math.functions.Expression; -import it.cavallium.warppi.math.parser.MathParser; - -public class TestGPU { - - public static final GraphicEngine d = DEngine.newGPUEngine(); - - public static void main(String[] args) throws IOException, Error { - StaticVars.debugOn = true; - Utils.debugThirdScreen = false; - d.create(); - - Keyboard k = new Keyboard(); - k.startKeyboard(); - k.setAdditionalKeyboardListener(new KeyboardEventListener() { - @Override - public boolean onKeyPressed(KeyPressedEvent k) { - try { - switch (k.getKey()) { - case LEFT: - c.moveLeft(); - return true; - case RIGHT: - c.moveRight(); - return true; - case NUM0: - c.typeChar('0'); - return true; - case NUM1: - c.typeChar('1'); - return true; - case NUM2: - c.typeChar('2'); - return true; - case NUM3: - c.typeChar('3'); - return true; - case NUM4: - c.typeChar('4'); - return true; - case NUM5: - c.typeChar('5'); - return true; - case NUM6: - c.typeChar('6'); - return true; - case NUM7: - c.typeChar('7'); - return true; - case NUM8: - c.typeChar('8'); - return true; - case NUM9: - c.typeChar('9'); - return true; - case PLUS: - c.typeChar(MathematicalSymbols.SUM); - return true; - case MINUS: - c.typeChar(MathematicalSymbols.SUBTRACTION); - return true; - case MULTIPLY: - c.typeChar(MathematicalSymbols.MULTIPLICATION); - return true; - case DIVIDE: - c.typeChar(MathematicalSymbols.DIVISION); - return true; - case SQRT: - c.typeChar(MathematicalSymbols.SQUARE_ROOT); - return true; - case PARENTHESIS_OPEN: - case SINE: - c.typeChar(MathematicalSymbols.PARENTHESIS_OPEN); - return true; - case PARENTHESIS_CLOSE: - case debug_DEG: - c.moveRight(); - return true; - case DELETE: - c.del(); - return true; - case RESET: - c.clear(); - return true; - case POWEROFF: - d.destroy(); - DSystem.exit(0); - return true; - case EQUAL: - Expression expr; - try { - expr = MathParser.parseInput(new MathContext(), c); - System.out.println("Parsed input:" + expr.toString()); - } catch (final Error e) { - e.printStackTrace(); - } - default: - break; - } - return false; - } catch (final Exception ex) { - ex.printStackTrace(); - } - return false; - - } - - @Override - public boolean onKeyReleased(KeyReleasedEvent k) { - return false; - - } - }); - - new Scene(d); - } - - private static NormalInputContainer c = null; - - private static class Scene implements RenderingLoop { - - private final BinaryFont exampleFont; - private final Skin exampleSkin; - - private final Renderer r; - private final GraphicEngine d; - private long lastTime = 0L; - - public Scene(GraphicEngine d) throws IOException, Error { - this.d = d; - r = d.getRenderer(); - - exampleFont = d.loadFont("norm"); - - exampleSkin = d.loadSkin("skin.png"); - - BlockContainer.initializeFonts(d.loadFont("norm"), d.loadFont("smal")); - - //New expression framework test - c = new NormalInputContainer(new InputContext(), false, 0, 200); - c.typeChar(MathematicalSymbols.DIVISION); - c.typeChar('5'); - c.typeChar(MathematicalSymbols.MULTIPLICATION); - c.typeChar('2'); - c.moveRight(); - c.typeChar('2'); - c.moveRight(); - c.typeChar(MathematicalSymbols.MULTIPLICATION); - c.typeChar('2'); - c.typeChar('2'); - c.recomputeDimensions(); - - d.start(this); - -// fonts = new RAWFont[1]; -// textures = new int[100]; -// fonts[0] = new RAWFont(); -// fonts[0].create("big"); - new Thread(() -> { - try { - for (int i = 0; i < 12; i++) { - Utils.printSystemResourcesUsage(); - Thread.sleep(5000); - } - } catch (final InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if (!StaticVars.debugOn) { - d.destroy(); - DSystem.exit(0); - } - }).start(); - - d.waitForExit(); - } - - @Override - public void refresh() { - exampleSkin.use(d); - r.glClearColor(0xFFD0FDCF); - r.glClear(d.getWidth(), d.getHeight()); - r.glColor3f(1.0f, 1.0f, 1.0f); - r.glFillRect(2, 2, 160, 160, 0, 0, 16, 16); - exampleFont.use(d); - r.glColor3f(1, 0, 0); - r.glDrawStringLeft(10, 170, "Prova! 123456789 222"); - - //MSAA TEST - r.glDrawStringLeft(10f, 190.5f, "Test MSAA"); - exampleSkin.use(d); - r.glColor3f(1.0f, 1.0f, 1.0f); - r.glFillRect(162, 2.5f, 160, 160, 0, 0, 16, 16); - - //New expression framework test - if (lastTime == 0) { - lastTime = System.currentTimeMillis(); - } - final double delta = System.currentTimeMillis() - lastTime; - lastTime = System.currentTimeMillis(); - c.beforeRender((float) (delta / 1000d)); - c.draw(d, r, 10, 220); - } - - } -} diff --git a/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java b/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java deleted file mode 100755 index 2c739877..00000000 --- a/src/main/java/it/cavallium/warppi/device/chip/ParallelToSerial.java +++ /dev/null @@ -1,35 +0,0 @@ -package it.cavallium.warppi.device.chip; - -import it.cavallium.warppi.deps.DGpio; - -public class ParallelToSerial { - - private final int SH_LD; - private final int CLK_INH; - private final int QH; - private final int CLK; - - public ParallelToSerial(int SH_LD_pin, int CLK_INH_pin, int QH_pin, int CLK_pin) { - SH_LD = SH_LD_pin; - CLK_INH = CLK_INH_pin; - QH = QH_pin; - CLK = CLK_pin; - } - - public boolean[] read() { - final boolean[] data = new boolean[8]; - DGpio.digitalWrite(CLK_INH, DGpio.HIGH); - DGpio.digitalWrite(SH_LD, DGpio.LOW); - DGpio.delayMicroseconds(1); - DGpio.digitalWrite(SH_LD, DGpio.HIGH); - DGpio.digitalWrite(CLK_INH, DGpio.LOW); - - for (int i = 7; i >= 0; i--) { - DGpio.digitalWrite(CLK, DGpio.HIGH); - DGpio.digitalWrite(CLK, DGpio.LOW); - data[i] = DGpio.digitalRead(QH) == DGpio.HIGH ? true : false; - } - - return data; - } -} diff --git a/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java b/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java deleted file mode 100755 index 3e991131..00000000 --- a/src/main/java/it/cavallium/warppi/device/chip/SerialToParallel.java +++ /dev/null @@ -1,31 +0,0 @@ -package it.cavallium.warppi.device.chip; - -import it.cavallium.warppi.deps.DGpio; - -public class SerialToParallel { - private final int RCK; //Storage register clock pin (latch pin) - private final int SCK; //Shift register clock pin - private final int SER; //Serial data input - - public SerialToParallel(int RCK_pin, int SCK_pin, int SER_pin) { - RCK = RCK_pin; - SCK = SCK_pin; - SER = SER_pin; - } - - public void write(boolean[] data) { - if (data.length != 8) { - return; - } else { - DGpio.digitalWrite(RCK, DGpio.LOW); - - for (int i = 7; i >= 0; i--) { - DGpio.digitalWrite(SCK, DGpio.LOW); - DGpio.digitalWrite(SER, data[i]); - DGpio.digitalWrite(SCK, DGpio.HIGH); - } - - DGpio.digitalWrite(RCK, DGpio.HIGH); - } - } -} diff --git a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUSkin.java b/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUSkin.java deleted file mode 100755 index a3b8353d..00000000 --- a/src/main/java/it/cavallium/warppi/gui/graphicengine/cpu/CPUSkin.java +++ /dev/null @@ -1,124 +0,0 @@ -package it.cavallium.warppi.gui.graphicengine.cpu; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; - -import javax.imageio.ImageIO; - -import ar.com.hjg.pngj.ImageLineInt; -import ar.com.hjg.pngj.PngReader; -import it.cavallium.warppi.deps.StorageUtils; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.Skin; - -public class CPUSkin implements Skin { - - public int[] skinData; - public int[] skinSize; - @SuppressWarnings("unused") - private final boolean isResource; - - public CPUSkin(String file) throws IOException { - isResource = !new File(file).exists(); - load(file); - } - - @SuppressWarnings("unused") - @Override - public void load(String file) throws IOException { - if (!file.startsWith("/")) - file = "/" + file; - try { - if (!file.endsWith(".png")) { - File f = File.createTempFile("picalculator-png", ".png"); - f.deleteOnExit(); - BufferedImage img = ImageIO.read(StorageUtils.getResourceStream(file)); - ImageIO.write(img, "PNG", f); - file = f.toString(); - } - PngReader r = new PngReader(StorageUtils.getResourceStream(file)); - if (r == null) { - skinData = new int[0]; - skinSize = new int[] { 0, 0 }; - System.err.println("ERROR WHILE LOADING SKIN " + file); - } else { - skinData = getMatrixOfImage(r); - skinSize = new int[] { r.imgInfo.cols, r.imgInfo.rows }; - } - } catch (URISyntaxException e) { - IOException ex = new IOException(); - ex.initCause(e); - throw ex; - } - } - - public static int[] getMatrixOfImage(PngReader r) { - final int width = r.imgInfo.cols; - final int height = r.imgInfo.rows; - final int channels = r.imgInfo.channels; - final int[] pixels = new int[width * height]; - int pi = 0; - ImageLineInt lint; - while (r.hasMoreRows()) { - lint = (ImageLineInt) r.readRow(); - int[] scanLine = lint.getScanline(); - - for (int i = 0; i < width; i++) { - int offset = i * channels; - - // Adjust the following code depending on your source image. - // I need the to set the alpha channel to 0xFF000000 since my destination image - // is TRANSLUCENT : BufferedImage bi = CONFIG.createCompatibleImage( width, height, Transparency.TRANSLUCENT ); - // my source was 3 channels RGB without transparency - int nextPixel; - if (channels == 4) { - nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (scanLine[offset + 3] << 24); - } else if (channels == 3) { - nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (0xFF << 24); - } else if (channels == 2) { - nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24); - } else { - nextPixel = (scanLine[offset] << 16) | (scanLine[offset] << 8) | scanLine[offset] | (0xFF << 24); - } - - // I'm placing the pixels on a memory mapped file - pixels[pi] = nextPixel; - pi++; - } - - } - - return pixels; - } - - @Override - public void initialize(GraphicEngine d) { - // TODO Auto-generated method stub - - } - - @Override - public void use(GraphicEngine d) { - if (d.getRenderer() instanceof CPURenderer) { - ((CPURenderer) d.getRenderer()).currentSkin = this; - } - } - - @Override - public boolean isInitialized() { - return true; - } - - @Override - public int getSkinWidth() { - return skinSize[0]; - } - - @Override - public int getSkinHeight() { - return skinSize[1]; - } - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/ConsoleUtils.java b/src/teavm-specific/java/it/cavallium/warppi/ConsoleUtils.java deleted file mode 100644 index e201d1d6..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/ConsoleUtils.java +++ /dev/null @@ -1,110 +0,0 @@ -package it.cavallium.warppi; - -import java.io.PrintStream; -import java.io.StringWriter; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; - -import it.cavallium.warppi.math.MathematicalSymbols; - -public class ConsoleUtils { - - public static final class AdvancedOutputStream { - - private void print(PrintStream stream, String str) { - stream.print(fixString(str)); - } - - private void println(PrintStream stream, String str) { - stream.println(fixString(str)); - } - - private void println(PrintStream stream) { - stream.println(); - } - - private String fixString(String str) { - - return str.replace("" + MathematicalSymbols.NTH_ROOT, "root").replace("" + MathematicalSymbols.SQUARE_ROOT, "sqrt").replace("" + MathematicalSymbols.POWER, "powerOf").replace("" + MathematicalSymbols.POWER_OF_TWO, "powerOfTwo").replace("" + MathematicalSymbols.SINE, "sine").replace("" + MathematicalSymbols.COSINE, "cosine").replace("" + MathematicalSymbols.TANGENT, "tangent").replace("" + MathematicalSymbols.ARC_SINE, "asin").replace("" + MathematicalSymbols.ARC_COSINE, "acos").replace("" + MathematicalSymbols.ARC_TANGENT, "atan").replace("" + MathematicalSymbols.UNDEFINED, "undefined").replace("" + MathematicalSymbols.PI, "PI").replace("" + MathematicalSymbols.EULER_NUMBER, "EULER_NUMBER").replace("" + MathematicalSymbols.X, "X").replace("" + MathematicalSymbols.Y, "Y"); - } - - public void println(String str) { - println(0, str); - } - - public void println(int level) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - if (StaticVars.outputLevel == 0) { - println(System.out); - } else { - println(System.out); - } - } - } - - public void println(int level, Object str) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - if (StaticVars.outputLevel == 0) { - println(System.out, "[" + time + "]" + str); - } else { - println(System.out, "[" + time + "]" + str); - } - } - } - - public void print(int level, String str) { - if (StaticVars.outputLevel >= level) { - if (StaticVars.outputLevel == 0) { - print(System.out, str); - } else { - print(System.out, str); - } - } - } - - public void println(int level, Object prefix, Object str) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - if (StaticVars.outputLevel == 0) { - println(System.out, "[" + time + "][" + prefix + "]" + str); - } else { - println(System.out, "[" + time + "][" + prefix + "]" + str); - } - } - } - - public void println(int level, Object... parts) { - if (StaticVars.outputLevel >= level) { - final String time = getTimeString(); - String output = ""; - for (int i = 0; i < parts.length; i++) { - if (i + 1 == parts.length) { - output += parts[i]; - } else { - output += "[" + parts[i] + "]"; - } - } - if (StaticVars.outputLevel == 0) { - println(System.out, "[" + time + "]" + output); - } else { - println(System.out, "[" + time + "]" + output); - } - } - } - - private String getTimeString() { - return System.currentTimeMillis()+""; - } - - int before = 0; - boolean due = false; - - } - public static ConsoleUtils.AdvancedOutputStream out = new ConsoleUtils.AdvancedOutputStream(); - public static final int OUTPUTLEVEL_NODEBUG = 0; - public static final int OUTPUTLEVEL_DEBUG_MIN = 1; - public static final int OUTPUTLEVEL_DEBUG_VERBOSE = 4; - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/ZipUtils.java b/src/teavm-specific/java/it/cavallium/warppi/ZipUtils.java deleted file mode 100644 index 6820c666..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/ZipUtils.java +++ /dev/null @@ -1,11 +0,0 @@ -package it.cavallium.warppi; - -public class ZipUtils { - public static void zip(String targetPath, String destinationFilePath, String password) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } - - public static void unzip(String targetZipFilePath, String destinationFolderPath, String password) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DAtomicInteger.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DAtomicInteger.java deleted file mode 100644 index ab47d0ec..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DAtomicInteger.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - -/* - * - * - * - * - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package it.cavallium.warppi.deps; -import java.util.function.IntUnaryOperator; -import java.util.function.IntBinaryOperator; - -/** - * An {@code int} value that may be updated atomically. See the - * {@link java.util.concurrent.atomic} package specification for - * description of the properties of atomic variables. An - * {@code AtomicInteger} is used in applications such as atomically - * incremented counters, and cannot be used as a replacement for an - * {@link java.lang.Integer}. However, this class does extend - * {@code Number} to allow uniform access by tools and utilities that - * deal with numerically-based classes. - * - * @since 1.5 - * @author Doug Lea -*/ -public class DAtomicInteger extends Number implements java.io.Serializable { - private static final long serialVersionUID = 6214790243416807050L; - - - private volatile int value; - - /** - * Creates a new AtomicInteger with the given initial value. - * - * @param initialValue the initial value - */ - public DAtomicInteger(int initialValue) { - value = initialValue; - } - - /** - * Creates a new AtomicInteger with initial value {@code 0}. - */ - public DAtomicInteger() { - } - - /** - * Gets the current value. - * - * @return the current value - */ - public final int get() { - return value; - } - - /** - * Sets to the given value. - * - * @param newValue the new value - */ - public final void set(int newValue) { - value = newValue; - } - - /** - * Eventually sets to the given value. - * - * @param newValue the new value - * @since 1.6 - */ - public final void lazySet(int newValue) { - value = newValue; - } - - /** - * Atomically sets to the given value and returns the old value. - * - * @param newValue the new value - * @return the previous value - */ - public final int getAndSet(int newValue) { - int oldV = value; - value = newValue; - return oldV; - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - * @param expect the expected value - * @param update the new value - * @return {@code true} if successful. False return indicates that - * the actual value was not equal to the expected value. - */ - public final boolean compareAndSet(int expect, int update) { - boolean equal = (value == expect); - value = update; - return equal; - } - - /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. - * - *

May fail - * spuriously and does not provide ordering guarantees, so is - * only rarely an appropriate alternative to {@code compareAndSet}. - * - * @param expect the expected value - * @param update the new value - * @return {@code true} if successful - */ - public final boolean weakCompareAndSet(int expect, int update) { - return compareAndSet(expect, update); - } - - /** - * Atomically increments by one the current value. - * - * @return the previous value - */ - public final int getAndIncrement() { - int oldV = value; - value++; - return oldV; - } - - /** - * Atomically decrements by one the current value. - * - * @return the previous value - */ - public final int getAndDecrement() { - int oldV = value; - value--; - return oldV; - } - - /** - * Atomically adds the given value to the current value. - * - * @param delta the value to add - * @return the previous value - */ - public final int getAndAdd(int delta) { - int oldV = value; - value+=delta; - return oldV; - } - - /** - * Atomically increments by one the current value. - * - * @return the updated value - */ - public final int incrementAndGet() { - value++; - return value; - } - - /** - * Atomically decrements by one the current value. - * - * @return the updated value - */ - public final int decrementAndGet() { - value--; - return value; - } - - /** - * Atomically adds the given value to the current value. - * - * @param delta the value to add - * @return the updated value - */ - public final int addAndGet(int delta) { - value+=delta; - return value; - } - - /** - * Atomically updates the current value with the results of - * applying the given function, returning the previous value. The - * function should be side-effect-free, since it may be re-applied - * when attempted updates fail due to contention among threads. - * - * @param updateFunction a side-effect-free function - * @return the previous value - * @since 1.8 - */ - public final int getAndUpdate(IntUnaryOperator updateFunction) { - int prev, next; - do { - prev = get(); - next = updateFunction.applyAsInt(prev); - } while (!compareAndSet(prev, next)); - return prev; - } - - /** - * Atomically updates the current value with the results of - * applying the given function, returning the updated value. The - * function should be side-effect-free, since it may be re-applied - * when attempted updates fail due to contention among threads. - * - * @param updateFunction a side-effect-free function - * @return the updated value - * @since 1.8 - */ - public final int updateAndGet(IntUnaryOperator updateFunction) { - int prev, next; - do { - prev = get(); - next = updateFunction.applyAsInt(prev); - } while (!compareAndSet(prev, next)); - return next; - } - - /** - * Atomically updates the current value with the results of - * applying the given function to the current and given values, - * returning the previous value. The function should be - * side-effect-free, since it may be re-applied when attempted - * updates fail due to contention among threads. The function - * is applied with the current value as its first argument, - * and the given update as the second argument. - * - * @param x the update value - * @param accumulatorFunction a side-effect-free function of two arguments - * @return the previous value - * @since 1.8 - */ - public final int getAndAccumulate(int x, - IntBinaryOperator accumulatorFunction) { - int prev, next; - do { - prev = get(); - next = accumulatorFunction.applyAsInt(prev, x); - } while (!compareAndSet(prev, next)); - return prev; - } - - /** - * Atomically updates the current value with the results of - * applying the given function to the current and given values, - * returning the updated value. The function should be - * side-effect-free, since it may be re-applied when attempted - * updates fail due to contention among threads. The function - * is applied with the current value as its first argument, - * and the given update as the second argument. - * - * @param x the update value - * @param accumulatorFunction a side-effect-free function of two arguments - * @return the updated value - * @since 1.8 - */ - public final int accumulateAndGet(int x, - IntBinaryOperator accumulatorFunction) { - int prev, next; - do { - prev = get(); - next = accumulatorFunction.applyAsInt(prev, x); - } while (!compareAndSet(prev, next)); - return next; - } - - /** - * Returns the String representation of the current value. - * @return the String representation of the current value - */ - public String toString() { - return Integer.toString(get()); - } - - /** - * Returns the value of this {@code AtomicInteger} as an {@code int}. - */ - public int intValue() { - return get(); - } - - /** - * Returns the value of this {@code AtomicInteger} as a {@code long} - * after a widening primitive conversion. - * @jls 5.1.2 Widening Primitive Conversions - */ - public long longValue() { - return (long)get(); - } - - /** - * Returns the value of this {@code AtomicInteger} as a {@code float} - * after a widening primitive conversion. - * @jls 5.1.2 Widening Primitive Conversions - */ - public float floatValue() { - return (float)get(); - } - - /** - * Returns the value of this {@code AtomicInteger} as a {@code double} - * after a widening primitive conversion. - * @jls 5.1.2 Widening Primitive Conversions - */ - public double doubleValue() { - return (double)get(); - } - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DEngine.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DEngine.java deleted file mode 100644 index 4d20fd67..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DEngine.java +++ /dev/null @@ -1,29 +0,0 @@ -package it.cavallium.warppi.deps; - -import it.cavallium.warppi.ClassUtils; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.html.HtmlEngine; - -public class DEngine { - public static GraphicEngine newCPUEngine() { - return null; - } - public static GraphicEngine newGPUEngine() { - return null; - } - public static GraphicEngine newHeadless24bitEngine() { - return null; - } - public static GraphicEngine newHeadless256Engine() { - return null; - } - public static GraphicEngine newHeadless8Engine() { - return null; - } - public static GraphicEngine newFBEngine() { - return null; - } - public static GraphicEngine newHtmlEngine() { - return new HtmlEngine(); - } -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DGpio.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DGpio.java deleted file mode 100644 index de9750f1..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DGpio.java +++ /dev/null @@ -1,45 +0,0 @@ -package it.cavallium.warppi.deps; - -import it.cavallium.warppi.ClassUtils; -import it.cavallium.warppi.ClassUtils.Var; - -public class DGpio { - - public static final int OUTPUT = 0; - public static final int PWM_OUTPUT = 1; - public static final int INPUT = 2; - public static final int HIGH = 3; - public static final int LOW = 4; - public static final Object UnknownBoardType = new Object(); - - public static void wiringPiSetupPhys() { - } - - public static void pinMode(int i, int type) { - } - - public static void digitalWrite(int pin, int val) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } - - public static void digitalWrite(int pin, boolean val) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } - - public static void pwmWrite(int pin, int val) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } - - public static void delayMicroseconds(int t) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } - - public static int digitalRead(int pin) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } - - public static Object getBoardType() { - return new Object(); - } - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DJDTCompiler.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DJDTCompiler.java deleted file mode 100644 index c7f815ca..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DJDTCompiler.java +++ /dev/null @@ -1,13 +0,0 @@ -package it.cavallium.warppi.deps; - -import java.io.PrintWriter; - -import it.cavallium.warppi.ClassUtils; -import it.cavallium.warppi.ClassUtils.Var; - -public class DJDTCompiler { - - public static boolean compile(String[] strings, PrintWriter printWriter, PrintWriter printWriter2) { - throw new java.lang.UnsupportedOperationException("Not implemented."); - } -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DStandardOpenOption.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DStandardOpenOption.java deleted file mode 100644 index 8635026c..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DStandardOpenOption.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - -package it.cavallium.warppi.deps; - -/** - * Defines the standard open options. - * - * @since 1.7 - */ - -public enum DStandardOpenOption { - /** - * Open for read access. - */ - READ, - - /** - * Open for write access. - */ - WRITE, - - /** - * If the file is opened for {@link #WRITE} access then bytes will be written - * to the end of the file rather than the beginning. - * - *

If the file is opened for write access by other programs, then it - * is file system specific if writing to the end of the file is atomic. - */ - APPEND, - - /** - * If the file already exists and it is opened for {@link #WRITE} - * access, then its length is truncated to 0. This option is ignored - * if the file is opened only for {@link #READ} access. - */ - TRUNCATE_EXISTING, - - /** - * Create a new file if it does not exist. - * This option is ignored if the {@link #CREATE_NEW} option is also set. - * The check for the existence of the file and the creation of the file - * if it does not exist is atomic with respect to other file system - * operations. - */ - CREATE, - - /** - * Create a new file, failing if the file already exists. - * The check for the existence of the file and the creation of the file - * if it does not exist is atomic with respect to other file system - * operations. - */ - CREATE_NEW, - - /** - * Delete on close. When this option is present then the implementation - * makes a best effort attempt to delete the file when closed - * by the appropriate {@code close} method. If the {@code close} method is - * not invoked then a best effort attempt is made to delete the - * file when the Java virtual machine terminates (either normally, as - * defined by the Java Language Specification, or where possible, abnormally). - * This option is primarily intended for use with work files that - * are used solely by a single instance of the Java virtual machine. This - * option is not recommended for use when opening files that are open - * concurrently by other entities. Many of the details as to when and how - * the file is deleted are implementation specific and therefore not - * specified. In particular, an implementation may be unable to guarantee - * that it deletes the expected file when replaced by an attacker while the - * file is open. Consequently, security sensitive applications should take - * care when using this option. - * - *

For security reasons, this option may imply the {@link - * LinkOption#NOFOLLOW_LINKS} option. In other words, if the option is present - * when opening an existing file that is a symbolic link then it may fail - * (by throwing {@link java.io.IOException}). - */ - DELETE_ON_CLOSE, - - /** - * Sparse file. When used with the {@link #CREATE_NEW} option then this - * option provides a hint that the new file will be sparse. The - * option is ignored when the file system does not support the creation of - * sparse files. - */ - SPARSE, - - /** - * Requires that every update to the file's content or metadata be written - * synchronously to the underlying storage device. - * - * @see Synchronized I/O file integrity - */ - SYNC, - - /** - * Requires that every update to the file's content be written - * synchronously to the underlying storage device. - * - * @see Synchronized I/O file integrity - */ - DSYNC; -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DSystem.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DSystem.java deleted file mode 100644 index dbdb0933..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DSystem.java +++ /dev/null @@ -1,7 +0,0 @@ -package it.cavallium.warppi.deps; - -public class DSystem { - public static final void exit(int code) { - System.err.println("====================PROGRAM END===================="); - } -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DURLClassLoader.java b/src/teavm-specific/java/it/cavallium/warppi/deps/DURLClassLoader.java deleted file mode 100644 index b6f444ee..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DURLClassLoader.java +++ /dev/null @@ -1,20 +0,0 @@ -package it.cavallium.warppi.deps; - -import java.net.URL; - -public class DURLClassLoader { - - public DURLClassLoader(URL[] urls) { - // TODO Auto-generated constructor stub - } - - public Class loadClass(String javaClassNameAndPath) { - return null; - } - - public void close() { - // TODO Auto-generated method stub - - } - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/jogamp/DJogamp.java b/src/teavm-specific/java/it/cavallium/warppi/deps/jogamp/DJogamp.java deleted file mode 100644 index a8f05605..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/jogamp/DJogamp.java +++ /dev/null @@ -1,568 +0,0 @@ -package it.cavallium.warppi.deps.jogamp; - -import it.cavallium.warppi.ClassUtils; -import it.cavallium.warppi.ClassUtils.Var; - -public class DJogamp { - - // - // Unicode: Non printable controls: [0x00 - 0x1F] - // - - /** - * This value, {@value}, is used to indicate that the keyCode is unknown. - */ - public static final short VK_UNDEFINED = (short) 0x0; - - static final short VK_FREE01 = (short) 0x01; - - /** Constant for the HOME function key. ASCII: Start Of Text. */ - public static final short VK_HOME = (short) 0x02; - - /** Constant for the END function key. ASCII: End Of Text. */ - public static final short VK_END = (short) 0x03; - - /** Constant for the END function key. ASCII: End Of Transmission. */ - public static final short VK_FINAL = (short) 0x04; - - /** Constant for the PRINT function key. ASCII: Enquiry. */ - public static final short VK_PRINTSCREEN = (short) 0x05; - - static final short VK_FREE06 = (short) 0x06; - static final short VK_FREE07 = (short) 0x07; - - /** Constant for the BACK SPACE key "\b", matching ASCII. Printable! */ - public static final short VK_BACK_SPACE = (short) 0x08; - - /** Constant for the HORIZ TAB key "\t", matching ASCII. Printable! */ - public static final short VK_TAB = (short) 0x09; - - /** LINE_FEED "\n", matching ASCII, n/a on keyboard. */ - static final short VK_FREE0A = (short) 0x0A; - - /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ - public static final short VK_PAGE_DOWN = (short) 0x0B; - - /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ - public static final short VK_CLEAR = (short) 0x0C; - - /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Printable! */ - public static final short VK_ENTER = (short) 0x0D; - - static final short VK_FREE0E = (short) 0x0E; - - /** Constant for the CTRL function key. ASCII: shift-in. */ - public static final short VK_SHIFT = (short) 0x0F; - - /** Constant for the PAGE UP function key. ASCII: Data Link Escape. */ - public static final short VK_PAGE_UP = (short) 0x10; - - /** Constant for the CTRL function key. ASCII: device-ctrl-one. */ - public static final short VK_CONTROL = (short) 0x11; - - /** Constant for the left ALT function key. ASCII: device-ctrl-two. */ - public static final short VK_ALT = (short) 0x12; - - /** Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII: device-ctrl-three. */ - public static final short VK_ALT_GRAPH = (short) 0x13; - - /** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */ - public static final short VK_CAPS_LOCK = (short) 0x14; - - static final short VK_FREE15 = (short) 0x15; - - /** Constant for the PAUSE function key. ASCII: sync-idle. */ - public static final short VK_PAUSE = (short) 0x16; - - /** scroll lock key. ASCII: End Of Transmission Block. */ - public static final short VK_SCROLL_LOCK = (short) 0x17; - - /** Constant for the CANCEL function key. ASCII: Cancel. */ - public static final short VK_CANCEL = (short) 0x18; - - static final short VK_FREE19 = (short) 0x19; - - /** Constant for the INSERT function key. ASCII: Substitute. */ - public static final short VK_INSERT = (short) 0x1A; - - /** Constant for the ESCAPE function key. ASCII: Escape. */ - public static final short VK_ESCAPE = (short) 0x1B; - - /** Constant for the Convert function key, Japanese "henkan". ASCII: File Separator. */ - public static final short VK_CONVERT = (short) 0x1C; - - /** Constant for the Don't Convert function key, Japanese "muhenkan". ASCII: Group Separator.*/ - public static final short VK_NONCONVERT = (short) 0x1D; - - /** Constant for the Accept or Commit function key, Japanese "kakutei". ASCII: Record Separator.*/ - public static final short VK_ACCEPT = (short) 0x1E; - - /** Constant for the Mode Change (?). ASCII: Unit Separator.*/ - public static final short VK_MODECHANGE = (short) 0x1F; - - // - // Unicode: Printable [0x20 - 0x7E] - // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys - // - - /** Constant for the SPACE function key. ASCII: SPACE. */ - public static final short VK_SPACE = (short) 0x20; - - /** Constant for the "!" key. */ - public static final short VK_EXCLAMATION_MARK = (short) 0x21; - - /** Constant for the """ key. */ - public static final short VK_QUOTEDBL = (short) 0x22; - - /** Constant for the "#" key. */ - public static final short VK_NUMBER_SIGN = (short) 0x23; - - /** Constant for the "$" key. */ - public static final short VK_DOLLAR = (short) 0x24; - - /** Constant for the "%" key. */ - public static final short VK_PERCENT = (short) 0x25; - - /** Constant for the "&" key. */ - public static final short VK_AMPERSAND = (short) 0x26; - - /** Constant for the "'" key. */ - public static final short VK_QUOTE = (short) 0x27; - - /** Constant for the "(" key. */ - public static final short VK_LEFT_PARENTHESIS = (short) 0x28; - - /** Constant for the ")" key. */ - public static final short VK_RIGHT_PARENTHESIS = (short) 0x29; - - /** Constant for the "*" key */ - public static final short VK_ASTERISK = (short) 0x2A; - - /** Constant for the "+" key. */ - public static final short VK_PLUS = (short) 0x2B; - - /** Constant for the comma key, "," */ - public static final short VK_COMMA = (short) 0x2C; - - /** Constant for the minus key, "-" */ - public static final short VK_MINUS = (short) 0x2D; - - /** Constant for the period key, "." */ - public static final short VK_PERIOD = (short) 0x2E; - - /** Constant for the forward slash key, "/" */ - public static final short VK_SLASH = (short) 0x2F; - - /** VK_0 thru VK_9 are the same as UTF16/ASCII '0' thru '9' [0x30 - 0x39] */ - public static final short VK_0 = (short) 0x30; - /** See {@link #VK_0}. */ - public static final short VK_1 = (short) 0x31; - /** See {@link #VK_0}. */ - public static final short VK_2 = (short) 0x32; - /** See {@link #VK_0}. */ - public static final short VK_3 = (short) 0x33; - /** See {@link #VK_0}. */ - public static final short VK_4 = (short) 0x34; - /** See {@link #VK_0}. */ - public static final short VK_5 = (short) 0x35; - /** See {@link #VK_0}. */ - public static final short VK_6 = (short) 0x36; - /** See {@link #VK_0}. */ - public static final short VK_7 = (short) 0x37; - /** See {@link #VK_0}. */ - public static final short VK_8 = (short) 0x38; - /** See {@link #VK_0}. */ - public static final short VK_9 = (short) 0x39; - - /** Constant for the ":" key. */ - public static final short VK_COLON = (short) 0x3A; - - /** Constant for the semicolon key, ";" */ - public static final short VK_SEMICOLON = (short) 0x3B; - - /** Constant for the equals key, "<" */ - public static final short VK_LESS = (short) 0x3C; - - /** Constant for the equals key, "=" */ - public static final short VK_EQUALS = (short) 0x3D; - - /** Constant for the equals key, ">" */ - public static final short VK_GREATER = (short) 0x3E; - - /** Constant for the equals key, "?" */ - public static final short VK_QUESTIONMARK = (short) 0x3F; - - /** Constant for the equals key, "@" */ - public static final short VK_AT = (short) 0x40; - - /** VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A) */ - public static final short VK_A = (short) 0x41; - /** See {@link #VK_A}. */ - public static final short VK_B = (short) 0x42; - /** See {@link #VK_A}. */ - public static final short VK_C = (short) 0x43; - /** See {@link #VK_A}. */ - public static final short VK_D = (short) 0x44; - /** See {@link #VK_A}. */ - public static final short VK_E = (short) 0x45; - /** See {@link #VK_A}. */ - public static final short VK_F = (short) 0x46; - /** See {@link #VK_A}. */ - public static final short VK_G = (short) 0x47; - /** See {@link #VK_A}. */ - public static final short VK_H = (short) 0x48; - /** See {@link #VK_A}. */ - public static final short VK_I = (short) 0x49; - /** See {@link #VK_A}. */ - public static final short VK_J = (short) 0x4A; - /** See {@link #VK_A}. */ - public static final short VK_K = (short) 0x4B; - /** See {@link #VK_A}. */ - public static final short VK_L = (short) 0x4C; - /** See {@link #VK_A}. */ - public static final short VK_M = (short) 0x4D; - /** See {@link #VK_A}. */ - public static final short VK_N = (short) 0x4E; - /** See {@link #VK_A}. */ - public static final short VK_O = (short) 0x4F; - /** See {@link #VK_A}. */ - public static final short VK_P = (short) 0x50; - /** See {@link #VK_A}. */ - public static final short VK_Q = (short) 0x51; - /** See {@link #VK_A}. */ - public static final short VK_R = (short) 0x52; - /** See {@link #VK_A}. */ - public static final short VK_S = (short) 0x53; - /** See {@link #VK_A}. */ - public static final short VK_T = (short) 0x54; - /** See {@link #VK_A}. */ - public static final short VK_U = (short) 0x55; - /** See {@link #VK_A}. */ - public static final short VK_V = (short) 0x56; - /** See {@link #VK_A}. */ - public static final short VK_W = (short) 0x57; - /** See {@link #VK_A}. */ - public static final short VK_X = (short) 0x58; - /** See {@link #VK_A}. */ - public static final short VK_Y = (short) 0x59; - /** See {@link #VK_A}. */ - public static final short VK_Z = (short) 0x5A; - - /** Constant for the open bracket key, "[" */ - public static final short VK_OPEN_BRACKET = (short) 0x5B; - - /**Constant for the back slash key, "\" */ - public static final short VK_BACK_SLASH = (short) 0x5C; - - /** Constant for the close bracket key, "]" */ - public static final short VK_CLOSE_BRACKET = (short) 0x5D; - - /** Constant for the "^" key. */ - public static final short VK_CIRCUMFLEX = (short) 0x5E; - - /** Constant for the "_" key */ - public static final short VK_UNDERSCORE = (short) 0x5F; - - /** Constant for the "`" key */ - public static final short VK_BACK_QUOTE = (short) 0x60; - - /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ - - /** - * Constant for the Fn function keys. - *

- * F1..F24, i.e. Fn, are mapped from on 0x60+n -> [0x61 .. 0x78]. - *

- *

- * Warning: The Fn function keys do collide with unicode characters small 'a' thru 'x'!
- * See Unicode Collision for details. - *

- */ - public static final short VK_F1 = (short) ( 0x60+ 1 ); - - /** Constant for the F2 function key. See {@link #VK_F1}. */ - public static final short VK_F2 = (short) ( 0x60+ 2 ); - - /** Constant for the F3 function key. See {@link #VK_F1}. */ - public static final short VK_F3 = (short) ( 0x60+ 3 ); - - /** Constant for the F4 function key. See {@link #VK_F1}. */ - public static final short VK_F4 = (short) ( 0x60+ 4 ); - - /** Constant for the F5 function key. See {@link #VK_F1}. */ - public static final short VK_F5 = (short) ( 0x60+ 5 ); - - /** Constant for the F6 function key. See {@link #VK_F1}. */ - public static final short VK_F6 = (short) ( 0x60+ 6 ); - - /** Constant for the F7 function key. See {@link #VK_F1}. */ - public static final short VK_F7 = (short) ( 0x60+ 7 ); - - /** Constant for the F8 function key. See {@link #VK_F1}. */ - public static final short VK_F8 = (short) ( 0x60+ 8 ); - - /** Constant for the F9 function key. See {@link #VK_F1}. */ - public static final short VK_F9 = (short) ( 0x60+ 9 ); - - /** Constant for the F11 function key. See {@link #VK_F1}. */ - public static final short VK_F10 = (short) ( 0x60+10 ); - - /** Constant for the F11 function key. See {@link #VK_F1}. */ - public static final short VK_F11 = (short) ( 0x60+11 ); - - /** Constant for the F12 function key. See {@link #VK_F1}.*/ - public static final short VK_F12 = (short) ( 0x60+12 ); - - /** Constant for the F13 function key. See {@link #VK_F1}. */ - public static final short VK_F13 = (short) ( 0x60+13 ); - - /** Constant for the F14 function key. See {@link #VK_F1}. */ - public static final short VK_F14 = (short) ( 0x60+14 ); - - /** Constant for the F15 function key. See {@link #VK_F1}. */ - public static final short VK_F15 = (short) ( 0x60+15 ); - - /** Constant for the F16 function key. See {@link #VK_F1}. */ - public static final short VK_F16 = (short) ( 0x60+16 ); - - /** Constant for the F17 function key. See {@link #VK_F1}. */ - public static final short VK_F17 = (short) ( 0x60+17 ); - - /** Constant for the F18 function key. See {@link #VK_F1}. */ - public static final short VK_F18 = (short) ( 0x60+18 ); - - /** Constant for the F19 function key. See {@link #VK_F1}. */ - public static final short VK_F19 = (short) ( 0x60+19 ); - - /** Constant for the F20 function key. See {@link #VK_F1}. */ - public static final short VK_F20 = (short) ( 0x60+20 ); - - /** Constant for the F21 function key. See {@link #VK_F1}. */ - public static final short VK_F21 = (short) ( 0x60+21 ); - - /** Constant for the F22 function key. See {@link #VK_F1}. */ - public static final short VK_F22 = (short) ( 0x60+22 ); - - /** Constant for the F23 function key. See {@link #VK_F1}. */ - public static final short VK_F23 = (short) ( 0x60+23 ); - - /** Constant for the F24 function key. See {@link #VK_F1}. */ - public static final short VK_F24 = (short) ( 0x60+24 ); - - - /** Constant for the "{" key */ - public static final short VK_LEFT_BRACE = (short) 0x7B; - /** Constant for the "|" key */ - public static final short VK_PIPE = (short) 0x7C; - /** Constant for the "}" key */ - public static final short VK_RIGHT_BRACE = (short) 0x7D; - - /** Constant for the "~" key, matching ASCII */ - public static final short VK_TILDE = (short) 0x7E; - - // - // Unicode: Non printable controls: [0x7F - 0x9F] - // - // Numpad keys [0x7F - 0x8E] are printable - // - - /** Numeric keypad decimal separator key. Non printable UTF control. */ - public static final short VK_SEPARATOR = (short) 0x7F; - - /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ - public static final short VK_NUMPAD0 = (short) 0x80; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD1 = (short) 0x81; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD2 = (short) 0x82; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD3 = (short) 0x83; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD4 = (short) 0x84; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD5 = (short) 0x85; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD6 = (short) 0x86; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD7 = (short) 0x87; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD8 = (short) 0x88; - /** See {@link #VK_NUMPAD0}. */ - public static final short VK_NUMPAD9 = (short) 0x89; - - /** Numeric keypad decimal separator key. Non printable UTF control. */ - public static final short VK_DECIMAL = (short) 0x8A; - - /** Numeric keypad add key. Non printable UTF control. */ - public static final short VK_ADD = (short) 0x8B; - - /** Numeric keypad subtract key. Non printable UTF control. */ - public static final short VK_SUBTRACT = (short) 0x8C; - - /** Numeric keypad multiply key. Non printable UTF control. */ - public static final short VK_MULTIPLY = (short) 0x8D; - - /** Numeric keypad divide key. Non printable UTF control. */ - public static final short VK_DIVIDE = (short) 0x8E; - - /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ - public static final short VK_DELETE = (short) 0x93; - - /** Numeric keypad num lock key. Non printable UTF control. */ - public static final short VK_NUM_LOCK = (short) 0x94; - - /** Constant for the cursor- or numerical-pad left arrow key. Non printable UTF control. */ - public static final short VK_LEFT = (short) 0x95; - - /** Constant for the cursor- or numerical-pad up arrow key. Non printable UTF control. */ - public static final short VK_UP = (short) 0x96; - - /** Constant for the cursor- or numerical-pad right arrow key. Non printable UTF control. */ - public static final short VK_RIGHT = (short) 0x97; - - /** Constant for the cursor- or numerical pad down arrow key. Non printable UTF control. */ - public static final short VK_DOWN = (short) 0x98; - - /** Constant for the Context Menu key. Non printable UTF control. */ - public static final short VK_CONTEXT_MENU = (short) 0x99; - - /** - * Constant for the MS "Windows" function key. - * It is used for both the left and right version of the key. - */ - public static final short VK_WINDOWS = (short) 0x9A; - - /** Constant for the Meta function key. */ - public static final short VK_META = (short) 0x9B; - - /** Constant for the Help function key. */ - public static final short VK_HELP = (short) 0x9C; - - /** Constant for the Compose function key. */ - public static final short VK_COMPOSE = (short) 0x9D; - - /** Constant for the Begin function key. */ - public static final short VK_BEGIN = (short) 0x9E; - - /** Constant for the Stop function key. */ - public static final short VK_STOP = (short) 0x9F; - - // - // Unicode: Printable [0x00A0 - 0xDFFF] - // - - /** Constant for the inverted exclamation mark key. */ - public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1; - - /** Constant for the Euro currency sign key. */ - public static final short VK_EURO_SIGN = (short) 0x20AC; - - // - // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) - // - - /* for Sun keyboards */ - public static final short VK_CUT = (short) 0xF879; - public static final short VK_COPY = (short) 0xF87A; - public static final short VK_PASTE = (short) 0xF87B; - public static final short VK_UNDO = (short) 0xF87C; - public static final short VK_AGAIN = (short) 0xF87D; - public static final short VK_FIND = (short) 0xF87E; - public static final short VK_PROPS = (short) 0xF87F; - - /* for input method support on Asian Keyboards */ - - /** - * Constant for the input method on/off key. - */ - /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ - public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890; - - /** - * Constant for the Code Input function key. - */ - /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ - public static final short VK_CODE_INPUT = (short) 0xF891; - - /** - * Constant for the Roman Characters function key. - */ - /* Japanese PC 106 keyboard: roumaji */ - public static final short VK_ROMAN_CHARACTERS = (short) 0xF892; - - /** - * Constant for the All Candidates function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ - public static final short VK_ALL_CANDIDATES = (short) 0xF893; - - /** - * Constant for the Previous Candidate function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ - public static final short VK_PREVIOUS_CANDIDATE = (short) 0xF894; - - /** - * Constant for the Alphanumeric function key. - */ - /* Japanese PC 106 keyboard: eisuu */ - public static final short VK_ALPHANUMERIC = (short) 0xF895; - - /** - * Constant for the Katakana function key. - */ - /* Japanese PC 106 keyboard: katakana */ - public static final short VK_KATAKANA = (short) 0xF896; - - /** - * Constant for the Hiragana function key. - */ - /* Japanese PC 106 keyboard: hiragana */ - public static final short VK_HIRAGANA = (short) 0xF897; - - /** - * Constant for the Full-Width Characters function key. - */ - /* Japanese PC 106 keyboard: zenkaku */ - public static final short VK_FULL_WIDTH = (short) 0xF898; - - /** - * Constant for the Half-Width Characters function key. - */ - /* Japanese PC 106 keyboard: hankaku */ - public static final short VK_HALF_WIDTH = (short) 0xF89A; - - /** - * Constant for the Japanese-Katakana function key. - * This key switches to a Japanese input method and selects its Katakana input mode. - */ - /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ - public static final short VK_JAPANESE_KATAKANA = (short) 0xF89B; - - /** - * Constant for the Japanese-Hiragana function key. - * This key switches to a Japanese input method and selects its Hiragana input mode. - */ - /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_HIRAGANA = (short) 0xF89C; - - /** - * Constant for the Japanese-Roman function key. - * This key switches to a Japanese input method and selects its Roman-Direct input mode. - */ - /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_ROMAN = (short) 0xF89D; - - /** - * Constant for the locking Kana function key. - * This key locks the keyboard into a Kana layout. - */ - /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ - public static final short VK_KANA_LOCK = (short) 0xF89F; - - /** - * Constant for Keyboard became invisible, e.g. Android's soft keyboard Back button hit while keyboard is visible. - */ - public static final short VK_KEYBOARD_INVISIBLE = (short) 0xF8FF; - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DFiles.java b/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DFiles.java deleted file mode 100644 index 7150c8d8..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DFiles.java +++ /dev/null @@ -1,32 +0,0 @@ -package it.cavallium.warppi.deps.nio; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.List; - -import org.apache.commons.io.FileUtils; - -import it.cavallium.warppi.deps.nio.DPaths.DPathImpl; - -public class DFiles { - - public static List readAllLines(DPath osRelease) throws IOException { - return FileUtils.readLines(osRelease.toFile(), Charset.defaultCharset()); - } - - public static boolean exists(DPath f) { - return f.toFile().exists(); - } - - public static DPath createTempFile(String prefix, String suffix) throws IOException { - return new DPathImpl(File.createTempFile(prefix, suffix)); - } - - public static void deleteIfExists(DPath f) throws IOException { - if (f.toFile().exists()) { - f.toFile().delete(); - } - } - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DPath.java b/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DPath.java deleted file mode 100644 index 685e8509..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DPath.java +++ /dev/null @@ -1,12 +0,0 @@ -package it.cavallium.warppi.deps.nio; - -import java.io.File; -import java.nio.file.Path; - -public interface DPath { - - DPath toAbsolutePath(); - - File toFile(); - -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DPaths.java b/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DPaths.java deleted file mode 100644 index 15197f2b..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/nio/DPaths.java +++ /dev/null @@ -1,32 +0,0 @@ -package it.cavallium.warppi.deps.nio; - -import java.io.File; - -public class DPaths { - public static DPath get(String first, String... more) { - return new DPathImpl("/etc", "os-release"); - } - - protected static class DPathImpl implements DPath { - protected final File realFile; - - private DPathImpl(String main, String... more) { - realFile = new File(String.join(File.separator, main)); - } - - DPathImpl(File f) { - realFile = f; - } - - @Override - public File toFile() { - return realFile; - } - - @Override - public DPath toAbsolutePath() { - return new DPathImpl(realFile.getAbsoluteFile()); - } - - } -} diff --git a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/InputEvent.java b/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/InputEvent.java deleted file mode 100644 index e28d2cb4..00000000 --- a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/InputEvent.java +++ /dev/null @@ -1,10 +0,0 @@ -package it.cavallium.warppi.gui.graphicengine.html; - -import org.teavm.jso.JSProperty; -import org.teavm.jso.dom.events.Event; - -public interface InputEvent extends Event { - - @JSProperty - String getValue(); -} diff --git a/teavm/.classpath b/teavm/.classpath new file mode 100644 index 00000000..e1938397 --- /dev/null +++ b/teavm/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/teavm/.gitignore b/teavm/.gitignore new file mode 100644 index 00000000..b83d2226 --- /dev/null +++ b/teavm/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/teavm/.project b/teavm/.project new file mode 100644 index 00000000..af36fefb --- /dev/null +++ b/teavm/.project @@ -0,0 +1,23 @@ + + + warppi-teavm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/teavm/.settings/org.eclipse.core.resources.prefs b/teavm/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..654c1750 --- /dev/null +++ b/teavm/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding/=UTF-8 diff --git a/teavm/.settings/org.eclipse.jdt.core.prefs b/teavm/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..f494d1de --- /dev/null +++ b/teavm/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/teavm/.settings/org.eclipse.m2e.core.prefs b/teavm/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..14b697b7 --- /dev/null +++ b/teavm/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/teavm/pom.xml b/teavm/pom.xml new file mode 100644 index 00000000..9df40a65 --- /dev/null +++ b/teavm/pom.xml @@ -0,0 +1,113 @@ + + 4.0.0 + + + it.cavallium + warppi + ${project.version} + + warppi-teavm + jar + + WarpPI Calculator TeaVM + WarpPI Calculator teavm project + + + it.cavallium + warppi-core + ${project.version} + + + it.cavallium + warppi-rules + ${project.version} + + + org.teavm + teavm-classlib + 0.6.0-dev-559 + + + + + teavm-dev + https://dl.bintray.com/konsoletyper/teavm + + true + + default + + + + + 1_teavm-dev + https://dl.bintray.com/konsoletyper/teavm + + true + + default + + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.5 + + + org.teavm:* + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + UTF-8 + + + + org.teavm + teavm-maven-plugin + 0.6.0-dev-559 + + + + compile + + process-classes + + it.cavallium.warppi.teavm.TeaVMBoot + true + true + true + + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + UTF-8 + + + + + + diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/BufferedStreamFeeder.java b/teavm/src/main/java/ar/com/hjg/pngj/BufferedStreamFeeder.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/BufferedStreamFeeder.java rename to teavm/src/main/java/ar/com/hjg/pngj/BufferedStreamFeeder.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ChunkReader.java b/teavm/src/main/java/ar/com/hjg/pngj/ChunkReader.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ChunkReader.java rename to teavm/src/main/java/ar/com/hjg/pngj/ChunkReader.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqBuffering.java b/teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqBuffering.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqBuffering.java rename to teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqBuffering.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqReader.java b/teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqReader.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqReader.java rename to teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqReader.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java b/teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java rename to teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqReaderPng.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqSkipping.java b/teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqSkipping.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ChunkSeqSkipping.java rename to teavm/src/main/java/ar/com/hjg/pngj/ChunkSeqSkipping.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/DeflatedChunkReader.java b/teavm/src/main/java/ar/com/hjg/pngj/DeflatedChunkReader.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/DeflatedChunkReader.java rename to teavm/src/main/java/ar/com/hjg/pngj/DeflatedChunkReader.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/DeflatedChunksSet.java b/teavm/src/main/java/ar/com/hjg/pngj/DeflatedChunksSet.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/DeflatedChunksSet.java rename to teavm/src/main/java/ar/com/hjg/pngj/DeflatedChunksSet.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/Deinterlacer.java b/teavm/src/main/java/ar/com/hjg/pngj/Deinterlacer.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/Deinterlacer.java rename to teavm/src/main/java/ar/com/hjg/pngj/Deinterlacer.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/FilterType.java b/teavm/src/main/java/ar/com/hjg/pngj/FilterType.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/FilterType.java rename to teavm/src/main/java/ar/com/hjg/pngj/FilterType.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IBytesConsumer.java b/teavm/src/main/java/ar/com/hjg/pngj/IBytesConsumer.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IBytesConsumer.java rename to teavm/src/main/java/ar/com/hjg/pngj/IBytesConsumer.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IChunkFactory.java b/teavm/src/main/java/ar/com/hjg/pngj/IChunkFactory.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IChunkFactory.java rename to teavm/src/main/java/ar/com/hjg/pngj/IChunkFactory.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IDatChunkWriter.java b/teavm/src/main/java/ar/com/hjg/pngj/IDatChunkWriter.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IDatChunkWriter.java rename to teavm/src/main/java/ar/com/hjg/pngj/IDatChunkWriter.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IImageLine.java b/teavm/src/main/java/ar/com/hjg/pngj/IImageLine.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IImageLine.java rename to teavm/src/main/java/ar/com/hjg/pngj/IImageLine.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IImageLineArray.java b/teavm/src/main/java/ar/com/hjg/pngj/IImageLineArray.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IImageLineArray.java rename to teavm/src/main/java/ar/com/hjg/pngj/IImageLineArray.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IImageLineFactory.java b/teavm/src/main/java/ar/com/hjg/pngj/IImageLineFactory.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IImageLineFactory.java rename to teavm/src/main/java/ar/com/hjg/pngj/IImageLineFactory.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IImageLineSet.java b/teavm/src/main/java/ar/com/hjg/pngj/IImageLineSet.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IImageLineSet.java rename to teavm/src/main/java/ar/com/hjg/pngj/IImageLineSet.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IImageLineSetFactory.java b/teavm/src/main/java/ar/com/hjg/pngj/IImageLineSetFactory.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IImageLineSetFactory.java rename to teavm/src/main/java/ar/com/hjg/pngj/IImageLineSetFactory.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IPngWriterFactory.java b/teavm/src/main/java/ar/com/hjg/pngj/IPngWriterFactory.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IPngWriterFactory.java rename to teavm/src/main/java/ar/com/hjg/pngj/IPngWriterFactory.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/IdatSet.java b/teavm/src/main/java/ar/com/hjg/pngj/IdatSet.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/IdatSet.java rename to teavm/src/main/java/ar/com/hjg/pngj/IdatSet.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ImageInfo.java b/teavm/src/main/java/ar/com/hjg/pngj/ImageInfo.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ImageInfo.java rename to teavm/src/main/java/ar/com/hjg/pngj/ImageInfo.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ImageLineByte.java b/teavm/src/main/java/ar/com/hjg/pngj/ImageLineByte.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ImageLineByte.java rename to teavm/src/main/java/ar/com/hjg/pngj/ImageLineByte.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ImageLineHelper.java b/teavm/src/main/java/ar/com/hjg/pngj/ImageLineHelper.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ImageLineHelper.java rename to teavm/src/main/java/ar/com/hjg/pngj/ImageLineHelper.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ImageLineInt.java b/teavm/src/main/java/ar/com/hjg/pngj/ImageLineInt.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ImageLineInt.java rename to teavm/src/main/java/ar/com/hjg/pngj/ImageLineInt.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java b/teavm/src/main/java/ar/com/hjg/pngj/ImageLineSetDefault.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/ImageLineSetDefault.java rename to teavm/src/main/java/ar/com/hjg/pngj/ImageLineSetDefault.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngHelperInternal.java b/teavm/src/main/java/ar/com/hjg/pngj/PngHelperInternal.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngHelperInternal.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngHelperInternal.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngHelperInternal2.java b/teavm/src/main/java/ar/com/hjg/pngj/PngHelperInternal2.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngHelperInternal2.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngHelperInternal2.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngReader.java b/teavm/src/main/java/ar/com/hjg/pngj/PngReader.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngReader.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngReader.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngReaderApng.java b/teavm/src/main/java/ar/com/hjg/pngj/PngReaderApng.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngReaderApng.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngReaderApng.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngReaderByte.java b/teavm/src/main/java/ar/com/hjg/pngj/PngReaderByte.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngReaderByte.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngReaderByte.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngReaderFilter.java b/teavm/src/main/java/ar/com/hjg/pngj/PngReaderFilter.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngReaderFilter.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngReaderFilter.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngReaderInt.java b/teavm/src/main/java/ar/com/hjg/pngj/PngReaderInt.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngReaderInt.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngReaderInt.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngWriter.java b/teavm/src/main/java/ar/com/hjg/pngj/PngWriter.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngWriter.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngWriter.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngWriterHc.java b/teavm/src/main/java/ar/com/hjg/pngj/PngWriterHc.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngWriterHc.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngWriterHc.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngjBadCrcException.java b/teavm/src/main/java/ar/com/hjg/pngj/PngjBadCrcException.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngjBadCrcException.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngjBadCrcException.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngjException.java b/teavm/src/main/java/ar/com/hjg/pngj/PngjException.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngjException.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngjException.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngjExceptionInternal.java b/teavm/src/main/java/ar/com/hjg/pngj/PngjExceptionInternal.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngjExceptionInternal.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngjExceptionInternal.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngjInputException.java b/teavm/src/main/java/ar/com/hjg/pngj/PngjInputException.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngjInputException.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngjInputException.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngjOutputException.java b/teavm/src/main/java/ar/com/hjg/pngj/PngjOutputException.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngjOutputException.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngjOutputException.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/PngjUnsupportedException.java b/teavm/src/main/java/ar/com/hjg/pngj/PngjUnsupportedException.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/PngjUnsupportedException.java rename to teavm/src/main/java/ar/com/hjg/pngj/PngjUnsupportedException.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/RowInfo.java b/teavm/src/main/java/ar/com/hjg/pngj/RowInfo.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/RowInfo.java rename to teavm/src/main/java/ar/com/hjg/pngj/RowInfo.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkCopyBehaviour.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkFactory.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkFactory.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkFactory.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkFactory.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkHelper.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkHelper.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkHelper.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkHelper.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkLoadBehaviour.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkPredicate.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkRaw.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkRaw.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunkRaw.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunkRaw.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunksList.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunksList.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunksList.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunksList.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/ChunksListForWrite.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngBadCharsetException.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunk.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunk.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunk.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkACTL.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkBKGD.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkCHRM.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFCTL.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkFDAT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkGAMA.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkHIST.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkICCP.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIDAT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIEND.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkIHDR.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkITXT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkMultiple.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkOFFS.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPHYS.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkPLTE.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSBIT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSPLT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSRGB.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSTER.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkSingle.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTEXT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTIME.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTRNS.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkTextVar.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkUNKNOWN.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngChunkZTXT.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngMetadata.java b/teavm/src/main/java/ar/com/hjg/pngj/chunks/PngMetadata.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/PngMetadata.java rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/PngMetadata.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/chunks/package.html b/teavm/src/main/java/ar/com/hjg/pngj/chunks/package.html similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/chunks/package.html rename to teavm/src/main/java/ar/com/hjg/pngj/chunks/package.html diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/package.html b/teavm/src/main/java/ar/com/hjg/pngj/package.html similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/package.html rename to teavm/src/main/java/ar/com/hjg/pngj/package.html diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/CompressorStream.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/CompressorStream.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/CompressorStream.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/CompressorStream.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamDeflater.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/CompressorStreamLz4.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorHjg.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/DeflaterEstimatorLz4.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/FiltersPerformance.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/PixelsWriter.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriter.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/PixelsWriter.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriter.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterDefault.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java b/teavm/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/PixelsWriterMultiple.java diff --git a/src/teavm-specific/java/ar/com/hjg/pngj/pixels/package.html b/teavm/src/main/java/ar/com/hjg/pngj/pixels/package.html similarity index 100% rename from src/teavm-specific/java/ar/com/hjg/pngj/pixels/package.html rename to teavm/src/main/java/ar/com/hjg/pngj/pixels/package.html diff --git a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java similarity index 93% rename from src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java rename to teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java index a668ae00..adb9c583 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java +++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlEngine.java @@ -1,300 +1,296 @@ -package it.cavallium.warppi.gui.graphicengine.html; - -import java.io.IOException; -import java.util.concurrent.Semaphore; - -import org.teavm.jso.JSBody; -import org.teavm.jso.JSObject; -import org.teavm.jso.browser.Window; -import org.teavm.jso.canvas.CanvasGradient; -import org.teavm.jso.canvas.CanvasRenderingContext2D; -import org.teavm.jso.dom.events.Event; -import org.teavm.jso.dom.events.EventListener; -import org.teavm.jso.dom.events.EventTarget; -import org.teavm.jso.dom.events.KeyboardEvent; -import org.teavm.jso.dom.html.HTMLButtonElement; -import org.teavm.jso.dom.html.HTMLCanvasElement; -import org.teavm.jso.dom.html.HTMLDocument; -import org.teavm.jso.dom.html.HTMLElement; -import org.teavm.jso.dom.html.HTMLInputElement; -import org.teavm.jso.dom.xml.NodeList; -import org.teavm.jso.json.JSON; - -import it.cavallium.warppi.PlatformUtils; -import it.cavallium.warppi.Utils; -import it.cavallium.warppi.deps.DSemaphore; -import it.cavallium.warppi.deps.StorageUtils; -import it.cavallium.warppi.device.Keyboard; -import it.cavallium.warppi.flow.BehaviorSubject; -import it.cavallium.warppi.flow.Observable; -import it.cavallium.warppi.gui.graphicengine.BinaryFont; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.Renderer; -import it.cavallium.warppi.gui.graphicengine.RenderingLoop; -import it.cavallium.warppi.gui.graphicengine.Skin; -import it.cavallium.warppi.gui.graphicengine.cpu.CPUFont; -import it.cavallium.warppi.gui.graphicengine.cpu.CPUSkin; - -public class HtmlEngine implements GraphicEngine { - - private boolean initialized; - public DSemaphore exitSemaphore = new DSemaphore(0); - private static final HTMLDocument document = Window.current().getDocument(); - private HTMLCanvasElement canvas; - private CanvasRenderingContext2D g; - private RenderingLoop renderingLoop; - private HtmlRenderer renderer; - private int width = -1, height = -1; - private final int frameTime = (int) (1000d/10d); - private final BehaviorSubject onResize = BehaviorSubject.create(); - - @Override - public int[] getSize() { - return new int[] { getWidth(), getHeight() }; - } - - @Override - public boolean isInitialized() { - return initialized; - } - - @Override - public void setTitle(String title) { - HtmlEngine.setHTMLTitle(title); - } - - @JSBody(params = {"wndTitle"}, script = "document.title = wndTitle") - private static native void setHTMLTitle(String wndTitle); - - @Override - public void setResizable(boolean r) {} - - @Override - public void setDisplayMode(int ww, int wh) { - canvas.setWidth(ww); - width = ww; - canvas.setHeight(wh); - height = wh; - } - - private String previousValue=""; - - @Override - public void create(Runnable onInitialized) { - canvas = (HTMLCanvasElement) document.createElement("canvas"); - g = (CanvasRenderingContext2D ) canvas.getContext("2d"); - HTMLInputElement keyInput = (HTMLInputElement) document.createElement("input"); - keyInput.setType("text"); - keyInput.getStyle().setProperty("opacity", "0.1"); - setDisplayMode(480, 320); - document.getElementById("container").appendChild(canvas); - document.getBody().appendChild(keyInput); - keyInput.setTabIndex(0); - keyInput.addEventListener("keydown", (KeyboardEvent evt) -> { - evt.preventDefault(); - new Thread(() -> { - previousValue = keyInput.getValue(); - Keyboard.debugKeyPressed(evt.getKeyCode()); - System.out.println(evt.getKeyCode()); - System.out.println(""+(int) evt.getKey().charAt(0)); - }).start(); - }); - keyInput.addEventListener("input", (Event evt) -> { - evt.preventDefault(); - final String previousValue = this.previousValue; - final String newValue = keyInput.getValue(); - final int prevLen = previousValue.length(); - final int newLen = newValue.length(); - - new Thread(() -> { - if (newLen == prevLen) { - - } else if (newLen - prevLen == 1) { - Keyboard.debugKeyPressed((int) newValue.toUpperCase().charAt(newLen-1)); - } else if (newLen - prevLen > 1) { - for (int i = 0; i < newLen - prevLen; i++) { - Keyboard.debugKeyPressed((int) newValue.toUpperCase().charAt(prevLen + i)); - } - } else if (newLen - prevLen < 1) { - for (int i = 0; i < prevLen - newLen; i++) { - Keyboard.debugKeyPressed(8); - } - } - }).start(); - }); - canvas.addEventListener("click", (Event evt) -> { - keyInput.focus(); - }); - document.addEventListener("DOMContentLoaded", (Event e) -> { - keyInput.focus(); - }); - NodeList buttons = document.getBody().getElementsByTagName("button"); - for (int i = 0; i < buttons.getLength(); i++) { - if (buttons.item(i).hasAttribute("keycode")) { - buttons.item(i).addEventListener("click", (Event evt) -> { - evt.preventDefault(); - EventTarget target = evt.getCurrentTarget(); - HTMLButtonElement button = target.cast(); - new Thread(() -> { - try { - if (button.hasAttribute("keycode") && button.getAttribute("keycode").contains(",")) { - String code = button.getAttribute("keycode"); - String[] coordinates = code.split(",", 2); - boolean removeshift = Keyboard.shift && Integer.parseInt(coordinates[0]) != 0 && Integer.parseInt(coordinates[1]) != 0; - boolean removealpha = Keyboard.alpha && Integer.parseInt(coordinates[0]) != 0 && Integer.parseInt(coordinates[1]) != 1; - Keyboard.keyPressedRaw(Integer.parseInt(coordinates[0]), Integer.parseInt(coordinates[1])); - if (removeshift) { - Keyboard.keyPressedRaw(0,0); - } - if (removealpha) { - Keyboard.keyPressedRaw(0,1); - } - Thread.sleep(100); - Keyboard.keyReleasedRaw(Integer.parseInt(coordinates[0]), Integer.parseInt(coordinates[1])); - if (removeshift) { - Keyboard.keyReleasedRaw(0,0); - } - if (removealpha) { - Keyboard.keyReleasedRaw(0,1); - } - } else { - if (Keyboard.alpha && !Keyboard.shift) { - if (button.hasAttribute("keycodea")) { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodea"))); - } else { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); - } - } else if (!Keyboard.alpha && Keyboard.shift) { - if (button.hasAttribute("keycodes")) { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodes"))); - } else { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); - } - } else if (Keyboard.alpha && Keyboard.shift) { - if (button.hasAttribute("keycodesa")) { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodesa"))); - } else { - if (button.hasAttribute("keycodes")) { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodes"))); - } else { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); - } - } - } else { - Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - }).start(); - }); - } - } - renderer = new HtmlRenderer(this, g); - initialized = true; - if (onInitialized != null) { - onInitialized.run(); - } - } - - @Override - public int getWidth() { - if (width == -1) { - width = canvas.getWidth(); - } - return width; - } - - @Override - public int getHeight() { - if (height == -1) { - height = canvas.getHeight(); - } - return height; - } - - @Override - public void destroy() { - document.getBody().removeChild(canvas); - initialized = false; - exitSemaphore.release(); - } - - @Override - public void start(RenderingLoop d) { - renderingLoop = d; - final Thread th = new Thread(() -> { - try { - double extratime = 0; - while (initialized) { - final long start = System.currentTimeMillis(); - repaint(); - final long end = System.currentTimeMillis(); - final double delta = (end - start) / 1000d; - final int deltaInt = (int) Math.floor(delta); - final int extraTimeInt = (int) Math.floor(extratime); - if (extraTimeInt + deltaInt < frameTime) { - Thread.sleep(frameTime - (extraTimeInt + deltaInt)); - extratime = 0; - } else { - extratime += delta - frameTime; - } - } - } catch (final InterruptedException e) { - e.printStackTrace(); - } - }); - PlatformUtils.setThreadName(th, "Canvas rendering thread"); - PlatformUtils.setDaemon(th); - th.start(); - } - - @Override - public void repaint() { - renderingLoop.refresh(); - } - - @Override - public HtmlRenderer getRenderer() { - return renderer; - } - - @Override - public HtmlFont loadFont(String fontName) throws IOException { - return new HtmlFont(fontName); - } - - @Override - public HtmlFont loadFont(String path, String fontName) throws IOException { - return new HtmlFont(fontName); - } - - @Override - public HtmlSkin loadSkin(String file) throws IOException { - return new HtmlSkin(file); - } - - @Override - public void waitForExit() { - try { - exitSemaphore.acquire(); - } catch (final InterruptedException e) {} - } - - @Override - public boolean isSupported() { - return PlatformUtils.isJavascript; - } - - @Override - public boolean doesRefreshPauses() { - return true; - } - - @Override - public Observable onResize() { - return onResize; - } - -} +package it.cavallium.warppi.gui.graphicengine.html; + +import java.io.IOException; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; +import org.teavm.jso.browser.Window; +import org.teavm.jso.canvas.CanvasGradient; +import org.teavm.jso.canvas.CanvasRenderingContext2D; +import org.teavm.jso.dom.events.Event; +import org.teavm.jso.dom.events.EventListener; +import org.teavm.jso.dom.events.EventTarget; +import org.teavm.jso.dom.events.KeyboardEvent; +import org.teavm.jso.dom.html.HTMLButtonElement; +import org.teavm.jso.dom.html.HTMLCanvasElement; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLElement; +import org.teavm.jso.dom.html.HTMLInputElement; +import org.teavm.jso.dom.xml.NodeList; +import org.teavm.jso.json.JSON; + +import it.cavallium.warppi.Engine; +import it.cavallium.warppi.Utils; +import it.cavallium.warppi.deps.Platform.Semaphore; +import it.cavallium.warppi.device.Keyboard; +import it.cavallium.warppi.flow.BehaviorSubject; +import it.cavallium.warppi.flow.Observable; +import it.cavallium.warppi.gui.graphicengine.BinaryFont; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.Renderer; +import it.cavallium.warppi.gui.graphicengine.RenderingLoop; +import it.cavallium.warppi.gui.graphicengine.Skin; + +public class HtmlEngine implements GraphicEngine { + + private boolean initialized; + public Semaphore exitSemaphore = Engine.getPlatform().newSemaphore(0); + private static final HTMLDocument document = Window.current().getDocument(); + private HTMLCanvasElement canvas; + private CanvasRenderingContext2D g; + private RenderingLoop renderingLoop; + private HtmlRenderer renderer; + private int width = -1, height = -1; + private final int frameTime = (int) (1000d/10d); + private final BehaviorSubject onResize = BehaviorSubject.create(); + + @Override + public int[] getSize() { + return new int[] { getWidth(), getHeight() }; + } + + @Override + public boolean isInitialized() { + return initialized; + } + + @Override + public void setTitle(String title) { + HtmlEngine.setHTMLTitle(title); + } + + @JSBody(params = {"wndTitle"}, script = "document.title = wndTitle") + private static native void setHTMLTitle(String wndTitle); + + @Override + public void setResizable(boolean r) {} + + @Override + public void setDisplayMode(int ww, int wh) { + canvas.setWidth(ww); + width = ww; + canvas.setHeight(wh); + height = wh; + } + + private String previousValue=""; + + @Override + public void create(Runnable onInitialized) { + canvas = (HTMLCanvasElement) document.createElement("canvas"); + g = (CanvasRenderingContext2D ) canvas.getContext("2d"); + HTMLInputElement keyInput = (HTMLInputElement) document.createElement("input"); + keyInput.setType("text"); + keyInput.getStyle().setProperty("opacity", "0.1"); + setDisplayMode(480, 320); + document.getElementById("container").appendChild(canvas); + document.getBody().appendChild(keyInput); + keyInput.setTabIndex(0); + keyInput.addEventListener("keydown", (KeyboardEvent evt) -> { + evt.preventDefault(); + new Thread(() -> { + previousValue = keyInput.getValue(); + Keyboard.debugKeyPressed(evt.getKeyCode()); + System.out.println(evt.getKeyCode()); + System.out.println(""+(int) evt.getKey().charAt(0)); + }).start(); + }); + keyInput.addEventListener("input", (Event evt) -> { + evt.preventDefault(); + final String previousValue = this.previousValue; + final String newValue = keyInput.getValue(); + final int prevLen = previousValue.length(); + final int newLen = newValue.length(); + + new Thread(() -> { + if (newLen == prevLen) { + + } else if (newLen - prevLen == 1) { + Keyboard.debugKeyPressed((int) newValue.toUpperCase().charAt(newLen-1)); + } else if (newLen - prevLen > 1) { + for (int i = 0; i < newLen - prevLen; i++) { + Keyboard.debugKeyPressed((int) newValue.toUpperCase().charAt(prevLen + i)); + } + } else if (newLen - prevLen < 1) { + for (int i = 0; i < prevLen - newLen; i++) { + Keyboard.debugKeyPressed(8); + } + } + }).start(); + }); + canvas.addEventListener("click", (Event evt) -> { + keyInput.focus(); + }); + document.addEventListener("DOMContentLoaded", (Event e) -> { + keyInput.focus(); + }); + NodeList buttons = document.getBody().getElementsByTagName("button"); + for (int i = 0; i < buttons.getLength(); i++) { + if (buttons.item(i).hasAttribute("keycode")) { + buttons.item(i).addEventListener("click", (Event evt) -> { + evt.preventDefault(); + EventTarget target = evt.getCurrentTarget(); + HTMLButtonElement button = target.cast(); + new Thread(() -> { + try { + if (button.hasAttribute("keycode") && button.getAttribute("keycode").contains(",")) { + String code = button.getAttribute("keycode"); + String[] coordinates = code.split(",", 2); + boolean removeshift = Keyboard.shift && Integer.parseInt(coordinates[0]) != 0 && Integer.parseInt(coordinates[1]) != 0; + boolean removealpha = Keyboard.alpha && Integer.parseInt(coordinates[0]) != 0 && Integer.parseInt(coordinates[1]) != 1; + Keyboard.keyPressedRaw(Integer.parseInt(coordinates[0]), Integer.parseInt(coordinates[1])); + if (removeshift) { + Keyboard.keyPressedRaw(0,0); + } + if (removealpha) { + Keyboard.keyPressedRaw(0,1); + } + Thread.sleep(100); + Keyboard.keyReleasedRaw(Integer.parseInt(coordinates[0]), Integer.parseInt(coordinates[1])); + if (removeshift) { + Keyboard.keyReleasedRaw(0,0); + } + if (removealpha) { + Keyboard.keyReleasedRaw(0,1); + } + } else { + if (Keyboard.alpha && !Keyboard.shift) { + if (button.hasAttribute("keycodea")) { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodea"))); + } else { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); + } + } else if (!Keyboard.alpha && Keyboard.shift) { + if (button.hasAttribute("keycodes")) { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodes"))); + } else { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); + } + } else if (Keyboard.alpha && Keyboard.shift) { + if (button.hasAttribute("keycodesa")) { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodesa"))); + } else { + if (button.hasAttribute("keycodes")) { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycodes"))); + } else { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); + } + } + } else { + Keyboard.debugKeyPressed(Integer.parseInt(button.getAttribute("keycode"))); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + }).start(); + }); + } + } + renderer = new HtmlRenderer(this, g); + initialized = true; + if (onInitialized != null) { + onInitialized.run(); + } + } + + @Override + public int getWidth() { + if (width == -1) { + width = canvas.getWidth(); + } + return width; + } + + @Override + public int getHeight() { + if (height == -1) { + height = canvas.getHeight(); + } + return height; + } + + @Override + public void destroy() { + document.getBody().removeChild(canvas); + initialized = false; + exitSemaphore.release(); + } + + @Override + public void start(RenderingLoop d) { + renderingLoop = d; + final Thread th = new Thread(() -> { + try { + double extratime = 0; + while (initialized) { + final long start = System.currentTimeMillis(); + repaint(); + final long end = System.currentTimeMillis(); + final double delta = (end - start) / 1000d; + final int deltaInt = (int) Math.floor(delta); + final int extraTimeInt = (int) Math.floor(extratime); + if (extraTimeInt + deltaInt < frameTime) { + Thread.sleep(frameTime - (extraTimeInt + deltaInt)); + extratime = 0; + } else { + extratime += delta - frameTime; + } + } + } catch (final InterruptedException e) { + e.printStackTrace(); + } + }); + Engine.getPlatform().setThreadName(th, "Canvas rendering thread"); + Engine.getPlatform().setThreadDaemon(th); + th.start(); + } + + @Override + public void repaint() { + renderingLoop.refresh(); + } + + @Override + public HtmlRenderer getRenderer() { + return renderer; + } + + @Override + public HtmlFont loadFont(String fontName) throws IOException { + return new HtmlFont(fontName); + } + + @Override + public HtmlFont loadFont(String path, String fontName) throws IOException { + return new HtmlFont(fontName); + } + + @Override + public HtmlSkin loadSkin(String file) throws IOException { + return new HtmlSkin(file); + } + + @Override + public void waitForExit() { + try { + exitSemaphore.acquire(); + } catch (final InterruptedException e) {} + } + + @Override + public boolean isSupported() { + return Engine.getPlatform().isJavascript(); + } + + @Override + public boolean doesRefreshPauses() { + return true; + } + + @Override + public Observable onResize() { + return onResize; + } + +} \ No newline at end of file diff --git a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java similarity index 92% rename from src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java rename to teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java index 57419beb..e7645b69 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java +++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlFont.java @@ -1,69 +1,69 @@ -package it.cavallium.warppi.gui.graphicengine.html; - -import java.io.IOException; - -import org.teavm.jso.browser.Window; -import org.teavm.jso.canvas.CanvasRenderingContext2D; -import org.teavm.jso.dom.html.HTMLCanvasElement; -import org.teavm.jso.dom.html.HTMLDocument; -import org.teavm.jso.dom.html.HTMLImageElement; -import org.teavm.jso.typedarrays.Uint8ClampedArray; - -import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.cpu.CPUFont; - -public class HtmlFont extends CPUFont { - - public HTMLCanvasElement imgEl; - public CanvasRenderingContext2D imgElCtx; - - public HtmlFont(String fontName) throws IOException { - super(fontName); - HTMLDocument doc = Window.current().getDocument(); - imgEl = doc.createElement("canvas").cast(); - imgEl.setClassName("hidden"); - doc.getBody().appendChild(imgEl); - imgElCtx = imgEl.getContext("2d").cast(); - imgEl.setWidth(this.charW); - imgEl.setHeight(this.charH * intervalsTotalSize); - - int screenPos = 0; - - int currentInt; - int currentIntBitPosition; - int bitData; - int j; - imgElCtx.clearRect(0, 0, imgEl.getWidth(), imgEl.getHeight()); - imgElCtx.setFillStyle("#000"); - int minBound = 0, maxBound = intervalsTotalSize-1; - System.out.println("charIndex:"+0); - System.out.println("minBound"+minBound); - System.out.println("maxBound"+maxBound); - for (int charIndex = minBound; charIndex < maxBound; charIndex++) { - for (int dy = 0; dy < charH; dy++) { - for (int dx = 0; dx < charW; dx++) { - j = dx; - final int bit = dx + dy * charW; - currentInt = (int) (Math.floor(bit) / (HtmlFont.intBits)); - currentIntBitPosition = bit - (currentInt * HtmlFont.intBits); - final int charIdx = charIndex * charIntCount + currentInt; - if (charIdx >= 0 && charIdx < chars32.length) { - bitData = (chars32[charIdx] >> currentIntBitPosition) & 1; - if (bitData == 1) { - imgElCtx.fillRect( dx, charIndex*charH+dy, 1, 1 ); - } - } - } - } - } - } - - @Override - public void use(GraphicEngine d) { - if (d.getRenderer() instanceof HtmlRenderer) { - ((HtmlRenderer) d.getRenderer()).f = this; - } - } - -} +package it.cavallium.warppi.gui.graphicengine.html; + +import java.io.IOException; + +import org.teavm.jso.browser.Window; +import org.teavm.jso.canvas.CanvasRenderingContext2D; +import org.teavm.jso.dom.html.HTMLCanvasElement; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLImageElement; +import org.teavm.jso.typedarrays.Uint8ClampedArray; + +import it.cavallium.warppi.StaticVars; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.common.RFTFont; + +public class HtmlFont extends RFTFont { + + public HTMLCanvasElement imgEl; + public CanvasRenderingContext2D imgElCtx; + + public HtmlFont(String fontName) throws IOException { + super(fontName); + HTMLDocument doc = Window.current().getDocument(); + imgEl = doc.createElement("canvas").cast(); + imgEl.setClassName("hidden"); + doc.getBody().appendChild(imgEl); + imgElCtx = imgEl.getContext("2d").cast(); + imgEl.setWidth(this.charW); + imgEl.setHeight(this.charH * intervalsTotalSize); + + int screenPos = 0; + + int currentInt; + int currentIntBitPosition; + int bitData; + int j; + imgElCtx.clearRect(0, 0, imgEl.getWidth(), imgEl.getHeight()); + imgElCtx.setFillStyle("#000"); + int minBound = 0, maxBound = intervalsTotalSize-1; + System.out.println("charIndex:"+0); + System.out.println("minBound"+minBound); + System.out.println("maxBound"+maxBound); + for (int charIndex = minBound; charIndex < maxBound; charIndex++) { + for (int dy = 0; dy < charH; dy++) { + for (int dx = 0; dx < charW; dx++) { + j = dx; + final int bit = dx + dy * charW; + currentInt = (int) (Math.floor(bit) / (HtmlFont.intBits)); + currentIntBitPosition = bit - (currentInt * HtmlFont.intBits); + final int charIdx = charIndex * charIntCount + currentInt; + if (charIdx >= 0 && charIdx < chars32.length) { + bitData = (chars32[charIdx] >> currentIntBitPosition) & 1; + if (bitData == 1) { + imgElCtx.fillRect( dx, charIndex*charH+dy, 1, 1 ); + } + } + } + } + } + } + + @Override + public void use(GraphicEngine d) { + if (d.getRenderer() instanceof HtmlRenderer) { + ((HtmlRenderer) d.getRenderer()).f = this; + } + } + +} \ No newline at end of file diff --git a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlRenderer.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlRenderer.java similarity index 96% rename from src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlRenderer.java rename to teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlRenderer.java index a1e17d90..5739fc5d 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlRenderer.java +++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlRenderer.java @@ -1,293 +1,293 @@ -package it.cavallium.warppi.gui.graphicengine.html; - -import org.teavm.jso.canvas.CanvasImageSource; -import org.teavm.jso.canvas.CanvasRenderingContext2D; -import org.teavm.jso.dom.html.HTMLImageElement; -import org.teavm.jso.typedarrays.Uint8ClampedArray; - -import it.cavallium.warppi.StaticVars; -import it.cavallium.warppi.gui.graphicengine.Renderer; - -public class HtmlRenderer implements Renderer { - private static final boolean ENABLE_SUPERSAMPLING = false; - private static final boolean ENABLE_TRANSPARENCY = true; - private String currentColor = "#000000ff"; - private String clearColor = "#000000ff"; - HtmlFont f = null; - HtmlSkin currentSkin = null; - private final CanvasRenderingContext2D g; - private final HtmlEngine e; - public HtmlRenderer(HtmlEngine e, CanvasRenderingContext2D g) { - this.g = g; - this.e = e; - } - - private String toHex(int c) { - final int a = c >> 24 & 0xFF; - final int r = c >> 16 & 0xFF; - final int gg = c >> 8 & 0xFF; - final int b = c & 0xFF; - return String.format("#%02x%02x%02x%02x", r, gg, b, a); - } - - private String toHex8(int c) { - final int r = c >> 16 & 0xFF; - final int gg = c >> 8 & 0xFF; - final int b = c & 0xFF; - return String.format("#%02x%02x%02x", r, gg, b); - } - - private String toHex(int r, int g, int b) { - return String.format("#%02x%02x%02x", r, g, b); - } - - private String toHex(int r, int g, int b, int a) { - return String.format("#%02x%02x%02x%02x", r, g, b, a); - } - - @Override - public int glGetClearColor() { - return hexToInt(clearColor); - } - - private int hexToInt(String hex) { - switch (hex.length()) { - case 6: - return (0xFF << 24) | - (Integer.valueOf(hex.substring(0, 2), 16) << 16) | - (Integer.valueOf(hex.substring(2, 4), 16) << 8) | - Integer.valueOf(hex.substring(4, 6), 16); - case 6+1: - return (0xFF << 24) | - (Integer.valueOf(hex.substring(0+1, 2+1), 16) << 16) | - (Integer.valueOf(hex.substring(2+1, 4+1), 16) << 8) | - Integer.valueOf(hex.substring(4+1, 6+1), 16); - case 8: - return (Integer.valueOf(hex.substring(6, 8), 16) << 24) | - (Integer.valueOf(hex.substring(0, 2), 16) << 16) | - (Integer.valueOf(hex.substring(2, 4), 16) << 8) | - Integer.valueOf(hex.substring(4, 6), 16); - case 8+1: - return (Integer.valueOf(hex.substring(6+1, 8+1), 16) << 24) | - (Integer.valueOf(hex.substring(0+1, 2+1), 16) << 16) | - (Integer.valueOf(hex.substring(2+1, 4+1), 16) << 8) | - Integer.valueOf(hex.substring(4+1, 6+1), 16); - } - return 0xFF000000; - } - - @Override - public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, - float uvHeight) { - if (currentSkin != null) { - glDrawSkin((int) x, (int) y, (int) (x + width), (int) (y + height), (int) uvX, (int) uvY, (int) (uvWidth + uvX), (int) (uvHeight + uvY), true); - } else { - glFillColor(x, y, width, height); - } - } - - @SuppressWarnings("unused") - private void glDrawSkin(int x0, int y0, int x1, int y1, int s0, int t0, int s1, int t1, boolean transparent) { - final int[] size = e.getSize(); - - x0 += StaticVars.screenPos[0]; - y0 += StaticVars.screenPos[1]; - final double incrementX = Math.abs((double) (x1 - x0) / (double) (s1 - s0)); - final double incrementY = Math.abs((double) (y1 - y0) / (double) (t1 - t0)); - final boolean flippedX = (x1 - x0) / (s1 - s0) < 0; - final boolean flippedY = (y1 - y0) / (t1 - t0) < 0; - int oldColor = 0; - int newColor; - final int onex = s0 <= s1 ? 1 : -1; - final int oney = t0 <= t1 ? 1 : -1; - int width = 0; - int height = 0; - if (onex == -1) { - final int s00 = s0; - s0 = s1; - s1 = s00; - width = s1 - s0; - } - if (oney == -1) { - final int t00 = t0; - t0 = t1; - t1 = t00; - height = t1 - t0; - } - if (x0 >= size[0] || y0 >= size[0]) { - return; - } - if (x0 + width >= size[0]) { - s1 = size[0] - x0 + s0; - } - if (y0 + height >= size[1]) { - t1 = size[1] - y0 + t0; - } - if (x0 < 0) { - if (onex == -1) { - width += x0; - s1 += x0 + 1; - } else { - s0 -= x0; - } - x0 = 0; - } - if (y0 < 0) { - if (oney == -1) { - height += y0; - t1 += y0 + 1; - } else { - t0 -= y0; - } - y0 = 0; - } - g.drawImage(currentSkin.getImgElement(), s0, t0, s1-s0, t1-t0, x0, y0, x1-x0, y1-y0); - } - - @Override - public void glFillColor(float x, float y, float width, float height) { - x += StaticVars.screenPos[0]; - y += StaticVars.screenPos[1]; - g.setFillStyle(currentColor); - g.fillRect( x, y, width, height ); - } - - @Override - public void glDrawStringRight(float x, float y, String text) { - glDrawStringLeft(x - f.getStringWidth(text), y, text); - } - - @Override - public void glDrawStringLeft(float x, float y, String textString) { - x += StaticVars.screenPos[0]; - y += StaticVars.screenPos[1]; - - f.imgElCtx.setGlobalCompositeOperation("source-in"); - f.imgElCtx.setFillStyle(currentColor); - f.imgElCtx.fillRect(0, 0, f.imgEl.getWidth(), f.imgEl.getHeight()); - - final int[] text = f.getCharIndexes(textString); - final int[] screenSize = e.getSize(); - int cpos; - final int l = text.length; - for (int i = 0; i < l; i++) { - cpos = (i * (f.charW)); - final int charIndex = text[i]; - g.drawImage(f.imgEl, 0, charIndex*f.charH, f.charW, f.charH, x+cpos, y, f.charW, f.charH); - } - } - - private int stackColors(int... color) { - double a = 0; - double r = 0; - double g = 0; - double b = 0; - for (final int newColor : color) { - final double alpha = (newColor >> 24 & 0xFF) / 255d; - a = a * (1d - alpha) + (newColor >> 24 & 0xFF) * alpha; - r = r * (1d - alpha) + (newColor >> 16 & 0xFF) * alpha; - g = g * (1d - alpha) + (newColor >> 8 & 0xFF) * alpha; - b = b * (1d - alpha) + (newColor & 0xFF) * alpha; - } - return ((int) a) << 24 | ((int) r) << 16 | ((int) g) << 8 | ((int) b); - } - - @Override - public void glDrawStringCenter(float x, float y, String text) { - glDrawStringLeft(x - (f.getStringWidth(text) / 2), y, text); - } - - @Override - public void glDrawLine(float x0, float y0, float x1, float y1) { - if (x1-x0 > 0 && y1-y0 > 0) { - g.beginPath(); - g.moveTo(x0, y0); - g.lineTo(x1, y1); - g.stroke(); - } else { - g.fillRect(x0, y0, (x1-x0)+1, (y1-y0)+1); - } - } - - @Override - public void glDrawCharRight(int x, int y, char ch) { - glDrawStringRight(x, y, ch + ""); - } - - @Override - public void glDrawCharLeft(int x, int y, char ch) { - glDrawStringLeft(x, y, ch + ""); - } - - @Override - public void glDrawCharCenter(int x, int y, char ch) { - glDrawStringCenter(x, y, ch + ""); - } - - @Override - public void glColor4i(int red, int green, int blue, int alpha) { - g.setFillStyle(currentColor = toHex(red, green, blue, alpha)); - } - - @Override - public void glColor4f(float red, float green, float blue, float alpha) { - glColor4i((int) (red * 255d), (int) (green * 255d), (int) (blue * 255d), (int) (alpha * 255d)); - } - - @Override - public void glColor3i(int r, int gg, int b) { - g.setFillStyle(currentColor = toHex(r, gg, b)); - } - - @Override - public void glColor3f(float red, float green, float blue) { - glColor3i((int) (red * 255d), (int) (green * 255d), (int) (blue * 255d)); - } - - @Override - public void glColor(int c) { - final int a = c >> 24 & 0xFF; - final int r = c >> 16 & 0xFF; - final int gg = c >> 8 & 0xFF; - final int b = c & 0xFF; - g.setFillStyle(currentColor = toHex(r, gg, b, a)); - } - - @Override - public void glClearSkin() { - currentSkin = null; - } - - @Override - public void glClearColor4i(int red, int green, int blue, int alpha) { - clearColor = toHex(red, green, blue, alpha); - } - - @Override - public void glClearColor4f(float red, float green, float blue, float alpha) { - clearColor = toHex((int)(red*255), - (int)(green*255), - (int)(blue*255), - (int)(alpha*255)); - } - - @Override - public void glClearColor(int c) { - final int r = c >> 16 & 0xFF; - final int gg = c >> 8 & 0xFF; - final int b = c & 0xFF; - clearColor = toHex(r, gg, b); - } - - @Override - public void glClear(int screenWidth, int screenHeight) { - g.setFillStyle(clearColor); - g.fillRect(0, 0, screenWidth, screenHeight); - g.setFillStyle(currentColor); - } - - @Override - public HtmlFont getCurrentFont() { - return f; - } -} +package it.cavallium.warppi.gui.graphicengine.html; + +import org.teavm.jso.canvas.CanvasImageSource; +import org.teavm.jso.canvas.CanvasRenderingContext2D; +import org.teavm.jso.dom.html.HTMLImageElement; +import org.teavm.jso.typedarrays.Uint8ClampedArray; + +import it.cavallium.warppi.StaticVars; +import it.cavallium.warppi.gui.graphicengine.Renderer; + +public class HtmlRenderer implements Renderer { + private static final boolean ENABLE_SUPERSAMPLING = false; + private static final boolean ENABLE_TRANSPARENCY = true; + private String currentColor = "#000000ff"; + private String clearColor = "#000000ff"; + HtmlFont f = null; + HtmlSkin currentSkin = null; + private final CanvasRenderingContext2D g; + private final HtmlEngine e; + public HtmlRenderer(HtmlEngine e, CanvasRenderingContext2D g) { + this.g = g; + this.e = e; + } + + private String toHex(int c) { + final int a = c >> 24 & 0xFF; + final int r = c >> 16 & 0xFF; + final int gg = c >> 8 & 0xFF; + final int b = c & 0xFF; + return String.format("#%02x%02x%02x%02x", r, gg, b, a); + } + + private String toHex8(int c) { + final int r = c >> 16 & 0xFF; + final int gg = c >> 8 & 0xFF; + final int b = c & 0xFF; + return String.format("#%02x%02x%02x", r, gg, b); + } + + private String toHex(int r, int g, int b) { + return String.format("#%02x%02x%02x", r, g, b); + } + + private String toHex(int r, int g, int b, int a) { + return String.format("#%02x%02x%02x%02x", r, g, b, a); + } + + @Override + public int glGetClearColor() { + return hexToInt(clearColor); + } + + private int hexToInt(String hex) { + switch (hex.length()) { + case 6: + return (0xFF << 24) | + (Integer.valueOf(hex.substring(0, 2), 16) << 16) | + (Integer.valueOf(hex.substring(2, 4), 16) << 8) | + Integer.valueOf(hex.substring(4, 6), 16); + case 6+1: + return (0xFF << 24) | + (Integer.valueOf(hex.substring(0+1, 2+1), 16) << 16) | + (Integer.valueOf(hex.substring(2+1, 4+1), 16) << 8) | + Integer.valueOf(hex.substring(4+1, 6+1), 16); + case 8: + return (Integer.valueOf(hex.substring(6, 8), 16) << 24) | + (Integer.valueOf(hex.substring(0, 2), 16) << 16) | + (Integer.valueOf(hex.substring(2, 4), 16) << 8) | + Integer.valueOf(hex.substring(4, 6), 16); + case 8+1: + return (Integer.valueOf(hex.substring(6+1, 8+1), 16) << 24) | + (Integer.valueOf(hex.substring(0+1, 2+1), 16) << 16) | + (Integer.valueOf(hex.substring(2+1, 4+1), 16) << 8) | + Integer.valueOf(hex.substring(4+1, 6+1), 16); + } + return 0xFF000000; + } + + @Override + public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, + float uvHeight) { + if (currentSkin != null) { + glDrawSkin((int) x, (int) y, (int) (x + width), (int) (y + height), (int) uvX, (int) uvY, (int) (uvWidth + uvX), (int) (uvHeight + uvY), true); + } else { + glFillColor(x, y, width, height); + } + } + + @SuppressWarnings("unused") + private void glDrawSkin(int x0, int y0, int x1, int y1, int s0, int t0, int s1, int t1, boolean transparent) { + final int[] size = e.getSize(); + + x0 += StaticVars.screenPos[0]; + y0 += StaticVars.screenPos[1]; + final double incrementX = Math.abs((double) (x1 - x0) / (double) (s1 - s0)); + final double incrementY = Math.abs((double) (y1 - y0) / (double) (t1 - t0)); + final boolean flippedX = (x1 - x0) / (s1 - s0) < 0; + final boolean flippedY = (y1 - y0) / (t1 - t0) < 0; + int oldColor = 0; + int newColor; + final int onex = s0 <= s1 ? 1 : -1; + final int oney = t0 <= t1 ? 1 : -1; + int width = 0; + int height = 0; + if (onex == -1) { + final int s00 = s0; + s0 = s1; + s1 = s00; + width = s1 - s0; + } + if (oney == -1) { + final int t00 = t0; + t0 = t1; + t1 = t00; + height = t1 - t0; + } + if (x0 >= size[0] || y0 >= size[0]) { + return; + } + if (x0 + width >= size[0]) { + s1 = size[0] - x0 + s0; + } + if (y0 + height >= size[1]) { + t1 = size[1] - y0 + t0; + } + if (x0 < 0) { + if (onex == -1) { + width += x0; + s1 += x0 + 1; + } else { + s0 -= x0; + } + x0 = 0; + } + if (y0 < 0) { + if (oney == -1) { + height += y0; + t1 += y0 + 1; + } else { + t0 -= y0; + } + y0 = 0; + } + g.drawImage(currentSkin.getImgElement(), s0, t0, s1-s0, t1-t0, x0, y0, x1-x0, y1-y0); + } + + @Override + public void glFillColor(float x, float y, float width, float height) { + x += StaticVars.screenPos[0]; + y += StaticVars.screenPos[1]; + g.setFillStyle(currentColor); + g.fillRect( x, y, width, height ); + } + + @Override + public void glDrawStringRight(float x, float y, String text) { + glDrawStringLeft(x - f.getStringWidth(text), y, text); + } + + @Override + public void glDrawStringLeft(float x, float y, String textString) { + x += StaticVars.screenPos[0]; + y += StaticVars.screenPos[1]; + + f.imgElCtx.setGlobalCompositeOperation("source-in"); + f.imgElCtx.setFillStyle(currentColor); + f.imgElCtx.fillRect(0, 0, f.imgEl.getWidth(), f.imgEl.getHeight()); + + final int[] text = f.getCharIndexes(textString); + final int[] screenSize = e.getSize(); + int cpos; + final int l = text.length; + for (int i = 0; i < l; i++) { + cpos = (i * (f.charW)); + final int charIndex = text[i]; + g.drawImage(f.imgEl, 0, charIndex*f.charH, f.charW, f.charH, x+cpos, y, f.charW, f.charH); + } + } + + private int stackColors(int... color) { + double a = 0; + double r = 0; + double g = 0; + double b = 0; + for (final int newColor : color) { + final double alpha = (newColor >> 24 & 0xFF) / 255d; + a = a * (1d - alpha) + (newColor >> 24 & 0xFF) * alpha; + r = r * (1d - alpha) + (newColor >> 16 & 0xFF) * alpha; + g = g * (1d - alpha) + (newColor >> 8 & 0xFF) * alpha; + b = b * (1d - alpha) + (newColor & 0xFF) * alpha; + } + return ((int) a) << 24 | ((int) r) << 16 | ((int) g) << 8 | ((int) b); + } + + @Override + public void glDrawStringCenter(float x, float y, String text) { + glDrawStringLeft(x - (f.getStringWidth(text) / 2), y, text); + } + + @Override + public void glDrawLine(float x0, float y0, float x1, float y1) { + if (x1-x0 > 0 && y1-y0 > 0) { + g.beginPath(); + g.moveTo(x0, y0); + g.lineTo(x1, y1); + g.stroke(); + } else { + g.fillRect(x0, y0, (x1-x0)+1, (y1-y0)+1); + } + } + + @Override + public void glDrawCharRight(int x, int y, char ch) { + glDrawStringRight(x, y, ch + ""); + } + + @Override + public void glDrawCharLeft(int x, int y, char ch) { + glDrawStringLeft(x, y, ch + ""); + } + + @Override + public void glDrawCharCenter(int x, int y, char ch) { + glDrawStringCenter(x, y, ch + ""); + } + + @Override + public void glColor4i(int red, int green, int blue, int alpha) { + g.setFillStyle(currentColor = toHex(red, green, blue, alpha)); + } + + @Override + public void glColor4f(float red, float green, float blue, float alpha) { + glColor4i((int) (red * 255d), (int) (green * 255d), (int) (blue * 255d), (int) (alpha * 255d)); + } + + @Override + public void glColor3i(int r, int gg, int b) { + g.setFillStyle(currentColor = toHex(r, gg, b)); + } + + @Override + public void glColor3f(float red, float green, float blue) { + glColor3i((int) (red * 255d), (int) (green * 255d), (int) (blue * 255d)); + } + + @Override + public void glColor(int c) { + final int a = c >> 24 & 0xFF; + final int r = c >> 16 & 0xFF; + final int gg = c >> 8 & 0xFF; + final int b = c & 0xFF; + g.setFillStyle(currentColor = toHex(r, gg, b, a)); + } + + @Override + public void glClearSkin() { + currentSkin = null; + } + + @Override + public void glClearColor4i(int red, int green, int blue, int alpha) { + clearColor = toHex(red, green, blue, alpha); + } + + @Override + public void glClearColor4f(float red, float green, float blue, float alpha) { + clearColor = toHex((int)(red*255), + (int)(green*255), + (int)(blue*255), + (int)(alpha*255)); + } + + @Override + public void glClearColor(int c) { + final int r = c >> 16 & 0xFF; + final int gg = c >> 8 & 0xFF; + final int b = c & 0xFF; + clearColor = toHex(r, gg, b); + } + + @Override + public void glClear(int screenWidth, int screenHeight) { + g.setFillStyle(clearColor); + g.fillRect(0, 0, screenWidth, screenHeight); + g.setFillStyle(currentColor); + } + + @Override + public HtmlFont getCurrentFont() { + return f; + } +} \ No newline at end of file diff --git a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java similarity index 85% rename from src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java rename to teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java index 2ab734d2..d9679265 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java +++ b/teavm/src/main/java/it/cavallium/warppi/gui/graphicengine/html/HtmlSkin.java @@ -1,86 +1,86 @@ -package it.cavallium.warppi.gui.graphicengine.html; - -import java.io.IOException; -import java.net.URISyntaxException; - -import org.teavm.jso.JSObject; -import org.teavm.jso.browser.Window; -import org.teavm.jso.dom.html.HTMLDocument; -import org.teavm.jso.dom.html.HTMLImageElement; - -import ar.com.hjg.pngj.PngReader; -import it.cavallium.warppi.deps.StorageUtils; -import it.cavallium.warppi.gui.graphicengine.GraphicEngine; -import it.cavallium.warppi.gui.graphicengine.Skin; - -public class HtmlSkin implements Skin { - - private String url; - - private int[] skinSize; - - private boolean initd; - - private HTMLImageElement imgEl; - - public HtmlSkin(String file) throws IOException { - load(file); - } - - public void use(GraphicEngine d) { - if (d instanceof HtmlEngine) { - if (!initd) - initialize(d); - ((HtmlEngine) d).getRenderer().currentSkin = this; - } - } - - @Override - public void load(String file) throws IOException { - if (!file.startsWith("/")) - file = "/"+file; - url = StorageUtils.basepath+file; - try { - PngReader r = new PngReader(StorageUtils.getResourceStream(file)); - skinSize = new int[] { r.imgInfo.cols, r.imgInfo.rows }; - r.close(); - } catch (URISyntaxException e) { - IOException ex = new IOException(); - ex.initCause(e); - throw ex; - } - } - - @Override - public void initialize(GraphicEngine d) { - HTMLDocument doc = Window.current().getDocument(); - imgEl = doc.createElement("img").cast(); - imgEl.setSrc(url); - imgEl.setClassName("hidden"); - doc.getBody().appendChild(imgEl); - initd = true; - } - - @Override - public boolean isInitialized() { - return initd; - } - - @Override - public int getSkinWidth() { - return skinSize[0]; - } - - @Override - public int getSkinHeight() { - return skinSize[1]; - } - - public final String getUrl() { - return url; - } - - public final HTMLImageElement getImgElement() { - return imgEl; - } -} +package it.cavallium.warppi.gui.graphicengine.html; + +import java.io.IOException; +import java.net.URISyntaxException; + +import org.teavm.jso.JSObject; +import org.teavm.jso.browser.Window; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLImageElement; + +import ar.com.hjg.pngj.PngReader; +import it.cavallium.warppi.Engine; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.Skin; + +public class HtmlSkin implements Skin { + + private String url; + + private int[] skinSize; + + private boolean initd; + + private HTMLImageElement imgEl; + + public HtmlSkin(String file) throws IOException { + load(file); + } + + public void use(GraphicEngine d) { + if (d instanceof HtmlEngine) { + if (!initd) + initialize(d); + ((HtmlEngine) d).getRenderer().currentSkin = this; + } + } + + @Override + public void load(String file) throws IOException { + if (!file.startsWith("/")) + file = "/"+file; + url = Engine.getPlatform().getStorageUtils().getBasePath()+file; + try { + PngReader r = new PngReader(Engine.getPlatform().getStorageUtils().getResourceStream(file)); + skinSize = new int[] { r.imgInfo.cols, r.imgInfo.rows }; + r.close(); + } catch (URISyntaxException e) { + IOException ex = new IOException(); + ex.initCause(e); + throw ex; + } + } + + @Override + public void initialize(GraphicEngine d) { + HTMLDocument doc = Window.current().getDocument(); + imgEl = doc.createElement("img").cast(); + imgEl.setSrc(url); + imgEl.setClassName("hidden"); + doc.getBody().appendChild(imgEl); + initd = true; + } + + @Override + public boolean isInitialized() { + return initd; + } + + @Override + public int getSkinWidth() { + return skinSize[0]; + } + + @Override + public int getSkinHeight() { + return skinSize[1]; + } + + public final String getUrl() { + return url; + } + + public final HTMLImageElement getImgElement() { + return imgEl; + } +} \ No newline at end of file diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMBoot.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMBoot.java new file mode 100644 index 00000000..c45cb4a2 --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMBoot.java @@ -0,0 +1,11 @@ +package it.cavallium.warppi.teavm; + +import it.cavallium.warppi.boot.Boot; + +public class TeaVMBoot { + + public static void main(String[] args) throws Exception { + Boot.boot(new TeaVMPlatform(), args); + } + +} diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMConsoleUtils.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMConsoleUtils.java new file mode 100644 index 00000000..f7ab52ee --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMConsoleUtils.java @@ -0,0 +1,113 @@ +package it.cavallium.warppi.teavm; + +import java.io.PrintStream; + +import it.cavallium.warppi.StaticVars; +import it.cavallium.warppi.math.MathematicalSymbols; + +public class TeaVMConsoleUtils implements it.cavallium.warppi.deps.Platform.ConsoleUtils { + + private AdvancedOutputStream os; + + public TeaVMConsoleUtils() { + os = new AdvancedOutputStream() { + private void print(PrintStream stream, String str) { + stream.print(fixString(str)); + } + + private void println(PrintStream stream, String str) { + stream.println(fixString(str)); + } + + private void println(PrintStream stream) { + stream.println(); + } + + private String fixString(String str) { + + return str.replace("" + MathematicalSymbols.NTH_ROOT, "root").replace("" + MathematicalSymbols.SQUARE_ROOT, "sqrt").replace("" + MathematicalSymbols.POWER, "powerOf").replace("" + MathematicalSymbols.POWER_OF_TWO, "powerOfTwo").replace("" + MathematicalSymbols.SINE, "sine").replace("" + MathematicalSymbols.COSINE, "cosine").replace("" + MathematicalSymbols.TANGENT, "tangent").replace("" + MathematicalSymbols.ARC_SINE, "asin").replace("" + MathematicalSymbols.ARC_COSINE, "acos").replace("" + MathematicalSymbols.ARC_TANGENT, "atan").replace("" + MathematicalSymbols.UNDEFINED, "undefined").replace("" + MathematicalSymbols.PI, "PI").replace("" + MathematicalSymbols.EULER_NUMBER, "EULER_NUMBER").replace("" + MathematicalSymbols.X, "X").replace("" + MathematicalSymbols.Y, "Y"); + } + + public void println(Object str) { + println(0, str); + } + + public void println(int level) { + if (StaticVars.outputLevel >= level) { + if (StaticVars.outputLevel == 0) { + println(System.out); + } else { + println(System.out); + } + } + } + + public void println(int level, Object str) { + if (StaticVars.outputLevel >= level) { + final String time = getTimeString(); + if (StaticVars.outputLevel == 0) { + println(System.out, "[" + time + "] " + str); + } else { + println(System.out, "[" + time + "] " + str); + } + } + } + + public void print(int level, String str) { + if (StaticVars.outputLevel >= level) { + if (StaticVars.outputLevel == 0) { + print(System.out, str); + } else { + print(System.out, str); + } + } + } + + public void println(int level, String prefix, String str) { + if (StaticVars.outputLevel >= level) { + final String time = getTimeString(); + if (StaticVars.outputLevel == 0) { + println(System.out, "[" + time + "][" + prefix + "] " + str); + } else { + println(System.out, "[" + time + "][" + prefix + "] " + str); + } + } + } + + public void println(int level, String... parts) { + if (StaticVars.outputLevel >= level) { + final String time = getTimeString(); + StringBuilder output = new StringBuilder(); + for (int i = 0; i < parts.length; i++) { + if (i + 1 == parts.length) { + output.append(' '); + output.append(parts[i]); + } else { + output.append('['); + output.append(parts[i]); + output.append(']'); + } + } + output.insert(0, '['); + output.insert(1, time); + output.insert(time.length() + 1, ']'); + if (StaticVars.outputLevel == 0) { + println(System.out, output.toString()); + } else { + println(System.out, output.toString()); + } + } + } + + private String getTimeString() { + return System.currentTimeMillis()+""; + } + }; + } + + @Override + public AdvancedOutputStream out() { + return os; + } + +} diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMGpio.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMGpio.java new file mode 100644 index 00000000..d735e6fc --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMGpio.java @@ -0,0 +1,75 @@ +package it.cavallium.warppi.teavm; + +import it.cavallium.warppi.ClassUtils; + +public class TeaVMGpio implements it.cavallium.warppi.deps.Platform.Gpio { + + @Override + public int valueOutput() { + return 0; + } + + @Override + public int valuePwmOutput() { + return 0; + } + + @Override + public int valueInput() { + return 0; + } + + @Override + public int valueHigh() { + return 0; + } + + @Override + public int valueLow() { + return 0; + } + + @Override + public Object valueUnknownBoardType() { + return new Object(); + } + + @Override + public void wiringPiSetupPhys() { + } + + @Override + public void pinMode(int i, int type) { + } + + @Override + public void digitalWrite(int pin, int val) { + throw new java.lang.UnsupportedOperationException("Not implemented."); + } + + @Override + public void digitalWrite(int pin, boolean val) { + throw new java.lang.UnsupportedOperationException("Not implemented."); + } + + @Override + public void pwmWrite(int pin, int val) { + throw new java.lang.UnsupportedOperationException("Not implemented."); + } + + @Override + public void delayMicroseconds(int t) { + throw new java.lang.UnsupportedOperationException("Not implemented."); + } + + @Override + public int digitalRead(int pin) { + throw new java.lang.UnsupportedOperationException("Not implemented."); + } + + @Override + public Object getBoardType() { + return new Object(); + } + +} diff --git a/src/teavm-specific/java/it/cavallium/warppi/PlatformUtils.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java similarity index 50% rename from src/teavm-specific/java/it/cavallium/warppi/PlatformUtils.java rename to teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java index 34cc1552..93b39989 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/PlatformUtils.java +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java @@ -1,37 +1,144 @@ -package it.cavallium.warppi; +package it.cavallium.warppi.teavm; import java.io.PrintWriter; import java.io.StringWriter; -import java.lang.ref.WeakReference; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; import org.teavm.jso.browser.Window; import org.teavm.jso.dom.html.HTMLDocument; -import it.cavallium.warppi.gui.expression.blocks.Block; +import it.cavallium.warppi.Error; +import it.cavallium.warppi.deps.Platform; +import it.cavallium.warppi.gui.graphicengine.GraphicEngine; +import it.cavallium.warppi.gui.graphicengine.html.HtmlEngine; import it.cavallium.warppi.math.rules.RulesManager; -public final class PlatformUtils { - public static final boolean isJavascript = true; - public static String osName = "JavaScript"; +public class TeaVMPlatform implements Platform { + + private final TeaVMConsoleUtils cu; + private final TeaVMGpio gi; + private final TeaVMStorageUtils su; + private final String on; + private final Map el; + private final TeaVMPngUtils pu; + + public TeaVMPlatform() { + cu = new TeaVMConsoleUtils(); + gi = new TeaVMGpio(); + su = new TeaVMStorageUtils(); + pu = new TeaVMPngUtils(); + on = "JavaScript"; + el = new HashMap<>(); + el.put("HTML5 engine", new HtmlEngine()); + } - public static void setThreadName(Thread t, String string) { + @Override + public ConsoleUtils getConsoleUtils() { + return cu; } - public static void setDaemon(Thread kt) { + @Override + public Gpio getGpio() { + return gi; } - public static void setDaemon(Thread kt, boolean val) { + @Override + public StorageUtils getStorageUtils() { + return su; } - public static void throwNewExceptionInInitializerError(String string) { - throw new NullPointerException(string); + @Override + public PngUtils getPngUtils() { + return pu; } - public static String[] stacktraceToString(Error e) { + @Override + public void setThreadName(Thread t, String name) { + } + + @Override + public void setThreadDaemon(Thread t) { + } + + @Override + public void setThreadDaemon(Thread t, boolean value) { + } + + @Override + public void exit(int value) { + System.err.println("====================PROGRAM END===================="); + } + + @Override + public void gc() { + + } + + @Override + public boolean isJavascript() { + return true; + } + + @Override + public String getOsName() { + return on; + } + + private boolean shift, alpha; + + @Override + public void alphaChanged(boolean alpha) { + this.alpha = alpha; + HTMLDocument doc = Window.current().getDocument(); + doc.getBody().setClassName((shift ? "shift " : "") + (alpha ? "alpha": "")); + } + + @Override + public void shiftChanged(boolean shift) { + this.shift = shift; + HTMLDocument doc = Window.current().getDocument(); + doc.getBody().setClassName((shift ? "shift " : "") + (alpha ? "alpha": "")); + } + + @Override + public Semaphore newSemaphore() { + return new TeaVMSemaphore(0); + } + + @Override + public Semaphore newSemaphore(int i) { + return new TeaVMSemaphore(i); + } + + @Override + public URLClassLoader newURLClassLoader(URL[] urls) { + return new TeaVMURLClassLoader(urls); + } + + @Override + public Map getEnginesList() { + return el; + } + + @Override + public GraphicEngine getEngine(String string) throws NullPointerException { + return el.get(string); + } + + @Override + public void throwNewExceptionInInitializerError(String text) { + throw new NullPointerException(); + } + + @Override + public String[] stacktraceToString(Error e) { return e.getMessage().toUpperCase().replace("\r", "").split("\n"); } - public static void loadPlatformRules() { + @Override + public void loadPlatformRules() { RulesManager.addRule(new rules.functions.DivisionRule()); RulesManager.addRule(new rules.functions.EmptyNumberRule()); RulesManager.addRule(new rules.functions.ExpressionRule()); @@ -83,21 +190,19 @@ public final class PlatformUtils { RulesManager.addRule(new rules.VariableRule3()); } - public static void gc() { + @Override + public void zip(String targetPath, String destinationFilePath, String password) { + throw new java.lang.UnsupportedOperationException("Not implemented."); } - private static boolean shift, alpha; - - public static void shiftChanged(boolean shift) { - PlatformUtils.shift = shift; - HTMLDocument doc = Window.current().getDocument(); - doc.getBody().setClassName((shift ? "shift " : "") + (alpha ? "alpha": "")); + @Override + public void unzip(String targetZipFilePath, String destinationFolderPath, String password) { + throw new java.lang.UnsupportedOperationException("Not implemented."); } - public static void alphaChanged(boolean alpha) { - PlatformUtils.alpha = alpha; - HTMLDocument doc = Window.current().getDocument(); - doc.getBody().setClassName((shift ? "shift " : "") + (alpha ? "alpha": "")); + @Override + public boolean compile(String[] command, PrintWriter printWriter, PrintWriter errors) { + throw new java.lang.UnsupportedOperationException("Not implemented."); } - + } diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngReader.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngReader.java new file mode 100644 index 00000000..c9d4d4aa --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngReader.java @@ -0,0 +1,61 @@ +package it.cavallium.warppi.teavm; + +import java.io.InputStream; + +import ar.com.hjg.pngj.ImageLineInt; +import it.cavallium.warppi.deps.Platform.PngUtils.PngReader; + +public class TeaVMPngReader implements PngReader { + + private ar.com.hjg.pngj.PngReader r; + + public TeaVMPngReader(InputStream resourceStream) { + r = new ar.com.hjg.pngj.PngReader(resourceStream); + } + + @Override + public int[] getImageMatrix() { + final int width = r.imgInfo.cols; + final int height = r.imgInfo.rows; + final int channels = r.imgInfo.channels; + final int[] pixels = new int[width * height]; + int pi = 0; + ImageLineInt lint; + while (r.hasMoreRows()) { + lint = (ImageLineInt) r.readRow(); + int[] scanLine = lint.getScanline(); + + for (int i = 0; i < width; i++) { + int offset = i * channels; + + // Adjust the following code depending on your source image. + // I need the to set the alpha channel to 0xFF000000 since my destination image + // is TRANSLUCENT : BufferedImage bi = CONFIG.createCompatibleImage( width, height, Transparency.TRANSLUCENT ); + // my source was 3 channels RGB without transparency + int nextPixel; + if (channels == 4) { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (scanLine[offset + 3] << 24); + } else if (channels == 3) { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (0xFF << 24); + } else if (channels == 2) { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24); + } else { + nextPixel = (scanLine[offset] << 16) | (scanLine[offset] << 8) | scanLine[offset] | (0xFF << 24); + } + + // I'm placing the pixels on a memory mapped file + pixels[pi] = nextPixel; + pi++; + } + + } + + return pixels; + } + + @Override + public int[] getSize() { + return new int[] {r.imgInfo.cols, r.imgInfo.rows}; + } + +} diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java new file mode 100644 index 00000000..ddc2cde0 --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java @@ -0,0 +1,14 @@ +package it.cavallium.warppi.teavm; + +import java.io.InputStream; + +import it.cavallium.warppi.deps.Platform.PngUtils; + +public class TeaVMPngUtils implements PngUtils { + + @Override + public PngReader load(InputStream resourceStream) { + return new TeaVMPngReader(resourceStream); + } + +} diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/DSemaphore.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMSemaphore.java similarity index 65% rename from src/teavm-specific/java/it/cavallium/warppi/deps/DSemaphore.java rename to teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMSemaphore.java index 9bc6b473..79fef229 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/DSemaphore.java +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMSemaphore.java @@ -1,23 +1,21 @@ -package it.cavallium.warppi.deps; +package it.cavallium.warppi.teavm; -import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; +import java.util.concurrent.Semaphore; -import org.teavm.classlib.java.util.TArrayList; -import org.teavm.classlib.java.util.TQueue; - -public class DSemaphore { +public class TeaVMSemaphore implements it.cavallium.warppi.deps.Platform.Semaphore { private Queue q; private int freePermits = 0; - public DSemaphore(int i) { + public TeaVMSemaphore(int i) { q = new LinkedList(); freePermits = i; } - + + @Override public void release() { if (q.peek() == null) { q.poll(); @@ -26,6 +24,7 @@ public class DSemaphore { } } + @Override public void acquire() throws InterruptedException { if (freePermits > 0) { freePermits--; @@ -37,5 +36,4 @@ public class DSemaphore { } } } - } diff --git a/src/teavm-specific/java/it/cavallium/warppi/deps/StorageUtils.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMStorageUtils.java similarity index 67% rename from src/teavm-specific/java/it/cavallium/warppi/deps/StorageUtils.java rename to teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMStorageUtils.java index add9f705..b04b21ce 100644 --- a/src/teavm-specific/java/it/cavallium/warppi/deps/StorageUtils.java +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMStorageUtils.java @@ -1,62 +1,35 @@ -package it.cavallium.warppi.deps; +package it.cavallium.warppi.teavm; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; -import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; -import java.nio.file.FileSystemAlreadyExistsException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.apache.commons.io.Charsets; import org.apache.commons.io.IOUtils; -import org.teavm.classlib.java.nio.charset.TCharset; import org.teavm.jso.browser.Window; -public class StorageUtils { - public static final String basepath; - static { - String fullurl = Window.current().getLocation().getFullURL(); - if (fullurl.charAt(fullurl.length()-1) == '/') { - basepath = fullurl+"resources"; - } else { - basepath = fullurl+"/resources"; - } -} - - private static Map resourcesCache = new HashMap(); - - public static final boolean exists(Path f) { - return f.toFile().exists(); - } - - public static final boolean exists(File f) { +import it.cavallium.warppi.deps.Platform.StorageUtils; + +public class TeaVMStorageUtils implements StorageUtils { + public boolean exists(File f) { return f.exists(); } - public static File get(String... path) { - return new File(join(path, File.separator)); + public File get(String path) { + return new File(path); } - + private static String join(String[] list, String conjunction) { StringBuilder sb = new StringBuilder(); @@ -72,7 +45,13 @@ public class StorageUtils { return sb.toString(); } - public static File getResource(String path) throws IOException, URISyntaxException { + public File get(String... path) { + return new File(join(path, File.separator)); + } + + private static Map resourcesCache = new HashMap(); + + public File getResource(String path) throws IOException, URISyntaxException { try { File targetFile; if (resourcesCache.containsKey(path)) { @@ -82,7 +61,7 @@ public class StorageUtils { resourcesCache.remove(path); } } - final URL res = new URL(basepath+path); + final URL res = new URL(this.getBasePath()+path); InputStream initialStream = res.openStream(); byte[] buffer = new byte[initialStream.available()]; initialStream.read(buffer); @@ -99,7 +78,7 @@ public class StorageUtils { } } - public static InputStream getResourceStream(String path) throws IOException, URISyntaxException { + public InputStream getResourceStream(String path) throws IOException, URISyntaxException { try { File targetFile; if (resourcesCache.containsKey(path)) { @@ -109,7 +88,7 @@ public class StorageUtils { resourcesCache.remove(path); } } - final URL res = new URL(basepath+path); + final URL res = new URL(this.getBasePath()+path); InputStream initialStream = res.openStream(); byte[] buffer = new byte[initialStream.available()]; initialStream.read(buffer); @@ -126,7 +105,7 @@ public class StorageUtils { } } - public static List readAllLines(File file) throws IOException { + public List readAllLines(File file) throws IOException { Reader reader_ = new InputStreamReader(new FileInputStream(file), Charset.defaultCharset()); BufferedReader reader = reader_ instanceof BufferedReader ? (BufferedReader) reader_ : new BufferedReader(reader_); List list = new ArrayList(); @@ -139,11 +118,11 @@ public class StorageUtils { return list; } - public static String read(InputStream input) throws IOException { - return IOUtils.toString(input); + public String read(InputStream input) throws IOException { + return IOUtils.toString(input, "UTF-8"); } - public static List walk(File dir) throws IOException { + public List walk(File dir) throws IOException { List out = new ArrayList<>(); File[] filesList = dir.listFiles(); if (filesList == null) { @@ -164,26 +143,26 @@ public class StorageUtils { return out; } - public static File relativize(File rulesPath, File f) { + public File relativize(File rulesPath, File f) { return f; } - public static File resolve(File file, String string) { + public File resolve(File file, String string) { return new File(file.getAbsolutePath() + File.separatorChar + string); } - public static File getParent(File f) { + public File getParent(File f) { return f.getParentFile(); } - public static void createDirectories(File dir) { + public void createDirectories(File dir) throws IOException { dir.mkdirs(); } - public static void write(File f, byte[] bytes, DStandardOpenOption... options) throws IOException { + public void write(File f, byte[] bytes, int... options) throws IOException { boolean create = false; - for (DStandardOpenOption opt : options) { - if (opt == DStandardOpenOption.CREATE) { + for (int opt : options) { + if (opt == StorageUtils.OpenOptionCreate) { create = true; } } @@ -200,8 +179,8 @@ public class StorageUtils { stream.write(bytes); stream.close(); } - - public static List readAllLines(InputStream input) throws IOException { + + public List readAllLines(InputStream input) throws IOException { try (BufferedReader buffer = new BufferedReader(new InputStreamReader(input))) { String thisLine = null; ArrayList output = new ArrayList<>(); @@ -211,4 +190,14 @@ public class StorageUtils { return output; } } + + @Override + public String getBasePath() { + String fullurl = Window.current().getLocation().getFullURL(); + if (fullurl.charAt(fullurl.length()-1) == '/') { + return fullurl+"resources"; + } else { + return fullurl+"/resources"; + } + } } diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMURLClassLoader.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMURLClassLoader.java new file mode 100644 index 00000000..547d0367 --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMURLClassLoader.java @@ -0,0 +1,24 @@ +package it.cavallium.warppi.teavm; + +import java.io.IOException; +import java.net.URL; + +import it.cavallium.warppi.deps.Platform.URLClassLoader; + +public class TeaVMURLClassLoader implements URLClassLoader { + + public TeaVMURLClassLoader(URL[] urls) { + + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException { + return null; + } + + @Override + public void close() throws IOException { + + } + +}