diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index fc378e22..ea4e391d 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 encoding//src/org/nevec/rjm/BigSurd.java=UTF-8 encoding//src/org/nevec/rjm/BigSurdVec.java=UTF-8 -encoding//src/org/warp/engine=UTF-8 -encoding//src/org/warp/engine/Display.java=UTF-8 -encoding//src/org/warp/picalculator/Expression.java=UTF-8 encoding//src/org/warp/picalculator/Main.java=UTF-8 -encoding//src/org/warp/picalculator/MathematicalSymbols.java=UTF-8 -encoding//src/org/warp/picalculator/Root.java=UTF-8 -encoding//src/org/warp/picalculator/RootSquare.java=UTF-8 +encoding//src/org/warp/picalculator/device/graphicengine=UTF-8 +encoding//src/org/warp/picalculator/device/graphicengine/Display.java=UTF-8 +encoding//src/org/warp/picalculator/math/MathematicalSymbols.java=UTF-8 +encoding//src/org/warp/picalculator/math/functions/Expression.java=UTF-8 +encoding//src/org/warp/picalculator/math/functions/Root.java=UTF-8 +encoding//src/org/warp/picalculator/math/functions/RootSquare.java=UTF-8 encoding//src/org/warp/picalculator/screens/EquationScreen.java=UTF-8 encoding/=UTF-8 diff --git a/src/org/nevec/rjm/NumeroAvanzato.java b/src/org/nevec/rjm/NumeroAvanzato.java index 5bd25ae3..8b64a2a2 100644 --- a/src/org/nevec/rjm/NumeroAvanzato.java +++ b/src/org/nevec/rjm/NumeroAvanzato.java @@ -6,7 +6,7 @@ import java.math.MathContext; import java.security.ProviderException; import org.warp.picalculator.Error; -import org.warp.picalculator.Variables; +import org.warp.picalculator.math.Variables; /** * Square roots on the real line. These represent numbers which are a product of diff --git a/src/org/nevec/rjm/NumeroAvanzatoVec.java b/src/org/nevec/rjm/NumeroAvanzatoVec.java index 10d1c203..39a75a89 100644 --- a/src/org/nevec/rjm/NumeroAvanzatoVec.java +++ b/src/org/nevec/rjm/NumeroAvanzatoVec.java @@ -7,8 +7,8 @@ import java.util.Comparator; import java.util.Vector; import org.warp.picalculator.Error; -import org.warp.picalculator.Variables; import org.warp.picalculator.Utils; +import org.warp.picalculator.math.Variables; /** * A NumeroAvanzatoVec represents an algebraic sum or differences of values diff --git a/src/org/warp/picalculator/AnteriorFunctionBase.java b/src/org/warp/picalculator/AnteriorFunctionBase.java deleted file mode 100644 index ad39e6ef..00000000 --- a/src/org/warp/picalculator/AnteriorFunctionBase.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.warp.picalculator; - -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glDrawStringLeft; - -import java.util.List; - -import org.nevec.rjm.NumeroAvanzatoVec; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; - -import com.rits.cloning.Cloner; - -public abstract class AnteriorFunctionBase extends FunctionBase { - public AnteriorFunctionBase(FunctionBase value) { - setVariable(value); - } - - protected FunctionBase variable = new Number(NumeroAvanzatoVec.ZERO); - protected int width; - protected int height; - protected int line; - protected boolean small; - - public FunctionBase getVariable() { - return variable; - } - - public void setVariable(FunctionBase value) { - variable = value; - } - - @Override - public abstract String getSymbol(); - - @Override - public abstract List solveOneStep() throws Error; - - protected int stepsCount = -1; - @Override - public int getStepsCount() { - if (stepsCount == -1) { - stepsCount = variable.getStepsCount()+1; - } - return stepsCount; - } - - @Override - public void generateGraphics() { - variable.setSmall(small); - variable.generateGraphics(); - - width = getStringWidth(getSymbol()) + 1 + getVariable().getWidth(); - height = variable.getHeight(); - line = variable.getLine(); - } - - @Override - public void draw(int x, int y) { - float h1 = getVariable().getHeight(); - int wsegno = getStringWidth(getSymbol()); - float hsegno = Utils.getFontHeight(small); - float maxh = getHeight(); - if (small) { - Display.Render.setFont(PIDisplay.fonts[1]); - } else { - Display.Render.setFont(PIDisplay.fonts[0]); - } - - glDrawStringLeft(x, (int) Math.floor(y + (maxh - hsegno) / 2), getSymbol()); - getVariable().draw(x + wsegno + 1, (int) Math.floor(y + (maxh - h1) / 2)); - } - - @Override - public int getWidth() { - return width; - } - - @Override - public int getHeight() { - return height; - } - - @Override - public int getLine() { - return line; - } - - @Override - public String toString() { -// try { -// return solve().toString(); - return "TODO: fare una nuova alternativa a solve().toString()"; -// } catch (Error e) { -// return e.id.toString(); -// } - } - - @Override - public AnteriorFunctionBase clone() { - Cloner cloner = new Cloner(); - return cloner.deepClone(this); - } - - @Override - public void setSmall(boolean small) { - this.small = small; - } -} diff --git a/src/org/warp/picalculator/FunctionBase.java b/src/org/warp/picalculator/FunctionBase.java deleted file mode 100644 index ba877099..00000000 --- a/src/org/warp/picalculator/FunctionBase.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.warp.picalculator; - -import java.util.List; - -public abstract class FunctionBase implements Function { - - @Override - public abstract String getSymbol(); - - @Override - public abstract int getStepsCount(); - - @Override - public abstract List solveOneStep() throws Error; - - @Override - public abstract void generateGraphics(); - - @Override - public abstract void draw(int x, int y); - - @Override - public abstract int getWidth(); - - @Override - public abstract int getHeight(); - - @Override - public abstract int getLine(); - - @Override - public abstract void setSmall(boolean small); - -} diff --git a/src/org/warp/picalculator/FunctionMultipleValuesBase.java b/src/org/warp/picalculator/FunctionMultipleValuesBase.java deleted file mode 100644 index 5cbd8457..00000000 --- a/src/org/warp/picalculator/FunctionMultipleValuesBase.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.warp.picalculator; - -import java.util.Arrays; -import java.util.List; - -import com.rits.cloning.Cloner; - -public abstract class FunctionMultipleValuesBase extends FunctionBase { - public FunctionMultipleValuesBase() { - setVariables(new FunctionBase[] {}); - } - - public FunctionMultipleValuesBase(FunctionBase[] values) { - setVariables(values); - } - - protected FunctionBase[] variables; - protected int width; - protected int height; - protected int line; - protected boolean small; - - public FunctionBase[] getVariables() { - return variables; - } - - public void setVariables(FunctionBase[] value) { - variables = value; - } - - public void setVariables(final List value) { - int vsize = value.size(); - FunctionBase[] tmp = new FunctionBase[vsize]; - for (int i = 0; i < vsize; i++) { - tmp[i] = value.get(i); - } - variables = tmp; - } - - public FunctionBase getVariable(int index) { - return variables[index]; - } - - public void setVariable(int index, FunctionBase value) { - variables[index] = value; - } - - public void addVariableToEnd(FunctionBase value) { - int index = variables.length; - setVariablesLength(index + 1); - variables[index] = value; - } - - public int getVariablesLength() { - return variables.length; - } - - public void setVariablesLength(int length) { - variables = Arrays.copyOf(variables, length); - } - - protected int stepsCount = -1; - @Override - public int getStepsCount() { - if (stepsCount == -1) { - int max = 0; - int cur = 0; - for (Function f : variables) { - cur = f.getStepsCount(); - if (max < cur) { - max = cur; - } - } - return max+1; - } else { - return stepsCount; - } - } - - @Override - public abstract String getSymbol(); - - @Override - public abstract void generateGraphics(); - - @Override - public String toString() { -// try { -// return solve().toString(); - return "TODO: fare una nuova alternativa a solve().toString()"; -// } catch (Error e) { -// return e.id.toString(); -// } - } - - @Override - public FunctionMultipleValuesBase clone() { - Cloner cloner = new Cloner(); - return cloner.deepClone(this); - } - - @Override - public void setSmall(boolean small) { - this.small = small; - } -} diff --git a/src/org/warp/picalculator/FunctionTwoValuesBase.java b/src/org/warp/picalculator/FunctionTwoValuesBase.java deleted file mode 100644 index 3340db0b..00000000 --- a/src/org/warp/picalculator/FunctionTwoValuesBase.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.warp.picalculator; - -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glDrawStringLeft; - -import java.util.List; - -import org.nevec.rjm.Rational; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; - -import com.rits.cloning.Cloner; - -public abstract class FunctionTwoValuesBase extends FunctionBase { - public FunctionTwoValuesBase(FunctionBase value1, FunctionBase value2) { - setVariable1(value1); - setVariable2(value2); - } - - protected FunctionBase variable1 = new Number(Rational.ZERO); - protected int width; - protected int height; - protected int line; - protected boolean small; - - public FunctionBase getVariable1() { - return variable1; - } - - public void setVariable1(FunctionBase value) { - variable1 = value; - } - - protected FunctionBase variable2 = new Number(Rational.ZERO); - - public FunctionBase getVariable2() { - return variable2; - } - - public void setVariable2(FunctionBase value) { - variable2 = value; - } - - @Override - public abstract String getSymbol(); - - @Override - public abstract List solveOneStep() throws Error; - - @Override - public void generateGraphics() { - variable1.setSmall(small); - variable1.generateGraphics(); - - variable2.setSmall(small); - variable2.generateGraphics(); - - width = calcWidth(); - height = calcHeight(); - line = calcLine(); - } - - @Override - public void draw(int x, int y) { - int ln = getLine(); - int dx = 0; - variable1.draw(dx + x, ln - variable1.getLine() + y); - dx += 1+variable1.getWidth(); - if (drawSignum()) { - if (small) { - Display.Render.setFont(PIDisplay.fonts[1]); - } else { - Display.Render.setFont(PIDisplay.fonts[0]); - } - glDrawStringLeft(dx + x, ln - Utils.getFontHeight(small) / 2 + y, getSymbol()); - dx += getStringWidth(getSymbol()); - } - variable2.draw(dx + x, ln - variable2.getLine() + y); - } - - @Override - public int getWidth() { - return width; - } - - @Override - public int getHeight() { - return height; - } - - @Override - public int getLine() { - return line; - } - - @Override - public String toString() { -// try { -// return solve().toString(); - return "TODO: fare una nuova alternativa a solve().toString()"; -// } catch (Error e) { -// return e.id.toString(); -// } - } - - @Override - public FunctionTwoValuesBase clone() { - Cloner cloner = new Cloner(); - return cloner.deepClone(this); - } - - public boolean drawSignum() { - return true; - } - - @Override - public void setSmall(boolean small) { - this.small = small; - } - - protected int calcWidth() { - return variable1.getWidth() + 1 + (drawSignum() ? getStringWidth(getSymbol()) : 0) + variable2.getWidth(); - } - - protected int calcHeight() { - - FunctionBase tmin = variable1; - FunctionBase tmax = variable1; - if (tmin == null || variable2.getLine() >= tmin.getLine()) { - tmin = variable2; - } - if (tmax == null || variable2.getHeight() - variable2.getLine() >= tmax.getHeight() - tmax.getLine()) { - tmax = variable2; - } - return tmin.getLine() + tmax.getHeight() - tmax.getLine(); - } - - protected int calcLine() { - FunctionBase tl = variable1; - if (tl == null || variable2.getLine() >= tl.getLine()) { - tl = variable2; - } - return tl.getLine(); - } - - protected int stepsCount = -1; - @Override - public int getStepsCount() { - if (stepsCount == -1) { - int val1 = variable1.getStepsCount(); - int val2 = variable2.getStepsCount(); - if (val1 > val2) { - stepsCount = val1+1; - } else { - stepsCount = val2+1; - } - } - return stepsCount; - } -} diff --git a/src/org/warp/picalculator/Main.java b/src/org/warp/picalculator/Main.java index c6026617..45cfc8dc 100644 --- a/src/org/warp/picalculator/Main.java +++ b/src/org/warp/picalculator/Main.java @@ -1,7 +1,7 @@ package org.warp.picalculator; -import org.warp.device.Keyboard; -import org.warp.device.PIDisplay; +import org.warp.picalculator.device.Keyboard; +import org.warp.picalculator.device.PIDisplay; import org.warp.picalculator.screens.EquationScreen; import com.pi4j.wiringpi.Gpio; diff --git a/src/org/warp/picalculator/Utils.java b/src/org/warp/picalculator/Utils.java index a0863654..2868e832 100644 --- a/src/org/warp/picalculator/Utils.java +++ b/src/org/warp/picalculator/Utils.java @@ -1,6 +1,6 @@ package org.warp.picalculator; -import static org.warp.engine.Display.Render.glDrawLine; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawLine; import java.awt.Font; import java.io.ByteArrayOutputStream; @@ -15,6 +15,20 @@ import java.util.List; import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.Rational; +import org.warp.picalculator.math.Variable; +import org.warp.picalculator.math.functions.AnteriorFunction; +import org.warp.picalculator.math.functions.Division; +import org.warp.picalculator.math.functions.Expression; +import org.warp.picalculator.math.functions.Function; +import org.warp.picalculator.math.functions.FunctionTwoValues; +import org.warp.picalculator.math.functions.Multiplication; +import org.warp.picalculator.math.functions.Number; +import org.warp.picalculator.math.functions.PrioritaryMultiplication; +import org.warp.picalculator.math.functions.Subtraction; +import org.warp.picalculator.math.functions.Sum; +import org.warp.picalculator.math.functions.SumSubtraction; +import org.warp.picalculator.math.functions.equations.Equation; +import org.warp.picalculator.math.functions.equations.EquationsSystemPart; public class Utils { @@ -84,12 +98,12 @@ public class Utils { public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { - if (fl.get(i) instanceof AnteriorFunctionBase) { - if (((AnteriorFunctionBase) fl.get(i)).variable == null) { + if (fl.get(i) instanceof AnteriorFunction) { + if (((AnteriorFunction) fl.get(i)).getVariable() == null) { return false; } - } else if (fl.get(i) instanceof FunctionTwoValuesBase) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null || ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + } else if (fl.get(i) instanceof FunctionTwoValues) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null || ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return false; } } else { @@ -103,12 +117,12 @@ public class Utils { public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { - if (fl.get(i) instanceof AnteriorFunctionBase) { - if (((AnteriorFunctionBase) fl.get(i)).variable == null) { + if (fl.get(i) instanceof AnteriorFunction) { + if (((AnteriorFunction) fl.get(i)).getVariable() == null) { return false; } - } else if (fl.get(i) instanceof FunctionTwoValuesBase) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null || ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + } else if (fl.get(i) instanceof FunctionTwoValues) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null || ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return false; } } else { @@ -122,12 +136,12 @@ public class Utils { public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { - if (fl.get(i) instanceof AnteriorFunctionBase) { - if (((AnteriorFunctionBase) fl.get(i)).variable == null) { + if (fl.get(i) instanceof AnteriorFunction) { + if (((AnteriorFunction) fl.get(i)).getVariable() == null) { return false; } - } else if (fl.get(i) instanceof FunctionTwoValuesBase) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null || ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + } else if (fl.get(i) instanceof FunctionTwoValues) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null || ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return false; } } else { @@ -141,12 +155,12 @@ public class Utils { public static boolean areThereOnlySettedUpFunctionsAndSystems(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) { - if (fl.get(i) instanceof AnteriorFunctionBase) { - if (((AnteriorFunctionBase) fl.get(i)).variable == null) { + if (fl.get(i) instanceof AnteriorFunction) { + if (((AnteriorFunction) fl.get(i)).getVariable() == null) { return false; } - } else if (fl.get(i) instanceof FunctionTwoValuesBase) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null || ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + } else if (fl.get(i) instanceof FunctionTwoValues) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null || ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return false; } } else { @@ -157,10 +171,10 @@ public class Utils { return true; } - public static boolean areThereOnlyEmptySNFunctions(ArrayList fl) { + public static boolean areThereOnlyEmptySNFunctions(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { - if (fl.get(i) instanceof AnteriorFunctionBase) { - if (((AnteriorFunctionBase) fl.get(i)).variable == null) { + if (fl.get(i) instanceof AnteriorFunction) { + if (((AnteriorFunction) fl.get(i)).getVariable() == null) { return true; } } @@ -168,10 +182,10 @@ public class Utils { return false; } - public static boolean areThereOnlyEmptyNSNFunctions(ArrayList fl) { + public static boolean areThereOnlyEmptyNSNFunctions(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { - if (fl.get(i) instanceof FunctionTwoValuesBase && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof SumSubtraction) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof PrioritaryMultiplication) && !(fl.get(i) instanceof Division)) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null && ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + if (fl.get(i) instanceof FunctionTwoValues && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof SumSubtraction) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof PrioritaryMultiplication) && !(fl.get(i) instanceof Division)) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null && ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return true; } } @@ -180,10 +194,10 @@ public class Utils { } - public static boolean areThereEmptyPrioritaryMultiplications(ArrayList funzioniOLD) { + public static boolean areThereEmptyPrioritaryMultiplications(ArrayList funzioniOLD) { for (int i = 0; i < funzioniOLD.size(); i++) { if (funzioniOLD.get(i) instanceof PrioritaryMultiplication) { - if (((FunctionTwoValuesBase) funzioniOLD.get(i)).variable1 == null && ((FunctionTwoValuesBase) funzioniOLD.get(i)).variable2 == null) { + if (((FunctionTwoValues) funzioniOLD.get(i)).getVariable1() == null && ((FunctionTwoValues) funzioniOLD.get(i)).getVariable2() == null) { return true; } } @@ -191,10 +205,10 @@ public class Utils { return false; } - public static boolean areThereEmptyMultiplications(ArrayList fl) { + public static boolean areThereEmptyMultiplications(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null && ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null && ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return true; } } @@ -202,10 +216,10 @@ public class Utils { return false; } - public static boolean areThereEmptySums(ArrayList fl) { + public static boolean areThereEmptySums(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null && ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null && ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return true; } } @@ -216,7 +230,7 @@ public class Utils { public static boolean areThereEmptySystems(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { if (fl.get(i) instanceof EquationsSystemPart) { - if (((EquationsSystemPart) fl.get(i)).variable == null) { + if (((EquationsSystemPart) fl.get(i)).getVariable() == null) { return true; } } @@ -226,13 +240,13 @@ public class Utils { public static boolean areThereOtherSettedUpFunctions(ArrayList fl) { for (int i = 0; i < fl.size(); i++) { - if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Expression || fl.get(i) instanceof AnteriorFunctionBase || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Division)) { - if (fl.get(i) instanceof AnteriorFunctionBase) { - if (((AnteriorFunctionBase) fl.get(i)).variable == null) { + if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Expression || fl.get(i) instanceof AnteriorFunction || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Division)) { + if (fl.get(i) instanceof AnteriorFunction) { + if (((AnteriorFunction) fl.get(i)).getVariable() == null) { return true; } - } else if (fl.get(i) instanceof FunctionTwoValuesBase) { - if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null || ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) { + } else if (fl.get(i) instanceof FunctionTwoValues) { + if (((FunctionTwoValues) fl.get(i)).getVariable1() == null || ((FunctionTwoValues) fl.get(i)).getVariable2() == null) { return true; } } else { diff --git a/src/org/warp/device/Keyboard.java b/src/org/warp/picalculator/device/Keyboard.java similarity index 94% rename from src/org/warp/device/Keyboard.java rename to src/org/warp/picalculator/device/Keyboard.java index 042b50a3..f4b8debc 100644 --- a/src/org/warp/device/Keyboard.java +++ b/src/org/warp/picalculator/device/Keyboard.java @@ -1,12 +1,12 @@ -package org.warp.device; +package org.warp.picalculator.device; -import org.warp.engine.Display; -import org.warp.engine.Screen; -import org.warp.picalculator.Calculator; import org.warp.picalculator.Main; import org.warp.picalculator.Utils; import org.warp.picalculator.device.chip.ParallelToSerial; import org.warp.picalculator.device.chip.SerialToParallel; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.device.graphicengine.Screen; +import org.warp.picalculator.math.Calculator; import org.warp.picalculator.screens.MarioScreen; import com.pi4j.wiringpi.Gpio; diff --git a/src/org/warp/device/PIDisplay.java b/src/org/warp/picalculator/device/PIDisplay.java similarity index 93% rename from src/org/warp/device/PIDisplay.java rename to src/org/warp/picalculator/device/PIDisplay.java index 8c19163e..aacd1792 100644 --- a/src/org/warp/device/PIDisplay.java +++ b/src/org/warp/picalculator/device/PIDisplay.java @@ -1,19 +1,19 @@ -package org.warp.device; +package org.warp.picalculator.device; -import static org.warp.engine.Display.Render.*; +import static org.warp.picalculator.device.graphicengine.Display.Render.*; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; -import org.warp.engine.Display; -import org.warp.engine.Display.Startable; -import org.warp.engine.RAWFont; -import org.warp.engine.Screen; -import org.warp.picalculator.Calculator; import org.warp.picalculator.Main; import org.warp.picalculator.Utils; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.device.graphicengine.RAWFont; +import org.warp.picalculator.device.graphicengine.Screen; +import org.warp.picalculator.device.graphicengine.Display.Startable; +import org.warp.picalculator.math.Calculator; import com.pi4j.wiringpi.Gpio; diff --git a/src/org/warp/device/PIFrame.java b/src/org/warp/picalculator/device/PIFrame.java similarity index 95% rename from src/org/warp/device/PIFrame.java rename to src/org/warp/picalculator/device/PIFrame.java index 51dabd67..7a2a07aa 100644 --- a/src/org/warp/device/PIFrame.java +++ b/src/org/warp/picalculator/device/PIFrame.java @@ -1,4 +1,4 @@ -package org.warp.device; +package org.warp.picalculator.device; import java.awt.Cursor; import java.awt.Frame; @@ -14,8 +14,8 @@ import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; -import org.warp.device.Keyboard.Key; -import org.warp.engine.Display; +import org.warp.picalculator.device.Keyboard.Key; +import org.warp.picalculator.device.graphicengine.Display; public class PIFrame extends JFrame { private static final long serialVersionUID = 2945898937634075491L; diff --git a/src/org/warp/engine/Display.java b/src/org/warp/picalculator/device/graphicengine/Display.java similarity index 94% rename from src/org/warp/engine/Display.java rename to src/org/warp/picalculator/device/graphicengine/Display.java index 24f7543d..5105edce 100644 --- a/src/org/warp/engine/Display.java +++ b/src/org/warp/picalculator/device/graphicengine/Display.java @@ -1,13 +1,13 @@ -package org.warp.engine; +package org.warp.picalculator.device.graphicengine; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; -import org.warp.device.PIDisplay; -import org.warp.device.PIFrame; import org.warp.picalculator.Main; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.PIFrame; public class Display { diff --git a/src/org/warp/engine/RAWFont.java b/src/org/warp/picalculator/device/graphicengine/RAWFont.java similarity index 96% rename from src/org/warp/engine/RAWFont.java rename to src/org/warp/picalculator/device/graphicengine/RAWFont.java index de8e2263..0c851218 100644 --- a/src/org/warp/engine/RAWFont.java +++ b/src/org/warp/picalculator/device/graphicengine/RAWFont.java @@ -1,4 +1,4 @@ -package org.warp.engine; +package org.warp.picalculator.device.graphicengine; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; diff --git a/src/org/warp/engine/Screen.java b/src/org/warp/picalculator/device/graphicengine/Screen.java similarity index 79% rename from src/org/warp/engine/Screen.java rename to src/org/warp/picalculator/device/graphicengine/Screen.java index c4c999a3..6e359def 100644 --- a/src/org/warp/engine/Screen.java +++ b/src/org/warp/picalculator/device/graphicengine/Screen.java @@ -1,7 +1,7 @@ -package org.warp.engine; +package org.warp.picalculator.device.graphicengine; -import org.warp.device.Keyboard.Key; -import org.warp.device.PIDisplay; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.Keyboard.Key; public abstract class Screen { public PIDisplay d; diff --git a/src/org/warp/picalculator/Calculator.java b/src/org/warp/picalculator/math/Calculator.java similarity index 69% rename from src/org/warp/picalculator/Calculator.java rename to src/org/warp/picalculator/math/Calculator.java index 48f06332..d1d3dba5 100644 --- a/src/org/warp/picalculator/Calculator.java +++ b/src/org/warp/picalculator/math/Calculator.java @@ -1,12 +1,22 @@ -package org.warp.picalculator; +package org.warp.picalculator.math; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.nevec.rjm.NumeroAvanzato; -import org.warp.device.PIDisplay; -import org.warp.engine.Screen; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Screen; +import org.warp.picalculator.math.functions.Expression; +import org.warp.picalculator.math.functions.Function; +import org.warp.picalculator.math.functions.Number; +import org.warp.picalculator.math.functions.equations.Equation; +import org.warp.picalculator.math.functions.equations.EquationsSystem; import org.warp.picalculator.screens.EquationScreen; import org.warp.picalculator.screens.SolveEquationScreen; @@ -58,8 +68,9 @@ public class Calculator { results.add(es.f); while (Utils.allSolved(results) == false) { for (Function itm : results) { - if (itm.getStepsCount() > 0) { - partialResults.addAll(itm.solveOneStep()); + if (itm.getStepsCount() != 0) { + List dt = itm.solveOneStep(); + partialResults.addAll(dt); } else { partialResults.add(itm); } @@ -71,6 +82,11 @@ public class Calculator { } else { Collections.reverse(results); + // add elements to al, including duplicates + Set hs = new LinkedHashSet<>(); + hs.addAll(results); + results.clear(); + results.addAll(hs); es.f2 = results; for (Function rf : es.f2) { rf.generateGraphics(); @@ -87,6 +103,11 @@ public class Calculator { if (f instanceof Equation) { List results = ((Equation)f).solve(letter); Collections.reverse(results); + // add elements to al, including duplicates + Set hs = new LinkedHashSet<>(); + hs.addAll(results); + results.clear(); + results.addAll(hs); es.f2 = results; for (Function rf : es.f2) { rf.generateGraphics(); diff --git a/src/org/warp/picalculator/MathematicalSymbols.java b/src/org/warp/picalculator/math/MathematicalSymbols.java similarity index 93% rename from src/org/warp/picalculator/MathematicalSymbols.java rename to src/org/warp/picalculator/math/MathematicalSymbols.java index 6f2804f3..dd5e7f30 100644 --- a/src/org/warp/picalculator/MathematicalSymbols.java +++ b/src/org/warp/picalculator/math/MathematicalSymbols.java @@ -1,7 +1,9 @@ -package org.warp.picalculator; +package org.warp.picalculator.math; import static org.warp.picalculator.Utils.concat; +import org.warp.picalculator.Utils; + public class MathematicalSymbols { public static final String SUM = "+"; public static final String SUM_SUBTRACTION = "±"; diff --git a/src/org/warp/picalculator/SolveMethod.java b/src/org/warp/picalculator/math/SolveMethod.java similarity index 63% rename from src/org/warp/picalculator/SolveMethod.java rename to src/org/warp/picalculator/math/SolveMethod.java index 33aa4ff7..a075b139 100644 --- a/src/org/warp/picalculator/SolveMethod.java +++ b/src/org/warp/picalculator/math/SolveMethod.java @@ -1,7 +1,9 @@ -package org.warp.picalculator; +package org.warp.picalculator.math; import java.util.ArrayList; +import org.warp.picalculator.math.functions.equations.Equation; + public interface SolveMethod { public static final SolveMethod[] techniques = new SolveMethod[] {}; diff --git a/src/org/warp/picalculator/Variable.java b/src/org/warp/picalculator/math/Variable.java similarity index 91% rename from src/org/warp/picalculator/Variable.java rename to src/org/warp/picalculator/math/Variable.java index 4ee95512..e27f7c9b 100644 --- a/src/org/warp/picalculator/Variable.java +++ b/src/org/warp/picalculator/math/Variable.java @@ -1,4 +1,4 @@ -package org.warp.picalculator; +package org.warp.picalculator.math; import org.nevec.rjm.Rational; diff --git a/src/org/warp/picalculator/Variables.java b/src/org/warp/picalculator/math/Variables.java similarity index 95% rename from src/org/warp/picalculator/Variables.java rename to src/org/warp/picalculator/math/Variables.java index ae794bcc..26103edb 100644 --- a/src/org/warp/picalculator/Variables.java +++ b/src/org/warp/picalculator/math/Variables.java @@ -1,4 +1,4 @@ -package org.warp.picalculator; +package org.warp.picalculator.math; import java.math.BigInteger; import java.util.Comparator; @@ -6,6 +6,7 @@ import java.util.Vector; import org.nevec.rjm.BigIntegerMath; import org.nevec.rjm.Rational; +import org.warp.picalculator.Error; public class Variables { diff --git a/src/org/warp/picalculator/AnteriorFunction.java b/src/org/warp/picalculator/math/functions/AnteriorFunction.java similarity index 74% rename from src/org/warp/picalculator/AnteriorFunction.java rename to src/org/warp/picalculator/math/functions/AnteriorFunction.java index 94eb93c9..f87c7877 100644 --- a/src/org/warp/picalculator/AnteriorFunction.java +++ b/src/org/warp/picalculator/math/functions/AnteriorFunction.java @@ -1,13 +1,15 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.getStringWidth; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; import java.util.List; import org.nevec.rjm.NumeroAvanzatoVec; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; +import org.warp.picalculator.Error; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Display; import com.rits.cloning.Cloner; @@ -105,5 +107,15 @@ public abstract class AnteriorFunction implements Function { @Override public void setSmall(boolean small) { this.small = small; - } + } + + @Override + public int hashCode() { + return variable.hashCode()+883*getSymbol().hashCode(); + } + + @Override + public boolean equals(Object o) { + return o != null && o.hashCode() == this.hashCode(); + } } diff --git a/src/org/warp/picalculator/Division.java b/src/org/warp/picalculator/math/functions/Division.java similarity index 82% rename from src/org/warp/picalculator/Division.java rename to src/org/warp/picalculator/math/functions/Division.java index 70b6643d..a67c7416 100644 --- a/src/org/warp/picalculator/Division.java +++ b/src/org/warp/picalculator/math/functions/Division.java @@ -1,20 +1,24 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glColor3f; -import static org.warp.engine.Display.Render.glDrawStringLeft; -import static org.warp.engine.Display.Render.glFillRect; +import static org.warp.picalculator.device.graphicengine.Display.Render.getStringWidth; +import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3f; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.glFillRect; import java.util.ArrayList; import java.util.List; import org.nevec.rjm.NumeroAvanzatoVec; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.math.MathematicalSymbols; -public class Division extends FunctionTwoValuesBase { +public class Division extends FunctionTwoValues { - public Division(FunctionBase value1, FunctionBase value2) { + public Division(Function value1, Function value2) { super(value1, value2); } @@ -66,7 +70,7 @@ public class Division extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Division((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Division((Function)f[0], (Function)f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/Expression.java b/src/org/warp/picalculator/math/functions/Expression.java similarity index 86% rename from src/org/warp/picalculator/Expression.java rename to src/org/warp/picalculator/math/functions/Expression.java index 84c9f4cc..314397dd 100644 --- a/src/org/warp/picalculator/Expression.java +++ b/src/org/warp/picalculator/math/functions/Expression.java @@ -1,9 +1,9 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.glColor3f; -import static org.warp.engine.Display.Render.glDrawLine; import static org.warp.picalculator.Utils.ArrayToRegex; import static org.warp.picalculator.Utils.concat; +import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3f; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawLine; import java.math.BigDecimal; import java.math.BigInteger; @@ -13,14 +13,20 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.nevec.rjm.NumeroAvanzato; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.Utils; +import org.warp.picalculator.math.MathematicalSymbols; +import org.warp.picalculator.math.Variable; +import org.warp.picalculator.math.Variables; -public class Expression extends FunctionMultipleValuesBase { +public class Expression extends FunctionMultipleValues { public Expression() { super(); } - public Expression(FunctionBase[] values) { + public Expression(Function[] values) { super(values); } @@ -51,7 +57,7 @@ public class Expression extends FunctionMultipleValuesBase { // If the expression is already a number: // Se l'espressione è già un numero: Number t = new Number(string); - setVariables(new FunctionBase[] { t }); + setVariables(new Function[] { t }); Utils.debug.println(debugSpaces + "•Result:" + t.toString()); } else { // Else prepare the expression: @@ -180,7 +186,7 @@ public class Expression extends FunctionMultipleValuesBase { // Convert the expression to a list of objects Expression imputRawParenthesis = new Expression(); - imputRawParenthesis.setVariables(new FunctionBase[] {}); + imputRawParenthesis.setVariables(new Function[] {}); String tmp = ""; final String[] functions = concat(concat(concat(concat(MathematicalSymbols.functions(), MathematicalSymbols.parentheses()), MathematicalSymbols.signums(true, true)), MathematicalSymbols.variables()), MathematicalSymbols.genericSyntax()); for (int i = 0; i < processExpression.length(); i++) { @@ -190,7 +196,7 @@ public class Expression extends FunctionMultipleValuesBase { // Finds the type of function fron the following list // Cerca il tipo di funzione tra le esistenti - FunctionBase f = null; + Function f = null; switch (charI) { case MathematicalSymbols.SUM: f = new Sum(null, null); @@ -254,7 +260,7 @@ public class Expression extends FunctionMultipleValuesBase { // Fallback NumeroAvanzato na = NumeroAvanzato.ONE; Variables iy = na.getVariableY(); - iy.variables.add(new Variable(charI.charAt(0), 1, 1)); + iy.getVariablesList().add(new Variable(charI.charAt(0), 1, 1)); na = na.setVariableY(iy); f = new Number(na); } else { @@ -333,7 +339,7 @@ public class Expression extends FunctionMultipleValuesBase { if (imputRawParenthesis.variables[i] instanceof Expression) { Expression par = (Expression) imputRawParenthesis.variables[i]; if (par.variables.length == 1) { - FunctionBase subFunz = par.variables[0]; + Function subFunz = par.variables[0]; if (subFunz instanceof Expression || subFunz instanceof Number) { imputRawParenthesis.variables[i] = subFunz; Utils.debug.println(debugSpaces + " •Useless parentheses removed"); @@ -345,10 +351,10 @@ public class Expression extends FunctionMultipleValuesBase { // Inizia l'affinazione dell'espressione Utils.debug.println(debugSpaces + "•Pushing classes..."); - FunctionBase[] oldFunctionsArray = imputRawParenthesis.getVariables(); - ArrayList oldFunctionsList = new ArrayList(); + Function[] oldFunctionsArray = imputRawParenthesis.getVariables(); + ArrayList oldFunctionsList = new ArrayList(); for (int i = 0; i < oldFunctionsArray.length; i++) { - FunctionBase funzione = oldFunctionsArray[i]; + Function funzione = oldFunctionsArray[i]; if (funzione != null) { //Affinazione if (funzione instanceof Root) { @@ -395,20 +401,20 @@ public class Expression extends FunctionMultipleValuesBase { } Utils.debug.println(debugSpaces + " •Phase: "+step); while (i < oldFunctionsList.size() && change == false && oldFunctionsList.size() > 1) { - FunctionBase funzioneTMP = oldFunctionsList.get(i); - if (funzioneTMP instanceof FunctionTwoValuesBase) { + Function funzioneTMP = oldFunctionsList.get(i); + if (funzioneTMP instanceof FunctionTwoValues) { if (step != "SN Functions") { if ( - (step == "sums" && (funzioneTMP instanceof Sum || funzioneTMP instanceof SumSubtraction) == true && ((funzioneTMP instanceof AnteriorFunctionBase && ((AnteriorFunctionBase) funzioneTMP).variable == null) || (funzioneTMP instanceof FunctionTwoValuesBase && ((FunctionTwoValuesBase) funzioneTMP).variable1 == null && ((FunctionTwoValuesBase) funzioneTMP).variable2 == null) || (!(funzioneTMP instanceof AnteriorFunctionBase) && !(funzioneTMP instanceof FunctionTwoValuesBase)))) + (step == "sums" && (funzioneTMP instanceof Sum || funzioneTMP instanceof SumSubtraction) == true && ((funzioneTMP instanceof AnteriorFunction && ((AnteriorFunction) funzioneTMP).variable == null) || (funzioneTMP instanceof FunctionTwoValues && ((FunctionTwoValues) funzioneTMP).variable1 == null && ((FunctionTwoValues) funzioneTMP).variable2 == null) || (!(funzioneTMP instanceof AnteriorFunction) && !(funzioneTMP instanceof FunctionTwoValues)))) || ( step.equals("prioritary multiplications") && (funzioneTMP instanceof PrioritaryMultiplication) && - ((FunctionTwoValuesBase) funzioneTMP).variable1 == null + ((FunctionTwoValues) funzioneTMP).variable1 == null && - ((FunctionTwoValuesBase) funzioneTMP).variable2 == null + ((FunctionTwoValues) funzioneTMP).variable2 == null ) || ( @@ -420,9 +426,9 @@ public class Expression extends FunctionMultipleValuesBase { (funzioneTMP instanceof Division) ) && - ((FunctionTwoValuesBase) funzioneTMP).variable1 == null + ((FunctionTwoValues) funzioneTMP).variable1 == null && - ((FunctionTwoValuesBase) funzioneTMP).variable2 == null + ((FunctionTwoValues) funzioneTMP).variable2 == null ) || ( @@ -440,23 +446,23 @@ public class Expression extends FunctionMultipleValuesBase { && ( ( - funzioneTMP instanceof AnteriorFunctionBase + funzioneTMP instanceof AnteriorFunction && - ((AnteriorFunctionBase) funzioneTMP).variable == null + ((AnteriorFunction) funzioneTMP).variable == null ) || ( - funzioneTMP instanceof FunctionTwoValuesBase + funzioneTMP instanceof FunctionTwoValues && - ((FunctionTwoValuesBase) funzioneTMP).variable1 == null + ((FunctionTwoValues) funzioneTMP).variable1 == null && - ((FunctionTwoValuesBase) funzioneTMP).variable2 == null + ((FunctionTwoValues) funzioneTMP).variable2 == null ) || ( - !(funzioneTMP instanceof AnteriorFunctionBase) + !(funzioneTMP instanceof AnteriorFunction) && - !(funzioneTMP instanceof FunctionTwoValuesBase) + !(funzioneTMP instanceof FunctionTwoValues) ) ) ) @@ -464,8 +470,8 @@ public class Expression extends FunctionMultipleValuesBase { change = true; if (i + 1 < oldFunctionsList.size() && i - 1 >= 0) { - ((FunctionTwoValuesBase) funzioneTMP).setVariable1((FunctionBase) oldFunctionsList.get(i - 1)); - ((FunctionTwoValuesBase) funzioneTMP).setVariable2((FunctionBase) oldFunctionsList.get(i + 1)); + ((FunctionTwoValues) funzioneTMP).setVariable1((Function) oldFunctionsList.get(i - 1)); + ((FunctionTwoValues) funzioneTMP).setVariable2((Function) oldFunctionsList.get(i + 1)); oldFunctionsList.set(i, funzioneTMP); // è importante togliere prima gli elementi @@ -476,13 +482,13 @@ public class Expression extends FunctionMultipleValuesBase { Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol()); try { - Utils.debug.println(debugSpaces + " " + "var1=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable1().toString()); + Utils.debug.println(debugSpaces + " " + "var1=" + ((FunctionTwoValues) funzioneTMP).getVariable1().toString()); } catch (NullPointerException ex2) {} try { - Utils.debug.println(debugSpaces + " " + "var2=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable2().toString()); + Utils.debug.println(debugSpaces + " " + "var2=" + ((FunctionTwoValues) funzioneTMP).getVariable2().toString()); } catch (NullPointerException ex2) {} try { - Utils.debug.println(debugSpaces + " " + "(result)=" + ((FunctionTwoValuesBase) funzioneTMP).toString()); + Utils.debug.println(debugSpaces + " " + "(result)=" + ((FunctionTwoValues) funzioneTMP).toString()); } catch (NullPointerException ex2) {} } else { @@ -490,15 +496,15 @@ public class Expression extends FunctionMultipleValuesBase { } } } - } else if (funzioneTMP instanceof AnteriorFunctionBase) { - if ((step == "SN Functions" && ((AnteriorFunctionBase) funzioneTMP).variable == null)) { + } else if (funzioneTMP instanceof AnteriorFunction) { + if ((step == "SN Functions" && ((AnteriorFunction) funzioneTMP).variable == null)) { if (i + 1 < oldFunctionsList.size()) { - FunctionBase nextFunc = oldFunctionsList.get(i + 1); - if (nextFunc instanceof AnteriorFunctionBase && ((AnteriorFunctionBase)nextFunc).variable == null) { + Function nextFunc = oldFunctionsList.get(i + 1); + if (nextFunc instanceof AnteriorFunction && ((AnteriorFunction)nextFunc).variable == null) { } else { change = true; - ((AnteriorFunctionBase) funzioneTMP).setVariable((FunctionBase) nextFunc); + ((AnteriorFunction) funzioneTMP).setVariable((Function) nextFunc); oldFunctionsList.set(i, funzioneTMP); // è importante togliere prima gli elementi in @@ -507,7 +513,7 @@ public class Expression extends FunctionMultipleValuesBase { oldFunctionsList.remove(i + 1); Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol()); - FunctionBase var = ((AnteriorFunctionBase) funzioneTMP).getVariable(); + Function var = ((AnteriorFunction) funzioneTMP).getVariable(); if (var == null) { Utils.debug.println(debugSpaces + " " + "var=null"); } else { @@ -563,7 +569,7 @@ public class Expression extends FunctionMultipleValuesBase { if (f instanceof Number) { ret.add(f); } else { - ret.add(new Expression(new FunctionBase[]{(FunctionBase) f})); + ret.add(new Expression(new Function[]{(Function) f})); } } stepsCount = -1; @@ -578,7 +584,7 @@ public class Expression extends FunctionMultipleValuesBase { if (f.getStepsCount() >= stepsCount - 1) { List partial = f.solveOneStep(); for (Function fnc : partial) { - ret.add(new Expression(new FunctionBase[]{(FunctionBase) fnc})); + ret.add(new Expression(new Function[]{(Function) fnc})); } } } diff --git a/src/org/warp/picalculator/Function.java b/src/org/warp/picalculator/math/functions/Function.java similarity index 79% rename from src/org/warp/picalculator/Function.java rename to src/org/warp/picalculator/math/functions/Function.java index 8ffa340d..0100bfc3 100644 --- a/src/org/warp/picalculator/Function.java +++ b/src/org/warp/picalculator/math/functions/Function.java @@ -1,7 +1,9 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.util.List; +import org.warp.picalculator.Error; + public interface Function { public String getSymbol(); diff --git a/src/org/warp/picalculator/FunctionMultipleValues.java b/src/org/warp/picalculator/math/functions/FunctionMultipleValues.java similarity index 84% rename from src/org/warp/picalculator/FunctionMultipleValues.java rename to src/org/warp/picalculator/math/functions/FunctionMultipleValues.java index 7500b911..b533ca43 100644 --- a/src/org/warp/picalculator/FunctionMultipleValues.java +++ b/src/org/warp/picalculator/math/functions/FunctionMultipleValues.java @@ -1,4 +1,4 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.util.Arrays; import java.util.List; @@ -103,4 +103,14 @@ public abstract class FunctionMultipleValues implements Function { public void setSmall(boolean small) { this.small = small; } + + @Override + public int hashCode() { + return variables.hashCode()+883*getSymbol().hashCode(); + } + + @Override + public boolean equals(Object o) { + return o != null && o.hashCode() == this.hashCode(); + } } diff --git a/src/org/warp/picalculator/FunctionTwoValues.java b/src/org/warp/picalculator/math/functions/FunctionTwoValues.java similarity index 69% rename from src/org/warp/picalculator/FunctionTwoValues.java rename to src/org/warp/picalculator/math/functions/FunctionTwoValues.java index 47f72c80..13a87d48 100644 --- a/src/org/warp/picalculator/FunctionTwoValues.java +++ b/src/org/warp/picalculator/math/functions/FunctionTwoValues.java @@ -1,13 +1,15 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.getStringWidth; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; import java.util.List; import org.nevec.rjm.Rational; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; +import org.warp.picalculator.Error; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Display; import com.rits.cloning.Cloner; @@ -17,7 +19,7 @@ public abstract class FunctionTwoValues implements Function { setVariable2(value2); } - protected Function variable1 = new Number(Rational.ZERO); + protected Function variable1 = (Function) new Number(Rational.ZERO); protected int width; protected int height; protected int line; @@ -31,7 +33,7 @@ public abstract class FunctionTwoValues implements Function { variable1 = value; } - protected Function variable2 = new Number(Rational.ZERO); + protected Function variable2 = (Function) new Number(Rational.ZERO); public Function getVariable2() { return variable2; @@ -43,10 +45,22 @@ public abstract class FunctionTwoValues implements Function { @Override public abstract String getSymbol(); - + + protected int stepsCount = -1; @Override - public abstract int getStepsCount(); - + public int getStepsCount() { + if (stepsCount == -1) { + int val1 = variable1.getStepsCount(); + int val2 = variable2.getStepsCount(); + if (val1 > val2) { + stepsCount = val1+1; + } else { + stepsCount = val2+1; + } + } + return stepsCount; + } + @Override public abstract List solveOneStep() throws Error; @@ -145,4 +159,14 @@ public abstract class FunctionTwoValues implements Function { } return tl.getLine(); } + + @Override + public int hashCode() { + return variable1.hashCode()+7*variable2.hashCode()+883*getSymbol().hashCode(); + } + + @Override + public boolean equals(Object o) { + return o != null && o.hashCode() == this.hashCode(); + } } diff --git a/src/org/warp/picalculator/Multiplication.java b/src/org/warp/picalculator/math/functions/Multiplication.java similarity index 78% rename from src/org/warp/picalculator/Multiplication.java rename to src/org/warp/picalculator/math/functions/Multiplication.java index 85279685..5501e438 100644 --- a/src/org/warp/picalculator/Multiplication.java +++ b/src/org/warp/picalculator/math/functions/Multiplication.java @@ -1,12 +1,17 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -public class Multiplication extends FunctionTwoValuesBase { +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.math.MathematicalSymbols; +import org.warp.picalculator.math.Variable; - public Multiplication(FunctionBase value1, FunctionBase value2) { +public class Multiplication extends FunctionTwoValues { + + public Multiplication(Function value1, Function value2) { super(value1, value2); } @@ -54,7 +59,7 @@ public class Multiplication extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Multiplication((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Multiplication(f[0], f[1])); } } stepsCount=-1; @@ -103,14 +108,14 @@ public class Multiplication extends FunctionTwoValuesBase { } else if (tmpVar[val] instanceof Expression) { ok[0] = true; ok[1] = true; - } else if (tmpVar[val] instanceof FunctionTwoValuesBase) { + } else if (tmpVar[val] instanceof FunctionTwoValues) { if (val == 0) { - tmpVar[val] = ((FunctionTwoValuesBase) tmpVar[val]).variable2; + tmpVar[val] = ((FunctionTwoValues) tmpVar[val]).variable2; } else { - tmpVar[val] = ((FunctionTwoValuesBase) tmpVar[val]).variable1; + tmpVar[val] = ((FunctionTwoValues) tmpVar[val]).variable1; } - } else if (tmpVar[val] instanceof AnteriorFunctionBase) { - tmpVar[val] = ((AnteriorFunctionBase) tmpVar[val]).variable; + } else if (tmpVar[val] instanceof AnteriorFunction) { + tmpVar[val] = ((AnteriorFunction) tmpVar[val]).variable; } } } diff --git a/src/org/warp/picalculator/Number.java b/src/org/warp/picalculator/math/functions/Number.java similarity index 89% rename from src/org/warp/picalculator/Number.java rename to src/org/warp/picalculator/math/functions/Number.java index 16e64138..ed461442 100644 --- a/src/org/warp/picalculator/Number.java +++ b/src/org/warp/picalculator/math/functions/Number.java @@ -1,9 +1,9 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glColor3f; -import static org.warp.engine.Display.Render.glDrawStringLeft; -import static org.warp.engine.Display.Render.glFillRect; +import static org.warp.picalculator.device.graphicengine.Display.Render.getStringWidth; +import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3f; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.glFillRect; import java.math.BigDecimal; import java.math.BigInteger; @@ -15,12 +15,15 @@ import org.nevec.rjm.BigDecimalMath; import org.nevec.rjm.NumeroAvanzato; import org.nevec.rjm.NumeroAvanzatoVec; import org.nevec.rjm.Rational; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; +import org.warp.picalculator.Error; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.math.Variables; import com.rits.cloning.Cloner; -public class Number extends FunctionBase { +public class Number implements Function { protected NumeroAvanzatoVec term = NumeroAvanzatoVec.ZERO; protected int width; @@ -394,6 +397,16 @@ public class Number extends FunctionBase { result.add(this); return result; } + + @Override + public int hashCode() { + return toString().hashCode(); + } + + @Override + public boolean equals(Object o) { + return o != null && o.hashCode() == this.hashCode(); + } /* * @Override diff --git a/src/org/warp/picalculator/Power.java b/src/org/warp/picalculator/math/functions/Power.java similarity index 81% rename from src/org/warp/picalculator/Power.java rename to src/org/warp/picalculator/math/functions/Power.java index aa6b0747..8c9a1b66 100644 --- a/src/org/warp/picalculator/Power.java +++ b/src/org/warp/picalculator/math/functions/Power.java @@ -1,11 +1,15 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.util.ArrayList; import java.util.List; -public class Power extends FunctionTwoValuesBase { +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.math.MathematicalSymbols; - public Power(FunctionBase value1, FunctionBase value2) { +public class Power extends FunctionTwoValues { + + public Power(Function value1, Function value2) { super(value1, value2); } @@ -34,7 +38,7 @@ public class Power extends FunctionTwoValuesBase { } ArrayList result = new ArrayList<>(); if (stepsCount == 1) { - result.add(((Number)variable1).pow((Number)variable2)); + result.add((Function) ((Number)variable1).pow((Number)variable2)); } else { List l1 = new ArrayList(); List l2 = new ArrayList(); @@ -66,7 +70,7 @@ public class Power extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Power((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Power((Function)f[0], (Function)f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/PrioritaryMultiplication.java b/src/org/warp/picalculator/math/functions/PrioritaryMultiplication.java similarity index 76% rename from src/org/warp/picalculator/PrioritaryMultiplication.java rename to src/org/warp/picalculator/math/functions/PrioritaryMultiplication.java index b81ec006..910c5f14 100644 --- a/src/org/warp/picalculator/PrioritaryMultiplication.java +++ b/src/org/warp/picalculator/math/functions/PrioritaryMultiplication.java @@ -1,11 +1,15 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.util.ArrayList; import java.util.List; -public class PrioritaryMultiplication extends FunctionTwoValuesBase { +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.math.MathematicalSymbols; - public PrioritaryMultiplication(FunctionBase value1, FunctionBase value2) { +public class PrioritaryMultiplication extends FunctionTwoValues { + + public PrioritaryMultiplication(Function value1, Function value2) { super(value1, value2); } @@ -53,7 +57,7 @@ public class PrioritaryMultiplication extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new PrioritaryMultiplication((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new PrioritaryMultiplication((Function)f[0], (Function)f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/Root.java b/src/org/warp/picalculator/math/functions/Root.java similarity index 84% rename from src/org/warp/picalculator/Root.java rename to src/org/warp/picalculator/math/functions/Root.java index 30b27276..d9e06559 100644 --- a/src/org/warp/picalculator/Root.java +++ b/src/org/warp/picalculator/math/functions/Root.java @@ -1,15 +1,18 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.glDrawLine; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawLine; import java.util.ArrayList; import java.util.List; import org.nevec.rjm.NumeroAvanzatoVec; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.math.MathematicalSymbols; -public class Root extends FunctionTwoValuesBase { +public class Root extends FunctionTwoValues { - public Root(FunctionBase value1, FunctionBase value2) { + public Root(Function value1, Function value2) { super(value1, value2); } @@ -72,7 +75,7 @@ public class Root extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Root((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Root((Function)f[0], (Function)f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/RootSquare.java b/src/org/warp/picalculator/math/functions/RootSquare.java similarity index 78% rename from src/org/warp/picalculator/RootSquare.java rename to src/org/warp/picalculator/math/functions/RootSquare.java index 4c009f77..4e22b1c6 100644 --- a/src/org/warp/picalculator/RootSquare.java +++ b/src/org/warp/picalculator/math/functions/RootSquare.java @@ -1,14 +1,17 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.util.ArrayList; import java.util.List; -import org.nevec.rjm.NumeroAvanzatoVec; import org.nevec.rjm.Rational; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.Utils; +import org.warp.picalculator.math.MathematicalSymbols; -public class RootSquare extends AnteriorFunctionBase { +public class RootSquare extends AnteriorFunction { - public RootSquare(FunctionBase value) { + public RootSquare(Function value) { super(value); } @@ -53,7 +56,7 @@ public class RootSquare extends AnteriorFunctionBase { } for (Function f : l1) { - result.add(new RootSquare((FunctionBase)f)); + result.add(new RootSquare((Function)f)); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/Subtraction.java b/src/org/warp/picalculator/math/functions/Subtraction.java similarity index 77% rename from src/org/warp/picalculator/Subtraction.java rename to src/org/warp/picalculator/math/functions/Subtraction.java index ee3d6693..5af84461 100644 --- a/src/org/warp/picalculator/Subtraction.java +++ b/src/org/warp/picalculator/math/functions/Subtraction.java @@ -1,11 +1,15 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; import java.util.ArrayList; import java.util.List; -public class Subtraction extends FunctionTwoValuesBase { +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.math.MathematicalSymbols; - public Subtraction(FunctionBase value1, FunctionBase value2) { +public class Subtraction extends FunctionTwoValues { + + public Subtraction(Function value1, Function value2) { super(value1, value2); } @@ -53,7 +57,7 @@ public class Subtraction extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Subtraction((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Subtraction((Function)f[0], (Function)f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/Sum.java b/src/org/warp/picalculator/math/functions/Sum.java similarity index 76% rename from src/org/warp/picalculator/Sum.java rename to src/org/warp/picalculator/math/functions/Sum.java index 68f1e8ee..e8d48f5f 100644 --- a/src/org/warp/picalculator/Sum.java +++ b/src/org/warp/picalculator/math/functions/Sum.java @@ -1,17 +1,21 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.getStringWidth; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; import java.util.ArrayList; import java.util.List; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.math.MathematicalSymbols; -public class Sum extends FunctionTwoValuesBase { +public class Sum extends FunctionTwoValues { - public Sum(FunctionBase value1, FunctionBase value2) { + public Sum(Function value1, Function value2) { super(value1, value2); } @@ -59,7 +63,7 @@ public class Sum extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Sum((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Sum((Function)f[0], (Function)f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/SumSubtraction.java b/src/org/warp/picalculator/math/functions/SumSubtraction.java similarity index 76% rename from src/org/warp/picalculator/SumSubtraction.java rename to src/org/warp/picalculator/math/functions/SumSubtraction.java index b131ec63..360ef41f 100644 --- a/src/org/warp/picalculator/SumSubtraction.java +++ b/src/org/warp/picalculator/math/functions/SumSubtraction.java @@ -1,17 +1,21 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions; -import static org.warp.engine.Display.Render.getStringWidth; -import static org.warp.engine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.getStringWidth; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; import java.util.ArrayList; import java.util.List; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.math.MathematicalSymbols; -public class SumSubtraction extends FunctionTwoValuesBase { +public class SumSubtraction extends FunctionTwoValues { - public SumSubtraction(FunctionBase value1, FunctionBase value2) { + public SumSubtraction(Function value1, Function value2) { super(value1, value2); } @@ -60,7 +64,7 @@ public class SumSubtraction extends FunctionTwoValuesBase { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new SumSubtraction((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new SumSubtraction(f[0], f[1])); } } stepsCount=-1; diff --git a/src/org/warp/picalculator/Equation.java b/src/org/warp/picalculator/math/functions/equations/Equation.java similarity index 80% rename from src/org/warp/picalculator/Equation.java rename to src/org/warp/picalculator/math/functions/equations/Equation.java index 009d9b35..7a6acbb2 100644 --- a/src/org/warp/picalculator/Equation.java +++ b/src/org/warp/picalculator/math/functions/equations/Equation.java @@ -1,4 +1,4 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions.equations; import java.math.BigInteger; import java.util.ArrayList; @@ -6,7 +6,14 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.nevec.rjm.NumeroAvanzatoVec; +import org.warp.picalculator.Error; +import org.warp.picalculator.Errors; +import org.warp.picalculator.math.MathematicalSymbols; +import org.warp.picalculator.math.SolveMethod; +import org.warp.picalculator.math.functions.Function; +import org.warp.picalculator.math.functions.FunctionTwoValues; +import org.warp.picalculator.math.functions.Number; +import org.warp.picalculator.math.functions.Subtraction; import com.rits.cloning.Cloner; @@ -31,7 +38,7 @@ public class Equation extends FunctionTwoValues { if (((Number)variable2).getTerm().isBigInteger(false) && ((Number)variable2).getTerm().toBigInteger(false).compareTo(new BigInteger("0")) == 0) { result.add(this); } else { - result.add(new Equation(new Subtraction((FunctionBase)variable1, (FunctionBase)variable2), new Number("0"))); + result.add(new Equation(new Subtraction(variable1, variable2), new Number("0"))); } } else { List l1 = new ArrayList(); @@ -64,7 +71,7 @@ public class Equation extends FunctionTwoValues { if (cur2 >= size1) cur2 = 0; } for (Function[] f : results) { - result.add(new Equation((FunctionBase)f[0], (FunctionBase)f[1])); + result.add(new Equation(f[0], f[1])); } stepsCount=-1; } diff --git a/src/org/warp/picalculator/EquationResult.java b/src/org/warp/picalculator/math/functions/equations/EquationResult.java similarity index 68% rename from src/org/warp/picalculator/EquationResult.java rename to src/org/warp/picalculator/math/functions/equations/EquationResult.java index c55f5cfa..bd84a507 100644 --- a/src/org/warp/picalculator/EquationResult.java +++ b/src/org/warp/picalculator/math/functions/equations/EquationResult.java @@ -1,7 +1,9 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions.equations; import java.math.BigInteger; +import org.warp.picalculator.math.functions.Number; + public class EquationResult { public boolean isAnEquation = false; public Number LR = new Number(new BigInteger("0")); diff --git a/src/org/warp/picalculator/EquationsSystem.java b/src/org/warp/picalculator/math/functions/equations/EquationsSystem.java similarity index 83% rename from src/org/warp/picalculator/EquationsSystem.java rename to src/org/warp/picalculator/math/functions/equations/EquationsSystem.java index 3d2519f1..0aab9725 100644 --- a/src/org/warp/picalculator/EquationsSystem.java +++ b/src/org/warp/picalculator/math/functions/equations/EquationsSystem.java @@ -1,10 +1,14 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions.equations; -import static org.warp.engine.Display.Render.glDrawLine; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawLine; import java.util.ArrayList; import java.util.List; +import org.warp.picalculator.Error; +import org.warp.picalculator.math.functions.Function; +import org.warp.picalculator.math.functions.FunctionMultipleValues; + public class EquationsSystem extends FunctionMultipleValues { static final int spacing = 2; diff --git a/src/org/warp/picalculator/EquationsSystemPart.java b/src/org/warp/picalculator/math/functions/equations/EquationsSystemPart.java similarity index 75% rename from src/org/warp/picalculator/EquationsSystemPart.java rename to src/org/warp/picalculator/math/functions/equations/EquationsSystemPart.java index e80cba98..9b7a3c70 100644 --- a/src/org/warp/picalculator/EquationsSystemPart.java +++ b/src/org/warp/picalculator/math/functions/equations/EquationsSystemPart.java @@ -1,10 +1,15 @@ -package org.warp.picalculator; +package org.warp.picalculator.math.functions.equations; -import static org.warp.engine.Display.Render.glColor3f; -import static org.warp.engine.Display.Render.glDrawLine; +import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3f; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawLine; import java.util.List; +import org.warp.picalculator.Error; +import org.warp.picalculator.math.MathematicalSymbols; +import org.warp.picalculator.math.functions.AnteriorFunction; +import org.warp.picalculator.math.functions.Function; + public class EquationsSystemPart extends AnteriorFunction { public EquationsSystemPart(Equation equazione) { diff --git a/src/org/warp/picalculator/screens/EmptyScreen.java b/src/org/warp/picalculator/screens/EmptyScreen.java index fd457931..192e350f 100644 --- a/src/org/warp/picalculator/screens/EmptyScreen.java +++ b/src/org/warp/picalculator/screens/EmptyScreen.java @@ -1,8 +1,8 @@ package org.warp.picalculator.screens; -import org.warp.device.Keyboard.Key; -import org.warp.device.PIDisplay; -import org.warp.engine.Screen; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.Keyboard.Key; +import org.warp.picalculator.device.graphicengine.Screen; public class EmptyScreen extends Screen { diff --git a/src/org/warp/picalculator/screens/EquationScreen.java b/src/org/warp/picalculator/screens/EquationScreen.java index 3cab7f45..5f18f180 100644 --- a/src/org/warp/picalculator/screens/EquationScreen.java +++ b/src/org/warp/picalculator/screens/EquationScreen.java @@ -1,20 +1,20 @@ package org.warp.picalculator.screens; -import static org.warp.engine.Display.Render.*; +import static org.warp.picalculator.device.graphicengine.Display.Render.*; import java.io.PrintWriter; import java.io.StringWriter; import java.util.List; -import org.warp.device.Keyboard.Key; -import org.warp.device.PIDisplay; -import org.warp.engine.Display; -import org.warp.engine.Screen; -import org.warp.picalculator.Calculator; import org.warp.picalculator.Error; import org.warp.picalculator.Errors; -import org.warp.picalculator.Function; import org.warp.picalculator.Utils; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.Keyboard.Key; +import org.warp.picalculator.device.graphicengine.Display; +import org.warp.picalculator.device.graphicengine.Screen; +import org.warp.picalculator.math.Calculator; +import org.warp.picalculator.math.functions.Function; public class EquationScreen extends Screen { diff --git a/src/org/warp/picalculator/screens/MarioScreen.java b/src/org/warp/picalculator/screens/MarioScreen.java index 8a212db7..b8029a5a 100644 --- a/src/org/warp/picalculator/screens/MarioScreen.java +++ b/src/org/warp/picalculator/screens/MarioScreen.java @@ -1,21 +1,21 @@ package org.warp.picalculator.screens; -import static org.warp.engine.Display.Render.getMatrixOfImage; -import static org.warp.engine.Display.Render.glClearColor; -import static org.warp.engine.Display.Render.glDrawSkin; -import static org.warp.engine.Display.Render.glDrawStringLeft; -import static org.warp.engine.Display.Render.setFont; +import static org.warp.picalculator.device.graphicengine.Display.Render.getMatrixOfImage; +import static org.warp.picalculator.device.graphicengine.Display.Render.glClearColor; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawSkin; +import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft; +import static org.warp.picalculator.device.graphicengine.Display.Render.setFont; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; -import org.warp.device.Keyboard; -import org.warp.device.Keyboard.Key; -import org.warp.device.PIDisplay; -import org.warp.engine.Screen; import org.warp.picalculator.Main; +import org.warp.picalculator.device.Keyboard; +import org.warp.picalculator.device.PIDisplay; +import org.warp.picalculator.device.Keyboard.Key; +import org.warp.picalculator.device.graphicengine.Screen; public class MarioScreen extends Screen { diff --git a/src/org/warp/picalculator/screens/SolveEquationScreen.java b/src/org/warp/picalculator/screens/SolveEquationScreen.java index b98cf96e..550d9364 100644 --- a/src/org/warp/picalculator/screens/SolveEquationScreen.java +++ b/src/org/warp/picalculator/screens/SolveEquationScreen.java @@ -1,13 +1,12 @@ package org.warp.picalculator.screens; -import static org.warp.engine.Display.Render.*; +import static org.warp.picalculator.device.graphicengine.Display.Render.*; -import org.warp.device.Keyboard.Key; -import org.warp.engine.Display; -import org.warp.engine.Screen; -import org.warp.picalculator.Calculator; import org.warp.picalculator.Error; import org.warp.picalculator.Main; +import org.warp.picalculator.device.Keyboard.Key; +import org.warp.picalculator.device.graphicengine.Screen; +import org.warp.picalculator.math.Calculator; public class SolveEquationScreen extends Screen {