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,2 */
{"", null, null }, /* 2,3 */
{"", null, null }, /* 2,4 */
{"", null, null }, /* 2,4 */
{"", null, null }, /* 2,5 */
{"", null, null }, /* 2,6 */
{"", 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.RenderingLoop;
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.util.Utils;
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();
if (selectedBlock != null) {
extra = selectedBlock.get().getExtraMenu();
extra.open();
if (extra != null) {
extra.open();
}
}
} else {
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.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.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;

View File

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

View File

@ -3,239 +3,4 @@ package it.cavallium.warppi.util;
public class ClassUtils {
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>
<groupId>it.cavallium</groupId>
<artifactId>warppi-engine-gpu</artifactId>
<artifactId>warppi-engine-jogl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -13,11 +13,11 @@ import org.apache.commons.io.FileUtils;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.Platform;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.cpu.CPUEngine;
import it.cavallium.warppi.gui.graphicengine.gpu.GPUEngine;
import it.cavallium.warppi.gui.graphicengine.headless24bit.Headless24bitEngine;
import it.cavallium.warppi.gui.graphicengine.headless256.Headless256Engine;
import it.cavallium.warppi.gui.graphicengine.headless8.Headless8Engine;
import it.cavallium.warppi.gui.graphicengine.impl.jansi24bitcolors.JAnsi24bitEngine;
import it.cavallium.warppi.gui.graphicengine.impl.jansi256colors.JAnsi256Engine;
import it.cavallium.warppi.gui.graphicengine.impl.jansi8colors.JAnsi8Engine;
import it.cavallium.warppi.gui.graphicengine.impl.jogl.JOGLEngine;
import it.cavallium.warppi.gui.graphicengine.impl.swing.SwingEngine;
import it.cavallium.warppi.util.CacheUtils;
import it.cavallium.warppi.util.Error;
import net.lingala.zip4j.core.ZipFile;
@ -41,11 +41,11 @@ public class DesktopPlatform implements Platform {
pu = new DesktopPngUtils();
on = System.getProperty("os.name").toLowerCase();
el = new HashMap<>();
el.put("CPU engine", new CPUEngine());
el.put("GPU engine", new GPUEngine());
el.put("headless 24 bit engine", new Headless24bitEngine());
el.put("headless 256 colors engine", new Headless256Engine());
el.put("headless 8 colors engine", new Headless8Engine());
el.put("CPU engine", new SwingEngine());
el.put("GPU engine", new JOGLEngine());
el.put("headless 24 bit engine", new JAnsi24bitEngine());
el.put("headless 256 colors engine", new JAnsi256Engine());
el.put("headless 8 colors engine", new JAnsi8Engine());
settings = new DesktopSettings();
}
@ -112,16 +112,16 @@ public class DesktopPlatform implements Platform {
@Override
public void alphaChanged(boolean val) {
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
if (currentEngine instanceof CPUEngine) {
((CPUEngine) currentEngine).setAlphaChanged(val);
if (currentEngine instanceof SwingEngine) {
((SwingEngine) currentEngine).setAlphaChanged(val);
}
}
@Override
public void shiftChanged(boolean val) {
final GraphicEngine currentEngine = Engine.INSTANCE.getHardwareDevice().getDisplayManager().engine;
if (currentEngine instanceof CPUEngine) {
((CPUEngine) currentEngine).setShiftChanged(val);
if (currentEngine instanceof SwingEngine) {
((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.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.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 RenderingLoop renderLoop;
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 Key precKey = null;
public Headless24bitEngine() {
public JAnsi24bitEngine() {
}
@Override
@ -70,7 +70,7 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
@Override
public void create(Runnable onInitialized) {
title = Engine.getPlatform().getSettings().getCalculatorName();
r = new Headless24bitRenderer();
r = new JAnsi24bitRenderer();
C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;
C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;
StaticVars.outputLevel = -1;
@ -203,13 +203,13 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
r.curColor = new int[] { 0x00, 0x87, 0x00 };
r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title);
if (win) {
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?25l");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} else {
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?25l");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
}
int[] precBgColor = 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];
curFgColor = r.fgColorMatrix[x + y * C_WIDTH];
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) {
WindowsSupport.writeConsole(out);
} else {
@ -269,7 +269,7 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
}
}
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) {
WindowsSupport.writeConsole(out);
} else {
@ -303,18 +303,18 @@ public class Headless24bitEngine implements it.cavallium.warppi.gui.graphicengin
}
@Override
public Headless24bitFont loadFont(String file) throws IOException {
return new Headless24bitFont();
public JAnsi24bitFont loadFont(String file) throws IOException {
return new JAnsi24bitFont();
}
@Override
public Headless24bitFont loadFont(String path, String file) throws IOException {
return new Headless24bitFont();
public JAnsi24bitFont loadFont(String path, String file) throws IOException {
return new JAnsi24bitFont();
}
@Override
public Headless24bitSkin loadSkin(String file) throws IOException {
return new Headless24bitSkin(file);
public JAnsi24bitSkin loadSkin(String file) throws IOException {
return new JAnsi24bitSkin(file);
}
@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 it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public class Headless256Font implements BinaryFont {
public class JAnsi24bitFont implements BinaryFont {
@Override
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;
public class Headless24bitRenderer implements Renderer {
public class JAnsi24bitRenderer implements Renderer {
Headless24bitFont currentFont;
public int[] size = new int[] { Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_MUL_X, Headless24bitEngine.C_HEIGHT * Headless24bitEngine.C_MUL_Y };
JAnsi24bitFont currentFont;
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[][] bgColorMatrixSs = new int[size[0] * size[1]][3];
protected char[] charmatrix = new char[Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT];
protected int[][] fgColorMatrix = new int[Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT][3];
protected int[][] bgColorMatrix = new int[Headless24bitEngine.C_WIDTH * Headless24bitEngine.C_HEIGHT][3];
protected char[] charmatrix = new char[JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT];
protected int[][] fgColorMatrix = new int[JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT][3];
protected int[][] bgColorMatrix = new int[JAnsi24bitEngine.C_WIDTH * JAnsi24bitEngine.C_HEIGHT][3];
protected int[] clearColor = rgbToIntArray(0xc5, 0xc2, 0xaf);
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 ansiFgColorPrefix = "38;2;";
@ -95,7 +95,7 @@ public class Headless24bitRenderer implements Renderer {
break;
}
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) {
break;
@ -148,7 +148,7 @@ public class Headless24bitRenderer implements Renderer {
for (int py = iy; py < y1; py++) {
drawPixelAt(' ', curColor, px, py);
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]) {
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;
}
@ -171,12 +171,12 @@ public class Headless24bitRenderer implements Renderer {
@Override
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;
if (cx >= size[0] || cy >= size[1]) {
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;
}
@ -189,7 +189,7 @@ public class Headless24bitRenderer implements Renderer {
if (cx + i >= size[0] || cy >= size[1]) {
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;
i++;
}
@ -197,14 +197,14 @@ public class Headless24bitRenderer implements Renderer {
@Override
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);
int i = 0;
for (final char c : text.toCharArray()) {
if (cx + i >= size[0] || cy >= size[1]) {
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;
i++;
}
@ -272,7 +272,7 @@ public class Headless24bitRenderer implements Renderer {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
if (transparent) {
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;
}
}
@ -292,7 +292,7 @@ public class Headless24bitRenderer implements Renderer {
}
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] = ' ';
}
for (int i = 0; i < size[0] * size[1]; i++) {
@ -302,7 +302,7 @@ public class Headless24bitRenderer implements Renderer {
}
@Override
public Headless24bitFont getCurrentFont() {
public JAnsi24bitFont getCurrentFont() {
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.io.IOException;
@ -8,12 +8,12 @@ import javax.imageio.ImageIO;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin;
public class Headless24bitSkin implements Skin {
public class JAnsi24bitSkin implements Skin {
public int[][] skinData;
public int[] skinSize;
Headless24bitSkin(String file) throws IOException {
JAnsi24bitSkin(String file) throws IOException {
load(file);
}
@ -36,7 +36,7 @@ public class Headless24bitSkin implements Skin {
final int g = (rgb >> 8) & 0xFF;
final int b = rgb & 0xFF;
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 };
}
}
@ -51,7 +51,7 @@ public class Headless24bitSkin implements Skin {
@Override
public void use(GraphicEngine d) {
((Headless24bitRenderer) d.getRenderer()).currentSkin = this;
((JAnsi24bitRenderer) d.getRenderer()).currentSkin = this;
}
@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.util.logging.ConsoleHandler;
@ -13,12 +13,12 @@ import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.Renderer;
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;
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 RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8;
@ -65,7 +65,7 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
@Override
public void create(Runnable onInitialized) {
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_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
StaticVars.outputLevel = -1;
@ -198,13 +198,13 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
r.curColor = 0x1C;
r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title);
if (win) {
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?25l");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} else {
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?25l");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
}
for (int y = 0; y < C_HEIGHT; y++) {
int precBgColor = -1;
@ -215,7 +215,7 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
curBgColor = r.bgColorMatrix[x + y * C_WIDTH];
curFgColor = r.fgColorMatrix[x + y * C_WIDTH];
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) {
WindowsSupport.writeConsole(str);
} else {
@ -223,7 +223,7 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
}
}
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) {
WindowsSupport.writeConsole(str);
} else {
@ -256,18 +256,18 @@ public class Headless256Engine implements it.cavallium.warppi.gui.graphicengine.
}
@Override
public Headless256Font loadFont(String file) throws IOException {
return new Headless256Font();
public JAnsi256Font loadFont(String file) throws IOException {
return new JAnsi256Font();
}
@Override
public Headless256Font loadFont(String path, String file) throws IOException {
return new Headless256Font();
public JAnsi256Font loadFont(String path, String file) throws IOException {
return new JAnsi256Font();
}
@Override
public Headless256Skin loadSkin(String file) throws IOException {
return new Headless256Skin(file);
public JAnsi256Skin loadSkin(String file) throws IOException {
return new JAnsi256Skin(file);
}
@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 it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public class Headless24bitFont implements BinaryFont {
public class JAnsi256Font implements BinaryFont {
@Override
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;
public class Headless256Renderer implements Renderer {
public class JAnsi256Renderer implements Renderer {
Headless256Font currentFont;
protected char[] charmatrix = new char[Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT];
protected int[] fgColorMatrix = new int[Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT];
protected int[] bgColorMatrix = new int[Headless256Engine.C_WIDTH * Headless256Engine.C_HEIGHT];
JAnsi256Font currentFont;
protected char[] charmatrix = new char[JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT];
protected int[] fgColorMatrix = new int[JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT];
protected int[] bgColorMatrix = new int[JAnsi256Engine.C_WIDTH * JAnsi256Engine.C_HEIGHT];
protected int clearColor = rgbToX256(0xc5, 0xc2, 0xaf);
protected int curColor = clearColor;
public Headless256Skin currentSkin;
public JAnsi256Skin currentSkin;
public static final String ANSI_PREFIX = "\u001B[";
public static final String ansiFgColorPrefix = "38;5;";
@ -110,10 +110,10 @@ public class Headless256Renderer implements Renderer {
@Override
public void glDrawLine(float x1, float y1, float x2, float y2) {
x1 /= Headless256Engine.C_MUL_X;
x2 /= Headless256Engine.C_MUL_X;
y1 /= Headless256Engine.C_MUL_Y;
y2 /= Headless256Engine.C_MUL_Y;
x1 /= JAnsi256Engine.C_MUL_X;
x2 /= JAnsi256Engine.C_MUL_X;
y1 /= JAnsi256Engine.C_MUL_Y;
y2 /= JAnsi256Engine.C_MUL_Y;
final int dx = (int) Math.abs(x2 - x1);
final int dy = (int) Math.abs(y2 - y1);
@ -124,11 +124,11 @@ public class Headless256Renderer implements Renderer {
int err = dx - dy;
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;
}
bgColorMatrix[((int) x1) + ((int) y1) * Headless256Engine.C_WIDTH] = curColor;
charmatrix[((int) x1) + ((int) y1) * Headless256Engine.C_WIDTH] = ' ';
bgColorMatrix[((int) x1) + ((int) y1) * JAnsi256Engine.C_WIDTH] = curColor;
charmatrix[((int) x1) + ((int) y1) * JAnsi256Engine.C_WIDTH] = ' ';
if (x1 == x2 && y1 == y2) {
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,
float uvHeight) {
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 {
glFillColor(x, y, width, height);
}
@ -160,23 +160,23 @@ public class Headless256Renderer implements Renderer {
@Override
public void glFillColor(float x, float y, float width, float height) {
final int ix = (int) x / Headless256Engine.C_MUL_X;
final int iy = (int) y / Headless256Engine.C_MUL_Y;
final int iw = (int) width / Headless256Engine.C_MUL_X;
final int ih = (int) height / Headless256Engine.C_MUL_Y;
final int ix = (int) x / JAnsi256Engine.C_MUL_X;
final int iy = (int) y / JAnsi256Engine.C_MUL_Y;
final int iw = (int) width / JAnsi256Engine.C_MUL_X;
final int ih = (int) height / JAnsi256Engine.C_MUL_Y;
int x1 = ix + iw;
int y1 = iy + ih;
if (ix >= Headless256Engine.C_WIDTH || iy >= Headless256Engine.C_WIDTH) {
if (ix >= JAnsi256Engine.C_WIDTH || iy >= JAnsi256Engine.C_WIDTH) {
return;
}
if (x1 >= Headless256Engine.C_WIDTH) {
x1 = Headless256Engine.C_WIDTH;
if (x1 >= JAnsi256Engine.C_WIDTH) {
x1 = JAnsi256Engine.C_WIDTH;
}
if (y1 >= Headless256Engine.C_HEIGHT) {
y1 = Headless256Engine.C_HEIGHT;
if (y1 >= JAnsi256Engine.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 py = iy; py < y1; py++) {
bgColorMatrix[(px) + (py) * sizeW] = curColor;
@ -187,13 +187,13 @@ public class Headless256Renderer implements Renderer {
@Override
public void glDrawCharLeft(int x, int y, char ch) {
final int cx = (x) / Headless256Engine.C_MUL_X;
final int cy = (y) / Headless256Engine.C_MUL_Y;
if (cx >= Headless256Engine.C_WIDTH || cy >= Headless256Engine.C_HEIGHT) {
final int cx = (x) / JAnsi256Engine.C_MUL_X;
final int cy = (y) / JAnsi256Engine.C_MUL_Y;
if (cx >= JAnsi256Engine.C_WIDTH || cy >= JAnsi256Engine.C_HEIGHT) {
return;
}
charmatrix[cx + cy * Headless256Engine.C_WIDTH] = ch;
fgColorMatrix[cx + cy * Headless256Engine.C_WIDTH] = curColor;
charmatrix[cx + cy * JAnsi256Engine.C_WIDTH] = ch;
fgColorMatrix[cx + cy * JAnsi256Engine.C_WIDTH] = curColor;
}
@Override
@ -203,41 +203,41 @@ public class Headless256Renderer implements Renderer {
@Override
public void glDrawCharRight(int x, int y, char ch) {
final int cx = (x) / Headless256Engine.C_MUL_X - 1;
final int cy = (y) / Headless256Engine.C_MUL_Y;
if (cx >= Headless256Engine.C_WIDTH || cy >= Headless256Engine.C_HEIGHT) {
final int cx = (x) / JAnsi256Engine.C_MUL_X - 1;
final int cy = (y) / JAnsi256Engine.C_MUL_Y;
if (cx >= JAnsi256Engine.C_WIDTH || cy >= JAnsi256Engine.C_HEIGHT) {
return;
}
charmatrix[cx + cy * Headless256Engine.C_WIDTH] = ch;
fgColorMatrix[cx + cy * Headless256Engine.C_WIDTH] = curColor;
charmatrix[cx + cy * JAnsi256Engine.C_WIDTH] = ch;
fgColorMatrix[cx + cy * JAnsi256Engine.C_WIDTH] = curColor;
}
@Override
public void glDrawStringLeft(float x, float y, String text) {
final int cx = ((int) x) / Headless256Engine.C_MUL_X;
final int cy = ((int) y) / Headless256Engine.C_MUL_Y;
final int cx = ((int) x) / JAnsi256Engine.C_MUL_X;
final int cy = ((int) y) / JAnsi256Engine.C_MUL_Y;
int i = 0;
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;
}
charmatrix[cx + i + cy * Headless256Engine.C_WIDTH] = c;
fgColorMatrix[cx + i + cy * Headless256Engine.C_WIDTH] = curColor;
charmatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = c;
fgColorMatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = curColor;
i++;
}
}
@Override
public void glDrawStringCenter(float x, float y, String text) {
final int cx = ((int) x) / Headless256Engine.C_MUL_X - text.length() / 2;
final int cy = ((int) y) / Headless256Engine.C_MUL_Y;
final int cx = ((int) x) / JAnsi256Engine.C_MUL_X - text.length() / 2;
final int cy = ((int) y) / JAnsi256Engine.C_MUL_Y;
int i = 0;
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;
}
charmatrix[cx + i + cy * Headless256Engine.C_WIDTH] = c;
fgColorMatrix[cx + i + cy * Headless256Engine.C_WIDTH] = curColor;
charmatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = c;
fgColorMatrix[cx + i + cy * JAnsi256Engine.C_WIDTH] = curColor;
i++;
}
}
@ -266,14 +266,14 @@ public class Headless256Renderer implements Renderer {
t1 = t00;
height = t1 - t0;
}
if (x0 >= Headless256Engine.C_WIDTH || y0 >= Headless256Engine.C_WIDTH) {
if (x0 >= JAnsi256Engine.C_WIDTH || y0 >= JAnsi256Engine.C_WIDTH) {
return;
}
if (x0 + width >= Headless256Engine.C_WIDTH) {
s1 = Headless256Engine.C_WIDTH - x0 + s0;
if (x0 + width >= JAnsi256Engine.C_WIDTH) {
s1 = JAnsi256Engine.C_WIDTH - x0 + s0;
}
if (y0 + height >= Headless256Engine.C_HEIGHT) {
t1 = Headless256Engine.C_HEIGHT - y0 + t0;
if (y0 + height >= JAnsi256Engine.C_HEIGHT) {
t1 = JAnsi256Engine.C_HEIGHT - y0 + t0;
}
if (x0 < 0) {
if (onex == -1) {
@ -299,12 +299,12 @@ public class Headless256Renderer implements Renderer {
for (int texy = 0; texy < t1 - t0; texy++) {
pixelX = (x0 + texx * onex + width);
pixelY = (y0 + texy * oney + height);
if (pixelY < Headless256Engine.C_HEIGHT) {
if (pixelX - (pixelX % Headless256Engine.C_WIDTH) == 0) {
if (pixelY < JAnsi256Engine.C_HEIGHT) {
if (pixelX - (pixelX % JAnsi256Engine.C_WIDTH) == 0) {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
if (transparent && !((newColor & TRANSPARENT) == TRANSPARENT)) {
charmatrix[pixelX + pixelY * Headless256Engine.C_WIDTH] = ' ';
bgColorMatrix[pixelX + pixelY * Headless256Engine.C_WIDTH] = newColor;
charmatrix[pixelX + pixelY * JAnsi256Engine.C_WIDTH] = ' ';
bgColorMatrix[pixelX + pixelY * JAnsi256Engine.C_WIDTH] = newColor;
}
}
}
@ -318,7 +318,7 @@ public class Headless256Renderer implements Renderer {
}
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] = ' ';
bgColorMatrix[i] = clearColor;
fgColorMatrix[i] = 0;
@ -326,7 +326,7 @@ public class Headless256Renderer implements Renderer {
}
@Override
public Headless256Font getCurrentFont() {
public JAnsi256Font getCurrentFont() {
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.image.AffineTransformOp;
@ -10,12 +10,12 @@ import javax.imageio.ImageIO;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin;
public class Headless256Skin implements Skin {
public class JAnsi256Skin implements Skin {
public int[] skinData;
public int[] skinSize;
Headless256Skin(String file) throws IOException {
JAnsi256Skin(String file) throws IOException {
load(file);
}
@ -29,7 +29,7 @@ public class Headless256Skin implements Skin {
public static int[] getMatrixOfImage(BufferedImage bufferedImage) {
BufferedImage after = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
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);
after = scaleOp.filter(bufferedImage, after);
@ -43,7 +43,7 @@ public class Headless256Skin implements Skin {
final int g = (rgb >> 8) & 0xFF;
final int b = rgb & 0xFF;
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
public void use(GraphicEngine d) {
((Headless256Renderer) d.getRenderer()).currentSkin = this;
((JAnsi256Renderer) d.getRenderer()).currentSkin = this;
}
@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.util.logging.ConsoleHandler;
@ -13,12 +13,12 @@ import it.cavallium.warppi.event.Key;
import it.cavallium.warppi.flow.Observable;
import it.cavallium.warppi.gui.graphicengine.Renderer;
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;
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 RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8;
@ -65,7 +65,7 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
@Override
public void create(Runnable onInitialized) {
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_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
StaticVars.outputLevel = -1;
@ -198,13 +198,13 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
r.curColor = 0x1C;
r.glDrawStringCenter((C_WIDTH * C_MUL_X) / 2, 0, title);
if (win) {
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(Headless24bitRenderer.ANSI_PREFIX + "?25l");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
WindowsSupport.writeConsole(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
} else {
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(Headless24bitRenderer.ANSI_PREFIX + "?25l");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "0;0f");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?12l");
AnsiConsole.out.print(JAnsi24bitRenderer.ANSI_PREFIX + "?25l");
}
for (int y = 0; y < C_HEIGHT; y++) {
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;
curFgColor = r.colorMatrix[x + y * C_WIDTH] & 0x0F;
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) {
WindowsSupport.writeConsole(str);
} else {
@ -223,7 +223,7 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
}
}
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) {
WindowsSupport.writeConsole(str);
} else {
@ -256,18 +256,18 @@ public class Headless8Engine implements it.cavallium.warppi.gui.graphicengine.Gr
}
@Override
public Headless8Font loadFont(String file) throws IOException {
return new Headless8Font();
public JAnsi8Font loadFont(String file) throws IOException {
return new JAnsi8Font();
}
@Override
public Headless8Font loadFont(String path, String file) throws IOException {
return new Headless8Font();
public JAnsi8Font loadFont(String path, String file) throws IOException {
return new JAnsi8Font();
}
@Override
public Headless8Skin loadSkin(String file) throws IOException {
return new Headless8Skin(file);
public JAnsi8Skin loadSkin(String file) throws IOException {
return new JAnsi8Skin(file);
}
@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 it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
public class Headless8Font implements BinaryFont {
public class JAnsi8Font implements BinaryFont {
@Override
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.gui.graphicengine.Renderer;
public class Headless8Renderer implements Renderer {
public class JAnsi8Renderer implements Renderer {
Headless8Font currentFont;
protected char[] charmatrix = new char[Headless8Engine.C_WIDTH * Headless8Engine.C_HEIGHT];
protected int[] colorMatrix = new int[Headless8Engine.C_WIDTH * Headless8Engine.C_HEIGHT];
JAnsi8Font currentFont;
protected char[] charmatrix = new char[JAnsi8Engine.C_WIDTH * JAnsi8Engine.C_HEIGHT];
protected int[] colorMatrix = new int[JAnsi8Engine.C_WIDTH * JAnsi8Engine.C_HEIGHT];
protected int clearColor = hexColor(0xc5, 0xc2, 0xaf);
protected int curColor = clearColor;
public Headless8Skin currentSkin;
public JAnsi8Skin currentSkin;
public static final String ANSI_PREFIX = "\u001B[";
public static final String ansiFgColorPrefix = "3";
@ -231,10 +231,10 @@ public class Headless8Renderer implements Renderer {
@Override
public void glDrawLine(float x1, float y1, float x2, float y2) {
x1 /= Headless8Engine.C_MUL_X;
x2 /= Headless8Engine.C_MUL_X;
y1 /= Headless8Engine.C_MUL_Y;
y2 /= Headless8Engine.C_MUL_Y;
x1 /= JAnsi8Engine.C_MUL_X;
x2 /= JAnsi8Engine.C_MUL_X;
y1 /= JAnsi8Engine.C_MUL_Y;
y2 /= JAnsi8Engine.C_MUL_Y;
final int dx = (int) Math.abs(x2 - x1);
final int dy = (int) Math.abs(y2 - y1);
@ -245,13 +245,13 @@ public class Headless8Renderer implements Renderer {
int err = dx - dy;
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;
}
final int precBG = colorMatrix[((int) x1) + ((int) y1) * Headless8Engine.C_WIDTH] & 0xF0;
colorMatrix[((int) x1) + ((int) y1) * Headless8Engine.C_WIDTH] = precBG | curColor;
final int precBG = colorMatrix[((int) x1) + ((int) y1) * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[((int) x1) + ((int) y1) * JAnsi8Engine.C_WIDTH] = precBG | curColor;
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) {
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,
float uvHeight) {
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 {
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) {
final int ix = (int) x / Headless8Engine.C_MUL_X;
final int iy = (int) y / Headless8Engine.C_MUL_Y;
final int iw = (int) width / Headless8Engine.C_MUL_X;
final int ih = (int) height / Headless8Engine.C_MUL_Y;
final int ix = (int) x / JAnsi8Engine.C_MUL_X;
final int iy = (int) y / JAnsi8Engine.C_MUL_Y;
final int iw = (int) width / JAnsi8Engine.C_MUL_X;
final int ih = (int) height / JAnsi8Engine.C_MUL_Y;
int x1 = ix + iw;
int y1 = iy + ih;
if (ix >= Headless8Engine.C_WIDTH || iy >= Headless8Engine.C_WIDTH) {
if (ix >= JAnsi8Engine.C_WIDTH || iy >= JAnsi8Engine.C_WIDTH) {
return;
}
if (x1 >= Headless8Engine.C_WIDTH) {
x1 = Headless8Engine.C_WIDTH;
if (x1 >= JAnsi8Engine.C_WIDTH) {
x1 = JAnsi8Engine.C_WIDTH;
}
if (y1 >= Headless8Engine.C_HEIGHT) {
y1 = Headless8Engine.C_HEIGHT;
if (y1 >= JAnsi8Engine.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 py = iy; py < y1; py++) {
final int precBG = colorMatrix[(px) + (py) * sizeW] & 0xF0;
@ -320,14 +320,14 @@ public class Headless8Renderer implements Renderer {
@Override
public void glDrawCharLeft(int x, int y, char ch) {
final int cx = (x) / Headless8Engine.C_MUL_X;
final int cy = (y) / Headless8Engine.C_MUL_Y;
if (cx >= Headless8Engine.C_WIDTH || cy >= Headless8Engine.C_HEIGHT) {
final int cx = (x) / JAnsi8Engine.C_MUL_X;
final int cy = (y) / JAnsi8Engine.C_MUL_Y;
if (cx >= JAnsi8Engine.C_WIDTH || cy >= JAnsi8Engine.C_HEIGHT) {
return;
}
charmatrix[cx + cy * Headless8Engine.C_WIDTH] = ch;
final int precBG = colorMatrix[cx + cy * Headless8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + cy * Headless8Engine.C_WIDTH] = precBG | curColor;
charmatrix[cx + cy * JAnsi8Engine.C_WIDTH] = ch;
final int precBG = colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
}
@Override
@ -337,44 +337,44 @@ public class Headless8Renderer implements Renderer {
@Override
public void glDrawCharRight(int x, int y, char ch) {
final int cx = (x) / Headless8Engine.C_MUL_X - 1;
final int cy = (y) / Headless8Engine.C_MUL_Y;
if (cx >= Headless8Engine.C_WIDTH || cy >= Headless8Engine.C_HEIGHT) {
final int cx = (x) / JAnsi8Engine.C_MUL_X - 1;
final int cy = (y) / JAnsi8Engine.C_MUL_Y;
if (cx >= JAnsi8Engine.C_WIDTH || cy >= JAnsi8Engine.C_HEIGHT) {
return;
}
charmatrix[cx + cy * Headless8Engine.C_WIDTH] = ch;
final int precBG = colorMatrix[cx + cy * Headless8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + cy * Headless8Engine.C_WIDTH] = precBG | curColor;
charmatrix[cx + cy * JAnsi8Engine.C_WIDTH] = ch;
final int precBG = colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
}
@Override
public void glDrawStringLeft(float x, float y, String text) {
final int cx = ((int) x) / Headless8Engine.C_MUL_X;
final int cy = ((int) y) / Headless8Engine.C_MUL_Y;
final int cx = ((int) x) / JAnsi8Engine.C_MUL_X;
final int cy = ((int) y) / JAnsi8Engine.C_MUL_Y;
int i = 0;
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;
}
charmatrix[cx + i + cy * Headless8Engine.C_WIDTH] = c;
final int precBG = colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] = precBG | curColor;
charmatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = c;
final int precBG = colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
i++;
}
}
@Override
public void glDrawStringCenter(float x, float y, String text) {
final int cx = ((int) x) / Headless8Engine.C_MUL_X - text.length() / 2;
final int cy = ((int) y) / Headless8Engine.C_MUL_Y;
final int cx = ((int) x) / JAnsi8Engine.C_MUL_X - text.length() / 2;
final int cy = ((int) y) / JAnsi8Engine.C_MUL_Y;
int i = 0;
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;
}
charmatrix[cx + i + cy * Headless8Engine.C_WIDTH] = c;
final int precBG = colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + i + cy * Headless8Engine.C_WIDTH] = precBG | curColor;
charmatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = c;
final int precBG = colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[cx + i + cy * JAnsi8Engine.C_WIDTH] = precBG | curColor;
i++;
}
}
@ -404,14 +404,14 @@ public class Headless8Renderer implements Renderer {
t1 = t00;
height = t1 - t0;
}
if (x0 >= Headless8Engine.C_WIDTH || y0 >= Headless8Engine.C_WIDTH) {
if (x0 >= JAnsi8Engine.C_WIDTH || y0 >= JAnsi8Engine.C_WIDTH) {
return;
}
if (x0 + width >= Headless8Engine.C_WIDTH) {
s1 = Headless8Engine.C_WIDTH - x0 + s0;
if (x0 + width >= JAnsi8Engine.C_WIDTH) {
s1 = JAnsi8Engine.C_WIDTH - x0 + s0;
}
if (y0 + height >= Headless8Engine.C_HEIGHT) {
t1 = Headless8Engine.C_HEIGHT - y0 + t0;
if (y0 + height >= JAnsi8Engine.C_HEIGHT) {
t1 = JAnsi8Engine.C_HEIGHT - y0 + t0;
}
if (x0 < 0) {
if (onex == -1) {
@ -437,11 +437,11 @@ public class Headless8Renderer implements Renderer {
for (int texy = 0; texy < t1 - t0; texy++) {
pixelX = (x0 + texx * onex + width);
pixelY = (y0 + texy * oney + height);
if (pixelY < Headless8Engine.C_HEIGHT) {
if (pixelX - (pixelX % Headless8Engine.C_WIDTH) == 0) {
if (pixelY < JAnsi8Engine.C_HEIGHT) {
if (pixelX - (pixelX % JAnsi8Engine.C_WIDTH) == 0) {
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
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 a1 = 1f - 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);
newColor = 0xFF000000 | r << 16 | g << 8 | b;
}
final int bgColor = colorMatrix[pixelX + pixelY * Headless8Engine.C_WIDTH] & 0xF0;
colorMatrix[pixelX + pixelY * Headless8Engine.C_WIDTH] = bgColor | hexColor(newColor >> 16 & 0xFF, newColor >> 8 & 0xFF, newColor & 0xFF);
final int bgColor = colorMatrix[pixelX + pixelY * JAnsi8Engine.C_WIDTH] & 0xF0;
colorMatrix[pixelX + pixelY * JAnsi8Engine.C_WIDTH] = bgColor | hexColor(newColor >> 16 & 0xFF, newColor >> 8 & 0xFF, newColor & 0xFF);
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() {
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] = ' ';
colorMatrix[i] = clearColor << 4;
}
}
@Override
public Headless8Font getCurrentFont() {
public JAnsi8Font getCurrentFont() {
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.image.AffineTransformOp;
@ -10,12 +10,12 @@ import javax.imageio.ImageIO;
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
import it.cavallium.warppi.gui.graphicengine.Skin;
public class Headless8Skin implements Skin {
public class JAnsi8Skin implements Skin {
public int[] skinData;
public int[] skinSize;
Headless8Skin(String file) throws IOException {
JAnsi8Skin(String file) throws IOException {
load(file);
}
@ -29,7 +29,7 @@ public class Headless8Skin implements Skin {
public static int[] getMatrixOfImage(BufferedImage bufferedImage) {
BufferedImage after = new BufferedImage(bufferedImage.getWidth(null), bufferedImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
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);
after = scaleOp.filter(bufferedImage, after);
@ -52,7 +52,7 @@ public class Headless8Skin implements Skin {
@Override
public void use(GraphicEngine d) {
((Headless8Renderer) d.getRenderer()).currentSkin = this;
((JAnsi8Renderer) d.getRenderer()).currentSkin = this;
}
@Override

View File

@ -2,7 +2,7 @@
// 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.Dimension;
@ -16,7 +16,7 @@ import java.io.IOException;
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 int state;
public JAdvancedButton() {
public SwingAdvancedButton() {
this.setOpaque(false);
this.backgroundImage = null;
this.backgroundSize = new Dimension(0, 0);
}
public JAdvancedButton(final BufferedImage backgroundImage) throws IOException {
public SwingAdvancedButton(final BufferedImage backgroundImage) throws IOException {
this.setOpaque(false);
this.backgroundImage = backgroundImage;
if (backgroundImage != null) {
@ -45,7 +45,7 @@ public class JAdvancedButton extends JButton {
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.backgroundImage = backgroundImage;
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.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.Skin;
public class CPUEngine implements GraphicEngine {
public class SwingEngine implements GraphicEngine {
private SwingWindow INSTANCE;
public CPURenderer r;
public SwingRenderer r;
public volatile BufferedImage g;
public volatile boolean initialized;
public Semaphore exitSemaphore;
@ -38,7 +38,7 @@ public class CPUEngine implements GraphicEngine {
public void setDisplayMode(final int ww, final int wh) {
INSTANCE.setSize(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);
}
@ -49,7 +49,7 @@ public class CPUEngine implements GraphicEngine {
@Override
public void create(Runnable onInitialized) {
r = new CPURenderer();
r = new SwingRenderer();
g = new BufferedImage(r.size[0], r.size[1], BufferedImage.TYPE_INT_RGB);
initialized = false;
exitSemaphore = new Semaphore(0);
@ -150,23 +150,23 @@ public class CPUEngine implements GraphicEngine {
}
@Override
public CPURenderer getRenderer() {
public SwingRenderer getRenderer() {
return r;
}
@Override
public BinaryFont loadFont(String fontName) throws IOException {
return new CPUFont(fontName);
return new SwingFont(fontName);
}
@Override
public BinaryFont loadFont(String path, String fontName) throws IOException {
return new CPUFont(path, fontName);
return new SwingFont(path, fontName);
}
@Override
public Skin loadSkin(String file) throws IOException {
return new CPUSkin(file);
return new SwingSkin(file);
}
@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;
@ -6,10 +6,10 @@ import it.cavallium.warppi.StaticVars;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.Renderer;
public class CPURenderer implements Renderer {
public class SwingRenderer implements Renderer {
public int clearcolor = 0xFFc5c2af;
public CPUFont currentFont;
public CPUSkin currentSkin;
public SwingFont currentFont;
public SwingSkin currentSkin;
public int color = 0xFF000000;
public int[] size = new int[] { 1, 1 };
static int[] canvas2d = new int[1];
@ -306,8 +306,8 @@ public class CPURenderer implements Renderer {
j = ix + cpos + dx;
if (j > 0 & j < screenSize[0]) {
final int bit = dx + dy * currentFont.charW;
currentInt = (int) (Math.floor(bit) / (CPUFont.intBits));
currentIntBitPosition = bit - (currentInt * CPUFont.intBits);
currentInt = (int) (Math.floor(bit) / (SwingFont.intBits));
currentIntBitPosition = bit - (currentInt * SwingFont.intBits);
final int charIdx = charIndex * currentFont.charIntCount + currentInt;
if (charIdx >= 0 && charIdx < currentFont.chars32.length) {
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.Color;
@ -45,15 +45,15 @@ public class SwingWindow extends JFrame {
private static final long serialVersionUID = 2945898937634075491L;
public CustomCanvas c;
private RenderingLoop renderingLoop;
private final CPUEngine display;
private final SwingEngine display;
private int mult = 1;
private BehaviorSubject<Integer[]> onResize;
private Observable<Integer[]> onResize$;
public JPanel buttonsPanel;
private JAdvancedButton[][] buttons;
private SwingAdvancedButton[][] buttons;
private int BTN_SIZE;
public SwingWindow(CPUEngine disp) {
public SwingWindow(SwingEngine disp) {
display = disp;
this.setLayout(new BorderLayout());
this.setBackground(Color.BLACK);
@ -93,7 +93,7 @@ public class SwingWindow extends JFrame {
if (disp.r.size[1] <= 0) {
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);
});
@ -201,7 +201,7 @@ public class SwingWindow extends JFrame {
BTN_SIZE *= 2;
}
buttons = new JAdvancedButton[8][8];
buttons = new SwingAdvancedButton[8][8];
JPanel buttonsPanelContainer = new JPanel();
buttonsPanelContainer.setLayout(new FlowLayout());
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 {
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.setText(Keyboard.getKeyName(row, col));
b.setForeground(Color.BLACK);
@ -266,7 +266,7 @@ public class SwingWindow extends JFrame {
public void setAlphaChanged(boolean val) {
for (int row = 0; row < buttons.length; row++) {
for (int col = 0; col < buttons[0].length; col++) {
JAdvancedButton btn = buttons[row][col];
SwingAdvancedButton btn = buttons[row][col];
if (btn != null) {
btn.setText(Keyboard.getKeyName(row, col));
if (row == 0 && col == 1) {
@ -289,7 +289,7 @@ public class SwingWindow extends JFrame {
public void setShiftChanged(boolean val) {
for (int row = 0; row < buttons.length; row++) {
for (int col = 0; col < buttons[0].length; col++) {
JAdvancedButton btn = buttons[row][col];
SwingAdvancedButton btn = buttons[row][col];
if (btn != null) {
btn.setText(Keyboard.getKeyName(row, col));
if (row == 0 && col == 0) {
@ -359,7 +359,7 @@ public class SwingWindow extends JFrame {
renderingLoop.refresh();
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.drawImage(display.g, 0, 0, display.r.size[0] * mult, display.r.size[1] * mult, null);
// long time2 = System.nanoTime();

View File

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

View File

@ -8,12 +8,12 @@
<artifactId>warppi</artifactId>
<version>${project.version}</version>
</parent>
<artifactId>warppi-engine-gpu</artifactId>
<artifactId>warppi-engine-jogl</artifactId>
<packaging>bundle</packaging>
<name>WarpPI Calculator GPU Engine</name>
<description>WarpPI Calculator engine-gpu project</description>
<name>WarpPI Calculator JOGL Engine</name>
<description>WarpPI Calculator engine-jogl project</description>
<dependencies>
<dependency>
<groupId>it.cavallium</groupId>
@ -44,7 +44,7 @@
<configuration>
<instructions>
<Export-Package>it.cavallium.warppi.*</Export-Package>
<Bundle-SymbolicName>warppi-engine-gpu</Bundle-SymbolicName>
<Bundle-SymbolicName>warppi-engine-jogl</Bundle-SymbolicName>
</instructions>
</configuration>
</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.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.Skin;
public class GPUEngine implements GraphicEngine {
public class JOGLEngine implements GraphicEngine {
private volatile boolean initialized;
private volatile boolean created;
private NEWTWindow wnd;
private RenderingLoop d;
private GPURenderer r;
private final Map<String, GPUFont> fontCache = new HashMap<>();
private JOGLRenderer r;
private final Map<String, JOGLFont> fontCache = new HashMap<>();
int[] size;
private final CopyOnWriteArrayList<BinaryFont> registeredFonts = new CopyOnWriteArrayList<>();
private final Semaphore exitSemaphore = new Semaphore(0);
@ -76,7 +76,7 @@ public class GPUEngine implements GraphicEngine {
created = true;
registeredTextures = new LinkedList<>();
unregisteredTextures = new LinkedList<>();
r = new GPURenderer();
r = new JOGLRenderer();
wnd = new NEWTWindow(this);
wnd.create();
setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
@ -118,43 +118,43 @@ public class GPUEngine implements GraphicEngine {
@Override
public void repaint() {
if (d != null & r != null && GPURenderer.gl != null) {
if (d != null & r != null && JOGLRenderer.gl != null) {
d.refresh();
}
}
@Override
public GPURenderer getRenderer() {
public JOGLRenderer getRenderer() {
return r;
}
@Override
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)) {
return entry.getValue();
}
}
final GPUFont font = new GPUFont(this, name);
final JOGLFont font = new JOGLFont(this, name);
fontCache.put(name, font);
return font;
}
@Override
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)) {
return entry.getValue();
}
}
final GPUFont font = new GPUFont(this, path, name);
final JOGLFont font = new JOGLFont(this, path, name);
fontCache.put(name, font);
return font;
}
@Override
public Skin loadSkin(String file) throws IOException {
return new GPUSkin(this, file);
return new JOGLSkin(this, file);
}
@Override
@ -191,7 +191,7 @@ public class GPUEngine implements GraphicEngine {
return false;
}
public void registerFont(GPUFont gpuFont) {
public void registerFont(JOGLFont 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.FileOutputStream;
@ -15,9 +15,9 @@ import ar.com.hjg.pngj.PngWriter;
import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
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 int textureW;
@ -35,13 +35,13 @@ public class GPUFont implements BinaryFont {
private boolean initialized = false;
private File tmpFont;
GPUFont(GraphicEngine g, String name) throws IOException {
JOGLFont(GraphicEngine g, String name) throws IOException {
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);
((GPUEngine) g).registerFont(this);
((JOGLEngine) g).registerFont(this);
}
@Override
@ -182,7 +182,7 @@ public class GPUFont implements BinaryFont {
private void genTexture() {
try {
texture = GPURenderer.importTexture(tmpFont, true);
texture = JOGLRenderer.importTexture(tmpFont, true);
tmpFont = null;
} catch (GLException | IOException e) {
e.printStackTrace();
@ -205,7 +205,7 @@ public class GPUFont implements BinaryFont {
if (!initialized) {
initialize(d);
}
final GPURenderer r = (GPURenderer) d.getRenderer();
final JOGLRenderer r = (JOGLRenderer) d.getRenderer();
r.currentFont = this;
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.io.File;
@ -21,7 +21,7 @@ import it.cavallium.warppi.Engine;
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
import it.cavallium.warppi.gui.graphicengine.Renderer;
public class GPURenderer implements Renderer {
public class JOGLRenderer implements Renderer {
public static GL2ES1 gl;
@ -59,7 +59,7 @@ public class GPURenderer implements Renderer {
float currentTexWidth;
float currentTexHeight;
GPUFont currentFont;
JOGLFont currentFont;
@Override
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 {
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;
if (isResource) {
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.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.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 int w;
@ -21,7 +21,7 @@ public class GPUSkin implements Skin {
private boolean initialized = false;
private boolean isResource;
GPUSkin(GraphicEngine d, String file) throws IOException {
JOGLSkin(GraphicEngine d, String file) throws IOException {
load(file);
}
@ -38,11 +38,11 @@ public class GPUSkin implements Skin {
@Override
public void initialize(GraphicEngine d) {
try {
final OpenedTextureData i = GPURenderer.openTexture(texturePath, isResource);
t = GPURenderer.importTexture(i.f, i.deleteOnExit);
final OpenedTextureData i = JOGLRenderer.openTexture(texturePath, isResource);
t = JOGLRenderer.importTexture(i.f, i.deleteOnExit);
w = i.w;
h = i.h;
((GPUEngine) d).registerTexture(t);
((JOGLEngine) d).registerTexture(t);
initialized = true;
} catch (GLException | IOException e) {
e.printStackTrace();
@ -55,7 +55,7 @@ public class GPUSkin implements Skin {
if (!initialized) {
initialize(d);
}
final GPURenderer r = (GPURenderer) d.getRenderer();
final JOGLRenderer r = (JOGLRenderer) d.getRenderer();
r.useTexture(t, w, h);
}

View File

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

View File

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

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;

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 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 {

View File

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

View File

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

View File

@ -8,7 +8,7 @@ import org.teavm.jso.dom.html.HTMLCanvasElement;
import org.teavm.jso.dom.html.HTMLDocument;
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 {