new plotter
This commit is contained in:
@@ -2,17 +2,12 @@ package org.solovyev.android.calculator;
|
||||
|
||||
import android.content.Context;
|
||||
import jscl.math.Generic;
|
||||
import jscl.math.function.Constant;
|
||||
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.PlotInput;
|
||||
import org.solovyev.android.calculator.view.NumeralBaseConverterDialog;
|
||||
import org.solovyev.android.menu.LabeledMenuItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
* Date: 21.09.12
|
||||
@@ -81,31 +76,17 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
|
||||
plot(R.string.c_plot) {
|
||||
@Override
|
||||
public void onClick(@NotNull CalculatorDisplayViewState data, @NotNull Context context) {
|
||||
final Generic generic = data.getResult();
|
||||
assert generic != null;
|
||||
final Generic expression = data.getResult();
|
||||
assert expression != null;
|
||||
|
||||
final List<Constant> variables = new ArrayList<Constant>(CalculatorUtils.getNotSystemConstants(generic));
|
||||
|
||||
final Constant xVariable;
|
||||
if ( variables.size() > 0 ) {
|
||||
xVariable = variables.get(0);
|
||||
} else {
|
||||
xVariable = null;
|
||||
}
|
||||
|
||||
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);
|
||||
Locator.getInstance().getPlotter().removeAllUnpinned();
|
||||
Locator.getInstance().getPlotter().addFunction(expression);
|
||||
Locator.getInstance().getPlotter().plot();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) {
|
||||
return CalculatorUtils.isPlotPossible(generic, operation);
|
||||
return Locator.getInstance().getPlotter().isPlotPossible(generic);
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -8,7 +8,6 @@ import org.solovyev.android.AndroidUtils;
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||
import org.solovyev.android.calculator.plot.GraphLineColor;
|
||||
import org.solovyev.android.calculator.plot.ParcelablePlotInput;
|
||||
import org.solovyev.android.prefs.BooleanPreference;
|
||||
import org.solovyev.android.prefs.IntegerPreference;
|
||||
import org.solovyev.android.prefs.LongPreference;
|
||||
@@ -16,10 +15,8 @@ import org.solovyev.android.prefs.Preference;
|
||||
import org.solovyev.android.prefs.R;
|
||||
import org.solovyev.android.prefs.StringPreference;
|
||||
import org.solovyev.android.view.VibratorContainer;
|
||||
import org.solovyev.common.ListMapper;
|
||||
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,164 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import jscl.math.Generic;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 1/12/13
|
||||
* Time: 11:03 PM
|
||||
*/
|
||||
public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@NotNull
|
||||
private final CalculatorPlotter plotter;
|
||||
|
||||
public AndroidCalculatorPlotter(@NotNull Context context,
|
||||
@NotNull CalculatorPlotter plotter) {
|
||||
this.plotter = plotter;
|
||||
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
onSharedPreferenceChanged(preferences, CalculatorPreferences.Graph.plotImag.getKey());
|
||||
onSharedPreferenceChanged(preferences, CalculatorPreferences.Graph.lineColorReal.getKey());
|
||||
onSharedPreferenceChanged(preferences, CalculatorPreferences.Graph.lineColorImag.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PlotData getPlotData() {
|
||||
return plotter.getPlotData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFunction(@NotNull Generic expression) {
|
||||
return plotter.addFunction(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFunction(@NotNull PlotFunction plotFunction) {
|
||||
return plotter.addFunction(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFunction(@NotNull XyFunction xyFunction) {
|
||||
return plotter.addFunction(xyFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef) {
|
||||
return plotter.addFunction(xyFunction, functionLineDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateFunction(@NotNull PlotFunction newFunction) {
|
||||
return plotter.updateFunction(newFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef) {
|
||||
return plotter.updateFunction(xyFunction, functionLineDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFunction(@NotNull PlotFunction plotFunction) {
|
||||
return plotter.removeFunction(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFunction(@NotNull XyFunction xyFunction) {
|
||||
return plotter.removeFunction(xyFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pin(@NotNull PlotFunction plotFunction) {
|
||||
plotter.pin(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unpin(@NotNull PlotFunction plotFunction) {
|
||||
plotter.unpin(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(@NotNull PlotFunction plotFunction) {
|
||||
plotter.show(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(@NotNull PlotFunction plotFunction) {
|
||||
plotter.hide(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllFunctions() {
|
||||
plotter.clearAllFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PlotFunction> getFunctions() {
|
||||
return plotter.getFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PlotFunction> getVisibleFunctions() {
|
||||
return plotter.getVisibleFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void plot() {
|
||||
plotter.plot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlotPossible(@NotNull Generic expression) {
|
||||
return plotter.isPlotPossible(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlot3d(boolean plot3d) {
|
||||
plotter.setPlot3d(plot3d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllUnpinned() {
|
||||
plotter.removeAllUnpinned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlotImag(boolean plotImag) {
|
||||
plotter.setPlotImag(plotImag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||
if (CalculatorPreferences.Graph.plotImag.getKey().equals(key)) {
|
||||
setPlotImag(CalculatorPreferences.Graph.plotImag.getPreference(preferences));
|
||||
}
|
||||
|
||||
if (CalculatorPreferences.Graph.lineColorReal.getKey().equals(key)) {
|
||||
setRealLineColor(CalculatorPreferences.Graph.lineColorReal.getPreference(preferences));
|
||||
}
|
||||
|
||||
if (CalculatorPreferences.Graph.lineColorImag.getKey().equals(key)) {
|
||||
setImagLineColor(CalculatorPreferences.Graph.lineColorImag.getPreference(preferences));
|
||||
}
|
||||
}
|
||||
|
||||
public void setImagLineColor(@NotNull GraphLineColor imagLineColor) {
|
||||
plotter.setImagLineColor(imagLineColor);
|
||||
}
|
||||
|
||||
public void setRealLineColor(@NotNull GraphLineColor realLineColor) {
|
||||
plotter.setRealLineColor(realLineColor);
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 1/5/13
|
||||
* Time: 7:37 PM
|
||||
*/
|
||||
public enum AndroidPlotLineStyle {
|
||||
|
||||
solid(PlotLineStyle.solid) {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(null);
|
||||
}
|
||||
},
|
||||
|
||||
dashed(PlotLineStyle.dashed) {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
|
||||
}
|
||||
},
|
||||
|
||||
dotted(PlotLineStyle.dotted) {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(new DashPathEffect(new float[]{5, 1}, 0));
|
||||
}
|
||||
},
|
||||
|
||||
dash_dotted(PlotLineStyle.dash_dotted) {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(new DashPathEffect(new float[]{10, 20, 5, 1}, 0));
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
private final PlotLineStyle plotLineStyle;
|
||||
|
||||
AndroidPlotLineStyle(@NotNull PlotLineStyle plotLineStyle) {
|
||||
this.plotLineStyle = plotLineStyle;
|
||||
}
|
||||
|
||||
public abstract void applyToPaint(@NotNull Paint paint);
|
||||
|
||||
@Nullable
|
||||
public static AndroidPlotLineStyle valueOf(@NotNull PlotLineStyle plotLineStyle) {
|
||||
for (AndroidPlotLineStyle androidPlotLineStyle : values()) {
|
||||
if ( androidPlotLineStyle.plotLineStyle == plotLineStyle ) {
|
||||
return androidPlotLineStyle;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 1/5/13
|
||||
* Time: 10:45 PM
|
||||
*/
|
||||
public enum FunctionLineColorType {
|
||||
|
||||
color_map,
|
||||
solid;
|
||||
}
|
@@ -1,156 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 1/5/13
|
||||
* Time: 7:41 PM
|
||||
*/
|
||||
public class FunctionLineDef implements Parcelable {
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* CONSTANTS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
private static final Float DEFAULT_LINE_WIDTH = -1f;
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* STATIC
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
private static final Creator<FunctionLineDef> CREATOR = new Creator<FunctionLineDef>() {
|
||||
@Override
|
||||
public FunctionLineDef createFromParcel(@NotNull Parcel in) {
|
||||
return fromParcel(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FunctionLineDef[] newArray(int size) {
|
||||
return new FunctionLineDef[size];
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* FIELDS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
private FunctionLineColorType lineColorType = FunctionLineColorType.solid;
|
||||
|
||||
private int lineColor = Color.WHITE;
|
||||
|
||||
@NotNull
|
||||
private FunctionLineStyle lineStyle = FunctionLineStyle.solid;
|
||||
|
||||
private float lineWidth = -DEFAULT_LINE_WIDTH;
|
||||
|
||||
private FunctionLineDef() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FunctionLineDef newInstance(int lineColor, @NotNull FunctionLineStyle lineStyle) {
|
||||
final FunctionLineDef result = new FunctionLineDef();
|
||||
result.lineColor = lineColor;
|
||||
result.lineStyle = lineStyle;
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FunctionLineDef newInstance(int lineColor, @NotNull FunctionLineStyle lineStyle, float lineWidth) {
|
||||
final FunctionLineDef result = new FunctionLineDef();
|
||||
result.lineColor = lineColor;
|
||||
result.lineStyle = lineStyle;
|
||||
result.lineWidth = lineWidth;
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FunctionLineDef newInstance(int lineColor, @NotNull FunctionLineStyle lineStyle, float lineWidth, @NotNull FunctionLineColorType lineColorType) {
|
||||
final FunctionLineDef result = new FunctionLineDef();
|
||||
result.lineColor = lineColor;
|
||||
result.lineColorType = lineColorType;
|
||||
result.lineStyle = lineStyle;
|
||||
result.lineWidth = lineWidth;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static FunctionLineDef fromParcel(@NotNull Parcel in) {
|
||||
final FunctionLineDef result = new FunctionLineDef();
|
||||
|
||||
result.lineColorType = (FunctionLineColorType) in.readSerializable();
|
||||
result.lineColor = in.readInt();
|
||||
result.lineStyle = (FunctionLineStyle) in.readSerializable();
|
||||
result.lineWidth = in.readFloat();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static FunctionLineDef newDefaultInstance() {
|
||||
return new FunctionLineDef();
|
||||
}
|
||||
|
||||
|
||||
public int getLineColor() {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FunctionLineStyle getLineStyle() {
|
||||
return lineStyle;
|
||||
}
|
||||
|
||||
public float getLineWidth() {
|
||||
return lineWidth;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public FunctionLineColorType getLineColorType() {
|
||||
return lineColorType;
|
||||
}
|
||||
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setColor(lineColor);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
|
||||
if ( lineWidth == DEFAULT_LINE_WIDTH ) {
|
||||
paint.setStrokeWidth(0);
|
||||
} else {
|
||||
paint.setStrokeWidth(lineWidth);
|
||||
}
|
||||
|
||||
lineStyle.applyToPaint(paint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NotNull Parcel out, int flags) {
|
||||
out.writeSerializable(lineColorType);
|
||||
out.writeInt(lineColor);
|
||||
out.writeSerializable(lineStyle);
|
||||
out.writeFloat(lineWidth);
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 1/5/13
|
||||
* Time: 7:37 PM
|
||||
*/
|
||||
public enum FunctionLineStyle {
|
||||
|
||||
solid {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(null);
|
||||
}
|
||||
},
|
||||
|
||||
dashed {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(new DashPathEffect(new float[] {10, 20}, 0));
|
||||
}
|
||||
},
|
||||
|
||||
dotted {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(new DashPathEffect(new float[] {5, 1}, 0));
|
||||
}
|
||||
},
|
||||
|
||||
dash_dotted {
|
||||
@Override
|
||||
public void applyToPaint(@NotNull Paint paint) {
|
||||
paint.setPathEffect(new DashPathEffect(new float[] {10, 20, 5, 1}, 0));
|
||||
}
|
||||
};
|
||||
|
||||
public abstract void applyToPaint(@NotNull Paint paint);
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 10/4/12
|
||||
* Time: 10:08 PM
|
||||
*/
|
||||
public enum GraphLineColor {
|
||||
|
||||
white(Color.WHITE),
|
||||
grey(Color.GRAY),
|
||||
red(Color.RED),
|
||||
blue(Color.rgb(16, 100, 140)),
|
||||
green(Color.GREEN);
|
||||
|
||||
private final int color;
|
||||
|
||||
private GraphLineColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
}
|
@@ -1,131 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ParcelablePlotInput implements Parcelable {
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* STATIC
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
@NotNull
|
||||
public static Creator<ParcelablePlotInput> CREATOR = new Creator<ParcelablePlotInput>() {
|
||||
@Override
|
||||
public ParcelablePlotInput createFromParcel(@NotNull Parcel in) {
|
||||
return fromParcel(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelablePlotInput[] newArray(int size) {
|
||||
return new ParcelablePlotInput[size];
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
**********************************************************************
|
||||
*
|
||||
* FIELDS
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
@NotNull
|
||||
private String expression;
|
||||
|
||||
@Nullable
|
||||
private String xVariableName;
|
||||
|
||||
@Nullable
|
||||
private String yVariableName;
|
||||
|
||||
@Nullable
|
||||
private FunctionLineDef lineDef;
|
||||
|
||||
public ParcelablePlotInput(@NotNull String expression,
|
||||
@Nullable String xVariableName,
|
||||
@Nullable String yVariableName) {
|
||||
this(expression, xVariableName, yVariableName, null);
|
||||
}
|
||||
|
||||
public ParcelablePlotInput(@NotNull String expression,
|
||||
@Nullable String xVariableName,
|
||||
@Nullable String yVariableName,
|
||||
@Nullable FunctionLineDef lineDef) {
|
||||
this.expression = expression;
|
||||
this.xVariableName = xVariableName;
|
||||
this.yVariableName = yVariableName;
|
||||
this.lineDef = lineDef;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ParcelablePlotInput fromParcel(@NotNull Parcel in) {
|
||||
final String expression = in.readString();
|
||||
final String xVariableName = in.readString();
|
||||
final String yVariableName = in.readString();
|
||||
final FunctionLineDef lineDef = in.readParcelable(Thread.currentThread().getContextClassLoader());
|
||||
return new ParcelablePlotInput(expression, xVariableName, yVariableName, lineDef);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getXVariableName() {
|
||||
return xVariableName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getYVariableName() {
|
||||
return yVariableName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FunctionLineDef getLineDef() {
|
||||
return lineDef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NotNull Parcel out, int flags) {
|
||||
out.writeString(expression);
|
||||
out.writeString(xVariableName);
|
||||
out.writeString(yVariableName);
|
||||
out.writeParcelable(lineDef, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ParcelablePlotInput)) return false;
|
||||
|
||||
final ParcelablePlotInput that = (ParcelablePlotInput) o;
|
||||
|
||||
if (!expression.equals(that.expression)) return false;
|
||||
if (xVariableName != null ? !xVariableName.equals(that.xVariableName) : that.xVariableName != null)
|
||||
return false;
|
||||
if (yVariableName != null ? !yVariableName.equals(that.yVariableName) : that.yVariableName != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = expression.hashCode();
|
||||
result = 31 * result + (xVariableName != null ? xVariableName.hashCode() : 0);
|
||||
result = 31 * result + (yVariableName != null ? yVariableName.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -13,12 +13,12 @@ import org.solovyev.android.view.UpdatableViewBuilder;
|
||||
public class ParcelablePlotInputListItem implements ListItem {
|
||||
|
||||
@NotNull
|
||||
private ParcelablePlotInput plotInput;
|
||||
private XyFunction plotInput;
|
||||
|
||||
@NotNull
|
||||
private UpdatableViewBuilder<TextView> viewBuilder;
|
||||
|
||||
public ParcelablePlotInputListItem(@NotNull ParcelablePlotInput plotInput) {
|
||||
public ParcelablePlotInputListItem(@NotNull XyFunction plotInput) {
|
||||
this.plotInput = plotInput;
|
||||
// todo serso: use correct tag
|
||||
this.viewBuilder = TextViewBuilder.newInstance(R.layout.plot_functions_fragment_list_item, null);
|
||||
@@ -52,6 +52,6 @@ public class ParcelablePlotInputListItem implements ListItem {
|
||||
}
|
||||
|
||||
private void fill(@NotNull TextView textView) {
|
||||
textView.setText(plotInput.getExpression());
|
||||
textView.setText(plotInput.getExpressionString());
|
||||
}
|
||||
}
|
||||
|
@@ -1,54 +0,0 @@
|
||||
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
|
||||
* Date: 12/1/12
|
||||
* Time: 5:09 PM
|
||||
*/
|
||||
public class PlotInput {
|
||||
|
||||
@NotNull
|
||||
private Generic function;
|
||||
|
||||
@Nullable
|
||||
private Constant xVariable;
|
||||
|
||||
@Nullable
|
||||
private Constant yVariable;
|
||||
|
||||
public PlotInput() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotInput newInstance(@NotNull Generic function,
|
||||
@Nullable Constant xVariable,
|
||||
@Nullable Constant yVariable) {
|
||||
PlotInput result = new PlotInput();
|
||||
|
||||
result.function = function;
|
||||
result.xVariable = xVariable;
|
||||
result.yVariable = yVariable;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Generic getFunction() {
|
||||
return function;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Constant getXVariable() {
|
||||
return xVariable;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Constant getYVariable() {
|
||||
return yVariable;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user