new plotter
This commit is contained in:
		@@ -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<CalculatorDispl
 | 
			
		||||
            final Generic expression = data.getResult();
 | 
			
		||||
            assert expression != null;
 | 
			
		||||
 | 
			
		||||
            Locator.getInstance().getPlotter().removeAllUnpinned();
 | 
			
		||||
            Locator.getInstance().getPlotter().addFunction(expression);
 | 
			
		||||
            Locator.getInstance().getPlotter().plot();
 | 
			
		||||
            final CalculatorPlotter plotter = Locator.getInstance().getPlotter();
 | 
			
		||||
            plotter.plot(expression);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -123,6 +123,11 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
 | 
			
		||||
        plotter.plot();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void plot(@NotNull Generic expression) {
 | 
			
		||||
        plotter.plot(expression);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean is2dPlotPossible() {
 | 
			
		||||
        return plotter.is2dPlotPossible();
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,7 @@ public interface CalculatorPlotter {
 | 
			
		||||
    List<PlotFunction> getVisibleFunctions();
 | 
			
		||||
 | 
			
		||||
    void plot();
 | 
			
		||||
    void plot(@NotNull Generic expression);
 | 
			
		||||
 | 
			
		||||
    boolean is2dPlotPossible();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
package org.solovyev.android.calculator.plot;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * User: serso
 | 
			
		||||
 * Date: 1/13/13
 | 
			
		||||
 * Time: 8:19 PM
 | 
			
		||||
 */
 | 
			
		||||
class PlotResourceManager {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user