new plotter
This commit is contained in:
@@ -9,7 +9,9 @@ import org.solovyev.android.calculator.jscl.JsclOperation;
|
||||
import org.solovyev.android.calculator.plot.PlotInput;
|
||||
import org.solovyev.android.calculator.view.NumeralBaseConverterDialog;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
import org.solovyev.common.collections.CollectionsUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
@@ -82,10 +84,17 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
|
||||
final Generic generic = data.getResult();
|
||||
assert generic != null;
|
||||
|
||||
final Constant constant = CollectionsUtils.getFirstCollectionElement(CalculatorUtils.getNotSystemConstants(generic));
|
||||
assert constant != null;
|
||||
final List<Constant> variables = new ArrayList<Constant>(CalculatorUtils.getNotSystemConstants(generic));
|
||||
final Constant xVariable = variables.get(0);
|
||||
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.plot_graph, PlotInput.newInstance(generic, constant), context);
|
||||
final Constant yVariable;
|
||||
if ( variables.size() > 1 ) {
|
||||
yVariable = variables.get(1);
|
||||
} else {
|
||||
yVariable = null;
|
||||
}
|
||||
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.plot_graph, PlotInput.newInstance(generic, xVariable, yVariable), context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,6 +3,7 @@ package org.solovyev.android.calculator.plot;
|
||||
import jscl.math.Generic;
|
||||
import jscl.math.function.Constant;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
@@ -15,19 +16,25 @@ public class PlotInput {
|
||||
private Generic function;
|
||||
|
||||
@NotNull
|
||||
private Constant constant;
|
||||
private Constant xVariable;
|
||||
|
||||
@Nullable
|
||||
private Constant yVariable;
|
||||
|
||||
public PlotInput() {
|
||||
}
|
||||
|
||||
private PlotInput(@NotNull Generic function, @NotNull Constant constant) {
|
||||
this.function = function;
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotInput newInstance(@NotNull Generic function, @NotNull Constant constant) {
|
||||
return new PlotInput(function, constant);
|
||||
public static PlotInput newInstance(@NotNull Generic function,
|
||||
@NotNull Constant xVariable,
|
||||
@Nullable Constant yVariable) {
|
||||
PlotInput result = new PlotInput();
|
||||
|
||||
result.function = function;
|
||||
result.xVariable = xVariable;
|
||||
result.yVariable = yVariable;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -36,7 +43,12 @@ public class PlotInput {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Constant getConstant() {
|
||||
return constant;
|
||||
public Constant getXVariable() {
|
||||
return xVariable;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Constant getYVariable() {
|
||||
return yVariable;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user