new method to clone the input screen
This commit is contained in:
parent
c4f51f8aee
commit
518bfc6c4a
@ -108,7 +108,7 @@ public class Keyboard {
|
|||||||
public static void debugKeyPressed(final int keyCode) {
|
public static void debugKeyPressed(final int keyCode) {
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.VK_ESCAPE:
|
case KeyEvent.VK_ESCAPE:
|
||||||
Keyboard.keyPressed(Key.POWEROFF);
|
Keyboard.keyPressed(Key.BACK);
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_S:
|
case KeyEvent.VK_S:
|
||||||
if (Keyboard.shift) {
|
if (Keyboard.shift) {
|
||||||
|
@ -137,6 +137,8 @@ public class CalculatorHUD extends HUD {
|
|||||||
currentDebugLine++;
|
currentDebugLine++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
r.glColor(0xFF000000);
|
||||||
|
r.glDrawStringLeft(5, StaticVars.screenSize[1] - ((currentDebugLine+1) * (r.getCurrentFont().getCharacterHeight()+1)), "DEBUG ENABLED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package it.cavallium.warppi.gui.expression;
|
package it.cavallium.warppi.gui.expression;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Caret implements Serializable {
|
public class Caret {
|
||||||
|
|
||||||
private int pos;
|
private int pos;
|
||||||
private int remaining;
|
private int remaining;
|
||||||
@ -22,6 +22,18 @@ public class Caret implements Serializable {
|
|||||||
this.lastSize = lastSize;
|
this.lastSize = lastSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy
|
||||||
|
* @param old
|
||||||
|
*/
|
||||||
|
public Caret(Caret old) {
|
||||||
|
this.pos = old.pos;
|
||||||
|
this.remaining = old.remaining;
|
||||||
|
this.state = old.state;
|
||||||
|
this.lastSize = Arrays.copyOf(old.lastSize, old.lastSize.length);
|
||||||
|
this.lastLocation = Arrays.copyOf(old.lastLocation, old.lastLocation.length);
|
||||||
|
}
|
||||||
|
|
||||||
public void skip(final int i) {
|
public void skip(final int i) {
|
||||||
remaining -= i;
|
remaining -= i;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package it.cavallium.warppi.gui.expression;
|
package it.cavallium.warppi.gui.expression;
|
||||||
|
|
||||||
import java.io.Serializable;
|
public enum CaretState {
|
||||||
|
|
||||||
public enum CaretState implements Serializable {
|
|
||||||
VISIBLE_ON, VISIBLE_OFF, HIDDEN
|
VISIBLE_ON, VISIBLE_OFF, HIDDEN
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package it.cavallium.warppi.gui.expression;
|
package it.cavallium.warppi.gui.expression;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import it.cavallium.warppi.event.KeyboardEventListener;
|
import it.cavallium.warppi.event.KeyboardEventListener;
|
||||||
import it.cavallium.warppi.gui.expression.blocks.Block;
|
import it.cavallium.warppi.gui.expression.blocks.Block;
|
||||||
|
import it.cavallium.warppi.gui.expression.blocks.BlockVariable;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
|
|
||||||
public abstract class ExtraMenu<T extends Block> implements Serializable, KeyboardEventListener {
|
public abstract class ExtraMenu<T extends Block> implements KeyboardEventListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = -6944683477814944299L;
|
private static final long serialVersionUID = -6944683477814944299L;
|
||||||
|
|
||||||
@ -18,6 +19,13 @@ public abstract class ExtraMenu<T extends Block> implements Serializable, Keyboa
|
|||||||
this.height = 0;
|
this.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExtraMenu(final ExtraMenu<T> old, final T newBlock) {
|
||||||
|
this.block = newBlock;
|
||||||
|
this.location = Arrays.copyOf(old.location, old.location.length);
|
||||||
|
this.width = old.width;
|
||||||
|
this.height = old.height;
|
||||||
|
}
|
||||||
|
|
||||||
public final T block;
|
public final T block;
|
||||||
protected int width;
|
protected int width;
|
||||||
protected int height;
|
protected int height;
|
||||||
@ -37,4 +45,8 @@ public abstract class ExtraMenu<T extends Block> implements Serializable, Keyboa
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract ExtraMenu<T> clone(InputContext ic);
|
||||||
|
|
||||||
|
public abstract ExtraMenu<T> clone(T newBlockVariable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package it.cavallium.warppi.gui.expression;
|
package it.cavallium.warppi.gui.expression;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.blocks.BlockVariable;
|
import it.cavallium.warppi.gui.expression.blocks.BlockVariable;
|
||||||
import it.cavallium.warppi.math.MathematicalSymbols;
|
import it.cavallium.warppi.math.MathematicalSymbols;
|
||||||
import it.cavallium.warppi.math.functions.Variable.V_TYPE;
|
import it.cavallium.warppi.math.functions.Variable.V_TYPE;
|
||||||
|
|
||||||
public class InputContext implements Serializable {
|
public class InputContext {
|
||||||
public final HashMap<Character, V_TYPE> variableTypes;
|
public final HashMap<Character, V_TYPE> variableTypes;
|
||||||
public BlockVariable variableTypeDirtyID = null;
|
public BlockVariable variableTypeDirtyID = null;
|
||||||
|
|
||||||
@ -20,4 +19,10 @@ public class InputContext implements Serializable {
|
|||||||
public InputContext(final HashMap<Character, V_TYPE> variableTypes) {
|
public InputContext(final HashMap<Character, V_TYPE> variableTypes) {
|
||||||
this.variableTypes = variableTypes;
|
this.variableTypes = variableTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InputContext(InputContext ic) {
|
||||||
|
this.variableTypes = new HashMap<>();
|
||||||
|
this.variableTypes.putAll(ic.variableTypes);
|
||||||
|
this.variableTypeDirtyID = ic.variableTypeDirtyID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package it.cavallium.warppi.gui.expression.blocks;
|
|||||||
import it.cavallium.warppi.gui.GraphicalElement;
|
import it.cavallium.warppi.gui.GraphicalElement;
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
import it.cavallium.warppi.gui.expression.ExtraMenu;
|
import it.cavallium.warppi.gui.expression.ExtraMenu;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.MathContext;
|
import it.cavallium.warppi.math.MathContext;
|
||||||
@ -93,4 +94,6 @@ public abstract class Block implements TreeBlock, GraphicalElement {
|
|||||||
public void setParent(final TreeContainer parent) {
|
public void setParent(final TreeContainer parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Block clone(InputContext ic);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.MathContext;
|
import it.cavallium.warppi.math.MathContext;
|
||||||
@ -17,6 +18,11 @@ public class BlockChar extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockChar(final char ch, InputContext ic) {
|
||||||
|
this.ch = ch;
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||||
BlockContainer.getDefaultFont(small).use(ge);
|
BlockContainer.getDefaultFont(small).use(ge);
|
||||||
@ -76,4 +82,9 @@ public class BlockChar extends Block {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockChar clone(InputContext ic) {
|
||||||
|
return new BlockChar(ch, ic);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import it.cavallium.warppi.Engine;
|
import it.cavallium.warppi.Engine;
|
||||||
import it.cavallium.warppi.gui.GraphicalElement;
|
import it.cavallium.warppi.gui.GraphicalElement;
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
import it.cavallium.warppi.gui.expression.CaretState;
|
import it.cavallium.warppi.gui.expression.CaretState;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
|
import it.cavallium.warppi.gui.graphicengine.BinaryFont;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
@ -31,6 +34,11 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
|
|||||||
private boolean autoMinimums;
|
private boolean autoMinimums;
|
||||||
private final TreeBlock parent;
|
private final TreeBlock parent;
|
||||||
|
|
||||||
|
public BlockContainer() {
|
||||||
|
this(null, false, BlockContainer.getDefaultCharWidth(false), BlockContainer.getDefaultCharHeight(false), true);
|
||||||
|
autoMinimums = true;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockContainer(final TreeBlock parent) {
|
public BlockContainer(final TreeBlock parent) {
|
||||||
this(parent, false, BlockContainer.getDefaultCharWidth(false), BlockContainer.getDefaultCharHeight(false), true);
|
this(parent, false, BlockContainer.getDefaultCharWidth(false), BlockContainer.getDefaultCharHeight(false), true);
|
||||||
autoMinimums = true;
|
autoMinimums = true;
|
||||||
@ -71,6 +79,26 @@ public class BlockContainer implements TreeContainer, GraphicalElement {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockContainer(BlockContainer old, InputContext ic) {
|
||||||
|
this.autoMinimums = old.autoMinimums;
|
||||||
|
this.content = new ObjectArrayList<>();
|
||||||
|
for (Block b : old.content) {
|
||||||
|
this.content.add(b.clone(ic));
|
||||||
|
}
|
||||||
|
this.height = old.height;
|
||||||
|
this.line = old.line;
|
||||||
|
this.minHeight = old.minHeight;
|
||||||
|
this.minWidth = old.minWidth;
|
||||||
|
this.parent = old.parent;
|
||||||
|
this.small = old.small;
|
||||||
|
this.width = old.width;
|
||||||
|
this.withBorder = old.withBorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainer clone(InputContext ic) {
|
||||||
|
return new BlockContainer(this, ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TreeBlock getParentBlock() {
|
public TreeBlock getParentBlock() {
|
||||||
return parent;
|
return parent;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
@ -26,6 +27,12 @@ public class BlockDivision extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockDivision(BlockDivision old, InputContext ic) {
|
||||||
|
containerUp = old.containerUp.clone(ic);
|
||||||
|
containerDown = old.containerDown.clone(ic);
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||||
BlockContainer.getDefaultFont(small).use(ge);
|
BlockContainer.getDefaultFont(small).use(ge);
|
||||||
@ -132,4 +139,9 @@ public class BlockDivision extends Block {
|
|||||||
public int getInnerContainersCount() {
|
public int getInnerContainersCount() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockDivision clone(InputContext ic) {
|
||||||
|
return new BlockDivision(this, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
@ -39,6 +40,12 @@ public class BlockLogarithm extends Block implements IParenthesis {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockLogarithm(BlockLogarithm old, InputContext ic) {
|
||||||
|
containerBase = old.containerBase.clone(ic);
|
||||||
|
containerNumber = old.containerNumber.clone(ic);
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||||
BlockContainer.getDefaultFont(small).use(ge);
|
BlockContainer.getDefaultFont(small).use(ge);
|
||||||
@ -171,4 +178,9 @@ public class BlockLogarithm extends Block implements IParenthesis {
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockLogarithm clone(InputContext ic) {
|
||||||
|
return new BlockLogarithm(this, ic);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
import it.cavallium.warppi.math.MathContext;
|
import it.cavallium.warppi.math.MathContext;
|
||||||
import it.cavallium.warppi.math.parser.features.FeatureParenthesis;
|
import it.cavallium.warppi.math.parser.features.FeatureParenthesis;
|
||||||
@ -14,6 +15,10 @@ public class BlockParenthesis extends BlockParenthesisAbstract {
|
|||||||
super(blocks);
|
super(blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockParenthesis(BlockParenthesis old, InputContext ic) {
|
||||||
|
super(old, ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Feature toFeature(final MathContext context) throws Error {
|
public Feature toFeature(final MathContext context) throws Error {
|
||||||
final Function cont = getNumberContainer().toFunction(context);
|
final Function cont = getNumberContainer().toFunction(context);
|
||||||
@ -30,4 +35,9 @@ public class BlockParenthesis extends BlockParenthesisAbstract {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockParenthesis clone(InputContext ic) {
|
||||||
|
return new BlockParenthesis(this, ic);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.MathContext;
|
import it.cavallium.warppi.math.MathContext;
|
||||||
@ -30,6 +31,12 @@ public abstract class BlockParenthesisAbstract extends Block implements IParenth
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlockParenthesisAbstract(BlockParenthesisAbstract old, InputContext ic) {
|
||||||
|
containerNumber = old.containerNumber.clone(ic);
|
||||||
|
prefix = old.prefix == null ? null : new String(old.prefix);
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
public BlockParenthesisAbstract(final ObjectArrayList<Block> blocks) {
|
public BlockParenthesisAbstract(final ObjectArrayList<Block> blocks) {
|
||||||
containerNumber = new BlockContainer(this, false, blocks);
|
containerNumber = new BlockContainer(this, false, blocks);
|
||||||
prefix = null;
|
prefix = null;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
@ -19,6 +20,10 @@ public class BlockPower extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockPower(BlockPower old, InputContext ic) {
|
||||||
|
this.containerExponent = old.containerExponent.clone(ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||||
BlockContainer.getDefaultFont(true).use(ge);
|
BlockContainer.getDefaultFont(true).use(ge);
|
||||||
@ -91,4 +96,9 @@ public class BlockPower extends Block {
|
|||||||
public int getInnerContainersCount() {
|
public int getInnerContainersCount() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPower clone(InputContext ic) {
|
||||||
|
return new BlockPower(this, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
@ -20,6 +21,10 @@ public class BlockPower2 extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockPower2(BlockPower2 old, InputContext ic) {
|
||||||
|
this.containerExponent = old.containerExponent.clone(ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCaretDeltaPositionAfterCreation() {
|
public int getCaretDeltaPositionAfterCreation() {
|
||||||
return 3;
|
return 3;
|
||||||
@ -97,4 +102,9 @@ public class BlockPower2 extends Block {
|
|||||||
public int getInnerContainersCount() {
|
public int getInnerContainersCount() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPower2 clone(InputContext ic) {
|
||||||
|
return new BlockPower2(this, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
import it.cavallium.warppi.math.MathContext;
|
import it.cavallium.warppi.math.MathContext;
|
||||||
import it.cavallium.warppi.math.parser.features.FeatureSine;
|
import it.cavallium.warppi.math.parser.features.FeatureSine;
|
||||||
@ -12,9 +13,18 @@ public class BlockSine extends BlockParenthesisAbstract {
|
|||||||
super("SIN");
|
super("SIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockSine(BlockSine old, InputContext ic) {
|
||||||
|
super(old, ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Feature toFeature(final MathContext context) throws Error {
|
public Feature toFeature(final MathContext context) throws Error {
|
||||||
final Function cont = getNumberContainer().toFunction(context);
|
final Function cont = getNumberContainer().toFunction(context);
|
||||||
return new FeatureSine(cont);
|
return new FeatureSine(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Block clone(InputContext ic) {
|
||||||
|
return new BlockSine(this, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
@ -21,6 +22,11 @@ public class BlockSquareRoot extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockSquareRoot(BlockSquareRoot old, InputContext ic) {
|
||||||
|
this.containerNumber = old.containerNumber.clone(ic);
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||||
BlockContainer.getDefaultFont(small).use(ge);
|
BlockContainer.getDefaultFont(small).use(ge);
|
||||||
@ -108,4 +114,9 @@ public class BlockSquareRoot extends Block {
|
|||||||
public int getInnerContainersCount() {
|
public int getInnerContainersCount() {
|
||||||
return 1; //2
|
return 1; //2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockSquareRoot clone(InputContext ic) {
|
||||||
|
return new BlockSquareRoot(this, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
|
import it.cavallium.warppi.gui.expression.InputContext;
|
||||||
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.cavallium.warppi.math.MathContext;
|
import it.cavallium.warppi.math.MathContext;
|
||||||
@ -15,6 +16,10 @@ public class BlockUndefined extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockUndefined(BlockUndefined old, InputContext ic) {
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
public void draw(final GraphicEngine ge, final Renderer r, final int x, final int y, final Caret caret) {
|
||||||
BlockContainer.getDefaultFont(small).use(ge);
|
BlockContainer.getDefaultFont(small).use(ge);
|
||||||
@ -70,4 +75,9 @@ public class BlockUndefined extends Block {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockUndefined clone(InputContext ic) {
|
||||||
|
return new BlockUndefined(this, ic);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import it.cavallium.warppi.Engine;
|
import it.cavallium.warppi.Engine;
|
||||||
import it.cavallium.warppi.event.KeyPressedEvent;
|
import it.cavallium.warppi.event.KeyPressedEvent;
|
||||||
import it.cavallium.warppi.event.KeyReleasedEvent;
|
import it.cavallium.warppi.event.KeyReleasedEvent;
|
||||||
@ -43,6 +45,18 @@ public class BlockVariable extends Block {
|
|||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockVariable(BlockVariable old, InputContext ic) {
|
||||||
|
this.ic = ic;
|
||||||
|
this.ch = old.ch;
|
||||||
|
type = old.type;
|
||||||
|
color = old.color;
|
||||||
|
typeDirtyID = old.typeDirtyID;
|
||||||
|
this.typeLocked = old.typeLocked;
|
||||||
|
menu = old.menu == null ? null : new VariableMenu(old.menu, this);
|
||||||
|
retrieveValue();
|
||||||
|
recomputeDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
private void retrieveValue() {
|
private void retrieveValue() {
|
||||||
type = ic.variableTypes.get(ch);
|
type = ic.variableTypes.get(ch);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
@ -53,7 +67,6 @@ public class BlockVariable extends Block {
|
|||||||
menu.mustRefreshMenu = true;
|
menu.mustRefreshMenu = true;
|
||||||
}
|
}
|
||||||
mustRefresh = true;
|
mustRefresh = true;
|
||||||
System.out.println("retrieve:" + type.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushValue() {
|
public void pushValue() {
|
||||||
@ -145,7 +158,11 @@ public class BlockVariable extends Block {
|
|||||||
super(var);
|
super(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = 3941994107852212764L;
|
private VariableMenu(VariableMenu old, BlockVariable newBlockVariable) {
|
||||||
|
super(old, newBlockVariable);
|
||||||
|
this.mustRefreshMenu = old.mustRefreshMenu;
|
||||||
|
this.text = new String(old.text);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open() {
|
public void open() {
|
||||||
@ -250,6 +267,16 @@ public class BlockVariable extends Block {
|
|||||||
r.glDrawStringCenter(popupX + width / 2, popupY + 2 + 5, text);
|
r.glDrawStringCenter(popupX + width / 2, popupY + 2 + 5, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VariableMenu clone(BlockVariable newBlockVariable) {
|
||||||
|
return new VariableMenu(this, newBlockVariable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VariableMenu clone(InputContext ic) {
|
||||||
|
return new VariableMenu(this, block.clone(ic));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -266,4 +293,9 @@ public class BlockVariable extends Block {
|
|||||||
public int getInnerContainersCount() {
|
public int getInnerContainersCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVariable clone(InputContext ic) {
|
||||||
|
return new BlockVariable(this, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import java.io.Serializable;
|
public interface TreeBlock {
|
||||||
|
|
||||||
public interface TreeBlock extends Serializable {
|
|
||||||
TreeContainer getParentContainer();
|
TreeContainer getParentContainer();
|
||||||
|
|
||||||
boolean hasParent();
|
boolean hasParent();
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package it.cavallium.warppi.gui.expression.blocks;
|
package it.cavallium.warppi.gui.expression.blocks;
|
||||||
|
|
||||||
import java.io.Serializable;
|
public interface TreeContainer {
|
||||||
|
|
||||||
public interface TreeContainer extends Serializable {
|
|
||||||
TreeBlock getParentBlock();
|
TreeBlock getParentBlock();
|
||||||
|
|
||||||
boolean hasParent();
|
boolean hasParent();
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package it.cavallium.warppi.gui.expression.containers;
|
package it.cavallium.warppi.gui.expression.containers;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import it.cavallium.warppi.event.KeyboardEventListener;
|
import it.cavallium.warppi.event.KeyboardEventListener;
|
||||||
import it.cavallium.warppi.gui.GraphicalElement;
|
import it.cavallium.warppi.gui.GraphicalElement;
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
@ -19,9 +17,9 @@ import it.cavallium.warppi.math.MathContext;
|
|||||||
import it.cavallium.warppi.util.Error;
|
import it.cavallium.warppi.util.Error;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
public abstract class InputContainer implements GraphicalElement, InputLayout, Serializable {
|
public abstract class InputContainer implements GraphicalElement, InputLayout {
|
||||||
private static final long serialVersionUID = 923589369317765667L;
|
private static final long serialVersionUID = 923589369317765667L;
|
||||||
protected final BlockContainer root;
|
protected BlockContainer root;
|
||||||
protected Caret caret;
|
protected Caret caret;
|
||||||
private static final float CARET_DURATION = 0.5f;
|
private static final float CARET_DURATION = 0.5f;
|
||||||
private float caretTime;
|
private float caretTime;
|
||||||
@ -56,6 +54,21 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
|||||||
root = new BlockContainer(null, small, false);
|
root = new BlockContainer(null, small, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy
|
||||||
|
* @param old
|
||||||
|
* @param ic
|
||||||
|
*/
|
||||||
|
protected InputContainer(InputContainer old, InputContext ic) {
|
||||||
|
this.caretTime = old.caretTime;
|
||||||
|
this.extra = old.extra == null ? null : old.extra.clone(ic);
|
||||||
|
this.maxPosition = old.maxPosition;
|
||||||
|
this.caret = old.caret == null ? null : new Caret(old.caret);
|
||||||
|
this.inputContext = ic;
|
||||||
|
this.root = old.root == null ? null : old.root.clone(ic);
|
||||||
|
this.parsed = old.parsed;
|
||||||
|
}
|
||||||
|
|
||||||
public void typeChar(final char c) {
|
public void typeChar(final char c) {
|
||||||
final Block b = parseChar(c);
|
final Block b = parseChar(c);
|
||||||
typeBlock(b);
|
typeBlock(b);
|
||||||
@ -117,6 +130,7 @@ public abstract class InputContainer implements GraphicalElement, InputLayout, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void moveRight(final int delta) {
|
public void moveRight(final int delta) {
|
||||||
|
|
||||||
final int curPos = caret.getPosition();
|
final int curPos = caret.getPosition();
|
||||||
if (curPos + delta < maxPosition) {
|
if (curPos + delta < maxPosition) {
|
||||||
caret.setPosition(curPos + delta);
|
caret.setPosition(curPos + delta);
|
||||||
|
@ -21,8 +21,6 @@ import it.cavallium.warppi.math.MathematicalSymbols;
|
|||||||
|
|
||||||
public class NormalInputContainer extends InputContainer {
|
public class NormalInputContainer extends InputContainer {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5236564695997222322L;
|
|
||||||
|
|
||||||
@Deprecated()
|
@Deprecated()
|
||||||
/**
|
/**
|
||||||
* Use NormalInputContainer(InputContext) instead
|
* Use NormalInputContainer(InputContext) instead
|
||||||
@ -43,6 +41,16 @@ public class NormalInputContainer extends InputContainer {
|
|||||||
super(ic, small, minWidth, minHeight);
|
super(ic, small, minWidth, minHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy
|
||||||
|
* @param userInput
|
||||||
|
* @param ic
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public NormalInputContainer(InputContainer old, InputContext ic) {
|
||||||
|
super(old, ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Block parseChar(final char c) {
|
public Block parseChar(final char c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package it.cavallium.warppi.gui.expression.containers;
|
package it.cavallium.warppi.gui.expression.containers;
|
||||||
|
|
||||||
public class NormalOutputContainer extends OutputContainer {
|
import it.cavallium.warppi.gui.expression.blocks.BlockContainer;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
private static final long serialVersionUID = 5087850494875415142L;
|
public class NormalOutputContainer extends OutputContainer {
|
||||||
|
|
||||||
public NormalOutputContainer() {
|
public NormalOutputContainer() {
|
||||||
super();
|
super();
|
||||||
@ -15,4 +16,9 @@ public class NormalOutputContainer extends OutputContainer {
|
|||||||
public NormalOutputContainer(final boolean small, final int minWidth, final int minHeight) {
|
public NormalOutputContainer(final boolean small, final int minWidth, final int minHeight) {
|
||||||
super(small, minWidth, minHeight);
|
super(small, minWidth, minHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NormalOutputContainer(OutputContainer old) {
|
||||||
|
super.roots.clear();
|
||||||
|
super.roots.addAll(old.roots.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package it.cavallium.warppi.gui.expression.containers;
|
package it.cavallium.warppi.gui.expression.containers;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.GraphicalElement;
|
import it.cavallium.warppi.gui.GraphicalElement;
|
||||||
import it.cavallium.warppi.gui.expression.Caret;
|
import it.cavallium.warppi.gui.expression.Caret;
|
||||||
import it.cavallium.warppi.gui.expression.CaretState;
|
import it.cavallium.warppi.gui.expression.CaretState;
|
||||||
@ -12,14 +10,14 @@ import it.cavallium.warppi.gui.graphicengine.GraphicEngine;
|
|||||||
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
import it.cavallium.warppi.gui.graphicengine.Renderer;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
public abstract class OutputContainer implements GraphicalElement, OutputLayout, Serializable {
|
public abstract class OutputContainer implements GraphicalElement, OutputLayout {
|
||||||
private static final long serialVersionUID = -5714825964892683571L;
|
private static final long serialVersionUID = -5714825964892683571L;
|
||||||
public final ObjectArrayList<BlockContainer> roots;
|
public final ObjectArrayList<BlockContainer> roots;
|
||||||
private final Caret caret = new Caret(CaretState.HIDDEN, 0);
|
private final Caret caret = new Caret(CaretState.HIDDEN, 0);
|
||||||
|
|
||||||
public OutputContainer() {
|
public OutputContainer() {
|
||||||
roots = new ObjectArrayList<>();
|
roots = new ObjectArrayList<>();
|
||||||
roots.add(new BlockContainer(null));
|
roots.add(new BlockContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public OutputContainer(final boolean small) {
|
public OutputContainer(final boolean small) {
|
||||||
@ -34,7 +32,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
|||||||
|
|
||||||
public void setContentAsSingleGroup(final ObjectArrayList<Block> blocks) {
|
public void setContentAsSingleGroup(final ObjectArrayList<Block> blocks) {
|
||||||
roots.clear();
|
roots.clear();
|
||||||
final BlockContainer bcnt = new BlockContainer(null);
|
final BlockContainer bcnt = new BlockContainer();
|
||||||
for (final Block block : blocks) {
|
for (final Block block : blocks) {
|
||||||
bcnt.appendBlockUnsafe(block);
|
bcnt.appendBlockUnsafe(block);
|
||||||
}
|
}
|
||||||
@ -45,7 +43,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
|||||||
public void setContentAsMultipleGroups(final ObjectArrayList<ObjectArrayList<Block>> roots) {
|
public void setContentAsMultipleGroups(final ObjectArrayList<ObjectArrayList<Block>> roots) {
|
||||||
this.roots.clear();
|
this.roots.clear();
|
||||||
for (final ObjectArrayList<Block> blocks : roots) {
|
for (final ObjectArrayList<Block> blocks : roots) {
|
||||||
final BlockContainer bcnt = new BlockContainer(null);
|
final BlockContainer bcnt = new BlockContainer();
|
||||||
for (final Block block : blocks) {
|
for (final Block block : blocks) {
|
||||||
bcnt.appendBlockUnsafe(block);
|
bcnt.appendBlockUnsafe(block);
|
||||||
}
|
}
|
||||||
@ -57,7 +55,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
|||||||
public void setContentAsMultipleElements(final ObjectArrayList<Block> elems) {
|
public void setContentAsMultipleElements(final ObjectArrayList<Block> elems) {
|
||||||
roots.clear();
|
roots.clear();
|
||||||
for (final Block block : elems) {
|
for (final Block block : elems) {
|
||||||
final BlockContainer bcnt = new BlockContainer(null);
|
final BlockContainer bcnt = new BlockContainer();
|
||||||
bcnt.appendBlockUnsafe(block);
|
bcnt.appendBlockUnsafe(block);
|
||||||
roots.add(bcnt);
|
roots.add(bcnt);
|
||||||
}
|
}
|
||||||
@ -131,7 +129,7 @@ public abstract class OutputContainer implements GraphicalElement, OutputLayout,
|
|||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
roots.clear();
|
roots.clear();
|
||||||
roots.add(new BlockContainer(null));
|
roots.add(new BlockContainer());
|
||||||
recomputeDimensions();
|
recomputeDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,24 @@ public class MathInputScreen extends Screen {
|
|||||||
canBeInHistory = true;
|
canBeInHistory = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a copy of this element
|
||||||
|
* @param mathInputScreen
|
||||||
|
*/
|
||||||
|
private MathInputScreen(MathInputScreen old) {
|
||||||
|
this.calc = new MathContext(old.calc);
|
||||||
|
this.canBeInHistory = old.canBeInHistory;
|
||||||
|
this.created = old.created;
|
||||||
|
this.currentStep = old.currentStep;
|
||||||
|
this.d = old.d;
|
||||||
|
this.errorLevel = old.errorLevel;
|
||||||
|
this.ic = new InputContext(old.ic);
|
||||||
|
this.initialized = old.initialized;
|
||||||
|
this.mustRefresh = old.mustRefresh;
|
||||||
|
this.result = new NormalOutputContainer(old.result);
|
||||||
|
this.userInput = new NormalInputContainer(old.userInput, this.ic);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void created() throws InterruptedException {
|
public void created() throws InterruptedException {
|
||||||
ic = new InputContext();
|
ic = new InputContext();
|
||||||
@ -471,19 +489,7 @@ public class MathInputScreen extends Screen {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void swapInputScreen() {
|
private void swapInputScreen() {
|
||||||
MathInputScreen mis = new MathInputScreen();
|
MathInputScreen mis = new MathInputScreen(this);
|
||||||
mis.calc = SerializationUtils.clone(calc);
|
|
||||||
mis.canBeInHistory = true;
|
|
||||||
mis.currentStep = currentStep;
|
|
||||||
mis.created = created;
|
|
||||||
mis.d = d;
|
|
||||||
mis.errorLevel = errorLevel;
|
|
||||||
mis.ic = SerializationUtils.clone(ic);
|
|
||||||
mis.initialized = initialized;
|
|
||||||
mis.mustRefresh = true;
|
|
||||||
mis.result = SerializationUtils.clone(result);
|
|
||||||
mis.userInput = SerializationUtils.clone(userInput);
|
|
||||||
mis.d = d;
|
|
||||||
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis);
|
Engine.INSTANCE.getHardwareDevice().getDisplayManager().setScreen(mis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package it.cavallium.warppi.gui.screens;
|
package it.cavallium.warppi.gui.screens;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import it.cavallium.warppi.event.KeyboardEventListener;
|
import it.cavallium.warppi.event.KeyboardEventListener;
|
||||||
import it.cavallium.warppi.event.TouchEventListener;
|
import it.cavallium.warppi.event.TouchEventListener;
|
||||||
import it.cavallium.warppi.gui.DisplayManager;
|
import it.cavallium.warppi.gui.DisplayManager;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package it.cavallium.warppi.math;
|
package it.cavallium.warppi.math;
|
||||||
|
|
||||||
import java.io.Serializable;
|
public enum AngleMode {
|
||||||
|
|
||||||
public enum AngleMode implements Serializable {
|
|
||||||
DEG, RAD, GRA
|
DEG, RAD, GRA
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package it.cavallium.warppi.math;
|
package it.cavallium.warppi.math;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.blocks.Block;
|
import it.cavallium.warppi.gui.expression.blocks.Block;
|
||||||
import it.cavallium.warppi.math.rules.Rule;
|
import it.cavallium.warppi.math.rules.Rule;
|
||||||
import it.cavallium.warppi.util.Error;
|
import it.cavallium.warppi.util.Error;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
public interface Function extends Serializable {
|
public interface Function {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this function and its children in a string form.
|
* Returns this function and its children in a string form.
|
||||||
@ -27,6 +25,14 @@ public interface Function extends Serializable {
|
|||||||
*/
|
*/
|
||||||
Function clone();
|
Function clone();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deep clone this function, also change mathContext.
|
||||||
|
*
|
||||||
|
* @param mathContext new mathContext
|
||||||
|
* @return A clone of this function.
|
||||||
|
*/
|
||||||
|
Function clone(MathContext newMathContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic method to change a parameter in a known position.
|
* Generic method to change a parameter in a known position.
|
||||||
*
|
*
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package it.cavallium.warppi.math;
|
package it.cavallium.warppi.math;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
|
||||||
|
|
||||||
import it.cavallium.warppi.math.functions.Variable.VariableValue;
|
import it.cavallium.warppi.math.functions.Variable.VariableValue;
|
||||||
import it.cavallium.warppi.math.rules.Rule;
|
import it.cavallium.warppi.math.rules.Rule;
|
||||||
import it.cavallium.warppi.math.rules.RuleType;
|
import it.cavallium.warppi.math.rules.RuleType;
|
||||||
@ -11,7 +7,7 @@ import it.cavallium.warppi.math.rules.RulesManager;
|
|||||||
import it.cavallium.warppi.util.Error;
|
import it.cavallium.warppi.util.Error;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
public class MathContext implements Serializable {
|
public class MathContext {
|
||||||
|
|
||||||
public AngleMode angleMode = AngleMode.DEG;
|
public AngleMode angleMode = AngleMode.DEG;
|
||||||
public boolean exactMode = false;
|
public boolean exactMode = false;
|
||||||
@ -27,6 +23,24 @@ public class MathContext implements Serializable {
|
|||||||
resultsCount = 0;
|
resultsCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MathContext(MathContext calc) {
|
||||||
|
this.f = new ObjectArrayList<>();
|
||||||
|
this.f2 = new ObjectArrayList<>();
|
||||||
|
for (Function f : calc.f) {
|
||||||
|
f = f.clone(this);
|
||||||
|
this.f.add(f);
|
||||||
|
}
|
||||||
|
for (Function f : calc.f2) {
|
||||||
|
f = f.clone(this);
|
||||||
|
this.f2.add(f);
|
||||||
|
}
|
||||||
|
this.variablesValues = new ObjectArrayList<>();
|
||||||
|
for (VariableValue varVal : calc.variablesValues) {
|
||||||
|
this.variablesValues.add(new VariableValue(varVal, this));
|
||||||
|
}
|
||||||
|
this.resultsCount = calc.resultsCount;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Function parseString(final String string) throws Error {
|
public Function parseString(final String string) throws Error {
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,7 +26,12 @@ public class Division extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FunctionOperator clone() {
|
public FunctionOperator clone() {
|
||||||
return new Division(getMathContext(), getParameter1(), getParameter2());
|
return new Division(getMathContext(), getParameter1() == null ? null : getParameter1().clone(), getParameter2() == null ? null : getParameter2().clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FunctionOperator clone(MathContext c) {
|
||||||
|
return new Division(c, getParameter1() == null ? null : getParameter1().clone(c), getParameter2() == null ? null : getParameter2().clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,6 +35,11 @@ public class EmptyNumber implements Function {
|
|||||||
return new EmptyNumber(root);
|
return new EmptyNumber(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Function clone(MathContext c) {
|
||||||
|
return new EmptyNumber(c);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Function setParameter(final int index, final Function var) throws IndexOutOfBoundsException {
|
public Function setParameter(final int index, final Function var) throws IndexOutOfBoundsException {
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
@ -610,7 +610,12 @@ public class Expression extends FunctionSingle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Expression clone() {
|
public Expression clone() {
|
||||||
return new Expression(mathContext, parameter);
|
return new Expression(mathContext, parameter == null ? null : parameter.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Expression clone(MathContext newContext) {
|
||||||
|
return new Expression(newContext, parameter == null ? null : parameter.clone(newContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,11 @@ public class Joke implements Function {
|
|||||||
return new Joke(root, joke);
|
return new Joke(root, joke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Function clone(MathContext c) {
|
||||||
|
return new Joke(c, joke);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Function setParameter(final int index, final Function var) throws IndexOutOfBoundsException {
|
public Function setParameter(final int index, final Function var) throws IndexOutOfBoundsException {
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
@ -26,7 +26,12 @@ public class Logarithm extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Logarithm clone() {
|
public Logarithm clone() {
|
||||||
return new Logarithm(mathContext, parameter1, parameter2);
|
return new Logarithm(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Logarithm clone(MathContext c) {
|
||||||
|
return new Logarithm(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,12 @@ public class Multiplication extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Multiplication clone() {
|
public Multiplication clone() {
|
||||||
return new Multiplication(mathContext, parameter1, parameter2);
|
return new Multiplication(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Multiplication clone(MathContext c) {
|
||||||
|
return new Multiplication(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,7 +71,7 @@ public class Multiplication extends FunctionOperator {
|
|||||||
} else {
|
} else {
|
||||||
result.addAll(sub1);
|
result.addAll(sub1);
|
||||||
}
|
}
|
||||||
if (nearLeft instanceof BlockChar && nearRight instanceof BlockChar && !(par2 instanceof Negative) && !(par1 instanceof Number && par2 instanceof Number)) {
|
if (nearLeft instanceof BlockChar && nearRight instanceof BlockChar && !(par2 instanceof Negative) && !(par1 instanceof Number && par2 instanceof Number) && !(par1 instanceof Number && par2 instanceof Multiplication && ((Multiplication)par2).getParameter1() instanceof Number)) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result.add(new BlockChar(MathematicalSymbols.MULTIPLICATION));
|
result.add(new BlockChar(MathematicalSymbols.MULTIPLICATION));
|
||||||
|
@ -26,7 +26,12 @@ public class Negative extends FunctionSingle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Negative clone() {
|
public Negative clone() {
|
||||||
return new Negative(mathContext, parameter);
|
return new Negative(mathContext, parameter == null ? null : parameter.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Negative clone(MathContext c) {
|
||||||
|
return new Negative(c, parameter == null ? null : parameter.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,6 +49,16 @@ public class Number implements Function {
|
|||||||
this(root, BigDecimal.valueOf(s).setScale(Utils.scale, Utils.scaleMode2));
|
this(root, BigDecimal.valueOf(s).setScale(Utils.scale, Utils.scaleMode2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy
|
||||||
|
* @param n
|
||||||
|
* @param newContext
|
||||||
|
*/
|
||||||
|
public Number(Number old, MathContext newContext) {
|
||||||
|
this.root = newContext;
|
||||||
|
this.term = old.term;
|
||||||
|
}
|
||||||
|
|
||||||
public BigDecimal getTerm() {
|
public BigDecimal getTerm() {
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
@ -117,6 +127,11 @@ public class Number implements Function {
|
|||||||
return new Number(root, term);
|
return new Number(root, term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Number clone(MathContext c) {
|
||||||
|
return new Number(c, term);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectArrayList<Function> simplify(final Rule rule) throws Error, InterruptedException {
|
public ObjectArrayList<Function> simplify(final Rule rule) throws Error, InterruptedException {
|
||||||
return rule.execute(this);
|
return rule.execute(this);
|
||||||
|
@ -26,7 +26,12 @@ public class Power extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Power clone() {
|
public Power clone() {
|
||||||
return new Power(mathContext, parameter1, parameter2);
|
return new Power(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Power clone(MathContext c) {
|
||||||
|
return new Power(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,12 @@ public class Root extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Root clone() {
|
public Root clone() {
|
||||||
return new Root(mathContext, parameter1, parameter2);
|
return new Root(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Root clone(MathContext c) {
|
||||||
|
return new Root(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,12 @@ public class RootSquare extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RootSquare clone() {
|
public RootSquare clone() {
|
||||||
return new RootSquare(mathContext, parameter2);
|
return new RootSquare(mathContext, parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RootSquare clone(MathContext c) {
|
||||||
|
return new RootSquare(c, parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,12 @@ public class Subtraction extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Subtraction clone() {
|
public Subtraction clone() {
|
||||||
return new Subtraction(mathContext, parameter1, parameter2);
|
return new Subtraction(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Subtraction clone(MathContext c) {
|
||||||
|
return new Subtraction(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,12 @@ public class Sum extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Sum clone() {
|
public Sum clone() {
|
||||||
return new Sum(mathContext, parameter1, parameter2);
|
return new Sum(mathContext, parameter1 == null ? parameter1 : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sum clone(MathContext c) {
|
||||||
|
return new Sum(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,12 @@ public class SumSubtraction extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SumSubtraction clone() {
|
public SumSubtraction clone() {
|
||||||
return new SumSubtraction(mathContext, parameter1, parameter2);
|
return new SumSubtraction(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SumSubtraction clone(MathContext c) {
|
||||||
|
return new SumSubtraction(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,6 +36,11 @@ public class Undefined implements Function {
|
|||||||
return new Undefined(root);
|
return new Undefined(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Undefined clone(MathContext c) {
|
||||||
|
return new Undefined(c);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Function setParameter(final int index, final Function var) throws IndexOutOfBoundsException {
|
public Function setParameter(final int index, final Function var) throws IndexOutOfBoundsException {
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package it.cavallium.warppi.math.functions;
|
package it.cavallium.warppi.math.functions;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import it.cavallium.warppi.gui.expression.blocks.Block;
|
import it.cavallium.warppi.gui.expression.blocks.Block;
|
||||||
import it.cavallium.warppi.gui.expression.blocks.BlockChar;
|
import it.cavallium.warppi.gui.expression.blocks.BlockChar;
|
||||||
import it.cavallium.warppi.math.Function;
|
import it.cavallium.warppi.math.Function;
|
||||||
@ -26,6 +24,17 @@ public class Variable implements Function {
|
|||||||
this(root, s.charAt(0), type);
|
this(root, s.charAt(0), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy
|
||||||
|
* @param old
|
||||||
|
* @param root
|
||||||
|
*/
|
||||||
|
public Variable(Variable old, MathContext root) {
|
||||||
|
this.root = root;
|
||||||
|
this.type = old.type;
|
||||||
|
this.var = old.var;
|
||||||
|
}
|
||||||
|
|
||||||
public char getChar() {
|
public char getChar() {
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
@ -47,8 +56,7 @@ public class Variable implements Function {
|
|||||||
return "" + getChar();
|
return "" + getChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class VariableValue implements Serializable {
|
public static class VariableValue {
|
||||||
private static final long serialVersionUID = -5656281021874324571L;
|
|
||||||
public final Variable v;
|
public final Variable v;
|
||||||
public final Number n;
|
public final Number n;
|
||||||
|
|
||||||
@ -56,6 +64,16 @@ public class Variable implements Function {
|
|||||||
this.v = v;
|
this.v = v;
|
||||||
this.n = n;
|
this.n = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy
|
||||||
|
* @param old
|
||||||
|
* @param newContext
|
||||||
|
*/
|
||||||
|
public VariableValue(VariableValue old, MathContext newContext) {
|
||||||
|
this.v = new Variable(old.v, newContext);
|
||||||
|
this.n = new Number(old.n, newContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,6 +104,11 @@ public class Variable implements Function {
|
|||||||
return new Variable(root, var, type);
|
return new Variable(root, var, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Variable clone(MathContext c) {
|
||||||
|
return new Variable(c, var, type);
|
||||||
|
}
|
||||||
|
|
||||||
public static enum V_TYPE {
|
public static enum V_TYPE {
|
||||||
CONSTANT, VARIABLE, SOLUTION
|
CONSTANT, VARIABLE, SOLUTION
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,12 @@ public class Equation extends FunctionOperator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Equation clone() {
|
public Equation clone() {
|
||||||
return new Equation(mathContext, parameter1, parameter2);
|
return new Equation(mathContext, parameter1 == null ? null : parameter1.clone(), parameter2 == null ? null : parameter2.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Equation clone(MathContext c) {
|
||||||
|
return new Equation(c, parameter1 == null ? null : parameter1.clone(c), parameter2 == null ? null : parameter2.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,20 @@ public class EquationsSystem extends FunctionDynamic {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EquationsSystem clone() {
|
public EquationsSystem clone() {
|
||||||
return new EquationsSystem(root, functions);
|
Function[] newFuncs = functions.clone();
|
||||||
|
for (int i = 0; i < newFuncs.length; i++) {
|
||||||
|
newFuncs[i] = newFuncs[i].clone();
|
||||||
|
}
|
||||||
|
return new EquationsSystem(root, newFuncs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EquationsSystem clone(MathContext c) {
|
||||||
|
Function[] newFuncs = new Function[this.functions.length];
|
||||||
|
for (int i = 0; i < newFuncs.length; i++) {
|
||||||
|
newFuncs[i] = this.functions[i] == null ? null : this.functions[i].clone(c);
|
||||||
|
}
|
||||||
|
return new EquationsSystem(c, newFuncs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,12 @@ public class EquationsSystemPart extends FunctionSingle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EquationsSystemPart clone() {
|
public EquationsSystemPart clone() {
|
||||||
return new EquationsSystemPart(mathContext, (Equation) parameter);
|
return new EquationsSystemPart(mathContext, (Equation) (parameter == null ? null : parameter.clone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EquationsSystemPart clone(MathContext c) {
|
||||||
|
return new EquationsSystemPart(c, (Equation) (parameter == null ? null : parameter.clone(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,12 @@ public class ArcCosine extends FunctionSingle {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FunctionSingle clone(MathContext c) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -26,6 +26,12 @@ public class ArcSine extends FunctionSingle {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FunctionSingle clone(MathContext c) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -26,6 +26,12 @@ public class ArcTangent extends FunctionSingle {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FunctionSingle clone(MathContext c) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -26,6 +26,12 @@ public class Cosine extends FunctionSingle {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FunctionSingle clone(MathContext c) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -28,7 +28,12 @@ public class Sine extends FunctionSingle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Sine clone() {
|
public Sine clone() {
|
||||||
return new Sine(mathContext, parameter);
|
return new Sine(mathContext, parameter == null ? null : parameter.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sine clone(MathContext c) {
|
||||||
|
return new Sine(c, parameter == null ? null : parameter.clone(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,12 @@ public class Tangent extends FunctionSingle {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FunctionSingle clone(MathContext c) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
public ObjectArrayList<Block> toBlock(final MathContext context) throws Error {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
Loading…
Reference in New Issue
Block a user