Renamed graphic engine packages

This commit is contained in:
Andrea Cavalli 2018-09-22 10:29:40 +02:00
parent 248842727e
commit 1b1cfa08fa
45 changed files with 376 additions and 603 deletions

View File

@ -695,7 +695,7 @@ public class Keyboard {
{"", null, null }, /* 2,1 */ {"", null, null }, /* 2,1 */
{"", null, null }, /* 2,2 */ {"", null, null }, /* 2,2 */
{"", null, null }, /* 2,3 */ {"", null, null }, /* 2,3 */
{"", null, null }, /* 2,4 */ {"", null, null }, /* 2,4 */
{"", null, null }, /* 2,5 */ {"", null, null }, /* 2,5 */
{"", null, null }, /* 2,6 */ {"", null, null }, /* 2,6 */
{"", null, null } /* 2,7 */ {"", null, null } /* 2,7 */

View File

@ -17,7 +17,7 @@ import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop; import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.graphicengine.nogui.NoGuiEngine; import it.cavallium.warppi.gui.graphicengine.impl.nogui.NoGuiEngine;
import it.cavallium.warppi.gui.screens.Screen; import it.cavallium.warppi.gui.screens.Screen;
import it.cavallium.warppi.util.Utils; import it.cavallium.warppi.util.Utils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectArrayList;

View File

@ -232,7 +232,9 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
final BlockReference<?> selectedBlock = getSelectedBlock(); final BlockReference<?> selectedBlock = getSelectedBlock();
if (selectedBlock != null) { if (selectedBlock != null) {
extra = selectedBlock.get().getExtraMenu(); extra = selectedBlock.get().getExtraMenu();
extra.open(); if (extra != null) {
extra.open();
}
} }
} else { } else {
extra.close(); extra.close();

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.common; package it.cavallium.warppi.gui.graphicengine.impl.common;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.common; package it.cavallium.warppi.gui.graphicengine.impl.common;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt; import java.awt.image.DataBufferInt;

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.nogui; package it.cavallium.warppi.gui.graphicengine.impl.nogui;
import java.io.IOException; import java.io.IOException;

View File

@ -183,6 +183,12 @@ public class MathInputScreen extends Screen {
mustRefresh = true; mustRefresh = true;
return true; return true;
} }
case BACK:
if (userInput.isExtraOpened()) {
userInput.closeExtra();
mustRefresh = true;
return true;
}
default: default:
if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().onKeyPressed(k)) { if (userInput.isExtraOpened() && userInput.getExtraKeyboardEventListener().onKeyPressed(k)) {
currentStep = 0; currentStep = 0;

View File

@ -3,239 +3,4 @@ package it.cavallium.warppi.util;
public class ClassUtils { public class ClassUtils {
public static Class<?> classLoader; public static Class<?> classLoader;
/*
public static Object invokeStaticMethod(String path, Var<?>... vars) {
return invokeMethod(path, null, vars);
}
@SuppressWarnings("rawtypes")
public static Object invokeMethod(String path, Object instance, Var<?>... vars) {
Class[] classes = new Class[vars.length];
Object[] objects = new Object[vars.length];
String[] blob = path.split("\\.");
String className = String.join(".", Arrays.copyOfRange(blob, 0, blob.length - 1));
String methodName = blob[blob.length - 1];
int index = 0;
for (Var<?> v : vars) {
classes[index] = v.getType();
objects[index] = v.getVar();
index++;
}
try {
return classLoader.getClassLoader().loadClass(className).getMethod(methodName, classes).invoke(instance, objects);
} catch (InvocationTargetException ex) {
NullPointerException exc = new NullPointerException();
exc.addSuppressed(ex);
throw exc;
} catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | ClassNotFoundException e) {
e.printStackTrace();
NullPointerException exc = new NullPointerException();
exc.addSuppressed(e);
throw exc;
}
}
@SuppressWarnings("rawtypes")
public static Object newClassInstance(String className, Var<?>... vars) {
Class[] classes = new Class[vars.length];
Object[] objects = new Object[vars.length];
int index = 0;
for (Var<?> v : vars) {
classes[index] = v.getType();
objects[index] = v.getVar();
index++;
}
try {
return classLoader.getClassLoader().loadClass(className).getDeclaredConstructor(classes).newInstance(objects);
} catch (InvocationTargetException ex) {
NullPointerException exc = new NullPointerException();
exc.addSuppressed(ex);
throw exc;
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | ClassNotFoundException e) {
e.printStackTrace();
NullPointerException exc = new NullPointerException();
exc.addSuppressed(e);
throw exc;
}
}
@SuppressWarnings("unchecked")
public static <T> T getStaticField(String path, Class<T> type) {
try {
String[] blob = path.split("\\.");
String className = String.join(".", Arrays.copyOfRange(blob, 0, blob.length - 1));
String var = blob[blob.length - 1];
return (T) classLoader.getClassLoader().loadClass(className).getField(var).get(null);
} catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
NullPointerException exc = new NullPointerException();
exc.addSuppressed(e);
throw exc;
}
}
public static <T> Var<T> getStaticFieldVar(String path, Class<T> type) {
T obj = getStaticField(path, type);
return new Var<T>(obj, type);
}
public static int getEnumIndex(String className, String value) {
try {
Object[] enumConstants = classLoader.getClassLoader().loadClass(className).getEnumConstants();
int index = 0;
for (Object o : enumConstants) {
if (o.toString().equals(value)) {
return index;
}
index++;
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
NullPointerException exc = new NullPointerException();
exc.addSuppressed(e);
throw exc;
}
return -1;
}
public static Object getEnumObject(String className, String value) {
try {
Object[] enumConstants = classLoader.getClassLoader().loadClass(className).getEnumConstants();
for (Object o : enumConstants) {
if (o.toString().equals(value)) {
return o;
}
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
NullPointerException exc = new NullPointerException();
exc.addSuppressed(e);
throw exc;
}
return new Object();
}
public static class Var<E> {
private final E var;
private final Class<E> type;
public Var(E var, Class<E> type) {
this.var = var;
this.type = type;
}
public synchronized final E getVar() {
return var;
}
public synchronized final Class<E> getType() {
return type;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((var == null) ? 0 : var.hashCode());
return result;
}
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Var other = (Var) obj;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
if (var == null) {
if (other.var != null)
return false;
} else if (!var.equals(other.var))
return false;
return true;
}
@Override
public String toString() {
return "Var [var=" + var + ", type=" + type + "]";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Integer> newVar(int i) {
return new Var(i, int.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Short> newVar(short i) {
return new Var(i, short.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Byte> newVar(byte i) {
return new Var(i, byte.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Boolean> newVar(boolean i) {
return new Var(i, boolean.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Character> newVar(char i) {
return new Var(i, char.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Long> newVar(long i) {
return new Var(i, long.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Float> newVar(float i) {
return new Var(i, float.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<Double> newVar(double i) {
return new Var(i, double.class);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Var<String> newVar(String i) {
return new Var(i, String.class);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <E> Var<E> newVar(E[] i, Class<E> type) {
return new Var(i, getArrayClass(type));
}
@SuppressWarnings("unchecked")
private static <T> Class<? extends T[]> getArrayClass(Class<T> clazz) {
return (Class<? extends T[]>) Array.newInstance(clazz, 0).getClass();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Var<?> newVarFromClass(Object classObj, String className) {
try {
return new Var(classObj, classLoader.getClassLoader().loadClass(className));
} catch (ClassNotFoundException | IllegalArgumentException e) {
e.printStackTrace();
NullPointerException exc = new NullPointerException();
exc.addSuppressed(e);
throw exc;
}
}
}
*/
} }

View File

@ -22,7 +22,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.cavallium</groupId> <groupId>it.cavallium</groupId>
<artifactId>warppi-engine-gpu</artifactId> <artifactId>warppi-engine-jogl</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -13,11 +13,11 @@ import org.apache.commons.io.FileUtils;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Platform; import it.cavallium.warppi.Platform;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.cpu.CPUEngine; import it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors.JAnsi24bitEngine;
import it.cavallium.warppi.gui.graphicengine.gpu.GPUEngine; import it.cavallium.warppi.gui.graphicengine.impl.jansi256colors.JAnsi256Engine;
import it.cavallium.warppi.gui.graphicengine.headless24bit.Headless24bitEngine; import it.cavallium.warppi.gui.graphicengine.impl.jansi8colors.JAnsi8Engine;
import it.cavallium.warppi.gui.graphicengine.headless256.Headless256Engine; import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
import it.cavallium.warppi.gui.graphicengine.headless8.Headless8Engine; import it.cavallium.warppi.gui.graphicengine.impl.swing.SwingEngine;
import it.cavallium.warppi.util.CacheUtils; import it.cavallium.warppi.util.CacheUtils;
import it.cavallium.warppi.util.Error; import it.cavallium.warppi.util.Error;
import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.core.ZipFile;
@ -41,11 +41,11 @@ public class DesktopPlatform implements Platform {
pu = new DesktopPngUtils(); pu = new DesktopPngUtils();
on = System.getProperty("os.name").toLowerCase(); on = System.getProperty("os.name").toLowerCase();
el = new HashMap<>(); el = new HashMap<>();
el.put("CPU engine", new CPUEngine()); el.put("CPU engine", new SwingEngine());
el.put("GPU engine", new GPUEngine()); el.put("GPU engine", new JOGLEngine());
el.put("headless 24 bit engine", new Headless24bitEngine()); el.put("headless 24 bit engine", new JAnsi24bitEngine());
el.put("headless 256 colors engine", new Headless256Engine()); el.put("headless 256 colors engine", new JAnsi256Engine());
el.put("headless 8 colors engine", new Headless8Engine()); el.put("headless 8 colors engine", new JAnsi8Engine());
settings = new DesktopSettings(); settings = new DesktopSettings();
} }
@ -112,16 +112,16 @@ public class DesktopPlatform implements Platform {
@Override @Override
public void alphaChanged(boolean val) { public void alphaChanged(boolean val) {
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine; final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
if (currentEngine instanceof CPUEngine) { if (currentEngine instanceof SwingEngine) {
((CPUEngine) currentEngine).setAlphaChanged(val); ((SwingEngine) currentEngine).setAlphaChanged(val);
} }
} }
@Override @Override
public void shiftChanged(boolean val) { public void shiftChanged(boolean val) {
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine; final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
if (currentEngine instanceof CPUEngine) { if (currentEngine instanceof SwingEngine) {
((CPUEngine) currentEngine).setShiftChanged(val); ((SwingEngine) currentEngine).setShiftChanged(val);
} }
} }

View File

@ -1,24 +0,0 @@
package it.cavallium.warppi.gui.graphicengine.cpu;
import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.common.RFTFont;
public class CPUFont extends RFTFont {
public CPUFont(String fontName) throws IOException {
super(fontName);
}
public CPUFont(String path, String fontName) throws IOException {
super(path, fontName);
}
@Override
public void use(GraphicEngine d) {
if (d.getRenderer() instanceof CPURenderer) {
((CPURenderer) d.getRenderer()).currentFont = this;
}
}
}

View File

@ -1,20 +0,0 @@
package it.cavallium.warppi.gui.graphicengine.cpu;
import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.common.PngSkin;
public class CPUSkin extends PngSkin {
public CPUSkin(String file) throws IOException {
super(file);
}
@Override
public void use(GraphicEngine d) {
if (d.getRenderer() instanceof CPURenderer) {
((CPURenderer) d.getRenderer()).currentSkin = this;
}
}
}

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.headless24bit; package it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors;
import java.io.IOException; import java.io.IOException;
import java.util.logging.ConsoleHandler; import java.util.logging.ConsoleHandler;
@ -15,9 +15,9 @@ import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop; import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.util.Utils; import it.cavallium.warppi.util.Utils;
public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengine.GraphicEngine { public class JAnsi24bitEngine implements it.cavallium.warppi.gui.graphicengine.GraphicEngine {
private Headless24bitRenderer r; private JAnsi24bitRenderer r;
private boolean stopped = true; private boolean stopped = true;
private RenderingLoop renderLoop; private RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8; public static final int C_MUL_X = 4;//8;
@ -28,7 +28,7 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
private boolean win = false; private boolean win = false;
private Key precKey = null; private Key precKey = null;
public Headless24bitEngine() { public JAnsi24bitEngine() {
} }
@Override @Override
@ -70,7 +70,7 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
@Override @Override
public void create(Runnable onInitialized) { public void create(Runnable onInitialized) {
title = Engine.getPlatform().getSettings().getCalculatorName(); title = Engine.getPlatform().getSettings().getCalculatorName();
r = new Headless24bitRenderer(); r = new JAnsi24bitRenderer();
C_WIDTH = StaticVars.screenSize[0] / C_MUL_X; C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;
C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y; C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;
StaticVars.outputLevel = -1; StaticVars.outputLevel = -1;
@ -203,13 +203,13 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
r.curColor = new int[] { 0x00, 0x87, 0x00 }; r.curColor = new int[] { 0x00, 0x87, 0x00 };
r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title); r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title);
if (win) { if (win) {
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "0;0f"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?12l"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?25l"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} else { } else {
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "0;0f"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?12l"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?25l"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} }
int[] precBgColor = new int[] { -1, -1, -1 }; int[] precBgColor = new int[] { -1, -1, -1 };
int[] precFgColor = new int[] { -1, -1, -1 }; int[] precFgColor = new int[] { -1, -1, -1 };
@ -261,7 +261,7 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
curBgColor = r.bgColorMatrix[x + y * C_WIDTH]; curBgColor = r.bgColorMatrix[x + y * C_WIDTH];
curFgColor = r.fgColorMatrix[x + y * C_WIDTH]; curFgColor = r.fgColorMatrix[x + y * C_WIDTH];
if (precBgColor != curBgColor) { if (precBgColor != curBgColor) {
out = Headless24bitRenderer.ANSI_PREFIX + Headless24bitRenderer.ansiBgColorPrefix + curBgColor[0] + ";" + curBgColor[1] + ";" + curBgColor[2] + Headless24bitRenderer.ansiColorSuffix; out = JAnsi24bitRenderer.ANSI_PREFIX + JAnsi24bitRenderer.ansiBgColorPrefix + curBgColor[0] + ";" + curBgColor[1] + ";" + curBgColor[2] + JAnsi24bitRenderer.ansiColorSuffix;
if (win) { if (win) {
WindowsSupport.writeConsole(out); WindowsSupport.writeConsole(out);
} else { } else {
@ -269,7 +269,7 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
} }
} }
if (precFgColor != curFgColor) { if (precFgColor != curFgColor) {
out = Headless24bitRenderer.ANSI_PREFIX + Headless24bitRenderer.ansiFgColorPrefix + curFgColor[0] + ";" + curFgColor[1] + ";" + curFgColor[2] + Headless24bitRenderer.ansiColorSuffix; out = JAnsi24bitRenderer.ANSI_PREFIX + JAnsi24bitRenderer.ansiFgColorPrefix + curFgColor[0] + ";" + curFgColor[1] + ";" + curFgColor[2] + JAnsi24bitRenderer.ansiColorSuffix;
if (win) { if (win) {
WindowsSupport.writeConsole(out); WindowsSupport.writeConsole(out);
} else { } else {
@ -303,18 +303,18 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
} }
@Override @Override
public Headless24bitFont loadFont(String file) throws IOException { public JAnsi24bitFont loadFont(String file) throws IOException {
return new Headless24bitFont(); return new JAnsi24bitFont();
} }
@Override @Override
public Headless24bitFont loadFont(String path, String file) throws IOException { public JAnsi24bitFont loadFont(String path, String file) throws IOException {
return new Headless24bitFont(); return new JAnsi24bitFont();
} }
@Override @Override
public Headless24bitSkin loadSkin(String file) throws IOException { public JAnsi24bitSkin loadSkin(String file) throws IOException {
return new Headless24bitSkin(file); return new JAnsi24bitSkin(file);
} }
@Override @Override

View File

@ -1,11 +1,11 @@
package it.cavallium.warppi.gui.graphicengine.headless256; package it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public class Headless256Font implements BinaryFont { public class JAnsi24bitFont implements BinaryFont {
@Override @Override
public void load(String file) throws IOException { public void load(String file) throws IOException {

View File

@ -1,20 +1,20 @@
package it.cavallium.warppi.gui.graphicengine.headless24bit; package it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public class Headless24bitRenderer implements Renderer { public class JAnsi24bitRenderer implements Renderer {
Headless24bitFont currentFont; JAnsi24bitFont currentFont;
public int[] size = new int[] { Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_MUL_X, Headless24bitEngine.C_HEIGHT * Headless24bitEngine.C_MUL_Y }; public int[] size = new int[] { JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_MUL_X, JAnsi24bitEngine.C_HEIGHT * JAnsi24bitEngine.C_MUL_Y };
protected int[][] fgColorMatrixSs = new int[size[0] * size[1]][3]; protected int[][] fgColorMatrixSs = new int[size[0] * size[1]][3];
protected int[][] bgColorMatrixSs = new int[size[0] * size[1]][3]; protected int[][] bgColorMatrixSs = new int[size[0] * size[1]][3];
protected char[] charmatrix = new char[Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT]; protected char[] charmatrix = new char[JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT];
protected int[][] fgColorMatrix = new int[Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT][3]; protected int[][] fgColorMatrix = new int[JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT][3];
protected int[][] bgColorMatrix = new int[Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT][3]; protected int[][] bgColorMatrix = new int[JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT][3];
protected int[] clearColor = rgbToIntArray(0xc5, 0xc2, 0xaf); protected int[] clearColor = rgbToIntArray(0xc5, 0xc2, 0xaf);
protected int[] curColor = new int[] { clearColor[0], clearColor[1], clearColor[2] }; protected int[] curColor = new int[] { clearColor[0], clearColor[1], clearColor[2] };
public Headless24bitSkin currentSkin; public JAnsi24bitSkin currentSkin;
public static final String ANSI_PREFIX = "\u001B["; public static final String ANSI_PREFIX = "\u001B[";
public static final String ansiFgColorPrefix = "38;2;"; public static final String ansiFgColorPrefix = "38;2;";
@ -95,7 +95,7 @@ public class Headless24bitRenderer implements Renderer {
break; break;
} }
bgColorMatrixSs[((int) x1) + ((int) y1) * size[0]] = curColor; bgColorMatrixSs[((int) x1) + ((int) y1) * size[0]] = curColor;
charmatrix[((int) x1 / Headless24bitEngine.C_MUL_X) + ((int) y1 / Headless24bitEngine.C_MUL_Y) * Headless24bitEngine.C_WIDTH] = ' '; charmatrix[((int) x1 / JAnsi24bitEngine.C_MUL_X) + ((int) y1 / JAnsi24bitEngine.C_MUL_Y) * JAnsi24bitEngine.C_WIDTH] = ' ';
if (x1 == x2 && y1 == y2) { if (x1 == x2 && y1 == y2) {
break; break;
@ -148,7 +148,7 @@ public class Headless24bitRenderer implements Renderer {
for (int py = iy; py < y1; py++) { for (int py = iy; py < y1; py++) {
drawPixelAt(' ', curColor, px, py); drawPixelAt(' ', curColor, px, py);
bgColorMatrixSs[(px) + (py) * sizeW] = curColor; bgColorMatrixSs[(px) + (py) * sizeW] = curColor;
charmatrix[(px / Headless24bitEngine.C_MUL_X) + (py / Headless24bitEngine.C_MUL_Y) * sizeW / Headless24bitEngine.C_MUL_X] = ' '; charmatrix[(px / JAnsi24bitEngine.C_MUL_X) + (py / JAnsi24bitEngine.C_MUL_Y) * sizeW / JAnsi24bitEngine.C_MUL_X] = ' ';
} }
} }
} }
@ -160,7 +160,7 @@ public class Headless24bitRenderer implements Renderer {
if (cx >= size[0] || cy >= size[1]) { if (cx >= size[0] || cy >= size[1]) {
return; return;
} }
charmatrix[cx / Headless24bitEngine.C_MUL_X + cy / Headless24bitEngine.C_MUL_Y * Headless24bitEngine.C_WIDTH] = ch; charmatrix[cx / JAnsi24bitEngine.C_MUL_X + cy / JAnsi24bitEngine.C_MUL_Y * JAnsi24bitEngine.C_WIDTH] = ch;
fgColorMatrixSs[cx + cy * size[0]] = curColor; fgColorMatrixSs[cx + cy * size[0]] = curColor;
} }
@ -171,12 +171,12 @@ public class Headless24bitRenderer implements Renderer {
@Override @Override
public void glDrawCharRight(int x, int y, char ch) { public void glDrawCharRight(int x, int y, char ch) {
final int cx = x - 1 * Headless24bitEngine.C_MUL_X; final int cx = x - 1 * JAnsi24bitEngine.C_MUL_X;
final int cy = y; final int cy = y;
if (cx >= size[0] || cy >= size[1]) { if (cx >= size[0] || cy >= size[1]) {
return; return;
} }
charmatrix[cx / Headless24bitEngine.C_MUL_X + cy / Headless24bitEngine.C_MUL_Y * Headless24bitEngine.C_WIDTH] = ch; charmatrix[cx / JAnsi24bitEngine.C_MUL_X + cy / JAnsi24bitEngine.C_MUL_Y * JAnsi24bitEngine.C_WIDTH] = ch;
fgColorMatrixSs[cx + cy * size[0]] = curColor; fgColorMatrixSs[cx + cy * size[0]] = curColor;
} }
@ -189,7 +189,7 @@ public class Headless24bitRenderer implements Renderer {
if (cx + i >= size[0] || cy >= size[1]) { if (cx + i >= size[0] || cy >= size[1]) {
break; break;
} }
charmatrix[cx / Headless24bitEngine.C_MUL_X + i + cy / Headless24bitEngine.C_MUL_Y * Headless24bitEngine.C_WIDTH] = c; charmatrix[cx / JAnsi24bitEngine.C_MUL_X + i + cy / JAnsi24bitEngine.C_MUL_Y * JAnsi24bitEngine.C_WIDTH] = c;
fgColorMatrixSs[cx + i + cy * size[0]] = curColor; fgColorMatrixSs[cx + i + cy * size[0]] = curColor;
i++; i++;
} }
@ -197,14 +197,14 @@ public class Headless24bitRenderer implements Renderer {
@Override @Override
public void glDrawStringCenter(float x, float y, String text) { public void glDrawStringCenter(float x, float y, String text) {
final int cx = ((int) x) - (text.length() / 2) * Headless24bitEngine.C_MUL_X; final int cx = ((int) x) - (text.length() / 2) * JAnsi24bitEngine.C_MUL_X;
final int cy = ((int) y); final int cy = ((int) y);
int i = 0; int i = 0;
for (final char c : text.toCharArray()) { for (final char c : text.toCharArray()) {
if (cx + i >= size[0] || cy >= size[1]) { if (cx + i >= size[0] || cy >= size[1]) {
break; break;
} }
charmatrix[cx / Headless24bitEngine.C_MUL_X + i + cy / Headless24bitEngine.C_MUL_Y * Headless24bitEngine.C_WIDTH] = c; charmatrix[cx / JAnsi24bitEngine.C_MUL_X + i + cy / JAnsi24bitEngine.C_MUL_Y * JAnsi24bitEngine.C_WIDTH] = c;
fgColorMatrixSs[cx + i + cy * size[0]] = curColor; fgColorMatrixSs[cx + i + cy * size[0]] = curColor;
i++; i++;
} }
@ -272,7 +272,7 @@ public class Headless24bitRenderer implements Renderer {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]]; newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
if (transparent) { if (transparent) {
if (newColor.length == 3 || (newColor.length == 4 && newColor[3] != 1)) { if (newColor.length == 3 || (newColor.length == 4 && newColor[3] != 1)) {
charmatrix[pixelX / Headless24bitEngine.C_MUL_X + pixelY / Headless24bitEngine.C_MUL_Y * Headless24bitEngine.C_WIDTH] = ' '; charmatrix[pixelX / JAnsi24bitEngine.C_MUL_X + pixelY / JAnsi24bitEngine.C_MUL_Y * JAnsi24bitEngine.C_WIDTH] = ' ';
bgColorMatrixSs[pixelX + pixelY * size[0]] = newColor; bgColorMatrixSs[pixelX + pixelY * size[0]] = newColor;
} }
} }
@ -292,7 +292,7 @@ public class Headless24bitRenderer implements Renderer {
} }
protected void clearAll() { protected void clearAll() {
for (int i = 0; i < Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT; i++) { for (int i = 0; i < JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT; i++) {
charmatrix[i] = ' '; charmatrix[i] = ' ';
} }
for (int i = 0; i < size[0] * size[1]; i++) { for (int i = 0; i < size[0] * size[1]; i++) {
@ -302,7 +302,7 @@ public class Headless24bitRenderer implements Renderer {
} }
@Override @Override
public Headless24bitFont getCurrentFont() { public JAnsi24bitFont getCurrentFont() {
return currentFont; return currentFont;
} }

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.headless24bit; package it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
@ -8,12 +8,12 @@ import javax.imageio.ImageIO;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public class Headless24bitSkin implements Skin { public class JAnsi24bitSkin implements Skin {
public int[][] skinData; public int[][] skinData;
public int[] skinSize; public int[] skinSize;
Headless24bitSkin(String file) throws IOException { JAnsi24bitSkin(String file) throws IOException {
load(file); load(file);
} }
@ -36,7 +36,7 @@ public class Headless24bitSkin implements Skin {
final int g = (rgb >> 8) & 0xFF; final int g = (rgb >> 8) & 0xFF;
final int b = rgb & 0xFF; final int b = rgb & 0xFF;
final boolean transparent = ((rgb >> 24) & 0xFF) <= 128; final boolean transparent = ((rgb >> 24) & 0xFF) <= 128;
final int[] curCol = Headless24bitRenderer.rgbToIntArray(r, g, b); final int[] curCol = JAnsi24bitRenderer.rgbToIntArray(r, g, b);
pixels[i + j * width] = new int[] { curCol[0], curCol[1], curCol[2], transparent ? 1 : 0 }; pixels[i + j * width] = new int[] { curCol[0], curCol[1], curCol[2], transparent ? 1 : 0 };
} }
} }
@ -51,7 +51,7 @@ public class Headless24bitSkin implements Skin {
@Override @Override
public void use(GraphicEngine d) { public void use(GraphicEngine d) {
((Headless24bitRenderer) d.getRenderer()).currentSkin = this; ((JAnsi24bitRenderer) d.getRenderer()).currentSkin = this;
} }
@Override @Override

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.headless256; package it.cavallium.warppi.gui.graphicengine.impl.jansi256colors;
import java.io.IOException; import java.io.IOException;
import java.util.logging.ConsoleHandler; import java.util.logging.ConsoleHandler;
@ -13,12 +13,12 @@ import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop; import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.headless24bit.Headless24bitRenderer; import it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors.JAnsi24bitRenderer;
import it.cavallium.warppi.util.Utils; import it.cavallium.warppi.util.Utils;
public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.GraphicEngine { public class JAnsi256Engine implements it.cavallium.warppi.gui.graphicengine.GraphicEngine {
private Headless256Renderer r; private JAnsi256Renderer r;
private boolean stopped = true; private boolean stopped = true;
private RenderingLoop renderLoop; private RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8; public static final int C_MUL_X = 4;//8;
@ -65,7 +65,7 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
@Override @Override
public void create(Runnable onInitialized) { public void create(Runnable onInitialized) {
title = Engine.getPlatform().getSettings().getCalculatorName(); title = Engine.getPlatform().getSettings().getCalculatorName();
r = new Headless256Renderer(); r = new JAnsi256Renderer();
C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60; C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40; C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
StaticVars.outputLevel = -1; StaticVars.outputLevel = -1;
@ -198,13 +198,13 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
r.curColor = 0x1C; r.curColor = 0x1C;
r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title); r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title);
if (win) { if (win) {
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "0;0f"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?12l"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?25l"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} else { } else {
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "0;0f"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?12l"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?25l"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} }
for (int y = 0; y < C_HEIGHT; y++) { for (int y = 0; y < C_HEIGHT; y++) {
int precBgColor = -1; int precBgColor = -1;
@ -215,7 +215,7 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
curBgColor = r.bgColorMatrix[x + y * C_WIDTH]; curBgColor = r.bgColorMatrix[x + y * C_WIDTH];
curFgColor = r.fgColorMatrix[x + y * C_WIDTH]; curFgColor = r.fgColorMatrix[x + y * C_WIDTH];
if (precBgColor != curBgColor) { if (precBgColor != curBgColor) {
final String str = Headless256Renderer.ANSI_PREFIX + Headless256Renderer.ansiBgColorPrefix + curBgColor + Headless256Renderer.ansiColorSuffix; final String str = JAnsi256Renderer.ANSI_PREFIX + JAnsi256Renderer.ansiBgColorPrefix + curBgColor + JAnsi256Renderer.ansiColorSuffix;
if (win) { if (win) {
WindowsSupport.writeConsole(str); WindowsSupport.writeConsole(str);
} else { } else {
@ -223,7 +223,7 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
} }
} }
if (precFgColor != curFgColor) { if (precFgColor != curFgColor) {
final String str = Headless256Renderer.ANSI_PREFIX + Headless256Renderer.ansiFgColorPrefix + curFgColor + Headless256Renderer.ansiColorSuffix; final String str = JAnsi256Renderer.ANSI_PREFIX + JAnsi256Renderer.ansiFgColorPrefix + curFgColor + JAnsi256Renderer.ansiColorSuffix;
if (win) { if (win) {
WindowsSupport.writeConsole(str); WindowsSupport.writeConsole(str);
} else { } else {
@ -256,18 +256,18 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
} }
@Override @Override
public Headless256Font loadFont(String file) throws IOException { public JAnsi256Font loadFont(String file) throws IOException {
return new Headless256Font(); return new JAnsi256Font();
} }
@Override @Override
public Headless256Font loadFont(String path, String file) throws IOException { public JAnsi256Font loadFont(String path, String file) throws IOException {
return new Headless256Font(); return new JAnsi256Font();
} }
@Override @Override
public Headless256Skin loadSkin(String file) throws IOException { public JAnsi256Skin loadSkin(String file) throws IOException {
return new Headless256Skin(file); return new JAnsi256Skin(file);
} }
@Override @Override

View File

@ -1,11 +1,11 @@
package it.cavallium.warppi.gui.graphicengine.headless24bit; package it.cavallium.warppi.gui.graphicengine.impl.jansi256colors;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public class Headless24bitFont implements BinaryFont { public class JAnsi256Font implements BinaryFont {
@Override @Override
public void load(String file) throws IOException { public void load(String file) throws IOException {

View File

@ -1,16 +1,16 @@
package it.cavallium.warppi.gui.graphicengine.headless256; package it.cavallium.warppi.gui.graphicengine.impl.jansi256colors;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public class Headless256Renderer implements Renderer { public class JAnsi256Renderer implements Renderer {
Headless256Font currentFont; JAnsi256Font currentFont;
protected char[] charmatrix = new char[Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT]; protected char[] charmatrix = new char[JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT];
protected int[] fgColorMatrix = new int[Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT]; protected int[] fgColorMatrix = new int[JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT];
protected int[] bgColorMatrix = new int[Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT]; protected int[] bgColorMatrix = new int[JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT];
protected int clearColor = rgbToX256(0xc5, 0xc2, 0xaf); protected int clearColor = rgbToX256(0xc5, 0xc2, 0xaf);
protected int curColor = clearColor; protected int curColor = clearColor;
public Headless256Skin currentSkin; public JAnsi256Skin currentSkin;
public static final String ANSI_PREFIX = "\u001B["; public static final String ANSI_PREFIX = "\u001B[";
public static final String ansiFgColorPrefix = "38;5;"; public static final String ansiFgColorPrefix = "38;5;";
@ -110,10 +110,10 @@ public class Headless256Renderer implements Renderer {
@Override @Override
public void glDrawLine(float x1, float y1, float x2, float y2) { public void glDrawLine(float x1, float y1, float x2, float y2) {
x1 /= Headless256Engine.C_MUL_X; x1 /= JAnsi256Engine.C_MUL_X;
x2 /= Headless256Engine.C_MUL_X; x2 /= JAnsi256Engine.C_MUL_X;
y1 /= Headless256Engine.C_MUL_Y; y1 /= JAnsi256Engine.C_MUL_Y;
y2 /= Headless256Engine.C_MUL_Y; y2 /= JAnsi256Engine.C_MUL_Y;
final int dx = (int) Math.abs(x2 - x1); final int dx = (int) Math.abs(x2 - x1);
final int dy = (int) Math.abs(y2 - y1); final int dy = (int) Math.abs(y2 - y1);
@ -124,11 +124,11 @@ public class Headless256Renderer implements Renderer {
int err = dx - dy; int err = dx - dy;
while (true) { while (true) {
if (((int) x1) >= Headless256Engine.C_WIDTH || ((int) y1) >= Headless256Engine.C_HEIGHT || ((int) x2) >= Headless256Engine.C_WIDTH || ((int) y2) >= Headless256Engine.C_HEIGHT) { if (((int) x1) >= JAnsi256Engine.C_WIDTH || ((int) y1) >= JAnsi256Engine.C_HEIGHT || ((int) x2) >= JAnsi256Engine.C_WIDTH || ((int) y2) >= JAnsi256Engine.C_HEIGHT) {
break; break;
} }
bgColorMatrix[((int) x1) + ((int) y1) * Headless256Engine.C_WIDTH] = curColor; bgColorMatrix[((int) x1) + ((int) y1) * JAnsi256Engine.C_WIDTH] = curColor;
charmatrix[((int) x1) + ((int) y1) * Headless256Engine.C_WIDTH] = ' '; charmatrix[((int) x1) + ((int) y1) * JAnsi256Engine.C_WIDTH] = ' ';
if (x1 == x2 && y1 == y2) { if (x1 == x2 && y1 == y2) {
break; break;
@ -152,7 +152,7 @@ public class Headless256Renderer implements Renderer {
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth,
float uvHeight) { float uvHeight) {
if (currentSkin != null) { if (currentSkin != null) {
glDrawSkin((int) (x / Headless256Engine.C_MUL_X), (int) (y / Headless256Engine.C_MUL_Y), (int) (uvX / Headless256Engine.C_MUL_X), (int) (uvY / Headless256Engine.C_MUL_Y), (int) ((uvWidth + uvX) / Headless256Engine.C_MUL_X), (int) ((uvHeight + uvY) / Headless256Engine.C_MUL_Y), true); glDrawSkin((int) (x / JAnsi256Engine.C_MUL_X), (int) (y / JAnsi256Engine.C_MUL_Y), (int) (uvX / JAnsi256Engine.C_MUL_X), (int) (uvY / JAnsi256Engine.C_MUL_Y), (int) ((uvWidth + uvX) / JAnsi256Engine.C_MUL_X), (int) ((uvHeight + uvY) / JAnsi256Engine.C_MUL_Y), true);
} else { } else {
glFillColor(x, y, width, height); glFillColor(x, y, width, height);
} }
@ -160,23 +160,23 @@ public class Headless256Renderer implements Renderer {
@Override @Override
public void glFillColor(float x, float y, float width, float height) { public void glFillColor(float x, float y, float width, float height) {
final int ix = (int) x / Headless256Engine.C_MUL_X; final int ix = (int) x / JAnsi256Engine.C_MUL_X;
final int iy = (int) y / Headless256Engine.C_MUL_Y; final int iy = (int) y / JAnsi256Engine.C_MUL_Y;
final int iw = (int) width / Headless256Engine.C_MUL_X; final int iw = (int) width / JAnsi256Engine.C_MUL_X;
final int ih = (int) height / Headless256Engine.C_MUL_Y; final int ih = (int) height / JAnsi256Engine.C_MUL_Y;
int x1 = ix + iw; int x1 = ix + iw;
int y1 = iy + ih; int y1 = iy + ih;
if (ix >= Headless256Engine.C_WIDTH || iy >= Headless256Engine.C_WIDTH) { if (ix >= JAnsi256Engine.C_WIDTH || iy >= JAnsi256Engine.C_WIDTH) {
return; return;
} }
if (x1 >= Headless256Engine.C_WIDTH) { if (x1 >= JAnsi256Engine.C_WIDTH) {
x1 = Headless256Engine.C_WIDTH; x1 = JAnsi256Engine.C_WIDTH;
} }
if (y1 >= Headless256Engine.C_HEIGHT) { if (y1 >= JAnsi256Engine.C_HEIGHT) {
y1 = Headless256Engine.C_HEIGHT; y1 = JAnsi256Engine.C_HEIGHT;
} }
final int sizeW = Headless256Engine.C_WIDTH; final int sizeW = JAnsi256Engine.C_WIDTH;
for (int px = ix; px < x1; px++) { for (int px = ix; px < x1; px++) {
for (int py = iy; py < y1; py++) { for (int py = iy; py < y1; py++) {
bgColorMatrix[(px) + (py) * sizeW] = curColor; bgColorMatrix[(px) + (py) * sizeW] = curColor;
@ -187,13 +187,13 @@ public class Headless256Renderer implements Renderer {
@Override @Override
public void glDrawCharLeft(int x, int y, char ch) { public void glDrawCharLeft(int x, int y, char ch) {
final int cx = (x) / Headless256Engine.C_MUL_X; final int cx = (x) / JAnsi256Engine.C_MUL_X;
final int cy = (y) / Headless256Engine.C_MUL_Y; final int cy = (y) / JAnsi256Engine.C_MUL_Y;
if (cx >= Headless256Engine.C_WIDTH || cy >= Headless256Engine.C_HEIGHT) { if (cx >= JAnsi256Engine.C_WIDTH || cy >= JAnsi256Engine.C_HEIGHT) {
return; return;
} }
charmatrix[cx + cy * Headless256Engine.C_WIDTH] = ch; charmatrix[cx + cy * JAnsi256Engine.C_WIDTH] = ch;
fgColorMatrix[cx + cy * Headless256Engine.C_WIDTH] = curColor; fgColorMatrix[cx + cy * JAnsi256Engine.C_WIDTH] = curColor;
} }
@Override @Override
@ -203,41 +203,41 @@ public class Headless256Renderer implements Renderer {
@Override @Override
public void glDrawCharRight(int x, int y, char ch) { public void glDrawCharRight(int x, int y, char ch) {
final int cx = (x) / Headless256Engine.C_MUL_X - 1; final int cx = (x) / JAnsi256Engine.C_MUL_X - 1;
final int cy = (y) / Headless256Engine.C_MUL_Y; final int cy = (y) / JAnsi256Engine.C_MUL_Y;
if (cx >= Headless256Engine.C_WIDTH || cy >= Headless256Engine.C_HEIGHT) { if (cx >= JAnsi256Engine.C_WIDTH || cy >= JAnsi256Engine.C_HEIGHT) {
return; return;
} }
charmatrix[cx + cy * Headless256Engine.C_WIDTH] = ch; charmatrix[cx + cy * JAnsi256Engine.C_WIDTH] = ch;
fgColorMatrix[cx + cy * Headless256Engine.C_WIDTH] = curColor; fgColorMatrix[cx + cy * JAnsi256Engine.C_WIDTH] = curColor;
} }
@Override @Override
public void glDrawStringLeft(float x, float y, String text) { public void glDrawStringLeft(float x, float y, String text) {
final int cx = ((int) x) / Headless256Engine.C_MUL_X; final int cx = ((int) x) / JAnsi256Engine.C_MUL_X;
final int cy = ((int) y) / Headless256Engine.C_MUL_Y; final int cy = ((int) y) / JAnsi256Engine.C_MUL_Y;
int i = 0; int i = 0;
for (final char c : text.toCharArray()) { for (final char c : text.toCharArray()) {
if (cx + i >= Headless256Engine.C_WIDTH || cy >= Headless256Engine.C_HEIGHT) { if (cx + i >= JAnsi256Engine.C_WIDTH || cy >= JAnsi256Engine.C_HEIGHT) {
break; break;
} }
charmatrix[cx + i + cy * Headless256Engine.C_WIDTH] = c; charmatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = c;
fgColorMatrix[cx + i + cy * Headless256Engine.C_WIDTH] = curColor; fgColorMatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = curColor;
i++; i++;
} }
} }
@Override @Override
public void glDrawStringCenter(float x, float y, String text) { public void glDrawStringCenter(float x, float y, String text) {
final int cx = ((int) x) / Headless256Engine.C_MUL_X - text.length() / 2; final int cx = ((int) x) / JAnsi256Engine.C_MUL_X - text.length() / 2;
final int cy = ((int) y) / Headless256Engine.C_MUL_Y; final int cy = ((int) y) / JAnsi256Engine.C_MUL_Y;
int i = 0; int i = 0;
for (final char c : text.toCharArray()) { for (final char c : text.toCharArray()) {
if (cx + i >= Headless256Engine.C_WIDTH || cy >= Headless256Engine.C_HEIGHT) { if (cx + i >= JAnsi256Engine.C_WIDTH || cy >= JAnsi256Engine.C_HEIGHT) {
break; break;
} }
charmatrix[cx + i + cy * Headless256Engine.C_WIDTH] = c; charmatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = c;
fgColorMatrix[cx + i + cy * Headless256Engine.C_WIDTH] = curColor; fgColorMatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = curColor;
i++; i++;
} }
} }
@ -266,14 +266,14 @@ public class Headless256Renderer implements Renderer {
t1 = t00; t1 = t00;
height = t1 - t0; height = t1 - t0;
} }
if (x0 >= Headless256Engine.C_WIDTH || y0 >= Headless256Engine.C_WIDTH) { if (x0 >= JAnsi256Engine.C_WIDTH || y0 >= JAnsi256Engine.C_WIDTH) {
return; return;
} }
if (x0 + width >= Headless256Engine.C_WIDTH) { if (x0 + width >= JAnsi256Engine.C_WIDTH) {
s1 = Headless256Engine.C_WIDTH - x0 + s0; s1 = JAnsi256Engine.C_WIDTH - x0 + s0;
} }
if (y0 + height >= Headless256Engine.C_HEIGHT) { if (y0 + height >= JAnsi256Engine.C_HEIGHT) {
t1 = Headless256Engine.C_HEIGHT - y0 + t0; t1 = JAnsi256Engine.C_HEIGHT - y0 + t0;
} }
if (x0 < 0) { if (x0 < 0) {
if (onex == -1) { if (onex == -1) {
@ -299,12 +299,12 @@ public class Headless256Renderer implements Renderer {
for (int texy = 0; texy < t1 - t0; texy++) { for (int texy = 0; texy < t1 - t0; texy++) {
pixelX = (x0 + texx * onex + width); pixelX = (x0 + texx * onex + width);
pixelY = (y0 + texy * oney + height); pixelY = (y0 + texy * oney + height);
if (pixelY < Headless256Engine.C_HEIGHT) { if (pixelY < JAnsi256Engine.C_HEIGHT) {
if (pixelX - (pixelX % Headless256Engine.C_WIDTH) == 0) { if (pixelX - (pixelX % JAnsi256Engine.C_WIDTH) == 0) {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]]; newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
if (transparent && !((newColor & TRANSPARENT) == TRANSPARENT)) { if (transparent && !((newColor & TRANSPARENT) == TRANSPARENT)) {
charmatrix[pixelX + pixelY * Headless256Engine.C_WIDTH] = ' '; charmatrix[pixelX + pixelY * JAnsi256Engine.C_WIDTH] = ' ';
bgColorMatrix[pixelX + pixelY * Headless256Engine.C_WIDTH] = newColor; bgColorMatrix[pixelX + pixelY * JAnsi256Engine.C_WIDTH] = newColor;
} }
} }
} }
@ -318,7 +318,7 @@ public class Headless256Renderer implements Renderer {
} }
protected void clearAll() { protected void clearAll() {
for (int i = 0; i < Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT; i++) { for (int i = 0; i < JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT; i++) {
charmatrix[i] = ' '; charmatrix[i] = ' ';
bgColorMatrix[i] = clearColor; bgColorMatrix[i] = clearColor;
fgColorMatrix[i] = 0; fgColorMatrix[i] = 0;
@ -326,7 +326,7 @@ public class Headless256Renderer implements Renderer {
} }
@Override @Override
public Headless256Font getCurrentFont() { public JAnsi256Font getCurrentFont() {
return currentFont; return currentFont;
} }

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.headless256; package it.cavallium.warppi.gui.graphicengine.impl.jansi256colors;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp; import java.awt.image.AffineTransformOp;
@ -10,12 +10,12 @@ import javax.imageio.ImageIO;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public class Headless256Skin implements Skin { public class JAnsi256Skin implements Skin {
public int[] skinData; public int[] skinData;
public int[] skinSize; public int[] skinSize;
Headless256Skin(String file) throws IOException { JAnsi256Skin(String file) throws IOException {
load(file); load(file);
} }
@ -29,7 +29,7 @@ public class Headless256Skin implements Skin {
public static int[] getMatrixOfImage(BufferedImage bufferedImage) { public static int[] getMatrixOfImage(BufferedImage bufferedImage) {
BufferedImage after = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_INT_ARGB); BufferedImage after = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
final AffineTransform at = new AffineTransform(); final AffineTransform at = new AffineTransform();
at.scale(1f / (Headless256Engine.C_MUL_X), 1f / (Headless256Engine.C_MUL_Y)); at.scale(1f / (JAnsi256Engine.C_MUL_X), 1f / (JAnsi256Engine.C_MUL_Y));
final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
after = scaleOp.filter(bufferedImage, after); after = scaleOp.filter(bufferedImage, after);
@ -43,7 +43,7 @@ public class Headless256Skin implements Skin {
final int g = (rgb >> 8) & 0xFF; final int g = (rgb >> 8) & 0xFF;
final int b = rgb & 0xFF; final int b = rgb & 0xFF;
final boolean transparent = ((rgb >> 24) & 0xFF) <= 128; final boolean transparent = ((rgb >> 24) & 0xFF) <= 128;
pixels[i + j * width] = Headless256Renderer.rgbToX256(r, g, b) | (transparent ? Headless256Renderer.TRANSPARENT : 0); pixels[i + j * width] = JAnsi256Renderer.rgbToX256(r, g, b) | (transparent ? JAnsi256Renderer.TRANSPARENT : 0);
} }
} }
@ -57,7 +57,7 @@ public class Headless256Skin implements Skin {
@Override @Override
public void use(GraphicEngine d) { public void use(GraphicEngine d) {
((Headless256Renderer) d.getRenderer()).currentSkin = this; ((JAnsi256Renderer) d.getRenderer()).currentSkin = this;
} }
@Override @Override

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.headless8; package it.cavallium.warppi.gui.graphicengine.impl.jansi8colors;
import java.io.IOException; import java.io.IOException;
import java.util.logging.ConsoleHandler; import java.util.logging.ConsoleHandler;
@ -13,12 +13,12 @@ import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.flow.Observable; import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop; import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.headless24bit.Headless24bitRenderer; import it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors.JAnsi24bitRenderer;
import it.cavallium.warppi.util.Utils; import it.cavallium.warppi.util.Utils;
public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.GraphicEngine { public class JAnsi8Engine implements it.cavallium.warppi.gui.graphicengine.GraphicEngine {
private Headless8Renderer r; private JAnsi8Renderer r;
private boolean stopped = true; private boolean stopped = true;
private RenderingLoop renderLoop; private RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8; public static final int C_MUL_X = 4;//8;
@ -65,7 +65,7 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
@Override @Override
public void create(Runnable onInitialized) { public void create(Runnable onInitialized) {
title = Engine.getPlatform().getSettings().getCalculatorName(); title = Engine.getPlatform().getSettings().getCalculatorName();
r = new Headless8Renderer(); r = new JAnsi8Renderer();
C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60; C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40; C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
StaticVars.outputLevel = -1; StaticVars.outputLevel = -1;
@ -198,13 +198,13 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
r.curColor = 0x1C; r.curColor = 0x1C;
r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title); r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title);
if (win) { if (win) {
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "0;0f"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?12l"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?25l"); WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} else { } else {
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "0;0f"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?12l"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?25l"); AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} }
for (int y = 0; y < C_HEIGHT; y++) { for (int y = 0; y < C_HEIGHT; y++) {
int precBgColor = -1; int precBgColor = -1;
@ -215,7 +215,7 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
curBgColor = (r.colorMatrix[x + y * C_WIDTH] & 0xF0) >> 4; curBgColor = (r.colorMatrix[x + y * C_WIDTH] & 0xF0) >> 4;
curFgColor = r.colorMatrix[x + y * C_WIDTH] & 0x0F; curFgColor = r.colorMatrix[x + y * C_WIDTH] & 0x0F;
if (precBgColor != curBgColor) { if (precBgColor != curBgColor) {
final String str = Headless8Renderer.ANSI_PREFIX + Headless8Renderer.ansiBgColorPrefix + Headless8Renderer.colorANSI[curBgColor] + Headless8Renderer.ansiColorSuffix; final String str = JAnsi8Renderer.ANSI_PREFIX + JAnsi8Renderer.ansiBgColorPrefix + JAnsi8Renderer.colorANSI[curBgColor] + JAnsi8Renderer.ansiColorSuffix;
if (win) { if (win) {
WindowsSupport.writeConsole(str); WindowsSupport.writeConsole(str);
} else { } else {
@ -223,7 +223,7 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
} }
} }
if (precFgColor != curFgColor) { if (precFgColor != curFgColor) {
final String str = Headless8Renderer.ANSI_PREFIX + Headless8Renderer.ansiFgColorPrefix + Headless8Renderer.colorANSI[curFgColor] + Headless8Renderer.ansiColorSuffix; final String str = JAnsi8Renderer.ANSI_PREFIX + JAnsi8Renderer.ansiFgColorPrefix + JAnsi8Renderer.colorANSI[curFgColor] + JAnsi8Renderer.ansiColorSuffix;
if (win) { if (win) {
WindowsSupport.writeConsole(str); WindowsSupport.writeConsole(str);
} else { } else {
@ -256,18 +256,18 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
} }
@Override @Override
public Headless8Font loadFont(String file) throws IOException { public JAnsi8Font loadFont(String file) throws IOException {
return new Headless8Font(); return new JAnsi8Font();
} }
@Override @Override
public Headless8Font loadFont(String path, String file) throws IOException { public JAnsi8Font loadFont(String path, String file) throws IOException {
return new Headless8Font(); return new JAnsi8Font();
} }
@Override @Override
public Headless8Skin loadSkin(String file) throws IOException { public JAnsi8Skin loadSkin(String file) throws IOException {
return new Headless8Skin(file); return new JAnsi8Skin(file);
} }
@Override @Override

View File

@ -1,11 +1,11 @@
package it.cavallium.warppi.gui.graphicengine.headless8; package it.cavallium.warppi.gui.graphicengine.impl.jansi8colors;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public class Headless8Font implements BinaryFont { public class JAnsi8Font implements BinaryFont {
@Override @Override
public void load(String file) throws IOException { public void load(String file) throws IOException {

View File

@ -1,16 +1,16 @@
package it.cavallium.warppi.gui.graphicengine.headless8; package it.cavallium.warppi.gui.graphicengine.impl.jansi8colors;
import it.cavallium.warppi.StaticVars; import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public class Headless8Renderer implements Renderer { public class JAnsi8Renderer implements Renderer {
Headless8Font currentFont; JAnsi8Font currentFont;
protected char[] charmatrix = new char[Headless8Engine.C_WIDTH * Headless8Engine.C_HEIGHT]; protected char[] charmatrix = new char[JAnsi8Engine.C_WIDTH * JAnsi8Engine.C_HEIGHT];
protected int[] colorMatrix = new int[Headless8Engine.C_WIDTH * Headless8Engine.C_HEIGHT]; protected int[] colorMatrix = new int[JAnsi8Engine.C_WIDTH * JAnsi8Engine.C_HEIGHT];
protected int clearColor = hexColor(0xc5, 0xc2, 0xaf); protected int clearColor = hexColor(0xc5, 0xc2, 0xaf);
protected int curColor = clearColor; protected int curColor = clearColor;
public Headless8Skin currentSkin; public JAnsi8Skin currentSkin;
public static final String ANSI_PREFIX = "\u001B["; public static final String ANSI_PREFIX = "\u001B[";
public static final String ansiFgColorPrefix = "3"; public static final String ansiFgColorPrefix = "3";
@ -231,10 +231,10 @@ public class Headless8Renderer implements Renderer {
@Override @Override
public void glDrawLine(float x1, float y1, float x2, float y2) { public void glDrawLine(float x1, float y1, float x2, float y2) {
x1 /= Headless8Engine.C_MUL_X; x1 /= JAnsi8Engine.C_MUL_X;
x2 /= Headless8Engine.C_MUL_X; x2 /= JAnsi8Engine.C_MUL_X;
y1 /= Headless8Engine.C_MUL_Y; y1 /= JAnsi8Engine.C_MUL_Y;
y2 /= Headless8Engine.C_MUL_Y; y2 /= JAnsi8Engine.C_MUL_Y;
final int dx = (int) Math.abs(x2 - x1); final int dx = (int) Math.abs(x2 - x1);
final int dy = (int) Math.abs(y2 - y1); final int dy = (int) Math.abs(y2 - y1);
@ -245,13 +245,13 @@ public class Headless8Renderer implements Renderer {
int err = dx - dy; int err = dx - dy;
while (true) { while (true) {
if (((int) x1) >= Headless8Engine.C_WIDTH || ((int) y1) >= Headless8Engine.C_HEIGHT || ((int) x2) >= Headless8Engine.C_WIDTH || ((int) y2) >= Headless8Engine.C_HEIGHT) { if (((int) x1) >= JAnsi8Engine.C_WIDTH || ((int) y1) >= JAnsi8Engine.C_HEIGHT || ((int) x2) >= JAnsi8Engine.C_WIDTH || ((int) y2) >= JAnsi8Engine.C_HEIGHT) {
break; break;
} }
final int precBG = colorMatrix[((int) x1) + ((int) y1) * Headless8Engine.C_WIDTH] & 0xF0; final int precBG = colorMatrix[((int) x1) + ((int) y1) * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[((int) x1) + ((int) y1) * Headless8Engine.C_WIDTH] = precBG | curColor; colorMatrix[((int) x1) + ((int) y1) * JAnsi8Engine.C_WIDTH] = precBG | curColor;
if (FILL == 0) initFill(); if (FILL == 0) initFill();
charmatrix[((int) x1) + ((int) y1) * Headless8Engine.C_WIDTH] = FILL; charmatrix[((int) x1) + ((int) y1) * JAnsi8Engine.C_WIDTH] = FILL;
if (x1 == x2 && y1 == y2) { if (x1 == x2 && y1 == y2) {
break; break;
@ -279,7 +279,7 @@ public class Headless8Renderer implements Renderer {
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth,
float uvHeight) { float uvHeight) {
if (currentSkin != null) { if (currentSkin != null) {
glDrawSkin((int) (x / Headless8Engine.C_MUL_X), (int) (y / Headless8Engine.C_MUL_Y), (int) (uvX / Headless8Engine.C_MUL_X), (int) (uvY / Headless8Engine.C_MUL_Y), (int) ((uvWidth + uvX) / Headless8Engine.C_MUL_X), (int) ((uvHeight + uvY) / Headless8Engine.C_MUL_Y), true); glDrawSkin((int) (x / JAnsi8Engine.C_MUL_X), (int) (y / JAnsi8Engine.C_MUL_Y), (int) (uvX / JAnsi8Engine.C_MUL_X), (int) (uvY / JAnsi8Engine.C_MUL_Y), (int) ((uvWidth + uvX) / JAnsi8Engine.C_MUL_X), (int) ((uvHeight + uvY) / JAnsi8Engine.C_MUL_Y), true);
} else { } else {
glFillColor(x, y, width, height); glFillColor(x, y, width, height);
} }
@ -292,23 +292,23 @@ public class Headless8Renderer implements Renderer {
} }
private void glFillColor(float x, float y, float width, float height, char character, int color) { private void glFillColor(float x, float y, float width, float height, char character, int color) {
final int ix = (int) x / Headless8Engine.C_MUL_X; final int ix = (int) x / JAnsi8Engine.C_MUL_X;
final int iy = (int) y / Headless8Engine.C_MUL_Y; final int iy = (int) y / JAnsi8Engine.C_MUL_Y;
final int iw = (int) width / Headless8Engine.C_MUL_X; final int iw = (int) width / JAnsi8Engine.C_MUL_X;
final int ih = (int) height / Headless8Engine.C_MUL_Y; final int ih = (int) height / JAnsi8Engine.C_MUL_Y;
int x1 = ix + iw; int x1 = ix + iw;
int y1 = iy + ih; int y1 = iy + ih;
if (ix >= Headless8Engine.C_WIDTH || iy >= Headless8Engine.C_WIDTH) { if (ix >= JAnsi8Engine.C_WIDTH || iy >= JAnsi8Engine.C_WIDTH) {
return; return;
} }
if (x1 >= Headless8Engine.C_WIDTH) { if (x1 >= JAnsi8Engine.C_WIDTH) {
x1 = Headless8Engine.C_WIDTH; x1 = JAnsi8Engine.C_WIDTH;
} }
if (y1 >= Headless8Engine.C_HEIGHT) { if (y1 >= JAnsi8Engine.C_HEIGHT) {
y1 = Headless8Engine.C_HEIGHT; y1 = JAnsi8Engine.C_HEIGHT;
} }
final int sizeW = Headless8Engine.C_WIDTH; final int sizeW = JAnsi8Engine.C_WIDTH;
for (int px = ix; px < x1; px++) { for (int px = ix; px < x1; px++) {
for (int py = iy; py < y1; py++) { for (int py = iy; py < y1; py++) {
final int precBG = colorMatrix[(px) + (py) * sizeW] & 0xF0; final int precBG = colorMatrix[(px) + (py) * sizeW] & 0xF0;
@ -320,14 +320,14 @@ public class Headless8Renderer implements Renderer {
@Override @Override
public void glDrawCharLeft(int x, int y, char ch) { public void glDrawCharLeft(int x, int y, char ch) {
final int cx = (x) / Headless8Engine.C_MUL_X; final int cx = (x) / JAnsi8Engine.C_MUL_X;
final int cy = (y) / Headless8Engine.C_MUL_Y; final int cy = (y) / JAnsi8Engine.C_MUL_Y;
if (cx >= Headless8Engine.C_WIDTH || cy >= Headless8Engine.C_HEIGHT) { if (cx >= JAnsi8Engine.C_WIDTH || cy >= JAnsi8Engine.C_HEIGHT) {
return; return;
} }
charmatrix[cx + cy * Headless8Engine.C_WIDTH] = ch; charmatrix[cx + cy * JAnsi8Engine.C_WIDTH] = ch;
final int precBG = colorMatrix[cx + cy * Headless8Engine.C_WIDTH] & 0xF0; final int precBG = colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + cy * Headless8Engine.C_WIDTH] = precBG | curColor; colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
} }
@Override @Override
@ -337,44 +337,44 @@ public class Headless8Renderer implements Renderer {
@Override @Override
public void glDrawCharRight(int x, int y, char ch) { public void glDrawCharRight(int x, int y, char ch) {
final int cx = (x) / Headless8Engine.C_MUL_X - 1; final int cx = (x) / JAnsi8Engine.C_MUL_X - 1;
final int cy = (y) / Headless8Engine.C_MUL_Y; final int cy = (y) / JAnsi8Engine.C_MUL_Y;
if (cx >= Headless8Engine.C_WIDTH || cy >= Headless8Engine.C_HEIGHT) { if (cx >= JAnsi8Engine.C_WIDTH || cy >= JAnsi8Engine.C_HEIGHT) {
return; return;
} }
charmatrix[cx + cy * Headless8Engine.C_WIDTH] = ch; charmatrix[cx + cy * JAnsi8Engine.C_WIDTH] = ch;
final int precBG = colorMatrix[cx + cy * Headless8Engine.C_WIDTH] & 0xF0; final int precBG = colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + cy * Headless8Engine.C_WIDTH] = precBG | curColor; colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
} }
@Override @Override
public void glDrawStringLeft(float x, float y, String text) { public void glDrawStringLeft(float x, float y, String text) {
final int cx = ((int) x) / Headless8Engine.C_MUL_X; final int cx = ((int) x) / JAnsi8Engine.C_MUL_X;
final int cy = ((int) y) / Headless8Engine.C_MUL_Y; final int cy = ((int) y) / JAnsi8Engine.C_MUL_Y;
int i = 0; int i = 0;
for (final char c : text.toCharArray()) { for (final char c : text.toCharArray()) {
if (cx + i >= Headless8Engine.C_WIDTH || cy >= Headless8Engine.C_HEIGHT) { if (cx + i >= JAnsi8Engine.C_WIDTH || cy >= JAnsi8Engine.C_HEIGHT) {
break; break;
} }
charmatrix[cx + i + cy * Headless8Engine.C_WIDTH] = c; charmatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = c;
final int precBG = colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] & 0xF0; final int precBG = colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] = precBG | curColor; colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
i++; i++;
} }
} }
@Override @Override
public void glDrawStringCenter(float x, float y, String text) { public void glDrawStringCenter(float x, float y, String text) {
final int cx = ((int) x) / Headless8Engine.C_MUL_X - text.length() / 2; final int cx = ((int) x) / JAnsi8Engine.C_MUL_X - text.length() / 2;
final int cy = ((int) y) / Headless8Engine.C_MUL_Y; final int cy = ((int) y) / JAnsi8Engine.C_MUL_Y;
int i = 0; int i = 0;
for (final char c : text.toCharArray()) { for (final char c : text.toCharArray()) {
if (cx + i >= Headless8Engine.C_WIDTH || cy >= Headless8Engine.C_HEIGHT) { if (cx + i >= JAnsi8Engine.C_WIDTH || cy >= JAnsi8Engine.C_HEIGHT) {
break; break;
} }
charmatrix[cx + i + cy * Headless8Engine.C_WIDTH] = c; charmatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = c;
final int precBG = colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] & 0xF0; final int precBG = colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] = precBG | curColor; colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
i++; i++;
} }
} }
@ -404,14 +404,14 @@ public class Headless8Renderer implements Renderer {
t1 = t00; t1 = t00;
height = t1 - t0; height = t1 - t0;
} }
if (x0 >= Headless8Engine.C_WIDTH || y0 >= Headless8Engine.C_WIDTH) { if (x0 >= JAnsi8Engine.C_WIDTH || y0 >= JAnsi8Engine.C_WIDTH) {
return; return;
} }
if (x0 + width >= Headless8Engine.C_WIDTH) { if (x0 + width >= JAnsi8Engine.C_WIDTH) {
s1 = Headless8Engine.C_WIDTH - x0 + s0; s1 = JAnsi8Engine.C_WIDTH - x0 + s0;
} }
if (y0 + height >= Headless8Engine.C_HEIGHT) { if (y0 + height >= JAnsi8Engine.C_HEIGHT) {
t1 = Headless8Engine.C_HEIGHT - y0 + t0; t1 = JAnsi8Engine.C_HEIGHT - y0 + t0;
} }
if (x0 < 0) { if (x0 < 0) {
if (onex == -1) { if (onex == -1) {
@ -437,11 +437,11 @@ public class Headless8Renderer implements Renderer {
for (int texy = 0; texy < t1 - t0; texy++) { for (int texy = 0; texy < t1 - t0; texy++) {
pixelX = (x0 + texx * onex + width); pixelX = (x0 + texx * onex + width);
pixelY = (y0 + texy * oney + height); pixelY = (y0 + texy * oney + height);
if (pixelY < Headless8Engine.C_HEIGHT) { if (pixelY < JAnsi8Engine.C_HEIGHT) {
if (pixelX - (pixelX % Headless8Engine.C_WIDTH) == 0) { if (pixelX - (pixelX % JAnsi8Engine.C_WIDTH) == 0) {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]]; newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
if (transparent) { if (transparent) {
oldColor = colorUnion(hexColorReverse((colorMatrix[pixelX + pixelY * Headless8Engine.C_WIDTH] & 0xF0) >> 4)); oldColor = colorUnion(hexColorReverse((colorMatrix[pixelX + pixelY * JAnsi8Engine.C_WIDTH] & 0xF0) >> 4));
final float a2 = (newColor >> 24 & 0xFF) / 255f; final float a2 = (newColor >> 24 & 0xFF) / 255f;
final float a1 = 1f - a2; final float a1 = 1f - a2;
final int r = (int) ((oldColor >> 16 & 0xFF) * a1 + (newColor >> 16 & 0xFF) * a2); final int r = (int) ((oldColor >> 16 & 0xFF) * a1 + (newColor >> 16 & 0xFF) * a2);
@ -449,10 +449,10 @@ public class Headless8Renderer implements Renderer {
final int b = (int) ((oldColor & 0xFF) * a1 + (newColor & 0xFF) * a2); final int b = (int) ((oldColor & 0xFF) * a1 + (newColor & 0xFF) * a2);
newColor = 0xFF000000 | r << 16 | g << 8 | b; newColor = 0xFF000000 | r << 16 | g << 8 | b;
} }
final int bgColor = colorMatrix[pixelX + pixelY * Headless8Engine.C_WIDTH] & 0xF0; final int bgColor = colorMatrix[pixelX + pixelY * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[pixelX + pixelY * Headless8Engine.C_WIDTH] = bgColor | hexColor(newColor >> 16 & 0xFF, newColor >> 8 & 0xFF, newColor & 0xFF); colorMatrix[pixelX + pixelY * JAnsi8Engine.C_WIDTH] = bgColor | hexColor(newColor >> 16 & 0xFF, newColor >> 8 & 0xFF, newColor & 0xFF);
if (FILL == 0) initFill(); if (FILL == 0) initFill();
charmatrix[pixelX + pixelY * Headless8Engine.C_WIDTH] = FILL; charmatrix[pixelX + pixelY * JAnsi8Engine.C_WIDTH] = FILL;
} }
} }
} }
@ -465,14 +465,14 @@ public class Headless8Renderer implements Renderer {
} }
protected void clearAll() { protected void clearAll() {
for (int i = 0; i < Headless8Engine.C_WIDTH * Headless8Engine.C_HEIGHT; i++) { for (int i = 0; i < JAnsi8Engine.C_WIDTH * JAnsi8Engine.C_HEIGHT; i++) {
charmatrix[i] = ' '; charmatrix[i] = ' ';
colorMatrix[i] = clearColor << 4; colorMatrix[i] = clearColor << 4;
} }
} }
@Override @Override
public Headless8Font getCurrentFont() { public JAnsi8Font getCurrentFont() {
return currentFont; return currentFont;
} }

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.headless8; package it.cavallium.warppi.gui.graphicengine.impl.jansi8colors;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp; import java.awt.image.AffineTransformOp;
@ -10,12 +10,12 @@ import javax.imageio.ImageIO;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public class Headless8Skin implements Skin { public class JAnsi8Skin implements Skin {
public int[] skinData; public int[] skinData;
public int[] skinSize; public int[] skinSize;
Headless8Skin(String file) throws IOException { JAnsi8Skin(String file) throws IOException {
load(file); load(file);
} }
@ -29,7 +29,7 @@ public class Headless8Skin implements Skin {
public static int[] getMatrixOfImage(BufferedImage bufferedImage) { public static int[] getMatrixOfImage(BufferedImage bufferedImage) {
BufferedImage after = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_INT_ARGB); BufferedImage after = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
final AffineTransform at = new AffineTransform(); final AffineTransform at = new AffineTransform();
at.scale(1f / (Headless8Engine.C_MUL_X), 1f / (Headless8Engine.C_MUL_Y)); at.scale(1f / (JAnsi8Engine.C_MUL_X), 1f / (JAnsi8Engine.C_MUL_Y));
final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
after = scaleOp.filter(bufferedImage, after); after = scaleOp.filter(bufferedImage, after);
@ -52,7 +52,7 @@ public class Headless8Skin implements Skin {
@Override @Override
public void use(GraphicEngine d) { public void use(GraphicEngine d) {
((Headless8Renderer) d.getRenderer()).currentSkin = this; ((JAnsi8Renderer) d.getRenderer()).currentSkin = this;
} }
@Override @Override

View File

@ -2,7 +2,7 @@
// Decompiled by Procyon v0.5.30 // Decompiled by Procyon v0.5.30
// //
package it.cavallium.warppi.gui.graphicengine.cpu; package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Dimension; import java.awt.Dimension;
@ -16,7 +16,7 @@ import java.io.IOException;
import javax.swing.JButton; import javax.swing.JButton;
public class JAdvancedButton extends JButton { public class SwingAdvancedButton extends JButton {
/** /**
* *
*/ */
@ -27,13 +27,13 @@ public class JAdvancedButton extends JButton {
public boolean drawDefaultComponent = false; public boolean drawDefaultComponent = false;
public int state; public int state;
public JAdvancedButton() { public SwingAdvancedButton() {
this.setOpaque(false); this.setOpaque(false);
this.backgroundImage = null; this.backgroundImage = null;
this.backgroundSize = new Dimension(0, 0); this.backgroundSize = new Dimension(0, 0);
} }
public JAdvancedButton(final BufferedImage backgroundImage) throws IOException { public SwingAdvancedButton(final BufferedImage backgroundImage) throws IOException {
this.setOpaque(false); this.setOpaque(false);
this.backgroundImage = backgroundImage; this.backgroundImage = backgroundImage;
if (backgroundImage != null) { if (backgroundImage != null) {
@ -45,7 +45,7 @@ public class JAdvancedButton extends JButton {
this.setSize(this.backgroundSize); this.setSize(this.backgroundSize);
} }
public JAdvancedButton(final BufferedImage backgroundImage, final Dimension backgroundSize) throws IOException { public SwingAdvancedButton(final BufferedImage backgroundImage, final Dimension backgroundSize) throws IOException {
this.setOpaque(false); this.setOpaque(false);
this.backgroundImage = backgroundImage; this.backgroundImage = backgroundImage;
this.backgroundSize = backgroundSize; this.backgroundSize = backgroundSize;

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.cpu; package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -13,10 +13,10 @@ import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop; import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public class CPUEngine implements GraphicEngine { public class SwingEngine implements GraphicEngine {
private SwingWindow INSTANCE; private SwingWindow INSTANCE;
public CPURenderer r; public SwingRenderer r;
public volatile BufferedImage g; public volatile BufferedImage g;
public volatile boolean initialized; public volatile boolean initialized;
public Semaphore exitSemaphore; public Semaphore exitSemaphore;
@ -38,7 +38,7 @@ public class CPUEngine implements GraphicEngine {
public void setDisplayMode(final int ww, final int wh) { public void setDisplayMode(final int ww, final int wh) {
INSTANCE.setSize(ww, wh); INSTANCE.setSize(ww, wh);
r.size = new int[] { ww, wh }; r.size = new int[] { ww, wh };
CPURenderer.canvas2d = new int[ww * wh]; SwingRenderer.canvas2d = new int[ww * wh];
g = new BufferedImage(ww, wh, BufferedImage.TYPE_INT_RGB); g = new BufferedImage(ww, wh, BufferedImage.TYPE_INT_RGB);
} }
@ -49,7 +49,7 @@ public class CPUEngine implements GraphicEngine {
@Override @Override
public void create(Runnable onInitialized) { public void create(Runnable onInitialized) {
r = new CPURenderer(); r = new SwingRenderer();
g = new BufferedImage(r.size[0], r.size[1], BufferedImage.TYPE_INT_RGB); g = new BufferedImage(r.size[0], r.size[1], BufferedImage.TYPE_INT_RGB);
initialized = false; initialized = false;
exitSemaphore = new Semaphore(0); exitSemaphore = new Semaphore(0);
@ -150,23 +150,23 @@ public class CPUEngine implements GraphicEngine {
} }
@Override @Override
public CPURenderer getRenderer() { public SwingRenderer getRenderer() {
return r; return r;
} }
@Override @Override
public BinaryFont loadFont(String fontName) throws IOException { public BinaryFont loadFont(String fontName) throws IOException {
return new CPUFont(fontName); return new SwingFont(fontName);
} }
@Override @Override
public BinaryFont loadFont(String path, String fontName) throws IOException { public BinaryFont loadFont(String path, String fontName) throws IOException {
return new CPUFont(path, fontName); return new SwingFont(path, fontName);
} }
@Override @Override
public Skin loadSkin(String file) throws IOException { public Skin loadSkin(String file) throws IOException {
return new CPUSkin(file); return new SwingSkin(file);
} }
@Override @Override

View File

@ -0,0 +1,24 @@
package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class SwingFont extends RFTFont {
public SwingFont(String fontName) throws IOException {
super(fontName);
}
public SwingFont(String path, String fontName) throws IOException {
super(path, fontName);
}
@Override
public void use(GraphicEngine d) {
if (d.getRenderer() instanceof SwingRenderer) {
((SwingRenderer) d.getRenderer()).currentFont = this;
}
}
}

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.cpu; package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.awt.FontMetrics; import java.awt.FontMetrics;
@ -6,10 +6,10 @@ import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public class CPURenderer implements Renderer { public class SwingRenderer implements Renderer {
public int clearcolor = 0xFFc5c2af; public int clearcolor = 0xFFc5c2af;
public CPUFont currentFont; public SwingFont currentFont;
public CPUSkin currentSkin; public SwingSkin currentSkin;
public int color = 0xFF000000; public int color = 0xFF000000;
public int[] size = new int[] { 1, 1 }; public int[] size = new int[] { 1, 1 };
static int[] canvas2d = new int[1]; static int[] canvas2d = new int[1];
@ -306,8 +306,8 @@ public class CPURenderer implements Renderer {
j = ix + cpos + dx; j = ix + cpos + dx;
if (j > 0 & j < screenSize[0]) { if (j > 0 & j < screenSize[0]) {
final int bit = dx + dy * currentFont.charW; final int bit = dx + dy * currentFont.charW;
currentInt = (int) (Math.floor(bit) / (CPUFont.intBits)); currentInt = (int) (Math.floor(bit) / (SwingFont.intBits));
currentIntBitPosition = bit - (currentInt * CPUFont.intBits); currentIntBitPosition = bit - (currentInt * SwingFont.intBits);
final int charIdx = charIndex * currentFont.charIntCount + currentInt; final int charIdx = charIndex * currentFont.charIntCount + currentInt;
if (charIdx >= 0 && charIdx < currentFont.chars32.length) { if (charIdx >= 0 && charIdx < currentFont.chars32.length) {
bitData = (currentFont.chars32[charIdx] >> currentIntBitPosition) & 1; bitData = (currentFont.chars32[charIdx] >> currentIntBitPosition) & 1;

View File

@ -0,0 +1,20 @@
package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin;
public class SwingSkin extends PngSkin {
public SwingSkin(String file) throws IOException {
super(file);
}
@Override
public void use(GraphicEngine d) {
if (d.getRenderer() instanceof SwingRenderer) {
((SwingRenderer) d.getRenderer()).currentSkin = this;
}
}
}

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.cpu; package it.cavallium.warppi.gui.graphicengine.impl.swing;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
@ -45,15 +45,15 @@ public class SwingWindow extends JFrame {
private static final long serialVersionUID = 2945898937634075491L; private static final long serialVersionUID = 2945898937634075491L;
public CustomCanvas c; public CustomCanvas c;
private RenderingLoop renderingLoop; private RenderingLoop renderingLoop;
private final CPUEngine display; private final SwingEngine display;
private int mult = 1; private int mult = 1;
private BehaviorSubject<Integer[]> onResize; private BehaviorSubject<Integer[]> onResize;
private Observable<Integer[]> onResize$; private Observable<Integer[]> onResize$;
public JPanel buttonsPanel; public JPanel buttonsPanel;
private JAdvancedButton[][] buttons; private SwingAdvancedButton[][] buttons;
private int BTN_SIZE; private int BTN_SIZE;
public SwingWindow(CPUEngine disp) { public SwingWindow(SwingEngine disp) {
display = disp; display = disp;
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.setBackground(Color.BLACK); this.setBackground(Color.BLACK);
@ -93,7 +93,7 @@ public class SwingWindow extends JFrame {
if (disp.r.size[1] <= 0) { if (disp.r.size[1] <= 0) {
disp.r.size[1] = 1; disp.r.size[1] = 1;
} }
CPURenderer.canvas2d = new int[disp.r.size[0] * disp.r.size[1]]; SwingRenderer.canvas2d = new int[disp.r.size[0] * disp.r.size[1]];
disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB); disp.g = new BufferedImage(disp.r.size[0], disp.r.size[1], BufferedImage.TYPE_INT_RGB);
}); });
@ -201,7 +201,7 @@ public class SwingWindow extends JFrame {
BTN_SIZE *= 2; BTN_SIZE *= 2;
} }
buttons = new JAdvancedButton[8][8]; buttons = new SwingAdvancedButton[8][8];
JPanel buttonsPanelContainer = new JPanel(); JPanel buttonsPanelContainer = new JPanel();
buttonsPanelContainer.setLayout(new FlowLayout()); buttonsPanelContainer.setLayout(new FlowLayout());
buttonsPanelContainer.setBackground(Color.BLACK); buttonsPanelContainer.setBackground(Color.BLACK);
@ -241,7 +241,7 @@ public class SwingWindow extends JFrame {
private void createBtn(final int row, final int col) throws IOException, URISyntaxException { private void createBtn(final int row, final int col) throws IOException, URISyntaxException {
BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png")); BufferedImage img = ImageIO.read(Engine.getPlatform().getStorageUtils().getResourceStream("/desktop-buttons.png"));
final JAdvancedButton b = new JAdvancedButton(img, new Dimension((int)(BTN_SIZE * 1.5), BTN_SIZE)); final SwingAdvancedButton b = new SwingAdvancedButton(img, new Dimension((int)(BTN_SIZE * 1.5), BTN_SIZE));
b.drawDefaultComponent = false; b.drawDefaultComponent = false;
b.setText(Keyboard.getKeyName(row, col)); b.setText(Keyboard.getKeyName(row, col));
b.setForeground(Color.BLACK); b.setForeground(Color.BLACK);
@ -266,7 +266,7 @@ public class SwingWindow extends JFrame {
public void setAlphaChanged(boolean val) { public void setAlphaChanged(boolean val) {
for (int row = 0; row < buttons.length; row++) { for (int row = 0; row < buttons.length; row++) {
for (int col = 0; col < buttons[0].length; col++) { for (int col = 0; col < buttons[0].length; col++) {
JAdvancedButton btn = buttons[row][col]; SwingAdvancedButton btn = buttons[row][col];
if (btn != null) { if (btn != null) {
btn.setText(Keyboard.getKeyName(row, col)); btn.setText(Keyboard.getKeyName(row, col));
if (row == 0 && col == 1) { if (row == 0 && col == 1) {
@ -289,7 +289,7 @@ public class SwingWindow extends JFrame {
public void setShiftChanged(boolean val) { public void setShiftChanged(boolean val) {
for (int row = 0; row < buttons.length; row++) { for (int row = 0; row < buttons.length; row++) {
for (int col = 0; col < buttons[0].length; col++) { for (int col = 0; col < buttons[0].length; col++) {
JAdvancedButton btn = buttons[row][col]; SwingAdvancedButton btn = buttons[row][col];
if (btn != null) { if (btn != null) {
btn.setText(Keyboard.getKeyName(row, col)); btn.setText(Keyboard.getKeyName(row, col));
if (row == 0 && col == 0) { if (row == 0 && col == 0) {
@ -359,7 +359,7 @@ public class SwingWindow extends JFrame {
renderingLoop.refresh(); renderingLoop.refresh();
final int[] a = ((DataBufferInt) display.g.getRaster().getDataBuffer()).getData(); final int[] a = ((DataBufferInt) display.g.getRaster().getDataBuffer()).getData();
CPURenderer.canvas2d = a; SwingRenderer.canvas2d = a;
g.clearRect(0, 0, display.r.size[0] * mult, display.r.size[1] * mult); g.clearRect(0, 0, display.r.size[0] * mult, display.r.size[1] * mult);
g.drawImage(display.g, 0, 0, display.r.size[0] * mult, display.r.size[1] * mult, null); g.drawImage(display.g, 0, 0, display.r.size[0] * mult, display.r.size[1] * mult, null);
// long time2 = System.nanoTime(); // long time2 = System.nanoTime();

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>warppi-desktop</name> <name>warppi-engine-jogl</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View File

@ -8,12 +8,12 @@
<artifactId>warppi</artifactId> <artifactId>warppi</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</parent> </parent>
<artifactId>warppi-engine-gpu</artifactId> <artifactId>warppi-engine-jogl</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<name>WarpPI Calculator GPU Engine</name> <name>WarpPI Calculator JOGL Engine</name>
<description>WarpPI Calculator engine-gpu project</description> <description>WarpPI Calculator engine-jogl project</description>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>it.cavallium</groupId> <groupId>it.cavallium</groupId>
@ -44,7 +44,7 @@
<configuration> <configuration>
<instructions> <instructions>
<Export-Package>it.cavallium.warppi.*</Export-Package> <Export-Package>it.cavallium.warppi.*</Export-Package>
<Bundle-SymbolicName>warppi-engine-gpu</Bundle-SymbolicName> <Bundle-SymbolicName>warppi-engine-jogl</Bundle-SymbolicName>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.gpu; package it.cavallium.warppi.gui.graphicengine.impl.jogl;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
@ -19,14 +19,14 @@ import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.RenderingLoop; import it.cavallium.warppi.gui.graphicengine.RenderingLoop;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
public class GPUEngine implements GraphicEngine { public class JOGLEngine implements GraphicEngine {
private volatile boolean initialized; private volatile boolean initialized;
private volatile boolean created; private volatile boolean created;
private NEWTWindow wnd; private NEWTWindow wnd;
private RenderingLoop d; private RenderingLoop d;
private GPURenderer r; private JOGLRenderer r;
private final Map<String, GPUFont> fontCache = new HashMap<>(); private final Map<String, JOGLFont> fontCache = new HashMap<>();
int[] size; int[] size;
private final CopyOnWriteArrayList<BinaryFont> registeredFonts = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<BinaryFont> registeredFonts = new CopyOnWriteArrayList<>();
private final Semaphore exitSemaphore = new Semaphore(0); private final Semaphore exitSemaphore = new Semaphore(0);
@ -76,7 +76,7 @@ public class GPUEngine implements GraphicEngine {
created = true; created = true;
registeredTextures = new LinkedList<>(); registeredTextures = new LinkedList<>();
unregisteredTextures = new LinkedList<>(); unregisteredTextures = new LinkedList<>();
r = new GPURenderer(); r = new JOGLRenderer();
wnd = new NEWTWindow(this); wnd = new NEWTWindow(this);
wnd.create(); wnd.create();
setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]); setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
@ -118,43 +118,43 @@ public class GPUEngine implements GraphicEngine {
@Override @Override
public void repaint() { public void repaint() {
if (d != null & r != null && GPURenderer.gl != null) { if (d != null & r != null && JOGLRenderer.gl != null) {
d.refresh(); d.refresh();
} }
} }
@Override @Override
public GPURenderer getRenderer() { public JOGLRenderer getRenderer() {
return r; return r;
} }
@Override @Override
public BinaryFont loadFont(String name) throws IOException { public BinaryFont loadFont(String name) throws IOException {
for (final Entry<String, GPUFont> entry : fontCache.entrySet()) { for (final Entry<String, JOGLFont> entry : fontCache.entrySet()) {
if (entry.getKey().equals(name)) { if (entry.getKey().equals(name)) {
return entry.getValue(); return entry.getValue();
} }
} }
final GPUFont font = new GPUFont(this, name); final JOGLFont font = new JOGLFont(this, name);
fontCache.put(name, font); fontCache.put(name, font);
return font; return font;
} }
@Override @Override
public BinaryFont loadFont(String path, String name) throws IOException { public BinaryFont loadFont(String path, String name) throws IOException {
for (final Entry<String, GPUFont> entry : fontCache.entrySet()) { for (final Entry<String, JOGLFont> entry : fontCache.entrySet()) {
if (entry.getKey().equals(name)) { if (entry.getKey().equals(name)) {
return entry.getValue(); return entry.getValue();
} }
} }
final GPUFont font = new GPUFont(this, path, name); final JOGLFont font = new JOGLFont(this, path, name);
fontCache.put(name, font); fontCache.put(name, font);
return font; return font;
} }
@Override @Override
public Skin loadSkin(String file) throws IOException { public Skin loadSkin(String file) throws IOException {
return new GPUSkin(this, file); return new JOGLSkin(this, file);
} }
@Override @Override
@ -191,7 +191,7 @@ public class GPUEngine implements GraphicEngine {
return false; return false;
} }
public void registerFont(GPUFont gpuFont) { public void registerFont(JOGLFont gpuFont) {
registeredFonts.add(gpuFont); registeredFonts.add(gpuFont);
} }

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.gpu; package it.cavallium.warppi.gui.graphicengine.impl.jogl;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -15,9 +15,9 @@ import ar.com.hjg.pngj.PngWriter;
import it.cavallium.warppi.Engine; import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class GPUFont implements BinaryFont { public class JOGLFont implements BinaryFont {
public Texture texture; public Texture texture;
public int textureW; public int textureW;
@ -35,13 +35,13 @@ public class GPUFont implements BinaryFont {
private boolean initialized = false; private boolean initialized = false;
private File tmpFont; private File tmpFont;
GPUFont(GraphicEngine g, String name) throws IOException { JOGLFont(GraphicEngine g, String name) throws IOException {
this(g, null, name); this(g, null, name);
} }
public GPUFont(GraphicEngine g, String path, String name) throws IOException { public JOGLFont(GraphicEngine g, String path, String name) throws IOException {
load(path, name); load(path, name);
((GPUEngine) g).registerFont(this); ((JOGLEngine) g).registerFont(this);
} }
@Override @Override
@ -182,7 +182,7 @@ public class GPUFont implements BinaryFont {
private void genTexture() { private void genTexture() {
try { try {
texture = GPURenderer.importTexture(tmpFont, true); texture = JOGLRenderer.importTexture(tmpFont, true);
tmpFont = null; tmpFont = null;
} catch (GLException | IOException e) { } catch (GLException | IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -205,7 +205,7 @@ public class GPUFont implements BinaryFont {
if (!initialized) { if (!initialized) {
initialize(d); initialize(d);
} }
final GPURenderer r = (GPURenderer) d.getRenderer(); final JOGLRenderer r = (JOGLRenderer) d.getRenderer();
r.currentFont = this; r.currentFont = this;
r.useTexture(texture, textureW, textureH); r.useTexture(texture, textureW, textureH);
} }

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.gpu; package it.cavallium.warppi.gui.graphicengine.impl.jogl;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
@ -21,7 +21,7 @@ import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.graphicengine.BinaryFont; import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.Renderer; import it.cavallium.warppi.gui.graphicengine.Renderer;
public class GPURenderer implements Renderer { public class JOGLRenderer implements Renderer {
public static GL2ES1 gl; public static GL2ES1 gl;
@ -59,7 +59,7 @@ public class GPURenderer implements Renderer {
float currentTexWidth; float currentTexWidth;
float currentTexHeight; float currentTexHeight;
GPUFont currentFont; JOGLFont currentFont;
@Override @Override
public void glColor3i(int r, int gg, int b) { public void glColor3i(int r, int gg, int b) {
@ -263,7 +263,7 @@ public class GPURenderer implements Renderer {
} }
static OpenedTextureData openTexture(String file, boolean isResource) throws GLException, IOException { static OpenedTextureData openTexture(String file, boolean isResource) throws GLException, IOException {
BufferedImage img = ImageIO.read(isResource ? GPURenderer.class.getResource("/" + file) : new File(file).toURI().toURL()); BufferedImage img = ImageIO.read(isResource ? JOGLRenderer.class.getResource("/" + file) : new File(file).toURI().toURL());
File f; File f;
if (isResource) { if (isResource) {
f = Files.createTempFile("texture-", ".png").toFile(); f = Files.createTempFile("texture-", ".png").toFile();

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.gpu; package it.cavallium.warppi.gui.graphicengine.impl.jogl;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -9,9 +9,9 @@ import com.jogamp.opengl.util.texture.Texture;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin; import it.cavallium.warppi.gui.graphicengine.Skin;
import it.cavallium.warppi.gui.graphicengine.gpu.GPURenderer.OpenedTextureData; import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLRenderer.OpenedTextureData;
public class GPUSkin implements Skin { public class JOGLSkin implements Skin {
public Texture t; public Texture t;
public int w; public int w;
@ -21,7 +21,7 @@ public class GPUSkin implements Skin {
private boolean initialized = false; private boolean initialized = false;
private boolean isResource; private boolean isResource;
GPUSkin(GraphicEngine d, String file) throws IOException { JOGLSkin(GraphicEngine d, String file) throws IOException {
load(file); load(file);
} }
@ -38,11 +38,11 @@ public class GPUSkin implements Skin {
@Override @Override
public void initialize(GraphicEngine d) { public void initialize(GraphicEngine d) {
try { try {
final OpenedTextureData i = GPURenderer.openTexture(texturePath, isResource); final OpenedTextureData i = JOGLRenderer.openTexture(texturePath, isResource);
t = GPURenderer.importTexture(i.f, i.deleteOnExit); t = JOGLRenderer.importTexture(i.f, i.deleteOnExit);
w = i.w; w = i.w;
h = i.h; h = i.h;
((GPUEngine) d).registerTexture(t); ((JOGLEngine) d).registerTexture(t);
initialized = true; initialized = true;
} catch (GLException | IOException e) { } catch (GLException | IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -55,7 +55,7 @@ public class GPUSkin implements Skin {
if (!initialized) { if (!initialized) {
initialize(d); initialize(d);
} }
final GPURenderer r = (GPURenderer) d.getRenderer(); final JOGLRenderer r = (JOGLRenderer) d.getRenderer();
r.useTexture(t, w, h); r.useTexture(t, w, h);
} }

View File

@ -26,7 +26,7 @@
* or implied, of JogAmp Community. * or implied, of JogAmp Community.
*/ */
package it.cavallium.warppi.gui.graphicengine.gpu; package it.cavallium.warppi.gui.graphicengine.impl.jogl;
import java.util.List; import java.util.List;
@ -72,8 +72,8 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class NEWTWindow implements GLEventListener { class NEWTWindow implements GLEventListener {
private final GPUEngine disp; private final JOGLEngine disp;
private final GPURenderer renderer; private final JOGLRenderer renderer;
public GLWindow window; public GLWindow window;
public volatile float windowZoom = 1; public volatile float windowZoom = 1;
public int[] realWindowSize; public int[] realWindowSize;
@ -86,7 +86,7 @@ class NEWTWindow implements GLEventListener {
private BehaviorSubject<Float> onZoom = BehaviorSubject.create(); private BehaviorSubject<Float> onZoom = BehaviorSubject.create();
private Subject<GL2ES1> onGLContext = SimpleSubject.create(); private Subject<GL2ES1> onGLContext = SimpleSubject.create();
public NEWTWindow(GPUEngine disp) { public NEWTWindow(JOGLEngine disp) {
this.disp = disp; this.disp = disp;
renderer = disp.getRenderer(); renderer = disp.getRenderer();
disp.size[0] = StaticVars.screenSize[0]; disp.size[0] = StaticVars.screenSize[0];
@ -478,7 +478,7 @@ class NEWTWindow implements GLEventListener {
//gl.glEnable(GL.GL_MULTISAMPLE); //gl.glEnable(GL.GL_MULTISAMPLE);
try { try {
renderer.currentTex = ((GPUSkin) disp.loadSkin("test.png")).t; renderer.currentTex = ((JOGLSkin) disp.loadSkin("test.png")).t;
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -503,7 +503,7 @@ class NEWTWindow implements GLEventListener {
@Override @Override
public void display(GLAutoDrawable glad) { public void display(GLAutoDrawable glad) {
final GL2ES1 gl = glad.getGL().getGL2ES1(); final GL2ES1 gl = glad.getGL().getGL2ES1();
GPURenderer.gl = gl; JOGLRenderer.gl = gl;
onGLContext.onNext(gl); onGLContext.onNext(gl);
boolean linear = (windowZoom % ((int) windowZoom)) != 0f; boolean linear = (windowZoom % ((int) windowZoom)) != 0f;
@ -546,7 +546,7 @@ class NEWTWindow implements GLEventListener {
gl.glDisableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY); gl.glDisableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); gl.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
GPURenderer.gl = null; JOGLRenderer.gl = null;
} }

View File

@ -22,7 +22,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.cavallium</groupId> <groupId>it.cavallium</groupId>
<artifactId>warppi-engine-gpu</artifactId> <artifactId>warppi-engine-jogl</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.framebuffer; package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;

View File

@ -1,9 +1,9 @@
package it.cavallium.warppi.gui.graphicengine.framebuffer; package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class FBFont extends RFTFont { public class FBFont extends RFTFont {

View File

@ -1,4 +1,4 @@
package it.cavallium.warppi.gui.graphicengine.framebuffer; package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.nio.MappedByteBuffer; import java.nio.MappedByteBuffer;

View File

@ -1,9 +1,9 @@
package it.cavallium.warppi.gui.graphicengine.framebuffer; package it.cavallium.warppi.gui.graphicengine.impl.framebuffer;
import java.io.IOException; import java.io.IOException;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.common.PngSkin; import it.cavallium.warppi.gui.graphicengine.impl.common.PngSkin;
public class FBSkin extends PngSkin { public class FBSkin extends PngSkin {

View File

@ -9,8 +9,8 @@ import java.util.Map;
import it.cavallium.warppi.Platform; import it.cavallium.warppi.Platform;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.framebuffer.FBEngine; import it.cavallium.warppi.gui.graphicengine.impl.framebuffer.FBEngine;
import it.cavallium.warppi.gui.graphicengine.gpu.GPUEngine; import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
import it.cavallium.warppi.util.Error; import it.cavallium.warppi.util.Error;
import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.model.ZipParameters; import net.lingala.zip4j.model.ZipParameters;
@ -33,7 +33,7 @@ public class HardwarePlatform implements Platform {
pu = new HardwarePngUtils(); pu = new HardwarePngUtils();
on = System.getProperty("os.name").toLowerCase(); on = System.getProperty("os.name").toLowerCase();
el = new HashMap<>(); el = new HashMap<>();
el.put("GPU engine", new GPUEngine()); el.put("GPU engine", new JOGLEngine());
el.put("framebuffer engine", new FBEngine()); el.put("framebuffer engine", new FBEngine());
settings = new HardwareSettings(); settings = new HardwareSettings();
} }

View File

@ -43,7 +43,7 @@
<module>hardware</module> <module>hardware</module>
<module>desktop</module> <module>desktop</module>
<module>teavm</module> <module>teavm</module>
<module>engine-gpu</module> <module>engine-jogl</module>
</modules> </modules>
<repositories> <repositories>

View File

@ -8,7 +8,7 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument; import org.teavm.jso.dom.html.HTMLDocument;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine; import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.common.RFTFont; import it.cavallium.warppi.gui.graphicengine.impl.common.RFTFont;
public class HtmlFont extends RFTFont { public class HtmlFont extends RFTFont {