From 1d4c2ec8a7433da956059ed558d80b1616c3fb38 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Mon, 15 Oct 2018 23:10:44 +0200 Subject: [PATCH] Removed useless dependencies --- Flow | 2 +- bigdecimal-math | 2 +- core/pom.xml | 8 +- .../java/it/cavallium/warppi/Platform.java | 18 +- .../it/cavallium/warppi/device/Keyboard.java | 126 ++-- .../warppi/device/KeyboardAWTValues.java | 700 ++++++++++++++++++ .../warppi/device/graphicengine/RAWFont.java | 16 - .../cavallium/warppi/gui/DisplayManager.java | 3 +- .../graphicengine/impl/common/PngSkin.java | 15 +- .../graphicengine/impl/common/RFTFont.java | 16 - .../java/it/cavallium/warppi/util/Utils.java | 54 -- desktop/pom.xml | 6 +- ...PngReader.java => DesktopImageReader.java} | 22 +- .../warppi/desktop/DesktopImageUtils.java | 16 + .../warppi/desktop/DesktopPlatform.java | 6 +- .../warppi/desktop/DesktopPngUtils.java | 14 - engine-jogl/pom.xml | 4 +- hardware/pom.xml | 6 +- ...ngReader.java => HardwareImageReader.java} | 6 +- .../warppi/hardware/HardwareImageUtils.java | 14 + .../warppi/hardware/HardwarePlatform.java | 6 +- .../warppi/hardware/HardwarePngUtils.java | 14 - pom.xml | 2 +- rules/pom.xml | 4 +- teavm/pom.xml | 6 +- ...VMPngReader.java => TeaVMImageReader.java} | 6 +- .../warppi/teavm/TeaVMImageUtils.java | 14 + .../cavallium/warppi/teavm/TeaVMPlatform.java | 6 +- .../cavallium/warppi/teavm/TeaVMPngUtils.java | 14 - util/pom.xml | 2 +- 30 files changed, 871 insertions(+), 257 deletions(-) create mode 100644 core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java rename desktop/src/main/java/it/cavallium/warppi/desktop/{DesktopPngReader.java => DesktopImageReader.java} (68%) create mode 100644 desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageUtils.java delete mode 100644 desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java rename hardware/src/main/java/it/cavallium/warppi/hardware/{HardwarePngReader.java => HardwareImageReader.java} (87%) create mode 100644 hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageUtils.java delete mode 100644 hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngUtils.java rename teavm/src/main/java/it/cavallium/warppi/teavm/{TeaVMPngReader.java => TeaVMImageReader.java} (87%) create mode 100644 teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageUtils.java delete mode 100644 teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java diff --git a/Flow b/Flow index 9acbcc2e..fc24680f 160000 --- a/Flow +++ b/Flow @@ -1 +1 @@ -Subproject commit 9acbcc2e0af4961688490eb3447d990d157a46a8 +Subproject commit fc24680f8f2178fa550174c75d7dbacb6065358c diff --git a/bigdecimal-math b/bigdecimal-math index 92a67122..b08a4a6a 160000 --- a/bigdecimal-math +++ b/bigdecimal-math @@ -1 +1 @@ -Subproject commit 92a67122350a38af726beae58d2582fb867a4c61 +Subproject commit b08a4a6aca41fbc6bf0c4bd252f716d518d368a5 diff --git a/core/pom.xml b/core/pom.xml index b4e2c2ca..39c3ca38 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -6,7 +6,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-core @@ -17,17 +17,17 @@ it.cavallium warppi-flow - 0.9.0a2 + 0.9.0a3 it.cavallium warppi-util - 0.9.0a2 + 0.9.0a3 it.cavallium bigdecimal-math - 0.9.0a2 + 0.9.0a3 it.unimi.dsi diff --git a/core/src/main/java/it/cavallium/warppi/Platform.java b/core/src/main/java/it/cavallium/warppi/Platform.java index 5951cfaf..47a4c906 100644 --- a/core/src/main/java/it/cavallium/warppi/Platform.java +++ b/core/src/main/java/it/cavallium/warppi/Platform.java @@ -20,7 +20,7 @@ public interface Platform { StorageUtils getStorageUtils(); - PngUtils getPngUtils(); + ImageUtils getImageUtils(); Settings getSettings(); @@ -171,19 +171,17 @@ public interface Platform { void close() throws IOException; } - - public interface PngUtils { - - PngReader load(InputStream resourceStream); - - public interface PngReader { - + + public interface ImageUtils { + + ImageReader load(InputStream resourceStream) throws IOException; + + public interface ImageReader { + int[] getImageMatrix(); int[] getSize(); - } - } public interface Settings { diff --git a/core/src/main/java/it/cavallium/warppi/device/Keyboard.java b/core/src/main/java/it/cavallium/warppi/device/Keyboard.java index 8aa67e43..3e91d26c 100644 --- a/core/src/main/java/it/cavallium/warppi/device/Keyboard.java +++ b/core/src/main/java/it/cavallium/warppi/device/Keyboard.java @@ -1,7 +1,5 @@ package it.cavallium.warppi.device; -import java.awt.event.KeyEvent; - import it.cavallium.warppi.Engine; import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.StaticVars; @@ -126,10 +124,10 @@ public class Keyboard { */ public static void debugKey(final int keyCode, boolean released) { switch (keyCode) { - case KeyEvent.VK_ESCAPE: + case KeyboardAWTValues.VK_ESCAPE: debugKey(Key.BACK, released); break; - case KeyEvent.VK_S: + case KeyboardAWTValues.VK_S: if (Keyboard.shift) { debugKey(Key.ARCSINE, released); } else if (Keyboard.alpha) { @@ -138,7 +136,7 @@ public class Keyboard { debugKey(Key.SINE, released); } break; - case KeyEvent.VK_C: + case KeyboardAWTValues.VK_C: if (Keyboard.shift) { debugKey(Key.ARCCOSINE, released); } else if (Keyboard.alpha) { @@ -147,7 +145,7 @@ public class Keyboard { debugKey(Key.COSINE, released); } break; - case KeyEvent.VK_T: + case KeyboardAWTValues.VK_T: if (Keyboard.shift) { debugKey(Key.ARCTANGENT, released); } else if (Keyboard.alpha) { @@ -156,7 +154,7 @@ public class Keyboard { debugKey(Key.TANGENT, released); } break; - case KeyEvent.VK_D: + case KeyboardAWTValues.VK_D: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.debug_DEG, released); } else if (Keyboard.alpha) { @@ -165,7 +163,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_R: + case KeyboardAWTValues.VK_R: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.debug_RAD, released); } else if (Keyboard.alpha) { @@ -174,7 +172,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_G: + case KeyboardAWTValues.VK_G: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.debug_GRA, released); } else if (Keyboard.alpha) { @@ -183,14 +181,14 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_X: + case KeyboardAWTValues.VK_X: if (Keyboard.alpha) { debugKey(Key.LETTER_X, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_P: + case KeyboardAWTValues.VK_P: if (Keyboard.shift) { debugKey(Key.NONE, released); } else if (Keyboard.alpha) { @@ -199,7 +197,7 @@ public class Keyboard { debugKey(Key.PI, released); } break; - case KeyEvent.VK_E: + case KeyboardAWTValues.VK_E: if (Keyboard.shift) { debugKey(Key.NONE, released); } else if (Keyboard.alpha) { @@ -208,14 +206,14 @@ public class Keyboard { debugKey(Key.EULER_NUMBER, released); } break; - case KeyEvent.VK_Y: + case KeyboardAWTValues.VK_Y: if (Keyboard.alpha) { debugKey(Key.LETTER_Y, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_B: + case KeyboardAWTValues.VK_B: if (Keyboard.shift) { debugKey(Key.BRIGHTNESS_CYCLE_REVERSE, released); } else if (!Keyboard.shift && !Keyboard.alpha) { @@ -224,7 +222,7 @@ public class Keyboard { debugKey(Key.LETTER_B, released); } break; - case KeyEvent.VK_L: + case KeyboardAWTValues.VK_L: if (Keyboard.shift) { debugKey(Key.LOGARITHM, released); } else if (Keyboard.alpha) { @@ -234,7 +232,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_ENTER: - case KeyEvent.VK_ENTER: + case KeyboardAWTValues.VK_ENTER: if (Keyboard.shift) { debugKey(Key.STEP, released); } else if (!Keyboard.shift && !Keyboard.alpha) { @@ -246,49 +244,49 @@ public class Keyboard { int col = 1; Keyboard.debugKeysDown[row - 1][col - 1] = true; break; - case KeyEvent.VK_1: + case KeyboardAWTValues.VK_1: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM1, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_2: + case KeyboardAWTValues.VK_2: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM2, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_3: + case KeyboardAWTValues.VK_3: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM3, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_4: + case KeyboardAWTValues.VK_4: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM4, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_5: + case KeyboardAWTValues.VK_5: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM5, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_6: + case KeyboardAWTValues.VK_6: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM6, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_7: + case KeyboardAWTValues.VK_7: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM7, released); } else if (Keyboard.shift) { @@ -297,7 +295,7 @@ public class Keyboard { } } break; - case KeyEvent.VK_8: + case KeyboardAWTValues.VK_8: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM8, released); } else if (Keyboard.shift) { @@ -306,7 +304,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_9: + case KeyboardAWTValues.VK_9: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM9, released); } else if (Keyboard.shift) { @@ -315,7 +313,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_0: + case KeyboardAWTValues.VK_0: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NUM0, released); } else if (Keyboard.shift) { @@ -324,7 +322,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_M: + case KeyboardAWTValues.VK_M: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.SURD_MODE, released); } else if (Keyboard.shift) { @@ -334,7 +332,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_ADD: - case KeyEvent.VK_ADD: + case KeyboardAWTValues.VK_ADD: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.PLUS, released); } else if (Keyboard.shift) { @@ -344,7 +342,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_SUBTRACT: - case KeyEvent.VK_SUBTRACT: + case KeyboardAWTValues.VK_SUBTRACT: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.MINUS, released); } else { @@ -352,7 +350,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_MULTIPLY: - case KeyEvent.VK_MULTIPLY: + case KeyboardAWTValues.VK_MULTIPLY: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.MULTIPLY, released); } else { @@ -360,18 +358,18 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_DIVIDE: - case KeyEvent.VK_DIVIDE: + case KeyboardAWTValues.VK_DIVIDE: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.DIVIDE, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_BACK_SPACE: + case KeyboardAWTValues.VK_BACK_SPACE: debugKey(Key.DELETE, released); break; case KeyboardJogampValues.VK_DELETE: - case KeyEvent.VK_DELETE: + case KeyboardAWTValues.VK_DELETE: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.RESET, released); } else { @@ -379,7 +377,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_LEFT: - case KeyEvent.VK_LEFT: + case KeyboardAWTValues.VK_LEFT: //LEFT row = 2; col = 3; @@ -391,7 +389,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_RIGHT: - case KeyEvent.VK_RIGHT: + case KeyboardAWTValues.VK_RIGHT: //RIGHT row = 2; col = 5; @@ -403,7 +401,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_UP: - case KeyEvent.VK_UP: + case KeyboardAWTValues.VK_UP: //UP row = 1; col = 4; @@ -415,7 +413,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_DOWN: - case KeyEvent.VK_DOWN: + case KeyboardAWTValues.VK_DOWN: //DOWN row = 3; col = 4; @@ -438,7 +436,7 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_NUMPAD4: - case KeyEvent.VK_NUMPAD4: + case KeyboardAWTValues.VK_NUMPAD4: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.HISTORY_BACK, released); } else { @@ -446,21 +444,21 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_NUMPAD6: - case KeyEvent.VK_NUMPAD6: + case KeyboardAWTValues.VK_NUMPAD6: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.HISTORY_FORWARD, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_PERIOD: + case KeyboardAWTValues.VK_PERIOD: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.DOT, released); } else { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_A: + case KeyboardAWTValues.VK_A: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -471,7 +469,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_F: + case KeyboardAWTValues.VK_F: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -482,7 +480,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_H: + case KeyboardAWTValues.VK_H: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -493,7 +491,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_I: + case KeyboardAWTValues.VK_I: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -504,7 +502,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_J: + case KeyboardAWTValues.VK_J: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -515,7 +513,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_K: + case KeyboardAWTValues.VK_K: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -526,7 +524,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_N: + case KeyboardAWTValues.VK_N: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -537,7 +535,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_O: + case KeyboardAWTValues.VK_O: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -548,7 +546,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_Q: + case KeyboardAWTValues.VK_Q: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -559,7 +557,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_U: + case KeyboardAWTValues.VK_U: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -570,7 +568,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_V: + case KeyboardAWTValues.VK_V: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -581,7 +579,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_W: + case KeyboardAWTValues.VK_W: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -592,7 +590,7 @@ public class Keyboard { debugKey(Key.NONE, released); } break; - case KeyEvent.VK_Z: + case KeyboardAWTValues.VK_Z: if (!Keyboard.shift && !Keyboard.alpha) { debugKey(Key.NONE, released); } else if (Keyboard.alpha && !Keyboard.shift) { @@ -604,26 +602,26 @@ public class Keyboard { } break; case KeyboardJogampValues.VK_SHIFT: - case KeyEvent.VK_SHIFT: + case KeyboardAWTValues.VK_SHIFT: debugKey(Key.SHIFT, released); break; - case KeyEvent.VK_CONTROL: + case KeyboardAWTValues.VK_CONTROL: debugKey(Key.ALPHA, released); break; case KeyboardJogampValues.VK_NUMPAD1: - case KeyEvent.VK_NUMPAD1: + case KeyboardAWTValues.VK_NUMPAD1: debugKey(Key.SQRT, released); break; case KeyboardJogampValues.VK_NUMPAD2: - case KeyEvent.VK_NUMPAD2: + case KeyboardAWTValues.VK_NUMPAD2: debugKey(Key.ROOT, released); break; case KeyboardJogampValues.VK_NUMPAD3: - case KeyEvent.VK_NUMPAD3: + case KeyboardAWTValues.VK_NUMPAD3: debugKey(Key.POWER_OF_2, released); break; case KeyboardJogampValues.VK_NUMPAD5: - case KeyEvent.VK_NUMPAD5: + case KeyboardAWTValues.VK_NUMPAD5: debugKey(Key.POWER_OF_x, released); break; } @@ -631,20 +629,20 @@ public class Keyboard { private synchronized static void debugKeyReleased(final int keyCode) { switch (keyCode) { - case KeyEvent.VK_ENTER: + case KeyboardAWTValues.VK_ENTER: int row = 2; int col = 1; Keyboard.debugKeysDown[row - 1][col - 1] = false; break; case KeyboardJogampValues.VK_LEFT: - case KeyEvent.VK_LEFT: + case KeyboardAWTValues.VK_LEFT: //LEFT row = 2; col = 3; Keyboard.debugKeysDown[row - 1][col - 1] = false; break; case KeyboardJogampValues.VK_RIGHT: - case KeyEvent.VK_RIGHT: + case KeyboardAWTValues.VK_RIGHT: //RIGHT row = 2; col = 5; @@ -652,14 +650,14 @@ public class Keyboard { System.out.println("RELEASE"); break; case KeyboardJogampValues.VK_UP: - case KeyEvent.VK_UP: + case KeyboardAWTValues.VK_UP: //UP row = 1; col = 4; Keyboard.debugKeysDown[row - 1][col - 1] = false; break; case KeyboardJogampValues.VK_DOWN: - case KeyEvent.VK_DOWN: + case KeyboardAWTValues.VK_DOWN: //DOWN row = 3; col = 4; diff --git a/core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java b/core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java new file mode 100644 index 00000000..083d0531 --- /dev/null +++ b/core/src/main/java/it/cavallium/warppi/device/KeyboardAWTValues.java @@ -0,0 +1,700 @@ +package it.cavallium.warppi.device; + +public interface KeyboardAWTValues { + + /** + * The first number in the range of ids used for key events. + */ + int KEY_FIRST = 400; + + /** + * The last number in the range of ids used for key events. + */ + int KEY_LAST = 402; + + /** + * The "key typed" event. This event is generated when a character is + * entered. In the simplest case, it is produced by a single key press. + * Often, however, characters are produced by series of key presses, and + * the mapping from key pressed events to key typed events may be + * many-to-one or many-to-many. + */ + int KEY_TYPED = KEY_FIRST; + + /** + * The "key pressed" event. This event is generated when a key + * is pushed down. + */ + int KEY_PRESSED = 1 + KEY_FIRST; //Event.KEY_PRESS + + /** + * The "key released" event. This event is generated when a key + * is let up. + */ + int KEY_RELEASED = 2 + KEY_FIRST; //Event.KEY_RELEASE + + /* Virtual key codes. */ + + int VK_ENTER = '\n'; + int VK_BACK_SPACE = '\b'; + int VK_TAB = '\t'; + int VK_CANCEL = 0x03; + int VK_CLEAR = 0x0C; + int VK_SHIFT = 0x10; + int VK_CONTROL = 0x11; + int VK_ALT = 0x12; + int VK_PAUSE = 0x13; + int VK_CAPS_LOCK = 0x14; + int VK_ESCAPE = 0x1B; + int VK_SPACE = 0x20; + int VK_PAGE_UP = 0x21; + int VK_PAGE_DOWN = 0x22; + int VK_END = 0x23; + int VK_HOME = 0x24; + + /** + * Constant for the non-numpad left arrow key. + * @see #VK_KP_LEFT + */ + int VK_LEFT = 0x25; + + /** + * Constant for the non-numpad up arrow key. + * @see #VK_KP_UP + */ + int VK_UP = 0x26; + + /** + * Constant for the non-numpad right arrow key. + * @see #VK_KP_RIGHT + */ + int VK_RIGHT = 0x27; + + /** + * Constant for the non-numpad down arrow key. + * @see #VK_KP_DOWN + */ + int VK_DOWN = 0x28; + + /** + * Constant for the comma key, "," + */ + int VK_COMMA = 0x2C; + + /** + * Constant for the minus key, "-" + * @since 1.2 + */ + int VK_MINUS = 0x2D; + + /** + * Constant for the period key, "." + */ + int VK_PERIOD = 0x2E; + + /** + * Constant for the forward slash key, "/" + */ + int VK_SLASH = 0x2F; + + /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ + int VK_0 = 0x30; + int VK_1 = 0x31; + int VK_2 = 0x32; + int VK_3 = 0x33; + int VK_4 = 0x34; + int VK_5 = 0x35; + int VK_6 = 0x36; + int VK_7 = 0x37; + int VK_8 = 0x38; + int VK_9 = 0x39; + + /** + * Constant for the semicolon key, ";" + */ + int VK_SEMICOLON = 0x3B; + + /** + * Constant for the equals key, "=" + */ + int VK_EQUALS = 0x3D; + + /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ + int VK_A = 0x41; + int VK_B = 0x42; + int VK_C = 0x43; + int VK_D = 0x44; + int VK_E = 0x45; + int VK_F = 0x46; + int VK_G = 0x47; + int VK_H = 0x48; + int VK_I = 0x49; + int VK_J = 0x4A; + int VK_K = 0x4B; + int VK_L = 0x4C; + int VK_M = 0x4D; + int VK_N = 0x4E; + int VK_O = 0x4F; + int VK_P = 0x50; + int VK_Q = 0x51; + int VK_R = 0x52; + int VK_S = 0x53; + int VK_T = 0x54; + int VK_U = 0x55; + int VK_V = 0x56; + int VK_W = 0x57; + int VK_X = 0x58; + int VK_Y = 0x59; + int VK_Z = 0x5A; + + /** + * Constant for the open bracket key, "[" + */ + int VK_OPEN_BRACKET = 0x5B; + + /** + * Constant for the back slash key, "\" + */ + int VK_BACK_SLASH = 0x5C; + + /** + * Constant for the close bracket key, "]" + */ + int VK_CLOSE_BRACKET = 0x5D; + + int VK_NUMPAD0 = 0x60; + int VK_NUMPAD1 = 0x61; + int VK_NUMPAD2 = 0x62; + int VK_NUMPAD3 = 0x63; + int VK_NUMPAD4 = 0x64; + int VK_NUMPAD5 = 0x65; + int VK_NUMPAD6 = 0x66; + int VK_NUMPAD7 = 0x67; + int VK_NUMPAD8 = 0x68; + int VK_NUMPAD9 = 0x69; + int VK_MULTIPLY = 0x6A; + int VK_ADD = 0x6B; + + /** + * This constant is obsolete, and is included only for backwards + * compatibility. + * @see #VK_SEPARATOR + */ + int VK_SEPARATER = 0x6C; + + /** + * Constant for the Numpad Separator key. + * @since 1.4 + */ + int VK_SEPARATOR = VK_SEPARATER; + + int VK_SUBTRACT = 0x6D; + int VK_DECIMAL = 0x6E; + int VK_DIVIDE = 0x6F; + int VK_DELETE = 0x7F; /* ASCII DEL */ + int VK_NUM_LOCK = 0x90; + int VK_SCROLL_LOCK = 0x91; + + /** Constant for the F1 function key. */ + int VK_F1 = 0x70; + + /** Constant for the F2 function key. */ + int VK_F2 = 0x71; + + /** Constant for the F3 function key. */ + int VK_F3 = 0x72; + + /** Constant for the F4 function key. */ + int VK_F4 = 0x73; + + /** Constant for the F5 function key. */ + int VK_F5 = 0x74; + + /** Constant for the F6 function key. */ + int VK_F6 = 0x75; + + /** Constant for the F7 function key. */ + int VK_F7 = 0x76; + + /** Constant for the F8 function key. */ + int VK_F8 = 0x77; + + /** Constant for the F9 function key. */ + int VK_F9 = 0x78; + + /** Constant for the F10 function key. */ + int VK_F10 = 0x79; + + /** Constant for the F11 function key. */ + int VK_F11 = 0x7A; + + /** Constant for the F12 function key. */ + int VK_F12 = 0x7B; + + /** + * Constant for the F13 function key. + * @since 1.2 + */ + /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */ + int VK_F13 = 0xF000; + + /** + * Constant for the F14 function key. + * @since 1.2 + */ + int VK_F14 = 0xF001; + + /** + * Constant for the F15 function key. + * @since 1.2 + */ + int VK_F15 = 0xF002; + + /** + * Constant for the F16 function key. + * @since 1.2 + */ + int VK_F16 = 0xF003; + + /** + * Constant for the F17 function key. + * @since 1.2 + */ + int VK_F17 = 0xF004; + + /** + * Constant for the F18 function key. + * @since 1.2 + */ + int VK_F18 = 0xF005; + + /** + * Constant for the F19 function key. + * @since 1.2 + */ + int VK_F19 = 0xF006; + + /** + * Constant for the F20 function key. + * @since 1.2 + */ + int VK_F20 = 0xF007; + + /** + * Constant for the F21 function key. + * @since 1.2 + */ + int VK_F21 = 0xF008; + + /** + * Constant for the F22 function key. + * @since 1.2 + */ + int VK_F22 = 0xF009; + + /** + * Constant for the F23 function key. + * @since 1.2 + */ + int VK_F23 = 0xF00A; + + /** + * Constant for the F24 function key. + * @since 1.2 + */ + int VK_F24 = 0xF00B; + + int VK_PRINTSCREEN = 0x9A; + int VK_INSERT = 0x9B; + int VK_HELP = 0x9C; + int VK_META = 0x9D; + + int VK_BACK_QUOTE = 0xC0; + int VK_QUOTE = 0xDE; + + /** + * Constant for the numeric keypad up arrow key. + * @see #VK_UP + * @since 1.2 + */ + int VK_KP_UP = 0xE0; + + /** + * Constant for the numeric keypad down arrow key. + * @see #VK_DOWN + * @since 1.2 + */ + int VK_KP_DOWN = 0xE1; + + /** + * Constant for the numeric keypad left arrow key. + * @see #VK_LEFT + * @since 1.2 + */ + int VK_KP_LEFT = 0xE2; + + /** + * Constant for the numeric keypad right arrow key. + * @see #VK_RIGHT + * @since 1.2 + */ + int VK_KP_RIGHT = 0xE3; + + /* For European keyboards */ + /** @since 1.2 */ + int VK_DEAD_GRAVE = 0x80; + /** @since 1.2 */ + int VK_DEAD_ACUTE = 0x81; + /** @since 1.2 */ + int VK_DEAD_CIRCUMFLEX = 0x82; + /** @since 1.2 */ + int VK_DEAD_TILDE = 0x83; + /** @since 1.2 */ + int VK_DEAD_MACRON = 0x84; + /** @since 1.2 */ + int VK_DEAD_BREVE = 0x85; + /** @since 1.2 */ + int VK_DEAD_ABOVEDOT = 0x86; + /** @since 1.2 */ + int VK_DEAD_DIAERESIS = 0x87; + /** @since 1.2 */ + int VK_DEAD_ABOVERING = 0x88; + /** @since 1.2 */ + int VK_DEAD_DOUBLEACUTE = 0x89; + /** @since 1.2 */ + int VK_DEAD_CARON = 0x8a; + /** @since 1.2 */ + int VK_DEAD_CEDILLA = 0x8b; + /** @since 1.2 */ + int VK_DEAD_OGONEK = 0x8c; + /** @since 1.2 */ + int VK_DEAD_IOTA = 0x8d; + /** @since 1.2 */ + int VK_DEAD_VOICED_SOUND = 0x8e; + /** @since 1.2 */ + int VK_DEAD_SEMIVOICED_SOUND = 0x8f; + + /** @since 1.2 */ + int VK_AMPERSAND = 0x96; + /** @since 1.2 */ + int VK_ASTERISK = 0x97; + /** @since 1.2 */ + int VK_QUOTEDBL = 0x98; + /** @since 1.2 */ + int VK_LESS = 0x99; + + /** @since 1.2 */ + int VK_GREATER = 0xa0; + /** @since 1.2 */ + int VK_BRACELEFT = 0xa1; + /** @since 1.2 */ + int VK_BRACERIGHT = 0xa2; + + /** + * Constant for the "@" key. + * @since 1.2 + */ + int VK_AT = 0x0200; + + /** + * Constant for the ":" key. + * @since 1.2 + */ + int VK_COLON = 0x0201; + + /** + * Constant for the "^" key. + * @since 1.2 + */ + int VK_CIRCUMFLEX = 0x0202; + + /** + * Constant for the "$" key. + * @since 1.2 + */ + int VK_DOLLAR = 0x0203; + + /** + * Constant for the Euro currency sign key. + * @since 1.2 + */ + int VK_EURO_SIGN = 0x0204; + + /** + * Constant for the "!" key. + * @since 1.2 + */ + int VK_EXCLAMATION_MARK = 0x0205; + + /** + * Constant for the inverted exclamation mark key. + * @since 1.2 + */ + int VK_INVERTED_EXCLAMATION_MARK = 0x0206; + + /** + * Constant for the "(" key. + * @since 1.2 + */ + int VK_LEFT_PARENTHESIS = 0x0207; + + /** + * Constant for the "#" key. + * @since 1.2 + */ + int VK_NUMBER_SIGN = 0x0208; + + /** + * Constant for the "+" key. + * @since 1.2 + */ + int VK_PLUS = 0x0209; + + /** + * Constant for the ")" key. + * @since 1.2 + */ + int VK_RIGHT_PARENTHESIS = 0x020A; + + /** + * Constant for the "_" key. + * @since 1.2 + */ + int VK_UNDERSCORE = 0x020B; + + /** + * Constant for the Microsoft Windows "Windows" key. + * It is used for both the left and right version of the key. + * @see #getKeyLocation() + * @since 1.5 + */ + int VK_WINDOWS = 0x020C; + + /** + * Constant for the Microsoft Windows Context Menu key. + * @since 1.5 + */ + int VK_CONTEXT_MENU = 0x020D; + + /* for input method support on Asian Keyboards */ + + /* not clear what this means - listed in Microsoft Windows API */ + int VK_FINAL = 0x0018; + + /** Constant for the Convert function key. */ + /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */ + int VK_CONVERT = 0x001C; + + /** Constant for the Don't Convert function key. */ + /* Japanese PC 106 keyboard: muhenkan */ + int VK_NONCONVERT = 0x001D; + + /** Constant for the Accept or Commit function key. */ + /* Japanese Solaris keyboard: kakutei */ + int VK_ACCEPT = 0x001E; + + /* not clear what this means - listed in Microsoft Windows API */ + int VK_MODECHANGE = 0x001F; + + /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris; + might still be used on other platforms */ + int VK_KANA = 0x0015; + + /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris; + might still be used for other platforms */ + int VK_KANJI = 0x0019; + + /** + * Constant for the Alphanumeric function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard: eisuu */ + int VK_ALPHANUMERIC = 0x00F0; + + /** + * Constant for the Katakana function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard: katakana */ + int VK_KATAKANA = 0x00F1; + + /** + * Constant for the Hiragana function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard: hiragana */ + int VK_HIRAGANA = 0x00F2; + + /** + * Constant for the Full-Width Characters function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard: zenkaku */ + int VK_FULL_WIDTH = 0x00F3; + + /** + * Constant for the Half-Width Characters function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard: hankaku */ + int VK_HALF_WIDTH = 0x00F4; + + /** + * Constant for the Roman Characters function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard: roumaji */ + int VK_ROMAN_CHARACTERS = 0x00F5; + + /** + * Constant for the All Candidates function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ + int VK_ALL_CANDIDATES = 0x0100; + + /** + * Constant for the Previous Candidate function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ + int VK_PREVIOUS_CANDIDATE = 0x0101; + + /** + * Constant for the Code Input function key. + * @since 1.2 + */ + /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ + int VK_CODE_INPUT = 0x0102; + + /** + * Constant for the Japanese-Katakana function key. + * This key switches to a Japanese input method and selects its Katakana input mode. + * @since 1.2 + */ + /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ + int VK_JAPANESE_KATAKANA = 0x0103; + + /** + * Constant for the Japanese-Hiragana function key. + * This key switches to a Japanese input method and selects its Hiragana input mode. + * @since 1.2 + */ + /* Japanese Macintosh keyboard */ + int VK_JAPANESE_HIRAGANA = 0x0104; + + /** + * Constant for the Japanese-Roman function key. + * This key switches to a Japanese input method and selects its Roman-Direct input mode. + * @since 1.2 + */ + /* Japanese Macintosh keyboard */ + int VK_JAPANESE_ROMAN = 0x0105; + + /** + * Constant for the locking Kana function key. + * This key locks the keyboard into a Kana layout. + * @since 1.3 + */ + /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ + int VK_KANA_LOCK = 0x0106; + + /** + * Constant for the input method on/off key. + * @since 1.3 + */ + /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ + int VK_INPUT_METHOD_ON_OFF = 0x0107; + + /* for Sun keyboards */ + /** @since 1.2 */ + int VK_CUT = 0xFFD1; + /** @since 1.2 */ + int VK_COPY = 0xFFCD; + /** @since 1.2 */ + int VK_PASTE = 0xFFCF; + /** @since 1.2 */ + int VK_UNDO = 0xFFCB; + /** @since 1.2 */ + int VK_AGAIN = 0xFFC9; + /** @since 1.2 */ + int VK_FIND = 0xFFD0; + /** @since 1.2 */ + int VK_PROPS = 0xFFCA; + /** @since 1.2 */ + int VK_STOP = 0xFFC8; + + /** + * Constant for the Compose function key. + * @since 1.2 + */ + int VK_COMPOSE = 0xFF20; + + /** + * Constant for the AltGraph function key. + * @since 1.2 + */ + int VK_ALT_GRAPH = 0xFF7E; + + /** + * Constant for the Begin key. + * @since 1.5 + */ + int VK_BEGIN = 0xFF58; + + /** + * This value is used to indicate that the keyCode is unknown. + * KEY_TYPED events do not have a keyCode value; this value + * is used instead. + */ + int VK_UNDEFINED = 0x0; + + /** + * KEY_PRESSED and KEY_RELEASED events which do not map to a + * valid Unicode character use this for the keyChar value. + */ + char CHAR_UNDEFINED = 0xFFFF; + + /** + * A constant indicating that the keyLocation is indeterminate + * or not relevant. + * KEY_TYPED events do not have a keyLocation; this value + * is used instead. + * @since 1.4 + */ + int KEY_LOCATION_UNKNOWN = 0; + + /** + * A constant indicating that the key pressed or released + * is not distinguished as the left or right version of a key, + * and did not originate on the numeric keypad (or did not + * originate with a virtual key corresponding to the numeric + * keypad). + * @since 1.4 + */ + int KEY_LOCATION_STANDARD = 1; + + /** + * A constant indicating that the key pressed or released is in + * the left key location (there is more than one possible location + * for this key). Example: the left shift key. + * @since 1.4 + */ + int KEY_LOCATION_LEFT = 2; + + /** + * A constant indicating that the key pressed or released is in + * the right key location (there is more than one possible location + * for this key). Example: the right shift key. + * @since 1.4 + */ + int KEY_LOCATION_RIGHT = 3; + + /** + * A constant indicating that the key event originated on the + * numeric keypad or with a virtual key corresponding to the + * numeric keypad. + * @since 1.4 + */ + int KEY_LOCATION_NUMPAD = 4; +} diff --git a/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java b/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java index 1be75b02..d344d79a 100644 --- a/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java +++ b/core/src/main/java/it/cavallium/warppi/device/graphicengine/RAWFont.java @@ -1,7 +1,5 @@ package it.cavallium.warppi.device.graphicengine; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; import java.io.File; import java.io.IOException; import java.lang.ref.WeakReference; @@ -9,8 +7,6 @@ import java.net.URL; import java.util.logging.Level; import java.util.logging.Logger; -import javax.imageio.ImageIO; - import it.cavallium.warppi.Engine; import it.cavallium.warppi.util.ClassUtils; import it.cavallium.warppi.util.Utils; @@ -135,18 +131,6 @@ public class RAWFont { return indexes; } - @SuppressWarnings("unused") - 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); - try { - ImageIO.write(bi, "PNG", new File(coutputpng)); - } catch (final IOException ex) { - Logger.getLogger(RAWFont.class.getName()).log(Level.SEVERE, null, ex); - } - } - 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; diff --git a/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java index faa26d33..55647aa6 100644 --- a/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java +++ b/core/src/main/java/it/cavallium/warppi/gui/DisplayManager.java @@ -5,14 +5,13 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; -import org.apache.commons.lang3.tuple.Pair; - import it.cavallium.warppi.Engine; import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.Platform.Semaphore; import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.device.Keyboard; import it.cavallium.warppi.flow.Observable; +import it.cavallium.warppi.flow.Pair; import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.Renderer; diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java index c90c8504..78a4fba0 100644 --- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java +++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/PngSkin.java @@ -1,14 +1,10 @@ package it.cavallium.warppi.gui.graphicengine.impl.common; -import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; - -import javax.imageio.ImageIO; import it.cavallium.warppi.Engine; -import it.cavallium.warppi.Platform.PngUtils.PngReader; +import it.cavallium.warppi.Platform.ImageUtils.ImageReader; import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.Skin; @@ -29,14 +25,7 @@ public abstract class PngSkin implements Skin { if (!file.startsWith("/")) { file = "/" + file; } - if (!file.endsWith(".png")) { - final File f = File.createTempFile("picalculator-png", ".png"); - f.deleteOnExit(); - final BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream(file)); - ImageIO.write(img, "PNG", f); - file = f.toString(); - } - final PngReader r = Engine.getPlatform().getPngUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file)); + final ImageReader r = Engine.getPlatform().getImageUtils().load(Engine.getPlatform().getStorageUtils().getResourceStream(file)); if (r == null) { skinData = new int[0]; skinSize = new int[] { 0, 0 }; diff --git a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java index af68f9cd..a2baae3a 100644 --- a/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java +++ b/core/src/main/java/it/cavallium/warppi/gui/graphicengine/impl/common/RFTFont.java @@ -1,7 +1,5 @@ package it.cavallium.warppi.gui.graphicengine.impl.common; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -10,8 +8,6 @@ import java.util.LinkedList; import java.util.logging.Level; import java.util.logging.Logger; -import javax.imageio.ImageIO; - import it.cavallium.warppi.Engine; import it.cavallium.warppi.Platform.ConsoleUtils; import it.cavallium.warppi.gui.graphicengine.BinaryFont; @@ -223,18 +219,6 @@ public abstract class RFTFont implements BinaryFont { } } - @SuppressWarnings("unused") - 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); - try { - ImageIO.write(bi, "PNG", new File(coutputpng)); - } catch (final IOException ex) { - Logger.getLogger(BinaryFont.class.getName()).log(Level.SEVERE, null, ex); - } - } - public int[] getCharIndexes(final String txt) { final int l = txt.length(); final int[] indexes = new int[l]; diff --git a/core/src/main/java/it/cavallium/warppi/util/Utils.java b/core/src/main/java/it/cavallium/warppi/util/Utils.java index c1d195a6..0336f252 100644 --- a/core/src/main/java/it/cavallium/warppi/util/Utils.java +++ b/core/src/main/java/it/cavallium/warppi/util/Utils.java @@ -4,15 +4,10 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.lang.management.ManagementFactory; -import java.lang.management.OperatingSystemMXBean; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.net.URISyntaxException; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -571,55 +566,6 @@ public class Utils { return sdata; } - public static void printSystemResourcesUsage() { - System.out.println("============"); - final OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); - for (final Method method : operatingSystemMXBean.getClass().getDeclaredMethods()) { - method.setAccessible(true); - if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) { - Object value; - try { - value = method.invoke(operatingSystemMXBean); - } catch (final Exception e) { - value = e; - } // try - boolean percent = false; - boolean mb = false; - final String displayName = method.getName(); - final String displayValue = value.toString(); - if (displayName.endsWith("CpuLoad")) { - percent = true; - } - if (displayName.endsWith("MemorySize")) { - mb = true; - } - final List arr = new ArrayList<>(); - arr.add("getFreePhysicalMemorySize"); - arr.add("getProcessCpuLoad"); - arr.add("getSystemCpuLoad"); - arr.add("getTotalPhysicalMemorySize"); - if (arr.contains(displayName)) { - if (percent) { - try { - System.out.println(displayName + " = " + (int) (Float.parseFloat(displayValue) * 10000f) / 100f + "%"); - } catch (final Exception ex) { - System.out.println(displayName + " = " + displayValue); - } - } else if (mb) { - try { - System.out.println(displayName + " = " + Long.parseLong(displayValue) / 1024L / 1024L + " MB"); - } catch (final Exception ex) { - System.out.println(displayName + " = " + displayValue); - } - } else { - System.out.println(displayName + " = " + displayValue); - } - } - } // if - } // for - System.out.println("============"); - } - public static boolean isWindows() { return Engine.getPlatform().getOsName().indexOf("win") >= 0; } diff --git a/desktop/pom.xml b/desktop/pom.xml index c16aa18e..c54f0525 100644 --- a/desktop/pom.xml +++ b/desktop/pom.xml @@ -6,7 +6,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-desktop @@ -16,12 +16,12 @@ it.cavallium warppi-core - 0.9.0a2 + 0.9.0a3 it.cavallium warppi-engine-jogl - 0.9.0a2 + 0.9.0a3 org.fusesource.jansi diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngReader.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java similarity index 68% rename from desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngReader.java rename to desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java index 26596ca5..feb4e75a 100644 --- a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngReader.java +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageReader.java @@ -1,16 +1,30 @@ package it.cavallium.warppi.desktop; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; import java.io.InputStream; +import javax.imageio.ImageIO; + import ar.com.hjg.pngj.ImageLineInt; -import it.cavallium.warppi.Platform.PngUtils.PngReader; +import it.cavallium.warppi.Engine; +import it.cavallium.warppi.Platform.ImageUtils.ImageReader; -public class DesktopPngReader implements PngReader { +public class DesktopImageReader implements ImageReader { - private final ar.com.hjg.pngj.PngReader r; + private ar.com.hjg.pngj.PngReader r; - public DesktopPngReader(final InputStream resourceStream) { + public DesktopImageReader(final InputStream resourceStream) throws IOException { r = new ar.com.hjg.pngj.PngReader(resourceStream); + // Try to read image converting it to png + if (r == null) { + final File f = File.createTempFile("picalculator-png", ".png"); + f.deleteOnExit(); + final BufferedImage img = ImageIO.read(resourceStream); + ImageIO.write(img, "PNG", f); + r = new ar.com.hjg.pngj.PngReader(f); + } } @Override diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageUtils.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageUtils.java new file mode 100644 index 00000000..7caac9d0 --- /dev/null +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopImageUtils.java @@ -0,0 +1,16 @@ +package it.cavallium.warppi.desktop; + +import java.io.IOException; +import java.io.InputStream; + +import it.cavallium.warppi.Platform.ImageUtils.ImageReader; +import it.cavallium.warppi.Platform.ImageUtils; + +public class DesktopImageUtils implements ImageUtils { + + @Override + public ImageReader load(final InputStream resourceStream) throws IOException { + return new DesktopImageReader(resourceStream); + } + +} diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java index c162f425..c08ec638 100644 --- a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java +++ b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPlatform.java @@ -26,7 +26,7 @@ public class DesktopPlatform implements Platform { private final DesktopConsoleUtils cu; private final DesktopGpio gi; private final DesktopStorageUtils su; - private final PngUtils pu; + private final ImageUtils pu; private final String on; private final Map el; private final DesktopSettings settings; @@ -36,7 +36,7 @@ public class DesktopPlatform implements Platform { cu = new DesktopConsoleUtils(); gi = new DesktopGpio(); su = new DesktopStorageUtils(); - pu = new DesktopPngUtils(); + pu = new DesktopImageUtils(); on = System.getProperty("os.name").toLowerCase(); el = new HashMap<>(); el.put("CPU engine", new SwingEngine()); @@ -60,7 +60,7 @@ public class DesktopPlatform implements Platform { } @Override - public PngUtils getPngUtils() { + public ImageUtils getImageUtils() { return pu; } diff --git a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java b/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java deleted file mode 100644 index a7ea6da4..00000000 --- a/desktop/src/main/java/it/cavallium/warppi/desktop/DesktopPngUtils.java +++ /dev/null @@ -1,14 +0,0 @@ -package it.cavallium.warppi.desktop; - -import java.io.InputStream; - -import it.cavallium.warppi.Platform.PngUtils; - -public class DesktopPngUtils implements PngUtils { - - @Override - public PngReader load(final InputStream resourceStream) { - return new DesktopPngReader(resourceStream); - } - -} diff --git a/engine-jogl/pom.xml b/engine-jogl/pom.xml index aa7a3f36..aeb6cab0 100644 --- a/engine-jogl/pom.xml +++ b/engine-jogl/pom.xml @@ -6,7 +6,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-engine-jogl @@ -16,7 +16,7 @@ it.cavallium warppi-core - 0.9.0a2 + 0.9.0a3 org.jogamp.jogl diff --git a/hardware/pom.xml b/hardware/pom.xml index e51cb1f7..26ab8ed6 100644 --- a/hardware/pom.xml +++ b/hardware/pom.xml @@ -6,7 +6,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-hardware @@ -18,12 +18,12 @@ it.cavallium warppi-core - 0.9.0a2 + 0.9.0a3 it.cavallium warppi-engine-jogl - 0.9.0a2 + 0.9.0a3 com.pi4j diff --git a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngReader.java b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageReader.java similarity index 87% rename from hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngReader.java rename to hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageReader.java index 30043b0b..61e944d7 100644 --- a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngReader.java +++ b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageReader.java @@ -3,13 +3,13 @@ package it.cavallium.warppi.hardware; import java.io.InputStream; import ar.com.hjg.pngj.ImageLineInt; -import it.cavallium.warppi.Platform.PngUtils.PngReader; +import it.cavallium.warppi.Platform.ImageUtils.ImageReader; -public class HardwarePngReader implements PngReader { +public class HardwareImageReader implements ImageReader { private final ar.com.hjg.pngj.PngReader r; - public HardwarePngReader(final InputStream resourceStream) { + public HardwareImageReader(final InputStream resourceStream) { r = new ar.com.hjg.pngj.PngReader(resourceStream); } diff --git a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageUtils.java b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageUtils.java new file mode 100644 index 00000000..586a870a --- /dev/null +++ b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwareImageUtils.java @@ -0,0 +1,14 @@ +package it.cavallium.warppi.hardware; + +import java.io.InputStream; + +import it.cavallium.warppi.Platform.ImageUtils; + +public class HardwareImageUtils implements ImageUtils { + + @Override + public ImageReader load(final InputStream resourceStream) { + return new HardwareImageReader(resourceStream); + } + +} diff --git a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java index 75aa321c..cbbf986d 100644 --- a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java +++ b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePlatform.java @@ -21,7 +21,7 @@ public class HardwarePlatform implements Platform { private final HardwareConsoleUtils cu; private final HardwareGpio gi; private final HardwareStorageUtils su; - private final PngUtils pu; + private final ImageUtils pu; private final String on; private final Map el; private final HardwareSettings settings; @@ -31,7 +31,7 @@ public class HardwarePlatform implements Platform { cu = new HardwareConsoleUtils(); gi = new HardwareGpio(); su = new HardwareStorageUtils(); - pu = new HardwarePngUtils(); + pu = new HardwareImageUtils(); on = System.getProperty("os.name").toLowerCase(); el = new HashMap<>(); el.put("GPU engine", new JOGLEngine()); @@ -55,7 +55,7 @@ public class HardwarePlatform implements Platform { } @Override - public PngUtils getPngUtils() { + public ImageUtils getImageUtils() { return pu; } diff --git a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngUtils.java b/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngUtils.java deleted file mode 100644 index c5943f17..00000000 --- a/hardware/src/main/java/it/cavallium/warppi/hardware/HardwarePngUtils.java +++ /dev/null @@ -1,14 +0,0 @@ -package it.cavallium.warppi.hardware; - -import java.io.InputStream; - -import it.cavallium.warppi.Platform.PngUtils; - -public class HardwarePngUtils implements PngUtils { - - @Override - public PngReader load(final InputStream resourceStream) { - return new HardwarePngReader(resourceStream); - } - -} diff --git a/pom.xml b/pom.xml index daf4c2cb..c1f1acbf 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 pom WarpPI Calculator diff --git a/rules/pom.xml b/rules/pom.xml index 52156d1d..437da7d6 100644 --- a/rules/pom.xml +++ b/rules/pom.xml @@ -6,7 +6,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-rules @@ -17,7 +17,7 @@ it.cavallium warppi-core - 0.9.0a2 + 0.9.0a3 diff --git a/teavm/pom.xml b/teavm/pom.xml index fc8c9325..d3212794 100644 --- a/teavm/pom.xml +++ b/teavm/pom.xml @@ -6,7 +6,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-teavm jar @@ -17,12 +17,12 @@ it.cavallium warppi-core - 0.9.0a2 + 0.9.0a3 it.cavallium warppi-rules - 0.9.0a2 + 0.9.0a3 org.teavm diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngReader.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageReader.java similarity index 87% rename from teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngReader.java rename to teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageReader.java index 2c21fce7..f0c1cff4 100644 --- a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngReader.java +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageReader.java @@ -3,13 +3,13 @@ package it.cavallium.warppi.teavm; import java.io.InputStream; import ar.com.hjg.pngj.ImageLineInt; -import it.cavallium.warppi.Platform.PngUtils.PngReader; +import it.cavallium.warppi.Platform.ImageUtils.ImageReader; -public class TeaVMPngReader implements PngReader { +public class TeaVMImageReader implements ImageReader { private final ar.com.hjg.pngj.PngReader r; - public TeaVMPngReader(final InputStream resourceStream) { + public TeaVMImageReader(final InputStream resourceStream) { r = new ar.com.hjg.pngj.PngReader(resourceStream); } diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageUtils.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageUtils.java new file mode 100644 index 00000000..9b0b493b --- /dev/null +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMImageUtils.java @@ -0,0 +1,14 @@ +package it.cavallium.warppi.teavm; + +import java.io.InputStream; + +import it.cavallium.warppi.Platform.ImageUtils; + +public class TeaVMImageUtils implements ImageUtils { + + @Override + public ImageReader load(final InputStream resourceStream) { + return new TeaVMImageReader(resourceStream); + } + +} diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java index d63899ae..b60fc0ff 100644 --- a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java +++ b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPlatform.java @@ -21,7 +21,7 @@ public class TeaVMPlatform implements Platform { private final TeaVMStorageUtils su; private final String on; private final Map el; - private final TeaVMPngUtils pu; + private final TeaVMImageUtils pu; private final TeaVMSettings settings; private Boolean runningOnRaspberryOverride = null; @@ -29,7 +29,7 @@ public class TeaVMPlatform implements Platform { cu = new TeaVMConsoleUtils(); gi = new TeaVMGpio(); su = new TeaVMStorageUtils(); - pu = new TeaVMPngUtils(); + pu = new TeaVMImageUtils(); on = "JavaScript"; el = new HashMap<>(); el.put("HTML5 engine", new HtmlEngine()); @@ -52,7 +52,7 @@ public class TeaVMPlatform implements Platform { } @Override - public PngUtils getPngUtils() { + public ImageUtils getImageUtils() { return pu; } diff --git a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java b/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java deleted file mode 100644 index 6378dc2d..00000000 --- a/teavm/src/main/java/it/cavallium/warppi/teavm/TeaVMPngUtils.java +++ /dev/null @@ -1,14 +0,0 @@ -package it.cavallium.warppi.teavm; - -import java.io.InputStream; - -import it.cavallium.warppi.Platform.PngUtils; - -public class TeaVMPngUtils implements PngUtils { - - @Override - public PngReader load(final InputStream resourceStream) { - return new TeaVMPngReader(resourceStream); - } - -} diff --git a/util/pom.xml b/util/pom.xml index 84e1c6a6..42cdcab3 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -7,7 +7,7 @@ it.cavallium warppi - 0.9.0a2 + 0.9.0a3 warppi-util