Source code formatted

This commit is contained in:
Andrea Cavalli 2018-09-02 12:45:51 +02:00
parent 28eaab65bd
commit 9c2d5cfb24
83 changed files with 295 additions and 392 deletions

View File

@ -31,9 +31,5 @@
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

10
pom.xml
View File

@ -73,7 +73,7 @@
<dependency> <dependency>
<groupId>org.jogamp.jogl</groupId> <groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId> <artifactId>jogl-all-main</artifactId>
<version>2.3.2</version> <version>2.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jogamp.gluegen</groupId> <groupId>org.jogamp.gluegen</groupId>
@ -88,7 +88,7 @@
<dependency> <dependency>
<groupId>org.fusesource.jansi</groupId> <groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId> <artifactId>jansi</artifactId>
<version>1.15</version> <version>1.17.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.lingala.zip4j</groupId> <groupId>net.lingala.zip4j</groupId>
@ -214,17 +214,17 @@
<dependency> <dependency>
<groupId>org.infinispan</groupId> <groupId>org.infinispan</groupId>
<artifactId>infinispan-jcache</artifactId> <artifactId>infinispan-jcache</artifactId>
<version>8.2.4.Final</version> <version>9.4.0.Beta1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.unimi.dsi</groupId> <groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId> <artifactId>fastutil</artifactId>
<version>7.2.0</version> <version>8.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.8.2</version> <version>2.8.5</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency> <dependency>

View File

@ -184,7 +184,7 @@ public class PngReaderApng extends PngReaderByte {
@Override @Override
protected boolean countChunkTypeAsAncillary(String id) { protected boolean countChunkTypeAsAncillary(String id) {
// we don't count fdat as ancillary data // we don't count fdat as ancillary data
return super.countChunkTypeAsAncillary(id) && !id.equals(id.equals(PngChunkFDAT.ID)); return super.countChunkTypeAsAncillary(id) && !id.equals(""+id.equals(PngChunkFDAT.ID));
} }
}; };

View File

@ -34,7 +34,6 @@ public class ConsoleUtils {
public void println(int level) { public void println(int level) {
if (StaticVars.outputLevel >= level) { if (StaticVars.outputLevel >= level) {
final String time = getTimeString();
if (StaticVars.outputLevel == 0) { if (StaticVars.outputLevel == 0) {
println(System.out); println(System.out);
} else { } else {

View File

@ -1,7 +1,6 @@
package org.warp.picalculator.deps; package org.warp.picalculator.deps;
import org.warp.picalculator.ClassUtils; import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.gui.graphicengine.GraphicEngine; import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.cpu.CPUEngine; import org.warp.picalculator.gui.graphicengine.cpu.CPUEngine;
import org.warp.picalculator.gui.graphicengine.framebuffer.FBEngine; import org.warp.picalculator.gui.graphicengine.framebuffer.FBEngine;

View File

@ -1,7 +1,6 @@
package org.warp.picalculator.deps; package org.warp.picalculator.deps;
import org.warp.picalculator.ClassUtils; import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.ClassUtils.Var;
public class DGpio { public class DGpio {

View File

@ -2,9 +2,6 @@ package org.warp.picalculator.deps;
import java.io.PrintWriter; import java.io.PrintWriter;
import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.ClassUtils.Var;
public class DJDTCompiler { public class DJDTCompiler {
public static boolean compile(String[] strings, PrintWriter printWriter, PrintWriter printWriter2) { public static boolean compile(String[] strings, PrintWriter printWriter, PrintWriter printWriter2) {

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.deps; package org.warp.picalculator.deps;
import java.util.ArrayList;
import java.util.Queue;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
public class DSemaphore extends Semaphore { public class DSemaphore extends Semaphore {

View File

@ -3,7 +3,6 @@ package org.warp.picalculator.deps;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory; import java.net.URLStreamHandlerFactory;
import java.security.AccessControlContext;
public class DURLClassLoader extends URLClassLoader { public class DURLClassLoader extends URLClassLoader {

View File

@ -2,7 +2,6 @@ package org.warp.picalculator.deps;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -17,7 +16,6 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -27,7 +25,6 @@ import java.util.stream.Stream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.warp.picalculator.ClassUtils; import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.boot.Main;
public class StorageUtils { public class StorageUtils {
public static final boolean exists(Path f) { public static final boolean exists(Path f) {

View File

@ -1,8 +1,5 @@
package org.warp.picalculator.deps.jogamp; package org.warp.picalculator.deps.jogamp;
import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.ClassUtils.Var;
public class DJogamp { public class DJogamp {
// //

View File

@ -2,11 +2,8 @@ package org.warp.picalculator.deps.nio;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.warp.picalculator.math.Function;
public class DFiles { public class DFiles {
public static boolean deleteIfExists(DPath path) throws IOException { public static boolean deleteIfExists(DPath path) throws IOException {

View File

@ -23,7 +23,10 @@
*/ */
package cz.adamh.utils; package cz.adamh.utils;
import java.io.*; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.FileSystemNotFoundException; import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
import java.nio.file.Files; import java.nio.file.Files;

View File

@ -576,6 +576,7 @@ public class BigIntegerPoly implements Cloneable {
*/ */
final int l = ldegree(); final int l = ldegree();
if (a.elementAt(l).compareTo(BigInteger.ZERO) != 0) { if (a.elementAt(l).compareTo(BigInteger.ZERO) != 0) {
@SuppressWarnings("deprecation")
final Vector<BigInteger> cand = BigIntegerMath.divisors(a.elementAt(l).abs()); final Vector<BigInteger> cand = BigIntegerMath.divisors(a.elementAt(l).abs());
/* check the divisors (both signs) */ /* check the divisors (both signs) */
@ -615,8 +616,10 @@ public class BigIntegerPoly implements Cloneable {
} }
final BigInteger bsco = a.firstElement().abs(); final BigInteger bsco = a.firstElement().abs();
@SuppressWarnings("deprecation")
final Vector<BigInteger> b = BigIntegerMath.divisors(bsco); final Vector<BigInteger> b = BigIntegerMath.divisors(bsco);
final BigInteger csco = a.lastElement().abs(); final BigInteger csco = a.lastElement().abs();
@SuppressWarnings("deprecation")
final Vector<BigInteger> c = BigIntegerMath.divisors(csco); final Vector<BigInteger> c = BigIntegerMath.divisors(csco);
/* /*

View File

@ -3,8 +3,6 @@ package org.warp.picalculator;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable;
import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
public class CacheUtils { public class CacheUtils {

View File

@ -2,9 +2,7 @@ package org.warp.picalculator;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
public class ClassUtils { public class ClassUtils {

View File

@ -3,8 +3,8 @@ package org.warp.picalculator;
import java.util.function.Function; import java.util.function.Function;
import org.warp.picalculator.boot.StartupArguments; import org.warp.picalculator.boot.StartupArguments;
import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.flow.BehaviorSubject; import org.warp.picalculator.flow.BehaviorSubject;
import org.warp.picalculator.flow.Observable;
public class StaticVars { public class StaticVars {
public static final boolean enableVBO = true; public static final boolean enableVBO = true;
@ -14,7 +14,7 @@ public class StaticVars {
public static boolean haxMode = true; public static boolean haxMode = true;
public static final boolean zoomed = true; public static final boolean zoomed = true;
public static int[] screenPos = new int[] { 0, 0 }; public static int[] screenPos = new int[] { 0, 0 };
public static final int[] screenSize = new int[] {480, 320}; public static final int[] screenSize = new int[] { 480, 320 };
public static boolean debugOn; public static boolean debugOn;
public static int outputLevel = 0; public static int outputLevel = 0;
public static boolean debugWindow2x = false; public static boolean debugWindow2x = false;

View File

@ -5,7 +5,6 @@ import java.io.IOException;
import org.warp.picalculator.deps.DEngine; import org.warp.picalculator.deps.DEngine;
import org.warp.picalculator.deps.DSystem; import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.Keyboard; import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent; import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener; import org.warp.picalculator.event.KeyboardEventListener;

View File

@ -1,7 +1,5 @@
package org.warp.picalculator; package org.warp.picalculator;
import org.warp.picalculator.MmapByteBuffer;
public class TestJNI { public class TestJNI {
public TestJNI() { public TestJNI() {

View File

@ -1,12 +1,8 @@
package org.warp.picalculator; package org.warp.picalculator;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean; import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -15,12 +11,8 @@ import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.Rational; import org.nevec.rjm.Rational;
@ -30,7 +22,6 @@ import org.warp.picalculator.deps.nio.DFiles;
import org.warp.picalculator.deps.nio.DPath; import org.warp.picalculator.deps.nio.DPath;
import org.warp.picalculator.deps.nio.DPaths; import org.warp.picalculator.deps.nio.DPaths;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator; import org.warp.picalculator.math.FunctionOperator;

View File

@ -1,9 +1,9 @@
package org.warp.picalculator.boot; package org.warp.picalculator.boot;
import java.util.Arrays; import java.util.Arrays;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PICalculator; import org.warp.picalculator.PICalculator;
import org.warp.picalculator.flow.TestFlow;
public class Main { public class Main {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
@ -16,7 +16,7 @@ public class Main {
args.setHeadlessEngineForced(args.isHeadlessEngineForced() || args.isHeadless8EngineForced() || args.isHeadless256EngineForced() || args.isHeadless24bitEngineForced()); args.setHeadlessEngineForced(args.isHeadlessEngineForced() || args.isHeadless8EngineForced() || args.isHeadless256EngineForced() || args.isHeadless24bitEngineForced());
return args; return args;
} }
public static void parseArgument(StartupArgumentsImpl args, String arg) { public static void parseArgument(StartupArgumentsImpl args, String arg) {
switch (arg) { switch (arg) {
case "-zoomed": case "-zoomed":

View File

@ -166,6 +166,5 @@ public class StartupArgumentsImpl implements StartupArguments {
public String toString() { public String toString() {
return "StartupArguments = {\n\t\"isRaspberryModeAllowed\": \"" + isRaspberryModeAllowed + "\",\n\tisZoomed\": \"" + isZoomed + "\",\n\tisHeadlessEngineForced\": \"" + isHeadlessEngineForced + "\",\n\tisHeadless8EngineForced\": \"" + isHeadless8EngineForced + "\",\n\tisHeadless256EngineForced\": \"" + isHeadless256EngineForced + "\",\n\tisHeadless24bitEngineForced\": \"" + isHeadless24bitEngineForced + "\",\n\tisCPUEngineForced\": \"" + isCPUEngineForced + "\",\n\tisGPUEngineForced\": \"" + isGPUEngineForced + "\",\n\tisFrameBufferEngineForced\": \"" + isFrameBufferEngineForced + "\",\n\tisNoGUIEngineForced\": \"" + isNoGUIEngineForced + "\",\n\tisHTMLEngineForced\": \"" + isHTMLEngineForced + "\",\n\tisMSDOSModeEnabled\": \"" + isMSDOSModeEnabled + "\",\n\tisVerboseLoggingEnabled\": \"" + isVerboseLoggingEnabled + "\",\n\tisDebugEnabled\": \"" + isDebugEnabled + "\",\n\tisUncached\": \"" + isUncached + "\"\n}"; return "StartupArguments = {\n\t\"isRaspberryModeAllowed\": \"" + isRaspberryModeAllowed + "\",\n\tisZoomed\": \"" + isZoomed + "\",\n\tisHeadlessEngineForced\": \"" + isHeadlessEngineForced + "\",\n\tisHeadless8EngineForced\": \"" + isHeadless8EngineForced + "\",\n\tisHeadless256EngineForced\": \"" + isHeadless256EngineForced + "\",\n\tisHeadless24bitEngineForced\": \"" + isHeadless24bitEngineForced + "\",\n\tisCPUEngineForced\": \"" + isCPUEngineForced + "\",\n\tisGPUEngineForced\": \"" + isGPUEngineForced + "\",\n\tisFrameBufferEngineForced\": \"" + isFrameBufferEngineForced + "\",\n\tisNoGUIEngineForced\": \"" + isNoGUIEngineForced + "\",\n\tisHTMLEngineForced\": \"" + isHTMLEngineForced + "\",\n\tisMSDOSModeEnabled\": \"" + isMSDOSModeEnabled + "\",\n\tisVerboseLoggingEnabled\": \"" + isVerboseLoggingEnabled + "\",\n\tisDebugEnabled\": \"" + isDebugEnabled + "\",\n\tisUncached\": \"" + isUncached + "\"\n}";
} }
} }

View File

@ -5,21 +5,19 @@ import java.awt.event.KeyEvent;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PlatformUtils; import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.deps.DGpio;
import org.warp.picalculator.deps.jogamp.DJogamp;
import org.warp.picalculator.device.chip.ParallelToSerial; import org.warp.picalculator.device.chip.ParallelToSerial;
import org.warp.picalculator.device.chip.SerialToParallel; import org.warp.picalculator.device.chip.SerialToParallel;
import org.warp.picalculator.event.Key; import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent; import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener; import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GUIErrorMessage; import org.warp.picalculator.gui.GUIErrorMessage;
import org.warp.picalculator.gui.screens.KeyboardDebugScreen; import org.warp.picalculator.gui.screens.KeyboardDebugScreen;
import org.warp.picalculator.gui.screens.MarioScreen; import org.warp.picalculator.gui.screens.MarioScreen;
import org.warp.picalculator.gui.screens.Screen; import org.warp.picalculator.gui.screens.Screen;
import org.warp.picalculator.deps.DGpio;
import org.warp.picalculator.deps.jogamp.DJogamp;
public class Keyboard { public class Keyboard {
public static volatile boolean alpha = false; public static volatile boolean alpha = false;
public static volatile boolean shift = false; public static volatile boolean shift = false;
@ -757,11 +755,7 @@ public class Keyboard {
if (k != null) { if (k != null) {
keyPressed(k); keyPressed(k);
} else { } else {
if (false) { keyPressed(Key.NONE);
} else {
keyPressed(Key.NONE);
}
} }
} }
@ -832,29 +826,26 @@ public class Keyboard {
} }
switch (k) { switch (k) {
case SHIFT: case SHIFT:
Keyboard.shift = !Keyboard.shift; if (Keyboard.alpha)
PlatformUtils.shiftChanged(Keyboard.shift); PlatformUtils.alphaChanged(Keyboard.alpha = false);
PlatformUtils.shiftChanged(Keyboard.shift = !Keyboard.shift);
refresh = true; refresh = true;
break; break;
case ALPHA: case ALPHA:
Keyboard.alpha = !Keyboard.alpha; if (Keyboard.shift)
PlatformUtils.alphaChanged(Keyboard.alpha); PlatformUtils.shiftChanged(Keyboard.shift = false);
PlatformUtils.alphaChanged(Keyboard.alpha = !Keyboard.alpha);
refresh = true; refresh = true;
break; break;
default: default:
if (k != Key.NONE) {
if (Keyboard.shift)
PlatformUtils.shiftChanged(Keyboard.shift = false);
if (Keyboard.alpha)
PlatformUtils.alphaChanged(Keyboard.alpha = false);
}
break; break;
} }
if (StaticVars.debugOn == false) {
if (k != Key.SHIFT && Keyboard.shift) {
Keyboard.shift = false;
PlatformUtils.shiftChanged(Keyboard.shift);
refresh = true;
} else if (k != Key.ALPHA && Keyboard.alpha) {
Keyboard.alpha = false;
PlatformUtils.alphaChanged(Keyboard.alpha);
refresh = true;
}
}
if (refresh) { if (refresh) {
refreshRequest = true; refreshRequest = true;
} }

View File

@ -12,7 +12,6 @@ import java.util.logging.Logger;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.warp.picalculator.ClassUtils; import org.warp.picalculator.ClassUtils;
import org.warp.picalculator.PICalculator;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DSystem; import org.warp.picalculator.deps.DSystem;

View File

@ -1,16 +1,5 @@
package org.warp.picalculator.event; package org.warp.picalculator.event;
public enum Key { public enum Key {
POWEROFF, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK, POWEROFF, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK, HISTORY_FORWARD, SURD_MODE, DRG_CYCLE, STEP, SIMPLIFY, BRIGHTNESS_CYCLE, BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2, POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI, SETTINGS, F1, F2, F3, F4, BACK, ZOOM_MODE, LOGARITHM, EULER_NUMBER, LETTER_A, LETTER_B, LETTER_C, LETTER_D, LETTER_E, LETTER_F, LETTER_G, LETTER_H, LETTER_I, LETTER_J, LETTER_K, LETTER_L, LETTER_M, LETTER_N, LETTER_O, LETTER_P, LETTER_Q, LETTER_R, LETTER_S, LETTER_T, LETTER_U, LETTER_V, LETTER_W, LETTER_X, LETTER_Y, LETTER_Z,
HISTORY_FORWARD, SURD_MODE, DRG_CYCLE, STEP, SIMPLIFY, BRIGHTNESS_CYCLE,
BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2, NUM3, NUM4, NUM5,
NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS,
MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT,
RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT,
ROOT, POWER_OF_2, POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE,
ARCTANGENT, PI, SETTINGS, F1, F2, F3, F4, BACK, ZOOM_MODE, LOGARITHM,
EULER_NUMBER, LETTER_A, LETTER_B, LETTER_C, LETTER_D, LETTER_E, LETTER_F,
LETTER_G, LETTER_H, LETTER_I, LETTER_J, LETTER_K, LETTER_L, LETTER_M,
LETTER_N, LETTER_O, LETTER_P, LETTER_Q, LETTER_R, LETTER_S, LETTER_T,
LETTER_U, LETTER_V, LETTER_W, LETTER_X, LETTER_Y, LETTER_Z,
} }

View File

@ -39,7 +39,9 @@ public class MarioGame {
final double curY = player.getY(); final double curY = player.getY();
final double futureX = curX + deltaX; final double futureX = curX + deltaX;
final double futureY = curY + deltaY; final double futureY = curY + deltaY;
@SuppressWarnings("unused")
final boolean forward = futureX >= curX; final boolean forward = futureX >= curX;
@SuppressWarnings("unused")
final boolean up = futureY >= curY; final boolean up = futureY >= curY;
player.move(dt, futureX - curX, futureY - curY); player.move(dt, futureX - curX, futureY - curY);
} }
@ -69,6 +71,7 @@ public class MarioGame {
} }
} }
@SuppressWarnings("unused")
private int nearest(double val, int a, int b) { private int nearest(double val, int a, int b) {
final double aa = Math.abs(val - a); final double aa = Math.abs(val - a);
final double ab = Math.abs(val - b); final double ab = Math.abs(val - b);

View File

@ -6,6 +6,7 @@ public class MarioWorld {
private final int width; private final int width;
private final int height; private final int height;
private final byte[][] data; private final byte[][] data;
@SuppressWarnings("unused")
private final MarioEvent[] events; private final MarioEvent[] events;
private final MarioEntity[] entities; private final MarioEntity[] entities;

View File

@ -2,6 +2,7 @@ package org.warp.picalculator.extra.mario;
public class PlayerEntity extends MarioEntity { public class PlayerEntity extends MarioEntity {
@SuppressWarnings("unused")
private final int life; private final int life;
public float walkAnimation = 0; public float walkAnimation = 0;
public float jumptime = 0; public float jumptime = 0;

View File

@ -1,19 +1,16 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.LinkedList;
import java.util.List;
public class BehaviorSubject<T> extends Subject<T> { public class BehaviorSubject<T> extends Subject<T> {
private T lastValue; private T lastValue;
private boolean lastValueSet; private boolean lastValueSet;
protected BehaviorSubject() { protected BehaviorSubject() {
super(); super();
lastValue = null; lastValue = null;
lastValueSet = false; lastValueSet = false;
} }
protected BehaviorSubject(T initialValue) { protected BehaviorSubject(T initialValue) {
super(); super();
lastValue = initialValue; lastValue = initialValue;
@ -23,7 +20,7 @@ public class BehaviorSubject<T> extends Subject<T> {
public final static <T> BehaviorSubject<T> create() { public final static <T> BehaviorSubject<T> create() {
return new BehaviorSubject<>(); return new BehaviorSubject<>();
} }
public final static <T> BehaviorSubject<T> create(T initialValue) { public final static <T> BehaviorSubject<T> create(T initialValue) {
return new BehaviorSubject<T>(initialValue); return new BehaviorSubject<T>(initialValue);
} }
@ -39,7 +36,7 @@ public class BehaviorSubject<T> extends Subject<T> {
public void onError(Throwable e) { public void onError(Throwable e) {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
} }
@Override @Override
@ -94,5 +91,5 @@ public class BehaviorSubject<T> extends Subject<T> {
public T getLastValue() { public T getLastValue() {
return lastValue; return lastValue;
} }
} }

View File

@ -4,27 +4,33 @@ import java.util.Objects;
public interface Consumer<T> { public interface Consumer<T> {
/** /**
* Performs this operation on the given argument. * Performs this operation on the given argument.
* *
* @param t the input argument * @param t
*/ * the input argument
void accept(T t); */
void accept(T t);
/** /**
* Returns a composed {@code Consumer} that performs, in sequence, this * Returns a composed {@code Consumer} that performs, in sequence, this
* operation followed by the {@code after} operation. If performing either * operation followed by the {@code after} operation. If performing either
* operation throws an exception, it is relayed to the caller of the * operation throws an exception, it is relayed to the caller of the
* composed operation. If performing this operation throws an exception, * composed operation. If performing this operation throws an exception,
* the {@code after} operation will not be performed. * the {@code after} operation will not be performed.
* *
* @param after the operation to perform after this operation * @param after
* @return a composed {@code Consumer} that performs in sequence this * the operation to perform after this operation
* operation followed by the {@code after} operation * @return a composed {@code Consumer} that performs in sequence this
* @throws NullPointerException if {@code after} is null * operation followed by the {@code after} operation
*/ * @throws NullPointerException
default Consumer<T> andThen(Consumer<? super T> after) { * if {@code after} is null
Objects.requireNonNull(after); */
return (T t) -> { accept(t); after.accept(t); }; default Consumer<T> andThen(Consumer<? super T> after) {
} Objects.requireNonNull(after);
return (T t) -> {
accept(t);
after.accept(t);
};
}
} }

View File

@ -2,6 +2,6 @@ package org.warp.picalculator.flow;
public interface Disposable { public interface Disposable {
public void dispose(); public void dispose();
public boolean isDisposed(); public boolean isDisposed();
} }

View File

@ -7,13 +7,13 @@ import org.warp.picalculator.PlatformUtils;
public class IntervalsManager { public class IntervalsManager {
private static List<ObservableInterval> intervals = new LinkedList<>(); private static List<ObservableInterval> intervals = new LinkedList<>();
static { static {
startChecker(); startChecker();
} }
private IntervalsManager() { private IntervalsManager() {
} }
public static void register(ObservableInterval t) { public static void register(ObservableInterval t) {
@ -23,7 +23,7 @@ public class IntervalsManager {
} }
} }
} }
private static void startChecker() { private static void startChecker() {
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
try { try {

View File

@ -2,7 +2,6 @@ package org.warp.picalculator.flow;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -10,25 +9,31 @@ import org.apache.commons.lang3.tuple.Pair;
public abstract class Observable<T> implements ObservableSource<T> { public abstract class Observable<T> implements ObservableSource<T> {
protected List<Subscriber<? super T>> subscribers = new LinkedList<>(); protected List<Subscriber<? super T>> subscribers = new LinkedList<>();
public Disposable subscribe() { public Disposable subscribe() {
return null; return null;
} }
public Disposable subscribe(Action1<? super T> onNext) { public Disposable subscribe(Action1<? super T> onNext) {
return subscribe(createSubscriber(onNext)); return subscribe(createSubscriber(onNext));
} }
protected Observable<T>.DisposableOfSubscriber createDisposable(Subscriber<? super T> sub) { protected Observable<T>.DisposableOfSubscriber createDisposable(Subscriber<? super T> sub) {
return new DisposableOfSubscriber(sub); return new DisposableOfSubscriber(sub);
} }
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) { public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) {
return subscribe(createSubscriber(onNext, onError)); return subscribe(createSubscriber(onNext, onError));
} }
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompleted) { public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompleted) {
return subscribe(createSubscriber(onNext, onError, onCompleted)); return subscribe(createSubscriber(onNext, onError, onCompleted));
} }
public void subscribe(Observer<? super T> obs) { public void subscribe(Observer<? super T> obs) {
subscribe(createSubscriber(obs)); subscribe(createSubscriber(obs));
} }
public Disposable subscribe(Subscriber<? super T> sub) { public Disposable subscribe(Subscriber<? super T> sub) {
subscribers.add(sub); subscribers.add(sub);
return createDisposable(sub); return createDisposable(sub);
@ -36,64 +41,77 @@ public abstract class Observable<T> implements ObservableSource<T> {
protected Subscriber<T> createSubscriber(Action1<? super T> onNext) { protected Subscriber<T> createSubscriber(Action1<? super T> onNext) {
return new Subscriber<T>() { return new Subscriber<T>() {
@Override public void onSubscribe(Subscription s) {} @Override
public void onSubscribe(Subscription s) {}
public void onNext(T t) { public void onNext(T t) {
onNext.call(t); onNext.call(t);
} }
}; };
} }
protected Subscriber<T> createSubscriber(Action1<? super T> onNext, Action1<Throwable> onError) { protected Subscriber<T> createSubscriber(Action1<? super T> onNext, Action1<Throwable> onError) {
return new Subscriber<T>() { return new Subscriber<T>() {
@Override public void onSubscribe(Subscription s) {} @Override
public void onSubscribe(Subscription s) {}
public void onNext(T t) { public void onNext(T t) {
onNext.call(t); onNext.call(t);
} }
@Override @Override
public void onError(Throwable t) { public void onError(Throwable t) {
onError.call(t); onError.call(t);
} }
}; };
} }
protected Subscriber<T> createSubscriber(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) { protected Subscriber<T> createSubscriber(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) {
return new Subscriber<T>() { return new Subscriber<T>() {
@Override public void onSubscribe(Subscription s) {} @Override
public void onSubscribe(Subscription s) {}
public void onNext(T t) { public void onNext(T t) {
onNext.call(t); onNext.call(t);
} }
@Override @Override
public void onError(Throwable t) { public void onError(Throwable t) {
onError.call(t); onError.call(t);
} }
@Override @Override
public void onComplete() { public void onComplete() {
onCompl.call(); onCompl.call();
} }
}; };
} }
protected Subscriber<T> createSubscriber(Observer<? super T> obs) { protected Subscriber<T> createSubscriber(Observer<? super T> obs) {
return new Subscriber<T>() { return new Subscriber<T>() {
@Override public void onSubscribe(Subscription s) {} @Override
public void onSubscribe(Subscription s) {}
public void onNext(T t) { public void onNext(T t) {
obs.onNext(t); obs.onNext(t);
} }
@Override @Override
public void onError(Throwable t) { public void onError(Throwable t) {
obs.onError(t); obs.onError(t);
} }
@Override @Override
public void onComplete() { public void onComplete() {
obs.onComplete(); obs.onComplete();
} }
}; };
} }
public static final <T> Observable<T> merge(Observable<T> a, Observable<T> b) { public static final <T> Observable<T> merge(Observable<T> a, Observable<T> b) {
return new ObservableMerged<>(a, b); return new ObservableMerged<>(a, b);
} }
@Deprecated @Deprecated
public static final <T> Observable<T> of(Observable<T> a) { public static final <T> Observable<T> of(Observable<T> a) {
return null; return null;
@ -103,26 +121,26 @@ public abstract class Observable<T> implements ObservableSource<T> {
return new ObservableMap<T, U>(this, f); return new ObservableMap<T, U>(this, f);
} }
public static final <T, U> Observable<Pair<T,U>> combineLatest(Observable<T> a, Observable<U> b) { public static final <T, U> Observable<Pair<T, U>> combineLatest(Observable<T> a, Observable<U> b) {
return new ObservableCombinedLatest<>(a, b); return new ObservableCombinedLatest<>(a, b);
} }
public static final <T, U> Observable<Pair<T,U>> combineChanged(Observable<T> a, Observable<U> b) { public static final <T, U> Observable<Pair<T, U>> combineChanged(Observable<T> a, Observable<U> b) {
return new ObservableCombinedChanged<>(a, b); return new ObservableCombinedChanged<>(a, b);
} }
public static final <T, U> Observable<Pair<T,U>> zip(Observable<T> a, Observable<U> b) { public static final <T, U> Observable<Pair<T, U>> zip(Observable<T> a, Observable<U> b) {
return new ObservableZipped<>(a, b); return new ObservableZipped<>(a, b);
} }
public static final Observable<Long> interval(long interval) { public static final Observable<Long> interval(long interval) {
return new ObservableInterval(interval); return new ObservableInterval(interval);
} }
protected class DisposableOfSubscriber implements Disposable { protected class DisposableOfSubscriber implements Disposable {
private final Subscriber<? super T> sub; private final Subscriber<? super T> sub;
public DisposableOfSubscriber(Subscriber<? super T> sub) { public DisposableOfSubscriber(Subscriber<? super T> sub) {
this.sub = sub; this.sub = sub;
} }
@ -130,7 +148,7 @@ public abstract class Observable<T> implements ObservableSource<T> {
protected Subscriber<? super T> getSubscriber() { protected Subscriber<? super T> getSubscriber() {
return sub; return sub;
} }
protected Observable<T> getObservable() { protected Observable<T> getObservable() {
return Observable.this; return Observable.this;
} }
@ -148,7 +166,7 @@ public abstract class Observable<T> implements ObservableSource<T> {
public boolean isDisposed() { public boolean isDisposed() {
return !subscribers.contains(sub); return !subscribers.contains(sub);
} }
} }
public Observable<T> doOnNext(Action1<T> onNext) { public Observable<T> doOnNext(Action1<T> onNext) {
@ -159,8 +177,8 @@ public abstract class Observable<T> implements ObservableSource<T> {
}); });
return onNextSubject; return onNextSubject;
} }
public void onDisposed(Subscriber<? super T> sub) { public void onDisposed(Subscriber<? super T> sub) {
} }
} }

View File

@ -1,23 +1,18 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
public class ObservableCombinedChanged<T, U> extends Observable<Pair<T, U>> { public class ObservableCombinedChanged<T, U> extends Observable<Pair<T, U>> {
private volatile boolean initialized = false; private volatile boolean initialized = false;
private Observable<T> a; private Observable<T> a;
private Observable<U> b; private Observable<U> b;
private Disposable disposableA; private Disposable disposableA;
private Disposable disposableB; private Disposable disposableB;
private Subject<Pair<T, U>> pairSubject;
private Subject<T> mapSubject;
public ObservableCombinedChanged(Observable<T> a, Observable<U> b) { public ObservableCombinedChanged(Observable<T> a, Observable<U> b) {
super(); super();
this.a = a; this.a = a;
this.b = b; this.b = b;
this.pairSubject = SimpleSubject.create();
} }
private void initialize() { private void initialize() {
@ -28,36 +23,36 @@ public class ObservableCombinedChanged<T, U> extends Observable<Pair<T, U>> {
}, (e) -> { }, (e) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
this.disposableB = b.subscribe((t) -> { this.disposableB = b.subscribe((t) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onNext(Pair.of(null, t)); sub.onNext(Pair.of(null, t));
}; } ;
}, (e) -> { }, (e) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
} }
private void chechInitialized() { private void chechInitialized() {
if (!initialized) { if (!initialized) {
initialized = true; initialized = true;
initialize(); initialize();
} }
} }
@Override @Override
public Disposable subscribe(Subscriber<? super Pair<T,U>> sub) { public Disposable subscribe(Subscriber<? super Pair<T, U>> sub) {
Disposable disp = super.subscribe(sub); Disposable disp = super.subscribe(sub);
chechInitialized(); chechInitialized();
return disp; return disp;

View File

@ -1,10 +1,8 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> { public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
private volatile boolean initialized = false; private volatile boolean initialized = false;
private Observable<T> a; private Observable<T> a;
private Observable<U> b; private Observable<U> b;
@ -14,14 +12,11 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
private volatile U lastB; private volatile U lastB;
private volatile boolean didAOneTime; private volatile boolean didAOneTime;
private volatile boolean didBOneTime; private volatile boolean didBOneTime;
private Subject<Pair<T, U>> pairSubject;
private Subject<T> mapSubject;
public ObservableCombinedLatest(Observable<T> a, Observable<U> b) { public ObservableCombinedLatest(Observable<T> a, Observable<U> b) {
super(); super();
this.a = a; this.a = a;
this.b = b; this.b = b;
this.pairSubject = SimpleSubject.create();
} }
private void initialize() { private void initialize() {
@ -32,11 +27,11 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
}, (e) -> { }, (e) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
this.disposableB = b.subscribe((t) -> { this.disposableB = b.subscribe((t) -> {
lastB = t; lastB = t;
@ -45,14 +40,14 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
}, (e) -> { }, (e) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
} }
private void receivedNext() { private void receivedNext() {
if (didAOneTime && didBOneTime) { if (didAOneTime && didBOneTime) {
this.subscribers.forEach(sub -> { this.subscribers.forEach(sub -> {
@ -67,9 +62,9 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
initialize(); initialize();
} }
} }
@Override @Override
public Disposable subscribe(Subscriber<? super Pair<T,U>> sub) { public Disposable subscribe(Subscriber<? super Pair<T, U>> sub) {
Disposable disp = super.subscribe(sub); Disposable disp = super.subscribe(sub);
chechInitialized(); chechInitialized();
return disp; return disp;

View File

@ -1,15 +1,12 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair;
import org.warp.picalculator.PlatformUtils; import org.warp.picalculator.PlatformUtils;
public class ObservableInterval extends Observable<Long> { public class ObservableInterval extends Observable<Long> {
private final long interval; private final long interval;
volatile boolean running; volatile boolean running;
volatile Thread timeThread; volatile Thread timeThread;
protected ObservableInterval(long interval) { protected ObservableInterval(long interval) {
super(); super();
this.interval = interval; this.interval = interval;
@ -19,14 +16,14 @@ public class ObservableInterval extends Observable<Long> {
e.printStackTrace(); e.printStackTrace();
} }
} }
void stopInterval() { void stopInterval() {
if (running) { if (running) {
running = false; running = false;
this.timeThread.interrupt(); this.timeThread.interrupt();
} }
} }
@Override @Override
public Disposable subscribe(Subscriber<? super Long> sub) { public Disposable subscribe(Subscriber<? super Long> sub) {
try { try {
@ -44,7 +41,7 @@ public class ObservableInterval extends Observable<Long> {
} }
timeThread = new Thread(() -> { timeThread = new Thread(() -> {
try { try {
while(!Thread.interrupted()) { while (!Thread.interrupted()) {
for (Subscriber<? super Long> sub : this.subscribers) { for (Subscriber<? super Long> sub : this.subscribers) {
sub.onNext(System.currentTimeMillis()); sub.onNext(System.currentTimeMillis());
} }
@ -62,7 +59,7 @@ public class ObservableInterval extends Observable<Long> {
public static ObservableInterval create(long l) { public static ObservableInterval create(long l) {
return new ObservableInterval(l); return new ObservableInterval(l);
} }
@Override @Override
public void onDisposed(Subscriber<? super Long> sub) { public void onDisposed(Subscriber<? super Long> sub) {
super.onDisposed(sub); super.onDisposed(sub);

View File

@ -2,38 +2,34 @@ package org.warp.picalculator.flow;
import java.util.function.Function; import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair; public class ObservableMap<T, U> extends Observable<U> {
public class ObservableMap<T, U> extends Observable<U> {
private Observable<T> originalObservable; private Observable<T> originalObservable;
private Function<T, U> mapAction; private Function<T, U> mapAction;
private volatile boolean initialized = false; private volatile boolean initialized = false;
private Disposable mapDisposable; private Disposable mapDisposable;
private Subject<T> mapSubject;
public ObservableMap(Observable<T> originalObservable, Function<T, U> mapAction) { public ObservableMap(Observable<T> originalObservable, Function<T, U> mapAction) {
super(); super();
this.originalObservable = originalObservable; this.originalObservable = originalObservable;
this.mapAction = mapAction; this.mapAction = mapAction;
this.mapSubject = SimpleSubject.create();
} }
private void initialize() { private void initialize() {
this.mapDisposable = originalObservable.subscribe((t) -> { this.mapDisposable = originalObservable.subscribe((t) -> {
for (Subscriber<? super U> sub : this.subscribers) { for (Subscriber<? super U> sub : this.subscribers) {
sub.onNext(mapAction.apply(t)); sub.onNext(mapAction.apply(t));
}; } ;
}, (e) -> { }, (e) -> {
for (Subscriber<? super U> sub : this.subscribers) { for (Subscriber<? super U> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super U> sub : this.subscribers) { for (Subscriber<? super U> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
} }
private void chechInitialized() { private void chechInitialized() {
if (!initialized) { if (!initialized) {
initialized = true; initialized = true;
@ -47,6 +43,7 @@ public class ObservableMap<T, U> extends Observable<U> {
chechInitialized(); chechInitialized();
return disp; return disp;
} }
@Override @Override
public void onDisposed(Subscriber<? super U> sub) { public void onDisposed(Subscriber<? super U> sub) {
super.onDisposed(sub); super.onDisposed(sub);

View File

@ -1,60 +1,54 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.function.Function; public class ObservableMerged<T> extends Observable<T> {
import org.apache.commons.lang3.tuple.Pair;
public class ObservableMerged<T> extends Observable<T> {
private Observable<T> originalObservableA; private Observable<T> originalObservableA;
private Observable<T> originalObservableB; private Observable<T> originalObservableB;
private volatile boolean initialized = false; private volatile boolean initialized = false;
private Disposable mapDisposableA; private Disposable mapDisposableA;
private Disposable mapDisposableB; private Disposable mapDisposableB;
private Subject<T> mapSubject;
public ObservableMerged(Observable<T> originalObservableA, Observable<T> originalObservableB) { public ObservableMerged(Observable<T> originalObservableA, Observable<T> originalObservableB) {
super(); super();
this.originalObservableA = originalObservableA; this.originalObservableA = originalObservableA;
this.originalObservableB = originalObservableB; this.originalObservableB = originalObservableB;
this.mapSubject = SimpleSubject.create();
} }
private void initialize() { private void initialize() {
this.mapDisposableA = originalObservableA.subscribe((t) -> { this.mapDisposableA = originalObservableA.subscribe((t) -> {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onNext(t); sub.onNext(t);
}; } ;
}, (e) -> { }, (e) -> {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
this.mapDisposableB = originalObservableB.subscribe((t) -> { this.mapDisposableB = originalObservableB.subscribe((t) -> {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onNext(t); sub.onNext(t);
}; } ;
}, (e) -> { }, (e) -> {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
} }
private void chechInitialized() { private void chechInitialized() {
if (!initialized) { if (!initialized) {
initialized = true; initialized = true;
initialize(); initialize();
} }
} }
@Override @Override
public Disposable subscribe(Subscriber<? super T> sub) { public Disposable subscribe(Subscriber<? super T> sub) {
Disposable disp = super.subscribe(sub); Disposable disp = super.subscribe(sub);

View File

@ -1,10 +1,8 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
public class ObservableZipped<T, U> extends Observable<Pair<T, U>> { public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
private volatile boolean initialized = false; private volatile boolean initialized = false;
private Observable<T> a; private Observable<T> a;
private Observable<U> b; private Observable<U> b;
@ -14,14 +12,11 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
private volatile U lastB; private volatile U lastB;
private volatile boolean didA; private volatile boolean didA;
private volatile boolean didB; private volatile boolean didB;
private Subject<Pair<T, U>> pairSubject;
private Subject<T> mapSubject;
public ObservableZipped(Observable<T> a, Observable<U> b) { public ObservableZipped(Observable<T> a, Observable<U> b) {
super(); super();
this.a = a; this.a = a;
this.b = b; this.b = b;
this.pairSubject = SimpleSubject.create();
} }
private void initialize() { private void initialize() {
@ -32,11 +27,11 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
}, (e) -> { }, (e) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
this.disposableB = b.subscribe((t) -> { this.disposableB = b.subscribe((t) -> {
lastB = t; lastB = t;
@ -45,21 +40,21 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
}, (e) -> { }, (e) -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
}, () -> { }, () -> {
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
}); });
} }
private void receivedNext() { private void receivedNext() {
if (didA && didB) { if (didA && didB) {
didA = false; didA = false;
didB = false; didB = false;
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) { for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
sub.onNext(Pair.of(lastA, lastB)); sub.onNext(Pair.of(lastA, lastB));
}; } ;
} }
} }
@ -69,9 +64,9 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
initialize(); initialize();
} }
} }
@Override @Override
public Disposable subscribe(Subscriber<? super Pair<T,U>> sub) { public Disposable subscribe(Subscriber<? super Pair<T, U>> sub) {
Disposable disp = super.subscribe(sub); Disposable disp = super.subscribe(sub);
chechInitialized(); chechInitialized();
return disp; return disp;

View File

@ -2,7 +2,10 @@ package org.warp.picalculator.flow;
public interface Observer<T> { public interface Observer<T> {
public void onComplete(); public void onComplete();
public void onError(Throwable e); public void onError(Throwable e);
public void onNext(T t); public void onNext(T t);
public void onSubscribe(Disposable d); public void onSubscribe(Disposable d);
} }

View File

@ -1,14 +1,8 @@
package org.warp.picalculator.flow; package org.warp.picalculator.flow;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
public class SimpleSubject<T> extends Subject<T> { public class SimpleSubject<T> extends Subject<T> {
protected SimpleSubject() { protected SimpleSubject() {}
}
public final static <T> SimpleSubject<T> create() { public final static <T> SimpleSubject<T> create() {
return new SimpleSubject<>(); return new SimpleSubject<>();
@ -18,21 +12,21 @@ public class SimpleSubject<T> extends Subject<T> {
public void onComplete() { public void onComplete() {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onComplete(); sub.onComplete();
}; } ;
} }
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onError(e); sub.onError(e);
}; } ;
} }
@Override @Override
public void onNext(T t) { public void onNext(T t) {
for (Subscriber<? super T> sub : this.subscribers) { for (Subscriber<? super T> sub : this.subscribers) {
sub.onNext(t); sub.onNext(t);
}; } ;
} }
@Override @Override
@ -66,7 +60,6 @@ public class SimpleSubject<T> extends Subject<T> {
} }
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {}
}
} }

View File

@ -2,26 +2,30 @@ package org.warp.picalculator.flow;
public abstract class Subject<T> extends Observable<T> implements Observer<T> { public abstract class Subject<T> extends Observable<T> implements Observer<T> {
abstract Throwable getThrowable(); abstract Throwable getThrowable();
abstract boolean hasComplete(); abstract boolean hasComplete();
abstract boolean hasObservers(); abstract boolean hasObservers();
abstract boolean hasThrowable(); abstract boolean hasThrowable();
abstract Subject<T> toSerialized(); abstract Subject<T> toSerialized();
@Override @Override
public Disposable subscribe(Action1<? super T> onNext) { public Disposable subscribe(Action1<? super T> onNext) {
return subscribe(createSubscriber(onNext)); return subscribe(createSubscriber(onNext));
} }
@Override @Override
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) { public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) {
return subscribe(createSubscriber(onNext, onError)); return subscribe(createSubscriber(onNext, onError));
} }
@Override @Override
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) { public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) {
return subscribe(createSubscriber(onNext, onError, onCompl)); return subscribe(createSubscriber(onNext, onError, onCompl));
} }
@Override @Override
public void subscribe(Observer<? super T> obs) { public void subscribe(Observer<? super T> obs) {
subscribe(createSubscriber(obs)); subscribe(createSubscriber(obs));

View File

@ -2,7 +2,10 @@ package org.warp.picalculator.flow;
public interface Subscriber<T> { public interface Subscriber<T> {
default void onComplete() {} default void onComplete() {}
default void onError(Throwable t) {} default void onError(Throwable t) {}
void onNext(T t); void onNext(T t);
void onSubscribe(Subscription s); void onSubscribe(Subscription s);
} }

View File

@ -2,5 +2,6 @@ package org.warp.picalculator.flow;
public interface Subscription { public interface Subscription {
void cancel(); void cancel();
void request(long n); void request(long n);
} }

View File

@ -7,7 +7,7 @@ public class TestFlow {
try { try {
BehaviorSubject<Float> subject0 = BehaviorSubject.create(0f); BehaviorSubject<Float> subject0 = BehaviorSubject.create(0f);
Disposable s00 = subject0.subscribe((val) -> { Disposable s00 = subject0.subscribe((val) -> {
System.out.println(val); System.out.println(val);
}); });
@ -21,8 +21,7 @@ public class TestFlow {
s00.dispose(); s00.dispose();
subject0.onNext(60f); subject0.onNext(60f);
subject0.onNext(7f); subject0.onNext(7f);
subject0.onComplete(); subject0.onComplete();
System.out.println("items sent."); System.out.println("items sent.");
@ -41,7 +40,7 @@ public class TestFlow {
s01.dispose(); s01.dispose();
subject1.onNext(60f); subject1.onNext(60f);
subject1.onNext(7f); subject1.onNext(7f);
subject1.onComplete(); subject1.onComplete();
System.out.println("items sent."); System.out.println("items sent.");
@ -62,7 +61,7 @@ public class TestFlow {
s1.dispose(); s1.dispose();
subjectB.onNext(60f); subjectB.onNext(60f);
subjectA.onNext(7f); subjectA.onNext(7f);
subjectB.onComplete(); subjectB.onComplete();
subjectA.onComplete(); subjectA.onComplete();
Thread.sleep(100); Thread.sleep(100);
@ -85,7 +84,7 @@ public class TestFlow {
subjectD.onNext(60f); subjectD.onNext(60f);
subjectC.onNext(7f); subjectC.onNext(7f);
s2.dispose(); s2.dispose();
subjectD.onComplete(); subjectD.onComplete();
subjectC.onComplete(); subjectC.onComplete();
System.out.println("items sent."); System.out.println("items sent.");
@ -94,7 +93,7 @@ public class TestFlow {
Disposable d = timA.subscribe((t) -> { Disposable d = timA.subscribe((t) -> {
System.out.println(t); System.out.println(t);
}); });
Thread.sleep(500); Thread.sleep(500);
d.dispose(); d.dispose();
System.out.println("items sent."); System.out.println("items sent.");
@ -124,12 +123,10 @@ public class TestFlow {
subjectF.onNext(7f); subjectF.onNext(7f);
Thread.sleep(500); Thread.sleep(500);
s3.dispose(); s3.dispose();
subjectF.onComplete(); subjectF.onComplete();
System.out.println("items sent."); System.out.println("items sent.");
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }

View File

@ -33,7 +33,6 @@ public class CalculatorHUD extends HUD {
public void renderTopmostBackground() { public void renderTopmostBackground() {
final Renderer renderer = d.renderer; final Renderer renderer = d.renderer;
final GraphicEngine engine = d.engine; final GraphicEngine engine = d.engine;
final Skin guiSkin = d.guiSkin;
renderer.glColor(0xFFc5c2af); renderer.glColor(0xFFc5c2af);
renderer.glFillColor(0, 0, engine.getWidth(), 20); renderer.glFillColor(0, 0, engine.getWidth(), 20);

View File

@ -3,26 +3,15 @@ package org.warp.picalculator.gui;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DEngine; import org.warp.picalculator.deps.DEngine;
import org.warp.picalculator.deps.DSemaphore; import org.warp.picalculator.deps.DSemaphore;
import org.warp.picalculator.deps.DSystem; import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard; import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.TouchCancelEvent;
import org.warp.picalculator.event.TouchEndEvent;
import org.warp.picalculator.event.TouchEvent;
import org.warp.picalculator.event.TouchEventListener;
import org.warp.picalculator.event.TouchMoveEvent;
import org.warp.picalculator.event.TouchStartEvent;
import org.warp.picalculator.flow.Observable; import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine; import org.warp.picalculator.gui.graphicengine.GraphicEngine;
@ -32,13 +21,11 @@ import org.warp.picalculator.gui.graphicengine.Skin;
import org.warp.picalculator.gui.graphicengine.nogui.NoGuiEngine; import org.warp.picalculator.gui.graphicengine.nogui.NoGuiEngine;
import org.warp.picalculator.gui.screens.Screen; import org.warp.picalculator.gui.screens.Screen;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public final class DisplayManager implements RenderingLoop { public final class DisplayManager implements RenderingLoop {
private static final int tickDuration = 50; private static final int tickDuration = 50;
private HardwareDevice device;
private float brightness; private float brightness;
public final GraphicEngine engine; public final GraphicEngine engine;
@ -400,9 +387,9 @@ public final class DisplayManager implements RenderingLoop {
e.printStackTrace(); e.printStackTrace();
DSystem.exit(0); DSystem.exit(0);
} }
Observable<Long> workTimer = Observable.interval(tickDuration); Observable<Long> workTimer = Observable.interval(tickDuration);
Observable<Integer[]> onResizeObservable = engine.onResize(); Observable<Integer[]> onResizeObservable = engine.onResize();
Observable<Pair<Long, Integer[]>> refreshObservable; Observable<Pair<Long, Integer[]>> refreshObservable;
if (onResizeObservable == null) { if (onResizeObservable == null) {
@ -410,7 +397,7 @@ public final class DisplayManager implements RenderingLoop {
} else { } else {
refreshObservable = Observable.combineChanged(workTimer, engine.onResize()); refreshObservable = Observable.combineChanged(workTimer, engine.onResize());
} }
refreshObservable.subscribe((pair) -> { refreshObservable.subscribe((pair) -> {
double dt = 0; double dt = 0;
final long newtime = System.nanoTime(); final long newtime = System.nanoTime();
@ -426,7 +413,7 @@ public final class DisplayManager implements RenderingLoop {
StaticVars.screenSize[0] = windowSize[0]; StaticVars.screenSize[0] = windowSize[0];
StaticVars.screenSize[1] = windowSize[1]; StaticVars.screenSize[1] = windowSize[1];
} }
screen.beforeRender((float) (dt / 1000d)); screen.beforeRender((float) (dt / 1000d));
}); });

View File

@ -3,7 +3,6 @@ package org.warp.picalculator.gui.expression.blocks;
import org.warp.picalculator.Error; import org.warp.picalculator.Error;
import org.warp.picalculator.Errors; import org.warp.picalculator.Errors;
import org.warp.picalculator.PlatformUtils; import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.gui.GraphicalElement; import org.warp.picalculator.gui.GraphicalElement;
import org.warp.picalculator.gui.expression.Caret; import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.expression.CaretState; import org.warp.picalculator.gui.expression.CaretState;

View File

@ -23,6 +23,7 @@ public class BlockLogarithm extends Block {
private int bl; private int bl;
private int chw; private int chw;
private int chh; private int chh;
@SuppressWarnings("unused")
private int schh; private int schh;
private int nmbh; private int nmbh;
private int toph; private int toph;

View File

@ -2,10 +2,8 @@ package org.warp.picalculator.gui.expression.blocks;
import org.warp.picalculator.Error; import org.warp.picalculator.Error;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent; import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.expression.Caret; import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.expression.ExtraMenu; import org.warp.picalculator.gui.expression.ExtraMenu;
import org.warp.picalculator.gui.expression.InputContext; import org.warp.picalculator.gui.expression.InputContext;

View File

@ -5,12 +5,12 @@ import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockChar; import org.warp.picalculator.gui.expression.blocks.BlockChar;
import org.warp.picalculator.gui.expression.blocks.BlockContainer; import org.warp.picalculator.gui.expression.blocks.BlockContainer;
import org.warp.picalculator.gui.expression.blocks.BlockDivision; import org.warp.picalculator.gui.expression.blocks.BlockDivision;
import org.warp.picalculator.gui.expression.blocks.BlockLogarithm;
import org.warp.picalculator.gui.expression.blocks.BlockNumericChar; import org.warp.picalculator.gui.expression.blocks.BlockNumericChar;
import org.warp.picalculator.gui.expression.blocks.BlockParenthesis; import org.warp.picalculator.gui.expression.blocks.BlockParenthesis;
import org.warp.picalculator.gui.expression.blocks.BlockPower; import org.warp.picalculator.gui.expression.blocks.BlockPower;
import org.warp.picalculator.gui.expression.blocks.BlockReference; import org.warp.picalculator.gui.expression.blocks.BlockReference;
import org.warp.picalculator.gui.expression.blocks.BlockSine; import org.warp.picalculator.gui.expression.blocks.BlockSine;
import org.warp.picalculator.gui.expression.blocks.BlockLogarithm;
import org.warp.picalculator.gui.expression.blocks.BlockSquareRoot; import org.warp.picalculator.gui.expression.blocks.BlockSquareRoot;
import org.warp.picalculator.gui.expression.blocks.BlockVariable; import org.warp.picalculator.gui.expression.blocks.BlockVariable;
import org.warp.picalculator.math.MathematicalSymbols; import org.warp.picalculator.math.MathematicalSymbols;
@ -97,7 +97,7 @@ public class NormalInputContainer extends InputContainer {
case MathematicalSymbols.DIVISION: case MathematicalSymbols.DIVISION:
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BlockReference<BlockDivision> ref = (BlockReference<BlockDivision>) getSelectedBlock(); final BlockReference<BlockDivision> ref = (BlockReference<BlockDivision>) getSelectedBlock();
final BlockContainer parentContainer = ref.getContainer(); @SuppressWarnings("unused") final BlockContainer parentContainer = ref.getContainer();
BlockReference<?> currentBlock = ref; BlockReference<?> currentBlock = ref;
boolean groupedBefore = false; boolean groupedBefore = false;
int before = 0; int before = 0;

View File

@ -9,7 +9,6 @@ import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.flow.Observable; import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine; import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.RenderingLoop; import org.warp.picalculator.gui.graphicengine.RenderingLoop;

View File

@ -6,7 +6,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -34,6 +33,7 @@ public class CPUFont implements BinaryFont {
public int[] intervals; public int[] intervals;
public int intervalsTotalSize = 0; public int intervalsTotalSize = 0;
public static final int intBits = 31; public static final int intBits = 31;
@SuppressWarnings("unused")
private final boolean isResource; private final boolean isResource;
public CPUFont(String fontName) throws IOException { public CPUFont(String fontName) throws IOException {
@ -186,6 +186,7 @@ public class CPUFont implements BinaryFont {
int beginIndex = -1; int beginIndex = -1;
int endIndex = 0; int endIndex = 0;
int intervalSize = 0; int intervalSize = 0;
@SuppressWarnings("unused")
final int holeSize = 0; final int holeSize = 0;
for (int i = 0; i < rawchars.length; i++) { for (int i = 0; i < rawchars.length; i++) {
if (rawchars[i] != null) { if (rawchars[i] != null) {
@ -273,6 +274,7 @@ public class CPUFont implements BinaryFont {
return compressedIndex; return compressedIndex;
} }
@SuppressWarnings("unused")
private int decompressIndex(int compressedIndex) { private int decompressIndex(int compressedIndex) {
final int originalIndex = 0; final int originalIndex = 0;
int i = 0; int i = 0;

View File

@ -3,17 +3,11 @@ package org.warp.picalculator.gui.graphicengine.cpu;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Files;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.deps.StorageUtils; import org.warp.picalculator.deps.StorageUtils;
import org.warp.picalculator.deps.nio.DFiles;
import org.warp.picalculator.deps.nio.DPath;
import org.warp.picalculator.deps.nio.DPaths;
import org.warp.picalculator.gui.graphicengine.GraphicEngine; import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Skin; import org.warp.picalculator.gui.graphicengine.Skin;
@ -24,6 +18,7 @@ public class CPUSkin implements Skin {
public int[] skinData; public int[] skinData;
public int[] skinSize; public int[] skinSize;
@SuppressWarnings("unused")
private final boolean isResource; private final boolean isResource;
public CPUSkin(String file) throws IOException { public CPUSkin(String file) throws IOException {
@ -84,7 +79,7 @@ public class CPUSkin implements Skin {
} else if (channels == 3) { } else if (channels == 3) {
nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (0xFF << 24); nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (0xFF << 24);
} else if (channels == 2) { } else if (channels == 2) {
nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24); nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24);
} else { } else {
nextPixel = (scanLine[offset] << 16) | (scanLine[offset] << 8) | scanLine[offset] | (0xFF << 24); nextPixel = (scanLine[offset] << 16) | (scanLine[offset] << 8) | scanLine[offset] | (0xFF << 24);
} }

View File

@ -20,7 +20,6 @@ import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
@ -31,7 +30,6 @@ import org.warp.picalculator.event.TouchPoint;
import org.warp.picalculator.event.TouchStartEvent; import org.warp.picalculator.event.TouchStartEvent;
import org.warp.picalculator.flow.BehaviorSubject; import org.warp.picalculator.flow.BehaviorSubject;
import org.warp.picalculator.flow.Observable; import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.RenderingLoop; import org.warp.picalculator.gui.graphicengine.RenderingLoop;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@ -56,7 +54,7 @@ public class SwingWindow extends JFrame {
final BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); final BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
mult = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()).intValue(); mult = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()).intValue();
if (StaticVars.debugOn) { if (StaticVars.debugOn) {
if (Utils.debugThirdScreen) { if (Utils.debugThirdScreen) {
this.setLocation(2880, 900); this.setLocation(2880, 900);
@ -87,7 +85,7 @@ public class SwingWindow extends JFrame {
CPURenderer.canvas2d = new int[disp.r.size[0] * disp.r.size[1]]; CPURenderer.canvas2d = new int[disp.r.size[0] * disp.r.size[1]];
disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB); disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB);
}); });
addComponentListener(new ComponentListener() { addComponentListener(new ComponentListener() {
@Override @Override
public void componentHidden(ComponentEvent e) { public void componentHidden(ComponentEvent e) {
@ -99,7 +97,7 @@ public class SwingWindow extends JFrame {
@Override @Override
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
onResize.onNext(new Integer[] {getWidth(), getHeight()}); onResize.onNext(new Integer[] { getWidth(), getHeight() });
} }
@Override @Override
@ -178,12 +176,11 @@ public class SwingWindow extends JFrame {
StaticVars.windowZoom$.subscribe((newZoomValue) -> { StaticVars.windowZoom$.subscribe((newZoomValue) -> {
if (newZoomValue != mult) { if (newZoomValue != mult) {
mult = (int) newZoomValue.floatValue(); mult = (int) newZoomValue.floatValue();
this.onResize.onNext(new Integer[] {getWidth(), getHeight()}); this.onResize.onNext(new Integer[] { getWidth(), getHeight() });
ConsoleUtils.out.println(3, "Engine", "CPU", "Zoom changed"); ConsoleUtils.out.println(3, "Engine", "CPU", "Zoom changed");
} }
}); });
} }
public Observable<Integer[]> onResize() { public Observable<Integer[]> onResize() {
return onResize$; return onResize$;

View File

@ -9,7 +9,6 @@ import java.util.concurrent.Semaphore;
import org.warp.picalculator.MmapByteBuffer; import org.warp.picalculator.MmapByteBuffer;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.TestJNI; import org.warp.picalculator.TestJNI;
import org.warp.picalculator.Utils;
import org.warp.picalculator.flow.BehaviorSubject; import org.warp.picalculator.flow.BehaviorSubject;
import org.warp.picalculator.flow.Observable; import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
@ -22,8 +21,11 @@ import org.warp.picalculator.gui.graphicengine.cpu.CPUSkin;
public class FBEngine implements GraphicEngine { public class FBEngine implements GraphicEngine {
@SuppressWarnings("unused")
private static final int FB_DISPLAY_WIDTH = 320; private static final int FB_DISPLAY_WIDTH = 320;
@SuppressWarnings("unused")
private static final int FB_DISPLAY_HEIGHT = 480; private static final int FB_DISPLAY_HEIGHT = 480;
@SuppressWarnings("unused")
private static final int FB_DISPLAY_BPP = 32; private static final int FB_DISPLAY_BPP = 32;
private static final int WIDTH = 480; private static final int WIDTH = 480;
private static final int HEIGHT = 320; private static final int HEIGHT = 320;
@ -36,7 +38,7 @@ public class FBEngine implements GraphicEngine {
private RandomAccessFile fbFileRW; private RandomAccessFile fbFileRW;
public volatile boolean initialized = false; public volatile boolean initialized = false;
public Semaphore exitSemaphore = new Semaphore(0); public Semaphore exitSemaphore = new Semaphore(0);
@Override @Override
public int[] getSize() { public int[] getSize() {
return SIZE; return SIZE;
@ -58,11 +60,11 @@ public class FBEngine implements GraphicEngine {
@Override @Override
public void create(Runnable onInitialized) { public void create(Runnable onInitialized) {
onResize = BehaviorSubject.create(new Integer[] {SIZE[0], SIZE[1]}); onResize = BehaviorSubject.create(new Integer[] { SIZE[0], SIZE[1] });
realFb = jni.retrieveBuffer(); realFb = jni.retrieveBuffer();
final long fbLen = realFb.getLength(); final long fbLen = realFb.getLength();
fb = (MappedByteBuffer) ByteBuffer.allocateDirect((int) fbLen); fb = (MappedByteBuffer) ByteBuffer.allocateDirect((int) fbLen);
r = new FBRenderer(this, fb); r = new FBRenderer(this, fb);
initialized = true; initialized = true;

View File

@ -81,7 +81,7 @@ public class GPUEngine implements GraphicEngine {
initialized = true; initialized = true;
wnd.onInitialized = onInitialized; wnd.onInitialized = onInitialized;
} }
@Override @Override
public Observable<Integer[]> onResize() { public Observable<Integer[]> onResize() {
return wnd.onResizeEvent; return wnd.onResizeEvent;

View File

@ -6,7 +6,6 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import org.warp.picalculator.PlatformUtils; import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine; import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.cpu.CPUFont; import org.warp.picalculator.gui.graphicengine.cpu.CPUFont;
@ -102,6 +101,7 @@ public class GPUFont implements BinaryFont {
return compressedIndex; return compressedIndex;
} }
@SuppressWarnings("unused")
private int decompressIndex(int compressedIndex) { private int decompressIndex(int compressedIndex) {
final int originalIndex = 0; final int originalIndex = 0;
int i = 0; int i = 0;

View File

@ -7,11 +7,11 @@ import java.io.IOException;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.file.Files; import java.nio.file.Files;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.warp.picalculator.PlatformUtils; import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.Renderer; import org.warp.picalculator.gui.graphicengine.Renderer;

View File

@ -8,7 +8,6 @@ import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Skin; import org.warp.picalculator.gui.graphicengine.Skin;
import org.warp.picalculator.gui.graphicengine.gpu.GPURenderer.OpenedTextureData; import org.warp.picalculator.gui.graphicengine.gpu.GPURenderer.OpenedTextureData;
import com.jogamp.opengl.GL2ES1;
import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.Texture;
@ -40,7 +39,6 @@ public class GPUSkin implements Skin {
public void initialize(GraphicEngine d) { public void initialize(GraphicEngine d) {
try { try {
final OpenedTextureData i = GPURenderer.openTexture(texturePath, isResource); final OpenedTextureData i = GPURenderer.openTexture(texturePath, isResource);
final GL2ES1 gl = GPURenderer.gl;
t = GPURenderer.importTexture(i.f, i.deleteOnExit); t = GPURenderer.importTexture(i.f, i.deleteOnExit);
w = i.w; w = i.w;
h = i.h; h = i.h;

View File

@ -94,22 +94,24 @@ class NEWTWindow implements GLEventListener {
disp.size[1] = StaticVars.screenSize[1]; disp.size[1] = StaticVars.screenSize[1];
realWindowSize = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] }; realWindowSize = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] };
windowZoom = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()); windowZoom = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue());
onRealResize = BehaviorSubject.create(new Integer[] {(int) (StaticVars.screenSize[0] * windowZoom), (int) (StaticVars.screenSize[1] * windowZoom)}); onRealResize = BehaviorSubject.create(new Integer[] { (int) (StaticVars.screenSize[0] * windowZoom), (int) (StaticVars.screenSize[1] * windowZoom) });
onRealResize.subscribe((realSize) -> { onRealResize.subscribe((realSize) -> {
System.err.println("[[[SET REALWINDOWZOOM"); System.err.println("[[[SET REALWINDOWZOOM");
realWindowSize[0] = realSize[0]; realWindowSize[0] = realSize[0];
realWindowSize[1] = realSize[1]; realWindowSize[1] = realSize[1];
disp.size[0] = realSize[0] / (int) windowZoom; disp.size[0] = realSize[0] / (int) windowZoom;
disp.size[1] = realSize[1] / (int) windowZoom; disp.size[1] = realSize[1] / (int) windowZoom;
System.err.println("[[["+realWindowSize[0]); System.err.println("[[[" + realWindowSize[0]);
System.err.println("[[["+windowZoom); System.err.println("[[[" + windowZoom);
System.err.println("[[["+disp.size[0]); System.err.println("[[[" + disp.size[0]);
onResizeEvent.onNext(new Integer[] {disp.size[0], disp.size[1]}); onResizeEvent.onNext(new Integer[] { disp.size[0], disp.size[1] });
refreshViewport = true; refreshViewport = true;
}); });
StaticVars.windowZoom$.subscribe((zoom) -> {onZoom.onNext(zoom);}); StaticVars.windowZoom$.subscribe((zoom) -> {
onZoom.subscribe((z)-> { onZoom.onNext(zoom);
});
onZoom.subscribe((z) -> {
if (windowZoom != 0) { if (windowZoom != 0) {
windowZoom = z; windowZoom = z;
disp.size[0] = (int) (realWindowSize[0] / windowZoom); disp.size[0] = (int) (realWindowSize[0] / windowZoom);
@ -117,9 +119,9 @@ class NEWTWindow implements GLEventListener {
StaticVars.screenSize[0] = disp.size[0]; StaticVars.screenSize[0] = disp.size[0];
StaticVars.screenSize[1] = disp.size[1]; StaticVars.screenSize[1] = disp.size[1];
System.err.println("[[[SET WINDOWZOOM"); System.err.println("[[[SET WINDOWZOOM");
System.err.println("[[["+realWindowSize[0]); System.err.println("[[[" + realWindowSize[0]);
System.err.println("[[["+windowZoom); System.err.println("[[[" + windowZoom);
System.err.println("[[[A:"+disp.size[0]); System.err.println("[[[A:" + disp.size[0]);
refreshViewport = true; refreshViewport = true;
} }
}); });
@ -142,12 +144,12 @@ class NEWTWindow implements GLEventListener {
caps.setBackgroundOpaque(true); //transparency window caps.setBackgroundOpaque(true); //transparency window
// caps.setSampleBuffers(true); // caps.setSampleBuffers(true);
// caps.setNumSamples(4); // caps.setNumSamples(4);
final GLWindow glWindow = GLWindow.create(caps); final GLWindow glWindow = GLWindow.create(caps);
window = glWindow; window = glWindow;
glWindow.setTitle("WarpPI Calculator by Andrea Cavalli (@Cavallium)"); glWindow.setTitle("WarpPI Calculator by Andrea Cavalli (@Cavallium)");
glWindow.addWindowListener(new WindowListener() { glWindow.addWindowListener(new WindowListener() {
@Override @Override
@ -372,6 +374,7 @@ class NEWTWindow implements GLEventListener {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
List<TouchPoint> newPoints = new ObjectArrayList<>(); List<TouchPoint> newPoints = new ObjectArrayList<>();
List<TouchPoint> changedPoints = new ObjectArrayList<>(); List<TouchPoint> changedPoints = new ObjectArrayList<>();
@SuppressWarnings("unused")
List<TouchPoint> oldPoints = touches; List<TouchPoint> oldPoints = touches;
int[] xs = e.getAllX(); int[] xs = e.getAllX();
int[] ys = e.getAllY(); int[] ys = e.getAllY();
@ -389,6 +392,7 @@ class NEWTWindow implements GLEventListener {
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
List<TouchPoint> newPoints = new ObjectArrayList<>(); List<TouchPoint> newPoints = new ObjectArrayList<>();
List<TouchPoint> changedPoints = new ObjectArrayList<>(); List<TouchPoint> changedPoints = new ObjectArrayList<>();
@SuppressWarnings("unused")
List<TouchPoint> oldPoints = touches; List<TouchPoint> oldPoints = touches;
int[] xs = e.getAllX(); int[] xs = e.getAllX();
int[] ys = e.getAllY(); int[] ys = e.getAllY();
@ -443,7 +447,7 @@ class NEWTWindow implements GLEventListener {
} }
}); });
glWindow.addGLEventListener(this /* GLEventListener */); glWindow.addGLEventListener(this /* GLEventListener */);
final Animator animator = new Animator(); final Animator animator = new Animator();
animator.add(glWindow); animator.add(glWindow);
@ -454,7 +458,7 @@ class NEWTWindow implements GLEventListener {
public void init(GLAutoDrawable drawable) { public void init(GLAutoDrawable drawable) {
final GL2ES1 gl = drawable.getGL().getGL2ES1(); final GL2ES1 gl = drawable.getGL().getGL2ES1();
onGLContext.onNext(gl); onGLContext.onNext(gl);
if (StaticVars.debugOn) { if (StaticVars.debugOn) {
//Vsync //Vsync
gl.setSwapInterval(1); gl.setSwapInterval(1);
@ -473,13 +477,13 @@ class NEWTWindow implements GLEventListener {
//Multisampling //Multisampling
//gl.glEnable(GL.GL_MULTISAMPLE); //gl.glEnable(GL.GL_MULTISAMPLE);
try { try {
renderer.currentTex = ((GPUSkin) disp.loadSkin("test.png")).t; renderer.currentTex = ((GPUSkin) disp.loadSkin("test.png")).t;
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (onInitialized != null) { if (onInitialized != null) {
onInitialized.run(); onInitialized.run();
onInitialized = null; onInitialized = null;
@ -494,7 +498,7 @@ class NEWTWindow implements GLEventListener {
@Override @Override
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
onRealResize.onNext(new Integer[] {width, height}); onRealResize.onNext(new Integer[] { width, height });
} }
@Override @Override
@ -502,7 +506,7 @@ class NEWTWindow implements GLEventListener {
final GL2ES1 gl = glad.getGL().getGL2ES1(); final GL2ES1 gl = glad.getGL().getGL2ES1();
GPURenderer.gl = gl; GPURenderer.gl = gl;
onGLContext.onNext(gl); onGLContext.onNext(gl);
boolean linear = (windowZoom % ((int) windowZoom)) != 0f; boolean linear = (windowZoom % ((int) windowZoom)) != 0f;
if (refreshViewport) { if (refreshViewport) {
System.err.println("[[[REFVP"); System.err.println("[[[REFVP");
@ -516,7 +520,7 @@ class NEWTWindow implements GLEventListener {
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity(); gl.glLoadIdentity();
for (final Texture t : disp.registeredTextures) { for (final Texture t : disp.registeredTextures) {
t.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, linear ? GL.GL_LINEAR : GL.GL_NEAREST); t.setTexParameteri(gl, GL.GL_TEXTURE_MAG_FILTER, linear ? GL.GL_LINEAR : GL.GL_NEAREST);
t.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); t.setTexParameteri(gl, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
@ -532,32 +536,32 @@ class NEWTWindow implements GLEventListener {
gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY); gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY); gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
renderer.initDrawCycle(); renderer.initDrawCycle();
disp.repaint(); disp.repaint();
renderer.endDrawCycle(); renderer.endDrawCycle();
gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY); gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY);
gl.glDisableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY); gl.glDisableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
GPURenderer.gl = null; GPURenderer.gl = null;
} }
void setSize(final int width, final int height) { void setSize(final int width, final int height) {
int zoom = (int) windowZoom; int zoom = (int) windowZoom;
if (zoom == 0) { if (zoom == 0) {
zoom = onZoom.getLastValue().intValue(); zoom = onZoom.getLastValue().intValue();
} }
if (zoom == 0) { if (zoom == 0) {
zoom = 1; zoom = 1;
} }
window.setSize(width * zoom, height * zoom); window.setSize(width * zoom, height * zoom);
onRealResize.onNext(new Integer[] {width * zoom, height * zoom}); onRealResize.onNext(new Integer[] { width * zoom, height * zoom });
} }
@Override @Override
public void dispose(GLAutoDrawable drawable) { public void dispose(GLAutoDrawable drawable) {

View File

@ -54,6 +54,7 @@ public class Headless24bitEngine implements org.warp.picalculator.gui.graphiceng
} }
@SuppressWarnings("unused")
private long outHandle; private long outHandle;
@Override @Override

View File

@ -1,7 +1,6 @@
package org.warp.picalculator.gui.graphicengine.headless8; package org.warp.picalculator.gui.graphicengine.headless8;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.Renderer; import org.warp.picalculator.gui.graphicengine.Renderer;
public class Headless8Renderer implements Renderer { public class Headless8Renderer implements Renderer {

View File

@ -1,9 +1,7 @@
package org.warp.picalculator.gui.graphicengine.nogui; package org.warp.picalculator.gui.graphicengine.nogui;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.Semaphore;
import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DSemaphore; import org.warp.picalculator.deps.DSemaphore;
import org.warp.picalculator.flow.Observable; import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;

View File

@ -3,9 +3,7 @@ package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.functions.Variable.VariableValue; import org.warp.picalculator.math.functions.Variable.VariableValue;

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.gui.screens; package org.warp.picalculator.gui.screens;
import org.warp.picalculator.event.Key;
public class EmptyScreen extends Screen { public class EmptyScreen extends Screen {
public float endLoading; public float endLoading;

View File

@ -2,10 +2,8 @@ package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent; import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.Renderer; import org.warp.picalculator.gui.graphicengine.Renderer;
public class KeyboardDebugScreen extends Screen { public class KeyboardDebugScreen extends Screen {

View File

@ -2,8 +2,6 @@ package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GraphicUtils; import org.warp.picalculator.gui.GraphicUtils;
public class LoadingScreen extends Screen { public class LoadingScreen extends Screen {

View File

@ -5,10 +5,8 @@ import java.io.IOException;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.device.Keyboard; import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.extra.mario.MarioGame; import org.warp.picalculator.extra.mario.MarioGame;
import org.warp.picalculator.extra.mario.MarioWorld; import org.warp.picalculator.extra.mario.MarioWorld;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.Skin; import org.warp.picalculator.gui.graphicengine.Skin;

View File

@ -1,8 +1,6 @@
package org.warp.picalculator.gui.screens; package org.warp.picalculator.gui.screens;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.Error; import org.warp.picalculator.Error;
@ -16,7 +14,6 @@ import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key; import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent; import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.expression.InputContext; import org.warp.picalculator.gui.expression.InputContext;
import org.warp.picalculator.gui.expression.blocks.Block; import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockContainer; import org.warp.picalculator.gui.expression.blocks.BlockContainer;
@ -58,6 +55,7 @@ public class MathInputScreen extends Screen {
private double computingElapsedTime = 0; private double computingElapsedTime = 0;
private boolean computingBreakTipVisible = false; private boolean computingBreakTipVisible = false;
boolean mustRefresh = true; boolean mustRefresh = true;
@SuppressWarnings("unused")
private int currentStep = 0; private int currentStep = 0;
public MathInputScreen() { public MathInputScreen() {

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.gui.screens; package org.warp.picalculator.gui.screens;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener; import org.warp.picalculator.event.KeyboardEventListener;
import org.warp.picalculator.event.TouchEventListener; import org.warp.picalculator.event.TouchEventListener;
import org.warp.picalculator.gui.DisplayManager; import org.warp.picalculator.gui.DisplayManager;

View File

@ -2,9 +2,7 @@ package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.HardwareDevice; import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent; import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.gui.DisplayManager;
public class SolveForXScreen extends Screen { public class SolveForXScreen extends Screen {

View File

@ -7,6 +7,7 @@ import org.warp.picalculator.gui.expression.blocks.BlockDivision;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator; import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Division extends FunctionOperator { public class Division extends FunctionOperator {

View File

@ -8,6 +8,7 @@ import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator; import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols; import org.warp.picalculator.math.MathematicalSymbols;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Multiplication extends FunctionOperator { public class Multiplication extends FunctionOperator {

View File

@ -3,6 +3,7 @@ package org.warp.picalculator.math.functions;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.LinkedList; import java.util.LinkedList;
import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.BigDecimalMath;
import org.warp.picalculator.Error; import org.warp.picalculator.Error;
import org.warp.picalculator.Utils; import org.warp.picalculator.Utils;

View File

@ -7,6 +7,7 @@ import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator; import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols; import org.warp.picalculator.math.MathematicalSymbols;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Sum extends FunctionOperator { public class Sum extends FunctionOperator {

View File

@ -5,6 +5,7 @@ import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionDynamic; import org.warp.picalculator.math.FunctionDynamic;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class EquationsSystem extends FunctionDynamic { public class EquationsSystem extends FunctionDynamic {

View File

@ -7,6 +7,7 @@ import org.warp.picalculator.gui.expression.blocks.BlockSine;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionSingle; import org.warp.picalculator.math.FunctionSingle;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Sine extends FunctionSingle { public class Sine extends FunctionSingle {

View File

@ -10,6 +10,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class RemoveParentheses implements MathParserStep { public class RemoveParentheses implements MathParserStep {
@SuppressWarnings("unused")
private final MathContext context; private final MathContext context;
public RemoveParentheses(MathContext context) { public RemoveParentheses(MathContext context) {

View File

@ -4,7 +4,6 @@ import org.warp.picalculator.Error;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
/** /**
* Rule interface * Rule interface
@ -27,7 +26,6 @@ public interface Rule {
* *
* @return * @return
*/ */
@SpecializedFunction
public RuleType getRuleType(); public RuleType getRuleType();
/** /**

View File

@ -8,26 +8,19 @@ import java.io.InputStream;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import org.apache.commons.io.IOUtils;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.Error; import org.warp.picalculator.Error;
import org.warp.picalculator.PlatformUtils; import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars; import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.ZipUtils; import org.warp.picalculator.ZipUtils;
import org.warp.picalculator.deps.StorageUtils;
import org.warp.picalculator.deps.DJDTCompiler; import org.warp.picalculator.deps.DJDTCompiler;
import org.warp.picalculator.deps.DStandardOpenOption; import org.warp.picalculator.deps.DStandardOpenOption;
import org.warp.picalculator.deps.DSystem; import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.deps.DURLClassLoader; import org.warp.picalculator.deps.DURLClassLoader;
import org.warp.picalculator.deps.StorageUtils;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Expression; import org.warp.picalculator.math.functions.Expression;
@ -43,7 +36,7 @@ public class RulesManager {
private RulesManager() {} private RulesManager() {}
@SuppressWarnings({ "unchecked", "unused" }) @SuppressWarnings({ "unchecked" })
public static void initialize() { public static void initialize() {
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules"); ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules");
rules = new ObjectArrayList[RuleType.values().length]; rules = new ObjectArrayList[RuleType.values().length];

View File

@ -4,6 +4,7 @@ import org.warp.picalculator.Error;
import org.warp.picalculator.math.Function; import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.MathContext; import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Multiplication; import org.warp.picalculator.math.functions.Multiplication;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/** /**

View File

@ -1,7 +1,6 @@
package org.warp.picalculator.math.solver; package org.warp.picalculator.math.solver;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.warp.picalculator.ConsoleUtils; import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.Error; import org.warp.picalculator.Error;
@ -12,7 +11,6 @@ import org.warp.picalculator.math.rules.Rule;
import org.warp.picalculator.math.rules.RuleType; import org.warp.picalculator.math.rules.RuleType;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class MathSolver { public class MathSolver {
@ -114,6 +112,7 @@ public class MathSolver {
return false; return false;
} }
@SuppressWarnings("unused")
private ObjectArrayList<Function> solveStep(ObjectArrayList<Function> fncs) throws InterruptedException, Error { private ObjectArrayList<Function> solveStep(ObjectArrayList<Function> fncs) throws InterruptedException, Error {
return solveStep(fncs, stepState); return solveStep(fncs, stepState);
} }
@ -143,8 +142,7 @@ public class MathSolver {
break; break;
} }
default: default:
System.err.println("Unknown Step State"); throw new RuntimeException("Unknown Step State");
throw new NotImplementedException();
} }
final ObjectArrayList<Function> results = applyRules(fncs, currentAcceptedRules); final ObjectArrayList<Function> results = applyRules(fncs, currentAcceptedRules);
switch (stepStates[stepState.get()]) { switch (stepStates[stepState.get()]) {
@ -203,8 +201,7 @@ public class MathSolver {
break; break;
} }
default: default:
System.err.println("Unknown Step State"); throw new RuntimeException("Unknown Step State");
throw new NotImplementedException();
} }
return null; return null;
} }
@ -214,28 +211,26 @@ public class MathSolver {
final ObjectArrayList<Rule> rules = initialFunction.getMathContext().getAcceptableRules(currentAcceptedRules); final ObjectArrayList<Rule> rules = initialFunction.getMathContext().getAcceptableRules(currentAcceptedRules);
ObjectArrayList<Function> results = null; ObjectArrayList<Function> results = null;
ObjectArrayList<Rule> appliedRules = new ObjectArrayList<>(); ObjectArrayList<Rule> appliedRules = new ObjectArrayList<>();
out: { for (final Function fnc : fncs) {
for (final Function fnc : fncs) { boolean didSomething = false;
boolean didSomething = false; for (final Rule rule : rules) {
for (final Rule rule : rules) { List<Function> ruleResults = fnc.simplify(rule);
List<Function> ruleResults = fnc.simplify(rule); if ((ruleResults != null && !ruleResults.isEmpty())) {
if ((ruleResults != null && !ruleResults.isEmpty())) {
if (results == null) {
results = new ObjectArrayList<>();
}
results.addAll(ruleResults);
appliedRules.add(rule);
didSomething = true;
break;
}
}
if (!didSomething && fncs.size() > 1) {
if (results == null) { if (results == null) {
results = new ObjectArrayList<>(); results = new ObjectArrayList<>();
} }
results.add(fnc); results.addAll(ruleResults);
appliedRules.add(rule);
didSomething = true;
break;
} }
} }
if (!didSomething && fncs.size() > 1) {
if (results == null) {
results = new ObjectArrayList<>();
}
results.add(fnc);
}
} }
if (appliedRules.isEmpty()) if (appliedRules.isEmpty())
results = null; results = null;