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>
<nature>org.eclipse.m2e.core.maven2Nature</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>
</projectDescription>

10
pom.xml
View File

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

View File

@ -184,7 +184,7 @@ public class PngReaderApng extends PngReaderByte {
@Override
protected boolean countChunkTypeAsAncillary(String id) {
// 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) {
if (StaticVars.outputLevel >= level) {
final String time = getTimeString();
if (StaticVars.outputLevel == 0) {
println(System.out);
} else {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,10 @@
*/
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.FileSystems;
import java.nio.file.Files;

View File

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

View File

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

View File

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

View File

@ -3,8 +3,8 @@ package org.warp.picalculator;
import java.util.function.Function;
import org.warp.picalculator.boot.StartupArguments;
import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.flow.BehaviorSubject;
import org.warp.picalculator.flow.Observable;
public class StaticVars {
public static final boolean enableVBO = true;
@ -14,7 +14,7 @@ public class StaticVars {
public static boolean haxMode = true;
public static final boolean zoomed = true;
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 int outputLevel = 0;
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.DSystem;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.event.KeyboardEventListener;

View File

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

View File

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

View File

@ -1,9 +1,9 @@
package org.warp.picalculator.boot;
import java.util.Arrays;
import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PICalculator;
import org.warp.picalculator.flow.TestFlow;
public class Main {
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());
return args;
}
public static void parseArgument(StartupArgumentsImpl args, String arg) {
switch (arg) {
case "-zoomed":

View File

@ -166,6 +166,5 @@ public class StartupArgumentsImpl implements StartupArguments {
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}";
}
}

View File

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

View File

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

View File

@ -1,16 +1,5 @@
package org.warp.picalculator.event;
public enum Key {
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,
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,
}

View File

@ -39,7 +39,9 @@ public class MarioGame {
final double curY = player.getY();
final double futureX = curX + deltaX;
final double futureY = curY + deltaY;
@SuppressWarnings("unused")
final boolean forward = futureX >= curX;
@SuppressWarnings("unused")
final boolean up = 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) {
final double aa = Math.abs(val - a);
final double ab = Math.abs(val - b);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,8 @@
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> {
protected SimpleSubject() {
}
protected SimpleSubject() {}
public final static <T> SimpleSubject<T> create() {
return new SimpleSubject<>();
@ -18,21 +12,21 @@ public class SimpleSubject<T> extends Subject<T> {
public void onComplete() {
for (Subscriber<? super T> sub : this.subscribers) {
sub.onComplete();
};
} ;
}
@Override
public void onError(Throwable e) {
for (Subscriber<? super T> sub : this.subscribers) {
sub.onError(e);
};
} ;
}
@Override
public void onNext(T t) {
for (Subscriber<? super T> sub : this.subscribers) {
sub.onNext(t);
};
} ;
}
@Override
@ -66,7 +60,6 @@ public class SimpleSubject<T> extends Subject<T> {
}
@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> {
abstract Throwable getThrowable();
abstract boolean hasComplete();
abstract boolean hasObservers();
abstract boolean hasThrowable();
abstract Subject<T> toSerialized();
@Override
public Disposable subscribe(Action1<? super T> onNext) {
return subscribe(createSubscriber(onNext));
}
@Override
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) {
return subscribe(createSubscriber(onNext, onError));
}
@Override
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) {
return subscribe(createSubscriber(onNext, onError, onCompl));
}
@Override
public void subscribe(Observer<? super T> obs) {
subscribe(createSubscriber(obs));

View File

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

View File

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

View File

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

View File

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

View File

@ -3,26 +3,15 @@ package org.warp.picalculator.gui;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.tuple.Pair;
import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DEngine;
import org.warp.picalculator.deps.DSemaphore;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.device.HardwareDevice;
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.gui.graphicengine.BinaryFont;
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.screens.Screen;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public final class DisplayManager implements RenderingLoop {
private static final int tickDuration = 50;
private HardwareDevice device;
private float brightness;
public final GraphicEngine engine;
@ -400,9 +387,9 @@ public final class DisplayManager implements RenderingLoop {
e.printStackTrace();
DSystem.exit(0);
}
Observable<Long> workTimer = Observable.interval(tickDuration);
Observable<Integer[]> onResizeObservable = engine.onResize();
Observable<Pair<Long, Integer[]>> refreshObservable;
if (onResizeObservable == null) {
@ -410,7 +397,7 @@ public final class DisplayManager implements RenderingLoop {
} else {
refreshObservable = Observable.combineChanged(workTimer, engine.onResize());
}
refreshObservable.subscribe((pair) -> {
double dt = 0;
final long newtime = System.nanoTime();
@ -426,7 +413,7 @@ public final class DisplayManager implements RenderingLoop {
StaticVars.screenSize[0] = windowSize[0];
StaticVars.screenSize[1] = windowSize[1];
}
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.Errors;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.gui.GraphicalElement;
import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.expression.CaretState;

View File

@ -23,6 +23,7 @@ public class BlockLogarithm extends Block {
private int bl;
private int chw;
private int chh;
@SuppressWarnings("unused")
private int schh;
private int nmbh;
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.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
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.ExtraMenu;
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.BlockContainer;
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.BlockParenthesis;
import org.warp.picalculator.gui.expression.blocks.BlockPower;
import org.warp.picalculator.gui.expression.blocks.BlockReference;
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.BlockVariable;
import org.warp.picalculator.math.MathematicalSymbols;
@ -97,7 +97,7 @@ public class NormalInputContainer extends InputContainer {
case MathematicalSymbols.DIVISION:
@SuppressWarnings("unchecked")
final BlockReference<BlockDivision> ref = (BlockReference<BlockDivision>) getSelectedBlock();
final BlockContainer parentContainer = ref.getContainer();
@SuppressWarnings("unused") final BlockContainer parentContainer = ref.getContainer();
BlockReference<?> currentBlock = ref;
boolean groupedBefore = false;
int before = 0;

View File

@ -9,7 +9,6 @@ import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.HardwareDevice;
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.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;

View File

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

View File

@ -3,17 +3,11 @@ package org.warp.picalculator.gui.graphicengine.cpu;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
import javax.imageio.ImageIO;
import org.warp.picalculator.deps.DSystem;
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.Skin;
@ -24,6 +18,7 @@ public class CPUSkin implements Skin {
public int[] skinData;
public int[] skinSize;
@SuppressWarnings("unused")
private final boolean isResource;
public CPUSkin(String file) throws IOException {
@ -84,7 +79,7 @@ public class CPUSkin implements Skin {
} else if (channels == 3) {
nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | (scanLine[offset + 2]) | (0xFF << 24);
} else if (channels == 2) {
nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24);
nextPixel = (scanLine[offset] << 16) | (scanLine[offset + 1] << 8) | 0xFF | (0xFF << 24);
} else {
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 org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
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.flow.BehaviorSubject;
import org.warp.picalculator.flow.Observable;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
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);
mult = StaticVars.windowZoomFunction.apply(StaticVars.windowZoom.getLastValue()).intValue();
if (StaticVars.debugOn) {
if (Utils.debugThirdScreen) {
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]];
disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB);
});
addComponentListener(new ComponentListener() {
@Override
public void componentHidden(ComponentEvent e) {
@ -99,7 +97,7 @@ public class SwingWindow extends JFrame {
@Override
public void componentResized(ComponentEvent e) {
onResize.onNext(new Integer[] {getWidth(), getHeight()});
onResize.onNext(new Integer[] { getWidth(), getHeight() });
}
@Override
@ -178,12 +176,11 @@ public class SwingWindow extends JFrame {
StaticVars.windowZoom$.subscribe((newZoomValue) -> {
if (newZoomValue != mult) {
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");
}
});
}
public Observable<Integer[]> onResize() {
return onResize$;

View File

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

View File

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

View File

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

View File

@ -7,11 +7,11 @@ import java.io.IOException;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.file.Files;
import javax.imageio.ImageIO;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
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.gpu.GPURenderer.OpenedTextureData;
import com.jogamp.opengl.GL2ES1;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.texture.Texture;
@ -40,7 +39,6 @@ public class GPUSkin implements Skin {
public void initialize(GraphicEngine d) {
try {
final OpenedTextureData i = GPURenderer.openTexture(texturePath, isResource);
final GL2ES1 gl = GPURenderer.gl;
t = GPURenderer.importTexture(i.f, i.deleteOnExit);
w = i.w;
h = i.h;

View File

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

View File

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

View File

@ -1,9 +1,7 @@
package org.warp.picalculator.gui.graphicengine.nogui;
import java.io.IOException;
import java.util.concurrent.Semaphore;
import org.warp.picalculator.Utils;
import org.warp.picalculator.deps.DSemaphore;
import org.warp.picalculator.flow.Observable;
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.Utils;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.functions.Variable.VariableValue;

View File

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

View File

@ -2,10 +2,8 @@ package org.warp.picalculator.gui.screens;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.event.KeyReleasedEvent;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.Renderer;
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.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GraphicUtils;
public class LoadingScreen extends Screen {

View File

@ -5,10 +5,8 @@ import java.io.IOException;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.HardwareDevice;
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.MarioWorld;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.Skin;

View File

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

View File

@ -1,7 +1,5 @@
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.TouchEventListener;
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.device.HardwareDevice;
import org.warp.picalculator.event.Key;
import org.warp.picalculator.event.KeyPressedEvent;
import org.warp.picalculator.gui.DisplayManager;
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.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
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.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Multiplication extends FunctionOperator {

View File

@ -3,6 +3,7 @@ package org.warp.picalculator.math.functions;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.LinkedList;
import org.nevec.rjm.BigDecimalMath;
import org.warp.picalculator.Error;
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.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
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.FunctionDynamic;
import org.warp.picalculator.math.MathContext;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
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.FunctionSingle;
import org.warp.picalculator.math.MathContext;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Sine extends FunctionSingle {

View File

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

View File

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

View File

@ -8,26 +8,19 @@ import java.io.InputStream;
import java.io.PrintWriter;
import java.net.URISyntaxException;
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.List;
import java.util.stream.Stream;
import org.apache.commons.io.IOUtils;
import org.warp.picalculator.ConsoleUtils;
import org.warp.picalculator.Error;
import org.warp.picalculator.PlatformUtils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.ZipUtils;
import org.warp.picalculator.deps.StorageUtils;
import org.warp.picalculator.deps.DJDTCompiler;
import org.warp.picalculator.deps.DStandardOpenOption;
import org.warp.picalculator.deps.DSystem;
import org.warp.picalculator.deps.DURLClassLoader;
import org.warp.picalculator.deps.StorageUtils;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Expression;
@ -43,7 +36,7 @@ public class RulesManager {
private RulesManager() {}
@SuppressWarnings({ "unchecked", "unused" })
@SuppressWarnings({ "unchecked" })
public static void initialize() {
ConsoleUtils.out.println(ConsoleUtils.OUTPUTLEVEL_NODEBUG, "RulesManager", "Loading the rules");
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.MathContext;
import org.warp.picalculator.math.functions.Multiplication;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/**

View File

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