Source cleanup

This commit is contained in:
Andrea Cavalli 2018-03-26 09:04:09 +02:00
parent 7279a44b0e
commit 4e9f4350f0
40 changed files with 24 additions and 131 deletions

View File

@ -1,10 +1,5 @@
package org.warp.picalculator;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import org.warp.picalculator.MmapByteBuffer;

View File

@ -4,8 +4,6 @@ import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -19,23 +17,18 @@ import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Time;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.nevec.rjm.BigDecimalMath;
@ -58,8 +51,6 @@ import org.warp.picalculator.math.functions.Variable;
import org.warp.picalculator.math.functions.equations.Equation;
import org.warp.picalculator.math.functions.equations.EquationsSystemPart;
import com.jogamp.common.util.IOUtil;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.model.ZipParameters;

View File

@ -3,8 +3,6 @@ package org.warp.picalculator.device;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.HardwareDisplay;
import org.warp.picalculator.gui.screens.Screen;
import com.pi4j.wiringpi.Gpio;
public class PIHardwareDisplay implements HardwareDisplay {

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.gui;
import org.warp.picalculator.gui.screens.Screen;
public abstract class HUD implements GraphicalInterface {
public DisplayManager d;
public boolean created = false;
@ -9,6 +7,7 @@ public abstract class HUD implements GraphicalInterface {
public HUD() {}
@Override
public void initialize() throws InterruptedException {
if (!initialized) {
initialized = true;
@ -16,6 +15,7 @@ public abstract class HUD implements GraphicalInterface {
}
}
@Override
public void create() throws InterruptedException {
if (!created) {
created = true;

View File

@ -4,7 +4,6 @@ import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Renderer;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.parser.features.FeatureChar;
import org.warp.picalculator.math.parser.features.interfaces.Feature;

View File

@ -1,13 +1,5 @@
package org.warp.picalculator.gui.expression.blocks;
import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Renderer;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.parser.features.FeatureChar;
import org.warp.picalculator.math.parser.features.interfaces.Feature;
public class BlockNumericChar extends BlockChar {
public BlockNumericChar(char ch) {

View File

@ -113,6 +113,7 @@ public abstract class BlockParenthesisAbstract extends Block {
return containerNumber.computeCaretMaxBound();
}
@Override
public abstract Feature toFeature(MathContext context) throws Error;
}

View File

@ -1,8 +1,5 @@
package org.warp.picalculator.gui.expression.containers;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.expression.Caret;
import org.warp.picalculator.gui.expression.CaretState;
import org.warp.picalculator.gui.expression.InputContext;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockChar;

View File

@ -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 };
r.canvas2d = new int[ww * wh];
CPURenderer.canvas2d = new int[ww * wh];
g = new BufferedImage(ww, wh, BufferedImage.TYPE_INT_ARGB);
INSTANCE.wasResized = false;
}
@ -63,7 +63,7 @@ public class CPUEngine implements GraphicEngine {
public boolean wasResized() {
if (INSTANCE.wasResized) {
r.size = new int[] { INSTANCE.getWidth(), INSTANCE.getHeight() };
r.canvas2d = new int[r.size[0] * r.size[1]];
CPURenderer.canvas2d = new int[r.size[0] * r.size[1]];
g = new BufferedImage(r.size[0], r.size[1], BufferedImage.TYPE_INT_ARGB);
INSTANCE.wasResized = false;
return true;

View File

@ -18,7 +18,6 @@ import javax.swing.JPanel;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;

View File

@ -1,9 +1,9 @@
package org.warp.picalculator.gui.graphicengine.framebuffer;
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.concurrent.Semaphore;
@ -19,8 +19,6 @@ import org.warp.picalculator.gui.graphicengine.Skin;
import org.warp.picalculator.gui.graphicengine.cpu.CPUFont;
import org.warp.picalculator.gui.graphicengine.cpu.CPUSkin;
import sun.nio.ch.DirectBuffer;
public class FBEngine implements GraphicEngine {
private static final int FB_DISPLAY_WIDTH = 320;
@ -66,7 +64,7 @@ public class FBEngine implements GraphicEngine {
resizedTrigger = true;
realFb = jni.retrieveBuffer();
final long fbLen = realFb.getLength();
fb = (MappedByteBuffer) MappedByteBuffer.allocateDirect((int) fbLen);
fb = (MappedByteBuffer) ByteBuffer.allocateDirect((int) fbLen);
r = new FBRenderer(this, fb);

View File

@ -1,12 +1,9 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Semaphore;

View File

@ -1,15 +1,11 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.LinkedList;
import javax.imageio.ImageIO;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
@ -18,14 +14,10 @@ import org.warp.picalculator.gui.graphicengine.cpu.CPUFont;
import com.jogamp.opengl.GLException;
import com.jogamp.opengl.util.texture.Texture;
import ar.com.hjg.pngj.IImageLine;
import ar.com.hjg.pngj.ImageInfo;
import ar.com.hjg.pngj.ImageLineHelper;
import ar.com.hjg.pngj.ImageLineInt;
import ar.com.hjg.pngj.PngReader;
import ar.com.hjg.pngj.PngWriter;
import ar.com.hjg.pngj.chunks.ChunkCopyBehaviour;
import ar.com.hjg.pngj.chunks.PngChunkTextVar;
public class GPUFont implements BinaryFont {
@ -46,7 +38,7 @@ public class GPUFont implements BinaryFont {
private File tmpFont;
GPUFont(GraphicEngine g, String name) throws IOException {
this((GPUEngine) g, null, name);
this(g, null, name);
}
public GPUFont(GraphicEngine g, String path, String name) throws IOException {

View File

@ -1,17 +1,12 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.imageio.ImageIO;
import org.warp.picalculator.StaticVars;

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

View File

@ -187,8 +187,8 @@ public class Headless256Renderer implements Renderer {
@Override
public void glDrawCharLeft(int x, int y, char ch) {
final int cx = ((int) x) / Headless256Engine.C_MUL_X;
final int cy = ((int) y) / Headless256Engine.C_MUL_Y;
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) {
return;
}
@ -203,8 +203,8 @@ public class Headless256Renderer implements Renderer {
@Override
public void glDrawCharRight(int x, int y, char ch) {
final int cx = ((int) x) / Headless256Engine.C_MUL_X - 1;
final int cy = ((int) y) / Headless256Engine.C_MUL_Y;
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) {
return;
}

View 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);
AffineTransform at = new AffineTransform();
at.scale(1f / ((float) Headless256Engine.C_MUL_X), 1f / ((float) Headless256Engine.C_MUL_Y));
at.scale(1f / (Headless256Engine.C_MUL_X), 1f / (Headless256Engine.C_MUL_Y));
AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
after = scaleOp.filter(bufferedImage, after);

View File

@ -309,8 +309,8 @@ public class Headless8Renderer implements Renderer {
@Override
public void glDrawCharLeft(int x, int y, char ch) {
final int cx = ((int) x) / Headless8Engine.C_MUL_X;
final int cy = ((int) y) / Headless8Engine.C_MUL_Y;
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) {
return;
}
@ -326,8 +326,8 @@ public class Headless8Renderer implements Renderer {
@Override
public void glDrawCharRight(int x, int y, char ch) {
final int cx = ((int) x) / Headless8Engine.C_MUL_X - 1;
final int cy = ((int) y) / Headless8Engine.C_MUL_Y;
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) {
return;
}

View 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);
AffineTransform at = new AffineTransform();
at.scale(1f / ((float) Headless8Engine.C_MUL_X), 1f / ((float) Headless8Engine.C_MUL_Y));
at.scale(1f / (Headless8Engine.C_MUL_X), 1f / (Headless8Engine.C_MUL_Y));
AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
after = scaleOp.filter(bufferedImage, after);

View File

@ -1,6 +1,5 @@
package org.warp.picalculator.gui.graphicengine.nogui;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.util.concurrent.Semaphore;

View File

@ -3,8 +3,6 @@ package org.warp.picalculator.gui.screens;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.StaticVars;

View File

@ -12,6 +12,7 @@ public abstract class Screen implements KeyboardEventListener, GraphicalInterfac
public Screen() {}
@Override
public void initialize() throws InterruptedException {
if (!initialized) {
initialized = true;
@ -19,6 +20,7 @@ public abstract class Screen implements KeyboardEventListener, GraphicalInterfac
}
}
@Override
public void create() throws InterruptedException {
if (!created) {
created = true;
@ -30,13 +32,17 @@ public abstract class Screen implements KeyboardEventListener, GraphicalInterfac
public abstract void initialized() throws InterruptedException;
@Override
public abstract void render();
@Override
public void renderTopmost() {
}
@Override
public abstract void beforeRender(float dt);
@Override
public abstract boolean mustBeRefreshed();
}

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.math;
import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.math.rules.Rule;

View File

@ -1,19 +1,12 @@
package org.warp.picalculator.math.functions;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.LinkedList;
import org.warp.picalculator.Error;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockContainer;
import org.warp.picalculator.gui.expression.blocks.BlockDivision;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.rules.methods.DivisionRule1;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Division extends FunctionOperator {

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.math.functions;
import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockContainer;

View File

@ -8,8 +8,6 @@ import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.rules.methods.MultiplicationMethod1;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Multiplication extends FunctionOperator {

View File

@ -1,7 +1,6 @@
package org.warp.picalculator.math.functions;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockChar;
import org.warp.picalculator.gui.expression.blocks.BlockParenthesis;

View File

@ -3,8 +3,6 @@ package org.warp.picalculator.math.functions;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.LinkedList;
import java.util.List;
import org.nevec.rjm.BigDecimalMath;
import org.warp.picalculator.Error;
import org.warp.picalculator.Utils;

View File

@ -1,8 +1,5 @@
package org.warp.picalculator.math.functions;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.gui.expression.blocks.Block;

View File

@ -1,17 +1,12 @@
package org.warp.picalculator.math.functions;
import java.math.BigDecimal;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockChar;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.rules.methods.SumMethod1;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Sum extends FunctionOperator {

View File

@ -1,7 +1,6 @@
package org.warp.picalculator.math.functions;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockChar;
import org.warp.picalculator.math.Function;

View File

@ -1,15 +1,10 @@
package org.warp.picalculator.math.functions;
import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockChar;
import org.warp.picalculator.gui.expression.blocks.BlockUndefined;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.rules.Rule;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;

View File

@ -1,18 +1,14 @@
package org.warp.picalculator.math.functions.equations;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Number;
import org.warp.picalculator.math.functions.Subtraction;
import org.warp.picalculator.math.solver.SolveMethod;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;

View File

@ -1,15 +1,10 @@
package org.warp.picalculator.math.functions.equations;
import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionDynamic;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Expression;
import org.warp.picalculator.math.functions.Number;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class EquationsSystem extends FunctionDynamic {

View File

@ -2,7 +2,6 @@ package org.warp.picalculator.math.functions.equations;
import org.warp.picalculator.Error;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionSingle;
import org.warp.picalculator.math.MathContext;

View File

@ -1,16 +1,12 @@
package org.warp.picalculator.math.functions.trigonometry;
import org.nevec.rjm.BigDecimalMath;
import org.warp.picalculator.Error;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.blocks.BlockContainer;
import org.warp.picalculator.gui.expression.blocks.BlockSine;
import org.warp.picalculator.math.AngleMode;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionSingle;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Number;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class Sine extends FunctionSingle {

View File

@ -2,7 +2,6 @@ package org.warp.picalculator.math.parser.steps;
import org.warp.picalculator.IntegerObj;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionSingle;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Multiplication;
import org.warp.picalculator.math.parser.MathParserStep;

View File

@ -1,7 +1,5 @@
package org.warp.picalculator.math.rules;
import java.io.Serializable;
import org.warp.picalculator.Error;
import org.warp.picalculator.math.Function;

View File

@ -2,31 +2,18 @@ package org.warp.picalculator.math.rules;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.HashMap;
import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.MathContext;

View File

@ -4,8 +4,6 @@ import org.warp.picalculator.Error;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.functions.Multiplication;
import org.warp.picalculator.math.functions.Number;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
/**