Code cleanup
This commit is contained in:
parent
1b1cfa08fa
commit
b57ae900e5
@ -21,15 +21,14 @@ public class Engine {
|
||||
private static Platform platform;
|
||||
private static boolean running = false;
|
||||
private static BehaviorSubject<LoadingStatus> loadPhase = BehaviorSubject.create();
|
||||
private BehaviorSubject<Boolean> loaded = BehaviorSubject.create(false);
|
||||
private final BehaviorSubject<Boolean> loaded = BehaviorSubject.create(false);
|
||||
private HardwareDevice hardwareDevice;
|
||||
|
||||
private Engine() {
|
||||
}
|
||||
private Engine() {}
|
||||
|
||||
/**
|
||||
* Start an instance of the calculator.
|
||||
*
|
||||
*
|
||||
* @param platform
|
||||
* Platform implementation
|
||||
* @param screen
|
||||
@ -43,32 +42,34 @@ public class Engine {
|
||||
* @throws InterruptedException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void start(Platform platform, Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud,
|
||||
StartupArguments args) throws InterruptedException, IOException {
|
||||
if (running) {
|
||||
public static void start(final Platform platform, final Screen screen, final HardwareDisplay disp,
|
||||
final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
|
||||
throws InterruptedException, IOException {
|
||||
if (Engine.running)
|
||||
throw new RuntimeException("Already running!");
|
||||
} else {
|
||||
running = true;
|
||||
INSTANCE.startInstance(platform, screen, disp, touchdevice, hud, args);
|
||||
else {
|
||||
Engine.running = true;
|
||||
Engine.INSTANCE.startInstance(platform, screen, disp, touchdevice, hud, args);
|
||||
}
|
||||
}
|
||||
|
||||
private void startInstance(final Platform platform, Screen screen, HardwareDisplay disp, HardwareTouchDevice touchdevice, HUD hud,
|
||||
StartupArguments args) throws InterruptedException, IOException {
|
||||
private void startInstance(final Platform platform, final Screen screen, final HardwareDisplay disp,
|
||||
final HardwareTouchDevice touchdevice, final HUD hud, final StartupArguments args)
|
||||
throws InterruptedException, IOException {
|
||||
Engine.platform = platform;
|
||||
platform.getConsoleUtils().out().println("WarpPI Calculator");
|
||||
initializeEnvironment(args);
|
||||
|
||||
Thread currentThread = Thread.currentThread();
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
currentThread.setPriority(Thread.MAX_PRIORITY);
|
||||
Engine.getPlatform().setThreadName(currentThread, "Main thread");
|
||||
|
||||
DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
|
||||
Keyboard k = new Keyboard();
|
||||
InputManager im = new InputManager(k, touchdevice);
|
||||
final DisplayManager dm = new DisplayManager(disp, hud, screen, "WarpPI Calculator by Andrea Cavalli (@Cavallium)");
|
||||
final Keyboard k = new Keyboard();
|
||||
final InputManager im = new InputManager(k, touchdevice);
|
||||
hardwareDevice = new HardwareDevice(dm, im);
|
||||
|
||||
hardwareDevice.setup(() -> loadPhase.onNext(new LoadingStatus()));
|
||||
|
||||
hardwareDevice.setup(() -> Engine.loadPhase.onNext(new LoadingStatus()));
|
||||
}
|
||||
|
||||
private void onShutdown() {
|
||||
@ -79,13 +80,12 @@ public class Engine {
|
||||
Engine.getPlatform().exit(0);
|
||||
}
|
||||
|
||||
private void initializeEnvironment(StartupArguments args) throws IOException {
|
||||
private void initializeEnvironment(final StartupArguments args) throws IOException {
|
||||
ClassUtils.classLoader = this.getClass();
|
||||
StaticVars.startupArguments = args;
|
||||
StaticVars.debugWindow2x = args.isZoomed();
|
||||
if (args.isVerboseLoggingEnabled() || args.isDebugEnabled()) {
|
||||
if (args.isVerboseLoggingEnabled() || args.isDebugEnabled())
|
||||
StaticVars.outputLevel = ConsoleUtils.OUTPUTLEVEL_DEBUG_VERBOSE;
|
||||
}
|
||||
Engine.platform.getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, args);
|
||||
checkDeviceType();
|
||||
if (Engine.getPlatform().isRunningOnRaspberry() && args.isRaspberryModeAllowed()) {
|
||||
@ -111,15 +111,15 @@ public class Engine {
|
||||
}
|
||||
|
||||
public Observable<LoadingStatus> getLoadPhase() {
|
||||
return loadPhase;
|
||||
return Engine.loadPhase;
|
||||
}
|
||||
|
||||
|
||||
public HardwareDevice getHardwareDevice() {
|
||||
return hardwareDevice;
|
||||
}
|
||||
|
||||
|
||||
public static Platform getPlatform() {
|
||||
return platform;
|
||||
return Engine.platform;
|
||||
}
|
||||
|
||||
public static class LoadingStatus {
|
||||
|
@ -14,166 +14,189 @@ import it.cavallium.warppi.util.Error;
|
||||
|
||||
public interface Platform {
|
||||
|
||||
public ConsoleUtils getConsoleUtils();
|
||||
public Gpio getGpio();
|
||||
public StorageUtils getStorageUtils();
|
||||
public PngUtils getPngUtils();
|
||||
public Settings getSettings();
|
||||
ConsoleUtils getConsoleUtils();
|
||||
|
||||
public void setThreadName(Thread t, String name);
|
||||
public void setThreadDaemon(Thread t);
|
||||
public void setThreadDaemon(Thread t, boolean value);
|
||||
Gpio getGpio();
|
||||
|
||||
public void exit(int value);
|
||||
public void gc();
|
||||
StorageUtils getStorageUtils();
|
||||
|
||||
public boolean isJavascript();
|
||||
public boolean isRunningOnRaspberry();
|
||||
|
||||
public String getOsName();
|
||||
PngUtils getPngUtils();
|
||||
|
||||
public void alphaChanged(boolean val);
|
||||
public void shiftChanged(boolean val);
|
||||
Settings getSettings();
|
||||
|
||||
public Semaphore newSemaphore();
|
||||
public Semaphore newSemaphore(int i);
|
||||
|
||||
public URLClassLoader newURLClassLoader(URL[] urls);
|
||||
void setThreadName(Thread t, String name);
|
||||
|
||||
public Map<String, GraphicEngine> getEnginesList();
|
||||
public GraphicEngine getEngine(String string) throws NullPointerException;
|
||||
void setThreadDaemon(Thread t);
|
||||
|
||||
public void throwNewExceptionInInitializerError(String text);
|
||||
public String[] stacktraceToString(Error e);
|
||||
void setThreadDaemon(Thread t, boolean value);
|
||||
|
||||
public void loadPlatformRules();
|
||||
public void zip(String targetPath, String destinationFilePath, String password);
|
||||
public void unzip(String targetZipFilePath, String destinationFolderPath, String password);
|
||||
void exit(int value);
|
||||
|
||||
public boolean compile(String[] command, PrintWriter printWriter, PrintWriter errors);
|
||||
void gc();
|
||||
|
||||
boolean isJavascript();
|
||||
|
||||
boolean isRunningOnRaspberry();
|
||||
|
||||
String getOsName();
|
||||
|
||||
void alphaChanged(boolean val);
|
||||
|
||||
void shiftChanged(boolean val);
|
||||
|
||||
Semaphore newSemaphore();
|
||||
|
||||
Semaphore newSemaphore(int i);
|
||||
|
||||
URLClassLoader newURLClassLoader(URL[] urls);
|
||||
|
||||
Map<String, GraphicEngine> getEnginesList();
|
||||
|
||||
GraphicEngine getEngine(String string) throws NullPointerException;
|
||||
|
||||
void throwNewExceptionInInitializerError(String text);
|
||||
|
||||
String[] stacktraceToString(Error e);
|
||||
|
||||
void loadPlatformRules();
|
||||
|
||||
void zip(String targetPath, String destinationFilePath, String password);
|
||||
|
||||
void unzip(String targetZipFilePath, String destinationFolderPath, String password);
|
||||
|
||||
boolean compile(String[] command, PrintWriter printWriter, PrintWriter errors);
|
||||
|
||||
public interface Gpio {
|
||||
public int valueOutput();
|
||||
public int valuePwmOutput();
|
||||
public int valueInput();
|
||||
public int valueHigh();
|
||||
public int valueLow();
|
||||
public Object valueUnknownBoardType();
|
||||
int valueOutput();
|
||||
|
||||
public void wiringPiSetupPhys();
|
||||
int valuePwmOutput();
|
||||
|
||||
public void pinMode(int i, int type);
|
||||
int valueInput();
|
||||
|
||||
public void digitalWrite(int pin, int val);
|
||||
int valueHigh();
|
||||
|
||||
public void digitalWrite(int pin, boolean val);
|
||||
int valueLow();
|
||||
|
||||
public void pwmWrite(int pin, int val);
|
||||
|
||||
public void delayMicroseconds(int t);
|
||||
Object valueUnknownBoardType();
|
||||
|
||||
public int digitalRead(int pin);
|
||||
void wiringPiSetupPhys();
|
||||
|
||||
public Object getBoardType();
|
||||
void pinMode(int i, int type);
|
||||
|
||||
void digitalWrite(int pin, int val);
|
||||
|
||||
void digitalWrite(int pin, boolean val);
|
||||
|
||||
void pwmWrite(int pin, int val);
|
||||
|
||||
void delayMicroseconds(int t);
|
||||
|
||||
int digitalRead(int pin);
|
||||
|
||||
Object getBoardType();
|
||||
}
|
||||
|
||||
|
||||
public interface ConsoleUtils {
|
||||
public static final int OUTPUTLEVEL_NODEBUG = 0;
|
||||
public static final int OUTPUTLEVEL_DEBUG_MIN = 1;
|
||||
public static final int OUTPUTLEVEL_DEBUG_VERBOSE = 4;
|
||||
|
||||
public AdvancedOutputStream out();
|
||||
|
||||
public int getOutputLevel();
|
||||
|
||||
int OUTPUTLEVEL_NODEBUG = 0;
|
||||
int OUTPUTLEVEL_DEBUG_MIN = 1;
|
||||
int OUTPUTLEVEL_DEBUG_VERBOSE = 4;
|
||||
|
||||
AdvancedOutputStream out();
|
||||
|
||||
int getOutputLevel();
|
||||
|
||||
public interface AdvancedOutputStream {
|
||||
public void println(Object str);
|
||||
void println(Object str);
|
||||
|
||||
public void println(int level);
|
||||
void println(int level);
|
||||
|
||||
public void println(int level, Object str);
|
||||
void println(int level, Object str);
|
||||
|
||||
public void print(int level, String str);
|
||||
void print(int level, String str);
|
||||
|
||||
public void println(int level, String prefix, String str);
|
||||
void println(int level, String prefix, String str);
|
||||
|
||||
public void println(int level, String... parts);
|
||||
void println(int level, String... parts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface StorageUtils {
|
||||
int OpenOptionWrite = 0;
|
||||
int OpenOptionCreate = 1;
|
||||
|
||||
public boolean exists(File f);
|
||||
boolean exists(File f);
|
||||
|
||||
public File get(String path);
|
||||
File get(String path);
|
||||
|
||||
public File get(String... path);
|
||||
File get(String... path);
|
||||
|
||||
@Deprecated()
|
||||
public File getResource(String string) throws IOException, URISyntaxException;
|
||||
File getResource(String string) throws IOException, URISyntaxException;
|
||||
|
||||
public InputStream getResourceStream(String string) throws IOException, URISyntaxException;
|
||||
InputStream getResourceStream(String string) throws IOException, URISyntaxException;
|
||||
|
||||
public List<String> readAllLines(File file) throws IOException;
|
||||
|
||||
public String read(InputStream input) throws IOException;
|
||||
List<String> readAllLines(File file) throws IOException;
|
||||
|
||||
public List<File> walk(File dir) throws IOException;
|
||||
String read(InputStream input) throws IOException;
|
||||
|
||||
public File relativize(File rulesPath, File f);
|
||||
List<File> walk(File dir) throws IOException;
|
||||
|
||||
public File resolve(File file, String string);
|
||||
|
||||
public File getParent(File f);
|
||||
File relativize(File rulesPath, File f);
|
||||
|
||||
public void createDirectories(File dir) throws IOException;
|
||||
File resolve(File file, String string);
|
||||
|
||||
public void write(File f, byte[] bytes, int... options) throws IOException;
|
||||
File getParent(File f);
|
||||
|
||||
public List<String> readAllLines(InputStream input) throws IOException;
|
||||
void createDirectories(File dir) throws IOException;
|
||||
|
||||
public String getBasePath();
|
||||
void write(File f, byte[] bytes, int... options) throws IOException;
|
||||
|
||||
List<String> readAllLines(InputStream input) throws IOException;
|
||||
|
||||
String getBasePath();
|
||||
}
|
||||
|
||||
|
||||
public interface Semaphore {
|
||||
void release();
|
||||
|
||||
void acquire() throws InterruptedException;
|
||||
}
|
||||
|
||||
|
||||
public interface URLClassLoader {
|
||||
public Class<?> loadClass(String name) throws ClassNotFoundException;
|
||||
Class<?> loadClass(String name) throws ClassNotFoundException;
|
||||
|
||||
void close() throws IOException;
|
||||
}
|
||||
|
||||
|
||||
public interface PngUtils {
|
||||
|
||||
public PngReader load(InputStream resourceStream);
|
||||
|
||||
PngReader load(InputStream resourceStream);
|
||||
|
||||
public interface PngReader {
|
||||
|
||||
int[] getImageMatrix();
|
||||
|
||||
int[] getSize();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public interface Settings {
|
||||
|
||||
public boolean isDebugEnabled();
|
||||
boolean isDebugEnabled();
|
||||
|
||||
public void setDebugEnabled(boolean debugOn);
|
||||
void setDebugEnabled(boolean debugOn);
|
||||
|
||||
public default String getCalculatorName() {
|
||||
default String getCalculatorName() {
|
||||
return "WarpPI";
|
||||
}
|
||||
public default String getCalculatorNameLowercase() {
|
||||
|
||||
default String getCalculatorNameLowercase() {
|
||||
return "warppi";
|
||||
}
|
||||
public default String getCalculatorNameUppercase() {
|
||||
|
||||
default String getCalculatorNameUppercase() {
|
||||
return "WARPPI";
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,12 @@ public class StaticVars {
|
||||
public static boolean debugWindow2x = false;
|
||||
public static BehaviorSubject<Float> windowZoom = BehaviorSubject.create(2F);
|
||||
public static Function<Float, Float> windowZoomFunction = (val) -> {
|
||||
if (StaticVars.debugWindow2x) {
|
||||
if (StaticVars.debugWindow2x)
|
||||
return val + 1;
|
||||
} else {
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
public static Observable<Float> windowZoom$ = windowZoom.map(windowZoomFunction);
|
||||
public static Observable<Float> windowZoom$ = StaticVars.windowZoom.map(StaticVars.windowZoomFunction);
|
||||
public static StartupArguments startupArguments;
|
||||
|
||||
private StaticVars() {
|
||||
|
@ -1,25 +1,23 @@
|
||||
package it.cavallium.warppi;
|
||||
|
||||
public class TestDrivers {
|
||||
public static void main(String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
System.out.println("Test started.");
|
||||
String className;
|
||||
className = "jogamp.newt.driver.bcm.vc.iv.DisplayDriver";
|
||||
if (exists(className)) {
|
||||
if (TestDrivers.exists(className))
|
||||
System.out.println("[FOUND] " + className);
|
||||
} else {
|
||||
else
|
||||
System.out.println("[NOT FOUND] " + className);
|
||||
}
|
||||
className = ".bcm.vc.iv.DisplayDriver";
|
||||
if (exists(className)) {
|
||||
if (TestDrivers.exists(className))
|
||||
System.out.println("[FOUND] " + className);
|
||||
} else {
|
||||
else
|
||||
System.out.println("[NOT FOUND] " + className);
|
||||
}
|
||||
System.out.println("Test finished.");
|
||||
}
|
||||
|
||||
public static boolean exists(String className) {
|
||||
public static boolean exists(final String className) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
|
@ -13,13 +13,13 @@ import it.cavallium.warppi.math.rules.RulesManager;
|
||||
import it.cavallium.warppi.util.Error;
|
||||
|
||||
public class Boot {
|
||||
|
||||
public static void boot(Platform platform, String[] args) throws Exception {
|
||||
Engine.start(platform, new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), parseStartupArguments(args));
|
||||
|
||||
public static void boot(final Platform platform, final String[] args) throws Exception {
|
||||
Engine.start(platform, new LoadingScreen(), new PIHardwareDisplay(), new PIHardwareTouchDevice(false, false, false), new CalculatorHUD(), Boot.parseStartupArguments(args));
|
||||
Engine.INSTANCE.getLoadPhase().subscribe(Boot::loadCalculator);
|
||||
}
|
||||
|
||||
private static void loadCalculator(LoadingStatus loading) {
|
||||
private static void loadCalculator(final LoadingStatus loading) {
|
||||
try {
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setBrightness(0.2f);
|
||||
RulesManager.initialize();
|
||||
@ -33,12 +33,12 @@ public class Boot {
|
||||
|
||||
public static StartupArguments parseStartupArguments(final String[] a) {
|
||||
final StartupArgumentsImpl args = new StartupArgumentsImpl();
|
||||
Arrays.asList(a).stream().parallel().map(String::toLowerCase).forEach(arg -> parseArgument(args, arg));
|
||||
Arrays.asList(a).stream().parallel().map(String::toLowerCase).forEach(arg -> Boot.parseArgument(args, arg));
|
||||
args.setHeadlessEngineForced(args.isHeadlessEngineForced() || args.isHeadless8EngineForced() || args.isHeadless256EngineForced() || args.isHeadless24bitEngineForced());
|
||||
return args;
|
||||
}
|
||||
|
||||
public static void parseArgument(StartupArgumentsImpl args, String arg) {
|
||||
public static void parseArgument(final StartupArgumentsImpl args, final String arg) {
|
||||
switch (arg) {
|
||||
case "-zoomed":
|
||||
args.setZoomed(true);
|
||||
|
@ -1,36 +1,36 @@
|
||||
package it.cavallium.warppi.boot;
|
||||
|
||||
public interface StartupArguments {
|
||||
public boolean isRaspberryModeAllowed();
|
||||
boolean isRaspberryModeAllowed();
|
||||
|
||||
public boolean isZoomed();
|
||||
boolean isZoomed();
|
||||
|
||||
public boolean isHeadlessEngineForced();
|
||||
boolean isHeadlessEngineForced();
|
||||
|
||||
public boolean isHeadless8EngineForced();
|
||||
boolean isHeadless8EngineForced();
|
||||
|
||||
public boolean isHeadless256EngineForced();
|
||||
boolean isHeadless256EngineForced();
|
||||
|
||||
public boolean isHeadless24bitEngineForced();
|
||||
boolean isHeadless24bitEngineForced();
|
||||
|
||||
public boolean isCPUEngineForced();
|
||||
boolean isCPUEngineForced();
|
||||
|
||||
public boolean isGPUEngineForced();
|
||||
boolean isGPUEngineForced();
|
||||
|
||||
public boolean isFrameBufferEngineForced();
|
||||
boolean isFrameBufferEngineForced();
|
||||
|
||||
public boolean isNoGUIEngineForced();
|
||||
boolean isNoGUIEngineForced();
|
||||
|
||||
public boolean isHTMLEngineForced();
|
||||
boolean isHTMLEngineForced();
|
||||
|
||||
public boolean isMSDOSModeEnabled();
|
||||
boolean isMSDOSModeEnabled();
|
||||
|
||||
public boolean isVerboseLoggingEnabled();
|
||||
boolean isVerboseLoggingEnabled();
|
||||
|
||||
public boolean isDebugEnabled();
|
||||
boolean isDebugEnabled();
|
||||
|
||||
public boolean isUncached();
|
||||
boolean isUncached();
|
||||
|
||||
public boolean isEngineForced();
|
||||
boolean isEngineForced();
|
||||
|
||||
}
|
||||
|
@ -102,63 +102,63 @@ public class StartupArgumentsImpl implements StartupArguments {
|
||||
return isCPUEngineForced || isFrameBufferEngineForced || isGPUEngineForced || isHeadless24bitEngineForced || isHeadless256EngineForced || isHeadless8EngineForced || isHTMLEngineForced || isNoGUIEngineForced;
|
||||
}
|
||||
|
||||
void setRaspberryModeAllowed(boolean isRaspberryModeAllowed) {
|
||||
void setRaspberryModeAllowed(final boolean isRaspberryModeAllowed) {
|
||||
this.isRaspberryModeAllowed = isRaspberryModeAllowed;
|
||||
}
|
||||
|
||||
void setZoomed(boolean isZoomed) {
|
||||
void setZoomed(final boolean isZoomed) {
|
||||
this.isZoomed = isZoomed;
|
||||
}
|
||||
|
||||
void setHeadlessEngineForced(boolean isHeadlessEngineForced) {
|
||||
void setHeadlessEngineForced(final boolean isHeadlessEngineForced) {
|
||||
this.isHeadlessEngineForced = isHeadlessEngineForced;
|
||||
}
|
||||
|
||||
void setHeadless8EngineForced(boolean isHeadless8EngineForced) {
|
||||
void setHeadless8EngineForced(final boolean isHeadless8EngineForced) {
|
||||
this.isHeadless8EngineForced = isHeadless8EngineForced;
|
||||
}
|
||||
|
||||
void setHeadless256EngineForced(boolean isHeadless256EngineForced) {
|
||||
void setHeadless256EngineForced(final boolean isHeadless256EngineForced) {
|
||||
this.isHeadless256EngineForced = isHeadless256EngineForced;
|
||||
}
|
||||
|
||||
void setHeadless24bitEngineForced(boolean isHeadless24bitEngineForced) {
|
||||
void setHeadless24bitEngineForced(final boolean isHeadless24bitEngineForced) {
|
||||
this.isHeadless24bitEngineForced = isHeadless24bitEngineForced;
|
||||
}
|
||||
|
||||
void setCPUEngineForced(boolean isCPUEngineForced) {
|
||||
void setCPUEngineForced(final boolean isCPUEngineForced) {
|
||||
this.isCPUEngineForced = isCPUEngineForced;
|
||||
}
|
||||
|
||||
void setGPUEngineForced(boolean isGPUEngineForced) {
|
||||
void setGPUEngineForced(final boolean isGPUEngineForced) {
|
||||
this.isGPUEngineForced = isGPUEngineForced;
|
||||
}
|
||||
|
||||
void setFrameBufferEngineForced(boolean isFrameBufferEngineForced) {
|
||||
void setFrameBufferEngineForced(final boolean isFrameBufferEngineForced) {
|
||||
this.isFrameBufferEngineForced = isFrameBufferEngineForced;
|
||||
}
|
||||
|
||||
void setNoGUIEngineForced(boolean isNoGUIEngineForced) {
|
||||
void setNoGUIEngineForced(final boolean isNoGUIEngineForced) {
|
||||
this.isNoGUIEngineForced = isNoGUIEngineForced;
|
||||
}
|
||||
|
||||
void setHTMLEngineForced(boolean isHTMLEngineForced) {
|
||||
void setHTMLEngineForced(final boolean isHTMLEngineForced) {
|
||||
this.isHTMLEngineForced = isHTMLEngineForced;
|
||||
}
|
||||
|
||||
void setMSDOSModeEnabled(boolean isMSDOSModeEnabled) {
|
||||
void setMSDOSModeEnabled(final boolean isMSDOSModeEnabled) {
|
||||
this.isMSDOSModeEnabled = isMSDOSModeEnabled;
|
||||
}
|
||||
|
||||
void setVerboseLoggingEnabled(boolean isVerboseLoggingEnabled) {
|
||||
void setVerboseLoggingEnabled(final boolean isVerboseLoggingEnabled) {
|
||||
this.isVerboseLoggingEnabled = isVerboseLoggingEnabled;
|
||||
}
|
||||
|
||||
void setDebugEnabled(boolean isDebugEnabled) {
|
||||
void setDebugEnabled(final boolean isDebugEnabled) {
|
||||
this.isDebugEnabled = isDebugEnabled;
|
||||
}
|
||||
|
||||
void setUncached(boolean isUncached) {
|
||||
void setUncached(final boolean isUncached) {
|
||||
this.isUncached = isUncached;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ public class CacheFile {
|
||||
private FileInputStream lastFIS;
|
||||
|
||||
public CacheFile() {
|
||||
do {
|
||||
do
|
||||
path = UUID.randomUUID().toString() + ".ser";
|
||||
} while (new File(path).exists());
|
||||
while (new File(path).exists());
|
||||
try {
|
||||
File.createTempFile(Engine.getPlatform().getSettings().getCalculatorNameLowercase(), "");
|
||||
} catch (final IOException e) {
|
||||
@ -29,28 +29,26 @@ public class CacheFile {
|
||||
}
|
||||
|
||||
public ObjectOutputStream getObjectOutputStram() {
|
||||
if (lastOOS == null) {
|
||||
if (lastOOS == null)
|
||||
try {
|
||||
return new ObjectOutputStream(new FileOutputStream(path));
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
return lastOOS;
|
||||
}
|
||||
} else {
|
||||
else
|
||||
return lastOOS;
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectInputStream getObjectInputStram() {
|
||||
if (lastOIS == null) {
|
||||
if (lastOIS == null)
|
||||
try {
|
||||
return new ObjectInputStream(new FileInputStream(path));
|
||||
} catch (final IOException e) {
|
||||
return lastOIS;
|
||||
}
|
||||
} else {
|
||||
else
|
||||
return lastOIS;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeStreams() {
|
||||
|
@ -7,7 +7,7 @@ public class HardwareDevice {
|
||||
private final DisplayManager displayManager;
|
||||
private final InputManager inputManager;
|
||||
|
||||
public HardwareDevice(DisplayManager m, InputManager im) {
|
||||
public HardwareDevice(final DisplayManager m, final InputManager im) {
|
||||
displayManager = m;
|
||||
inputManager = im;
|
||||
}
|
||||
@ -20,10 +20,10 @@ public class HardwareDevice {
|
||||
return inputManager;
|
||||
}
|
||||
|
||||
public void setup(Runnable r) {
|
||||
public void setup(final Runnable r) {
|
||||
displayManager.initialize();
|
||||
inputManager.getKeyboard().startKeyboard();
|
||||
Thread t = new Thread(r);
|
||||
final Thread t = new Thread(r);
|
||||
Engine.getPlatform().setThreadDaemon(t, false);
|
||||
Engine.getPlatform().setThreadName(t, "Main thread (after setup)");
|
||||
t.start();
|
||||
|
@ -4,18 +4,18 @@ import it.cavallium.warppi.event.TouchEventListener;
|
||||
import it.cavallium.warppi.event.TouchPoint;
|
||||
|
||||
public interface HardwareTouchDevice extends TouchEventListener {
|
||||
public boolean getInvertedXY();
|
||||
boolean getInvertedXY();
|
||||
|
||||
public boolean getInvertedX();
|
||||
boolean getInvertedX();
|
||||
|
||||
public boolean getInvertedY();
|
||||
boolean getInvertedY();
|
||||
|
||||
public default void setInvertedXY() {}
|
||||
default void setInvertedXY() {}
|
||||
|
||||
public default void setInvertedX() {}
|
||||
default void setInvertedX() {}
|
||||
|
||||
public default void setInvertedY() {}
|
||||
default void setInvertedY() {}
|
||||
|
||||
public TouchPoint makePoint(long id, float x, float y, int maxX, int maxY, float radiusX, float radiusY,
|
||||
float force, float rotationAngle);
|
||||
TouchPoint makePoint(long id, float x, float y, int maxX, int maxY, float radiusX, float radiusY, float force,
|
||||
float rotationAngle);
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ public class InputManager {
|
||||
private final Keyboard keyboard;
|
||||
private final HardwareTouchDevice touchDevice;
|
||||
|
||||
public InputManager(Keyboard k, HardwareTouchDevice t) {
|
||||
this.keyboard = k;
|
||||
this.touchDevice = t;
|
||||
public InputManager(final Keyboard k, final HardwareTouchDevice t) {
|
||||
keyboard = k;
|
||||
touchDevice = t;
|
||||
}
|
||||
|
||||
public Keyboard getKeyboard() {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,108 +9,108 @@ public interface KeyboardJogampValues {
|
||||
/**
|
||||
* This value, {@value}, is used to indicate that the keyCode is unknown.
|
||||
*/
|
||||
public static final short VK_UNDEFINED = (short) 0x0;
|
||||
short VK_UNDEFINED = (short) 0x0;
|
||||
|
||||
static final short VK_FREE01 = (short) 0x01;
|
||||
short VK_FREE01 = (short) 0x01;
|
||||
|
||||
/** Constant for the HOME function key. ASCII: Start Of Text. */
|
||||
public static final short VK_HOME = (short) 0x02;
|
||||
short VK_HOME = (short) 0x02;
|
||||
|
||||
/** Constant for the END function key. ASCII: End Of Text. */
|
||||
public static final short VK_END = (short) 0x03;
|
||||
short VK_END = (short) 0x03;
|
||||
|
||||
/** Constant for the END function key. ASCII: End Of Transmission. */
|
||||
public static final short VK_FINAL = (short) 0x04;
|
||||
short VK_FINAL = (short) 0x04;
|
||||
|
||||
/** Constant for the PRINT function key. ASCII: Enquiry. */
|
||||
public static final short VK_PRINTSCREEN = (short) 0x05;
|
||||
short VK_PRINTSCREEN = (short) 0x05;
|
||||
|
||||
static final short VK_FREE06 = (short) 0x06;
|
||||
static final short VK_FREE07 = (short) 0x07;
|
||||
short VK_FREE06 = (short) 0x06;
|
||||
short VK_FREE07 = (short) 0x07;
|
||||
|
||||
/** Constant for the BACK SPACE key "\b", matching ASCII. Printable! */
|
||||
public static final short VK_BACK_SPACE = (short) 0x08;
|
||||
short VK_BACK_SPACE = (short) 0x08;
|
||||
|
||||
/** Constant for the HORIZ TAB key "\t", matching ASCII. Printable! */
|
||||
public static final short VK_TAB = (short) 0x09;
|
||||
short VK_TAB = (short) 0x09;
|
||||
|
||||
/** LINE_FEED "\n", matching ASCII, n/a on keyboard. */
|
||||
static final short VK_FREE0A = (short) 0x0A;
|
||||
short VK_FREE0A = (short) 0x0A;
|
||||
|
||||
/** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */
|
||||
public static final short VK_PAGE_DOWN = (short) 0x0B;
|
||||
short VK_PAGE_DOWN = (short) 0x0B;
|
||||
|
||||
/** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */
|
||||
public static final short VK_CLEAR = (short) 0x0C;
|
||||
short VK_CLEAR = (short) 0x0C;
|
||||
|
||||
/**
|
||||
* Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII.
|
||||
* Printable!
|
||||
*/
|
||||
public static final short VK_ENTER = (short) 0x0D;
|
||||
short VK_ENTER = (short) 0x0D;
|
||||
|
||||
static final short VK_FREE0E = (short) 0x0E;
|
||||
short VK_FREE0E = (short) 0x0E;
|
||||
|
||||
/** Constant for the CTRL function key. ASCII: shift-in. */
|
||||
public static final short VK_SHIFT = (short) 0x0F;
|
||||
short VK_SHIFT = (short) 0x0F;
|
||||
|
||||
/** Constant for the PAGE UP function key. ASCII: Data Link Escape. */
|
||||
public static final short VK_PAGE_UP = (short) 0x10;
|
||||
short VK_PAGE_UP = (short) 0x10;
|
||||
|
||||
/** Constant for the CTRL function key. ASCII: device-ctrl-one. */
|
||||
public static final short VK_CONTROL = (short) 0x11;
|
||||
short VK_CONTROL = (short) 0x11;
|
||||
|
||||
/** Constant for the left ALT function key. ASCII: device-ctrl-two. */
|
||||
public static final short VK_ALT = (short) 0x12;
|
||||
short VK_ALT = (short) 0x12;
|
||||
|
||||
/**
|
||||
* Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII:
|
||||
* device-ctrl-three.
|
||||
*/
|
||||
public static final short VK_ALT_GRAPH = (short) 0x13;
|
||||
short VK_ALT_GRAPH = (short) 0x13;
|
||||
|
||||
/** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */
|
||||
public static final short VK_CAPS_LOCK = (short) 0x14;
|
||||
short VK_CAPS_LOCK = (short) 0x14;
|
||||
|
||||
static final short VK_FREE15 = (short) 0x15;
|
||||
short VK_FREE15 = (short) 0x15;
|
||||
|
||||
/** Constant for the PAUSE function key. ASCII: sync-idle. */
|
||||
public static final short VK_PAUSE = (short) 0x16;
|
||||
short VK_PAUSE = (short) 0x16;
|
||||
|
||||
/** <b>scroll lock</b> key. ASCII: End Of Transmission Block. */
|
||||
public static final short VK_SCROLL_LOCK = (short) 0x17;
|
||||
short VK_SCROLL_LOCK = (short) 0x17;
|
||||
|
||||
/** Constant for the CANCEL function key. ASCII: Cancel. */
|
||||
public static final short VK_CANCEL = (short) 0x18;
|
||||
short VK_CANCEL = (short) 0x18;
|
||||
|
||||
static final short VK_FREE19 = (short) 0x19;
|
||||
short VK_FREE19 = (short) 0x19;
|
||||
|
||||
/** Constant for the INSERT function key. ASCII: Substitute. */
|
||||
public static final short VK_INSERT = (short) 0x1A;
|
||||
short VK_INSERT = (short) 0x1A;
|
||||
|
||||
/** Constant for the ESCAPE function key. ASCII: Escape. */
|
||||
public static final short VK_ESCAPE = (short) 0x1B;
|
||||
short VK_ESCAPE = (short) 0x1B;
|
||||
|
||||
/**
|
||||
* Constant for the Convert function key, Japanese "henkan". ASCII: File
|
||||
* Separator.
|
||||
*/
|
||||
public static final short VK_CONVERT = (short) 0x1C;
|
||||
short VK_CONVERT = (short) 0x1C;
|
||||
|
||||
/**
|
||||
* Constant for the Don't Convert function key, Japanese "muhenkan". ASCII:
|
||||
* Group Separator.
|
||||
*/
|
||||
public static final short VK_NONCONVERT = (short) 0x1D;
|
||||
short VK_NONCONVERT = (short) 0x1D;
|
||||
|
||||
/**
|
||||
* Constant for the Accept or Commit function key, Japanese "kakutei".
|
||||
* ASCII: Record Separator.
|
||||
*/
|
||||
public static final short VK_ACCEPT = (short) 0x1E;
|
||||
short VK_ACCEPT = (short) 0x1E;
|
||||
|
||||
/** Constant for the Mode Change (?). ASCII: Unit Separator. */
|
||||
public static final short VK_MODECHANGE = (short) 0x1F;
|
||||
short VK_MODECHANGE = (short) 0x1F;
|
||||
|
||||
//
|
||||
// Unicode: Printable [0x20 - 0x7E]
|
||||
@ -118,168 +118,168 @@ public interface KeyboardJogampValues {
|
||||
//
|
||||
|
||||
/** Constant for the SPACE function key. ASCII: SPACE. */
|
||||
public static final short VK_SPACE = (short) 0x20;
|
||||
short VK_SPACE = (short) 0x20;
|
||||
|
||||
/** Constant for the "!" key. */
|
||||
public static final short VK_EXCLAMATION_MARK = (short) 0x21;
|
||||
short VK_EXCLAMATION_MARK = (short) 0x21;
|
||||
|
||||
/** Constant for the """ key. */
|
||||
public static final short VK_QUOTEDBL = (short) 0x22;
|
||||
short VK_QUOTEDBL = (short) 0x22;
|
||||
|
||||
/** Constant for the "#" key. */
|
||||
public static final short VK_NUMBER_SIGN = (short) 0x23;
|
||||
short VK_NUMBER_SIGN = (short) 0x23;
|
||||
|
||||
/** Constant for the "$" key. */
|
||||
public static final short VK_DOLLAR = (short) 0x24;
|
||||
short VK_DOLLAR = (short) 0x24;
|
||||
|
||||
/** Constant for the "%" key. */
|
||||
public static final short VK_PERCENT = (short) 0x25;
|
||||
short VK_PERCENT = (short) 0x25;
|
||||
|
||||
/** Constant for the "&" key. */
|
||||
public static final short VK_AMPERSAND = (short) 0x26;
|
||||
short VK_AMPERSAND = (short) 0x26;
|
||||
|
||||
/** Constant for the "'" key. */
|
||||
public static final short VK_QUOTE = (short) 0x27;
|
||||
short VK_QUOTE = (short) 0x27;
|
||||
|
||||
/** Constant for the "(" key. */
|
||||
public static final short VK_LEFT_PARENTHESIS = (short) 0x28;
|
||||
short VK_LEFT_PARENTHESIS = (short) 0x28;
|
||||
|
||||
/** Constant for the ")" key. */
|
||||
public static final short VK_RIGHT_PARENTHESIS = (short) 0x29;
|
||||
short VK_RIGHT_PARENTHESIS = (short) 0x29;
|
||||
|
||||
/** Constant for the "*" key */
|
||||
public static final short VK_ASTERISK = (short) 0x2A;
|
||||
short VK_ASTERISK = (short) 0x2A;
|
||||
|
||||
/** Constant for the "+" key. */
|
||||
public static final short VK_PLUS = (short) 0x2B;
|
||||
short VK_PLUS = (short) 0x2B;
|
||||
|
||||
/** Constant for the comma key, "," */
|
||||
public static final short VK_COMMA = (short) 0x2C;
|
||||
short VK_COMMA = (short) 0x2C;
|
||||
|
||||
/** Constant for the minus key, "-" */
|
||||
public static final short VK_MINUS = (short) 0x2D;
|
||||
short VK_MINUS = (short) 0x2D;
|
||||
|
||||
/** Constant for the period key, "." */
|
||||
public static final short VK_PERIOD = (short) 0x2E;
|
||||
short VK_PERIOD = (short) 0x2E;
|
||||
|
||||
/** Constant for the forward slash key, "/" */
|
||||
public static final short VK_SLASH = (short) 0x2F;
|
||||
short VK_SLASH = (short) 0x2F;
|
||||
|
||||
/** VK_0 thru VK_9 are the same as UTF16/ASCII '0' thru '9' [0x30 - 0x39] */
|
||||
public static final short VK_0 = (short) 0x30;
|
||||
short VK_0 = (short) 0x30;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_1 = (short) 0x31;
|
||||
short VK_1 = (short) 0x31;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_2 = (short) 0x32;
|
||||
short VK_2 = (short) 0x32;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_3 = (short) 0x33;
|
||||
short VK_3 = (short) 0x33;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_4 = (short) 0x34;
|
||||
short VK_4 = (short) 0x34;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_5 = (short) 0x35;
|
||||
short VK_5 = (short) 0x35;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_6 = (short) 0x36;
|
||||
short VK_6 = (short) 0x36;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_7 = (short) 0x37;
|
||||
short VK_7 = (short) 0x37;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_8 = (short) 0x38;
|
||||
short VK_8 = (short) 0x38;
|
||||
/** See {@link #VK_0}. */
|
||||
public static final short VK_9 = (short) 0x39;
|
||||
short VK_9 = (short) 0x39;
|
||||
|
||||
/** Constant for the ":" key. */
|
||||
public static final short VK_COLON = (short) 0x3A;
|
||||
short VK_COLON = (short) 0x3A;
|
||||
|
||||
/** Constant for the semicolon key, ";" */
|
||||
public static final short VK_SEMICOLON = (short) 0x3B;
|
||||
short VK_SEMICOLON = (short) 0x3B;
|
||||
|
||||
/** Constant for the equals key, "<" */
|
||||
public static final short VK_LESS = (short) 0x3C;
|
||||
short VK_LESS = (short) 0x3C;
|
||||
|
||||
/** Constant for the equals key, "=" */
|
||||
public static final short VK_EQUALS = (short) 0x3D;
|
||||
short VK_EQUALS = (short) 0x3D;
|
||||
|
||||
/** Constant for the equals key, ">" */
|
||||
public static final short VK_GREATER = (short) 0x3E;
|
||||
short VK_GREATER = (short) 0x3E;
|
||||
|
||||
/** Constant for the equals key, "?" */
|
||||
public static final short VK_QUESTIONMARK = (short) 0x3F;
|
||||
short VK_QUESTIONMARK = (short) 0x3F;
|
||||
|
||||
/** Constant for the equals key, "@" */
|
||||
public static final short VK_AT = (short) 0x40;
|
||||
short VK_AT = (short) 0x40;
|
||||
|
||||
/**
|
||||
* VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 -
|
||||
* 0x5A)
|
||||
*/
|
||||
public static final short VK_A = (short) 0x41;
|
||||
short VK_A = (short) 0x41;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_B = (short) 0x42;
|
||||
short VK_B = (short) 0x42;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_C = (short) 0x43;
|
||||
short VK_C = (short) 0x43;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_D = (short) 0x44;
|
||||
short VK_D = (short) 0x44;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_E = (short) 0x45;
|
||||
short VK_E = (short) 0x45;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_F = (short) 0x46;
|
||||
short VK_F = (short) 0x46;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_G = (short) 0x47;
|
||||
short VK_G = (short) 0x47;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_H = (short) 0x48;
|
||||
short VK_H = (short) 0x48;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_I = (short) 0x49;
|
||||
short VK_I = (short) 0x49;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_J = (short) 0x4A;
|
||||
short VK_J = (short) 0x4A;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_K = (short) 0x4B;
|
||||
short VK_K = (short) 0x4B;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_L = (short) 0x4C;
|
||||
short VK_L = (short) 0x4C;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_M = (short) 0x4D;
|
||||
short VK_M = (short) 0x4D;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_N = (short) 0x4E;
|
||||
short VK_N = (short) 0x4E;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_O = (short) 0x4F;
|
||||
short VK_O = (short) 0x4F;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_P = (short) 0x50;
|
||||
short VK_P = (short) 0x50;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_Q = (short) 0x51;
|
||||
short VK_Q = (short) 0x51;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_R = (short) 0x52;
|
||||
short VK_R = (short) 0x52;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_S = (short) 0x53;
|
||||
short VK_S = (short) 0x53;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_T = (short) 0x54;
|
||||
short VK_T = (short) 0x54;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_U = (short) 0x55;
|
||||
short VK_U = (short) 0x55;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_V = (short) 0x56;
|
||||
short VK_V = (short) 0x56;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_W = (short) 0x57;
|
||||
short VK_W = (short) 0x57;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_X = (short) 0x58;
|
||||
short VK_X = (short) 0x58;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_Y = (short) 0x59;
|
||||
short VK_Y = (short) 0x59;
|
||||
/** See {@link #VK_A}. */
|
||||
public static final short VK_Z = (short) 0x5A;
|
||||
short VK_Z = (short) 0x5A;
|
||||
|
||||
/** Constant for the open bracket key, "[" */
|
||||
public static final short VK_OPEN_BRACKET = (short) 0x5B;
|
||||
short VK_OPEN_BRACKET = (short) 0x5B;
|
||||
|
||||
/** Constant for the back slash key, "\" */
|
||||
public static final short VK_BACK_SLASH = (short) 0x5C;
|
||||
short VK_BACK_SLASH = (short) 0x5C;
|
||||
|
||||
/** Constant for the close bracket key, "]" */
|
||||
public static final short VK_CLOSE_BRACKET = (short) 0x5D;
|
||||
short VK_CLOSE_BRACKET = (short) 0x5D;
|
||||
|
||||
/** Constant for the "^" key. */
|
||||
public static final short VK_CIRCUMFLEX = (short) 0x5E;
|
||||
short VK_CIRCUMFLEX = (short) 0x5E;
|
||||
|
||||
/** Constant for the "_" key */
|
||||
public static final short VK_UNDERSCORE = (short) 0x5F;
|
||||
short VK_UNDERSCORE = (short) 0x5F;
|
||||
|
||||
/** Constant for the "`" key */
|
||||
public static final short VK_BACK_QUOTE = (short) 0x60;
|
||||
short VK_BACK_QUOTE = (short) 0x60;
|
||||
|
||||
/**
|
||||
* Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode /
|
||||
@ -298,86 +298,86 @@ public interface KeyboardJogampValues {
|
||||
* See <a href="#unicodeCollision">Unicode Collision</a> for details.
|
||||
* </p>
|
||||
*/
|
||||
public static final short VK_F1 = (short) (0x60 + 1);
|
||||
short VK_F1 = (short) (0x60 + 1);
|
||||
|
||||
/** Constant for the F2 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F2 = (short) (0x60 + 2);
|
||||
short VK_F2 = (short) (0x60 + 2);
|
||||
|
||||
/** Constant for the F3 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F3 = (short) (0x60 + 3);
|
||||
short VK_F3 = (short) (0x60 + 3);
|
||||
|
||||
/** Constant for the F4 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F4 = (short) (0x60 + 4);
|
||||
short VK_F4 = (short) (0x60 + 4);
|
||||
|
||||
/** Constant for the F5 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F5 = (short) (0x60 + 5);
|
||||
short VK_F5 = (short) (0x60 + 5);
|
||||
|
||||
/** Constant for the F6 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F6 = (short) (0x60 + 6);
|
||||
short VK_F6 = (short) (0x60 + 6);
|
||||
|
||||
/** Constant for the F7 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F7 = (short) (0x60 + 7);
|
||||
short VK_F7 = (short) (0x60 + 7);
|
||||
|
||||
/** Constant for the F8 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F8 = (short) (0x60 + 8);
|
||||
short VK_F8 = (short) (0x60 + 8);
|
||||
|
||||
/** Constant for the F9 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F9 = (short) (0x60 + 9);
|
||||
short VK_F9 = (short) (0x60 + 9);
|
||||
|
||||
/** Constant for the F11 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F10 = (short) (0x60 + 10);
|
||||
short VK_F10 = (short) (0x60 + 10);
|
||||
|
||||
/** Constant for the F11 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F11 = (short) (0x60 + 11);
|
||||
short VK_F11 = (short) (0x60 + 11);
|
||||
|
||||
/** Constant for the F12 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F12 = (short) (0x60 + 12);
|
||||
short VK_F12 = (short) (0x60 + 12);
|
||||
|
||||
/** Constant for the F13 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F13 = (short) (0x60 + 13);
|
||||
short VK_F13 = (short) (0x60 + 13);
|
||||
|
||||
/** Constant for the F14 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F14 = (short) (0x60 + 14);
|
||||
short VK_F14 = (short) (0x60 + 14);
|
||||
|
||||
/** Constant for the F15 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F15 = (short) (0x60 + 15);
|
||||
short VK_F15 = (short) (0x60 + 15);
|
||||
|
||||
/** Constant for the F16 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F16 = (short) (0x60 + 16);
|
||||
short VK_F16 = (short) (0x60 + 16);
|
||||
|
||||
/** Constant for the F17 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F17 = (short) (0x60 + 17);
|
||||
short VK_F17 = (short) (0x60 + 17);
|
||||
|
||||
/** Constant for the F18 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F18 = (short) (0x60 + 18);
|
||||
short VK_F18 = (short) (0x60 + 18);
|
||||
|
||||
/** Constant for the F19 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F19 = (short) (0x60 + 19);
|
||||
short VK_F19 = (short) (0x60 + 19);
|
||||
|
||||
/** Constant for the F20 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F20 = (short) (0x60 + 20);
|
||||
short VK_F20 = (short) (0x60 + 20);
|
||||
|
||||
/** Constant for the F21 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F21 = (short) (0x60 + 21);
|
||||
short VK_F21 = (short) (0x60 + 21);
|
||||
|
||||
/** Constant for the F22 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F22 = (short) (0x60 + 22);
|
||||
short VK_F22 = (short) (0x60 + 22);
|
||||
|
||||
/** Constant for the F23 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F23 = (short) (0x60 + 23);
|
||||
short VK_F23 = (short) (0x60 + 23);
|
||||
|
||||
/** Constant for the F24 function key. See {@link #VK_F1}. */
|
||||
public static final short VK_F24 = (short) (0x60 + 24);
|
||||
short VK_F24 = (short) (0x60 + 24);
|
||||
|
||||
/** Constant for the "{" key */
|
||||
public static final short VK_LEFT_BRACE = (short) 0x7B;
|
||||
short VK_LEFT_BRACE = (short) 0x7B;
|
||||
/** Constant for the "|" key */
|
||||
public static final short VK_PIPE = (short) 0x7C;
|
||||
short VK_PIPE = (short) 0x7C;
|
||||
/** Constant for the "}" key */
|
||||
public static final short VK_RIGHT_BRACE = (short) 0x7D;
|
||||
short VK_RIGHT_BRACE = (short) 0x7D;
|
||||
|
||||
/** Constant for the "~" key, matching ASCII */
|
||||
public static final short VK_TILDE = (short) 0x7E;
|
||||
short VK_TILDE = (short) 0x7E;
|
||||
|
||||
//
|
||||
// Unicode: Non printable controls: [0x7F - 0x9F]
|
||||
@ -388,125 +388,125 @@ public interface KeyboardJogampValues {
|
||||
/**
|
||||
* Numeric keypad <b>decimal separator</b> key. Non printable UTF control.
|
||||
*/
|
||||
public static final short VK_SEPARATOR = (short) 0x7F;
|
||||
short VK_SEPARATOR = (short) 0x7F;
|
||||
|
||||
/**
|
||||
* Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80
|
||||
* - 0x89). Non printable UTF control.
|
||||
*/
|
||||
public static final short VK_NUMPAD0 = (short) 0x80;
|
||||
short VK_NUMPAD0 = (short) 0x80;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD1 = (short) 0x81;
|
||||
short VK_NUMPAD1 = (short) 0x81;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD2 = (short) 0x82;
|
||||
short VK_NUMPAD2 = (short) 0x82;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD3 = (short) 0x83;
|
||||
short VK_NUMPAD3 = (short) 0x83;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD4 = (short) 0x84;
|
||||
short VK_NUMPAD4 = (short) 0x84;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD5 = (short) 0x85;
|
||||
short VK_NUMPAD5 = (short) 0x85;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD6 = (short) 0x86;
|
||||
short VK_NUMPAD6 = (short) 0x86;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD7 = (short) 0x87;
|
||||
short VK_NUMPAD7 = (short) 0x87;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD8 = (short) 0x88;
|
||||
short VK_NUMPAD8 = (short) 0x88;
|
||||
/** See {@link #VK_NUMPAD0}. */
|
||||
public static final short VK_NUMPAD9 = (short) 0x89;
|
||||
short VK_NUMPAD9 = (short) 0x89;
|
||||
|
||||
/**
|
||||
* Numeric keypad <b>decimal separator</b> key. Non printable UTF control.
|
||||
*/
|
||||
public static final short VK_DECIMAL = (short) 0x8A;
|
||||
short VK_DECIMAL = (short) 0x8A;
|
||||
|
||||
/** Numeric keypad <b>add</b> key. Non printable UTF control. */
|
||||
public static final short VK_ADD = (short) 0x8B;
|
||||
short VK_ADD = (short) 0x8B;
|
||||
|
||||
/** Numeric keypad <b>subtract</b> key. Non printable UTF control. */
|
||||
public static final short VK_SUBTRACT = (short) 0x8C;
|
||||
short VK_SUBTRACT = (short) 0x8C;
|
||||
|
||||
/** Numeric keypad <b>multiply</b> key. Non printable UTF control. */
|
||||
public static final short VK_MULTIPLY = (short) 0x8D;
|
||||
short VK_MULTIPLY = (short) 0x8D;
|
||||
|
||||
/** Numeric keypad <b>divide</b> key. Non printable UTF control. */
|
||||
public static final short VK_DIVIDE = (short) 0x8E;
|
||||
short VK_DIVIDE = (short) 0x8E;
|
||||
|
||||
/** Constant for the DEL key, matching ASCII. Non printable UTF control. */
|
||||
public static final short VK_DELETE = (short) 0x93;
|
||||
short VK_DELETE = (short) 0x93;
|
||||
|
||||
/** Numeric keypad <b>num lock</b> key. Non printable UTF control. */
|
||||
public static final short VK_NUM_LOCK = (short) 0x94;
|
||||
short VK_NUM_LOCK = (short) 0x94;
|
||||
|
||||
/**
|
||||
* Constant for the cursor- or numerical-pad <b>left</b> arrow key. Non
|
||||
* printable UTF control.
|
||||
*/
|
||||
public static final short VK_LEFT = (short) 0x95;
|
||||
short VK_LEFT = (short) 0x95;
|
||||
|
||||
/**
|
||||
* Constant for the cursor- or numerical-pad <b>up</b> arrow key. Non
|
||||
* printable UTF control.
|
||||
*/
|
||||
public static final short VK_UP = (short) 0x96;
|
||||
short VK_UP = (short) 0x96;
|
||||
|
||||
/**
|
||||
* Constant for the cursor- or numerical-pad <b>right</b> arrow key. Non
|
||||
* printable UTF control.
|
||||
*/
|
||||
public static final short VK_RIGHT = (short) 0x97;
|
||||
short VK_RIGHT = (short) 0x97;
|
||||
|
||||
/**
|
||||
* Constant for the cursor- or numerical pad <b>down</b> arrow key. Non
|
||||
* printable UTF control.
|
||||
*/
|
||||
public static final short VK_DOWN = (short) 0x98;
|
||||
short VK_DOWN = (short) 0x98;
|
||||
|
||||
/** Constant for the Context Menu key. Non printable UTF control. */
|
||||
public static final short VK_CONTEXT_MENU = (short) 0x99;
|
||||
short VK_CONTEXT_MENU = (short) 0x99;
|
||||
|
||||
/**
|
||||
* Constant for the MS "Windows" function key.
|
||||
* It is used for both the left and right version of the key.
|
||||
*/
|
||||
public static final short VK_WINDOWS = (short) 0x9A;
|
||||
short VK_WINDOWS = (short) 0x9A;
|
||||
|
||||
/** Constant for the Meta function key. */
|
||||
public static final short VK_META = (short) 0x9B;
|
||||
short VK_META = (short) 0x9B;
|
||||
|
||||
/** Constant for the Help function key. */
|
||||
public static final short VK_HELP = (short) 0x9C;
|
||||
short VK_HELP = (short) 0x9C;
|
||||
|
||||
/** Constant for the Compose function key. */
|
||||
public static final short VK_COMPOSE = (short) 0x9D;
|
||||
short VK_COMPOSE = (short) 0x9D;
|
||||
|
||||
/** Constant for the Begin function key. */
|
||||
public static final short VK_BEGIN = (short) 0x9E;
|
||||
short VK_BEGIN = (short) 0x9E;
|
||||
|
||||
/** Constant for the Stop function key. */
|
||||
public static final short VK_STOP = (short) 0x9F;
|
||||
short VK_STOP = (short) 0x9F;
|
||||
|
||||
//
|
||||
// Unicode: Printable [0x00A0 - 0xDFFF]
|
||||
//
|
||||
|
||||
/** Constant for the inverted exclamation mark key. */
|
||||
public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1;
|
||||
short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1;
|
||||
|
||||
/** Constant for the Euro currency sign key. */
|
||||
public static final short VK_EURO_SIGN = (short) 0x20AC;
|
||||
short VK_EURO_SIGN = (short) 0x20AC;
|
||||
|
||||
//
|
||||
// Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable)
|
||||
//
|
||||
|
||||
/* for Sun keyboards */
|
||||
public static final short VK_CUT = (short) 0xF879;
|
||||
public static final short VK_COPY = (short) 0xF87A;
|
||||
public static final short VK_PASTE = (short) 0xF87B;
|
||||
public static final short VK_UNDO = (short) 0xF87C;
|
||||
public static final short VK_AGAIN = (short) 0xF87D;
|
||||
public static final short VK_FIND = (short) 0xF87E;
|
||||
public static final short VK_PROPS = (short) 0xF87F;
|
||||
short VK_CUT = (short) 0xF879;
|
||||
short VK_COPY = (short) 0xF87A;
|
||||
short VK_PASTE = (short) 0xF87B;
|
||||
short VK_UNDO = (short) 0xF87C;
|
||||
short VK_AGAIN = (short) 0xF87D;
|
||||
short VK_FIND = (short) 0xF87E;
|
||||
short VK_PROPS = (short) 0xF87F;
|
||||
|
||||
/* for input method support on Asian Keyboards */
|
||||
|
||||
@ -514,61 +514,61 @@ public interface KeyboardJogampValues {
|
||||
* Constant for the input method on/off key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
|
||||
public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890;
|
||||
short VK_INPUT_METHOD_ON_OFF = (short) 0xF890;
|
||||
|
||||
/**
|
||||
* Constant for the Code Input function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
|
||||
public static final short VK_CODE_INPUT = (short) 0xF891;
|
||||
short VK_CODE_INPUT = (short) 0xF891;
|
||||
|
||||
/**
|
||||
* Constant for the Roman Characters function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: roumaji */
|
||||
public static final short VK_ROMAN_CHARACTERS = (short) 0xF892;
|
||||
short VK_ROMAN_CHARACTERS = (short) 0xF892;
|
||||
|
||||
/**
|
||||
* Constant for the All Candidates function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
|
||||
public static final short VK_ALL_CANDIDATES = (short) 0xF893;
|
||||
short VK_ALL_CANDIDATES = (short) 0xF893;
|
||||
|
||||
/**
|
||||
* Constant for the Previous Candidate function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
|
||||
public static final short VK_PREVIOUS_CANDIDATE = (short) 0xF894;
|
||||
short VK_PREVIOUS_CANDIDATE = (short) 0xF894;
|
||||
|
||||
/**
|
||||
* Constant for the Alphanumeric function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: eisuu */
|
||||
public static final short VK_ALPHANUMERIC = (short) 0xF895;
|
||||
short VK_ALPHANUMERIC = (short) 0xF895;
|
||||
|
||||
/**
|
||||
* Constant for the Katakana function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: katakana */
|
||||
public static final short VK_KATAKANA = (short) 0xF896;
|
||||
short VK_KATAKANA = (short) 0xF896;
|
||||
|
||||
/**
|
||||
* Constant for the Hiragana function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: hiragana */
|
||||
public static final short VK_HIRAGANA = (short) 0xF897;
|
||||
short VK_HIRAGANA = (short) 0xF897;
|
||||
|
||||
/**
|
||||
* Constant for the Full-Width Characters function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: zenkaku */
|
||||
public static final short VK_FULL_WIDTH = (short) 0xF898;
|
||||
short VK_FULL_WIDTH = (short) 0xF898;
|
||||
|
||||
/**
|
||||
* Constant for the Half-Width Characters function key.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard: hankaku */
|
||||
public static final short VK_HALF_WIDTH = (short) 0xF89A;
|
||||
short VK_HALF_WIDTH = (short) 0xF89A;
|
||||
|
||||
/**
|
||||
* Constant for the Japanese-Katakana function key.
|
||||
@ -576,7 +576,7 @@ public interface KeyboardJogampValues {
|
||||
* input mode.
|
||||
*/
|
||||
/* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
|
||||
public static final short VK_JAPANESE_KATAKANA = (short) 0xF89B;
|
||||
short VK_JAPANESE_KATAKANA = (short) 0xF89B;
|
||||
|
||||
/**
|
||||
* Constant for the Japanese-Hiragana function key.
|
||||
@ -584,7 +584,7 @@ public interface KeyboardJogampValues {
|
||||
* input mode.
|
||||
*/
|
||||
/* Japanese Macintosh keyboard */
|
||||
public static final short VK_JAPANESE_HIRAGANA = (short) 0xF89C;
|
||||
short VK_JAPANESE_HIRAGANA = (short) 0xF89C;
|
||||
|
||||
/**
|
||||
* Constant for the Japanese-Roman function key.
|
||||
@ -592,19 +592,19 @@ public interface KeyboardJogampValues {
|
||||
* input mode.
|
||||
*/
|
||||
/* Japanese Macintosh keyboard */
|
||||
public static final short VK_JAPANESE_ROMAN = (short) 0xF89D;
|
||||
short VK_JAPANESE_ROMAN = (short) 0xF89D;
|
||||
|
||||
/**
|
||||
* Constant for the locking Kana function key.
|
||||
* This key locks the keyboard into a Kana layout.
|
||||
*/
|
||||
/* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
|
||||
public static final short VK_KANA_LOCK = (short) 0xF89F;
|
||||
short VK_KANA_LOCK = (short) 0xF89F;
|
||||
|
||||
/**
|
||||
* Constant for Keyboard became invisible, e.g. Android's soft keyboard Back
|
||||
* button hit while keyboard is visible.
|
||||
*/
|
||||
public static final short VK_KEYBOARD_INVISIBLE = (short) 0xF8FF;
|
||||
short VK_KEYBOARD_INVISIBLE = (short) 0xF8FF;
|
||||
|
||||
}
|
||||
|
@ -12,13 +12,12 @@ public class PIHardwareDisplay implements HardwareDisplay {
|
||||
public void shutdown() {}
|
||||
|
||||
@Override
|
||||
public void setBrightness(double value) {
|
||||
if (Engine.getPlatform().getSettings().isDebugEnabled() == false) {
|
||||
public void setBrightness(final double value) {
|
||||
if (Engine.getPlatform().getSettings().isDebugEnabled() == false)
|
||||
Engine.getPlatform().getGpio().pwmWrite(12, (int) Math.ceil(value * 1024f));
|
||||
// SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10)));
|
||||
} else {
|
||||
else
|
||||
Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,69 +12,65 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
|
||||
private final boolean invertXY, invertX, invertY;
|
||||
|
||||
public PIHardwareTouchDevice(boolean invertXY, boolean invertX, boolean invertY) {
|
||||
public PIHardwareTouchDevice(final boolean invertXY, final boolean invertX, final boolean invertY) {
|
||||
this.invertXY = invertXY;
|
||||
this.invertX = invertX;
|
||||
this.invertY = invertY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchStart(TouchStartEvent e) {
|
||||
public boolean onTouchStart(final TouchStartEvent e) {
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchStart(e)) {
|
||||
if (scr != null && scr.initialized && scr.onTouchStart(e))
|
||||
refresh = true;
|
||||
} else {
|
||||
else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
if (refresh)
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEnd(TouchEndEvent e) {
|
||||
public boolean onTouchEnd(final TouchEndEvent e) {
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchEnd(e)) {
|
||||
if (scr != null && scr.initialized && scr.onTouchEnd(e))
|
||||
refresh = true;
|
||||
} else {
|
||||
else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
if (refresh)
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchCancel(TouchCancelEvent e) {
|
||||
public boolean onTouchCancel(final TouchCancelEvent e) {
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchCancel(e)) {
|
||||
if (scr != null && scr.initialized && scr.onTouchCancel(e))
|
||||
refresh = true;
|
||||
} else {
|
||||
else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
if (refresh)
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchMove(TouchMoveEvent e) {
|
||||
public boolean onTouchMove(final TouchMoveEvent e) {
|
||||
final Screen scr = Engine.INSTANCE.getHardwareDevice().getDisplayManager().getScreen();
|
||||
boolean refresh = false;
|
||||
if (scr != null && scr.initialized && scr.onTouchMove(e)) {
|
||||
if (scr != null && scr.initialized && scr.onTouchMove(e))
|
||||
refresh = true;
|
||||
} else {
|
||||
else {
|
||||
//Default behavior
|
||||
}
|
||||
if (refresh) {
|
||||
if (refresh)
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().forceRefresh = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,20 +90,18 @@ public class PIHardwareTouchDevice implements HardwareTouchDevice {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TouchPoint makePoint(long id, float x, float y, int screenWidth, int screenHeight, float radiusX,
|
||||
float radiusY, float force, float rotationAngle) {
|
||||
public TouchPoint makePoint(final long id, float x, float y, final int screenWidth, final int screenHeight,
|
||||
final float radiusX, final float radiusY, final float force, final float rotationAngle) {
|
||||
if (getInvertedXY()) {
|
||||
double oldX = x;
|
||||
double oldY = y;
|
||||
x = (float) (oldY * ((double) screenWidth) / ((double) screenHeight));
|
||||
y = (float) (oldX * ((double) screenHeight) / ((double) screenWidth));
|
||||
final double oldX = x;
|
||||
final double oldY = y;
|
||||
x = (float) (oldY * screenWidth / screenHeight);
|
||||
y = (float) (oldX * screenHeight / screenWidth);
|
||||
}
|
||||
if (getInvertedX()) {
|
||||
if (getInvertedX())
|
||||
x = screenWidth - x;
|
||||
}
|
||||
if (getInvertedY()) {
|
||||
if (getInvertedY())
|
||||
y = screenHeight - y;
|
||||
}
|
||||
return new TouchPoint(id, x, y, radiusX, radiusY, force, rotationAngle);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class ParallelToSerial {
|
||||
private final int QH;
|
||||
private final int CLK;
|
||||
|
||||
public ParallelToSerial(int SH_LD_pin, int CLK_INH_pin, int QH_pin, int CLK_pin) {
|
||||
public ParallelToSerial(final int SH_LD_pin, final int CLK_INH_pin, final int QH_pin, final int CLK_pin) {
|
||||
SH_LD = SH_LD_pin;
|
||||
CLK_INH = CLK_INH_pin;
|
||||
QH = QH_pin;
|
||||
|
@ -7,16 +7,16 @@ public class SerialToParallel {
|
||||
private final int SCK; //Shift register clock pin
|
||||
private final int SER; //Serial data input
|
||||
|
||||
public SerialToParallel(int RCK_pin, int SCK_pin, int SER_pin) {
|
||||
public SerialToParallel(final int RCK_pin, final int SCK_pin, final int SER_pin) {
|
||||
RCK = RCK_pin;
|
||||
SCK = SCK_pin;
|
||||
SER = SER_pin;
|
||||
}
|
||||
|
||||
public void write(boolean[] data) {
|
||||
if (data.length != 8) {
|
||||
public void write(final boolean[] data) {
|
||||
if (data.length != 8)
|
||||
return;
|
||||
} else {
|
||||
else {
|
||||
Engine.getPlatform().getGpio().digitalWrite(RCK, Engine.getPlatform().getGpio().valueLow());
|
||||
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
|
@ -31,7 +31,7 @@ public class RAWFont {
|
||||
public int charIntCount;
|
||||
public static final int intBits = 31;
|
||||
|
||||
public void create(String name) {
|
||||
public void create(final String name) {
|
||||
try {
|
||||
loadFont("/font_" + name + ".rft");
|
||||
} catch (final IOException e) {
|
||||
@ -45,7 +45,7 @@ public class RAWFont {
|
||||
int currentInt = 0;
|
||||
int currentBit = 0;
|
||||
for (int i = 0; i < charS; i++) {
|
||||
if (currentInt * intBits + currentBit >= (currentInt + 1) * intBits) {
|
||||
if (currentInt * RAWFont.intBits + currentBit >= (currentInt + 1) * RAWFont.intBits) {
|
||||
currentInt += 1;
|
||||
currentBit = 0;
|
||||
}
|
||||
@ -56,11 +56,11 @@ public class RAWFont {
|
||||
int currentInt = 0;
|
||||
int currentBit = 0;
|
||||
for (int i = 0; i < charS; i++) {
|
||||
if (currentBit >= intBits) {
|
||||
if (currentBit >= RAWFont.intBits) {
|
||||
currentInt += 1;
|
||||
currentBit = 0;
|
||||
}
|
||||
chars32[charIndex * charIntCount + currentInt] = (chars32[charIndex * charIntCount + currentInt]) | ((currentChar[i] ? 1 : 0) << currentBit);
|
||||
chars32[charIndex * charIntCount + currentInt] = chars32[charIndex * charIntCount + currentInt] | (currentChar[i] ? 1 : 0) << currentBit;
|
||||
currentBit++;
|
||||
}
|
||||
}
|
||||
@ -69,12 +69,11 @@ public class RAWFont {
|
||||
Object obj = new Object();
|
||||
final WeakReference<Object> ref = new WeakReference<>(obj);
|
||||
obj = null;
|
||||
while (ref.get() != null) {
|
||||
while (ref.get() != null)
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFont(String string) throws IOException {
|
||||
private void loadFont(final String string) throws IOException {
|
||||
final URL res = ClassUtils.classLoader.getClass().getResource(string);
|
||||
final int[] file = Utils.realBytes(Utils.convertStreamToByteArray(res.openStream(), res.getFile().length()));
|
||||
final int filelength = file.length;
|
||||
@ -83,32 +82,28 @@ public class RAWFont {
|
||||
charW = file[0x4] << 8 | file[0x5];
|
||||
charH = file[0x6] << 8 | file[0x7];
|
||||
charS = charW * charH;
|
||||
charIntCount = (int) Math.ceil(((double) charS) / ((double) intBits));
|
||||
charIntCount = (int) Math.ceil((double) charS / (double) RAWFont.intBits);
|
||||
minBound = file[0x9] << 24 | file[0xA] << 16 | file[0xB] << 8 | file[0xC];
|
||||
maxBound = file[0xE] << 24 | file[0xF] << 16 | file[0x10] << 8 | file[0x11];
|
||||
if (maxBound <= minBound) {
|
||||
if (maxBound <= minBound)
|
||||
maxBound = 10000; //TODO remove it: temp fix
|
||||
}
|
||||
rawchars = new boolean[maxBound - minBound][];
|
||||
int index = 0x12;
|
||||
while (index < filelength) {
|
||||
while (index < filelength)
|
||||
try {
|
||||
final int charIndex = file[index] << 8 | file[index + 1];
|
||||
final boolean[] rawchar = new boolean[charS];
|
||||
int charbytescount = 0;
|
||||
while (charbytescount * 8 < charS) {
|
||||
while (charbytescount * 8 < charS)
|
||||
charbytescount += 1;
|
||||
}
|
||||
int currentBit = 0;
|
||||
for (int i = 0; i <= charbytescount; i++) {
|
||||
for (int i = 0; i <= charbytescount; i++)
|
||||
for (int bit = 0; bit < 8; bit++) {
|
||||
if (currentBit >= charS) {
|
||||
if (currentBit >= charS)
|
||||
break;
|
||||
}
|
||||
rawchar[currentBit] = (((file[index + 2 + i] >> (8 - 1 - bit)) & 0x1) == 1) ? true : false;
|
||||
rawchar[currentBit] = (file[index + 2 + i] >> 8 - 1 - bit & 0x1) == 1 ? true : false;
|
||||
currentBit++;
|
||||
}
|
||||
}
|
||||
rawchars[charIndex - minBound] = rawchar;
|
||||
index += 2 + charbytescount;
|
||||
} catch (final Exception ex) {
|
||||
@ -116,27 +111,23 @@ public class RAWFont {
|
||||
System.out.println(string);
|
||||
Engine.getPlatform().exit(-1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
throw new IOException();
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getCharIndexes(String txt) {
|
||||
public int[] getCharIndexes(final String txt) {
|
||||
final int l = txt.length();
|
||||
final int[] indexes = new int[l];
|
||||
final char[] chars = txt.toCharArray();
|
||||
for (int i = 0; i < l; i++) {
|
||||
for (int i = 0; i < l; i++)
|
||||
indexes[i] = (chars[i] & 0xFFFF) - minBound;
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void saveArray(int[] screen, String coutputpng) {
|
||||
private void saveArray(final int[] screen, final String coutputpng) {
|
||||
final BufferedImage bi = new BufferedImage(300, 200, BufferedImage.TYPE_INT_RGB);
|
||||
final int[] a = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
|
||||
System.arraycopy(screen, 0, a, 0, screen.length);
|
||||
@ -147,7 +138,8 @@ public class RAWFont {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawText(int[] screen, int[] screenSize, int x, int y, int[] text, int color) {
|
||||
public void drawText(final int[] screen, final int[] screenSize, final int x, final int y, final int[] text,
|
||||
final int color) {
|
||||
final int screenLength = screen.length;
|
||||
int screenPos = 0;
|
||||
|
||||
@ -158,23 +150,21 @@ public class RAWFont {
|
||||
int j;
|
||||
final int l = text.length;
|
||||
for (int i = 0; i < l; i++) {
|
||||
cpos = (i * (charW + 1));
|
||||
cpos = i * (charW + 1);
|
||||
final int charIndex = text[i];
|
||||
for (int dy = 0; dy < charH; dy++) {
|
||||
for (int dy = 0; dy < charH; dy++)
|
||||
for (int dx = 0; dx < charW; dx++) {
|
||||
j = x + cpos + dx;
|
||||
if (j > 0 & j < screenSize[0]) {
|
||||
final int bit = dx + dy * charW;
|
||||
currentInt = (int) (Math.floor(bit) / (intBits));
|
||||
currentIntBitPosition = bit - (currentInt * intBits);
|
||||
bitData = (chars32[charIndex * charIntCount + currentInt] >> currentIntBitPosition) & 1;
|
||||
currentInt = (int) (Math.floor(bit) / RAWFont.intBits);
|
||||
currentIntBitPosition = bit - currentInt * RAWFont.intBits;
|
||||
bitData = chars32[charIndex * charIntCount + currentInt] >> currentIntBitPosition & 1;
|
||||
screenPos = x + cpos + dx + (y + dy) * screenSize[0];
|
||||
if (bitData == 1 & screenLength > screenPos) {
|
||||
if (bitData == 1 & screenLength > screenPos)
|
||||
screen[screenPos] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
package it.cavallium.warppi.event;
|
||||
|
||||
public interface KeyEvent extends Event {
|
||||
public Key getKey();
|
||||
Key getKey();
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package it.cavallium.warppi.event;
|
||||
|
||||
public class KeyPressedEvent implements KeyEvent {
|
||||
|
||||
private Key k;
|
||||
private final Key k;
|
||||
|
||||
public KeyPressedEvent(Key k) {
|
||||
public KeyPressedEvent(final Key k) {
|
||||
this.k = k;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,9 @@ package it.cavallium.warppi.event;
|
||||
|
||||
public class KeyReleasedEvent implements KeyEvent {
|
||||
|
||||
private Key k;
|
||||
private final Key k;
|
||||
|
||||
public KeyReleasedEvent(Key k) {
|
||||
public KeyReleasedEvent(final Key k) {
|
||||
this.k = k;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package it.cavallium.warppi.event;
|
||||
|
||||
public interface KeyboardEventListener {
|
||||
public default boolean onKeyPressed(KeyPressedEvent k) {
|
||||
default boolean onKeyPressed(final KeyPressedEvent k) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public default boolean onKeyReleased(KeyReleasedEvent k) {
|
||||
default boolean onKeyReleased(final KeyReleasedEvent k) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public class TouchCancelEvent implements TouchEvent {
|
||||
private final List<TouchPoint> changedTouches;
|
||||
private final List<TouchPoint> touches;
|
||||
|
||||
public TouchCancelEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
|
||||
public TouchCancelEvent(final List<TouchPoint> changedTouches, final List<TouchPoint> touches) {
|
||||
super();
|
||||
this.changedTouches = changedTouches;
|
||||
this.touches = touches;
|
||||
@ -27,20 +27,20 @@ public class TouchCancelEvent implements TouchEvent {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
|
||||
result = prime * result + (changedTouches == null ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + (touches == null ? 0 : touches.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TouchCancelEvent other = (TouchCancelEvent) obj;
|
||||
final TouchCancelEvent other = (TouchCancelEvent) obj;
|
||||
if (changedTouches == null) {
|
||||
if (other.changedTouches != null)
|
||||
return false;
|
||||
|
@ -7,7 +7,7 @@ public class TouchEndEvent implements TouchEvent {
|
||||
private final List<TouchPoint> changedTouches;
|
||||
private final List<TouchPoint> touches;
|
||||
|
||||
public TouchEndEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
|
||||
public TouchEndEvent(final List<TouchPoint> changedTouches, final List<TouchPoint> touches) {
|
||||
super();
|
||||
this.changedTouches = changedTouches;
|
||||
this.touches = touches;
|
||||
@ -27,20 +27,20 @@ public class TouchEndEvent implements TouchEvent {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
|
||||
result = prime * result + (changedTouches == null ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + (touches == null ? 0 : touches.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TouchEndEvent other = (TouchEndEvent) obj;
|
||||
final TouchEndEvent other = (TouchEndEvent) obj;
|
||||
if (changedTouches == null) {
|
||||
if (other.changedTouches != null)
|
||||
return false;
|
||||
|
@ -3,7 +3,7 @@ package it.cavallium.warppi.event;
|
||||
import java.util.List;
|
||||
|
||||
public interface TouchEvent extends Event {
|
||||
public List<TouchPoint> getChangedTouches();
|
||||
List<TouchPoint> getChangedTouches();
|
||||
|
||||
public List<TouchPoint> getTouches();
|
||||
List<TouchPoint> getTouches();
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
package it.cavallium.warppi.event;
|
||||
|
||||
public interface TouchEventListener {
|
||||
public default boolean onTouchStart(TouchStartEvent k) {
|
||||
default boolean onTouchStart(final TouchStartEvent k) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public default boolean onTouchEnd(TouchEndEvent k) {
|
||||
default boolean onTouchEnd(final TouchEndEvent k) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public default boolean onTouchCancel(TouchCancelEvent k) {
|
||||
default boolean onTouchCancel(final TouchCancelEvent k) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public default boolean onTouchMove(TouchMoveEvent k) {
|
||||
default boolean onTouchMove(final TouchMoveEvent k) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ public class TouchMoveEvent implements TouchEvent {
|
||||
private final List<TouchPoint> changedTouches;
|
||||
private final List<TouchPoint> touches;
|
||||
|
||||
public TouchMoveEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
|
||||
public TouchMoveEvent(final List<TouchPoint> changedTouches, final List<TouchPoint> touches) {
|
||||
super();
|
||||
this.changedTouches = changedTouches;
|
||||
this.touches = touches;
|
||||
@ -27,20 +27,20 @@ public class TouchMoveEvent implements TouchEvent {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
|
||||
result = prime * result + (changedTouches == null ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + (touches == null ? 0 : touches.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TouchMoveEvent other = (TouchMoveEvent) obj;
|
||||
final TouchMoveEvent other = (TouchMoveEvent) obj;
|
||||
if (changedTouches == null) {
|
||||
if (other.changedTouches != null)
|
||||
return false;
|
||||
|
@ -9,7 +9,7 @@ public class TouchPoint {
|
||||
private final float y;
|
||||
private final long id;
|
||||
|
||||
public TouchPoint(long id, float x, float y, float radiusX, float radiusY, float force, float rotationAngle) {
|
||||
public TouchPoint(final long id, final float x, final float y, final float radiusX, final float radiusY, final float force, final float rotationAngle) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.radiusX = radiusX;
|
||||
@ -53,7 +53,7 @@ public class TouchPoint {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + Float.floatToIntBits(force);
|
||||
result = prime * result + (int) (id ^ (id >>> 32));
|
||||
result = prime * result + (int) (id ^ id >>> 32);
|
||||
result = prime * result + Float.floatToIntBits(radiusX);
|
||||
result = prime * result + Float.floatToIntBits(radiusY);
|
||||
result = prime * result + Float.floatToIntBits(rotationAngle);
|
||||
@ -63,14 +63,14 @@ public class TouchPoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TouchPoint other = (TouchPoint) obj;
|
||||
final TouchPoint other = (TouchPoint) obj;
|
||||
if (Float.floatToIntBits(force) != Float.floatToIntBits(other.force))
|
||||
return false;
|
||||
if (id != other.id)
|
||||
|
@ -7,7 +7,7 @@ public class TouchStartEvent implements TouchEvent {
|
||||
private final List<TouchPoint> changedTouches;
|
||||
private final List<TouchPoint> touches;
|
||||
|
||||
public TouchStartEvent(List<TouchPoint> changedTouches, List<TouchPoint> touches) {
|
||||
public TouchStartEvent(final List<TouchPoint> changedTouches, final List<TouchPoint> touches) {
|
||||
super();
|
||||
this.changedTouches = changedTouches;
|
||||
this.touches = touches;
|
||||
@ -27,20 +27,20 @@ public class TouchStartEvent implements TouchEvent {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((changedTouches == null) ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + ((touches == null) ? 0 : touches.hashCode());
|
||||
result = prime * result + (changedTouches == null ? 0 : changedTouches.hashCode());
|
||||
result = prime * result + (touches == null ? 0 : touches.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TouchStartEvent other = (TouchStartEvent) obj;
|
||||
final TouchStartEvent other = (TouchStartEvent) obj;
|
||||
if (changedTouches == null) {
|
||||
if (other.changedTouches != null)
|
||||
return false;
|
||||
|
@ -5,7 +5,7 @@ public class MarioBlock {
|
||||
private final int y;
|
||||
private final byte id;
|
||||
|
||||
public MarioBlock(int x, int y, byte b) {
|
||||
public MarioBlock(final int x, final int y, final byte b) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
id = b;
|
||||
@ -27,7 +27,7 @@ public class MarioBlock {
|
||||
return y;
|
||||
}
|
||||
|
||||
public static boolean isSolid(byte id) {
|
||||
public static boolean isSolid(final byte id) {
|
||||
return id != 0b0;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package it.cavallium.warppi.extra.mario;
|
||||
|
||||
public class MarioEnemy extends MarioEntity {
|
||||
|
||||
public MarioEnemy(double x, double y, double forceX, double forceY, boolean onGround, boolean subjectToGravity) {
|
||||
public MarioEnemy(final double x, final double y, final double forceX, final double forceY, final boolean onGround, final boolean subjectToGravity) {
|
||||
super(x, y, forceX, forceY, onGround, subjectToGravity);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class MarioEntity {
|
||||
public boolean collisionRight;
|
||||
public boolean subjectToGravity;
|
||||
|
||||
public MarioEntity(double x, double y, double forceX, double forceY, boolean onGround, boolean subjectToGravity) {
|
||||
public MarioEntity(final double x, final double y, final double forceX, final double forceY, final boolean onGround, final boolean subjectToGravity) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.forceX = forceX;
|
||||
@ -20,12 +20,12 @@ public class MarioEntity {
|
||||
this.subjectToGravity = subjectToGravity;
|
||||
}
|
||||
|
||||
public void setPosition(double x, double y) {
|
||||
public void setPosition(final double x, final double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setPosition(double x, double y, boolean onGround) {
|
||||
public void setPosition(final double x, final double y, final boolean onGround) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
collisionDown = onGround;
|
||||
@ -43,43 +43,41 @@ public class MarioEntity {
|
||||
return collisionDown;
|
||||
}
|
||||
|
||||
public void setOnGround(boolean onGround) {
|
||||
public void setOnGround(final boolean onGround) {
|
||||
collisionDown = onGround;
|
||||
}
|
||||
|
||||
public void gameTick(double dt) {
|
||||
public void gameTick(final double dt) {
|
||||
x = computeFutureDX(dt);
|
||||
y = computeFutureDY(dt);
|
||||
forceX = computeFutureForceDX(dt);
|
||||
forceY = computeFutureForceDY(dt);
|
||||
}
|
||||
|
||||
public double computeFutureDX(double dt) {
|
||||
return (x + dt * forceX) - x;
|
||||
public double computeFutureDX(final double dt) {
|
||||
return x + dt * forceX - x;
|
||||
}
|
||||
|
||||
public double computeFutureDY(double dt) {
|
||||
public double computeFutureDY(final double dt) {
|
||||
final double forceY = this.forceY;
|
||||
double y = this.y;
|
||||
if (!collisionDown) {
|
||||
if (!collisionDown)
|
||||
y += dt * forceY;
|
||||
}
|
||||
return y - this.y;
|
||||
}
|
||||
|
||||
public double computeFutureForceDX(double dt) {
|
||||
public double computeFutureForceDX(final double dt) {
|
||||
double forceX = this.forceX;
|
||||
forceX *= 0.75;
|
||||
return forceX - this.forceX;
|
||||
}
|
||||
|
||||
public double computeFutureForceDY(double dt) {
|
||||
public double computeFutureForceDY(final double dt) {
|
||||
double forceY = this.forceY;
|
||||
if (subjectToGravity && !collisionDown) {
|
||||
if (subjectToGravity && !collisionDown)
|
||||
forceY -= dt * 1569.6 / 16f;
|
||||
} else {
|
||||
else
|
||||
forceY *= 0.75;
|
||||
}
|
||||
return forceY - this.forceY;
|
||||
}
|
||||
}
|
||||
|
@ -26,15 +26,15 @@ public class MarioGame {
|
||||
canMove = true;
|
||||
}
|
||||
|
||||
public MarioBlock getBlockAt(int x, int y) {
|
||||
public MarioBlock getBlockAt(final int x, final int y) {
|
||||
return worlds[currentWorld].getBlockAt(x, y);
|
||||
}
|
||||
|
||||
public MarioBlock getBlockAt(double x, double y) {
|
||||
public MarioBlock getBlockAt(final double x, final double y) {
|
||||
return getBlockAt((int) x, (int) y);
|
||||
}
|
||||
|
||||
public void move(float dt, double deltaX, double deltaY) {
|
||||
public void move(final float dt, final double deltaX, final double deltaY) {
|
||||
final double curX = player.getX();
|
||||
final double curY = player.getY();
|
||||
final double futureX = curX + deltaX;
|
||||
@ -50,15 +50,14 @@ public class MarioGame {
|
||||
return worlds[currentWorld];
|
||||
}
|
||||
|
||||
public void gameTick(float dt, boolean upPressed, boolean downPressed, boolean leftPressed, boolean rightPressed,
|
||||
boolean jumpPressed, boolean runPressed) {
|
||||
public void gameTick(final float dt, final boolean upPressed, final boolean downPressed, final boolean leftPressed,
|
||||
final boolean rightPressed, final boolean jumpPressed, final boolean runPressed) {
|
||||
checkOnGround(getPlayer(), dt);
|
||||
checkCollisionTop(getPlayer(), dt);
|
||||
checkCollisionLeft(getPlayer(), dt);
|
||||
checkCollisionRight(getPlayer(), dt);
|
||||
if (canMove) {
|
||||
if (canMove)
|
||||
move(dt, (rightPressed ? 1 : 0) - (leftPressed ? 1 : 0), jumpPressed ? 1 : 0);
|
||||
}
|
||||
getPlayer().gameTick(dt);
|
||||
|
||||
final MarioWorld w = getCurrentWorld();
|
||||
@ -72,25 +71,24 @@ public class MarioGame {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int nearest(double val, int a, int b) {
|
||||
private int nearest(final double val, final int a, final int b) {
|
||||
final double aa = Math.abs(val - a);
|
||||
final double ab = Math.abs(val - b);
|
||||
if (aa < ab) {
|
||||
if (aa < ab)
|
||||
return (int) aa;
|
||||
} else {
|
||||
else
|
||||
return (int) ab;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkOnGround(MarioEntity e, float dt) {
|
||||
private void checkOnGround(final MarioEntity e, final float dt) {
|
||||
if (e.subjectToGravity) {
|
||||
final int xA = (int) Math.floor(e.getX());
|
||||
final int xB = (int) Math.ceil(e.getX());
|
||||
final int y0 = (int) Math.ceil(e.getY());
|
||||
final int y1 = (int) Math.ceil(e.getY() + e.computeFutureDY(dt));
|
||||
boolean onGround = false;
|
||||
if (y1 < y0) {
|
||||
for (int y = y0; y >= y1; y--) {
|
||||
if (y1 < y0)
|
||||
for (int y = y0; y >= y1; y--)
|
||||
for (int x = xA; x <= xB; x++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x, y - 1);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
@ -103,8 +101,7 @@ public class MarioGame {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else
|
||||
for (int x = xA; x <= xB; x++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x, y0 - 1);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
@ -116,22 +113,20 @@ public class MarioGame {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!onGround) {
|
||||
if (!onGround)
|
||||
e.setOnGround(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCollisionTop(MarioEntity e, float dt) {
|
||||
private void checkCollisionTop(final MarioEntity e, final float dt) {
|
||||
if (e.subjectToGravity) {
|
||||
final int xA = (int) Math.floor(e.getX());
|
||||
final int xB = (int) Math.ceil(e.getX());
|
||||
final int y0 = (int) Math.ceil(e.getY());
|
||||
final int y1 = (int) Math.ceil(e.getY() + e.computeFutureDY(dt));
|
||||
boolean collisionUp = false;
|
||||
if (y1 > y0) {
|
||||
for (int y = y0; y <= y1; y++) {
|
||||
if (y1 > y0)
|
||||
for (int y = y0; y <= y1; y++)
|
||||
for (int x = xA; x <= xB; x++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x, y + 1);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
@ -144,8 +139,7 @@ public class MarioGame {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else
|
||||
for (int x = xA; x <= xB; x++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x, y0 + 1);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
@ -157,14 +151,12 @@ public class MarioGame {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!collisionUp) {
|
||||
if (!collisionUp)
|
||||
e.collisionUp = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCollisionRight(MarioEntity e, float dt) {
|
||||
private void checkCollisionRight(final MarioEntity e, final float dt) {
|
||||
if (e.subjectToGravity) {
|
||||
final int yA = (int) Math.floor(e.getY());
|
||||
final int yB = (int) Math.ceil(e.getY());
|
||||
@ -172,8 +164,8 @@ public class MarioGame {
|
||||
final double x1double = e.getX() + e.computeFutureDX(dt);
|
||||
final int x1 = (int) Math.floor(x1double);
|
||||
boolean collisionRight = false;
|
||||
if (x1 > x0) {
|
||||
for (int x = x0; x <= x1; x++) {
|
||||
if (x1 > x0)
|
||||
for (int x = x0; x <= x1; x++)
|
||||
for (int y = yA; y <= yB; y++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x + 1, y);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
@ -186,8 +178,7 @@ public class MarioGame {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else
|
||||
for (int y = yA; y <= yB; y++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x0 + 1, y);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
@ -199,14 +190,12 @@ public class MarioGame {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!collisionRight) {
|
||||
if (!collisionRight)
|
||||
e.collisionRight = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCollisionLeft(MarioEntity e, float dt) {
|
||||
private void checkCollisionLeft(final MarioEntity e, final float dt) {
|
||||
if (e.subjectToGravity) {
|
||||
final int yA = (int) Math.floor(e.getY());
|
||||
final int yB = (int) Math.ceil(e.getY());
|
||||
@ -220,39 +209,34 @@ public class MarioGame {
|
||||
e.setPosition(0, e.getY());
|
||||
}
|
||||
e.collisionLeft = true;
|
||||
} else {
|
||||
if (x1 < x0) {
|
||||
for (int x = x0; x >= x1; x--) {
|
||||
for (int y = yA; y <= yB; y++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x - 1, y);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
collisionLeft = true;
|
||||
if (e.forceX < 0 && x1double <= x) {
|
||||
e.forceX = 0;
|
||||
e.setPosition(x, e.getY());
|
||||
e.collisionLeft = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (x1 < x0)
|
||||
for (int x = x0; x >= x1; x--)
|
||||
for (int y = yA; y <= yB; y++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x0 - 1, y);
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x - 1, y);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
collisionLeft = true;
|
||||
if (e.forceX < 0 && x1double <= x0) {
|
||||
if (e.forceX < 0 && x1double <= x) {
|
||||
e.forceX = 0;
|
||||
e.setPosition(x0, e.getY());
|
||||
e.setPosition(x, e.getY());
|
||||
e.collisionLeft = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int y = yA; y <= yB; y++) {
|
||||
final byte b = getCurrentWorld().getBlockIdAt(x0 - 1, y);
|
||||
if (MarioBlock.isSolid(b)) {
|
||||
collisionLeft = true;
|
||||
if (e.forceX < 0 && x1double <= x0) {
|
||||
e.forceX = 0;
|
||||
e.setPosition(x0, e.getY());
|
||||
e.collisionLeft = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!collisionLeft) {
|
||||
if (!collisionLeft)
|
||||
e.collisionLeft = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class MarioWorld {
|
||||
* @param events
|
||||
* @param marioEnemies
|
||||
*/
|
||||
public MarioWorld(int[] spawnPoint, int width, int height, byte[][] data, MarioEvent[] events, MarioEntity[] entities) {
|
||||
public MarioWorld(final int[] spawnPoint, final int width, final int height, final byte[][] data, final MarioEvent[] events, final MarioEntity[] entities) {
|
||||
this.spawnPoint = spawnPoint;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
@ -26,19 +26,17 @@ public class MarioWorld {
|
||||
this.entities = entities;
|
||||
}
|
||||
|
||||
public byte getBlockIdAt(int x, int y) {
|
||||
final int idy = (height - 1 - y);
|
||||
if (idy < 0 || idy >= data.length) {
|
||||
public byte getBlockIdAt(final int x, final int y) {
|
||||
final int idy = height - 1 - y;
|
||||
if (idy < 0 || idy >= data.length)
|
||||
return 0b0;
|
||||
}
|
||||
final int idx = x;
|
||||
if (idx < 0 || idx >= data[0].length) {
|
||||
if (idx < 0 || idx >= data[0].length)
|
||||
return 0b0;
|
||||
}
|
||||
return data[idy][idx];
|
||||
}
|
||||
|
||||
public MarioBlock getBlockAt(int x, int y) {
|
||||
public MarioBlock getBlockAt(final int x, final int y) {
|
||||
return new MarioBlock(x, y, getBlockIdAt(x, y));
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,13 @@ public class PlayerEntity extends MarioEntity {
|
||||
private double controllerDX;
|
||||
private double controllerDY;
|
||||
|
||||
public PlayerEntity(double x, double y, int life) {
|
||||
public PlayerEntity(final double x, final double y, final int life) {
|
||||
super(x, y, 0, 0, true, true);
|
||||
this.life = life;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gameTick(double dt) {
|
||||
public void gameTick(final double dt) {
|
||||
walkAnimation += dt;
|
||||
x += computeFutureDX(dt);
|
||||
y += computeFutureDY(dt);
|
||||
@ -48,87 +48,79 @@ public class PlayerEntity extends MarioEntity {
|
||||
if (jumptime <= 0.5f && !jumping && collisionDown) {
|
||||
jumping = true;
|
||||
collisionDown = false;
|
||||
} else if (jumptime <= 0.5f) {} else {
|
||||
} else if (jumptime <= 0.5f) {} else
|
||||
jumping = false;
|
||||
}
|
||||
} else {
|
||||
jumping = false;
|
||||
if (collisionDown) {
|
||||
if (collisionDown)
|
||||
jumptime = 0;
|
||||
} else {
|
||||
else
|
||||
jumptime = Float.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
if (!walking & !running & !jumping) {
|
||||
marioSkinPos[0] = 0;
|
||||
marioSkinPos[1] = 0;
|
||||
} else if (collisionDown & walking & !running & !jumping && walkAnimation >= 0.08) {
|
||||
} else if (collisionDown & walking & !running & !jumping && walkAnimation >= 0.08)
|
||||
while (walkAnimation > 0.08) {
|
||||
walkAnimation -= 0.08;
|
||||
if (marioSkinPos[0] == 1 & marioSkinPos[1] == 0) {
|
||||
if (marioSkinPos[0] == 1 & marioSkinPos[1] == 0)
|
||||
marioSkinPos[0] += 2;
|
||||
} else if (marioSkinPos[0] == 3 & marioSkinPos[1] == 0) {
|
||||
else if (marioSkinPos[0] == 3 & marioSkinPos[1] == 0)
|
||||
marioSkinPos[0] -= 1;
|
||||
} else if (marioSkinPos[0] == 2 & marioSkinPos[1] == 0) {
|
||||
else if (marioSkinPos[0] == 2 & marioSkinPos[1] == 0)
|
||||
marioSkinPos[0] -= 1;
|
||||
} else {
|
||||
else {
|
||||
marioSkinPos[0] = 1;
|
||||
marioSkinPos[1] = 0;
|
||||
}
|
||||
}
|
||||
} else if (jumping) {
|
||||
else if (jumping) {
|
||||
marioSkinPos[0] = 5;
|
||||
marioSkinPos[1] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeFutureDX(double dt) {
|
||||
public double computeFutureDX(final double dt) {
|
||||
return super.computeFutureDX(dt);
|
||||
}
|
||||
|
||||
public double computeFuturedDY(double dt) {
|
||||
public double computeFuturedDY(final double dt) {
|
||||
return super.computeFutureDY(dt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeFutureForceDX(double dt) {
|
||||
public double computeFutureForceDX(final double dt) {
|
||||
double forceX = this.forceX;
|
||||
if (controllerDX == 0) {} else {
|
||||
if (controllerDX > 0) { //RIGHT
|
||||
if (forceX < 500f / 16f) {
|
||||
if (controllerDX > 0)
|
||||
if (forceX < 500f / 16f)
|
||||
forceX += dt * 500f / 16f;
|
||||
}
|
||||
}
|
||||
if (controllerDX < 0) { //LEFT
|
||||
if (forceX > -500f / 16f) {
|
||||
if (controllerDX < 0)
|
||||
if (forceX > -500f / 16f)
|
||||
forceX -= dt * 500f / 16f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (forceX + super.computeFutureForceDX(dt)) - this.forceX;
|
||||
return forceX + super.computeFutureForceDX(dt) - this.forceX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computeFutureForceDY(double dt) {
|
||||
public double computeFutureForceDY(final double dt) {
|
||||
float jumptime = this.jumptime;
|
||||
double forceY = this.forceY;
|
||||
if (controllerDY > 0) { //JUMP
|
||||
if (collisionUp) {
|
||||
if (collisionUp)
|
||||
jumptime = Float.MAX_VALUE;
|
||||
}
|
||||
jumptime += dt;
|
||||
if (jumptime <= 0.5f && !jumping && collisionDown) {
|
||||
if (jumptime <= 0.5f && !jumping && collisionDown)
|
||||
forceY = dt * (4 * 1569.6f) / 16f;
|
||||
} else if (jumptime <= 0.5f) {
|
||||
else if (jumptime <= 0.5f)
|
||||
forceY = dt * (4 * 1569.6f) / 16f;
|
||||
}
|
||||
}
|
||||
return (forceY + super.computeFutureForceDY(dt)) - this.forceY;
|
||||
return forceY + super.computeFutureForceDY(dt) - this.forceY;
|
||||
}
|
||||
|
||||
public void move(float dt, double dX, double dY) {
|
||||
public void move(final float dt, final double dX, final double dY) {
|
||||
walkAnimation += dt;
|
||||
|
||||
controllerDX = dX;
|
||||
|
@ -11,7 +11,7 @@ public class BehaviorSubject<T> extends Subject<T> {
|
||||
lastValueSet = false;
|
||||
}
|
||||
|
||||
protected BehaviorSubject(T initialValue) {
|
||||
protected BehaviorSubject(final T initialValue) {
|
||||
super();
|
||||
lastValue = initialValue;
|
||||
lastValueSet = true;
|
||||
@ -21,31 +21,28 @@ public class BehaviorSubject<T> extends Subject<T> {
|
||||
return new BehaviorSubject<>();
|
||||
}
|
||||
|
||||
public final static <T> BehaviorSubject<T> create(T initialValue) {
|
||||
return new BehaviorSubject<T>(initialValue);
|
||||
public final static <T> BehaviorSubject<T> create(final T initialValue) {
|
||||
return new BehaviorSubject<>(initialValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
public void onError(final Throwable e) {
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(T t) {
|
||||
public void onNext(final T t) {
|
||||
lastValue = t;
|
||||
lastValueSet = true;
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onNext(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,13 +76,12 @@ public class BehaviorSubject<T> extends Subject<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
public void onSubscribe(final Disposable d) {
|
||||
@SuppressWarnings("unchecked")
|
||||
DisposableOfSubscriber ds = (DisposableOfSubscriber) d;
|
||||
Subscriber<? super T> s = ds.getSubscriber();
|
||||
if (lastValueSet) {
|
||||
final DisposableOfSubscriber ds = (DisposableOfSubscriber) d;
|
||||
final Subscriber<? super T> s = ds.getSubscriber();
|
||||
if (lastValueSet)
|
||||
s.onNext(lastValue);
|
||||
}
|
||||
}
|
||||
|
||||
public T getLastValue() {
|
||||
|
@ -26,9 +26,9 @@ public interface Consumer<T> {
|
||||
* @throws NullPointerException
|
||||
* if {@code after} is null
|
||||
*/
|
||||
default Consumer<T> andThen(Consumer<? super T> after) {
|
||||
default Consumer<T> andThen(final Consumer<? super T> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return (T t) -> {
|
||||
return (final T t) -> {
|
||||
accept(t);
|
||||
after.accept(t);
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
package it.cavallium.warppi.flow;
|
||||
|
||||
public interface Disposable {
|
||||
public void dispose();
|
||||
void dispose();
|
||||
|
||||
public boolean isDisposed();
|
||||
boolean isDisposed();
|
||||
}
|
||||
|
@ -9,35 +9,31 @@ public class IntervalsManager {
|
||||
private static List<ObservableInterval> intervals = new LinkedList<>();
|
||||
|
||||
static {
|
||||
startChecker();
|
||||
IntervalsManager.startChecker();
|
||||
}
|
||||
|
||||
private IntervalsManager() {
|
||||
|
||||
}
|
||||
|
||||
public static void register(ObservableInterval t) {
|
||||
synchronized (intervals) {
|
||||
if (!intervals.contains(t)) {
|
||||
intervals.add(t);
|
||||
}
|
||||
public static void register(final ObservableInterval t) {
|
||||
synchronized (IntervalsManager.intervals) {
|
||||
if (!IntervalsManager.intervals.contains(t))
|
||||
IntervalsManager.intervals.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void startChecker() {
|
||||
Thread t = new Thread(() -> {
|
||||
final Thread t = new Thread(() -> {
|
||||
try {
|
||||
while (true) {
|
||||
Thread.sleep(1000);
|
||||
for (ObservableInterval interval : intervals) {
|
||||
if (interval.running) {
|
||||
if (interval.subscribers.size() <= 0) {
|
||||
for (final ObservableInterval interval : IntervalsManager.intervals)
|
||||
if (interval.running)
|
||||
if (interval.subscribers.size() <= 0)
|
||||
interval.stopInterval();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
@ -14,69 +14,75 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Disposable subscribe(Action1<? super T> onNext) {
|
||||
public Disposable subscribe(final Action1<? super T> onNext) {
|
||||
return subscribe(createSubscriber(onNext));
|
||||
}
|
||||
|
||||
protected Observable<T>.DisposableOfSubscriber createDisposable(Subscriber<? super T> sub) {
|
||||
protected Observable<T>.DisposableOfSubscriber createDisposable(final Subscriber<? super T> sub) {
|
||||
return new DisposableOfSubscriber(sub);
|
||||
}
|
||||
|
||||
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) {
|
||||
public Disposable subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError) {
|
||||
return subscribe(createSubscriber(onNext, onError));
|
||||
}
|
||||
|
||||
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompleted) {
|
||||
public Disposable subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError,
|
||||
final Action0 onCompleted) {
|
||||
return subscribe(createSubscriber(onNext, onError, onCompleted));
|
||||
}
|
||||
|
||||
public void subscribe(Observer<? super T> obs) {
|
||||
@Override
|
||||
public void subscribe(final Observer<? super T> obs) {
|
||||
subscribe(createSubscriber(obs));
|
||||
}
|
||||
|
||||
public Disposable subscribe(Subscriber<? super T> sub) {
|
||||
public Disposable subscribe(final Subscriber<? super T> sub) {
|
||||
subscribers.add(sub);
|
||||
return createDisposable(sub);
|
||||
}
|
||||
|
||||
protected Subscriber<T> createSubscriber(Action1<? super T> onNext) {
|
||||
protected Subscriber<T> createSubscriber(final Action1<? super T> onNext) {
|
||||
return new Subscriber<T>() {
|
||||
@Override
|
||||
public void onSubscribe(Subscription s) {}
|
||||
public void onSubscribe(final Subscription s) {}
|
||||
|
||||
public void onNext(T t) {
|
||||
@Override
|
||||
public void onNext(final T t) {
|
||||
onNext.call(t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected Subscriber<T> createSubscriber(Action1<? super T> onNext, Action1<Throwable> onError) {
|
||||
protected Subscriber<T> createSubscriber(final Action1<? super T> onNext, final Action1<Throwable> onError) {
|
||||
return new Subscriber<T>() {
|
||||
@Override
|
||||
public void onSubscribe(Subscription s) {}
|
||||
public void onSubscribe(final Subscription s) {}
|
||||
|
||||
public void onNext(T t) {
|
||||
@Override
|
||||
public void onNext(final T t) {
|
||||
onNext.call(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable t) {
|
||||
public void onError(final Throwable t) {
|
||||
onError.call(t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected Subscriber<T> createSubscriber(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) {
|
||||
protected Subscriber<T> createSubscriber(final Action1<? super T> onNext, final Action1<Throwable> onError,
|
||||
final Action0 onCompl) {
|
||||
return new Subscriber<T>() {
|
||||
@Override
|
||||
public void onSubscribe(Subscription s) {}
|
||||
public void onSubscribe(final Subscription s) {}
|
||||
|
||||
public void onNext(T t) {
|
||||
@Override
|
||||
public void onNext(final T t) {
|
||||
onNext.call(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable t) {
|
||||
public void onError(final Throwable t) {
|
||||
onError.call(t);
|
||||
}
|
||||
|
||||
@ -87,17 +93,18 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
};
|
||||
}
|
||||
|
||||
protected Subscriber<T> createSubscriber(Observer<? super T> obs) {
|
||||
protected Subscriber<T> createSubscriber(final Observer<? super T> obs) {
|
||||
return new Subscriber<T>() {
|
||||
@Override
|
||||
public void onSubscribe(Subscription s) {}
|
||||
public void onSubscribe(final Subscription s) {}
|
||||
|
||||
public void onNext(T t) {
|
||||
@Override
|
||||
public void onNext(final T t) {
|
||||
obs.onNext(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable t) {
|
||||
public void onError(final Throwable t) {
|
||||
obs.onError(t);
|
||||
}
|
||||
|
||||
@ -108,32 +115,32 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
};
|
||||
}
|
||||
|
||||
public static final <T> Observable<T> merge(Observable<T> a, Observable<T> b) {
|
||||
public static final <T> Observable<T> merge(final Observable<T> a, final Observable<T> b) {
|
||||
return new ObservableMerged<>(a, b);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static final <T> Observable<T> of(Observable<T> a) {
|
||||
public static final <T> Observable<T> of(final Observable<T> a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final <U> Observable<U> map(Function<T, U> f) {
|
||||
return new ObservableMap<T, U>(this, f);
|
||||
public final <U> Observable<U> map(final Function<T, U> f) {
|
||||
return new ObservableMap<>(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(final Observable<T> a, final 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(final Observable<T> a, final 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(final Observable<T> a, final Observable<U> b) {
|
||||
return new ObservableZipped<>(a, b);
|
||||
}
|
||||
|
||||
public static final Observable<Long> interval(long interval) {
|
||||
public static final Observable<Long> interval(final long interval) {
|
||||
return new ObservableInterval(interval);
|
||||
}
|
||||
|
||||
@ -141,7 +148,7 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
|
||||
private final Subscriber<? super T> sub;
|
||||
|
||||
public DisposableOfSubscriber(Subscriber<? super T> sub) {
|
||||
public DisposableOfSubscriber(final Subscriber<? super T> sub) {
|
||||
this.sub = sub;
|
||||
}
|
||||
|
||||
@ -155,9 +162,8 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (isDisposed()) {
|
||||
if (isDisposed())
|
||||
throw new RuntimeException("Already disposed!");
|
||||
}
|
||||
subscribers.remove(sub);
|
||||
Observable.this.onDisposed(sub);
|
||||
}
|
||||
@ -169,8 +175,8 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
|
||||
}
|
||||
|
||||
public Observable<T> doOnNext(Action1<T> onNext) {
|
||||
Subject<T> onNextSubject = BehaviorSubject.create();
|
||||
public Observable<T> doOnNext(final Action1<T> onNext) {
|
||||
final Subject<T> onNextSubject = BehaviorSubject.create();
|
||||
this.subscribe((val) -> {
|
||||
onNext.call(val);
|
||||
onNextSubject.onNext(val);
|
||||
@ -178,7 +184,7 @@ public abstract class Observable<T> implements ObservableSource<T> {
|
||||
return onNextSubject;
|
||||
}
|
||||
|
||||
public void onDisposed(Subscriber<? super T> sub) {
|
||||
public void onDisposed(final Subscriber<? super T> sub) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ObservableCombinedChanged<T, U> extends Observable<Pair<T, U>> {
|
||||
private volatile boolean initialized = false;
|
||||
private Observable<T> a;
|
||||
private Observable<U> b;
|
||||
private final Observable<T> a;
|
||||
private final Observable<U> b;
|
||||
private Disposable disposableA;
|
||||
private Disposable disposableB;
|
||||
|
||||
public ObservableCombinedChanged(Observable<T> a, Observable<U> b) {
|
||||
public ObservableCombinedChanged(final Observable<T> a, final Observable<U> b) {
|
||||
super();
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
@ -17,30 +17,24 @@ public class ObservableCombinedChanged<T, U> extends Observable<Pair<T, U>> {
|
||||
|
||||
private void initialize() {
|
||||
this.disposableA = a.subscribe((t) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onNext(Pair.of(t, null));
|
||||
}
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
this.disposableB = b.subscribe((t) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onNext(Pair.of(null, t));
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onNext(Pair.of(null, t));;
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
}
|
||||
|
||||
@ -52,14 +46,14 @@ public class ObservableCombinedChanged<T, U> extends Observable<Pair<T, U>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super Pair<T, U>> sub) {
|
||||
Disposable disp = super.subscribe(sub);
|
||||
public Disposable subscribe(final Subscriber<? super Pair<T, U>> sub) {
|
||||
final Disposable disp = super.subscribe(sub);
|
||||
chechInitialized();
|
||||
return disp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisposed(Subscriber<? super Pair<T, U>> sub) {
|
||||
public void onDisposed(final Subscriber<? super Pair<T, U>> sub) {
|
||||
super.onDisposed(sub);
|
||||
this.disposableA.dispose();
|
||||
this.disposableB.dispose();
|
||||
|
@ -4,8 +4,8 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
|
||||
private volatile boolean initialized = false;
|
||||
private Observable<T> a;
|
||||
private Observable<U> b;
|
||||
private final Observable<T> a;
|
||||
private final Observable<U> b;
|
||||
private Disposable disposableA;
|
||||
private Disposable disposableB;
|
||||
private volatile T lastA;
|
||||
@ -13,7 +13,7 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
|
||||
private volatile boolean didAOneTime;
|
||||
private volatile boolean didBOneTime;
|
||||
|
||||
public ObservableCombinedLatest(Observable<T> a, Observable<U> b) {
|
||||
public ObservableCombinedLatest(final Observable<T> a, final Observable<U> b) {
|
||||
super();
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
@ -25,35 +25,30 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
|
||||
didAOneTime = true;
|
||||
receivedNext();
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
this.disposableB = b.subscribe((t) -> {
|
||||
lastB = t;
|
||||
didBOneTime = true;
|
||||
receivedNext();
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
}
|
||||
|
||||
private void receivedNext() {
|
||||
if (didAOneTime && didBOneTime) {
|
||||
this.subscribers.forEach(sub -> {
|
||||
if (didAOneTime && didBOneTime)
|
||||
subscribers.forEach(sub -> {
|
||||
sub.onNext(Pair.of(lastA, lastB));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void chechInitialized() {
|
||||
@ -64,14 +59,14 @@ public class ObservableCombinedLatest<T, U> extends Observable<Pair<T, U>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super Pair<T, U>> sub) {
|
||||
Disposable disp = super.subscribe(sub);
|
||||
public Disposable subscribe(final Subscriber<? super Pair<T, U>> sub) {
|
||||
final Disposable disp = super.subscribe(sub);
|
||||
chechInitialized();
|
||||
return disp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisposed(Subscriber<? super Pair<T, U>> sub) {
|
||||
public void onDisposed(final Subscriber<? super Pair<T, U>> sub) {
|
||||
super.onDisposed(sub);
|
||||
this.disposableA.dispose();
|
||||
this.disposableB.dispose();
|
||||
|
@ -7,12 +7,12 @@ public class ObservableInterval extends Observable<Long> {
|
||||
volatile boolean running;
|
||||
volatile Thread timeThread;
|
||||
|
||||
protected ObservableInterval(long interval) {
|
||||
protected ObservableInterval(final long interval) {
|
||||
super();
|
||||
this.interval = interval;
|
||||
try {
|
||||
startInterval();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -20,15 +20,15 @@ public class ObservableInterval extends Observable<Long> {
|
||||
void stopInterval() {
|
||||
if (running) {
|
||||
running = false;
|
||||
this.timeThread.interrupt();
|
||||
timeThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super Long> sub) {
|
||||
public Disposable subscribe(final Subscriber<? super Long> sub) {
|
||||
try {
|
||||
startInterval();
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.subscribe(sub);
|
||||
@ -36,18 +36,16 @@ public class ObservableInterval extends Observable<Long> {
|
||||
|
||||
void startInterval() throws InterruptedException {
|
||||
if (running == false) {
|
||||
while (timeThread != null) {
|
||||
while (timeThread != null)
|
||||
Thread.sleep(100);
|
||||
}
|
||||
timeThread = new Thread(() -> {
|
||||
try {
|
||||
while (!Thread.interrupted()) {
|
||||
for (Subscriber<? super Long> sub : this.subscribers) {
|
||||
for (final Subscriber<? super Long> sub : subscribers)
|
||||
sub.onNext(System.currentTimeMillis());
|
||||
}
|
||||
Thread.sleep(interval);
|
||||
}
|
||||
} catch (InterruptedException e) {}
|
||||
} catch (final InterruptedException e) {}
|
||||
timeThread = null;
|
||||
});
|
||||
Engine.getPlatform().setThreadName(timeThread, "ObservableTimer");
|
||||
@ -56,12 +54,12 @@ public class ObservableInterval extends Observable<Long> {
|
||||
}
|
||||
}
|
||||
|
||||
public static ObservableInterval create(long l) {
|
||||
public static ObservableInterval create(final long l) {
|
||||
return new ObservableInterval(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisposed(Subscriber<? super Long> sub) {
|
||||
public void onDisposed(final Subscriber<? super Long> sub) {
|
||||
super.onDisposed(sub);
|
||||
stopInterval();
|
||||
}
|
||||
|
@ -3,12 +3,12 @@ package it.cavallium.warppi.flow;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ObservableMap<T, U> extends Observable<U> {
|
||||
private Observable<T> originalObservable;
|
||||
private Function<T, U> mapAction;
|
||||
private final Observable<T> originalObservable;
|
||||
private final Function<T, U> mapAction;
|
||||
private volatile boolean initialized = false;
|
||||
private Disposable mapDisposable;
|
||||
|
||||
public ObservableMap(Observable<T> originalObservable, Function<T, U> mapAction) {
|
||||
public ObservableMap(final Observable<T> originalObservable, final Function<T, U> mapAction) {
|
||||
super();
|
||||
this.originalObservable = originalObservable;
|
||||
this.mapAction = mapAction;
|
||||
@ -16,17 +16,14 @@ public class ObservableMap<T, U> extends Observable<U> {
|
||||
|
||||
private void initialize() {
|
||||
this.mapDisposable = originalObservable.subscribe((t) -> {
|
||||
for (Subscriber<? super U> sub : this.subscribers) {
|
||||
sub.onNext(mapAction.apply(t));
|
||||
} ;
|
||||
for (final Subscriber<? super U> sub : subscribers)
|
||||
sub.onNext(mapAction.apply(t));;
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super U> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super U> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super U> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super U> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
}
|
||||
|
||||
@ -38,14 +35,14 @@ public class ObservableMap<T, U> extends Observable<U> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super U> sub) {
|
||||
Disposable disp = super.subscribe(sub);
|
||||
public Disposable subscribe(final Subscriber<? super U> sub) {
|
||||
final Disposable disp = super.subscribe(sub);
|
||||
chechInitialized();
|
||||
return disp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisposed(Subscriber<? super U> sub) {
|
||||
public void onDisposed(final Subscriber<? super U> sub) {
|
||||
super.onDisposed(sub);
|
||||
mapDisposable.dispose();
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package it.cavallium.warppi.flow;
|
||||
|
||||
public class ObservableMerged<T> extends Observable<T> {
|
||||
private Observable<T> originalObservableA;
|
||||
private Observable<T> originalObservableB;
|
||||
private final Observable<T> originalObservableA;
|
||||
private final Observable<T> originalObservableB;
|
||||
private volatile boolean initialized = false;
|
||||
private Disposable mapDisposableA;
|
||||
private Disposable mapDisposableB;
|
||||
|
||||
public ObservableMerged(Observable<T> originalObservableA, Observable<T> originalObservableB) {
|
||||
public ObservableMerged(final Observable<T> originalObservableA, final Observable<T> originalObservableB) {
|
||||
super();
|
||||
this.originalObservableA = originalObservableA;
|
||||
this.originalObservableB = originalObservableB;
|
||||
@ -15,30 +15,24 @@ public class ObservableMerged<T> extends Observable<T> {
|
||||
|
||||
private void initialize() {
|
||||
this.mapDisposableA = originalObservableA.subscribe((t) -> {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onNext(t);
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onNext(t);;
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
this.mapDisposableB = originalObservableB.subscribe((t) -> {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onNext(t);
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onNext(t);;
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
}
|
||||
|
||||
@ -50,14 +44,14 @@ public class ObservableMerged<T> extends Observable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super T> sub) {
|
||||
Disposable disp = super.subscribe(sub);
|
||||
public Disposable subscribe(final Subscriber<? super T> sub) {
|
||||
final Disposable disp = super.subscribe(sub);
|
||||
chechInitialized();
|
||||
return disp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisposed(Subscriber<? super T> sub) {
|
||||
public void onDisposed(final Subscriber<? super T> sub) {
|
||||
super.onDisposed(sub);
|
||||
this.mapDisposableA.dispose();
|
||||
this.mapDisposableB.dispose();
|
||||
|
@ -1,5 +1,5 @@
|
||||
package it.cavallium.warppi.flow;
|
||||
|
||||
public interface ObservableSource<T> {
|
||||
public void subscribe(Observer<? super T> observer);
|
||||
void subscribe(Observer<? super T> observer);
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
|
||||
private volatile boolean initialized = false;
|
||||
private Observable<T> a;
|
||||
private Observable<U> b;
|
||||
private final Observable<T> a;
|
||||
private final Observable<U> b;
|
||||
private Disposable disposableA;
|
||||
private Disposable disposableB;
|
||||
private volatile T lastA;
|
||||
@ -13,7 +13,7 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
|
||||
private volatile boolean didA;
|
||||
private volatile boolean didB;
|
||||
|
||||
public ObservableZipped(Observable<T> a, Observable<U> b) {
|
||||
public ObservableZipped(final Observable<T> a, final Observable<U> b) {
|
||||
super();
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
@ -25,26 +25,22 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
|
||||
didA = true;
|
||||
receivedNext();
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
this.disposableB = b.subscribe((t) -> {
|
||||
lastB = t;
|
||||
didB = true;
|
||||
receivedNext();
|
||||
}, (e) -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}, () -> {
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
});
|
||||
}
|
||||
|
||||
@ -52,9 +48,8 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
|
||||
if (didA && didB) {
|
||||
didA = false;
|
||||
didB = false;
|
||||
for (Subscriber<? super Pair<T, U>> sub : this.subscribers) {
|
||||
sub.onNext(Pair.of(lastA, lastB));
|
||||
} ;
|
||||
for (final Subscriber<? super Pair<T, U>> sub : subscribers)
|
||||
sub.onNext(Pair.of(lastA, lastB));;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,14 +61,14 @@ public class ObservableZipped<T, U> extends Observable<Pair<T, U>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super Pair<T, U>> sub) {
|
||||
Disposable disp = super.subscribe(sub);
|
||||
public Disposable subscribe(final Subscriber<? super Pair<T, U>> sub) {
|
||||
final Disposable disp = super.subscribe(sub);
|
||||
chechInitialized();
|
||||
return disp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisposed(Subscriber<? super Pair<T, U>> sub) {
|
||||
public void onDisposed(final Subscriber<? super Pair<T, U>> sub) {
|
||||
super.onDisposed(sub);
|
||||
this.disposableA.dispose();
|
||||
this.disposableB.dispose();
|
||||
|
@ -1,11 +1,11 @@
|
||||
package it.cavallium.warppi.flow;
|
||||
|
||||
public interface Observer<T> {
|
||||
public void onComplete();
|
||||
void onComplete();
|
||||
|
||||
public void onError(Throwable e);
|
||||
void onError(Throwable e);
|
||||
|
||||
public void onNext(T t);
|
||||
void onNext(T t);
|
||||
|
||||
public void onSubscribe(Disposable d);
|
||||
void onSubscribe(Disposable d);
|
||||
}
|
||||
|
@ -10,23 +10,20 @@ public class SimpleSubject<T> extends Subject<T> {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onComplete();
|
||||
} ;
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onComplete();;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onError(e);
|
||||
} ;
|
||||
public void onError(final Throwable e) {
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onError(e);;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(T t) {
|
||||
for (Subscriber<? super T> sub : this.subscribers) {
|
||||
sub.onNext(t);
|
||||
} ;
|
||||
public void onNext(final T t) {
|
||||
for (final Subscriber<? super T> sub : subscribers)
|
||||
sub.onNext(t);;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,6 +57,6 @@ public class SimpleSubject<T> extends Subject<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {}
|
||||
public void onSubscribe(final Disposable d) {}
|
||||
|
||||
}
|
||||
|
@ -12,29 +12,30 @@ public abstract class Subject<T> extends Observable<T> implements Observer<T> {
|
||||
abstract Subject<T> toSerialized();
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Action1<? super T> onNext) {
|
||||
public Disposable subscribe(final Action1<? super T> onNext) {
|
||||
return subscribe(createSubscriber(onNext));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError) {
|
||||
public Disposable subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError) {
|
||||
return subscribe(createSubscriber(onNext, onError));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Action1<? super T> onNext, Action1<Throwable> onError, Action0 onCompl) {
|
||||
public Disposable subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError,
|
||||
final Action0 onCompl) {
|
||||
return subscribe(createSubscriber(onNext, onError, onCompl));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribe(Observer<? super T> obs) {
|
||||
public void subscribe(final Observer<? super T> obs) {
|
||||
subscribe(createSubscriber(obs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disposable subscribe(Subscriber<? super T> sub) {
|
||||
Disposable disp = super.subscribe(sub);
|
||||
this.onSubscribe(disp);
|
||||
public Disposable subscribe(final Subscriber<? super T> sub) {
|
||||
final Disposable disp = super.subscribe(sub);
|
||||
onSubscribe(disp);
|
||||
return disp;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package it.cavallium.warppi.flow;
|
||||
public interface Subscriber<T> {
|
||||
default void onComplete() {}
|
||||
|
||||
default void onError(Throwable t) {}
|
||||
default void onError(final Throwable t) {}
|
||||
|
||||
void onNext(T t);
|
||||
|
||||
|
@ -3,12 +3,12 @@ package it.cavallium.warppi.flow;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class TestFlow {
|
||||
public static void main(String[] args) {
|
||||
public static void main(final String[] args) {
|
||||
try {
|
||||
|
||||
BehaviorSubject<Float> subject0 = BehaviorSubject.create(0f);
|
||||
final BehaviorSubject<Float> subject0 = BehaviorSubject.create(0f);
|
||||
|
||||
Disposable s00 = subject0.subscribe((val) -> {
|
||||
final Disposable s00 = subject0.subscribe((val) -> {
|
||||
System.out.println(val);
|
||||
});
|
||||
Thread.sleep(100);
|
||||
@ -25,9 +25,9 @@ public class TestFlow {
|
||||
subject0.onComplete();
|
||||
System.out.println("items sent.");
|
||||
|
||||
Subject<Float> subject1 = BehaviorSubject.create(0f);
|
||||
final Subject<Float> subject1 = BehaviorSubject.create(0f);
|
||||
|
||||
Disposable s01 = subject1.map((val) -> val + 1).subscribe((val) -> {
|
||||
final Disposable s01 = subject1.map((val) -> val + 1).subscribe((val) -> {
|
||||
System.out.println(val);
|
||||
});
|
||||
Thread.sleep(100);
|
||||
@ -44,11 +44,11 @@ public class TestFlow {
|
||||
subject1.onComplete();
|
||||
System.out.println("items sent.");
|
||||
|
||||
BehaviorSubject<Float> subjectA = BehaviorSubject.create();
|
||||
BehaviorSubject<Float> subjectB = BehaviorSubject.create();
|
||||
Observable<Float> observable = Observable.merge(subjectA, subjectB);
|
||||
final BehaviorSubject<Float> subjectA = BehaviorSubject.create();
|
||||
final BehaviorSubject<Float> subjectB = BehaviorSubject.create();
|
||||
final Observable<Float> observable = Observable.merge(subjectA, subjectB);
|
||||
|
||||
Disposable s1 = observable.subscribe((val) -> {
|
||||
final Disposable s1 = observable.subscribe((val) -> {
|
||||
System.out.println(val);
|
||||
});
|
||||
Thread.sleep(100);
|
||||
@ -67,11 +67,11 @@ public class TestFlow {
|
||||
Thread.sleep(100);
|
||||
System.out.println("no more news subscribers left, closing publisher..");
|
||||
|
||||
BehaviorSubject<Float> subjectC = BehaviorSubject.create();
|
||||
BehaviorSubject<Float> subjectD = BehaviorSubject.create();
|
||||
Observable<Pair<Float, Float>> observableCombined = Observable.combineLatest(subjectC, subjectD);
|
||||
final BehaviorSubject<Float> subjectC = BehaviorSubject.create();
|
||||
final BehaviorSubject<Float> subjectD = BehaviorSubject.create();
|
||||
final Observable<Pair<Float, Float>> observableCombined = Observable.combineLatest(subjectC, subjectD);
|
||||
System.out.println("Combined observable: " + observableCombined.toString());
|
||||
Disposable s2 = observableCombined.subscribe((val) -> {
|
||||
final Disposable s2 = observableCombined.subscribe((val) -> {
|
||||
System.out.println(val);
|
||||
});
|
||||
Thread.sleep(100);
|
||||
@ -89,8 +89,8 @@ public class TestFlow {
|
||||
subjectC.onComplete();
|
||||
System.out.println("items sent.");
|
||||
|
||||
ObservableInterval timA = ObservableInterval.create(100L);
|
||||
Disposable d = timA.subscribe((t) -> {
|
||||
final ObservableInterval timA = ObservableInterval.create(100L);
|
||||
final Disposable d = timA.subscribe((t) -> {
|
||||
System.out.println(t);
|
||||
});
|
||||
|
||||
@ -98,11 +98,11 @@ public class TestFlow {
|
||||
d.dispose();
|
||||
System.out.println("items sent.");
|
||||
|
||||
ObservableInterval subjectE = ObservableInterval.create(100L);
|
||||
BehaviorSubject<Float> subjectF = BehaviorSubject.create();
|
||||
Observable<Pair<Long, Float>> observableZipped = Observable.zip(subjectE, subjectF);
|
||||
final ObservableInterval subjectE = ObservableInterval.create(100L);
|
||||
final BehaviorSubject<Float> subjectF = BehaviorSubject.create();
|
||||
final Observable<Pair<Long, Float>> observableZipped = Observable.zip(subjectE, subjectF);
|
||||
System.out.println("Zipped observable: " + observableZipped.toString());
|
||||
Disposable s3 = observableZipped.subscribe((val) -> {
|
||||
final Disposable s3 = observableZipped.subscribe((val) -> {
|
||||
System.out.println(val);
|
||||
});
|
||||
Thread.sleep(100);
|
||||
@ -127,7 +127,7 @@ public class TestFlow {
|
||||
subjectF.onComplete();
|
||||
System.out.println("items sent.");
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -48,43 +48,22 @@ public class CalculatorHUD extends HUD {
|
||||
renderer.glDrawLine(0, 20, engine.getWidth() - 1, 20);
|
||||
renderer.glColor3i(255, 255, 255);
|
||||
guiSkin.use(engine);
|
||||
if (Keyboard.shift) {
|
||||
if (Keyboard.shift)
|
||||
renderer.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 2, 16 * 0, 16, 16);
|
||||
} else {
|
||||
else
|
||||
renderer.glFillRect(2 + 18 * 0, 2, 16, 16, 16 * 3, 16 * 0, 16, 16);
|
||||
}
|
||||
if (Keyboard.alpha) {
|
||||
if (Keyboard.alpha)
|
||||
renderer.glFillRect(2 + 18 * 1, 2, 16, 16, 16 * 0, 16 * 0, 16, 16);
|
||||
} else {
|
||||
else
|
||||
renderer.glFillRect(2 + 18 * 1, 2, 16, 16, 16 * 1, 16 * 0, 16, 16);
|
||||
}
|
||||
/*
|
||||
if (Calculator.angleMode == AngleMode.DEG) {
|
||||
drawSkinPart(8 + 18 * 2, 2, 16 * 4, 16 * 0, 16 + 16 * 4, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 3, 2, 16 * 7, 16 * 0, 16 + 16 * 7, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 4, 2, 16 * 9, 16 * 0, 16 + 16 * 9, 16 + 16 * 0);
|
||||
} else if (Calculator.angleMode == AngleMode.RAD) {
|
||||
drawSkinPart(8 + 18 * 2, 2, 16 * 5, 16 * 0, 16 + 16 * 5, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 3, 2, 16 * 6, 16 * 0, 16 + 16 * 6, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 4, 2, 16 * 9, 16 * 0, 16 + 16 * 9, 16 + 16 * 0);
|
||||
} else if (Calculator.angleMode == AngleMode.GRA) {
|
||||
drawSkinPart(8 + 18 * 2, 2, 16 * 5, 16 * 0, 16 + 16 * 5, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 3, 2, 16 * 7, 16 * 0, 16 + 16 * 7, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 4, 2, 16 * 8, 16 * 0, 16 + 16 * 8, 16 + 16 * 0);
|
||||
} else {
|
||||
drawSkinPart(8 + 18 * 2, 2, 16 * 5, 16 * 0, 16 + 16 * 5, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 3, 2, 16 * 7, 16 * 0, 16 + 16 * 7, 16 + 16 * 0);
|
||||
drawSkinPart(8 + 18 * 4, 2, 16 * 9, 16 * 0, 16 + 16 * 9, 16 + 16 * 0);
|
||||
}*/
|
||||
|
||||
int padding = 2;
|
||||
|
||||
final int brightness = (int) (Math.ceil(Engine.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9));
|
||||
if (brightness <= 10) {
|
||||
final int brightness = (int) Math.ceil(Engine.INSTANCE.getHardwareDevice().getDisplayManager().getBrightness() * 9);
|
||||
if (brightness <= 10)
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
|
||||
} else {
|
||||
else
|
||||
Engine.getPlatform().getConsoleUtils().out().println(1, "Brightness error");
|
||||
}
|
||||
|
||||
padding += 18 + 6;
|
||||
|
||||
@ -96,15 +75,14 @@ public class CalculatorHUD extends HUD {
|
||||
padding += 18 + 6;
|
||||
}
|
||||
|
||||
if (canGoBack && canGoForward) {
|
||||
if (canGoBack && canGoForward)
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
|
||||
} else if (canGoBack) {
|
||||
else if (canGoBack)
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
|
||||
} else if (canGoForward) {
|
||||
else if (canGoForward)
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
|
||||
} else {
|
||||
else
|
||||
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
|
||||
}
|
||||
|
||||
padding += 18;
|
||||
|
||||
@ -123,7 +101,7 @@ public class CalculatorHUD extends HUD {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -51,12 +51,12 @@ public final class DisplayManager implements RenderingLoop {
|
||||
*/
|
||||
public boolean forceRefresh;
|
||||
|
||||
public DisplayManager(HardwareDisplay monitor, HUD hud, Screen screen, String title) {
|
||||
public DisplayManager(final HardwareDisplay monitor, final HUD hud, final Screen screen, final String title) {
|
||||
this.monitor = monitor;
|
||||
this.hud = hud;
|
||||
this.initialTitle = title;
|
||||
this.initialScreen = screen;
|
||||
|
||||
initialTitle = title;
|
||||
initialScreen = screen;
|
||||
|
||||
screenChange = Engine.getPlatform().newSemaphore();
|
||||
engine = chooseGraphicEngine();
|
||||
supportsPauses = engine.doesRefreshPauses();
|
||||
@ -72,9 +72,8 @@ public final class DisplayManager implements RenderingLoop {
|
||||
try {
|
||||
hud.d = this;
|
||||
hud.create();
|
||||
if (!hud.initialized) {
|
||||
if (!hud.initialized)
|
||||
hud.initialize();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
Engine.getPlatform().exit(0);
|
||||
@ -97,18 +96,18 @@ public final class DisplayManager implements RenderingLoop {
|
||||
* skin_tex = glGenTextures();
|
||||
* glBindTexture(GL_TEXTURE_2D, skin_tex);
|
||||
* glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
*
|
||||
*
|
||||
* InputStream in = new FileInputStream("skin.png");
|
||||
* PNGDecoder decoder = new PNGDecoder(in);
|
||||
*
|
||||
*
|
||||
* System.out.println("width="+decoder.getWidth());
|
||||
* System.out.println("height="+decoder.getHeight());
|
||||
*
|
||||
*
|
||||
* ByteBuffer buf =
|
||||
* ByteBuffer.allocateDirect(4*decoder.getWidth()*decoder.getHeight());
|
||||
* decoder.decode(buf, decoder.getWidth()*4, Format.RGBA);
|
||||
* buf.flip();
|
||||
*
|
||||
*
|
||||
* skin = buf;
|
||||
* skin_w = decoder.getWidth();
|
||||
* skin_h = decoder.getHeight();
|
||||
@ -165,55 +164,48 @@ public final class DisplayManager implements RenderingLoop {
|
||||
throw new UnsupportedOperationException("No graphic engines available.");
|
||||
}
|
||||
|
||||
public void setScreen(Screen screen) {
|
||||
if (screen.initialized == false) {
|
||||
public void setScreen(final Screen screen) {
|
||||
if (screen.initialized == false)
|
||||
if (screen.canBeInHistory) {
|
||||
if (this.currentSession > 0) {
|
||||
final int sl = this.sessions.length + 5; //TODO: I don't know why if i don't add +5 or more some items disappear
|
||||
this.sessions = Arrays.copyOfRange(this.sessions, this.currentSession, sl);
|
||||
if (currentSession > 0) {
|
||||
final int sl = sessions.length + 5; //TODO: I don't know why if i don't add +5 or more some items disappear
|
||||
sessions = Arrays.copyOfRange(sessions, currentSession, sl);
|
||||
}
|
||||
this.currentSession = 0;
|
||||
for (int i = this.sessions.length - 1; i >= 1; i--) {
|
||||
this.sessions[i] = this.sessions[i - 1];
|
||||
}
|
||||
this.sessions[0] = screen;
|
||||
} else {
|
||||
this.currentSession = -1;
|
||||
}
|
||||
}
|
||||
currentSession = 0;
|
||||
for (int i = sessions.length - 1; i >= 1; i--)
|
||||
sessions[i] = sessions[i - 1];
|
||||
sessions[0] = screen;
|
||||
} else
|
||||
currentSession = -1;
|
||||
screen.d = this;
|
||||
try {
|
||||
screen.create();
|
||||
this.screen = screen;
|
||||
screenChange.release();
|
||||
if (screen.initialized == false) {
|
||||
if (screen.initialized == false)
|
||||
screen.initialize();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
Engine.getPlatform().exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void replaceScreen(Screen screen) {
|
||||
if (screen.initialized == false) {
|
||||
if (screen.canBeInHistory) {
|
||||
this.sessions[this.currentSession] = screen;
|
||||
} else {
|
||||
this.currentSession = -1;
|
||||
for (int i = 0; i < this.sessions.length - 2; i++) {
|
||||
this.sessions[i] = this.sessions[i + 1];
|
||||
}
|
||||
public void replaceScreen(final Screen screen) {
|
||||
if (screen.initialized == false)
|
||||
if (screen.canBeInHistory)
|
||||
sessions[currentSession] = screen;
|
||||
else {
|
||||
currentSession = -1;
|
||||
for (int i = 0; i < sessions.length - 2; i++)
|
||||
sessions[i] = sessions[i + 1];
|
||||
}
|
||||
}
|
||||
screen.d = this;
|
||||
try {
|
||||
screen.create();
|
||||
this.screen = screen;
|
||||
screenChange.release();
|
||||
if (screen.initialized == false) {
|
||||
if (screen.initialized == false)
|
||||
screen.initialize();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
Engine.getPlatform().exit(0);
|
||||
@ -221,65 +213,55 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
|
||||
public boolean canGoBack() {
|
||||
if (this.currentSession == -1) {
|
||||
return this.sessions[0] != null;
|
||||
}
|
||||
if (this.screen != this.sessions[this.currentSession]) {
|
||||
if (currentSession == -1)
|
||||
return sessions[0] != null;
|
||||
if (screen != sessions[currentSession]) {
|
||||
|
||||
} else if (this.currentSession + 1 < this.sessions.length) {
|
||||
if (this.sessions[this.currentSession + 1] != null) {
|
||||
} else if (currentSession + 1 < sessions.length) {
|
||||
if (sessions[currentSession + 1] != null) {
|
||||
|
||||
} else {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
if (this.sessions[this.currentSession] != null) {
|
||||
if (sessions[currentSession] != null)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void goBack() {
|
||||
if (canGoBack()) {
|
||||
if (this.currentSession >= 0 && this.screen != this.sessions[this.currentSession]) {} else {
|
||||
this.currentSession += 1;
|
||||
}
|
||||
this.screen = this.sessions[this.currentSession];
|
||||
if (currentSession >= 0 && screen != sessions[currentSession]) {} else
|
||||
currentSession += 1;
|
||||
screen = sessions[currentSession];
|
||||
screenChange.release();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canGoForward() {
|
||||
if (this.currentSession <= 0) { // -1 e 0
|
||||
if (currentSession <= 0)
|
||||
return false;
|
||||
}
|
||||
if (this.screen != this.sessions[this.currentSession]) {
|
||||
if (screen != sessions[currentSession]) {
|
||||
|
||||
} else if (this.currentSession > 0) {
|
||||
if (this.sessions[this.currentSession - 1] != null) {
|
||||
} else if (currentSession > 0) {
|
||||
if (sessions[currentSession - 1] != null) {
|
||||
|
||||
} else {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
if (this.sessions[this.currentSession] != null) {
|
||||
if (sessions[currentSession] != null)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void goForward() {
|
||||
if (canGoForward()) {
|
||||
if (this.screen != this.sessions[this.currentSession]) {
|
||||
if (screen != sessions[currentSession]) {
|
||||
|
||||
} else {
|
||||
this.currentSession -= 1;
|
||||
}
|
||||
this.screen = this.sessions[this.currentSession];
|
||||
} else
|
||||
currentSession -= 1;
|
||||
screen = sessions[currentSession];
|
||||
screenChange.release();
|
||||
}
|
||||
}
|
||||
@ -309,11 +291,9 @@ public final class DisplayManager implements RenderingLoop {
|
||||
private void draw_init() {
|
||||
if (engine.supportsFontRegistering()) {
|
||||
final List<BinaryFont> fontsIterator = engine.getRegisteredFonts();
|
||||
for (final BinaryFont f : fontsIterator) {
|
||||
if (!f.isInitialized()) {
|
||||
for (final BinaryFont f : fontsIterator)
|
||||
if (!f.isInitialized())
|
||||
f.initialize(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
renderer.glClear(engine.getWidth(), engine.getHeight());
|
||||
}
|
||||
@ -323,28 +303,25 @@ public final class DisplayManager implements RenderingLoop {
|
||||
|
||||
if (error != null) {
|
||||
final BinaryFont fnt = Utils.getFont(false, false);
|
||||
if (fnt != null && fnt != engine.getRenderer().getCurrentFont()) {
|
||||
if (fnt != null && fnt != engine.getRenderer().getCurrentFont())
|
||||
fnt.use(engine);
|
||||
}
|
||||
renderer.glColor3i(129, 28, 22);
|
||||
renderer.glDrawStringRight(StaticVars.screenSize[0] - 2, StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2), Engine.getPlatform().getSettings().getCalculatorNameUppercase() + " CALCULATOR");
|
||||
renderer.glColor3i(149, 32, 26);
|
||||
renderer.glDrawStringCenter((StaticVars.screenSize[0] / 2), 22, error);
|
||||
renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 22, error);
|
||||
renderer.glColor3i(164, 34, 28);
|
||||
int i = 22;
|
||||
for (final String stackPart : errorStackTrace) {
|
||||
renderer.glDrawStringLeft(2, 22 + i, stackPart);
|
||||
i += 11;
|
||||
}
|
||||
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
|
||||
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont())
|
||||
fonts[0].use(engine);
|
||||
}
|
||||
renderer.glColor3i(129, 28, 22);
|
||||
renderer.glDrawStringCenter((StaticVars.screenSize[0] / 2), 11, "UNEXPECTED EXCEPTION");
|
||||
renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, 11, "UNEXPECTED EXCEPTION");
|
||||
} else {
|
||||
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
|
||||
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont())
|
||||
fonts[0].use(engine);
|
||||
}
|
||||
hud.renderBackground();
|
||||
screen.render();
|
||||
hud.render();
|
||||
@ -363,7 +340,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
if (supportsPauses == false || (Keyboard.popRefreshRequest() || forceRefresh || screen.mustBeRefreshed())) {
|
||||
if (supportsPauses == false || Keyboard.popRefreshRequest() || forceRefresh || screen.mustBeRefreshed()) {
|
||||
forceRefresh = false;
|
||||
draw();
|
||||
}
|
||||
@ -386,28 +363,26 @@ public final class DisplayManager implements RenderingLoop {
|
||||
Engine.getPlatform().exit(0);
|
||||
}
|
||||
|
||||
Observable<Long> workTimer = Observable.interval(tickDuration);
|
||||
final Observable<Long> workTimer = Observable.interval(DisplayManager.tickDuration);
|
||||
|
||||
Observable<Integer[]> onResizeObservable = engine.onResize();
|
||||
final Observable<Integer[]> onResizeObservable = engine.onResize();
|
||||
Observable<Pair<Long, Integer[]>> refreshObservable;
|
||||
if (onResizeObservable == null) {
|
||||
if (onResizeObservable == null)
|
||||
refreshObservable = workTimer.map((l) -> Pair.of(l, null));
|
||||
} else {
|
||||
else
|
||||
refreshObservable = Observable.combineChanged(workTimer, engine.onResize());
|
||||
}
|
||||
|
||||
refreshObservable.subscribe((pair) -> {
|
||||
double dt = 0;
|
||||
final long newtime = System.nanoTime();
|
||||
if (precTime == -1) {
|
||||
dt = tickDuration;
|
||||
} else {
|
||||
if (precTime == -1)
|
||||
dt = DisplayManager.tickDuration;
|
||||
else
|
||||
dt = (newtime - precTime) / 1000d / 1000d;
|
||||
}
|
||||
precTime = newtime;
|
||||
|
||||
if (pair.getRight() != null) {
|
||||
Integer[] windowSize = pair.getRight();
|
||||
final Integer[] windowSize = pair.getRight();
|
||||
StaticVars.screenSize[0] = windowSize[0];
|
||||
StaticVars.screenSize[1] = windowSize[1];
|
||||
}
|
||||
@ -421,26 +396,25 @@ public final class DisplayManager implements RenderingLoop {
|
||||
} finally {}
|
||||
}
|
||||
|
||||
public void changeBrightness(float change) {
|
||||
public void changeBrightness(final float change) {
|
||||
setBrightness(brightness + change);
|
||||
}
|
||||
|
||||
public void setBrightness(float newval) {
|
||||
public void setBrightness(final float newval) {
|
||||
if (newval >= 0 && newval <= 1) {
|
||||
brightness = newval;
|
||||
monitor.setBrightness(brightness);
|
||||
}
|
||||
}
|
||||
|
||||
public void cycleBrightness(boolean reverse) {
|
||||
public void cycleBrightness(final boolean reverse) {
|
||||
final float step = reverse ? -0.1f : 0.1f;
|
||||
if (brightness + step > 1f) {
|
||||
if (brightness + step > 1f)
|
||||
setBrightness(0f);
|
||||
} else if (brightness + step <= 0f) {
|
||||
else if (brightness + step <= 0f)
|
||||
setBrightness(1.0f);
|
||||
} else {
|
||||
else
|
||||
changeBrightness(step);
|
||||
}
|
||||
}
|
||||
|
||||
public float getBrightness() {
|
||||
@ -451,7 +425,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
public Screen[] sessions = new Screen[5];
|
||||
|
||||
@Deprecated
|
||||
public void colore(float f1, float f2, float f3, float f4) {
|
||||
public void colore(final float f1, final float f2, final float f3, final float f4) {
|
||||
renderer.glColor4f(f1, f2, f3, f4);
|
||||
}
|
||||
|
||||
@ -460,7 +434,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void drawSkinPart(int x, int y, int uvX, int uvY, int uvX2, int uvY2) {
|
||||
public void drawSkinPart(final int x, final int y, final int uvX, final int uvY, final int uvX2, final int uvY2) {
|
||||
renderer.glFillRect(x, y, uvX2 - uvX, uvY2 - uvY, uvX, uvY, uvX2 - uvX, uvY2 - uvY);
|
||||
}
|
||||
|
||||
|
@ -10,17 +10,17 @@ public class GUIErrorMessage {
|
||||
private final String err;
|
||||
private final long creationTime;
|
||||
|
||||
public GUIErrorMessage(Error e) {
|
||||
public GUIErrorMessage(final Error e) {
|
||||
err = e.getLocalizedMessage();
|
||||
creationTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public GUIErrorMessage(Exception ex) {
|
||||
public GUIErrorMessage(final Exception ex) {
|
||||
err = ex.getLocalizedMessage();
|
||||
creationTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void draw(GraphicEngine g, Renderer r, String msg) {
|
||||
public void draw(final GraphicEngine g, final Renderer r, final String msg) {
|
||||
final int scrW = g.getWidth();
|
||||
final int scrH = g.getHeight();
|
||||
final int width = 200;
|
||||
|
@ -1,20 +1,20 @@
|
||||
package it.cavallium.warppi.gui;
|
||||
|
||||
public class GraphicUtils {
|
||||
public static final float sin(float rad) {
|
||||
return sin[(int) (rad * radToIndex) & SIN_MASK];
|
||||
public static final float sin(final float rad) {
|
||||
return GraphicUtils.sin[(int) (rad * GraphicUtils.radToIndex) & GraphicUtils.SIN_MASK];
|
||||
}
|
||||
|
||||
public static final float cos(float rad) {
|
||||
return cos[(int) (rad * radToIndex) & SIN_MASK];
|
||||
public static final float cos(final float rad) {
|
||||
return GraphicUtils.cos[(int) (rad * GraphicUtils.radToIndex) & GraphicUtils.SIN_MASK];
|
||||
}
|
||||
|
||||
public static final float sinDeg(float deg) {
|
||||
return sin[(int) (deg * degToIndex) & SIN_MASK];
|
||||
public static final float sinDeg(final float deg) {
|
||||
return GraphicUtils.sin[(int) (deg * GraphicUtils.degToIndex) & GraphicUtils.SIN_MASK];
|
||||
}
|
||||
|
||||
public static final float cosDeg(float deg) {
|
||||
return cos[(int) (deg * degToIndex) & SIN_MASK];
|
||||
public static final float cosDeg(final float deg) {
|
||||
return GraphicUtils.cos[(int) (deg * GraphicUtils.degToIndex) & GraphicUtils.SIN_MASK];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -36,26 +36,26 @@ public class GraphicUtils {
|
||||
DEG = 180.0f / (float) Math.PI;
|
||||
|
||||
SIN_BITS = 8;
|
||||
SIN_MASK = ~(-1 << SIN_BITS);
|
||||
SIN_COUNT = SIN_MASK + 1;
|
||||
SIN_MASK = ~(-1 << GraphicUtils.SIN_BITS);
|
||||
SIN_COUNT = GraphicUtils.SIN_MASK + 1;
|
||||
|
||||
radFull = (float) (Math.PI * 2.0);
|
||||
degFull = (float) (360.0);
|
||||
radToIndex = SIN_COUNT / radFull;
|
||||
degToIndex = SIN_COUNT / degFull;
|
||||
degFull = (float) 360.0;
|
||||
radToIndex = GraphicUtils.SIN_COUNT / GraphicUtils.radFull;
|
||||
degToIndex = GraphicUtils.SIN_COUNT / GraphicUtils.degFull;
|
||||
|
||||
sin = new float[SIN_COUNT];
|
||||
cos = new float[SIN_COUNT];
|
||||
sin = new float[GraphicUtils.SIN_COUNT];
|
||||
cos = new float[GraphicUtils.SIN_COUNT];
|
||||
|
||||
for (int i = 0; i < SIN_COUNT; i++) {
|
||||
sin[i] = (float) Math.sin((i + 0.5f) / SIN_COUNT * radFull);
|
||||
cos[i] = (float) Math.cos((i + 0.5f) / SIN_COUNT * radFull);
|
||||
for (int i = 0; i < GraphicUtils.SIN_COUNT; i++) {
|
||||
GraphicUtils.sin[i] = (float) Math.sin((i + 0.5f) / GraphicUtils.SIN_COUNT * GraphicUtils.radFull);
|
||||
GraphicUtils.cos[i] = (float) Math.cos((i + 0.5f) / GraphicUtils.SIN_COUNT * GraphicUtils.radFull);
|
||||
}
|
||||
|
||||
// Four cardinal directions (credits: Nate)
|
||||
for (int i = 0; i < 360; i += 90) {
|
||||
sin[(int) (i * degToIndex) & SIN_MASK] = (float) Math.sin(i * Math.PI / 180.0);
|
||||
cos[(int) (i * degToIndex) & SIN_MASK] = (float) Math.cos(i * Math.PI / 180.0);
|
||||
GraphicUtils.sin[(int) (i * GraphicUtils.degToIndex) & GraphicUtils.SIN_MASK] = (float) Math.sin(i * Math.PI / 180.0);
|
||||
GraphicUtils.cos[(int) (i * GraphicUtils.degToIndex) & GraphicUtils.SIN_MASK] = (float) Math.cos(i * Math.PI / 180.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,24 +7,24 @@ public interface GraphicalElement {
|
||||
* <strong>height</strong>, <strong>line</strong> or
|
||||
* <strong>length</strong>.
|
||||
*/
|
||||
public void recomputeDimensions();
|
||||
void recomputeDimensions();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Width of the element.
|
||||
*/
|
||||
public int getWidth();
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Height of the element.
|
||||
*/
|
||||
public int getHeight();
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Position of the vertical alignment line of the element, relative
|
||||
* to itself.
|
||||
*/
|
||||
public int getLine();
|
||||
int getLine();
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package it.cavallium.warppi.gui;
|
||||
|
||||
public interface GraphicalInterface {
|
||||
public void create() throws InterruptedException;
|
||||
void create() throws InterruptedException;
|
||||
|
||||
public void initialize() throws InterruptedException;
|
||||
void initialize() throws InterruptedException;
|
||||
|
||||
public void render();
|
||||
void render();
|
||||
|
||||
public void renderTopmost();
|
||||
void renderTopmost();
|
||||
|
||||
public void beforeRender(float dt);
|
||||
void beforeRender(float dt);
|
||||
|
||||
public boolean mustBeRefreshed();
|
||||
boolean mustBeRefreshed();
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package it.cavallium.warppi.gui;
|
||||
|
||||
public interface HardwareDisplay {
|
||||
public void initialize();
|
||||
void initialize();
|
||||
|
||||
public void shutdown();
|
||||
void shutdown();
|
||||
|
||||
public void setBrightness(double value);
|
||||
void setBrightness(double value);
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ public class Caret {
|
||||
private final int[] lastSize;
|
||||
private final int[] lastLocation;
|
||||
|
||||
public Caret(CaretState state, int pos) {
|
||||
public Caret(final CaretState state, final int pos) {
|
||||
this(state, pos, new int[] { 0, 0 }, new int[] { 2, 5 });
|
||||
}
|
||||
|
||||
public Caret(CaretState state, int pos, int[] lastLocation, int[] lastSize) {
|
||||
public Caret(final CaretState state, final int pos, final int[] lastLocation, final int[] lastSize) {
|
||||
this.state = state;
|
||||
this.pos = pos;
|
||||
remaining = pos;
|
||||
@ -20,7 +20,7 @@ public class Caret {
|
||||
this.lastSize = lastSize;
|
||||
}
|
||||
|
||||
public void skip(int i) {
|
||||
public void skip(final int i) {
|
||||
remaining -= i;
|
||||
}
|
||||
|
||||
@ -37,20 +37,18 @@ public class Caret {
|
||||
}
|
||||
|
||||
public void flipState() {
|
||||
if (state == CaretState.VISIBLE_ON) {
|
||||
if (state == CaretState.VISIBLE_ON)
|
||||
state = CaretState.VISIBLE_OFF;
|
||||
} else if (state == CaretState.VISIBLE_OFF) {
|
||||
else if (state == CaretState.VISIBLE_OFF)
|
||||
state = CaretState.VISIBLE_ON;
|
||||
}
|
||||
}
|
||||
|
||||
public void turnOn() {
|
||||
if (state == CaretState.VISIBLE_OFF) {
|
||||
if (state == CaretState.VISIBLE_OFF)
|
||||
state = CaretState.VISIBLE_ON;
|
||||
}
|
||||
}
|
||||
|
||||
public void setPosition(int i) {
|
||||
public void setPosition(final int i) {
|
||||
pos = i;
|
||||
}
|
||||
|
||||
@ -58,7 +56,7 @@ public class Caret {
|
||||
remaining = pos;
|
||||
}
|
||||
|
||||
public void setLastLocation(int x, int y) {
|
||||
public void setLastLocation(final int x, final int y) {
|
||||
lastLocation[0] = x;
|
||||
lastLocation[1] = y;
|
||||
}
|
||||
@ -67,7 +65,7 @@ public class Caret {
|
||||
return new int[] { lastLocation[0], lastLocation[1] };
|
||||
}
|
||||
|
||||
public void setLastSize(int w, int h) {
|
||||
public void setLastSize(final int w, final int h) {
|
||||
lastSize[0] = w;
|
||||
lastSize[1] = h;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public abstract class ExtraMenu<T extends Block> implements Serializable, Keyboa
|
||||
|
||||
private static final long serialVersionUID = -6944683477814944299L;
|
||||
|
||||
public ExtraMenu(T block) {
|
||||
public ExtraMenu(final T block) {
|
||||
this.block = block;
|
||||
this.location = new int[] { 0, 0 };
|
||||
this.width = 0;
|
||||
@ -29,7 +29,7 @@ public abstract class ExtraMenu<T extends Block> implements Serializable, Keyboa
|
||||
|
||||
public abstract void close();
|
||||
|
||||
public boolean beforeRender(float delta, Caret caret) {
|
||||
public boolean beforeRender(final float delta, final Caret caret) {
|
||||
final int[] l = caret.getLastLocation();
|
||||
final int[] cs = caret.getLastSize();
|
||||
location[0] = l[0] - block.getWidth() / 2 - width / 2;
|
||||
|
@ -16,7 +16,7 @@ public class InputContext {
|
||||
variableTypes.put(MathematicalSymbols.EULER_NUMBER, V_TYPE.CONSTANT);
|
||||
}
|
||||
|
||||
public InputContext(HashMap<Character, V_TYPE> variableTypes) {
|
||||
public InputContext(final HashMap<Character, V_TYPE> variableTypes) {
|
||||
this.variableTypes = variableTypes;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public abstract class Block implements GraphicalElement {
|
||||
protected int line;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param r
|
||||
* Graphic Renderer class.
|
||||
* @param x
|
||||
@ -53,7 +53,7 @@ public abstract class Block implements GraphicalElement {
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
public int getCaretDeltaPositionAfterCreation() {
|
||||
return 1;
|
||||
}
|
||||
|
@ -11,30 +11,30 @@ public class BlockChar extends Block {
|
||||
|
||||
private final char ch;
|
||||
|
||||
public BlockChar(char ch) {
|
||||
public BlockChar(final char ch) {
|
||||
this.ch = ch;
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
r.glDrawCharLeft(x, y, ch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class BlockChar extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
recomputeDimensions();
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class BlockChar extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) {
|
||||
public Feature toFeature(final MathContext context) {
|
||||
return new FeatureChar(getChar());
|
||||
}
|
||||
|
||||
|
@ -34,83 +34,78 @@ public class BlockContainer implements GraphicalElement {
|
||||
autoMinimums = true;
|
||||
}
|
||||
|
||||
public BlockContainer(boolean small) {
|
||||
public BlockContainer(final boolean small) {
|
||||
this(small, BlockContainer.getDefaultCharWidth(small), BlockContainer.getDefaultCharHeight(small), true);
|
||||
autoMinimums = true;
|
||||
}
|
||||
|
||||
public BlockContainer(boolean small, ObjectArrayList<Block> content) {
|
||||
public BlockContainer(final boolean small, final ObjectArrayList<Block> content) {
|
||||
this(small, BlockContainer.getDefaultCharWidth(small), BlockContainer.getDefaultCharHeight(small), content, true);
|
||||
autoMinimums = true;
|
||||
}
|
||||
|
||||
public BlockContainer(boolean small, boolean withBorder) {
|
||||
public BlockContainer(final boolean small, final boolean withBorder) {
|
||||
this(small, BlockContainer.getDefaultCharWidth(small), BlockContainer.getDefaultCharHeight(small), withBorder);
|
||||
autoMinimums = true;
|
||||
}
|
||||
|
||||
public BlockContainer(boolean small, int minWidth, int minHeight, boolean withBorder) {
|
||||
public BlockContainer(final boolean small, final int minWidth, final int minHeight, final boolean withBorder) {
|
||||
this(small, minWidth, minHeight, new ObjectArrayList<>(), withBorder);
|
||||
autoMinimums = false;
|
||||
}
|
||||
|
||||
public BlockContainer(boolean small, int minWidth, int minHeight, ObjectArrayList<Block> content, boolean withBorder) {
|
||||
public BlockContainer(final boolean small, final int minWidth, final int minHeight, final ObjectArrayList<Block> content, final boolean withBorder) {
|
||||
this.small = small;
|
||||
this.minWidth = minWidth;
|
||||
this.minHeight = minHeight;
|
||||
this.withBorder = withBorder;
|
||||
for (final Block b : content) {
|
||||
if (b.isSmall() != small) {
|
||||
for (final Block b : content)
|
||||
if (b.isSmall() != small)
|
||||
b.setSmall(small);
|
||||
}
|
||||
}
|
||||
this.content = content;
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public void addBlock(int position, Block b) {
|
||||
public void addBlock(final int position, final Block b) {
|
||||
addBlockUnsafe(position, b);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public void addBlockUnsafe(int position, Block b) {
|
||||
if (b.isSmall() != small) {
|
||||
public void addBlockUnsafe(final int position, final Block b) {
|
||||
if (b.isSmall() != small)
|
||||
b.setSmall(small);
|
||||
}
|
||||
if (position >= content.size()) {
|
||||
if (position >= content.size())
|
||||
content.add(b);
|
||||
} else {
|
||||
else
|
||||
content.add(position, b);
|
||||
}
|
||||
}
|
||||
|
||||
public void appendBlock(Block b) {
|
||||
public void appendBlock(final Block b) {
|
||||
appendBlockUnsafe(b);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public void appendBlockUnsafe(Block b) {
|
||||
if (b.isSmall() != small) {
|
||||
public void appendBlockUnsafe(final Block b) {
|
||||
if (b.isSmall() != small)
|
||||
b.setSmall(small);
|
||||
}
|
||||
content.add(b);
|
||||
}
|
||||
|
||||
public void removeBlock(Block b) {
|
||||
public void removeBlock(final Block b) {
|
||||
removeBlockUnsafe(b);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public void removeBlockUnsafe(Block b) {
|
||||
public void removeBlockUnsafe(final Block b) {
|
||||
content.remove(b);
|
||||
}
|
||||
|
||||
public void removeAt(int i) {
|
||||
public void removeAt(final int i) {
|
||||
content.remove(i);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public BlockReference<?> getBlockAt(int i) {
|
||||
public BlockReference<?> getBlockAt(final int i) {
|
||||
final Block b = content.get(i);
|
||||
return new BlockReference<>(b, i, this);
|
||||
}
|
||||
@ -125,7 +120,7 @@ public class BlockContainer implements GraphicalElement {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param ge
|
||||
* Graphic Engine class.
|
||||
* @param r
|
||||
@ -137,16 +132,14 @@ public class BlockContainer implements GraphicalElement {
|
||||
* @param caret
|
||||
* Position of the caret.
|
||||
*/
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
int paddingX = 1;
|
||||
|
||||
if (caret.getRemaining() == 0) {
|
||||
if (content.size() > 0) {
|
||||
if (caret.getRemaining() == 0)
|
||||
if (content.size() > 0)
|
||||
BlockContainer.drawCaret(ge, r, caret, small, x, y + line - content.get(0).line, content.get(0).height);
|
||||
} else {
|
||||
else
|
||||
BlockContainer.drawCaret(ge, r, caret, small, x, y, height);
|
||||
}
|
||||
}
|
||||
|
||||
if (withBorder && content.size() == 0) {
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
@ -154,21 +147,19 @@ public class BlockContainer implements GraphicalElement {
|
||||
r.glDrawLine(x + paddingX, y, x + paddingX, y + height - 1);
|
||||
r.glDrawLine(x + paddingX + width - 1, y, x + paddingX + width - 1, y + height - 1);
|
||||
r.glDrawLine(x + paddingX, y + height - 1, x + paddingX + width - 1, y + height - 1);
|
||||
} else {
|
||||
} else
|
||||
for (final Block b : content) {
|
||||
caret.skip(1);
|
||||
b.draw(ge, r, x + paddingX, y + line - b.line, caret);
|
||||
paddingX += b.getWidth();
|
||||
if (caret.getRemaining() == 0) {
|
||||
if (caret.getRemaining() == 0)
|
||||
BlockContainer.drawCaret(ge, r, caret, small, x + paddingX, y + line - b.line, b.height);
|
||||
}
|
||||
paddingX += 1;
|
||||
}
|
||||
}
|
||||
caret.skip(1);
|
||||
}
|
||||
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
|
||||
if (caret.getRemaining() == 0) {
|
||||
@ -187,13 +178,12 @@ public class BlockContainer implements GraphicalElement {
|
||||
}
|
||||
}
|
||||
caret.skip(1);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
|
||||
int pos = 0;
|
||||
@ -202,20 +192,19 @@ public class BlockContainer implements GraphicalElement {
|
||||
pos++;
|
||||
final int deltaCaret = caret.getRemaining();
|
||||
removed = removed | b.delBlock(caret);
|
||||
if (caret.getRemaining() == 0 || (removed == false && deltaCaret >= 0 && caret.getRemaining() < 0)) {
|
||||
if (caret.getRemaining() == 0 || removed == false && deltaCaret >= 0 && caret.getRemaining() < 0) {
|
||||
removeAt(pos - 1);
|
||||
caret.setPosition(caret.getPosition() - deltaCaret);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
caret.skip(1);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
BlockReference<?> block = null;
|
||||
|
||||
int pos = 0;
|
||||
@ -225,10 +214,9 @@ public class BlockContainer implements GraphicalElement {
|
||||
final int deltaCaret = caret.getRemaining();
|
||||
|
||||
block = b.getBlock(caret);
|
||||
if (block != null) {
|
||||
if (block != null)
|
||||
return block;
|
||||
}
|
||||
if (caret.getRemaining() == 0 || (deltaCaret >= 0 && caret.getRemaining() < 0)) {
|
||||
if (caret.getRemaining() == 0 || deltaCaret >= 0 && caret.getRemaining() < 0) {
|
||||
block = getBlockAt(pos - 1);
|
||||
return block;
|
||||
}
|
||||
@ -249,29 +237,25 @@ public class BlockContainer implements GraphicalElement {
|
||||
final int bl = b.getLine();
|
||||
final int bh = b.getHeight();
|
||||
final int bh2 = bh - bl;
|
||||
if (bl > l) {
|
||||
if (bl > l)
|
||||
l = bl;
|
||||
}
|
||||
if (bh2 > h2) {
|
||||
if (bh2 > h2)
|
||||
h2 = bh2;
|
||||
}
|
||||
}
|
||||
|
||||
if (content.size() > 0) {
|
||||
if (content.size() > 0)
|
||||
w -= 1;
|
||||
}
|
||||
|
||||
h = h2 + l;
|
||||
|
||||
line = l;
|
||||
if (w > minWidth) {
|
||||
if (w > minWidth)
|
||||
width = w;
|
||||
} else {
|
||||
else
|
||||
width = minWidth;
|
||||
}
|
||||
if (h > minHeight) {
|
||||
if (h > minHeight)
|
||||
height = h;
|
||||
} else {
|
||||
else {
|
||||
height = minHeight;
|
||||
line = height / 2;
|
||||
}
|
||||
@ -296,53 +280,53 @@ public class BlockContainer implements GraphicalElement {
|
||||
private static final int[] defFontSizes = new int[4];
|
||||
private static final int defColor = 0xFF000000;
|
||||
|
||||
public static void initializeFonts(BinaryFont big, BinaryFont small) {
|
||||
defFonts[0] = big;
|
||||
defFonts[1] = small;
|
||||
defFontSizes[0] = big.getCharacterWidth();
|
||||
defFontSizes[1] = big.getCharacterHeight();
|
||||
defFontSizes[2] = small.getCharacterWidth();
|
||||
defFontSizes[3] = small.getCharacterHeight();
|
||||
initialized = true;
|
||||
public static void initializeFonts(final BinaryFont big, final BinaryFont small) {
|
||||
BlockContainer.defFonts[0] = big;
|
||||
BlockContainer.defFonts[1] = small;
|
||||
BlockContainer.defFontSizes[0] = big.getCharacterWidth();
|
||||
BlockContainer.defFontSizes[1] = big.getCharacterHeight();
|
||||
BlockContainer.defFontSizes[2] = small.getCharacterWidth();
|
||||
BlockContainer.defFontSizes[3] = small.getCharacterHeight();
|
||||
BlockContainer.initialized = true;
|
||||
}
|
||||
|
||||
public static BinaryFont getDefaultFont(boolean small) {
|
||||
checkInitialized();
|
||||
return defFonts[small ? 1 : 0];
|
||||
public static BinaryFont getDefaultFont(final boolean small) {
|
||||
BlockContainer.checkInitialized();
|
||||
return BlockContainer.defFonts[small ? 1 : 0];
|
||||
}
|
||||
|
||||
public static int getDefaultColor() {
|
||||
return defColor;
|
||||
return BlockContainer.defColor;
|
||||
}
|
||||
|
||||
public static int getDefaultCharWidth(boolean b) {
|
||||
checkInitialized();
|
||||
return defFontSizes[b ? 2 : 0];
|
||||
public static int getDefaultCharWidth(final boolean b) {
|
||||
BlockContainer.checkInitialized();
|
||||
return BlockContainer.defFontSizes[b ? 2 : 0];
|
||||
}
|
||||
|
||||
public static int getDefaultCharHeight(boolean b) {
|
||||
checkInitialized();
|
||||
return defFontSizes[b ? 3 : 1];
|
||||
public static int getDefaultCharHeight(final boolean b) {
|
||||
BlockContainer.checkInitialized();
|
||||
return BlockContainer.defFontSizes[b ? 3 : 1];
|
||||
}
|
||||
|
||||
public static void drawCaret(GraphicEngine ge, Renderer r, Caret caret, boolean small, int x, int y, int height) {
|
||||
public static void drawCaret(final GraphicEngine ge, final Renderer r, final Caret caret, final boolean small,
|
||||
final int x, final int y, final int height) {
|
||||
if (caret.getState() == CaretState.VISIBLE_ON) {
|
||||
r.glColor(getDefaultColor());
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
r.glFillColor(x, y, small ? 2 : 3, height);
|
||||
caret.setLastLocation(x, y);
|
||||
caret.setLastSize(small ? 2 : 3, height);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
if (autoMinimums) {
|
||||
minWidth = BlockContainer.getDefaultCharWidth(small);
|
||||
minHeight = BlockContainer.getDefaultCharHeight(small);
|
||||
}
|
||||
for (final Block b : content) {
|
||||
for (final Block b : content)
|
||||
b.setSmall(small);
|
||||
}
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
@ -351,28 +335,25 @@ public class BlockContainer implements GraphicalElement {
|
||||
}
|
||||
|
||||
private static void checkInitialized() {
|
||||
if (!initialized) {
|
||||
if (!BlockContainer.initialized)
|
||||
Engine.getPlatform().throwNewExceptionInInitializerError("Please initialize BlockContainer by running the method BlockContainer.initialize(...) first!");
|
||||
}
|
||||
}
|
||||
|
||||
public int computeCaretMaxBound() {
|
||||
int maxpos = 0;
|
||||
for (final Block b : content) {
|
||||
for (final Block b : content)
|
||||
maxpos += 1 + b.computeCaretMaxBound();
|
||||
}
|
||||
return maxpos + 1;
|
||||
}
|
||||
|
||||
public Function toFunction(MathContext context) throws Error {
|
||||
public Function toFunction(final MathContext context) throws Error {
|
||||
final ObjectArrayList<Block> blocks = getContent();
|
||||
final ObjectArrayList<Feature> blockFeatures = new ObjectArrayList<>();
|
||||
|
||||
for (final Block block : blocks) {
|
||||
final Feature blockFeature = block.toFeature(context);
|
||||
if (blockFeature == null) {
|
||||
if (blockFeature == null)
|
||||
throw new Error(Errors.NOT_IMPLEMENTED, "The block " + block.getClass().getSimpleName() + " isn't a known Block");
|
||||
}
|
||||
blockFeatures.add(blockFeature);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class BlockDivision extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
containerUp.draw(ge, r, x + 1 + paddingLeftUpper, y, caret);
|
||||
@ -35,34 +35,31 @@ public class BlockDivision extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerUp.putBlock(caret, newBlock);
|
||||
added = added | containerDown.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerUp.delBlock(caret);
|
||||
removed = removed | containerDown.delBlock(caret);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
BlockReference<?> bl = null;
|
||||
bl = containerUp.getBlock(caret);
|
||||
if (bl != null) {
|
||||
if (bl != null)
|
||||
return bl;
|
||||
}
|
||||
bl = containerDown.getBlock(caret);
|
||||
return bl;
|
||||
}
|
||||
@ -92,7 +89,7 @@ public class BlockDivision extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
containerUp.setSmall(small);
|
||||
containerDown.setSmall(small);
|
||||
@ -113,7 +110,7 @@ public class BlockDivision extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function upper = getUpperContainer().toFunction(context);
|
||||
final Function lower = getLowerContainer().toFunction(context);
|
||||
return new FeatureDivision(upper, lower);
|
||||
|
@ -9,7 +9,7 @@ public class BlockExponentialNotation extends BlockPower {
|
||||
private int bh;
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
r.glDrawStringLeft(x, y + height - bh, "ℯ℮");
|
||||
|
@ -33,19 +33,18 @@ public class BlockLogarithm extends Block {
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public BlockLogarithm(ObjectArrayList<Block> blocks) {
|
||||
public BlockLogarithm(final ObjectArrayList<Block> blocks) {
|
||||
containerBase = new BlockContainer(true);
|
||||
containerNumber = new BlockContainer(false, blocks);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
if (prefix != null) {
|
||||
if (prefix != null)
|
||||
r.glDrawStringLeft(x + 1, y + line - chh / 2, prefix);
|
||||
}
|
||||
r.glDrawCharLeft(x + bw + prw, y + toph, '╭');
|
||||
r.glDrawCharLeft(x + bw + prw, y + toph + nmbh - chh, '╰');
|
||||
if (small) {
|
||||
@ -64,45 +63,41 @@ public class BlockLogarithm extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerBase.putBlock(caret, newBlock);
|
||||
added = added | containerNumber.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerBase.delBlock(caret);
|
||||
removed = removed | containerNumber.delBlock(caret);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
BlockReference<?> bl = null;
|
||||
bl = containerBase.getBlock(caret);
|
||||
if (bl != null) {
|
||||
if (bl != null)
|
||||
return bl;
|
||||
}
|
||||
bl = containerNumber.getBlock(caret);
|
||||
return bl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recomputeDimensions() {
|
||||
if (prefix == null) {
|
||||
if (prefix == null)
|
||||
prw = 0;
|
||||
} else {
|
||||
else
|
||||
prw = 1 + BlockContainer.getDefaultCharWidth(small) * prefix.length();
|
||||
}
|
||||
bw = containerBase.getWidth();
|
||||
bh = containerBase.getHeight();
|
||||
bl = containerBase.getLine();
|
||||
@ -115,25 +110,23 @@ public class BlockLogarithm extends Block {
|
||||
if (bl > nmbh) {
|
||||
toph = bl - nmbh;
|
||||
line = toph + nl;
|
||||
if (bl + (bh - bl) > toph + nmbh) {
|
||||
height = bl + (bh - bl);
|
||||
} else {
|
||||
if (bl + bh - bl > toph + nmbh)
|
||||
height = bl + bh - bl;
|
||||
else
|
||||
height = toph + nmbh;
|
||||
}
|
||||
} else {
|
||||
System.out.println("b");
|
||||
toph = 0;
|
||||
line = toph + nl;
|
||||
if (nmbh + bh - bl > toph + nmbh) {
|
||||
height = nmbh + (bh - bl);
|
||||
} else {
|
||||
if (nmbh + bh - bl > toph + nmbh)
|
||||
height = nmbh + bh - bl;
|
||||
else
|
||||
height = toph + nmbh;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
containerBase.setSmall(small);
|
||||
containerNumber.setSmall(small);
|
||||
@ -154,7 +147,7 @@ public class BlockLogarithm extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function base = getBaseContainer().toFunction(context);
|
||||
final Function number = getNumberContainer().toFunction(context);
|
||||
return new FeatureLogarithm(base, number);
|
||||
|
@ -2,7 +2,7 @@ package it.cavallium.warppi.gui.expression.blocks;
|
||||
|
||||
public class BlockNumericChar extends BlockChar {
|
||||
|
||||
public BlockNumericChar(char ch) {
|
||||
public BlockNumericChar(final char ch) {
|
||||
super(ch);
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,12 @@ public class BlockParenthesis extends BlockParenthesisAbstract {
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockParenthesis(ObjectArrayList<Block> blocks) {
|
||||
public BlockParenthesis(final ObjectArrayList<Block> blocks) {
|
||||
super(blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function cont = getNumberContainer().toFunction(context);
|
||||
return new FeatureParenthesis(cont);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public abstract class BlockParenthesisAbstract extends Block {
|
||||
private int chw;
|
||||
private int chh;
|
||||
|
||||
protected BlockParenthesisAbstract(String prefix) {
|
||||
protected BlockParenthesisAbstract(final String prefix) {
|
||||
containerNumber = new BlockContainer(false);
|
||||
this.prefix = prefix;
|
||||
|
||||
@ -30,19 +30,18 @@ public abstract class BlockParenthesisAbstract extends Block {
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public BlockParenthesisAbstract(ObjectArrayList<Block> blocks) {
|
||||
public BlockParenthesisAbstract(final ObjectArrayList<Block> blocks) {
|
||||
containerNumber = new BlockContainer(false, blocks);
|
||||
prefix = null;
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
if (prefix != null) {
|
||||
if (prefix != null)
|
||||
r.glDrawStringLeft(x + 1, y + line - chh / 2, prefix);
|
||||
}
|
||||
r.glDrawCharLeft(x + prw, y, '╭');
|
||||
r.glDrawCharLeft(x + prw, y + height - chh, '╰');
|
||||
if (small) {
|
||||
@ -58,37 +57,34 @@ public abstract class BlockParenthesisAbstract extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerNumber.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerNumber.delBlock(caret);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return containerNumber.getBlock(caret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recomputeDimensions() {
|
||||
if (prefix == null) {
|
||||
if (prefix == null)
|
||||
prw = 0;
|
||||
} else {
|
||||
else
|
||||
prw = 1 + BlockContainer.getDefaultCharWidth(small) * prefix.length() + 2;
|
||||
}
|
||||
chw = BlockContainer.getDefaultCharWidth(small);
|
||||
chh = BlockContainer.getDefaultCharHeight(small);
|
||||
width = prw + chw + containerNumber.getWidth() + chw + 3;
|
||||
@ -97,7 +93,7 @@ public abstract class BlockParenthesisAbstract extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
containerNumber.setSmall(small);
|
||||
recomputeDimensions();
|
||||
|
@ -19,34 +19,32 @@ public class BlockPower extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(true).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
containerExponent.draw(ge, r, x, y, caret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerExponent.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerExponent.delBlock(caret);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return containerExponent.getBlock(caret);
|
||||
}
|
||||
|
||||
@ -60,7 +58,7 @@ public class BlockPower extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
containerExponent.setSmall(true);
|
||||
recomputeDimensions();
|
||||
@ -76,7 +74,7 @@ public class BlockPower extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function exp = getExponentContainer().toFunction(context);
|
||||
return new FeaturePowerChar(exp);
|
||||
}
|
||||
|
@ -18,41 +18,39 @@ public class BlockPower2 extends Block {
|
||||
containerExponent.addBlock(0, new BlockNumericChar('2'));
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCaretDeltaPositionAfterCreation() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(true).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
containerExponent.draw(ge, r, x, y, caret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerExponent.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerExponent.delBlock(caret);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return containerExponent.getBlock(caret);
|
||||
}
|
||||
|
||||
@ -66,7 +64,7 @@ public class BlockPower2 extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
containerExponent.setSmall(true);
|
||||
recomputeDimensions();
|
||||
@ -82,7 +80,7 @@ public class BlockPower2 extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function exp = getExponentContainer().toFunction(context);
|
||||
return new FeaturePowerChar(exp);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ public class BlockReference<T extends Block> {
|
||||
private final BlockContainer container;
|
||||
private final int blockPosition;
|
||||
|
||||
public BlockReference(T block, int blockPosition, BlockContainer container) {
|
||||
public BlockReference(final T block, final int blockPosition, final BlockContainer container) {
|
||||
this.block = block;
|
||||
this.blockPosition = blockPosition;
|
||||
this.container = container;
|
||||
@ -39,14 +39,13 @@ public class BlockReference<T extends Block> {
|
||||
return isInsideBounds(this.blockPosition - 1);
|
||||
}
|
||||
|
||||
private BlockReference<?> getBlockAtSafe(int i) {
|
||||
if (isInsideBounds(i)) {
|
||||
private BlockReference<?> getBlockAtSafe(final int i) {
|
||||
if (isInsideBounds(i))
|
||||
return container.getBlockAt(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isInsideBounds(int i) {
|
||||
private boolean isInsideBounds(final int i) {
|
||||
return i < container.getSize() && i >= 0;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class BlockSine extends BlockParenthesisAbstract {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function cont = getNumberContainer().toFunction(context);
|
||||
return new FeatureSine(cont);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class BlockSquareRoot extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
r.glDrawLine(x, y + height - 10 + 1, x, y + height - 10 + 2); // /
|
||||
@ -36,27 +36,25 @@ public class BlockSquareRoot extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
boolean added = false;
|
||||
added = added | containerNumber.putBlock(caret, newBlock);
|
||||
if (added) {
|
||||
if (added)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
boolean removed = false;
|
||||
removed = removed | containerNumber.delBlock(caret);
|
||||
if (removed) {
|
||||
if (removed)
|
||||
recomputeDimensions();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return containerNumber.getBlock(caret);
|
||||
}
|
||||
|
||||
@ -70,12 +68,12 @@ public class BlockSquareRoot extends Block {
|
||||
line = 3 + l1;
|
||||
if (height < 9) {
|
||||
height = 9;
|
||||
line += (9 - (3 + h1));
|
||||
line += 9 - (3 + h1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
containerNumber.setSmall(small);
|
||||
recomputeDimensions();
|
||||
@ -91,7 +89,7 @@ public class BlockSquareRoot extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
final Function contnt = getNumberContainer().toFunction(context);
|
||||
return new FeatureSquareRoot(contnt);
|
||||
}
|
||||
|
@ -15,24 +15,24 @@ public class BlockUndefined extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
BlockContainer.getDefaultFont(small).use(ge);
|
||||
r.glColor(BlockContainer.getDefaultColor());
|
||||
r.glDrawStringLeft(x, y, "UNDEFINED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class BlockUndefined extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
recomputeDimensions();
|
||||
}
|
||||
@ -55,7 +55,7 @@ public class BlockUndefined extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) {
|
||||
public Feature toFeature(final MathContext context) {
|
||||
return new FeatureChar(MathematicalSymbols.UNDEFINED);
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,11 @@ public class BlockVariable extends Block {
|
||||
private BlockVariable typeDirtyID;
|
||||
private final boolean typeLocked;
|
||||
|
||||
public BlockVariable(InputContext ic, char ch) {
|
||||
public BlockVariable(final InputContext ic, final char ch) {
|
||||
this(ic, ch, false);
|
||||
}
|
||||
|
||||
public BlockVariable(InputContext ic, char ch, boolean typeLocked) {
|
||||
public BlockVariable(final InputContext ic, final char ch, final boolean typeLocked) {
|
||||
this.ic = ic;
|
||||
this.ch = ch;
|
||||
type = V_TYPE.VARIABLE;
|
||||
@ -44,13 +44,11 @@ public class BlockVariable extends Block {
|
||||
|
||||
private void retrieveValue() {
|
||||
type = ic.variableTypes.get(ch);
|
||||
if (type == null) {
|
||||
if (type == null)
|
||||
type = V_TYPE.VARIABLE;
|
||||
}
|
||||
typeDirtyID = ic.variableTypeDirtyID;
|
||||
if (menu != null) {
|
||||
if (menu != null)
|
||||
menu.mustRefreshMenu = true;
|
||||
}
|
||||
mustRefresh = true;
|
||||
System.out.println("retrieve:" + type.toString());
|
||||
}
|
||||
@ -68,10 +66,9 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y, Caret caret) {
|
||||
if (ic.variableTypeDirtyID != typeDirtyID) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||
if (ic.variableTypeDirtyID != typeDirtyID)
|
||||
retrieveValue();
|
||||
}
|
||||
if (mustRefresh) {
|
||||
mustRefresh = false;
|
||||
switch (type) {
|
||||
@ -94,17 +91,17 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putBlock(Caret caret, Block newBlock) {
|
||||
public boolean putBlock(final Caret caret, final Block newBlock) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delBlock(Caret caret) {
|
||||
public boolean delBlock(final Caret caret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockReference<?> getBlock(Caret caret) {
|
||||
public BlockReference<?> getBlock(final Caret caret) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -116,7 +113,7 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
public void setSmall(final boolean small) {
|
||||
this.small = small;
|
||||
recomputeDimensions();
|
||||
}
|
||||
@ -140,7 +137,7 @@ public class BlockVariable extends Block {
|
||||
String text = "";
|
||||
boolean mustRefreshMenu = true;
|
||||
|
||||
public VariableMenu(BlockVariable var) {
|
||||
public VariableMenu(final BlockVariable var) {
|
||||
super(var);
|
||||
}
|
||||
|
||||
@ -155,7 +152,7 @@ public class BlockVariable extends Block {
|
||||
public void close() {}
|
||||
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyPressedEvent k) {
|
||||
public boolean onKeyPressed(final KeyPressedEvent k) {
|
||||
switch (k.getKey()) {
|
||||
case LEFT:
|
||||
case UP:
|
||||
@ -200,12 +197,12 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyReleased(KeyReleasedEvent k) {
|
||||
public boolean onKeyReleased(final KeyReleasedEvent k) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeRender(float delta, Caret caret) {
|
||||
public boolean beforeRender(final float delta, final Caret caret) {
|
||||
if (mustRefreshMenu) {
|
||||
mustRefreshMenu = false;
|
||||
text = block.type.toString();
|
||||
@ -220,24 +217,20 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GraphicEngine ge, Renderer r, Caret caret) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final Caret caret) {
|
||||
r.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(ge);
|
||||
int popupX = location[0];
|
||||
int popupY = location[1];
|
||||
if (popupX < 0) {
|
||||
if (popupX < 0)
|
||||
popupX = 0;
|
||||
}
|
||||
if (popupY < 0) {
|
||||
if (popupY < 0)
|
||||
popupY = 0;
|
||||
}
|
||||
final int[] screenSize = ge.getSize();
|
||||
if (popupX + width >= screenSize[0]) {
|
||||
if (popupX + width >= screenSize[0])
|
||||
popupX = screenSize[0] - width - 1;
|
||||
}
|
||||
if (popupY + height >= screenSize[1]) {
|
||||
if (popupY + height >= screenSize[1])
|
||||
popupY = screenSize[1] - height - 1;
|
||||
}
|
||||
r.glFillRect(location[0] + width / 2 - 5, popupY + 1, 10, 5, 163, 16, 10, 5);
|
||||
r.glFillColor(popupX, popupY + 5, width, height);
|
||||
r.glFillColor(popupX + 2, popupY + 4, width - 4, height + 2);
|
||||
@ -252,7 +245,7 @@ public class BlockVariable extends Block {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature toFeature(MathContext context) throws Error {
|
||||
public Feature toFeature(final MathContext context) throws Error {
|
||||
return new FeatureVariable(ch, type);
|
||||
}
|
||||
}
|
||||
|
@ -16,20 +16,20 @@ public class InlineInputContainer extends InputContainer {
|
||||
super();
|
||||
}
|
||||
|
||||
public InlineInputContainer(InputContext ic) {
|
||||
public InlineInputContainer(final InputContext ic) {
|
||||
super(ic);
|
||||
}
|
||||
|
||||
public InlineInputContainer(InputContext ic, boolean small) {
|
||||
public InlineInputContainer(final InputContext ic, final boolean small) {
|
||||
super(ic, small);
|
||||
}
|
||||
|
||||
public InlineInputContainer(InputContext ic, boolean small, int minWidth, int minHeight) {
|
||||
public InlineInputContainer(final InputContext ic, final boolean small, final int minWidth, final int minHeight) {
|
||||
super(ic, small, minWidth, minHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block parseChar(char c) {
|
||||
public Block parseChar(final char c) {
|
||||
return new BlockChar(c);
|
||||
}
|
||||
}
|
||||
|
@ -42,26 +42,26 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
this(new InputContext());
|
||||
}
|
||||
|
||||
public InputContainer(InputContext ic) {
|
||||
public InputContainer(final InputContext ic) {
|
||||
this(ic, false);
|
||||
}
|
||||
|
||||
public InputContainer(InputContext ic, boolean small) {
|
||||
public InputContainer(final InputContext ic, final boolean small) {
|
||||
this(ic, small, 0, 0);
|
||||
}
|
||||
|
||||
public InputContainer(InputContext ic, boolean small, int minWidth, int minHeight) {
|
||||
public InputContainer(final InputContext ic, final boolean small, final int minWidth, final int minHeight) {
|
||||
inputContext = ic;
|
||||
caret = new Caret(CaretState.VISIBLE_ON, 0);
|
||||
root = new BlockContainer(small, false);
|
||||
}
|
||||
|
||||
public void typeChar(char c) {
|
||||
public void typeChar(final char c) {
|
||||
final Block b = parseChar(c);
|
||||
typeBlock(b);
|
||||
}
|
||||
|
||||
public void typeBlock(Block b) {
|
||||
public void typeBlock(final Block b) {
|
||||
if (b != null) {
|
||||
caret.resetRemaining();
|
||||
if (root.putBlock(caret, b)) {
|
||||
@ -75,15 +75,14 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
closeExtra();
|
||||
}
|
||||
|
||||
public void typeChar(String c) {
|
||||
public void typeChar(final String c) {
|
||||
typeChar(c.charAt(0));
|
||||
}
|
||||
|
||||
public void del() {
|
||||
caret.resetRemaining();
|
||||
if (root.delBlock(caret)) {
|
||||
if (root.delBlock(caret))
|
||||
root.recomputeDimensions();
|
||||
}
|
||||
if (caret.getPosition() > 0) {
|
||||
caret.setPosition(caret.getPosition() - 1);
|
||||
maxPosition = root.computeCaretMaxBound();
|
||||
@ -101,11 +100,10 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
|
||||
public void moveLeft() {
|
||||
final int curPos = caret.getPosition();
|
||||
if (curPos > 0) {
|
||||
if (curPos > 0)
|
||||
caret.setPosition(curPos - 1);
|
||||
} else {
|
||||
else
|
||||
caret.setPosition(maxPosition - 1);
|
||||
}
|
||||
caret.turnOn();
|
||||
caretTime = 0;
|
||||
closeExtra();
|
||||
@ -113,11 +111,10 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
|
||||
public void moveRight() {
|
||||
final int curPos = caret.getPosition();
|
||||
if (curPos + 1 < maxPosition) {
|
||||
if (curPos + 1 < maxPosition)
|
||||
caret.setPosition(curPos + 1);
|
||||
} else {
|
||||
else
|
||||
caret.setPosition(0);
|
||||
}
|
||||
caret.turnOn();
|
||||
caretTime = 0;
|
||||
closeExtra();
|
||||
@ -144,31 +141,29 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param delta
|
||||
* Time, in seconds
|
||||
* @return true if something changed
|
||||
*/
|
||||
public boolean beforeRender(float delta) {
|
||||
public boolean beforeRender(final float delta) {
|
||||
boolean somethingChanged = false;
|
||||
caretTime += delta;
|
||||
if (caretTime >= CARET_DURATION) {
|
||||
while (caretTime >= CARET_DURATION) {
|
||||
caretTime -= CARET_DURATION;
|
||||
if (caretTime >= InputContainer.CARET_DURATION)
|
||||
while (caretTime >= InputContainer.CARET_DURATION) {
|
||||
caretTime -= InputContainer.CARET_DURATION;
|
||||
caret.flipState();
|
||||
somethingChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (extra != null) {
|
||||
if (extra != null)
|
||||
somethingChanged = somethingChanged | extra.beforeRender(delta, caret);
|
||||
}
|
||||
|
||||
return somethingChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param ge
|
||||
* Graphic Engine class.
|
||||
* @param r
|
||||
@ -178,12 +173,11 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
* @param y
|
||||
* Position relative to the window.
|
||||
*/
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y) {
|
||||
caret.resetRemaining();
|
||||
root.draw(ge, r, x, y, caret);
|
||||
if (extra != null) {
|
||||
if (extra != null)
|
||||
extra.draw(ge, r, caret);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
@ -201,16 +195,15 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
return maxPosition;
|
||||
}
|
||||
|
||||
public void setCaretPosition(int pos) {
|
||||
if (pos > 0 && pos < maxPosition) {
|
||||
public void setCaretPosition(final int pos) {
|
||||
if (pos > 0 && pos < maxPosition)
|
||||
caret.setPosition(pos);
|
||||
}
|
||||
caret.turnOn();
|
||||
caretTime = 0;
|
||||
closeExtra();
|
||||
}
|
||||
|
||||
public void setParsed(boolean parsed) {
|
||||
public void setParsed(final boolean parsed) {
|
||||
this.parsed = parsed;
|
||||
}
|
||||
|
||||
@ -220,7 +213,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
|
||||
/**
|
||||
* <strong>WARNING! DO NOT MODIFY THIS ARRAY!!!</strong>
|
||||
*
|
||||
*
|
||||
* @return an arraylist representing the content
|
||||
*/
|
||||
public ObjectArrayList<Block> getContent() {
|
||||
@ -232,9 +225,8 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
final BlockReference<?> selectedBlock = getSelectedBlock();
|
||||
if (selectedBlock != null) {
|
||||
extra = selectedBlock.get().getExtraMenu();
|
||||
if (extra != null) {
|
||||
if (extra != null)
|
||||
extra.open();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
extra.close();
|
||||
@ -257,7 +249,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
||||
return extra;
|
||||
}
|
||||
|
||||
public Function toFunction(MathContext context) throws Error {
|
||||
public Function toFunction(final MathContext context) throws Error {
|
||||
return root.toFunction(context);
|
||||
}
|
||||
|
||||
|
@ -28,20 +28,20 @@ public class NormalInputContainer extends InputContainer {
|
||||
super();
|
||||
}
|
||||
|
||||
public NormalInputContainer(InputContext ic) {
|
||||
public NormalInputContainer(final InputContext ic) {
|
||||
super(ic);
|
||||
}
|
||||
|
||||
public NormalInputContainer(InputContext ic, boolean small) {
|
||||
public NormalInputContainer(final InputContext ic, final boolean small) {
|
||||
super(ic, small);
|
||||
}
|
||||
|
||||
public NormalInputContainer(InputContext ic, boolean small, int minWidth, int minHeight) {
|
||||
public NormalInputContainer(final InputContext ic, final boolean small, final int minWidth, final int minHeight) {
|
||||
super(ic, small, minWidth, minHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block parseChar(char c) {
|
||||
public Block parseChar(final char c) {
|
||||
switch (c) {
|
||||
case MathematicalSymbols.DIVISION:
|
||||
return new BlockDivision();
|
||||
@ -81,17 +81,15 @@ public class NormalInputContainer extends InputContainer {
|
||||
case MathematicalSymbols.EULER_NUMBER:
|
||||
return new BlockVariable(inputContext, c, true);
|
||||
default:
|
||||
for (final char v : MathematicalSymbols.variables) {
|
||||
if (c == v) {
|
||||
for (final char v : MathematicalSymbols.variables)
|
||||
if (c == v)
|
||||
return new BlockVariable(inputContext, c);
|
||||
}
|
||||
}
|
||||
return new BlockChar(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void typeChar(char c) {
|
||||
public void typeChar(final char c) {
|
||||
super.typeChar(c);
|
||||
switch (c) {
|
||||
case MathematicalSymbols.PARENTHESIS_CLOSE:
|
||||
@ -106,18 +104,15 @@ public class NormalInputContainer extends InputContainer {
|
||||
int before = 0;
|
||||
while (true) {
|
||||
currentBlock = currentBlock.getPreviousBlock();
|
||||
if (currentBlock == null) {
|
||||
if (currentBlock == null)
|
||||
break;
|
||||
}
|
||||
final Block b = currentBlock.get();
|
||||
if (b instanceof BlockNumericChar || b instanceof BlockVariable) {
|
||||
if (!groupedBefore) {
|
||||
if (!groupedBefore)
|
||||
groupedBefore = true;
|
||||
}
|
||||
before++;
|
||||
} else {
|
||||
} else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (groupedBefore) {
|
||||
moveLeft();
|
||||
@ -129,9 +124,8 @@ public class NormalInputContainer extends InputContainer {
|
||||
moveLeft();
|
||||
moveLeft();
|
||||
}
|
||||
for (int i = 0; i < before + 1; i++) {
|
||||
for (int i = 0; i < before + 1; i++)
|
||||
moveRight();
|
||||
}
|
||||
moveRight();// Move to the divisor
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,11 @@ public class NormalOutputContainer extends OutputContainer {
|
||||
super();
|
||||
}
|
||||
|
||||
public NormalOutputContainer(boolean small) {
|
||||
public NormalOutputContainer(final boolean small) {
|
||||
super(small);
|
||||
}
|
||||
|
||||
public NormalOutputContainer(boolean small, int minWidth, int minHeight) {
|
||||
public NormalOutputContainer(final boolean small, final int minWidth, final int minHeight) {
|
||||
super(small, minWidth, minHeight);
|
||||
}
|
||||
}
|
||||
|
@ -22,39 +22,37 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
roots.add(new BlockContainer());
|
||||
}
|
||||
|
||||
public OutputContainer(boolean small) {
|
||||
public OutputContainer(final boolean small) {
|
||||
roots = new ObjectArrayList<>();
|
||||
roots.add(new BlockContainer(small));
|
||||
}
|
||||
|
||||
public OutputContainer(boolean small, int minWidth, int minHeight) {
|
||||
public OutputContainer(final boolean small, final int minWidth, final int minHeight) {
|
||||
roots = new ObjectArrayList<>();
|
||||
roots.add(new BlockContainer(small));
|
||||
}
|
||||
|
||||
public void setContentAsSingleGroup(ObjectArrayList<Block> blocks) {
|
||||
public void setContentAsSingleGroup(final ObjectArrayList<Block> blocks) {
|
||||
roots.clear();
|
||||
final BlockContainer bcnt = new BlockContainer();
|
||||
for (final Block block : blocks) {
|
||||
for (final Block block : blocks)
|
||||
bcnt.appendBlockUnsafe(block);
|
||||
}
|
||||
roots.add(bcnt);
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public void setContentAsMultipleGroups(ObjectArrayList<ObjectArrayList<Block>> roots) {
|
||||
public void setContentAsMultipleGroups(final ObjectArrayList<ObjectArrayList<Block>> roots) {
|
||||
this.roots.clear();
|
||||
for (final ObjectArrayList<Block> blocks : roots) {
|
||||
final BlockContainer bcnt = new BlockContainer();
|
||||
for (final Block block : blocks) {
|
||||
for (final Block block : blocks)
|
||||
bcnt.appendBlockUnsafe(block);
|
||||
}
|
||||
this.roots.add(bcnt);
|
||||
}
|
||||
recomputeDimensions();
|
||||
}
|
||||
|
||||
public void setContentAsMultipleElements(ObjectArrayList<Block> elems) {
|
||||
public void setContentAsMultipleElements(final ObjectArrayList<Block> elems) {
|
||||
roots.clear();
|
||||
for (final Block block : elems) {
|
||||
final BlockContainer bcnt = new BlockContainer();
|
||||
@ -66,9 +64,8 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
|
||||
@Override
|
||||
public void recomputeDimensions() {
|
||||
for (final BlockContainer root : roots) {
|
||||
for (final BlockContainer root : roots)
|
||||
root.recomputeDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,9 +73,8 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
int maxw = 0;
|
||||
for (final BlockContainer root : roots) {
|
||||
final int w = root.getWidth();
|
||||
if (w > maxw) {
|
||||
if (w > maxw)
|
||||
maxw = w;
|
||||
}
|
||||
}
|
||||
return maxw;
|
||||
}
|
||||
@ -86,14 +82,12 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
@Override
|
||||
public int getHeight() {
|
||||
int h = 0;
|
||||
for (final BlockContainer root : roots) {
|
||||
for (final BlockContainer root : roots)
|
||||
h += root.getHeight() + 2;
|
||||
}
|
||||
if (h > 0) {
|
||||
if (h > 0)
|
||||
return h - 2;
|
||||
} else {
|
||||
else
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,16 +96,16 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param delta
|
||||
* Time, in seconds
|
||||
*/
|
||||
public void beforeRender(double delta) {
|
||||
public void beforeRender(final double delta) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param ge
|
||||
* Graphic Engine class.
|
||||
* @param r
|
||||
@ -121,7 +115,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
* @param y
|
||||
* Position relative to the window.
|
||||
*/
|
||||
public void draw(GraphicEngine ge, Renderer r, int x, int y) {
|
||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y) {
|
||||
int offset = 0;
|
||||
for (final BlockContainer root : roots) {
|
||||
root.draw(ge, r, x, y + offset, caret);
|
||||
@ -138,9 +132,8 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
||||
public boolean isContentEmpty() {
|
||||
for (final BlockContainer root : roots) {
|
||||
final ObjectArrayList<Block> cnt = root.getContent();
|
||||
if (cnt != null && !cnt.isEmpty()) {
|
||||
if (cnt != null && !cnt.isEmpty())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ package it.cavallium.warppi.gui.expression.layouts;
|
||||
import it.cavallium.warppi.gui.expression.blocks.Block;
|
||||
|
||||
public interface InputLayout {
|
||||
public Block parseChar(char c);
|
||||
Block parseChar(char c);
|
||||
}
|
||||
|
@ -6,9 +6,9 @@ package it.cavallium.warppi.gui.graphicengine;
|
||||
*/
|
||||
public interface BinaryFont extends Skin {
|
||||
|
||||
public int getStringWidth(String text);
|
||||
int getStringWidth(String text);
|
||||
|
||||
public int getCharacterWidth();
|
||||
int getCharacterWidth();
|
||||
|
||||
public int getCharacterHeight();
|
||||
int getCharacterHeight();
|
||||
}
|
||||
|
@ -7,53 +7,53 @@ import it.cavallium.warppi.flow.Observable;
|
||||
|
||||
public interface GraphicEngine {
|
||||
|
||||
public int[] getSize();
|
||||
int[] getSize();
|
||||
|
||||
public boolean isInitialized();
|
||||
boolean isInitialized();
|
||||
|
||||
public void setTitle(String title);
|
||||
void setTitle(String title);
|
||||
|
||||
public void setResizable(boolean r);
|
||||
void setResizable(boolean r);
|
||||
|
||||
public void setDisplayMode(final int ww, final int wh);
|
||||
void setDisplayMode(final int ww, final int wh);
|
||||
|
||||
public default void create() {
|
||||
default void create() {
|
||||
create(null);
|
||||
};
|
||||
|
||||
public void create(Runnable object);
|
||||
void create(Runnable object);
|
||||
|
||||
public Observable<Integer[]> onResize();
|
||||
Observable<Integer[]> onResize();
|
||||
|
||||
public int getWidth();
|
||||
int getWidth();
|
||||
|
||||
public int getHeight();
|
||||
int getHeight();
|
||||
|
||||
public void destroy();
|
||||
void destroy();
|
||||
|
||||
public void start(RenderingLoop d);
|
||||
void start(RenderingLoop d);
|
||||
|
||||
public void repaint();
|
||||
void repaint();
|
||||
|
||||
public Renderer getRenderer();
|
||||
Renderer getRenderer();
|
||||
|
||||
public BinaryFont loadFont(String fontName) throws IOException;
|
||||
BinaryFont loadFont(String fontName) throws IOException;
|
||||
|
||||
public BinaryFont loadFont(String path, String fontName) throws IOException;
|
||||
BinaryFont loadFont(String path, String fontName) throws IOException;
|
||||
|
||||
public Skin loadSkin(String file) throws IOException;
|
||||
Skin loadSkin(String file) throws IOException;
|
||||
|
||||
public void waitForExit();
|
||||
void waitForExit();
|
||||
|
||||
public boolean isSupported();
|
||||
boolean isSupported();
|
||||
|
||||
public boolean doesRefreshPauses();
|
||||
boolean doesRefreshPauses();
|
||||
|
||||
public default boolean supportsFontRegistering() {
|
||||
default boolean supportsFontRegistering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public default List<BinaryFont> getRegisteredFonts() {
|
||||
default List<BinaryFont> getRegisteredFonts() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,45 @@
|
||||
package it.cavallium.warppi.gui.graphicengine;
|
||||
|
||||
public interface Renderer {
|
||||
public void glColor3i(int r, int gg, int b);
|
||||
void glColor3i(int r, int gg, int b);
|
||||
|
||||
public void glColor(int c);
|
||||
void glColor(int c);
|
||||
|
||||
public void glColor4i(int red, int green, int blue, int alpha);
|
||||
void glColor4i(int red, int green, int blue, int alpha);
|
||||
|
||||
public void glColor3f(float red, float green, float blue);
|
||||
void glColor3f(float red, float green, float blue);
|
||||
|
||||
public void glColor4f(float red, float green, float blue, float alpha);
|
||||
void glColor4f(float red, float green, float blue, float alpha);
|
||||
|
||||
public void glClearColor4i(int red, int green, int blue, int alpha);
|
||||
void glClearColor4i(int red, int green, int blue, int alpha);
|
||||
|
||||
public void glClearColor4f(float red, float green, float blue, float alpha);
|
||||
void glClearColor4f(float red, float green, float blue, float alpha);
|
||||
|
||||
public int glGetClearColor();
|
||||
int glGetClearColor();
|
||||
|
||||
public void glClearColor(int c);
|
||||
void glClearColor(int c);
|
||||
|
||||
public void glClear(int screenWidth, int screenHeight);
|
||||
void glClear(int screenWidth, int screenHeight);
|
||||
|
||||
public void glDrawLine(float x0, float y0, float x1, float y1);
|
||||
void glDrawLine(float x0, float y0, float x1, float y1);
|
||||
|
||||
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth,
|
||||
float uvHeight);
|
||||
void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, float uvHeight);
|
||||
|
||||
public void glFillColor(float x, float y, float width, float height);
|
||||
void glFillColor(float x, float y, float width, float height);
|
||||
|
||||
public void glDrawCharLeft(int x, int y, char ch);
|
||||
void glDrawCharLeft(int x, int y, char ch);
|
||||
|
||||
public void glDrawCharCenter(int x, int y, char ch);
|
||||
void glDrawCharCenter(int x, int y, char ch);
|
||||
|
||||
public void glDrawCharRight(int x, int y, char ch);
|
||||
void glDrawCharRight(int x, int y, char ch);
|
||||
|
||||
public void glDrawStringLeft(float x, float y, String text);
|
||||
void glDrawStringLeft(float x, float y, String text);
|
||||
|
||||
public void glDrawStringCenter(float x, float y, String text);
|
||||
void glDrawStringCenter(float x, float y, String text);
|
||||
|
||||
public void glDrawStringRight(float x, float y, String text);
|
||||
void glDrawStringRight(float x, float y, String text);
|
||||
|
||||
public void glClearSkin();
|
||||
void glClearSkin();
|
||||
|
||||
public BinaryFont getCurrentFont();
|
||||
BinaryFont getCurrentFont();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
package it.cavallium.warppi.gui.graphicengine;
|
||||
|
||||
public interface RenderingLoop {
|
||||
public void refresh();
|
||||
void refresh();
|
||||
}
|
||||
|
@ -5,15 +5,15 @@ import java.net.URISyntaxException;
|
||||
|
||||
public interface Skin {
|
||||
|
||||
public void load(String file) throws IOException, URISyntaxException;
|
||||
void load(String file) throws IOException, URISyntaxException;
|
||||
|
||||
public void initialize(GraphicEngine d);
|
||||
void initialize(GraphicEngine d);
|
||||
|
||||
public boolean isInitialized();
|
||||
boolean isInitialized();
|
||||
|
||||
public void use(GraphicEngine d);
|
||||
void use(GraphicEngine d);
|
||||
|
||||
public int getSkinWidth();
|
||||
int getSkinWidth();
|
||||
|
||||
public int getSkinHeight();
|
||||
int getSkinHeight();
|
||||
}
|
||||
|
@ -19,25 +19,24 @@ public abstract class PngSkin implements Skin {
|
||||
@SuppressWarnings("unused")
|
||||
private final boolean isResource;
|
||||
|
||||
public PngSkin(String file) throws IOException {
|
||||
public PngSkin(final String file) throws IOException {
|
||||
isResource = !new File(file).exists();
|
||||
load(file);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public void load(String file) throws IOException {
|
||||
if (!file.startsWith("/"))
|
||||
file = "/" + file;
|
||||
try {
|
||||
if (!file.endsWith(".png")) {
|
||||
File f = File.createTempFile("picalculator-png", ".png");
|
||||
final File f = File.createTempFile("picalculator-png", ".png");
|
||||
f.deleteOnExit();
|
||||
BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream(file));
|
||||
final BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream(file));
|
||||
ImageIO.write(img, "PNG", f);
|
||||
file = f.toString();
|
||||
}
|
||||
PngReader r = Engine.getPlatform().getPngUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file));
|
||||
final PngReader r = Engine.getPlatform().getPngUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file));
|
||||
if (r == null) {
|
||||
skinData = new int[0];
|
||||
skinSize = new int[] { 0, 0 };
|
||||
@ -46,15 +45,15 @@ public abstract class PngSkin implements Skin {
|
||||
skinData = r.getImageMatrix();
|
||||
skinSize = r.getSize();
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
IOException ex = new IOException();
|
||||
} catch (final URISyntaxException e) {
|
||||
final IOException ex = new IOException();
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(GraphicEngine d) {
|
||||
public void initialize(final GraphicEngine d) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -34,49 +34,49 @@ public abstract class RFTFont implements BinaryFont {
|
||||
@SuppressWarnings("unused")
|
||||
private final boolean isResource;
|
||||
|
||||
public RFTFont(String fontName) throws IOException {
|
||||
public RFTFont(final String fontName) throws IOException {
|
||||
this(fontName, false);
|
||||
}
|
||||
|
||||
RFTFont(String fontName, boolean onlyRaw) throws IOException {
|
||||
RFTFont(final String fontName, final boolean onlyRaw) throws IOException {
|
||||
isResource = true;
|
||||
load("/font_" + fontName + ".rft", onlyRaw);
|
||||
}
|
||||
|
||||
public RFTFont(String path, String fontName) throws IOException {
|
||||
public RFTFont(final String path, final String fontName) throws IOException {
|
||||
this(path, fontName, false);
|
||||
}
|
||||
|
||||
RFTFont(String path, String fontName, boolean onlyRaw) throws IOException {
|
||||
RFTFont(final String path, final String fontName, final boolean onlyRaw) throws IOException {
|
||||
isResource = false;
|
||||
load(path + "/font_" + fontName + ".rft", onlyRaw);
|
||||
}
|
||||
|
||||
public static RFTFont loadTemporaryFont(String name) throws IOException {
|
||||
public static RFTFont loadTemporaryFont(final String name) throws IOException {
|
||||
return new BlankRFTFont(name, true);
|
||||
}
|
||||
|
||||
public static RFTFont loadTemporaryFont(String path, String name) throws IOException {
|
||||
public static RFTFont loadTemporaryFont(final String path, final String name) throws IOException {
|
||||
return new BlankRFTFont(path, name, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(String path) throws IOException {
|
||||
public void load(final String path) throws IOException {
|
||||
load(path, false);
|
||||
}
|
||||
|
||||
private void load(String path, boolean onlyRaw) throws IOException {
|
||||
private void load(final String path, final boolean onlyRaw) throws IOException {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN + 1, "Loading font " + path);
|
||||
loadFont(path);
|
||||
if (!onlyRaw) {
|
||||
chars32 = new int[(intervalsTotalSize) * charIntCount];
|
||||
chars32 = new int[intervalsTotalSize * charIntCount];
|
||||
for (int charCompressedIndex = 0; charCompressedIndex < intervalsTotalSize; charCompressedIndex++) {
|
||||
final boolean[] currentChar = rawchars[charCompressedIndex];
|
||||
if (currentChar == null) {
|
||||
int currentInt = 0;
|
||||
int currentBit = 0;
|
||||
for (int i = 0; i < charS; i++) {
|
||||
if (currentInt * intBits + currentBit >= (currentInt + 1) * intBits) {
|
||||
if (currentInt * RFTFont.intBits + currentBit >= (currentInt + 1) * RFTFont.intBits) {
|
||||
currentInt += 1;
|
||||
currentBit = 0;
|
||||
}
|
||||
@ -87,11 +87,11 @@ public abstract class RFTFont implements BinaryFont {
|
||||
int currentInt = 0;
|
||||
int currentBit = 0;
|
||||
for (int i = 0; i < charS; i++) {
|
||||
if (currentBit >= intBits) {
|
||||
if (currentBit >= RFTFont.intBits) {
|
||||
currentInt += 1;
|
||||
currentBit = 0;
|
||||
}
|
||||
chars32[charCompressedIndex * charIntCount + currentInt] = (chars32[charCompressedIndex * charIntCount + currentInt]) | ((currentChar[i] ? 1 : 0) << currentBit);
|
||||
chars32[charCompressedIndex * charIntCount + currentInt] = chars32[charCompressedIndex * charIntCount + currentInt] | (currentChar[i] ? 1 : 0) << currentBit;
|
||||
currentBit++;
|
||||
}
|
||||
}
|
||||
@ -107,8 +107,8 @@ public abstract class RFTFont implements BinaryFont {
|
||||
if (!string.startsWith("/"))
|
||||
string = "/" + string;
|
||||
res = Engine.getPlatform().getStorageUtils().getResourceStream(string);
|
||||
} catch (URISyntaxException e) {
|
||||
IOException ex = new IOException();
|
||||
} catch (final URISyntaxException e) {
|
||||
final IOException ex = new IOException();
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
@ -119,32 +119,28 @@ public abstract class RFTFont implements BinaryFont {
|
||||
charW = file[0x4] << 8 | file[0x5];
|
||||
charH = file[0x6] << 8 | file[0x7];
|
||||
charS = charW * charH;
|
||||
charIntCount = (int) Math.ceil(((double) charS) / ((double) intBits));
|
||||
charIntCount = (int) Math.ceil((double) charS / (double) RFTFont.intBits);
|
||||
minBound = file[0x9] << 24 | file[0xA] << 16 | file[0xB] << 8 | file[0xC];
|
||||
maxBound = file[0xE] << 24 | file[0xF] << 16 | file[0x10] << 8 | file[0x11];
|
||||
if (maxBound <= minBound) {
|
||||
if (maxBound <= minBound)
|
||||
maxBound = 66000; //TODO remove it: temp fix
|
||||
}
|
||||
rawchars = new boolean[maxBound - minBound][];
|
||||
int index = 0x12;
|
||||
while (index < filelength) {
|
||||
while (index < filelength)
|
||||
try {
|
||||
final int charIndex = file[index] << 8 | file[index + 1];
|
||||
final boolean[] rawchar = new boolean[charS];
|
||||
int charbytescount = 0;
|
||||
while (charbytescount * 8 < charS) {
|
||||
while (charbytescount * 8 < charS)
|
||||
charbytescount += 1;
|
||||
}
|
||||
int currentBit = 0;
|
||||
for (int i = 0; i <= charbytescount; i++) {
|
||||
for (int i = 0; i <= charbytescount; i++)
|
||||
for (int bit = 0; bit < 8; bit++) {
|
||||
if (currentBit >= charS) {
|
||||
if (currentBit >= charS)
|
||||
break;
|
||||
}
|
||||
rawchar[currentBit] = (((file[index + 2 + i] >> (8 - 1 - bit)) & 0x1) == 1) ? true : false;
|
||||
rawchar[currentBit] = (file[index + 2 + i] >> 8 - 1 - bit & 0x1) == 1 ? true : false;
|
||||
currentBit++;
|
||||
}
|
||||
}
|
||||
rawchars[charIndex - minBound] = rawchar;
|
||||
index += 2 + charbytescount;
|
||||
} catch (final Exception ex) {
|
||||
@ -152,13 +148,10 @@ public abstract class RFTFont implements BinaryFont {
|
||||
System.out.println(string);
|
||||
Engine.getPlatform().exit(-1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
throw new IOException();
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
throw new IOException();
|
||||
}
|
||||
findIntervals();
|
||||
/*int[] screen = new int[rawchars.length * charW * charH];
|
||||
for (int i = 0; i < rawchars.length; i++) {
|
||||
@ -186,13 +179,12 @@ public abstract class RFTFont implements BinaryFont {
|
||||
int intervalSize = 0;
|
||||
@SuppressWarnings("unused")
|
||||
final int holeSize = 0;
|
||||
for (int i = 0; i < rawchars.length; i++) {
|
||||
for (int i = 0; i < rawchars.length; i++)
|
||||
if (rawchars[i] != null) {
|
||||
beginIndex = i;
|
||||
int firstNull = 0;
|
||||
while (i + firstNull < rawchars.length && rawchars[i + firstNull] != null) {
|
||||
while (i + firstNull < rawchars.length && rawchars[i + firstNull] != null)
|
||||
firstNull++;
|
||||
}
|
||||
endIndex = beginIndex + firstNull - 1;
|
||||
i = endIndex;
|
||||
if (endIndex >= 0) {
|
||||
@ -202,13 +194,12 @@ public abstract class RFTFont implements BinaryFont {
|
||||
}
|
||||
beginIndex = -1;
|
||||
}
|
||||
}
|
||||
int lastIndex = 0;
|
||||
final boolean[][] newrawchars = new boolean[intervalsTotalSize][];
|
||||
for (final int[] interval : intervals) {
|
||||
if (rawchars.length - (interval[0]) - interval[2] < 0) {
|
||||
if (rawchars.length - interval[0] - interval[2] < 0) {
|
||||
System.err.println(interval[0] + "-" + interval[1] + "(" + interval[2] + ")");
|
||||
System.err.println(rawchars.length - (interval[0]) - interval[2]);
|
||||
System.err.println(rawchars.length - interval[0] - interval[2]);
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
if (newrawchars.length - (lastIndex - 1) - interval[2] < 0) {
|
||||
@ -230,7 +221,7 @@ public abstract class RFTFont implements BinaryFont {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void saveArray(int[] screen, int w, int h, String coutputpng) {
|
||||
private void saveArray(final int[] screen, final int w, final int h, final String coutputpng) {
|
||||
final BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
||||
final int[] a = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
|
||||
System.arraycopy(screen, 0, a, 0, screen.length);
|
||||
@ -241,7 +232,7 @@ public abstract class RFTFont implements BinaryFont {
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getCharIndexes(String txt) {
|
||||
public int[] getCharIndexes(final String txt) {
|
||||
final int l = txt.length();
|
||||
final int[] indexes = new int[l];
|
||||
final char[] chars = txt.toCharArray();
|
||||
@ -252,52 +243,48 @@ public abstract class RFTFont implements BinaryFont {
|
||||
return indexes;
|
||||
}
|
||||
|
||||
public int getCharIndex(char c) {
|
||||
public int getCharIndex(final char c) {
|
||||
final int originalIndex = c & 0xFFFF;
|
||||
return compressIndex(originalIndex);
|
||||
}
|
||||
|
||||
protected int compressIndex(int originalIndex) {
|
||||
protected int compressIndex(final int originalIndex) {
|
||||
int compressedIndex = 0;
|
||||
for (int i = 0; i < intervals.length; i += 3) {
|
||||
if (intervals[i] > originalIndex) {
|
||||
for (int i = 0; i < intervals.length; i += 3)
|
||||
if (intervals[i] > originalIndex)
|
||||
break;
|
||||
} else if (originalIndex <= intervals[i + 1]) {
|
||||
compressedIndex += (originalIndex - intervals[i]);
|
||||
else if (originalIndex <= intervals[i + 1]) {
|
||||
compressedIndex += originalIndex - intervals[i];
|
||||
break;
|
||||
} else {
|
||||
} else
|
||||
compressedIndex += intervals[i + 2];
|
||||
}
|
||||
}
|
||||
return compressedIndex;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int decompressIndex(int compressedIndex) {
|
||||
private int decompressIndex(final int compressedIndex) {
|
||||
final int originalIndex = 0;
|
||||
int i = 0;
|
||||
for (int intvl = 0; intvl < intervals.length; intvl += 3) {
|
||||
i += intervals[intvl + 2];
|
||||
if (i == compressedIndex) {
|
||||
if (i == compressedIndex)
|
||||
return intervals[intvl + 1];
|
||||
} else if (i > compressedIndex) {
|
||||
else if (i > compressedIndex)
|
||||
return intervals[intvl + 1] - (i - compressedIndex);
|
||||
}
|
||||
}
|
||||
return originalIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(GraphicEngine d) {}
|
||||
public void initialize(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public int getStringWidth(String text) {
|
||||
public int getStringWidth(final String text) {
|
||||
final int w = charW * text.length();
|
||||
if (text.length() > 0 && w > 0) {
|
||||
if (text.length() > 0 && w > 0)
|
||||
return w;
|
||||
} else {
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -324,22 +311,22 @@ public abstract class RFTFont implements BinaryFont {
|
||||
public int getSkinHeight() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
private static class BlankRFTFont extends RFTFont {
|
||||
|
||||
BlankRFTFont(String fontName, boolean onlyRaw) throws IOException {
|
||||
BlankRFTFont(final String fontName, final boolean onlyRaw) throws IOException {
|
||||
super(fontName, onlyRaw);
|
||||
}
|
||||
|
||||
public BlankRFTFont(String path, String name, boolean b) throws IOException {
|
||||
public BlankRFTFont(final String path, final String name, final boolean b) throws IOException {
|
||||
super(path, name, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use(GraphicEngine d) {
|
||||
|
||||
public void use(final GraphicEngine d) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,20 +27,19 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {}
|
||||
public void setTitle(final String title) {}
|
||||
|
||||
@Override
|
||||
public void setResizable(boolean r) {}
|
||||
public void setResizable(final boolean r) {}
|
||||
|
||||
@Override
|
||||
public void setDisplayMode(int ww, int wh) {}
|
||||
public void setDisplayMode(final int ww, final int wh) {}
|
||||
|
||||
@Override
|
||||
public void create(Runnable onInitialized) {
|
||||
public void create(final Runnable onInitialized) {
|
||||
initialized = true;
|
||||
if (onInitialized != null) {
|
||||
if (onInitialized != null)
|
||||
onInitialized.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,7 +64,7 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(RenderingLoop d) {}
|
||||
public void start(final RenderingLoop d) {}
|
||||
|
||||
@Override
|
||||
public void repaint() {}
|
||||
@ -79,62 +78,62 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth,
|
||||
float uvHeight) {}
|
||||
public void glFillRect(final float x, final float y, final float width, final float height, final float uvX,
|
||||
final float uvY, final float uvWidth, final float uvHeight) {}
|
||||
|
||||
@Override
|
||||
public void glFillColor(float x, float y, float width, float height) {}
|
||||
public void glFillColor(final float x, final float y, final float width, final float height) {}
|
||||
|
||||
@Override
|
||||
public void glDrawStringRight(float x, float y, String text) {}
|
||||
public void glDrawStringRight(final float x, final float y, final String text) {}
|
||||
|
||||
@Override
|
||||
public void glDrawStringLeft(float x, float y, String text) {}
|
||||
public void glDrawStringLeft(final float x, final float y, final String text) {}
|
||||
|
||||
@Override
|
||||
public void glDrawStringCenter(float x, float y, String text) {}
|
||||
public void glDrawStringCenter(final float x, final float y, final String text) {}
|
||||
|
||||
@Override
|
||||
public void glDrawLine(float x0, float y0, float x1, float y1) {}
|
||||
public void glDrawLine(final float x0, final float y0, final float x1, final float y1) {}
|
||||
|
||||
@Override
|
||||
public void glDrawCharRight(int x, int y, char ch) {}
|
||||
public void glDrawCharRight(final int x, final int y, final char ch) {}
|
||||
|
||||
@Override
|
||||
public void glDrawCharLeft(int x, int y, char ch) {}
|
||||
public void glDrawCharLeft(final int x, final int y, final char ch) {}
|
||||
|
||||
@Override
|
||||
public void glDrawCharCenter(int x, int y, char ch) {}
|
||||
public void glDrawCharCenter(final int x, final int y, final char ch) {}
|
||||
|
||||
@Override
|
||||
public void glColor4i(int red, int green, int blue, int alpha) {}
|
||||
public void glColor4i(final int red, final int green, final int blue, final int alpha) {}
|
||||
|
||||
@Override
|
||||
public void glColor4f(float red, float green, float blue, float alpha) {}
|
||||
public void glColor4f(final float red, final float green, final float blue, final float alpha) {}
|
||||
|
||||
@Override
|
||||
public void glColor3i(int r, int gg, int b) {}
|
||||
public void glColor3i(final int r, final int gg, final int b) {}
|
||||
|
||||
@Override
|
||||
public void glColor3f(float red, float green, float blue) {}
|
||||
public void glColor3f(final float red, final float green, final float blue) {}
|
||||
|
||||
@Override
|
||||
public void glColor(int c) {}
|
||||
public void glColor(final int c) {}
|
||||
|
||||
@Override
|
||||
public void glClearSkin() {}
|
||||
|
||||
@Override
|
||||
public void glClearColor4i(int red, int green, int blue, int alpha) {}
|
||||
public void glClearColor4i(final int red, final int green, final int blue, final int alpha) {}
|
||||
|
||||
@Override
|
||||
public void glClearColor4f(float red, float green, float blue, float alpha) {}
|
||||
public void glClearColor4f(final float red, final float green, final float blue, final float alpha) {}
|
||||
|
||||
@Override
|
||||
public void glClearColor(int c) {}
|
||||
public void glClearColor(final int c) {}
|
||||
|
||||
@Override
|
||||
public void glClear(int screenWidth, int screenHeight) {}
|
||||
public void glClear(final int screenWidth, final int screenHeight) {}
|
||||
|
||||
@Override
|
||||
public BinaryFont getCurrentFont() {
|
||||
@ -144,13 +143,13 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryFont loadFont(String fontName) throws IOException {
|
||||
public BinaryFont loadFont(final String fontName) throws IOException {
|
||||
return new BinaryFont() {
|
||||
@Override
|
||||
public void use(GraphicEngine d) {}
|
||||
public void use(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public void load(String file) throws IOException {}
|
||||
public void load(final String file) throws IOException {}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
@ -158,10 +157,10 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(GraphicEngine d) {}
|
||||
public void initialize(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public int getStringWidth(String text) {
|
||||
public int getStringWidth(final String text) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -190,13 +189,13 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryFont loadFont(String path, String fontName) throws IOException {
|
||||
public BinaryFont loadFont(final String path, final String fontName) throws IOException {
|
||||
return new BinaryFont() {
|
||||
@Override
|
||||
public void use(GraphicEngine d) {}
|
||||
public void use(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public void load(String file) throws IOException {}
|
||||
public void load(final String file) throws IOException {}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
@ -204,10 +203,10 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(GraphicEngine d) {}
|
||||
public void initialize(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public int getStringWidth(String text) {
|
||||
public int getStringWidth(final String text) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -236,13 +235,13 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skin loadSkin(String file) throws IOException {
|
||||
public Skin loadSkin(final String file) throws IOException {
|
||||
return new Skin() {
|
||||
@Override
|
||||
public void use(GraphicEngine d) {}
|
||||
public void use(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public void load(String file) throws IOException {}
|
||||
public void load(final String file) throws IOException {}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
@ -250,7 +249,7 @@ public class NoGuiEngine implements GraphicEngine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(GraphicEngine d) {}
|
||||
public void initialize(final GraphicEngine d) {}
|
||||
|
||||
@Override
|
||||
public int getSkinWidth() {
|
||||
|
@ -13,7 +13,7 @@ public class ChooseVariableValueScreen extends Screen {
|
||||
private final MathInputScreen es;
|
||||
public Function resultNumberValue;
|
||||
|
||||
public ChooseVariableValueScreen(MathInputScreen es, VariableValue variableValue) {
|
||||
public ChooseVariableValueScreen(final MathInputScreen es, final VariableValue variableValue) {
|
||||
super();
|
||||
canBeInHistory = false;
|
||||
|
||||
@ -46,7 +46,7 @@ public class ChooseVariableValueScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public class ChooseVariableValueScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyPressedEvent k) {
|
||||
public boolean onKeyPressed(final KeyPressedEvent k) {
|
||||
switch (k.getKey()) {
|
||||
case LETTER_X:
|
||||
// PIDisplay.INSTANCE.goBack();
|
||||
|
@ -24,7 +24,7 @@ public class EmptyScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -36,17 +36,15 @@ public class KeyboardDebugScreen extends Screen {
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringLeft(10, 30, "Key position");
|
||||
renderer.glDrawStringLeft(10, 45, "X: " + keyX + ", Y:" + keyY);
|
||||
renderer.glDrawStringLeft(10, 45, "X: " + KeyboardDebugScreen.keyX + ", Y:" + KeyboardDebugScreen.keyY);
|
||||
renderer.glDrawStringLeft(10, 65, "Key value");
|
||||
renderer.glDrawStringLeft(10, 80, key);
|
||||
}
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (log[i] != null) {
|
||||
renderer.glDrawStringLeft(10, 230 + 15 * (i + 1), log[i].toUpperCase());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (KeyboardDebugScreen.log[i] != null)
|
||||
renderer.glDrawStringLeft(10, 230 + 15 * (i + 1), KeyboardDebugScreen.log[i].toUpperCase());
|
||||
|
||||
//FROM SERIAL
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
@ -54,44 +52,41 @@ public class KeyboardDebugScreen extends Screen {
|
||||
renderer.glFillColor(-80 + 100, 100, 200, 70);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(-80 + 100 + 200 / 2, 100 + 70 / 2 - (renderer.getCurrentFont().getCharacterHeight() / 2), "FROM SERIAL");
|
||||
renderer.glDrawStringCenter(-80 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "FROM SERIAL");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (pinsA[i] == 1) {
|
||||
if (KeyboardDebugScreen.pinsA[i] == 1)
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else if (pinsA[i] == 2) {
|
||||
else if (KeyboardDebugScreen.pinsA[i] == 2)
|
||||
renderer.glColor4f(0.5f, 0.5f, 1.0f, 1.0f);
|
||||
} else if (pinsA[i] == -1) {
|
||||
else if (KeyboardDebugScreen.pinsA[i] == -1)
|
||||
renderer.glColor4f(0.7f, 0.7f, 0.7f, 1.0f);
|
||||
} else if (pinsA[i] == 0) {
|
||||
else if (KeyboardDebugScreen.pinsA[i] == 0)
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(-80 + 103 + 25 * (7 - i), 80, 20, 20);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(-80 + 113 + 25 * (7 - i), 90 - (renderer.getCurrentFont().getCharacterHeight() / 2), "" + (i + 1));
|
||||
renderer.glDrawStringCenter(-80 + 113 + 25 * (7 - i), 90 - renderer.getCurrentFont().getCharacterHeight() / 2, "" + (i + 1));
|
||||
}
|
||||
for (int i = 15; i >= 8; i--) {
|
||||
if (pinsA[i] == 1) {
|
||||
if (KeyboardDebugScreen.pinsA[i] == 1)
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else if (pinsA[i] == 2) {
|
||||
else if (KeyboardDebugScreen.pinsA[i] == 2)
|
||||
renderer.glColor4f(0.5f, 0.5f, 1.0f, 1.0f);
|
||||
} else if (pinsA[i] == -1) {
|
||||
else if (KeyboardDebugScreen.pinsA[i] == -1)
|
||||
renderer.glColor4f(0.7f, 0.7f, 0.7f, 1.0f);
|
||||
} else if (pinsA[i] == 0) {
|
||||
else if (KeyboardDebugScreen.pinsA[i] == 0)
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(-80 + 103 + 25 * (i - 8), 170, 20, 20);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(-80 + 113 + 25 * (i - 8), 180 - (renderer.getCurrentFont().getCharacterHeight() / 2), "" + (i + 1));
|
||||
renderer.glDrawStringCenter(-80 + 113 + 25 * (i - 8), 180 - renderer.getCurrentFont().getCharacterHeight() / 2, "" + (i + 1));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (dataA[i]) {
|
||||
if (KeyboardDebugScreen.dataA[i])
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else {
|
||||
else
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(-80 + 160 + 10 * (i), 150, 8, 8);
|
||||
renderer.glFillColor(-80 + 160 + 10 * i, 150, 8, 8);
|
||||
}
|
||||
|
||||
//TO SERIAL
|
||||
@ -100,57 +95,53 @@ public class KeyboardDebugScreen extends Screen {
|
||||
renderer.glFillColor(150 + 100, 100, 200, 70);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[2].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(150 + 100 + 200 / 2, 100 + 70 / 2 - (renderer.getCurrentFont().getCharacterHeight() / 2), "TO SERIAL");
|
||||
renderer.glDrawStringCenter(150 + 100 + 200 / 2, 100 + 70 / 2 - renderer.getCurrentFont().getCharacterHeight() / 2, "TO SERIAL");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().fonts[3].use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
for (int i = 15; i >= 8; i--) {
|
||||
if (pinsB[i] == 1) {
|
||||
if (KeyboardDebugScreen.pinsB[i] == 1)
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else if (pinsB[i] == 2) {
|
||||
else if (KeyboardDebugScreen.pinsB[i] == 2)
|
||||
renderer.glColor4f(0.5f, 0.5f, 1.0f, 1.0f);
|
||||
} else if (pinsB[i] == -1) {
|
||||
else if (KeyboardDebugScreen.pinsB[i] == -1)
|
||||
renderer.glColor4f(0.7f, 0.7f, 0.7f, 1.0f);
|
||||
} else if (pinsB[i] == 0) {
|
||||
else if (KeyboardDebugScreen.pinsB[i] == 0)
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(150 + 103 + 25 * (15 - i), 80, 20, 20);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(150 + 113 + 25 * (15 - i), 90 - (renderer.getCurrentFont().getCharacterHeight() / 2), "" + (i + 1));
|
||||
renderer.glDrawStringCenter(150 + 113 + 25 * (15 - i), 90 - renderer.getCurrentFont().getCharacterHeight() / 2, "" + (i + 1));
|
||||
}
|
||||
for (int i = 7; i >= 0; i--) {
|
||||
if (pinsB[i] == 1) {
|
||||
if (KeyboardDebugScreen.pinsB[i] == 1)
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else if (pinsB[i] == 2) {
|
||||
else if (KeyboardDebugScreen.pinsB[i] == 2)
|
||||
renderer.glColor4f(0.5f, 0.5f, 1.0f, 1.0f);
|
||||
} else if (pinsB[i] == -1) {
|
||||
else if (KeyboardDebugScreen.pinsB[i] == -1)
|
||||
renderer.glColor4f(0.7f, 0.7f, 0.7f, 1.0f);
|
||||
} else if (pinsB[i] == 0) {
|
||||
else if (KeyboardDebugScreen.pinsB[i] == 0)
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(150 + 103 + 25 * (i), 170, 20, 20);
|
||||
renderer.glFillColor(150 + 103 + 25 * i, 170, 20, 20);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(150 + 113 + 25 * (i), 180 - (renderer.getCurrentFont().getCharacterHeight() / 2), "" + (i + 1));
|
||||
renderer.glDrawStringCenter(150 + 113 + 25 * i, 180 - renderer.getCurrentFont().getCharacterHeight() / 2, "" + (i + 1));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (dataB[i]) {
|
||||
if (KeyboardDebugScreen.dataB[i])
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else {
|
||||
else
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(150 + 160 + 10 * (i), 150, 8, 8);
|
||||
renderer.glFillColor(150 + 160 + 10 * i, 150, 8, 8);
|
||||
}
|
||||
|
||||
//GPIO
|
||||
for (int i = 0; i < 40; i++) {
|
||||
if (gpio[i] == true) {
|
||||
if (KeyboardDebugScreen.gpio[i] == true)
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else {
|
||||
else
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
if (i % 2 == 0) {
|
||||
renderer.glFillColor(53 + 15 * ((i) / 2), 50, 5, 5);
|
||||
renderer.glFillColor(53 + 15 * (i / 2), 50, 5, 5);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
renderer.glDrawStringCenter(55 + 15 * ((i) / 2), 60, "" + (i + 1));
|
||||
renderer.glDrawStringCenter(55 + 15 * (i / 2), 60, "" + (i + 1));
|
||||
} else {
|
||||
renderer.glFillColor(53 + 15 * ((i - 1) / 2), 40, 5, 5);
|
||||
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
@ -159,24 +150,22 @@ public class KeyboardDebugScreen extends Screen {
|
||||
}
|
||||
|
||||
//KEYS
|
||||
for (int c = 0; c < 8; c++) {
|
||||
for (int c = 0; c < 8; c++)
|
||||
for (int r = 0; r < 8; r++) {
|
||||
if (ks[c][r]) {
|
||||
if (KeyboardDebugScreen.ks[c][r])
|
||||
renderer.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
} else {
|
||||
else
|
||||
renderer.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
renderer.glFillColor(250 + 6 * c, 250 + 6 * r, 5, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
if (System.currentTimeMillis() - beforetime >= 1000) {
|
||||
keyevent = "NONE";
|
||||
keyX = 0;
|
||||
keyY = 0;
|
||||
KeyboardDebugScreen.keyX = 0;
|
||||
KeyboardDebugScreen.keyY = 0;
|
||||
key = "";
|
||||
}
|
||||
}
|
||||
@ -187,21 +176,21 @@ public class KeyboardDebugScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyPressedEvent k) {
|
||||
public boolean onKeyPressed(final KeyPressedEvent k) {
|
||||
beforetime = System.currentTimeMillis();
|
||||
keyevent = "PRESSED";
|
||||
keyX = 0;
|
||||
keyY = 0;
|
||||
KeyboardDebugScreen.keyX = 0;
|
||||
KeyboardDebugScreen.keyY = 0;
|
||||
key = k.toString();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyReleased(KeyReleasedEvent k) {
|
||||
public boolean onKeyReleased(final KeyReleasedEvent k) {
|
||||
beforetime = System.currentTimeMillis();
|
||||
keyevent = "RELEASED";
|
||||
keyX = 0;
|
||||
keyY = 0;
|
||||
KeyboardDebugScreen.keyX = 0;
|
||||
KeyboardDebugScreen.keyY = 0;
|
||||
key = k.toString();
|
||||
return false;
|
||||
}
|
||||
@ -213,13 +202,12 @@ public class KeyboardDebugScreen extends Screen {
|
||||
public static boolean[][] ks = new boolean[8][8];
|
||||
public static boolean[] gpio = new boolean[40];
|
||||
|
||||
public static void log(String str) {
|
||||
final String[] newlog = log;
|
||||
for (int i = 1; i < 5; i++) {
|
||||
public static void log(final String str) {
|
||||
final String[] newlog = KeyboardDebugScreen.log;
|
||||
for (int i = 1; i < 5; i++)
|
||||
newlog[i - 1] = newlog[i];
|
||||
}
|
||||
newlog[4] = "[" + System.currentTimeMillis() + "]" + str;
|
||||
log = newlog;
|
||||
KeyboardDebugScreen.log = newlog;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class LoadingScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
loadingTextTranslation = GraphicUtils.sinDeg(endLoading * 90f) * 10f;
|
||||
|
||||
endLoading += dt;
|
||||
@ -60,9 +60,8 @@ public class LoadingScreen extends Screen {
|
||||
if (mustRefresh) {
|
||||
mustRefresh = false;
|
||||
return true;
|
||||
} else {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,35 +44,30 @@ public class MarioScreen extends Screen {
|
||||
@Override
|
||||
public void initialized() {
|
||||
try {
|
||||
if (skin == null) {
|
||||
skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioskin.png");
|
||||
}
|
||||
if (groundskin == null) {
|
||||
groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioground.png");
|
||||
}
|
||||
if (gpuTest2 == null) {
|
||||
if (MarioScreen.skin == null)
|
||||
MarioScreen.skin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioskin.png");
|
||||
if (MarioScreen.groundskin == null)
|
||||
MarioScreen.groundskin = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("marioground.png");
|
||||
if (MarioScreen.gpuTest2 == null)
|
||||
try {
|
||||
gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest2");
|
||||
MarioScreen.gpuTest2 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest2");
|
||||
} catch (final Exception ex) {}
|
||||
}
|
||||
if (gpuTest1 == null) {
|
||||
if (MarioScreen.gpuTest1 == null)
|
||||
try {
|
||||
gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest12");
|
||||
gpuTest12 = true;
|
||||
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest12");
|
||||
MarioScreen.gpuTest12 = true;
|
||||
} catch (final Exception ex) {
|
||||
gpuTest12 = false;
|
||||
MarioScreen.gpuTest12 = false;
|
||||
try {
|
||||
gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest1");
|
||||
MarioScreen.gpuTest1 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadFont("gputest1");
|
||||
} catch (final Exception ex2) {}
|
||||
}
|
||||
}
|
||||
if (gpuTest3 == null) {
|
||||
if (MarioScreen.gpuTest3 == null)
|
||||
try {
|
||||
gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("font_gputest3.png");
|
||||
MarioScreen.gpuTest3 = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.loadSkin("font_gputest3.png");
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -80,13 +75,12 @@ public class MarioScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void created() throws InterruptedException {
|
||||
if (!errored) {
|
||||
if (!errored)
|
||||
g = new MarioGame();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
if (!errored) {
|
||||
final boolean rightPressed = Keyboard.isKeyDown(2, 5);
|
||||
final boolean leftPressed = Keyboard.isKeyDown(2, 3);
|
||||
@ -111,13 +105,13 @@ public class MarioScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
if (errored) {
|
||||
if (errored)
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringLeft(0, 20, "ERROR");
|
||||
} else {
|
||||
if (groundskin != null) {
|
||||
else {
|
||||
if (MarioScreen.groundskin != null) {
|
||||
final double playerX = g.getPlayer().getX();
|
||||
final double playerY = g.getPlayer().getY();
|
||||
groundskin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
MarioScreen.groundskin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
final MarioWorld w = g.getCurrentWorld();
|
||||
final int width = w.getWidth();
|
||||
final int height = w.getHeight();
|
||||
@ -126,11 +120,11 @@ public class MarioScreen extends Screen {
|
||||
final float shiftX = -8 + 16 * (float) playerX;
|
||||
final float shiftY = -8 + 16 * (height - (float) playerY);
|
||||
int blue = -1;
|
||||
for (int ix = 0; ix < width; ix++) {
|
||||
for (int ix = 0; ix < width; ix++)
|
||||
for (int iy = 0; iy < height; iy++) {
|
||||
final double distX = Math.abs(playerX - ix);
|
||||
final double distY = Math.abs(playerY - iy - 1.5d);
|
||||
if ((distX * distX + distY * distY / 2d) < 25d) {
|
||||
if (distX * distX + distY * distY / 2d < 25d) {
|
||||
final byte b = w.getBlockIdAt(ix, iy);
|
||||
if (b == 0) {
|
||||
if (blue != 1) {
|
||||
@ -147,47 +141,46 @@ public class MarioScreen extends Screen {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (blue != 0) {
|
||||
blue = 0;
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xffffffff);
|
||||
}
|
||||
|
||||
//DRAW MARIO
|
||||
skin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
MarioScreen.skin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(screenX - (g.getPlayer().flipped ? 3 : 0), screenY, 35, 27, 35 * (g.getPlayer().marioSkinPos[0] + (g.getPlayer().flipped ? 2 : 1)), 27 * g.getPlayer().marioSkinPos[1], 35 * (g.getPlayer().flipped ? -1 : 1), 27);
|
||||
// PIDisplay.renderer.glDrawSkin(getPosX() - 18, 25 + getPosY(), 35 * (marioSkinPos[0] + (flipped ? 2 : 1)), 27 * marioSkinPos[1], 35 * (marioSkinPos[0] + (flipped ? 1 : 2)), 27 * (marioSkinPos[1] + 1), true);
|
||||
}
|
||||
|
||||
// GPU PERFORMANCE TEST
|
||||
if (gpuTest1 != null) {
|
||||
if (MarioScreen.gpuTest1 != null) {
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(1, 1, 1);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - (gpuTest12 ? 512 : 256), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuTest12 ? 512 : 256, gpuTest12 ? 512 : 256);
|
||||
gpuTest1.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillColor(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - (MarioScreen.gpuTest12 ? 512 : 256), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), MarioScreen.gpuTest12 ? 512 : 256, MarioScreen.gpuTest12 ? 512 : 256);
|
||||
MarioScreen.gpuTest1.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor3f(0, 0, 0);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth(), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth(), Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() / 2 - (MarioScreen.gpuTest12 ? 256 : 128), gpuCharTest1[gpuCharTest1Num]);
|
||||
}
|
||||
if (gpuTest3 != null) {
|
||||
gpuTest3.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
if (MarioScreen.gpuTest3 != null) {
|
||||
MarioScreen.gpuTest3.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor4f(1, 1, 1, 0.7f);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, gpuTestNum * 224, 0, 224, 128);
|
||||
}
|
||||
if (gpuTest2 != null) {
|
||||
gpuTest2.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
if (MarioScreen.gpuTest2 != null) {
|
||||
MarioScreen.gpuTest2.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF000000);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "A");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "A");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFF800000);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "B");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "B");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeea28e);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "C");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "C");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFee7255);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "D");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "D");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFeac0b0);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "E");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "E");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFf3d8ce);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "F");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "F");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glColor(0xFFffede7);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - gpuTest2.getCharacterHeight(), "G");
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glDrawStringRight(StaticVars.screenSize[0], Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - MarioScreen.gpuTest2.getCharacterHeight(), "G");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,15 +83,13 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error == null) {
|
||||
public void beforeRender(final float dt) {
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error == null)
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFc5c2af);
|
||||
} else {
|
||||
else
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer.glClearColor(0xFFDC3C32);
|
||||
}
|
||||
if (userInput.beforeRender(dt)) {
|
||||
if (userInput.beforeRender(dt))
|
||||
mustRefresh = true;
|
||||
}
|
||||
if (computingResult) {
|
||||
computingElapsedTime += dt;
|
||||
computingAnimationElapsedTime += dt;
|
||||
@ -100,9 +98,8 @@ public class MathInputScreen extends Screen {
|
||||
computingAnimationIndex = (computingAnimationIndex + 1) % 16;
|
||||
mustRefresh = true;
|
||||
}
|
||||
if (computingElapsedTime > 5) {
|
||||
if (computingElapsedTime > 5)
|
||||
computingBreakTipVisible = true;
|
||||
}
|
||||
} else {
|
||||
computingElapsedTime = 0;
|
||||
computingAnimationElapsedTime = 0;
|
||||
@ -114,7 +111,7 @@ public class MathInputScreen extends Screen {
|
||||
@Override
|
||||
public void render() {
|
||||
final Renderer renderer = Engine.INSTANCE.getHardwareDevice().getDisplayManager().renderer;
|
||||
fontBig.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
MathInputScreen.fontBig.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
final int textColor = 0xFF000000;
|
||||
final int padding = 4;
|
||||
renderer.glColor(textColor);
|
||||
@ -134,11 +131,8 @@ public class MathInputScreen extends Screen {
|
||||
renderer.glColor3f(0.75f, 0, 0);
|
||||
renderer.glDrawStringRight(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - 4 - size - 4, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - size / 2 - renderer.getCurrentFont().getCharacterHeight() / 2 - 4, "Press (=) to stop");
|
||||
}
|
||||
} else {
|
||||
if (!result.isContentEmpty()) {
|
||||
result.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - result.getWidth() - 2, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - result.getHeight() - 2);
|
||||
}
|
||||
}
|
||||
} else if (!result.isContentEmpty())
|
||||
result.draw(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine, renderer, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getWidth() - result.getWidth() - 2, Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine.getHeight() - result.getHeight() - 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -148,11 +142,10 @@ public class MathInputScreen extends Screen {
|
||||
final int pos = 2;
|
||||
final int spacersNumb = 1;
|
||||
int skinN = 0;
|
||||
if (calc.exactMode) {
|
||||
if (calc.exactMode)
|
||||
skinN = 22;
|
||||
} else {
|
||||
else
|
||||
skinN = 21;
|
||||
}
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().guiSkin.use(Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine);
|
||||
renderer.glFillRect(2 + 18 * pos + 2 * spacersNumb, 2, 16, 16, 16 * skinN, 16 * 0, 16, 16);
|
||||
}
|
||||
@ -162,13 +155,12 @@ public class MathInputScreen extends Screen {
|
||||
if (mustRefresh) {
|
||||
mustRefresh = false;
|
||||
return true;
|
||||
} else {
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyPressedEvent k) {
|
||||
public boolean onKeyPressed(final KeyPressedEvent k) {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "MathInputScreen", "Pressed key " + k.getKey().toString());
|
||||
try {
|
||||
switch (k.getKey()) {
|
||||
@ -200,9 +192,8 @@ public class MathInputScreen extends Screen {
|
||||
case STEP:
|
||||
currentStep++;
|
||||
case SIMPLIFY:
|
||||
if (!step) {
|
||||
if (!step)
|
||||
currentStep = 0;
|
||||
}
|
||||
if (Engine.INSTANCE.getHardwareDevice().getDisplayManager().error != null) {
|
||||
//TODO: make the error management a global API rather than being relegated to this screen.
|
||||
Engine.getPlatform().getConsoleUtils().out().println(1, "Resetting after error...");
|
||||
@ -211,65 +202,61 @@ public class MathInputScreen extends Screen {
|
||||
calc.f2 = null;
|
||||
calc.resultsCount = 0;
|
||||
return true;
|
||||
} else {
|
||||
if (!computingResult) {
|
||||
computingResult = true;
|
||||
computingThread = new Thread(() -> {
|
||||
} else if (!computingResult) {
|
||||
computingResult = true;
|
||||
computingThread = new Thread(() -> {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
if (!userInput.isAlreadyParsed() && !userInput.isEmpty()) {
|
||||
final Expression expr = MathParser.parseInput(calc, userInput);
|
||||
if (calc.f == null | calc.f2 == null) {
|
||||
calc.f = new ObjectArrayList<>();
|
||||
calc.f2 = new ObjectArrayList<>();
|
||||
} else {
|
||||
calc.f.clear();
|
||||
calc.f2.clear();
|
||||
}
|
||||
calc.f.add(expr);
|
||||
Engine.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr);
|
||||
final MathSolver ms = new MathSolver(expr);
|
||||
final ObjectArrayList<ObjectArrayList<Function>> resultSteps = ms.solveAllSteps();
|
||||
resultSteps.add(0, Utils.newArrayList(expr));
|
||||
final ObjectArrayList<Function> resultExpressions = resultSteps.get(resultSteps.size() - 1);
|
||||
for (final Function rr : resultExpressions) {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString());
|
||||
}
|
||||
final ObjectArrayList<ObjectArrayList<Block>> resultBlocks = MathParser.parseOutput(calc, resultExpressions);
|
||||
result.setContentAsMultipleGroups(resultBlocks);
|
||||
// showVariablesDialog(() -> {
|
||||
// currentExpression = newExpression;
|
||||
// simplify();
|
||||
// });
|
||||
if (!userInput.isAlreadyParsed() && !userInput.isEmpty()) {
|
||||
final Expression expr = MathParser.parseInput(calc, userInput);
|
||||
if (calc.f == null | calc.f2 == null) {
|
||||
calc.f = new ObjectArrayList<>();
|
||||
calc.f2 = new ObjectArrayList<>();
|
||||
} else {
|
||||
calc.f.clear();
|
||||
calc.f2.clear();
|
||||
}
|
||||
} catch (final InterruptedException ex) {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
|
||||
} catch (final Exception ex) {
|
||||
if (Engine.getPlatform().getSettings().isDebugEnabled()) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
throw new Error(Errors.SYNTAX_ERROR);
|
||||
calc.f.add(expr);
|
||||
Engine.getPlatform().getConsoleUtils().out().println(2, "INPUT: " + expr);
|
||||
final MathSolver ms = new MathSolver(expr);
|
||||
final ObjectArrayList<ObjectArrayList<Function>> resultSteps = ms.solveAllSteps();
|
||||
resultSteps.add(0, Utils.newArrayList(expr));
|
||||
final ObjectArrayList<Function> resultExpressions = resultSteps.get(resultSteps.size() - 1);
|
||||
for (final Function rr : resultExpressions)
|
||||
Engine.getPlatform().getConsoleUtils().out().println(0, "RESULT: " + rr.toString());
|
||||
final ObjectArrayList<ObjectArrayList<Block>> resultBlocks = MathParser.parseOutput(calc, resultExpressions);
|
||||
result.setContentAsMultipleGroups(resultBlocks);
|
||||
// showVariablesDialog(() -> {
|
||||
// currentExpression = newExpression;
|
||||
// simplify();
|
||||
// });
|
||||
}
|
||||
} catch (final Error e) {
|
||||
d.errorStackTrace = Engine.getPlatform().stacktraceToString(e);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
} catch (final InterruptedException ex) {
|
||||
Engine.getPlatform().getConsoleUtils().out().println(ConsoleUtils.OUTPUTLEVEL_DEBUG_MIN, "Computing thread stopped.");
|
||||
} catch (final Exception ex) {
|
||||
if (Engine.getPlatform().getSettings().isDebugEnabled())
|
||||
ex.printStackTrace();
|
||||
throw new Error(Errors.SYNTAX_ERROR);
|
||||
}
|
||||
computingResult = false;
|
||||
});
|
||||
Engine.getPlatform().setThreadName(computingThread, "Computing Thread");
|
||||
Engine.getPlatform().setThreadDaemon(computingThread);
|
||||
computingThread.setPriority(Thread.NORM_PRIORITY + 3);
|
||||
computingThread.start();
|
||||
return true;
|
||||
} else {
|
||||
if (computingThread != null) {
|
||||
computingThread.interrupt();
|
||||
computingResult = false;
|
||||
return true;
|
||||
} catch (final Error e) {
|
||||
d.errorStackTrace = Engine.getPlatform().stacktraceToString(e);
|
||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().error = e.id.toString();
|
||||
System.err.println(e.id);
|
||||
}
|
||||
return false;
|
||||
computingResult = false;
|
||||
});
|
||||
Engine.getPlatform().setThreadName(computingThread, "Computing Thread");
|
||||
Engine.getPlatform().setThreadDaemon(computingThread);
|
||||
computingThread.setPriority(Thread.NORM_PRIORITY + 3);
|
||||
computingThread.start();
|
||||
return true;
|
||||
} else {
|
||||
if (computingThread != null) {
|
||||
computingThread.interrupt();
|
||||
computingResult = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case NUM0:
|
||||
typeChar('0');
|
||||
@ -448,13 +435,12 @@ public class MathInputScreen extends Screen {
|
||||
}
|
||||
return false;
|
||||
case DRG_CYCLE:
|
||||
if (calc.angleMode.equals(AngleMode.DEG) == true) {
|
||||
if (calc.angleMode.equals(AngleMode.DEG) == true)
|
||||
calc.angleMode = AngleMode.RAD;
|
||||
} else if (calc.angleMode.equals(AngleMode.RAD) == true) {
|
||||
else if (calc.angleMode.equals(AngleMode.RAD) == true)
|
||||
calc.angleMode = AngleMode.GRA;
|
||||
} else {
|
||||
else
|
||||
calc.angleMode = AngleMode.DEG;
|
||||
}
|
||||
currentStep = 0;
|
||||
return true;
|
||||
default:
|
||||
@ -470,7 +456,7 @@ public class MathInputScreen extends Screen {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated
|
||||
private ObjectArrayList<Function> solveExpression(ObjectArrayList<Function> f22) {
|
||||
private ObjectArrayList<Function> solveExpression(final ObjectArrayList<Function> f22) {
|
||||
return null;
|
||||
/*
|
||||
try {
|
||||
@ -519,7 +505,7 @@ public class MathInputScreen extends Screen {
|
||||
partialResults.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (results.size() == 0) {
|
||||
calc.resultsCount = 0;
|
||||
} else {
|
||||
@ -561,7 +547,7 @@ public class MathInputScreen extends Screen {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final ObjectArrayList<Function> results = solveExpression(calc.f);
|
||||
if (results.size() == 0) {
|
||||
calc.resultsCount = 0;
|
||||
@ -596,7 +582,7 @@ public class MathInputScreen extends Screen {
|
||||
@Deprecated
|
||||
private void changeEquationScreen() {
|
||||
throw new UnsupportedOperationException();
|
||||
//
|
||||
//
|
||||
// if (!userInput.isEmpty()) {
|
||||
// final MathInputScreen cloned = clone();
|
||||
// cloned.userInput.setCaretPosition(cloned.userInput.getCaretMaxPosition()-1);
|
||||
@ -607,25 +593,22 @@ public class MathInputScreen extends Screen {
|
||||
// }
|
||||
}
|
||||
|
||||
public void typeChar(char chr) {
|
||||
public void typeChar(final char chr) {
|
||||
userInput.typeChar(chr);
|
||||
mustRefresh = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyReleased(KeyReleasedEvent k) {
|
||||
if (k.getKey() == Key.OK) {
|
||||
public boolean onKeyReleased(final KeyReleasedEvent k) {
|
||||
if (k.getKey() == Key.OK)
|
||||
return true;
|
||||
} else {
|
||||
if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().onKeyReleased(k)) {
|
||||
return true;
|
||||
} else {
|
||||
switch (k.getKey()) {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
else if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().onKeyReleased(k))
|
||||
return true;
|
||||
else
|
||||
switch (k.getKey()) {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showVariablesDialog() {
|
||||
@ -635,11 +618,9 @@ public class MathInputScreen extends Screen {
|
||||
public void showVariablesDialog(final Runnable runnable) {
|
||||
final Thread ct = new Thread(() -> {
|
||||
final ObjectArrayList<Function> knownVarsInFunctions = getKnownVariables(calc.f.toArray(new Function[calc.f.size()]));
|
||||
for (final VariableValue f : calc.variablesValues) {
|
||||
if (knownVarsInFunctions.contains(f.v)) {
|
||||
for (final VariableValue f : calc.variablesValues)
|
||||
if (knownVarsInFunctions.contains(f.v))
|
||||
knownVarsInFunctions.remove(f.v);
|
||||
}
|
||||
}
|
||||
|
||||
boolean cancelled = false;
|
||||
for (final Function f : knownVarsInFunctions) {
|
||||
@ -653,19 +634,15 @@ public class MathInputScreen extends Screen {
|
||||
break;
|
||||
} else {
|
||||
final int is = calc.variablesValues.size();
|
||||
for (int i = 0; i < is; i++) {
|
||||
if (calc.variablesValues.get(i).v == f) {
|
||||
for (int i = 0; i < is; i++)
|
||||
if (calc.variablesValues.get(i).v == f)
|
||||
calc.variablesValues.remove(i);
|
||||
}
|
||||
}
|
||||
calc.variablesValues.add(new VariableValue((Variable) f, (Number) cvs.resultNumberValue));
|
||||
}
|
||||
}
|
||||
if (!cancelled) {
|
||||
if (runnable != null) {
|
||||
if (!cancelled)
|
||||
if (runnable != null)
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
Engine.getPlatform().setThreadName(ct, "Variables user-input queue thread");
|
||||
ct.setPriority(Thread.MIN_PRIORITY);
|
||||
@ -673,23 +650,19 @@ public class MathInputScreen extends Screen {
|
||||
ct.start();
|
||||
}
|
||||
|
||||
private ObjectArrayList<Function> getKnownVariables(Function[] fncs) {
|
||||
private ObjectArrayList<Function> getKnownVariables(final Function[] fncs) {
|
||||
final ObjectArrayList<Function> res = new ObjectArrayList<>();
|
||||
for (final Function f : fncs) {
|
||||
if (f instanceof FunctionOperator) {
|
||||
for (final Function f : fncs)
|
||||
if (f instanceof FunctionOperator)
|
||||
res.addAll(getKnownVariables(new Function[] { ((FunctionOperator) f).getParameter1(), ((FunctionOperator) f).getParameter2() }));
|
||||
} else if (f instanceof FunctionDynamic) {
|
||||
else if (f instanceof FunctionDynamic)
|
||||
res.addAll(getKnownVariables(((FunctionDynamic) f).getParameters()));
|
||||
} else if (f instanceof FunctionSingle) {
|
||||
else if (f instanceof FunctionSingle)
|
||||
res.addAll(getKnownVariables(new Function[] { ((FunctionSingle) f).getParameter() }));
|
||||
} else if (f instanceof Variable) {
|
||||
if (((Variable) f).getType() == Variable.V_TYPE.CONSTANT) {
|
||||
if (!res.contains(f)) {
|
||||
else if (f instanceof Variable)
|
||||
if (((Variable) f).getType() == Variable.V_TYPE.CONSTANT)
|
||||
if (!res.contains(f))
|
||||
res.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ public class SolveForXScreen extends Screen {
|
||||
@SuppressWarnings("unused")
|
||||
private final MathInputScreen es;
|
||||
|
||||
public SolveForXScreen(MathInputScreen es) {
|
||||
public SolveForXScreen(final MathInputScreen es) {
|
||||
super();
|
||||
canBeInHistory = false;
|
||||
|
||||
@ -33,7 +33,7 @@ public class SolveForXScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRender(float dt) {
|
||||
public void beforeRender(final float dt) {
|
||||
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class SolveForXScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyPressedEvent k) {
|
||||
public boolean onKeyPressed(final KeyPressedEvent k) {
|
||||
switch (k.getKey()) {
|
||||
case LETTER_X:
|
||||
//TODO: far funzionare questa parte
|
||||
|
@ -9,67 +9,67 @@ public interface Function {
|
||||
|
||||
/**
|
||||
* Returns this function and its children in a string form.
|
||||
*
|
||||
*
|
||||
* @return This function and its children in a string form.
|
||||
*/
|
||||
@Override
|
||||
public String toString();
|
||||
String toString();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o);
|
||||
boolean equals(Object o);
|
||||
|
||||
/**
|
||||
* Deep clone this function.
|
||||
*
|
||||
*
|
||||
* @return A clone of this function.
|
||||
*/
|
||||
public Function clone();
|
||||
Function clone();
|
||||
|
||||
/**
|
||||
* Generic method to change a parameter in a known position.
|
||||
*
|
||||
*
|
||||
* @param index
|
||||
* parameter index.
|
||||
* @param var
|
||||
* parameter.
|
||||
* @return A new instance of this function.
|
||||
*/
|
||||
public Function setParameter(int index, Function var) throws IndexOutOfBoundsException;
|
||||
Function setParameter(int index, Function var) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Generic method to retrieve a parameter in a known position.
|
||||
*
|
||||
*
|
||||
* @param index
|
||||
* parameter index.
|
||||
* @return The requested parameter.
|
||||
*/
|
||||
public Function getParameter(int index) throws IndexOutOfBoundsException;
|
||||
Function getParameter(int index) throws IndexOutOfBoundsException;
|
||||
|
||||
/**
|
||||
* Retrieve the current Math Context used by this function
|
||||
*
|
||||
*
|
||||
* @return Calculator mathContext
|
||||
*/
|
||||
public MathContext getMathContext();
|
||||
MathContext getMathContext();
|
||||
|
||||
/**
|
||||
* Simplify the current function or it's children using the specified
|
||||
* <b>rule</b>
|
||||
*
|
||||
*
|
||||
* @param rule
|
||||
* @return A list of the resulting Functions if the rule is applicable and
|
||||
* something changed, <b>null</b> otherwise
|
||||
* @throws Error
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public ObjectArrayList<Function> simplify(Rule rule) throws Error, InterruptedException;
|
||||
ObjectArrayList<Function> simplify(Rule rule) throws Error, InterruptedException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
* Mathematical Context
|
||||
* @return An ArrayList of parsed Blocks
|
||||
* @throws Error
|
||||
*/
|
||||
public ObjectArrayList<Block> toBlock(MathContext context) throws Error;
|
||||
ObjectArrayList<Block> toBlock(MathContext context) throws Error;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user