Merged FunctionBase class to Function class.
This commit is contained in:
parent
c81df8bdc0
commit
7aeb5e4749
@ -1,12 +1,12 @@
|
|||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
encoding//src/org/nevec/rjm/BigSurd.java=UTF-8
|
encoding//src/org/nevec/rjm/BigSurd.java=UTF-8
|
||||||
encoding//src/org/nevec/rjm/BigSurdVec.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/Main.java=UTF-8
|
||||||
encoding//src/org/warp/picalculator/MathematicalSymbols.java=UTF-8
|
encoding//src/org/warp/picalculator/device/graphicengine=UTF-8
|
||||||
encoding//src/org/warp/picalculator/Root.java=UTF-8
|
encoding//src/org/warp/picalculator/device/graphicengine/Display.java=UTF-8
|
||||||
encoding//src/org/warp/picalculator/RootSquare.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//src/org/warp/picalculator/screens/EquationScreen.java=UTF-8
|
||||||
encoding/<project>=UTF-8
|
encoding/<project>=UTF-8
|
||||||
|
@ -6,7 +6,7 @@ import java.math.MathContext;
|
|||||||
import java.security.ProviderException;
|
import java.security.ProviderException;
|
||||||
|
|
||||||
import org.warp.picalculator.Error;
|
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
|
* Square roots on the real line. These represent numbers which are a product of
|
||||||
|
@ -7,8 +7,8 @@ import java.util.Comparator;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.warp.picalculator.Error;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.picalculator.Variables;
|
|
||||||
import org.warp.picalculator.Utils;
|
import org.warp.picalculator.Utils;
|
||||||
|
import org.warp.picalculator.math.Variables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A NumeroAvanzatoVec represents an algebraic sum or differences of values
|
* A NumeroAvanzatoVec represents an algebraic sum or differences of values
|
||||||
|
@ -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<Function> 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<Function> 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);
|
|
||||||
|
|
||||||
}
|
|
@ -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<FunctionBase> 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<Function> 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator;
|
||||||
|
|
||||||
import org.warp.device.Keyboard;
|
import org.warp.picalculator.device.Keyboard;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.device.PIDisplay;
|
||||||
import org.warp.picalculator.screens.EquationScreen;
|
import org.warp.picalculator.screens.EquationScreen;
|
||||||
|
|
||||||
import com.pi4j.wiringpi.Gpio;
|
import com.pi4j.wiringpi.Gpio;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package org.warp.picalculator;
|
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.awt.Font;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -15,6 +15,20 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.nevec.rjm.BigDecimalMath;
|
import org.nevec.rjm.BigDecimalMath;
|
||||||
import org.nevec.rjm.Rational;
|
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 {
|
public class Utils {
|
||||||
|
|
||||||
@ -84,12 +98,12 @@ public class Utils {
|
|||||||
public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(ArrayList<Function> fl) {
|
public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
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 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 (fl.get(i) instanceof AnteriorFunction) {
|
||||||
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
|
if (((AnteriorFunction) fl.get(i)).getVariable() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (fl.get(i) instanceof FunctionTwoValuesBase) {
|
} else if (fl.get(i) instanceof FunctionTwoValues) {
|
||||||
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 false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -103,12 +117,12 @@ public class Utils {
|
|||||||
public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems(ArrayList<Function> fl) {
|
public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
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 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 (fl.get(i) instanceof AnteriorFunction) {
|
||||||
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
|
if (((AnteriorFunction) fl.get(i)).getVariable() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (fl.get(i) instanceof FunctionTwoValuesBase) {
|
} else if (fl.get(i) instanceof FunctionTwoValues) {
|
||||||
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 false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -122,12 +136,12 @@ public class Utils {
|
|||||||
public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(ArrayList<Function> fl) {
|
public static boolean areThereOnlySettedUpFunctionsEquationsAndSystems(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
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 Number || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
|
||||||
if (fl.get(i) instanceof AnteriorFunctionBase) {
|
if (fl.get(i) instanceof AnteriorFunction) {
|
||||||
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
|
if (((AnteriorFunction) fl.get(i)).getVariable() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (fl.get(i) instanceof FunctionTwoValuesBase) {
|
} else if (fl.get(i) instanceof FunctionTwoValues) {
|
||||||
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 false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -141,12 +155,12 @@ public class Utils {
|
|||||||
public static boolean areThereOnlySettedUpFunctionsAndSystems(ArrayList<Function> fl) {
|
public static boolean areThereOnlySettedUpFunctionsAndSystems(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
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 Number || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
|
||||||
if (fl.get(i) instanceof AnteriorFunctionBase) {
|
if (fl.get(i) instanceof AnteriorFunction) {
|
||||||
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
|
if (((AnteriorFunction) fl.get(i)).getVariable() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (fl.get(i) instanceof FunctionTwoValuesBase) {
|
} else if (fl.get(i) instanceof FunctionTwoValues) {
|
||||||
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 false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -157,10 +171,10 @@ public class Utils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areThereOnlyEmptySNFunctions(ArrayList<FunctionBase> fl) {
|
public static boolean areThereOnlyEmptySNFunctions(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
for (int i = 0; i < fl.size(); i++) {
|
||||||
if (fl.get(i) instanceof AnteriorFunctionBase) {
|
if (fl.get(i) instanceof AnteriorFunction) {
|
||||||
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
|
if (((AnteriorFunction) fl.get(i)).getVariable() == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,10 +182,10 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areThereOnlyEmptyNSNFunctions(ArrayList<FunctionBase> fl) {
|
public static boolean areThereOnlyEmptyNSNFunctions(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
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 (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 (((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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,10 +194,10 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean areThereEmptyPrioritaryMultiplications(ArrayList<FunctionBase> funzioniOLD) {
|
public static boolean areThereEmptyPrioritaryMultiplications(ArrayList<Function> funzioniOLD) {
|
||||||
for (int i = 0; i < funzioniOLD.size(); i++) {
|
for (int i = 0; i < funzioniOLD.size(); i++) {
|
||||||
if (funzioniOLD.get(i) instanceof PrioritaryMultiplication) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,10 +205,10 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areThereEmptyMultiplications(ArrayList<FunctionBase> fl) {
|
public static boolean areThereEmptyMultiplications(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
for (int i = 0; i < fl.size(); i++) {
|
||||||
if (fl.get(i) instanceof Multiplication || fl.get(i) instanceof Division) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,10 +216,10 @@ public class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean areThereEmptySums(ArrayList<FunctionBase> fl) {
|
public static boolean areThereEmptySums(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
for (int i = 0; i < fl.size(); i++) {
|
||||||
if (fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +230,7 @@ public class Utils {
|
|||||||
public static boolean areThereEmptySystems(ArrayList<Function> fl) {
|
public static boolean areThereEmptySystems(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
for (int i = 0; i < fl.size(); i++) {
|
||||||
if (fl.get(i) instanceof EquationsSystemPart) {
|
if (fl.get(i) instanceof EquationsSystemPart) {
|
||||||
if (((EquationsSystemPart) fl.get(i)).variable == null) {
|
if (((EquationsSystemPart) fl.get(i)).getVariable() == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,13 +240,13 @@ public class Utils {
|
|||||||
|
|
||||||
public static boolean areThereOtherSettedUpFunctions(ArrayList<Function> fl) {
|
public static boolean areThereOtherSettedUpFunctions(ArrayList<Function> fl) {
|
||||||
for (int i = 0; i < fl.size(); i++) {
|
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 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 AnteriorFunctionBase) {
|
if (fl.get(i) instanceof AnteriorFunction) {
|
||||||
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
|
if (((AnteriorFunction) fl.get(i)).getVariable() == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (fl.get(i) instanceof FunctionTwoValuesBase) {
|
} else if (fl.get(i) instanceof FunctionTwoValues) {
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -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.Main;
|
||||||
import org.warp.picalculator.Utils;
|
import org.warp.picalculator.Utils;
|
||||||
import org.warp.picalculator.device.chip.ParallelToSerial;
|
import org.warp.picalculator.device.chip.ParallelToSerial;
|
||||||
import org.warp.picalculator.device.chip.SerialToParallel;
|
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 org.warp.picalculator.screens.MarioScreen;
|
||||||
|
|
||||||
import com.pi4j.wiringpi.Gpio;
|
import com.pi4j.wiringpi.Gpio;
|
@ -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.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
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.Main;
|
||||||
import org.warp.picalculator.Utils;
|
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;
|
import com.pi4j.wiringpi.Gpio;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.warp.device;
|
package org.warp.picalculator.device;
|
||||||
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
@ -14,8 +14,8 @@ import java.awt.image.BufferedImage;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import org.warp.device.Keyboard.Key;
|
import org.warp.picalculator.device.Keyboard.Key;
|
||||||
import org.warp.engine.Display;
|
import org.warp.picalculator.device.graphicengine.Display;
|
||||||
|
|
||||||
public class PIFrame extends JFrame {
|
public class PIFrame extends JFrame {
|
||||||
private static final long serialVersionUID = 2945898937634075491L;
|
private static final long serialVersionUID = 2945898937634075491L;
|
@ -1,13 +1,13 @@
|
|||||||
package org.warp.engine;
|
package org.warp.picalculator.device.graphicengine;
|
||||||
|
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferInt;
|
import java.awt.image.DataBufferInt;
|
||||||
|
|
||||||
import org.warp.device.PIDisplay;
|
|
||||||
import org.warp.device.PIFrame;
|
|
||||||
import org.warp.picalculator.Main;
|
import org.warp.picalculator.Main;
|
||||||
|
import org.warp.picalculator.device.PIDisplay;
|
||||||
|
import org.warp.picalculator.device.PIFrame;
|
||||||
|
|
||||||
public class Display {
|
public class Display {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.warp.engine;
|
package org.warp.picalculator.device.graphicengine;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferInt;
|
import java.awt.image.DataBufferInt;
|
@ -1,7 +1,7 @@
|
|||||||
package org.warp.engine;
|
package org.warp.picalculator.device.graphicengine;
|
||||||
|
|
||||||
import org.warp.device.Keyboard.Key;
|
import org.warp.picalculator.device.PIDisplay;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.device.Keyboard.Key;
|
||||||
|
|
||||||
public abstract class Screen {
|
public abstract class Screen {
|
||||||
public PIDisplay d;
|
public PIDisplay d;
|
@ -1,12 +1,22 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.nevec.rjm.NumeroAvanzato;
|
import org.nevec.rjm.NumeroAvanzato;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Screen;
|
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.EquationScreen;
|
||||||
import org.warp.picalculator.screens.SolveEquationScreen;
|
import org.warp.picalculator.screens.SolveEquationScreen;
|
||||||
|
|
||||||
@ -58,8 +68,9 @@ public class Calculator {
|
|||||||
results.add(es.f);
|
results.add(es.f);
|
||||||
while (Utils.allSolved(results) == false) {
|
while (Utils.allSolved(results) == false) {
|
||||||
for (Function itm : results) {
|
for (Function itm : results) {
|
||||||
if (itm.getStepsCount() > 0) {
|
if (itm.getStepsCount() != 0) {
|
||||||
partialResults.addAll(itm.solveOneStep());
|
List<Function> dt = itm.solveOneStep();
|
||||||
|
partialResults.addAll(dt);
|
||||||
} else {
|
} else {
|
||||||
partialResults.add(itm);
|
partialResults.add(itm);
|
||||||
}
|
}
|
||||||
@ -71,6 +82,11 @@ public class Calculator {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
Collections.reverse(results);
|
Collections.reverse(results);
|
||||||
|
// add elements to al, including duplicates
|
||||||
|
Set<Function> hs = new LinkedHashSet<>();
|
||||||
|
hs.addAll(results);
|
||||||
|
results.clear();
|
||||||
|
results.addAll(hs);
|
||||||
es.f2 = results;
|
es.f2 = results;
|
||||||
for (Function rf : es.f2) {
|
for (Function rf : es.f2) {
|
||||||
rf.generateGraphics();
|
rf.generateGraphics();
|
||||||
@ -87,6 +103,11 @@ public class Calculator {
|
|||||||
if (f instanceof Equation) {
|
if (f instanceof Equation) {
|
||||||
List<Function> results = ((Equation)f).solve(letter);
|
List<Function> results = ((Equation)f).solve(letter);
|
||||||
Collections.reverse(results);
|
Collections.reverse(results);
|
||||||
|
// add elements to al, including duplicates
|
||||||
|
Set<Function> hs = new LinkedHashSet<>();
|
||||||
|
hs.addAll(results);
|
||||||
|
results.clear();
|
||||||
|
results.addAll(hs);
|
||||||
es.f2 = results;
|
es.f2 = results;
|
||||||
for (Function rf : es.f2) {
|
for (Function rf : es.f2) {
|
||||||
rf.generateGraphics();
|
rf.generateGraphics();
|
@ -1,7 +1,9 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math;
|
||||||
|
|
||||||
import static org.warp.picalculator.Utils.concat;
|
import static org.warp.picalculator.Utils.concat;
|
||||||
|
|
||||||
|
import org.warp.picalculator.Utils;
|
||||||
|
|
||||||
public class MathematicalSymbols {
|
public class MathematicalSymbols {
|
||||||
public static final String SUM = "+";
|
public static final String SUM = "+";
|
||||||
public static final String SUM_SUBTRACTION = "±";
|
public static final String SUM_SUBTRACTION = "±";
|
@ -1,7 +1,9 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.warp.picalculator.math.functions.equations.Equation;
|
||||||
|
|
||||||
public interface SolveMethod {
|
public interface SolveMethod {
|
||||||
public static final SolveMethod[] techniques = new SolveMethod[] {};
|
public static final SolveMethod[] techniques = new SolveMethod[] {};
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math;
|
||||||
|
|
||||||
import org.nevec.rjm.Rational;
|
import org.nevec.rjm.Rational;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -6,6 +6,7 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import org.nevec.rjm.BigIntegerMath;
|
import org.nevec.rjm.BigIntegerMath;
|
||||||
import org.nevec.rjm.Rational;
|
import org.nevec.rjm.Rational;
|
||||||
|
import org.warp.picalculator.Error;
|
||||||
|
|
||||||
public class Variables {
|
public class Variables {
|
||||||
|
|
@ -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.picalculator.device.graphicengine.Display.Render.getStringWidth;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.nevec.rjm.NumeroAvanzatoVec;
|
import org.nevec.rjm.NumeroAvanzatoVec;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Display;
|
import org.warp.picalculator.Utils;
|
||||||
|
import org.warp.picalculator.device.PIDisplay;
|
||||||
|
import org.warp.picalculator.device.graphicengine.Display;
|
||||||
|
|
||||||
import com.rits.cloning.Cloner;
|
import com.rits.cloning.Cloner;
|
||||||
|
|
||||||
@ -106,4 +108,14 @@ public abstract class AnteriorFunction implements Function {
|
|||||||
public void setSmall(boolean small) {
|
public void setSmall(boolean small) {
|
||||||
this.small = 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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -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.picalculator.device.graphicengine.Display.Render.getStringWidth;
|
||||||
import static org.warp.engine.Display.Render.glColor3f;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3f;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
import static org.warp.engine.Display.Render.glFillRect;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glFillRect;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.nevec.rjm.NumeroAvanzatoVec;
|
import org.nevec.rjm.NumeroAvanzatoVec;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Display;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +70,7 @@ public class Division extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
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;
|
stepsCount=-1;
|
@ -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.ArrayToRegex;
|
||||||
import static org.warp.picalculator.Utils.concat;
|
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.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -13,14 +13,20 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.nevec.rjm.NumeroAvanzato;
|
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() {
|
public Expression() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Expression(FunctionBase[] values) {
|
public Expression(Function[] values) {
|
||||||
super(values);
|
super(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +57,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
// If the expression is already a number:
|
// If the expression is already a number:
|
||||||
// Se l'espressione è già un numero:
|
// Se l'espressione è già un numero:
|
||||||
Number t = new Number(string);
|
Number t = new Number(string);
|
||||||
setVariables(new FunctionBase[] { t });
|
setVariables(new Function[] { t });
|
||||||
Utils.debug.println(debugSpaces + "•Result:" + t.toString());
|
Utils.debug.println(debugSpaces + "•Result:" + t.toString());
|
||||||
} else {
|
} else {
|
||||||
// Else prepare the expression:
|
// Else prepare the expression:
|
||||||
@ -180,7 +186,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
|
|
||||||
// Convert the expression to a list of objects
|
// Convert the expression to a list of objects
|
||||||
Expression imputRawParenthesis = new Expression();
|
Expression imputRawParenthesis = new Expression();
|
||||||
imputRawParenthesis.setVariables(new FunctionBase[] {});
|
imputRawParenthesis.setVariables(new Function[] {});
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
final String[] functions = concat(concat(concat(concat(MathematicalSymbols.functions(), MathematicalSymbols.parentheses()), MathematicalSymbols.signums(true, true)), MathematicalSymbols.variables()), MathematicalSymbols.genericSyntax());
|
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++) {
|
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
|
// Finds the type of function fron the following list
|
||||||
// Cerca il tipo di funzione tra le esistenti
|
// Cerca il tipo di funzione tra le esistenti
|
||||||
FunctionBase f = null;
|
Function f = null;
|
||||||
switch (charI) {
|
switch (charI) {
|
||||||
case MathematicalSymbols.SUM:
|
case MathematicalSymbols.SUM:
|
||||||
f = new Sum(null, null);
|
f = new Sum(null, null);
|
||||||
@ -254,7 +260,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
// Fallback
|
// Fallback
|
||||||
NumeroAvanzato na = NumeroAvanzato.ONE;
|
NumeroAvanzato na = NumeroAvanzato.ONE;
|
||||||
Variables iy = na.getVariableY();
|
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);
|
na = na.setVariableY(iy);
|
||||||
f = new Number(na);
|
f = new Number(na);
|
||||||
} else {
|
} else {
|
||||||
@ -333,7 +339,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
if (imputRawParenthesis.variables[i] instanceof Expression) {
|
if (imputRawParenthesis.variables[i] instanceof Expression) {
|
||||||
Expression par = (Expression) imputRawParenthesis.variables[i];
|
Expression par = (Expression) imputRawParenthesis.variables[i];
|
||||||
if (par.variables.length == 1) {
|
if (par.variables.length == 1) {
|
||||||
FunctionBase subFunz = par.variables[0];
|
Function subFunz = par.variables[0];
|
||||||
if (subFunz instanceof Expression || subFunz instanceof Number) {
|
if (subFunz instanceof Expression || subFunz instanceof Number) {
|
||||||
imputRawParenthesis.variables[i] = subFunz;
|
imputRawParenthesis.variables[i] = subFunz;
|
||||||
Utils.debug.println(debugSpaces + " •Useless parentheses removed");
|
Utils.debug.println(debugSpaces + " •Useless parentheses removed");
|
||||||
@ -345,10 +351,10 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
// Inizia l'affinazione dell'espressione
|
// Inizia l'affinazione dell'espressione
|
||||||
Utils.debug.println(debugSpaces + "•Pushing classes...");
|
Utils.debug.println(debugSpaces + "•Pushing classes...");
|
||||||
|
|
||||||
FunctionBase[] oldFunctionsArray = imputRawParenthesis.getVariables();
|
Function[] oldFunctionsArray = imputRawParenthesis.getVariables();
|
||||||
ArrayList<FunctionBase> oldFunctionsList = new ArrayList<FunctionBase>();
|
ArrayList<Function> oldFunctionsList = new ArrayList<Function>();
|
||||||
for (int i = 0; i < oldFunctionsArray.length; i++) {
|
for (int i = 0; i < oldFunctionsArray.length; i++) {
|
||||||
FunctionBase funzione = oldFunctionsArray[i];
|
Function funzione = oldFunctionsArray[i];
|
||||||
if (funzione != null) {
|
if (funzione != null) {
|
||||||
//Affinazione
|
//Affinazione
|
||||||
if (funzione instanceof Root) {
|
if (funzione instanceof Root) {
|
||||||
@ -395,20 +401,20 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
}
|
}
|
||||||
Utils.debug.println(debugSpaces + " •Phase: "+step);
|
Utils.debug.println(debugSpaces + " •Phase: "+step);
|
||||||
while (i < oldFunctionsList.size() && change == false && oldFunctionsList.size() > 1) {
|
while (i < oldFunctionsList.size() && change == false && oldFunctionsList.size() > 1) {
|
||||||
FunctionBase funzioneTMP = oldFunctionsList.get(i);
|
Function funzioneTMP = oldFunctionsList.get(i);
|
||||||
if (funzioneTMP instanceof FunctionTwoValuesBase) {
|
if (funzioneTMP instanceof FunctionTwoValues) {
|
||||||
if (step != "SN Functions") {
|
if (step != "SN Functions") {
|
||||||
if (
|
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")
|
step.equals("prioritary multiplications")
|
||||||
&&
|
&&
|
||||||
(funzioneTMP instanceof PrioritaryMultiplication)
|
(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)
|
(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;
|
change = true;
|
||||||
|
|
||||||
if (i + 1 < oldFunctionsList.size() && i - 1 >= 0) {
|
if (i + 1 < oldFunctionsList.size() && i - 1 >= 0) {
|
||||||
((FunctionTwoValuesBase) funzioneTMP).setVariable1((FunctionBase) oldFunctionsList.get(i - 1));
|
((FunctionTwoValues) funzioneTMP).setVariable1((Function) oldFunctionsList.get(i - 1));
|
||||||
((FunctionTwoValuesBase) funzioneTMP).setVariable2((FunctionBase) oldFunctionsList.get(i + 1));
|
((FunctionTwoValues) funzioneTMP).setVariable2((Function) oldFunctionsList.get(i + 1));
|
||||||
oldFunctionsList.set(i, funzioneTMP);
|
oldFunctionsList.set(i, funzioneTMP);
|
||||||
|
|
||||||
// è importante togliere prima gli elementi
|
// è importante togliere prima gli elementi
|
||||||
@ -476,13 +482,13 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
|
|
||||||
Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol());
|
Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol());
|
||||||
try {
|
try {
|
||||||
Utils.debug.println(debugSpaces + " " + "var1=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable1().toString());
|
Utils.debug.println(debugSpaces + " " + "var1=" + ((FunctionTwoValues) funzioneTMP).getVariable1().toString());
|
||||||
} catch (NullPointerException ex2) {}
|
} catch (NullPointerException ex2) {}
|
||||||
try {
|
try {
|
||||||
Utils.debug.println(debugSpaces + " " + "var2=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable2().toString());
|
Utils.debug.println(debugSpaces + " " + "var2=" + ((FunctionTwoValues) funzioneTMP).getVariable2().toString());
|
||||||
} catch (NullPointerException ex2) {}
|
} catch (NullPointerException ex2) {}
|
||||||
try {
|
try {
|
||||||
Utils.debug.println(debugSpaces + " " + "(result)=" + ((FunctionTwoValuesBase) funzioneTMP).toString());
|
Utils.debug.println(debugSpaces + " " + "(result)=" + ((FunctionTwoValues) funzioneTMP).toString());
|
||||||
} catch (NullPointerException ex2) {}
|
} catch (NullPointerException ex2) {}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -490,15 +496,15 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (funzioneTMP instanceof AnteriorFunctionBase) {
|
} else if (funzioneTMP instanceof AnteriorFunction) {
|
||||||
if ((step == "SN Functions" && ((AnteriorFunctionBase) funzioneTMP).variable == null)) {
|
if ((step == "SN Functions" && ((AnteriorFunction) funzioneTMP).variable == null)) {
|
||||||
if (i + 1 < oldFunctionsList.size()) {
|
if (i + 1 < oldFunctionsList.size()) {
|
||||||
FunctionBase nextFunc = oldFunctionsList.get(i + 1);
|
Function nextFunc = oldFunctionsList.get(i + 1);
|
||||||
if (nextFunc instanceof AnteriorFunctionBase && ((AnteriorFunctionBase)nextFunc).variable == null) {
|
if (nextFunc instanceof AnteriorFunction && ((AnteriorFunction)nextFunc).variable == null) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
change = true;
|
change = true;
|
||||||
((AnteriorFunctionBase) funzioneTMP).setVariable((FunctionBase) nextFunc);
|
((AnteriorFunction) funzioneTMP).setVariable((Function) nextFunc);
|
||||||
oldFunctionsList.set(i, funzioneTMP);
|
oldFunctionsList.set(i, funzioneTMP);
|
||||||
|
|
||||||
// è importante togliere prima gli elementi in
|
// è importante togliere prima gli elementi in
|
||||||
@ -507,7 +513,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
oldFunctionsList.remove(i + 1);
|
oldFunctionsList.remove(i + 1);
|
||||||
|
|
||||||
Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol());
|
Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol());
|
||||||
FunctionBase var = ((AnteriorFunctionBase) funzioneTMP).getVariable();
|
Function var = ((AnteriorFunction) funzioneTMP).getVariable();
|
||||||
if (var == null) {
|
if (var == null) {
|
||||||
Utils.debug.println(debugSpaces + " " + "var=null");
|
Utils.debug.println(debugSpaces + " " + "var=null");
|
||||||
} else {
|
} else {
|
||||||
@ -563,7 +569,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
if (f instanceof Number) {
|
if (f instanceof Number) {
|
||||||
ret.add(f);
|
ret.add(f);
|
||||||
} else {
|
} else {
|
||||||
ret.add(new Expression(new FunctionBase[]{(FunctionBase) f}));
|
ret.add(new Expression(new Function[]{(Function) f}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stepsCount = -1;
|
stepsCount = -1;
|
||||||
@ -578,7 +584,7 @@ public class Expression extends FunctionMultipleValuesBase {
|
|||||||
if (f.getStepsCount() >= stepsCount - 1) {
|
if (f.getStepsCount() >= stepsCount - 1) {
|
||||||
List<Function> partial = f.solveOneStep();
|
List<Function> partial = f.solveOneStep();
|
||||||
for (Function fnc : partial) {
|
for (Function fnc : partial) {
|
||||||
ret.add(new Expression(new FunctionBase[]{(FunctionBase) fnc}));
|
ret.add(new Expression(new Function[]{(Function) fnc}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.warp.picalculator.Error;
|
||||||
|
|
||||||
public interface Function {
|
public interface Function {
|
||||||
public String getSymbol();
|
public String getSymbol();
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -103,4 +103,14 @@ public abstract class FunctionMultipleValues implements Function {
|
|||||||
public void setSmall(boolean small) {
|
public void setSmall(boolean small) {
|
||||||
this.small = 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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -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.picalculator.device.graphicengine.Display.Render.getStringWidth;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.nevec.rjm.Rational;
|
import org.nevec.rjm.Rational;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Display;
|
import org.warp.picalculator.Utils;
|
||||||
|
import org.warp.picalculator.device.PIDisplay;
|
||||||
|
import org.warp.picalculator.device.graphicengine.Display;
|
||||||
|
|
||||||
import com.rits.cloning.Cloner;
|
import com.rits.cloning.Cloner;
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ public abstract class FunctionTwoValues implements Function {
|
|||||||
setVariable2(value2);
|
setVariable2(value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Function variable1 = new Number(Rational.ZERO);
|
protected Function variable1 = (Function) new Number(Rational.ZERO);
|
||||||
protected int width;
|
protected int width;
|
||||||
protected int height;
|
protected int height;
|
||||||
protected int line;
|
protected int line;
|
||||||
@ -31,7 +33,7 @@ public abstract class FunctionTwoValues implements Function {
|
|||||||
variable1 = value;
|
variable1 = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Function variable2 = new Number(Rational.ZERO);
|
protected Function variable2 = (Function) new Number(Rational.ZERO);
|
||||||
|
|
||||||
public Function getVariable2() {
|
public Function getVariable2() {
|
||||||
return variable2;
|
return variable2;
|
||||||
@ -44,8 +46,20 @@ public abstract class FunctionTwoValues implements Function {
|
|||||||
@Override
|
@Override
|
||||||
public abstract String getSymbol();
|
public abstract String getSymbol();
|
||||||
|
|
||||||
|
protected int stepsCount = -1;
|
||||||
@Override
|
@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
|
@Override
|
||||||
public abstract List<Function> solveOneStep() throws Error;
|
public abstract List<Function> solveOneStep() throws Error;
|
||||||
@ -145,4 +159,14 @@ public abstract class FunctionTwoValues implements Function {
|
|||||||
}
|
}
|
||||||
return tl.getLine();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,12 +1,17 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +59,7 @@ public class Multiplication extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
for (Function[] f : results) {
|
||||||
result.add(new Multiplication((FunctionBase)f[0], (FunctionBase)f[1]));
|
result.add(new Multiplication(f[0], f[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stepsCount=-1;
|
stepsCount=-1;
|
||||||
@ -103,14 +108,14 @@ public class Multiplication extends FunctionTwoValuesBase {
|
|||||||
} else if (tmpVar[val] instanceof Expression) {
|
} else if (tmpVar[val] instanceof Expression) {
|
||||||
ok[0] = true;
|
ok[0] = true;
|
||||||
ok[1] = true;
|
ok[1] = true;
|
||||||
} else if (tmpVar[val] instanceof FunctionTwoValuesBase) {
|
} else if (tmpVar[val] instanceof FunctionTwoValues) {
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
tmpVar[val] = ((FunctionTwoValuesBase) tmpVar[val]).variable2;
|
tmpVar[val] = ((FunctionTwoValues) tmpVar[val]).variable2;
|
||||||
} else {
|
} else {
|
||||||
tmpVar[val] = ((FunctionTwoValuesBase) tmpVar[val]).variable1;
|
tmpVar[val] = ((FunctionTwoValues) tmpVar[val]).variable1;
|
||||||
}
|
}
|
||||||
} else if (tmpVar[val] instanceof AnteriorFunctionBase) {
|
} else if (tmpVar[val] instanceof AnteriorFunction) {
|
||||||
tmpVar[val] = ((AnteriorFunctionBase) tmpVar[val]).variable;
|
tmpVar[val] = ((AnteriorFunction) tmpVar[val]).variable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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.picalculator.device.graphicengine.Display.Render.getStringWidth;
|
||||||
import static org.warp.engine.Display.Render.glColor3f;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glColor3f;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
import static org.warp.engine.Display.Render.glFillRect;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glFillRect;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@ -15,12 +15,15 @@ import org.nevec.rjm.BigDecimalMath;
|
|||||||
import org.nevec.rjm.NumeroAvanzato;
|
import org.nevec.rjm.NumeroAvanzato;
|
||||||
import org.nevec.rjm.NumeroAvanzatoVec;
|
import org.nevec.rjm.NumeroAvanzatoVec;
|
||||||
import org.nevec.rjm.Rational;
|
import org.nevec.rjm.Rational;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Display;
|
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;
|
import com.rits.cloning.Cloner;
|
||||||
|
|
||||||
public class Number extends FunctionBase {
|
public class Number implements Function {
|
||||||
|
|
||||||
protected NumeroAvanzatoVec term = NumeroAvanzatoVec.ZERO;
|
protected NumeroAvanzatoVec term = NumeroAvanzatoVec.ZERO;
|
||||||
protected int width;
|
protected int width;
|
||||||
@ -395,6 +398,16 @@ public class Number extends FunctionBase {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return toString().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o != null && o.hashCode() == this.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Override
|
* @Override
|
||||||
* public void draw(int x, int y, Graphics g) {
|
* public void draw(int x, int y, Graphics g) {
|
@ -1,11 +1,15 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +38,7 @@ public class Power extends FunctionTwoValuesBase {
|
|||||||
}
|
}
|
||||||
ArrayList<Function> result = new ArrayList<>();
|
ArrayList<Function> result = new ArrayList<>();
|
||||||
if (stepsCount == 1) {
|
if (stepsCount == 1) {
|
||||||
result.add(((Number)variable1).pow((Number)variable2));
|
result.add((Function) ((Number)variable1).pow((Number)variable2));
|
||||||
} else {
|
} else {
|
||||||
List<Function> l1 = new ArrayList<Function>();
|
List<Function> l1 = new ArrayList<Function>();
|
||||||
List<Function> l2 = new ArrayList<Function>();
|
List<Function> l2 = new ArrayList<Function>();
|
||||||
@ -66,7 +70,7 @@ public class Power extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
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;
|
stepsCount=-1;
|
@ -1,11 +1,15 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +57,7 @@ public class PrioritaryMultiplication extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
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;
|
stepsCount=-1;
|
@ -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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.nevec.rjm.NumeroAvanzatoVec;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +75,7 @@ public class Root extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
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;
|
stepsCount=-1;
|
@ -1,14 +1,17 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.nevec.rjm.NumeroAvanzatoVec;
|
|
||||||
import org.nevec.rjm.Rational;
|
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);
|
super(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ public class RootSquare extends AnteriorFunctionBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Function f : l1) {
|
for (Function f : l1) {
|
||||||
result.add(new RootSquare((FunctionBase)f));
|
result.add(new RootSquare((Function)f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stepsCount=-1;
|
stepsCount=-1;
|
@ -1,11 +1,15 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +57,7 @@ public class Subtraction extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
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;
|
stepsCount=-1;
|
@ -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.picalculator.device.graphicengine.Display.Render.getStringWidth;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Display;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +63,7 @@ public class Sum extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
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;
|
stepsCount=-1;
|
@ -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.picalculator.device.graphicengine.Display.Render.getStringWidth;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.Error;
|
||||||
import org.warp.engine.Display;
|
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);
|
super(value1, value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +64,7 @@ public class SumSubtraction extends FunctionTwoValuesBase {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
for (Function[] f : results) {
|
||||||
result.add(new SumSubtraction((FunctionBase)f[0], (FunctionBase)f[1]));
|
result.add(new SumSubtraction(f[0], f[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stepsCount=-1;
|
stepsCount=-1;
|
@ -1,4 +1,4 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions.equations;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -6,7 +6,14 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
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;
|
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) {
|
if (((Number)variable2).getTerm().isBigInteger(false) && ((Number)variable2).getTerm().toBigInteger(false).compareTo(new BigInteger("0")) == 0) {
|
||||||
result.add(this);
|
result.add(this);
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
List<Function> l1 = new ArrayList<Function>();
|
List<Function> l1 = new ArrayList<Function>();
|
||||||
@ -64,7 +71,7 @@ public class Equation extends FunctionTwoValues {
|
|||||||
if (cur2 >= size1) cur2 = 0;
|
if (cur2 >= size1) cur2 = 0;
|
||||||
}
|
}
|
||||||
for (Function[] f : results) {
|
for (Function[] f : results) {
|
||||||
result.add(new Equation((FunctionBase)f[0], (FunctionBase)f[1]));
|
result.add(new Equation(f[0], f[1]));
|
||||||
}
|
}
|
||||||
stepsCount=-1;
|
stepsCount=-1;
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package org.warp.picalculator;
|
package org.warp.picalculator.math.functions.equations;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import org.warp.picalculator.math.functions.Number;
|
||||||
|
|
||||||
public class EquationResult {
|
public class EquationResult {
|
||||||
public boolean isAnEquation = false;
|
public boolean isAnEquation = false;
|
||||||
public Number LR = new Number(new BigInteger("0"));
|
public Number LR = new Number(new BigInteger("0"));
|
@ -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.ArrayList;
|
||||||
import java.util.List;
|
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 {
|
public class EquationsSystem extends FunctionMultipleValues {
|
||||||
static final int spacing = 2;
|
static final int spacing = 2;
|
||||||
|
|
@ -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.picalculator.device.graphicengine.Display.Render.glColor3f;
|
||||||
import static org.warp.engine.Display.Render.glDrawLine;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawLine;
|
||||||
|
|
||||||
import java.util.List;
|
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 class EquationsSystemPart extends AnteriorFunction {
|
||||||
|
|
||||||
public EquationsSystemPart(Equation equazione) {
|
public EquationsSystemPart(Equation equazione) {
|
@ -1,8 +1,8 @@
|
|||||||
package org.warp.picalculator.screens;
|
package org.warp.picalculator.screens;
|
||||||
|
|
||||||
import org.warp.device.Keyboard.Key;
|
import org.warp.picalculator.device.PIDisplay;
|
||||||
import org.warp.device.PIDisplay;
|
import org.warp.picalculator.device.Keyboard.Key;
|
||||||
import org.warp.engine.Screen;
|
import org.warp.picalculator.device.graphicengine.Screen;
|
||||||
|
|
||||||
public class EmptyScreen extends Screen {
|
public class EmptyScreen extends Screen {
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package org.warp.picalculator.screens;
|
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.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.List;
|
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.Error;
|
||||||
import org.warp.picalculator.Errors;
|
import org.warp.picalculator.Errors;
|
||||||
import org.warp.picalculator.Function;
|
|
||||||
import org.warp.picalculator.Utils;
|
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 {
|
public class EquationScreen extends Screen {
|
||||||
|
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
package org.warp.picalculator.screens;
|
package org.warp.picalculator.screens;
|
||||||
|
|
||||||
import static org.warp.engine.Display.Render.getMatrixOfImage;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.getMatrixOfImage;
|
||||||
import static org.warp.engine.Display.Render.glClearColor;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glClearColor;
|
||||||
import static org.warp.engine.Display.Render.glDrawSkin;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawSkin;
|
||||||
import static org.warp.engine.Display.Render.glDrawStringLeft;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.glDrawStringLeft;
|
||||||
import static org.warp.engine.Display.Render.setFont;
|
import static org.warp.picalculator.device.graphicengine.Display.Render.setFont;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
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.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 {
|
public class MarioScreen extends Screen {
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package org.warp.picalculator.screens;
|
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.Error;
|
||||||
import org.warp.picalculator.Main;
|
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 {
|
public class SolveEquationScreen extends Screen {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user