Initial TeaVM support
This commit is contained in:
parent
773f2c14bf
commit
54ddf9df9d
18
.classpath
18
.classpath
@ -1,11 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
@ -28,5 +22,17 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/jar-specific/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
@ -1,4 +1,6 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/jar-specific/java=UTF-8
|
||||
encoding//src/js-specific/java=UTF-8
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/java/org/warp/picalculator/gui/expression/blocks/BlockParenthesis.java=UTF-8
|
||||
encoding//src/main/java/org/warp/picalculator/math/MathematicalSymbols.java=UTF-8
|
||||
|
@ -1,4 +1,4 @@
|
||||
activeProfiles=
|
||||
activeProfiles=jarprofile
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
|
Binary file not shown.
222
pom.xml
222
pom.xml
@ -1,4 +1,5 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.warp.picalculator</groupId>
|
||||
@ -7,7 +8,16 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>WarpPI Calculator</name>
|
||||
<url>http://warp.ovh</url>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<src.dir>src/main/java</src.dir>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>teavm-dev</id>
|
||||
<url>https://dl.bintray.com/konsoletyper/teavm</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>oss-snapshots-repo</id>
|
||||
<name>Sonatype OSS Maven Repository</name>
|
||||
@ -18,34 +28,130 @@
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<!--
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>windows-profile</id>
|
||||
<id>jarprofile</id>
|
||||
<properties>
|
||||
<src.dir>jar-specific</src.dir>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
<file>
|
||||
<exists>${JAVA_HOME}/lib/tools.jar</exists>
|
||||
</file>
|
||||
</activation>
|
||||
<properties>
|
||||
<toolsjar>${JAVA_HOME}/lib/tools.jar</toolsjar>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jogamp.jogl</groupId>
|
||||
<artifactId>jogl-all-main</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jogamp.gluegen</groupId>
|
||||
<artifactId>gluegen-rt-main</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
<artifactId>pi4j-core</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.fusesource.jansi</groupId>
|
||||
<artifactId>jansi</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.lingala.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
<version>4.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ar.com.hjg</groupId>
|
||||
<artifactId>pngj</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Set a compiler level -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>mac-profile</id>
|
||||
<id>jsprofile</id>
|
||||
<properties>
|
||||
<src.dir>js-specific</src.dir>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
<file>
|
||||
<exists>${java.home}/../lib/tools.jar</exists>
|
||||
</file>
|
||||
</activation>
|
||||
<properties>
|
||||
<toolsjar>${java.home}/../lib/tools.jar</toolsjar>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>org/warp/picalculator/gui/graphicengine/cpu/*</exclude>
|
||||
<exclude>org/warp/picalculator/gui/graphicengine/gpu/*</exclude>
|
||||
<exclude>org/warp/picalculator/gui/graphicengine/headless24bit/*</exclude>
|
||||
<exclude>org/warp/picalculator/gui/graphicengine/headless256/*</exclude>
|
||||
<exclude>org/warp/picalculator/gui/graphicengine/headless8/*</exclude>
|
||||
<exclude>org/warp/picalculator/gui/graphicengine/framebuffer/*</exclude>
|
||||
</excludes>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven-plugin</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<dependencies>
|
||||
<!-- This dependency is required by TeaVM to emulate subset of Java
|
||||
class library -->
|
||||
<dependency>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-classlib</artifactId>
|
||||
<version>0.5.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
<configuration>
|
||||
<mainClass>org.warp.picalculator.Main</mainClass>
|
||||
<mainPageIncluded>true</mainPageIncluded>
|
||||
<debugInformationGenerated>true</debugInformationGenerated>
|
||||
<sourceMapsGenerated>true</sourceMapsGenerated>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
-->
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!--<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId>
|
||||
<version>4.12</version> <scope>test</scope> </dependency> -->
|
||||
@ -55,53 +161,38 @@
|
||||
<version>7.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jogamp.jogl</groupId>
|
||||
<artifactId>jogl-all-main</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jogamp.gluegen</groupId>
|
||||
<artifactId>gluegen-rt-main</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pi4j</groupId>
|
||||
<artifactId>pi4j-core</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.fusesource.jansi</groupId>
|
||||
<artifactId>jansi</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ar.com.hjg</groupId>
|
||||
<artifactId>pngj</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
<version>4.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.lingala.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<build>
|
||||
<finalName>WarpPICalculator</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-source</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>
|
||||
${basedir}/src/main/java
|
||||
</source>
|
||||
<source>
|
||||
${basedir}/src/${src.dir}/java
|
||||
</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- download source code in Eclipse, best practice -->
|
||||
<plugin>
|
||||
@ -123,18 +214,6 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Set a compiler level -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Assembly Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -164,7 +243,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<!-- <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId>
|
||||
|
110
src/jar-specific/java/org/warp/picalculator/ConsoleUtils.java
Normal file
110
src/jar-specific/java/org/warp/picalculator/ConsoleUtils.java
Normal file
@ -0,0 +1,110 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.StringWriter;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.warp.picalculator.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(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, String 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();
|
||||
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 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;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
49
src/jar-specific/java/org/warp/picalculator/ZipUtils.java
Normal file
49
src/jar-specific/java/org/warp/picalculator/ZipUtils.java
Normal file
@ -0,0 +1,49 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.warp.picalculator.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;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.cpu.CPUEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.framebuffer.FBEngine;
|
||||
|
||||
public class DEngine {
|
||||
public static GraphicEngine newGPUEngine() {
|
||||
return new org.warp.picalculator.gui.graphicengine.gpu.GPUEngine();
|
||||
}
|
||||
public static GraphicEngine newHeadless24bitEngine() {
|
||||
return new org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitEngine();
|
||||
}
|
||||
public static GraphicEngine newHeadless256Engine() {
|
||||
return new org.warp.picalculator.gui.graphicengine.headless256.Headless256Engine();
|
||||
}
|
||||
public static GraphicEngine newHeadless8Engine() {
|
||||
return new org.warp.picalculator.gui.graphicengine.headless8.Headless8Engine();
|
||||
}
|
||||
public static GraphicEngine newCPUEngine() {
|
||||
return new CPUEngine();
|
||||
}
|
||||
public static GraphicEngine newFBEngine() {
|
||||
return new FBEngine();
|
||||
}
|
||||
}
|
47
src/jar-specific/java/org/warp/picalculator/deps/DGpio.java
Normal file
47
src/jar-specific/java/org/warp/picalculator/deps/DGpio.java
Normal file
@ -0,0 +1,47 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.ClassUtils.Var;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.ClassUtils.Var;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
public class DSystem {
|
||||
public static final void exit(int val) {
|
||||
System.exit(val);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class StorageUtils {
|
||||
public static final boolean exists(Path f) {
|
||||
return Files.exists(f);
|
||||
}
|
||||
|
||||
public static Path get(String path) {
|
||||
return Paths.get(path);
|
||||
}
|
||||
}
|
@ -0,0 +1,568 @@
|
||||
package org.warp.picalculator.deps.jogamp;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.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;
|
||||
|
||||
/** <b>scroll lock</b> 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 F<i>n</i> function keys.
|
||||
* <p>
|
||||
* F1..F24, i.e. F<i>n</i>, are mapped from on <code>0x60+n</code> -> <code>[0x61 .. 0x78]</code>.
|
||||
* </p>
|
||||
* <p>
|
||||
* <b>Warning:</b> The F<i>n</i> function keys <b>do collide</b> with unicode characters small 'a' thru 'x'!<br/>
|
||||
* See <a href="#unicodeCollision">Unicode Collision</a> for details.
|
||||
* </p>
|
||||
*/
|
||||
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 <b>decimal separator</b> 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 <b>decimal separator</b> key. Non printable UTF control. */
|
||||
public static final short VK_DECIMAL = (short) 0x8A;
|
||||
|
||||
/** Numeric keypad <b>add</b> key. Non printable UTF control. */
|
||||
public static final short VK_ADD = (short) 0x8B;
|
||||
|
||||
/** Numeric keypad <b>subtract</b> key. Non printable UTF control. */
|
||||
public static final short VK_SUBTRACT = (short) 0x8C;
|
||||
|
||||
/** Numeric keypad <b>multiply</b> key. Non printable UTF control. */
|
||||
public static final short VK_MULTIPLY = (short) 0x8D;
|
||||
|
||||
/** Numeric keypad <b>divide</b> 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 <b>num lock</b> key. Non printable UTF control. */
|
||||
public static final short VK_NUM_LOCK = (short) 0x94;
|
||||
|
||||
/** Constant for the cursor- or numerical-pad <b>left</b> arrow key. Non printable UTF control. */
|
||||
public static final short VK_LEFT = (short) 0x95;
|
||||
|
||||
/** Constant for the cursor- or numerical-pad <b>up</b> arrow key. Non printable UTF control. */
|
||||
public static final short VK_UP = (short) 0x96;
|
||||
|
||||
/** Constant for the cursor- or numerical-pad <b>right</b> arrow key. Non printable UTF control. */
|
||||
public static final short VK_RIGHT = (short) 0x97;
|
||||
|
||||
/** Constant for the cursor- or numerical pad <b>down</b> 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;
|
||||
|
||||
}
|
110
src/js-specific/java/org/warp/picalculator/ConsoleUtils.java
Normal file
110
src/js-specific/java/org/warp/picalculator/ConsoleUtils.java
Normal file
@ -0,0 +1,110 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.StringWriter;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.warp.picalculator.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, String 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();
|
||||
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;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.warp.picalculator.gui.expression.blocks.Block;
|
||||
|
||||
public final class PlatformUtils {
|
||||
public static final boolean isJavascript = true;
|
||||
public static String osName = "JavaScript";
|
||||
|
||||
public static void setThreadName(Thread t, String string) {
|
||||
}
|
||||
|
||||
public static void setDaemon(Thread kt) {
|
||||
}
|
||||
|
||||
public static void setDaemon(Thread kt, boolean val) {
|
||||
}
|
||||
|
||||
public static void throwNewExceptionInInitializerError(String string) {
|
||||
throw new NullPointerException(string);
|
||||
}
|
||||
|
||||
public static String[] stacktraceToString(Error e) {
|
||||
return e.getMessage().toUpperCase().replace("\r", "").split("\n");
|
||||
}
|
||||
}
|
11
src/js-specific/java/org/warp/picalculator/ZipUtils.java
Normal file
11
src/js-specific/java/org/warp/picalculator/ZipUtils.java
Normal file
@ -0,0 +1,11 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
@ -0,0 +1,339 @@
|
||||
/*
|
||||
* 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 org.warp.picalculator.deps;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p><a href="package-summary.html#weakCompareAndSet">May fail
|
||||
* spuriously and does not provide ordering guarantees</a>, 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();
|
||||
}
|
||||
|
||||
}
|
25
src/js-specific/java/org/warp/picalculator/deps/DEngine.java
Normal file
25
src/js-specific/java/org/warp/picalculator/deps/DEngine.java
Normal file
@ -0,0 +1,25 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
45
src/js-specific/java/org/warp/picalculator/deps/DGpio.java
Normal file
45
src/js-specific/java/org/warp/picalculator/deps/DGpio.java
Normal file
@ -0,0 +1,45 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.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();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.ClassUtils.Var;
|
||||
|
||||
public class DJDTCompiler {
|
||||
|
||||
public static boolean compile(String[] strings, PrintWriter printWriter, PrintWriter printWriter2) {
|
||||
throw new java.lang.UnsupportedOperationException("Not implemented.");
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
public class DSystem {
|
||||
public static final void exit(int code) {
|
||||
System.err.println("====================PROGRAM END====================");
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.warp.picalculator.deps;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class StorageUtils {
|
||||
public static final boolean exists(Path f) {
|
||||
return f.toFile().exists();
|
||||
}
|
||||
|
||||
public static Path get(String path) {
|
||||
return new File(path).toPath();
|
||||
}
|
||||
}
|
@ -0,0 +1,568 @@
|
||||
package org.warp.picalculator.deps.jogamp;
|
||||
|
||||
import org.warp.picalculator.ClassUtils;
|
||||
import org.warp.picalculator.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;
|
||||
|
||||
/** <b>scroll lock</b> 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 F<i>n</i> function keys.
|
||||
* <p>
|
||||
* F1..F24, i.e. F<i>n</i>, are mapped from on <code>0x60+n</code> -> <code>[0x61 .. 0x78]</code>.
|
||||
* </p>
|
||||
* <p>
|
||||
* <b>Warning:</b> The F<i>n</i> function keys <b>do collide</b> with unicode characters small 'a' thru 'x'!<br/>
|
||||
* See <a href="#unicodeCollision">Unicode Collision</a> for details.
|
||||
* </p>
|
||||
*/
|
||||
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 <b>decimal separator</b> 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 <b>decimal separator</b> key. Non printable UTF control. */
|
||||
public static final short VK_DECIMAL = (short) 0x8A;
|
||||
|
||||
/** Numeric keypad <b>add</b> key. Non printable UTF control. */
|
||||
public static final short VK_ADD = (short) 0x8B;
|
||||
|
||||
/** Numeric keypad <b>subtract</b> key. Non printable UTF control. */
|
||||
public static final short VK_SUBTRACT = (short) 0x8C;
|
||||
|
||||
/** Numeric keypad <b>multiply</b> key. Non printable UTF control. */
|
||||
public static final short VK_MULTIPLY = (short) 0x8D;
|
||||
|
||||
/** Numeric keypad <b>divide</b> 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 <b>num lock</b> key. Non printable UTF control. */
|
||||
public static final short VK_NUM_LOCK = (short) 0x94;
|
||||
|
||||
/** Constant for the cursor- or numerical-pad <b>left</b> arrow key. Non printable UTF control. */
|
||||
public static final short VK_LEFT = (short) 0x95;
|
||||
|
||||
/** Constant for the cursor- or numerical-pad <b>up</b> arrow key. Non printable UTF control. */
|
||||
public static final short VK_UP = (short) 0x96;
|
||||
|
||||
/** Constant for the cursor- or numerical-pad <b>right</b> arrow key. Non printable UTF control. */
|
||||
public static final short VK_RIGHT = (short) 0x97;
|
||||
|
||||
/** Constant for the cursor- or numerical pad <b>down</b> 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;
|
||||
|
||||
}
|
@ -3,13 +3,13 @@ package org.nevec.rjm;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
|
||||
public final class SafeMathContext {
|
||||
|
||||
public static MathContext newMathContext(int precision) {
|
||||
if (precision <= 0) {
|
||||
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")");
|
||||
ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")");
|
||||
precision = 1;
|
||||
}
|
||||
return new MathContext(precision);
|
||||
@ -17,7 +17,7 @@ public final class SafeMathContext {
|
||||
|
||||
public static MathContext newMathContext(int precision, RoundingMode roundingMode) {
|
||||
if (precision <= 0) {
|
||||
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")");
|
||||
ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Warning! MathContext precision is <= 0 (" + precision + ")");
|
||||
precision = 1;
|
||||
}
|
||||
return new MathContext(precision, roundingMode);
|
||||
|
244
src/main/java/org/warp/picalculator/ClassUtils.java
Normal file
244
src/main/java/org/warp/picalculator/ClassUtils.java
Normal file
@ -0,0 +1,244 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ClassUtils {
|
||||
|
||||
public static Class<?> classLoader;
|
||||
|
||||
public static Object invokeStaticMethod(String path, Var<?>... vars) {
|
||||
return invokeMethod(path, null, vars);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Object invokeMethod(String path, Object instance, Var<?>... vars) {
|
||||
Class[] classes = new Class[vars.length];
|
||||
Object[] objects = new Object[vars.length];
|
||||
String[] blob = path.split("\\.");
|
||||
String className = String.join(".", Arrays.copyOfRange(blob, 0, blob.length-1));
|
||||
String methodName = blob[blob.length-1];
|
||||
int index = 0;
|
||||
for (Var<?> v : vars) {
|
||||
classes[index] = v.getType();
|
||||
objects[index] = v.getVar();
|
||||
index++;
|
||||
}
|
||||
try {
|
||||
return classLoader.getClassLoader().loadClass(className).getMethod(methodName, classes).invoke(instance, objects);
|
||||
} catch (InvocationTargetException ex) {
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(ex);
|
||||
throw exc;
|
||||
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(e);
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static Object newClassInstance(String className, Var<?>... vars) {
|
||||
Class[] classes = new Class[vars.length];
|
||||
Object[] objects = new Object[vars.length];
|
||||
int index = 0;
|
||||
for (Var<?> v : vars) {
|
||||
classes[index] = v.getType();
|
||||
objects[index] = v.getVar();
|
||||
index++;
|
||||
}
|
||||
try {
|
||||
return classLoader.getClassLoader().loadClass(className).getDeclaredConstructor(classes).newInstance(objects);
|
||||
} catch (InvocationTargetException ex) {
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(ex);
|
||||
throw exc;
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(e);
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getStaticField(String path, Class<T> type) {
|
||||
try {
|
||||
String[] blob = path.split("\\.");
|
||||
String className = String.join(".", Arrays.copyOfRange(blob, 0, blob.length-1));
|
||||
String var = blob[blob.length-1];
|
||||
return (T) classLoader.getClassLoader().loadClass(className).getField(var).get(null);
|
||||
} catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(e);
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Var<T> getStaticFieldVar(String path, Class<T> type) {
|
||||
T obj = getStaticField(path, type);
|
||||
return new Var<T>(obj, type);
|
||||
}
|
||||
|
||||
public static int getEnumIndex(String className, String value) {
|
||||
try {
|
||||
Object[] enumConstants = classLoader.getClassLoader().loadClass(className).getEnumConstants();
|
||||
int index = 0;
|
||||
for (Object o : enumConstants) {
|
||||
if (o.toString().equals(value)) {
|
||||
return index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(e);
|
||||
throw exc;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static Object getEnumObject(String className, String value) {
|
||||
try {
|
||||
Object[] enumConstants = classLoader.getClassLoader().loadClass(className).getEnumConstants();
|
||||
for (Object o : enumConstants) {
|
||||
if (o.toString().equals(value)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(e);
|
||||
throw exc;
|
||||
}
|
||||
return new Object();
|
||||
}
|
||||
|
||||
public static class Var<E> {
|
||||
private final E var;
|
||||
private final Class<E> type;
|
||||
|
||||
public Var(E var, Class<E> type) {
|
||||
this.var = var;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public synchronized final E getVar() {
|
||||
return var;
|
||||
}
|
||||
|
||||
public synchronized final Class<E> getType() {
|
||||
return type;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((var == null) ? 0 : var.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Var other = (Var) obj;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
if (var == null) {
|
||||
if (other.var != null)
|
||||
return false;
|
||||
} else if (!var.equals(other.var))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Var [var=" + var + ", type=" + type + "]";
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Integer> newVar(int i) {
|
||||
return new Var(i, int.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Short> newVar(short i) {
|
||||
return new Var(i, short.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Byte> newVar(byte i) {
|
||||
return new Var(i, byte.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Boolean> newVar(boolean i) {
|
||||
return new Var(i, boolean.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Character> newVar(char i) {
|
||||
return new Var(i, char.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Long> newVar(long i) {
|
||||
return new Var(i, long.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Float> newVar(float i) {
|
||||
return new Var(i, float.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<Double> newVar(double i) {
|
||||
return new Var(i, double.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Var<String> newVar(String i) {
|
||||
return new Var(i, String.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <E> Var<E> newVar(E[] i, Class<E> type) {
|
||||
return new Var(i, getArrayClass(type));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> Class<? extends T[]> getArrayClass(Class<T> clazz) {
|
||||
return (Class<? extends T[]>) Array.newInstance(clazz, 0).getClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static Var<?> newVarFromClass(Object classObj, String className) {
|
||||
try {
|
||||
return new Var(classObj, classLoader.getClassLoader().loadClass(className));
|
||||
} catch (ClassNotFoundException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
NullPointerException exc = new NullPointerException();
|
||||
exc.addSuppressed(e);
|
||||
throw exc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.warp.picalculator.device.PIHardwareDisplay;
|
||||
import org.warp.picalculator.gui.CalculatorHUD;
|
||||
import org.warp.picalculator.gui.screens.KeyboardDebugScreen;
|
||||
|
||||
public class KeyboardTest {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, Error {
|
||||
public static void main(String[] args) throws InterruptedException, Error, IOException {
|
||||
new Main(new KeyboardDebugScreen(), new PIHardwareDisplay(), new CalculatorHUD(), args);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package org.warp.picalculator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.warp.picalculator.deps.DGpio;
|
||||
import org.warp.picalculator.deps.DSystem;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.PIHardwareDisplay;
|
||||
import org.warp.picalculator.gui.CalculatorHUD;
|
||||
@ -10,46 +14,43 @@ import org.warp.picalculator.gui.screens.LoadingScreen;
|
||||
import org.warp.picalculator.gui.screens.Screen;
|
||||
import org.warp.picalculator.math.rules.RulesManager;
|
||||
|
||||
import com.pi4j.system.SystemInfo.BoardType;
|
||||
import com.pi4j.wiringpi.Gpio;
|
||||
|
||||
public class Main {
|
||||
public static Main instance;
|
||||
public static String[] args;
|
||||
|
||||
public Main(String[] args) throws InterruptedException, Error {
|
||||
public Main(String[] args) throws InterruptedException, Error, IOException {
|
||||
this(new LoadingScreen(), new PIHardwareDisplay(), new CalculatorHUD(), args);
|
||||
}
|
||||
|
||||
public Main(Screen screen, HardwareDisplay disp, HUD hud, String[] args) throws InterruptedException, Error {
|
||||
public Main(Screen screen, HardwareDisplay disp, HUD hud, String[] args) throws InterruptedException, Error, IOException {
|
||||
System.out.println("WarpPI Calculator");
|
||||
instance = this;
|
||||
Main.args = args;
|
||||
StaticVars.classLoader = this.getClass();
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
Thread.currentThread().setName("Main thread");
|
||||
ClassUtils.classLoader = this.getClass();
|
||||
beforeStart();
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
PlatformUtils.setThreadName(Thread.currentThread(), "Main thread");
|
||||
new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
|
||||
afterStart();
|
||||
if (screen instanceof LoadingScreen) {
|
||||
((LoadingScreen) screen).loaded = true;
|
||||
}
|
||||
DisplayManager.INSTANCE.waitForExit();
|
||||
Utils.out.println(1, "Shutdown...");
|
||||
ConsoleUtils.out.println(1, "Shutdown...");
|
||||
beforeShutdown();
|
||||
Utils.out.println(1, "");
|
||||
Utils.out.println(1, "Closed.");
|
||||
System.exit(0);
|
||||
ConsoleUtils.out.println(1, "");
|
||||
ConsoleUtils.out.println(1, "Closed.");
|
||||
DSystem.exit(0);
|
||||
}
|
||||
|
||||
public void beforeStart() {
|
||||
public void beforeStart() throws IOException {
|
||||
boolean isRaspi = false;
|
||||
try {
|
||||
isRaspi = com.pi4j.system.SystemInfo.getBoardType() != BoardType.UNKNOWN;
|
||||
isRaspi = DGpio.getBoardType() != DGpio.UnknownBoardType;
|
||||
} catch (final Exception e) {}
|
||||
if (Utils.isRunningOnRaspberry() && !Utils.isInArray("-noraspi", args) && isRaspi) {
|
||||
Gpio.wiringPiSetupPhys();
|
||||
Gpio.pinMode(12, Gpio.PWM_OUTPUT);
|
||||
DGpio.wiringPiSetupPhys();
|
||||
DGpio.pinMode(12, DGpio.PWM_OUTPUT);
|
||||
} else {
|
||||
StaticVars.screenPos = new int[] { 0, 0 };
|
||||
StaticVars.debugOn = true;
|
||||
@ -87,7 +88,7 @@ public class Main {
|
||||
Utils.forceEngine = "nogui";
|
||||
}
|
||||
if (arg.contains("verbose") || arg.contains("debug")) {
|
||||
StaticVars.outputLevel = Utils.OUTPUTLEVEL_DEBUG_VERBOSE;
|
||||
StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
|
||||
}
|
||||
if (arg.contains("uncached")) {
|
||||
Utils.debugCache = true;
|
||||
@ -110,7 +111,7 @@ public class Main {
|
||||
Keyboard.stopKeyboard();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, Error {
|
||||
public static void main(String[] args) throws InterruptedException, Error, IOException {
|
||||
/*
|
||||
* TEST: Comparing BigIntegerMath.divisors() vs programmingpraxis' Number.getFactors() function
|
||||
*
|
||||
|
@ -12,7 +12,6 @@ public class StaticVars {
|
||||
public static boolean debugOn;
|
||||
public static int outputLevel = 0;
|
||||
public static boolean debugWindow2x = false;
|
||||
public static Class<?> classLoader;
|
||||
public static float windowZoom = 2;
|
||||
|
||||
private StaticVars() {
|
||||
|
@ -2,6 +2,8 @@ package org.warp.picalculator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.warp.picalculator.deps.DEngine;
|
||||
import org.warp.picalculator.deps.DSystem;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.KeyboardEventListener;
|
||||
@ -13,7 +15,6 @@ import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.Renderer;
|
||||
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
|
||||
import org.warp.picalculator.gui.graphicengine.Skin;
|
||||
import org.warp.picalculator.gui.graphicengine.gpu.GPUEngine;
|
||||
import org.warp.picalculator.math.MathContext;
|
||||
import org.warp.picalculator.math.MathematicalSymbols;
|
||||
import org.warp.picalculator.math.functions.Expression;
|
||||
@ -21,7 +22,7 @@ import org.warp.picalculator.math.parser.MathParser;
|
||||
|
||||
public class TestGPU {
|
||||
|
||||
public static final GraphicEngine d = new GPUEngine();
|
||||
public static final GraphicEngine d = DEngine.newGPUEngine();
|
||||
|
||||
public static void main(String[] args) throws IOException, Error {
|
||||
StaticVars.debugOn = true;
|
||||
@ -101,7 +102,7 @@ public class TestGPU {
|
||||
return true;
|
||||
case POWEROFF:
|
||||
d.destroy();
|
||||
System.exit(0);
|
||||
DSystem.exit(0);
|
||||
return true;
|
||||
case EQUAL:
|
||||
Expression expr;
|
||||
@ -185,7 +186,7 @@ public class TestGPU {
|
||||
}
|
||||
if (!StaticVars.debugOn) {
|
||||
d.destroy();
|
||||
System.exit(0);
|
||||
DSystem.exit(0);
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
@ -7,8 +7,6 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -25,10 +23,9 @@ import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.nevec.rjm.BigDecimalMath;
|
||||
@ -38,7 +35,6 @@ import org.warp.picalculator.gui.graphicengine.BinaryFont;
|
||||
import org.warp.picalculator.math.Function;
|
||||
import org.warp.picalculator.math.FunctionOperator;
|
||||
import org.warp.picalculator.math.FunctionSingle;
|
||||
import org.warp.picalculator.math.MathematicalSymbols;
|
||||
import org.warp.picalculator.math.functions.Division;
|
||||
import org.warp.picalculator.math.functions.Expression;
|
||||
import org.warp.picalculator.math.functions.Multiplication;
|
||||
@ -52,9 +48,6 @@ import org.warp.picalculator.math.functions.equations.Equation;
|
||||
import org.warp.picalculator.math.functions.equations.EquationsSystemPart;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.lingala.zip4j.core.ZipFile;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.util.Zip4jConstants;
|
||||
|
||||
public class Utils {
|
||||
|
||||
@ -65,113 +58,13 @@ public class Utils {
|
||||
public static final int scaleMode = BigDecimal.ROUND_HALF_UP;
|
||||
public static final RoundingMode scaleMode2 = RoundingMode.HALF_UP;
|
||||
|
||||
public static AdvancedOutputStream out = new AdvancedOutputStream();
|
||||
|
||||
public static final int OUTPUTLEVEL_NODEBUG = 0;
|
||||
public static final int OUTPUTLEVEL_DEBUG_MIN = 1;
|
||||
public static final int OUTPUTLEVEL_DEBUG_VERBOSE = 4;
|
||||
public static boolean debugThirdScreen;
|
||||
public static boolean headlessOverride = false;
|
||||
private static String OS = System.getProperty("os.name").toLowerCase();
|
||||
public static String forceEngine;
|
||||
public static boolean msDosMode;
|
||||
public static boolean debugCache;
|
||||
public static boolean newtMode = true;
|
||||
|
||||
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(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, String 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();
|
||||
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 LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss.SSS"));
|
||||
}
|
||||
|
||||
int before = 0;
|
||||
boolean due = false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isInArray(String ch, String[] a) {
|
||||
boolean contains = false;
|
||||
for (final String c : a) {
|
||||
@ -760,7 +653,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static boolean isRunningOnRaspberry() {
|
||||
if (System.getProperty("os.name").equals("Linux")) {
|
||||
if (PlatformUtils.osName.equals("Linux")) {
|
||||
final File file = new File("/etc", "os-release");
|
||||
try (FileInputStream fis = new FileInputStream(file); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fis))) {
|
||||
String string;
|
||||
@ -779,7 +672,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static boolean isWindows() {
|
||||
return (OS.indexOf("win") >= 0);
|
||||
return (PlatformUtils.osName.indexOf("win") >= 0);
|
||||
}
|
||||
|
||||
public static void gc() {
|
||||
@ -861,46 +754,6 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public static Path getJarDirectory() {
|
||||
return Paths.get("").toAbsolutePath();
|
||||
}
|
||||
|
@ -2,8 +2,9 @@ package org.warp.picalculator.device;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.PlatformUtils;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.device.chip.ParallelToSerial;
|
||||
import org.warp.picalculator.device.chip.SerialToParallel;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
@ -12,7 +13,8 @@ import org.warp.picalculator.gui.screens.KeyboardDebugScreen;
|
||||
import org.warp.picalculator.gui.screens.MarioScreen;
|
||||
import org.warp.picalculator.gui.screens.Screen;
|
||||
|
||||
import com.pi4j.wiringpi.Gpio;
|
||||
import org.warp.picalculator.deps.DGpio;
|
||||
import org.warp.picalculator.deps.jogamp.DJogamp;
|
||||
|
||||
public class Keyboard {
|
||||
public static volatile boolean alpha = false;
|
||||
@ -54,19 +56,19 @@ public class Keyboard {
|
||||
}
|
||||
} catch (final InterruptedException e) {}
|
||||
} else {
|
||||
Gpio.pinMode(CLK_INH_pin, Gpio.OUTPUT);
|
||||
Gpio.pinMode(RCK_pin, Gpio.OUTPUT);
|
||||
Gpio.pinMode(SER_pin, Gpio.OUTPUT);
|
||||
Gpio.pinMode(SH_LD_pin, Gpio.OUTPUT);
|
||||
Gpio.pinMode(SCK_and_CLK_pin, Gpio.OUTPUT);
|
||||
Gpio.pinMode(QH_pin, Gpio.INPUT);
|
||||
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);
|
||||
|
||||
Gpio.digitalWrite(CLK_INH_pin, false);
|
||||
Gpio.digitalWrite(RCK_pin, false);
|
||||
Gpio.digitalWrite(SER_pin, false);
|
||||
Gpio.digitalWrite(SH_LD_pin, false);
|
||||
Gpio.digitalWrite(SCK_and_CLK_pin, false);
|
||||
Gpio.digitalWrite(QH_pin, false);
|
||||
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);
|
||||
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*/);
|
||||
|
||||
@ -97,12 +99,12 @@ public class Keyboard {
|
||||
}
|
||||
}
|
||||
});
|
||||
kt.setName("Keyboard thread");
|
||||
PlatformUtils.setThreadName(kt, "Keyboard thread");
|
||||
kt.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
kt.setDaemon(true);
|
||||
PlatformUtils.setDaemon(kt);
|
||||
kt.start();
|
||||
}
|
||||
|
||||
|
||||
private synchronized static void debugKeyPressed(int keyCode) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
@ -204,7 +206,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.LOGARITHM);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_ENTER:
|
||||
case DJogamp.VK_ENTER:
|
||||
case KeyEvent.VK_ENTER:
|
||||
if (Keyboard.shift) {
|
||||
Keyboard.keyPressed(Key.STEP);
|
||||
@ -304,7 +306,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_ADD:
|
||||
case DJogamp.VK_ADD:
|
||||
case KeyEvent.VK_ADD:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.PLUS);
|
||||
@ -314,7 +316,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_SUBTRACT:
|
||||
case DJogamp.VK_SUBTRACT:
|
||||
case KeyEvent.VK_SUBTRACT:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.MINUS);
|
||||
@ -322,7 +324,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY:
|
||||
case DJogamp.VK_MULTIPLY:
|
||||
case KeyEvent.VK_MULTIPLY:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.MULTIPLY);
|
||||
@ -330,7 +332,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_DIVIDE:
|
||||
case DJogamp.VK_DIVIDE:
|
||||
case KeyEvent.VK_DIVIDE:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.DIVIDE);
|
||||
@ -345,7 +347,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_DELETE:
|
||||
case DJogamp.VK_DELETE:
|
||||
case KeyEvent.VK_DELETE:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.RESET);
|
||||
@ -353,7 +355,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_LEFT:
|
||||
case DJogamp.VK_LEFT:
|
||||
case KeyEvent.VK_LEFT:
|
||||
//LEFT
|
||||
row = 2;
|
||||
@ -365,7 +367,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_RIGHT:
|
||||
case DJogamp.VK_RIGHT:
|
||||
case KeyEvent.VK_RIGHT:
|
||||
//RIGHT
|
||||
row = 2;
|
||||
@ -377,7 +379,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_UP:
|
||||
case DJogamp.VK_UP:
|
||||
case KeyEvent.VK_UP:
|
||||
//UP
|
||||
row = 1;
|
||||
@ -389,7 +391,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_DOWN:
|
||||
case DJogamp.VK_DOWN:
|
||||
case KeyEvent.VK_DOWN:
|
||||
//DOWN
|
||||
row = 3;
|
||||
@ -412,7 +414,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_NUMPAD4:
|
||||
case DJogamp.VK_NUMPAD4:
|
||||
case KeyEvent.VK_NUMPAD4:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.HISTORY_BACK);
|
||||
@ -420,7 +422,7 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_NUMPAD6:
|
||||
case DJogamp.VK_NUMPAD6:
|
||||
case KeyEvent.VK_NUMPAD6:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.HISTORY_FORWARD);
|
||||
@ -435,26 +437,26 @@ public class Keyboard {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
}
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_SHIFT:
|
||||
case DJogamp.VK_SHIFT:
|
||||
case KeyEvent.VK_SHIFT:
|
||||
Keyboard.keyPressed(Key.SHIFT);
|
||||
break;
|
||||
case KeyEvent.VK_A:
|
||||
Keyboard.keyPressed(Key.ALPHA);
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_NUMPAD1:
|
||||
case DJogamp.VK_NUMPAD1:
|
||||
case KeyEvent.VK_NUMPAD1:
|
||||
Keyboard.keyPressed(Key.SQRT);
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_NUMPAD2:
|
||||
case DJogamp.VK_NUMPAD2:
|
||||
case KeyEvent.VK_NUMPAD2:
|
||||
Keyboard.keyPressed(Key.ROOT);
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_NUMPAD3:
|
||||
case DJogamp.VK_NUMPAD3:
|
||||
case KeyEvent.VK_NUMPAD3:
|
||||
Keyboard.keyPressed(Key.POWER_OF_2);
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_NUMPAD5:
|
||||
case DJogamp.VK_NUMPAD5:
|
||||
case KeyEvent.VK_NUMPAD5:
|
||||
Keyboard.keyPressed(Key.POWER_OF_x);
|
||||
break;
|
||||
@ -468,14 +470,14 @@ public class Keyboard {
|
||||
int col = 1;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_LEFT:
|
||||
case DJogamp.VK_LEFT:
|
||||
case KeyEvent.VK_LEFT:
|
||||
//LEFT
|
||||
row = 2;
|
||||
col = 3;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_RIGHT:
|
||||
case DJogamp.VK_RIGHT:
|
||||
case KeyEvent.VK_RIGHT:
|
||||
//RIGHT
|
||||
row = 2;
|
||||
@ -483,14 +485,14 @@ public class Keyboard {
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
System.out.println("RELEASE");
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_UP:
|
||||
case DJogamp.VK_UP:
|
||||
case KeyEvent.VK_UP:
|
||||
//UP
|
||||
row = 1;
|
||||
col = 4;
|
||||
Keyboard.debugKeysDown[row - 1][col - 1] = false;
|
||||
break;
|
||||
case com.jogamp.newt.event.KeyEvent.VK_DOWN:
|
||||
case DJogamp.VK_DOWN:
|
||||
case KeyEvent.VK_DOWN:
|
||||
//DOWN
|
||||
row = 3;
|
||||
@ -614,12 +616,12 @@ public class Keyboard {
|
||||
|
||||
public static void stopKeyboard() {
|
||||
if (StaticVars.debugOn == false) {
|
||||
Gpio.digitalWrite(33, false);
|
||||
Gpio.digitalWrite(35, false);
|
||||
Gpio.digitalWrite(36, false);
|
||||
Gpio.digitalWrite(37, false);
|
||||
Gpio.digitalWrite(38, false);
|
||||
Gpio.digitalWrite(40, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +705,7 @@ public class Keyboard {
|
||||
refreshRequest = true;
|
||||
}
|
||||
} else if (!done) {
|
||||
Utils.out.println(1, "Key " + k.toString() + " ignored.");
|
||||
ConsoleUtils.out.println(1, "Key " + k.toString() + " ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,7 +735,7 @@ public class Keyboard {
|
||||
refreshRequest = true;
|
||||
}
|
||||
} else if (!done) {
|
||||
Utils.out.println(1, "Key " + k.toString() + " ignored.");
|
||||
ConsoleUtils.out.println(1, "Key " + k.toString() + " ignored.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package org.warp.picalculator.device;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.deps.DGpio;
|
||||
import org.warp.picalculator.gui.HardwareDisplay;
|
||||
import com.pi4j.wiringpi.Gpio;
|
||||
|
||||
public class PIHardwareDisplay implements HardwareDisplay {
|
||||
|
||||
@ -16,10 +16,10 @@ public class PIHardwareDisplay implements HardwareDisplay {
|
||||
@Override
|
||||
public void setBrightness(double value) {
|
||||
if (StaticVars.debugOn == false) {
|
||||
Gpio.pwmWrite(12, (int) Math.ceil(value * 1024f));
|
||||
DGpio.pwmWrite(12, (int) Math.ceil(value * 1024f));
|
||||
// SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10)));
|
||||
} else {
|
||||
Utils.out.println(1, "Brightness: " + value);
|
||||
ConsoleUtils.out.println(1, "Brightness: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.warp.picalculator.device.chip;
|
||||
|
||||
import com.pi4j.wiringpi.Gpio;
|
||||
import org.warp.picalculator.deps.DGpio;
|
||||
|
||||
public class ParallelToSerial {
|
||||
|
||||
@ -18,16 +18,16 @@ public class ParallelToSerial {
|
||||
|
||||
public boolean[] read() {
|
||||
final boolean[] data = new boolean[8];
|
||||
Gpio.digitalWrite(CLK_INH, Gpio.HIGH);
|
||||
Gpio.digitalWrite(SH_LD, Gpio.LOW);
|
||||
Gpio.delayMicroseconds(1);
|
||||
Gpio.digitalWrite(SH_LD, Gpio.HIGH);
|
||||
Gpio.digitalWrite(CLK_INH, Gpio.LOW);
|
||||
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--) {
|
||||
Gpio.digitalWrite(CLK, Gpio.HIGH);
|
||||
Gpio.digitalWrite(CLK, Gpio.LOW);
|
||||
data[i] = Gpio.digitalRead(QH) == Gpio.HIGH ? true : false;
|
||||
DGpio.digitalWrite(CLK, DGpio.HIGH);
|
||||
DGpio.digitalWrite(CLK, DGpio.LOW);
|
||||
data[i] = DGpio.digitalRead(QH) == DGpio.HIGH ? true : false;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.warp.picalculator.device.chip;
|
||||
|
||||
import com.pi4j.wiringpi.Gpio;
|
||||
import org.warp.picalculator.deps.DGpio;
|
||||
|
||||
public class SerialToParallel {
|
||||
private final int RCK; //Storage register clock pin (latch pin)
|
||||
@ -17,15 +17,15 @@ public class SerialToParallel {
|
||||
if (data.length != 8) {
|
||||
return;
|
||||
} else {
|
||||
Gpio.digitalWrite(RCK, Gpio.LOW);
|
||||
DGpio.digitalWrite(RCK, DGpio.LOW);
|
||||
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
Gpio.digitalWrite(SCK, Gpio.LOW);
|
||||
Gpio.digitalWrite(SER, data[i]);
|
||||
Gpio.digitalWrite(SCK, Gpio.HIGH);
|
||||
DGpio.digitalWrite(SCK, DGpio.LOW);
|
||||
DGpio.digitalWrite(SER, data[i]);
|
||||
DGpio.digitalWrite(SCK, DGpio.HIGH);
|
||||
}
|
||||
|
||||
Gpio.digitalWrite(RCK, Gpio.HIGH);
|
||||
DGpio.digitalWrite(RCK, DGpio.HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import javax.imageio.ImageIO;
|
||||
|
||||
import org.warp.picalculator.Main;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.deps.DSystem;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -35,7 +36,7 @@ public class RAWFont {
|
||||
loadFont("/font_" + name + ".rft");
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
DSystem.exit(1);
|
||||
}
|
||||
chars32 = new int[(maxBound - minBound) * charIntCount];
|
||||
for (int charIndex = 0; charIndex < maxBound - minBound; charIndex++) {
|
||||
@ -113,7 +114,7 @@ public class RAWFont {
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
System.out.println(string);
|
||||
System.exit(-1);
|
||||
DSystem.exit(-1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.warp.picalculator.gui;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
@ -83,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 {
|
||||
Utils.out.println(1, "Brightness error");
|
||||
ConsoleUtils.out.println(1, "Brightness error");
|
||||
}
|
||||
|
||||
padding += 18 + 6;
|
||||
|
@ -5,20 +5,18 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.PlatformUtils;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.deps.DEngine;
|
||||
import org.warp.picalculator.deps.DSystem;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.gui.graphicengine.BinaryFont;
|
||||
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.Renderer;
|
||||
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
|
||||
import org.warp.picalculator.gui.graphicengine.Skin;
|
||||
import org.warp.picalculator.gui.graphicengine.cpu.CPUEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.framebuffer.FBEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.gpu.GPUEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitEngine;
|
||||
import org.warp.picalculator.gui.graphicengine.headless256.Headless256Engine;
|
||||
import org.warp.picalculator.gui.graphicengine.headless8.Headless8Engine;
|
||||
import org.warp.picalculator.gui.graphicengine.nogui.NoGuiEngine;
|
||||
import org.warp.picalculator.gui.screens.Screen;
|
||||
|
||||
@ -67,7 +65,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
DSystem.exit(0);
|
||||
}
|
||||
|
||||
setScreen(screen);
|
||||
@ -114,37 +112,37 @@ public final class DisplayManager implements RenderingLoop {
|
||||
GraphicEngine d;
|
||||
d = new NoGuiEngine();
|
||||
if (d.isSupported()) {
|
||||
Utils.out.println(1, "Using NoGui Graphic Engine");
|
||||
ConsoleUtils.out.println(1, "Using NoGui Graphic Engine");
|
||||
return d;
|
||||
}
|
||||
if (!StaticVars.debugOn) {
|
||||
d = new FBEngine();
|
||||
d = DEngine.newFBEngine();
|
||||
if (d.isSupported()) {
|
||||
Utils.out.println(1, "Using FB Graphic Engine");
|
||||
ConsoleUtils.out.println(1, "Using FB Graphic Engine");
|
||||
return d;
|
||||
}
|
||||
}
|
||||
d = new GPUEngine();
|
||||
d = DEngine.newGPUEngine();
|
||||
if (d.isSupported()) {
|
||||
Utils.out.println(1, "Using GPU Graphic Engine");
|
||||
ConsoleUtils.out.println(1, "Using GPU Graphic Engine");
|
||||
return d;
|
||||
}
|
||||
d = new CPUEngine();
|
||||
d = DEngine.newCPUEngine();
|
||||
if (d.isSupported()) {
|
||||
Utils.out.println(1, "Using CPU Graphic Engine");
|
||||
ConsoleUtils.out.println(1, "Using CPU Graphic Engine");
|
||||
return d;
|
||||
}
|
||||
d = new Headless24bitEngine();
|
||||
d = DEngine.newHeadless24bitEngine();
|
||||
if (d.isSupported()) {
|
||||
System.err.println("Using Headless 24 bit Engine! This is a problem! No other graphic engines are available.");
|
||||
return d;
|
||||
}
|
||||
d = new Headless256Engine();
|
||||
d = DEngine.newHeadless256Engine();
|
||||
if (d.isSupported()) {
|
||||
System.err.println("Using Headless 256 Engine! This is a problem! No other graphic engines are available.");
|
||||
return d;
|
||||
}
|
||||
d = new Headless8Engine();
|
||||
d = DEngine.newHeadless8Engine();
|
||||
if (d.isSupported()) {
|
||||
System.err.println("Using Headless basic Engine! This is a problem! No other graphic engines are available.");
|
||||
return d;
|
||||
@ -178,7 +176,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
DSystem.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +201,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
DSystem.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,7 +370,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
screen.initialize();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
DSystem.exit(0);
|
||||
}
|
||||
|
||||
//Working thread
|
||||
@ -449,8 +447,8 @@ public final class DisplayManager implements RenderingLoop {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
workThread.setDaemon(true);
|
||||
workThread.setName("Work thread");
|
||||
PlatformUtils.setDaemon(workThread);
|
||||
PlatformUtils.setThreadName(workThread, "Work thread");
|
||||
workThread.start();
|
||||
|
||||
engine.start(getDrawable());
|
||||
|
@ -2,6 +2,8 @@ package org.warp.picalculator.gui.expression.blocks;
|
||||
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.Errors;
|
||||
import org.warp.picalculator.PlatformUtils;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.gui.GraphicalElement;
|
||||
import org.warp.picalculator.gui.expression.Caret;
|
||||
import org.warp.picalculator.gui.expression.CaretState;
|
||||
@ -352,7 +354,7 @@ public class BlockContainer implements GraphicalElement {
|
||||
|
||||
private static void checkInitialized() {
|
||||
if (!initialized) {
|
||||
throw new ExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!");
|
||||
PlatformUtils.throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,10 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
private void retrieveValue() {
|
||||
type = ic.variableTypes.getOrDefault(ch, V_TYPE.VARIABLE);
|
||||
type = ic.variableTypes.get(ch);
|
||||
if (type == null) {
|
||||
type = V_TYPE.VARIABLE;
|
||||
}
|
||||
typeDirtyID = ic.variableTypeDirtyID;
|
||||
if (menu != null) {
|
||||
menu.mustRefreshMenu = true;
|
||||
|
@ -11,6 +11,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.gui.graphicengine.BinaryFont;
|
||||
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
||||
@ -62,7 +63,7 @@ public class CPUFont implements BinaryFont {
|
||||
}
|
||||
|
||||
private void load(String path, boolean onlyRaw) throws IOException {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_MIN, "Loading font " + path);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Loading font " + path);
|
||||
loadFont(path);
|
||||
if (!onlyRaw) {
|
||||
chars32 = new int[(intervalsTotalSize) * charIntCount];
|
||||
|
@ -3,10 +3,14 @@ package org.warp.picalculator.gui.screens;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.Errors;
|
||||
import org.warp.picalculator.PlatformUtils;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.deps.DSystem;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
@ -67,7 +71,7 @@ public class MathInputScreen extends Screen {
|
||||
BlockContainer.initializeFonts(DisplayManager.INSTANCE.engine.loadFont("norm"), DisplayManager.INSTANCE.engine.loadFont("smal"));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
DSystem.exit(1);
|
||||
}
|
||||
|
||||
userInput = new NormalInputContainer(ic);
|
||||
@ -168,7 +172,7 @@ public class MathInputScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(Key k) {
|
||||
Utils.out.println(1, k.toString());
|
||||
ConsoleUtils.out.println(1, k.toString());
|
||||
try {
|
||||
switch (k) {
|
||||
case OK:
|
||||
@ -198,7 +202,7 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
if (DisplayManager.INSTANCE.error != null) {
|
||||
//TODO: make the error management a global API rather than being relegated to this screen.
|
||||
Utils.out.println(1, "Resetting after error...");
|
||||
ConsoleUtils.out.println(1, "Resetting after error...");
|
||||
DisplayManager.INSTANCE.error = null;
|
||||
calc.f = null;
|
||||
calc.f2 = null;
|
||||
@ -220,13 +224,13 @@ public class MathInputScreen extends Screen {
|
||||
calc.f2.clear();
|
||||
}
|
||||
calc.f.add(expr);
|
||||
Utils.out.println(2, "INPUT: " + expr);
|
||||
ConsoleUtils.out.println(2, "INPUT: " + expr);
|
||||
final MathSolver ms = new MathSolver(expr);
|
||||
final ObjectArrayList<ObjectArrayList<Function>> resultSteps = ms.solveAllSteps();
|
||||
resultSteps.add(0, Utils.newArrayList(expr));
|
||||
final ObjectArrayList<Function> resultExpressions = resultSteps.get(resultSteps.size() - 1);
|
||||
for (final Function rr : resultExpressions) {
|
||||
Utils.out.println(0, "RESULT: " + rr.toString());
|
||||
ConsoleUtils.out.println(0, "RESULT: " + rr.toString());
|
||||
}
|
||||
final ObjectArrayList<ObjectArrayList<Block>> resultBlocks = MathParser.parseOutput(calc, resultExpressions);
|
||||
result.setContentAsMultipleGroups(resultBlocks);
|
||||
@ -236,7 +240,7 @@ public class MathInputScreen extends Screen {
|
||||
// });
|
||||
}
|
||||
} catch (final InterruptedException ex) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
|
||||
} catch (final Exception ex) {
|
||||
if (StaticVars.debugOn) {
|
||||
ex.printStackTrace();
|
||||
@ -244,17 +248,14 @@ public class MathInputScreen extends Screen {
|
||||
throw new Error(Errors.SYNTAX_ERROR);
|
||||
}
|
||||
} catch (final Error e) {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
d.errorStackTrace = sw.toString().toUpperCase().replace("\t", " ").replace("\r", "").split("\n");
|
||||
d.errorStackTrace = PlatformUtils.stacktraceToString(e);
|
||||
DisplayManager.INSTANCE.error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
}
|
||||
computingResult = false;
|
||||
});
|
||||
computingThread.setName("Computing Thread");
|
||||
computingThread.setDaemon(true);
|
||||
PlatformUtils.setThreadName(computingThread, "Computing Thread");
|
||||
PlatformUtils.setDaemon(computingThread);
|
||||
computingThread.setPriority(Thread.NORM_PRIORITY + 3);
|
||||
computingThread.start();
|
||||
return true;
|
||||
@ -387,7 +388,7 @@ public class MathInputScreen extends Screen {
|
||||
result.clear();
|
||||
currentStep = 0;
|
||||
if (DisplayManager.INSTANCE.error != null) {
|
||||
Utils.out.println(1, "Resetting after error...");
|
||||
ConsoleUtils.out.println(1, "Resetting after error...");
|
||||
DisplayManager.INSTANCE.error = null;
|
||||
}
|
||||
return true;
|
||||
@ -661,9 +662,9 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
}
|
||||
});
|
||||
ct.setName("Variables user-input queue thread");
|
||||
PlatformUtils.setThreadName(ct, "Variables user-input queue thread");
|
||||
ct.setPriority(Thread.MIN_PRIORITY);
|
||||
ct.setDaemon(true);
|
||||
PlatformUtils.setDaemon(ct);
|
||||
ct.start();
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.warp.picalculator.math.parser;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.Errors;
|
||||
import org.warp.picalculator.IntegerObj;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.gui.expression.blocks.Block;
|
||||
import org.warp.picalculator.gui.expression.containers.InputContainer;
|
||||
import org.warp.picalculator.math.Function;
|
||||
@ -85,16 +85,16 @@ public class MathParser {
|
||||
Function lastElement;
|
||||
|
||||
if (StaticVars.debugOn) {
|
||||
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
|
||||
ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
|
||||
for (final Function f : functionsList) {
|
||||
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
|
||||
ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
|
||||
}
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
|
||||
}
|
||||
|
||||
for (final MathParserStep step : steps) {
|
||||
if (StaticVars.debugOn) {
|
||||
Utils.out.println(2, "Stack fixing step \"" + step.getStepName() + "\"");
|
||||
ConsoleUtils.out.println(2, "Stack fixing step \"" + step.getStepName() + "\"");
|
||||
}
|
||||
final int stepQty = step.requiresReversedIteration() ? -1 : 1,
|
||||
initialIndex = step.requiresReversedIteration() ? functionsList.size() - 1 : 0;
|
||||
@ -116,11 +116,11 @@ public class MathParser {
|
||||
} while (lastLoopDidSomething);
|
||||
|
||||
if (StaticVars.debugOn) {
|
||||
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
|
||||
ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "\tStatus: ");
|
||||
for (final Function f : functionsList) {
|
||||
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
|
||||
ConsoleUtils.out.print(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, f.toString());
|
||||
}
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.ZipUtils;
|
||||
import org.warp.picalculator.deps.StorageUtils;
|
||||
import org.warp.picalculator.deps.DJDTCompiler;
|
||||
import org.warp.picalculator.deps.DSystem;
|
||||
import org.warp.picalculator.math.Function;
|
||||
import org.warp.picalculator.math.MathContext;
|
||||
import org.warp.picalculator.math.functions.Expression;
|
||||
@ -35,7 +40,7 @@ public class RulesManager {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void initialize() {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules");
|
||||
ConsoleUtils.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<>();
|
||||
@ -43,11 +48,11 @@ public class RulesManager {
|
||||
try {
|
||||
boolean compiledSomething = false;
|
||||
final Path defaultRulesPath = Utils.getResource("/default-rules.lst");
|
||||
if (!Files.exists(defaultRulesPath)) {
|
||||
if (!StorageUtils.exists(defaultRulesPath)) {
|
||||
throw new FileNotFoundException("default-rules.lst not found!");
|
||||
}
|
||||
final List<String> ruleLines = new ArrayList<>();
|
||||
final Path rulesPath = Paths.get("rules/");
|
||||
final Path rulesPath = StorageUtils.get("rules/");
|
||||
if (rulesPath.toFile().exists()) {
|
||||
try (Stream<Path> paths = Files.walk(rulesPath)) {
|
||||
paths.filter(Files::isRegularFile).forEach((Path p) -> {
|
||||
@ -55,7 +60,7 @@ public class RulesManager {
|
||||
String path = rulesPath.relativize(p).toString();
|
||||
path = path.substring(0, path.length() - ".java".length());
|
||||
ruleLines.add(path);
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Found external rule: " + p.toAbsolutePath().toString());
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Found external rule: " + p.toAbsolutePath().toString());
|
||||
System.err.println(path);
|
||||
}
|
||||
});
|
||||
@ -74,7 +79,7 @@ public class RulesManager {
|
||||
if (tDir.toFile().exists()) {
|
||||
tDir.toFile().delete();
|
||||
}
|
||||
Utils.unzip(cacheFilePath.toString(), tDir.getParent().toString(), "");
|
||||
ZipUtils.unzip(cacheFilePath.toString(), tDir.getParent().toString(), "");
|
||||
useCache = !Utils.debugCache;
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@ -85,7 +90,7 @@ public class RulesManager {
|
||||
final String[] ruleDetails = rulesLine.split(",", 1);
|
||||
final String ruleName = ruleDetails[0];
|
||||
final String ruleNameEscaped = ruleName.replace(".", "_");
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Evaluating /rules/" + ruleNameEscaped + ".java");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Evaluating /rules/" + ruleNameEscaped + ".java");
|
||||
final String pathWithoutExtension = "/rules/" + ruleNameEscaped;
|
||||
final String scriptFile = pathWithoutExtension + ".java";
|
||||
final InputStream resourcePath = Utils.getResourceStream(scriptFile);
|
||||
@ -95,18 +100,18 @@ public class RulesManager {
|
||||
Rule r = null;
|
||||
if (useCache) {
|
||||
try {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Trying to load cached rule");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Trying to load cached rule");
|
||||
r = loadClassRuleFromSourceFile(scriptFile, tDir);
|
||||
if (r != null) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Loaded cached rule");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "Loaded cached rule");
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", ruleName, "Can't load the rule!");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", ruleName, "Can't load the rule!");
|
||||
}
|
||||
}
|
||||
if (r == null || !useCache) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "This rule is not cached. Compiling");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "RulesManager", ruleName, "This rule is not cached. Compiling");
|
||||
try {
|
||||
r = compileJavaRule(scriptFile, tDir);
|
||||
compiledSomething = true;
|
||||
@ -121,17 +126,17 @@ public class RulesManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loaded all the rules successfully");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loaded all the rules successfully");
|
||||
if (compiledSomething) {
|
||||
if (cacheFilePath.toFile().exists()) {
|
||||
cacheFilePath.toFile().delete();
|
||||
}
|
||||
Utils.zip(tDir.toString(), cacheFilePath.toString(), "");
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Cached the compiled rules");
|
||||
ZipUtils.zip(tDir.toString(), cacheFilePath.toString(), "");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Cached the compiled rules");
|
||||
}
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
DSystem.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +161,7 @@ public class RulesManager {
|
||||
tFileJava.toFile().delete();
|
||||
}
|
||||
Files.write(tFileJava, javaCode.getBytes("UTF-8"), StandardOpenOption.WRITE, StandardOpenOption.CREATE);
|
||||
final boolean compiled = org.eclipse.jdt.internal.compiler.batch.Main.compile(new String[] { "-nowarn", "-1.8", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err), null);
|
||||
final boolean compiled = DJDTCompiler.compile(new String[] { "-nowarn", "-1.8", tFileJava.toString() }, new PrintWriter(System.out), new PrintWriter(System.err));
|
||||
if (Utils.debugCache) {
|
||||
tFileJava.toFile().deleteOnExit();
|
||||
} else {
|
||||
@ -229,6 +234,6 @@ public class RulesManager {
|
||||
|
||||
public static void addRule(Rule rule) {
|
||||
rules[rule.getRuleType().ordinal()].add(rule);
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_NODEBUG, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule");
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", rule.getRuleName(), "Loaded as " + rule.getRuleType() + " rule");
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ package org.warp.picalculator.math.solver;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.warp.picalculator.ConsoleUtils;
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.deps.DAtomicInteger;
|
||||
import org.warp.picalculator.math.Function;
|
||||
import org.warp.picalculator.math.rules.Rule;
|
||||
import org.warp.picalculator.math.rules.RuleType;
|
||||
@ -16,7 +17,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
public class MathSolver {
|
||||
|
||||
private final Function initialFunction;
|
||||
private final AtomicInteger stepState = new AtomicInteger(0);
|
||||
private final DAtomicInteger stepState = new DAtomicInteger(0);
|
||||
private int stepStateRepetitions = 0;
|
||||
private int consecutiveNullSteps = 0;
|
||||
|
||||
@ -36,11 +37,11 @@ public class MathSolver {
|
||||
public ObjectArrayList<ObjectArrayList<Function>> solveAllSteps() throws InterruptedException, Error {
|
||||
final ObjectArrayList<ObjectArrayList<Function>> steps = new ObjectArrayList<>();
|
||||
ObjectArrayList<Function> lastFnc = null, currFnc = new ObjectArrayList<>();
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Solving all steps. Input: " + initialFunction.toString());
|
||||
ConsoleUtils.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 AtomicInteger stepState = new AtomicInteger(0);
|
||||
final DAtomicInteger stepState = new DAtomicInteger(0);
|
||||
do {
|
||||
final ObjectArrayList<Function>[] currFncHistory = new ObjectArrayList[stepStates.length];
|
||||
final String stepName = "Step " + stepNumber;
|
||||
@ -62,11 +63,11 @@ public class MathSolver {
|
||||
}
|
||||
lastFnc = currFnc;
|
||||
initStepState = stepState.get();
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Starting step " + stepStates[initStepState] + ". Input: " + currFnc);
|
||||
final ObjectArrayList<Function> stepResult = solveStep(lastFnc, stepState);
|
||||
if (stepResult != null) {
|
||||
for (final Function result : stepResult) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString());
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, result.toString());
|
||||
}
|
||||
currFnc = stepResult;
|
||||
steps.add(currFnc);
|
||||
@ -74,22 +75,22 @@ public class MathSolver {
|
||||
endStepState = stepState.get();
|
||||
stepNumber++;
|
||||
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result: " + stepResult);
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Step result details: Consecutive steps that did nothing: " + consecutiveNullSteps + ", this step did " + stepStateRepetitions + " simplifications.");
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, "Next step state: " + stepStates[endStepState]);
|
||||
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]);
|
||||
if (StaticVars.debugOn) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[0][endStepState]) ? "" : "not ") + "equals to [0]:" + lastFunctions[0][endStepState]);
|
||||
ConsoleUtils.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) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", stepName, currFnc + " is " + (checkEquals(currFnc, lastFunctions[1][endStepState]) ? "" : "not ") + "equals to [1]:" + lastFunctions[1][endStepState]);
|
||||
ConsoleUtils.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) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + consecutiveNullSteps + " >= " + stepStates.length);
|
||||
} else if (checkEquals(currFnc, lastFunctions[0][endStepState])) {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [0]:" + lastFunctions[0][endStepState]);
|
||||
} else {
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", "Loop ended because " + currFnc + " is equals to [1]:" + lastFunctions[1][endStepState]);
|
||||
}
|
||||
return steps;
|
||||
}
|
||||
@ -117,7 +118,7 @@ public class MathSolver {
|
||||
return solveStep(fncs, stepState);
|
||||
}
|
||||
|
||||
private ObjectArrayList<Function> solveStep(ObjectArrayList<Function> fncs, AtomicInteger stepState)
|
||||
private ObjectArrayList<Function> solveStep(ObjectArrayList<Function> fncs, DAtomicInteger stepState)
|
||||
throws InterruptedException, Error {
|
||||
final ObjectArrayList<Function> processedFncs = applyRules(fncs, RuleType.EXISTENCE); // Apply existence rules before everything
|
||||
if (processedFncs != null) {
|
||||
@ -239,14 +240,14 @@ public class MathSolver {
|
||||
if (appliedRules.isEmpty()) results = null;
|
||||
if (StaticVars.debugOn & results != null && !appliedRules.isEmpty()) {
|
||||
StringBuilder rulesStr = new StringBuilder();
|
||||
appliedRules.forEach((r) -> {
|
||||
for(Rule r : appliedRules) {
|
||||
rulesStr.append(r.getRuleName());
|
||||
rulesStr.append(',');
|
||||
});
|
||||
}
|
||||
if (rulesStr.length() > 0) {
|
||||
rulesStr.setLength(rulesStr.length() - 1);
|
||||
}
|
||||
Utils.out.println(Utils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr);
|
||||
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE, "Math Solver", currentAcceptedRules.toString(), "Applied rules: " + rulesStr);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user