From f792e4c8eccc918f976c8d9aae838011078ed82e Mon Sep 17 00:00:00 2001 From: Sergey Solovyev Date: Sun, 13 Jan 2013 21:23:46 +0400 Subject: [PATCH] new plotter --- .../calculator/CalculatorDisplayMenuItem.java | 6 +++--- .../plot/AndroidCalculatorPlotter.java | 5 +++++ .../calculator/plot/CalculatorPlotter.java | 1 + .../calculator/plot/CalculatorPlotterImpl.java | 18 ++++++++++++++++-- .../calculator/plot/PlotResourceManager.java | 10 ++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/org/solovyev/android/calculator/plot/PlotResourceManager.java diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java index f3f990df..589e08e4 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorDisplayMenuItem.java @@ -5,6 +5,7 @@ import jscl.math.Generic; import org.jetbrains.annotations.NotNull; import org.solovyev.android.calculator.core.R; import org.solovyev.android.calculator.jscl.JsclOperation; +import org.solovyev.android.calculator.plot.CalculatorPlotter; import org.solovyev.android.calculator.view.NumeralBaseConverterDialog; import org.solovyev.android.menu.LabeledMenuItem; @@ -79,9 +80,8 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem getVisibleFunctions(); void plot(); + void plot(@NotNull Generic expression); boolean is2dPlotPossible(); diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotterImpl.java b/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotterImpl.java index 17e97280..74bba028 100644 --- a/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotterImpl.java +++ b/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotterImpl.java @@ -27,6 +27,8 @@ public class CalculatorPlotterImpl implements CalculatorPlotter { @NotNull private final Calculator calculator; + private final PlotResourceManager plotResourceManager = new PlotResourceManager(); + private boolean plot3d = false; private boolean plotImag = false; @@ -71,12 +73,17 @@ public class CalculatorPlotterImpl implements CalculatorPlotter { boolean realAdded = addFunction(new XyFunction(expression, xVariable, yVariable, false)); - final PlotFunction imagPlotFunction = new PlotFunction(new XyFunction(expression, xVariable, yVariable, true)); + final PlotFunction imagPlotFunction = newPlotFunction(new XyFunction(expression, xVariable, yVariable, true)); final boolean imagAdded = addFunction(plotImag ? imagPlotFunction : PlotFunction.invisible(imagPlotFunction)); return imagAdded || realAdded; } + @NotNull + private PlotFunction newPlotFunction(@NotNull XyFunction xyFunction) { + return new PlotFunction(xyFunction); + } + @Override public boolean addFunction(@NotNull PlotFunction plotFunction) { synchronized (functions) { @@ -119,7 +126,7 @@ public class CalculatorPlotterImpl implements CalculatorPlotter { @Override public boolean addFunction(@NotNull XyFunction xyFunction) { - return addFunction(new PlotFunction(xyFunction)); + return addFunction(newPlotFunction(xyFunction)); } @Override @@ -258,6 +265,13 @@ public class CalculatorPlotterImpl implements CalculatorPlotter { calculator.fireCalculatorEvent(CalculatorEventType.plot_graph, null); } + @Override + public void plot(@NotNull Generic expression) { + removeAllUnpinned(); + addFunction(expression); + plot(); + } + @Override public boolean is2dPlotPossible() { return arity < 2; diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/PlotResourceManager.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotResourceManager.java new file mode 100644 index 00000000..5fc6ab8b --- /dev/null +++ b/core/src/main/java/org/solovyev/android/calculator/plot/PlotResourceManager.java @@ -0,0 +1,10 @@ +package org.solovyev.android.calculator.plot; + +/** + * User: serso + * Date: 1/13/13 + * Time: 8:19 PM + */ +class PlotResourceManager { + +}