new plotter
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="wrap_content"
|
||||
a:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
a:id="@+id/cpp_plot_function_expression_textview"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_weight="5"/>
|
||||
|
||||
<CheckBox
|
||||
a:id="@+id/cpp_plot_function_pinned_checkbox"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
<CheckBox
|
||||
a:id="@+id/cpp_plot_function_visible_checkbox"
|
||||
a:layout_width="0dp"
|
||||
a:layout_height="wrap_content"
|
||||
a:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
36
android-app-core/res/values/arrays.xml
Normal file
36
android-app-core/res/values/arrays.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!--
|
||||
monochrome,
|
||||
dashed,
|
||||
dotted,
|
||||
dash_dotted;
|
||||
-->
|
||||
<string-array name="cpp_plot_line_style_names">
|
||||
<item>@string/cpp_solid_line_style</item>
|
||||
<item>@string/cpp_dashed_line_style</item>
|
||||
<item>@string/cpp_dotted_line_style</item>
|
||||
<item>@string/cpp_dash_dotted_line_style</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="cpp_plot_line_color_type_names">
|
||||
<item>@string/cpp_monochrome_line_color_type</item>
|
||||
<item>@string/cpp_color_map_line_color_type</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="cpp_plot_line_color_names">
|
||||
<item>@string/p_white_line_color</item>
|
||||
<item>@string/p_grey_line_color</item>
|
||||
<item>@string/p_red_line_color</item>
|
||||
<item>@string/p_blue_line_color</item>
|
||||
<item>@string/p_green_line_color</item>
|
||||
</string-array>
|
||||
<string-array name="cpp_plot_line_color_values">
|
||||
<item>white</item>
|
||||
<item>grey</item>
|
||||
<item>red</item>
|
||||
<item>blue</item>
|
||||
<item>green</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@@ -289,5 +289,13 @@
|
||||
<string name="cpp_prefs_graph_plot_imag_title">Plot imaginary part of function</string>
|
||||
<string name="cpp_prefs_graph_plot_imag_summary">If checked imaginary part of function will be plotted</string>
|
||||
|
||||
<string name="cpp_monochrome_line_color_type">Monochrome</string>
|
||||
<string name="cpp_color_map_line_color_type">Color map</string>
|
||||
|
||||
<string name="cpp_solid_line_style">Solid (-----)</string>
|
||||
<string name="cpp_dashed_line_style">Dashed (- - -)</string>
|
||||
<string name="cpp_dotted_line_style">Dotted (. . .)</string>
|
||||
<string name="cpp_dash_dotted_line_style">Dash dotted (-.-.-)</string>
|
||||
|
||||
|
||||
</resources>
|
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
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.PlotLineColor;
|
||||
import org.solovyev.android.prefs.BooleanPreference;
|
||||
import org.solovyev.android.prefs.IntegerPreference;
|
||||
import org.solovyev.android.prefs.LongPreference;
|
||||
@@ -132,8 +132,8 @@ public final class CalculatorPreferences {
|
||||
|
||||
public static class Graph {
|
||||
public static final Preference<Boolean> interpolate = new BooleanPreference("graph_interpolate", true);
|
||||
public static final Preference<GraphLineColor> lineColorReal = StringPreference.newInstance("graph_line_color_real", GraphLineColor.white, GraphLineColor.class);
|
||||
public static final Preference<GraphLineColor> lineColorImag = StringPreference.newInstance("graph_line_color_imag", GraphLineColor.blue, GraphLineColor.class);
|
||||
public static final Preference<PlotLineColor> lineColorReal = StringPreference.newInstance("graph_line_color_real", PlotLineColor.white, PlotLineColor.class);
|
||||
public static final Preference<PlotLineColor> lineColorImag = StringPreference.newInstance("graph_line_color_imag", PlotLineColor.blue, PlotLineColor.class);
|
||||
public static final Preference<Boolean> plotImag = new BooleanPreference("graph_plot_imag", false);
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import jscl.math.Generic;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
||||
|
||||
import java.util.List;
|
||||
@@ -53,7 +54,7 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef) {
|
||||
public boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef) {
|
||||
return plotter.addFunction(xyFunction, functionLineDef);
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef) {
|
||||
public boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef) {
|
||||
return plotter.updateFunction(xyFunction, functionLineDef);
|
||||
}
|
||||
|
||||
@@ -106,7 +107,13 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
plotter.clearAllFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@Override
|
||||
public PlotFunction getFunctionById(@NotNull String functionId) {
|
||||
return plotter.getFunctionById(functionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PlotFunction> getFunctions() {
|
||||
return plotter.getFunctions();
|
||||
@@ -168,11 +175,11 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
}
|
||||
}
|
||||
|
||||
public void setImagLineColor(@NotNull GraphLineColor imagLineColor) {
|
||||
public void setImagLineColor(@NotNull PlotLineColor imagLineColor) {
|
||||
plotter.setImagLineColor(imagLineColor);
|
||||
}
|
||||
|
||||
public void setRealLineColor(@NotNull GraphLineColor realLineColor) {
|
||||
public void setRealLineColor(@NotNull PlotLineColor realLineColor) {
|
||||
plotter.setRealLineColor(realLineColor);
|
||||
}
|
||||
}
|
||||
|
@@ -1,119 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.Locator;
|
||||
import org.solovyev.android.calculator.core.R;
|
||||
import org.solovyev.android.list.ListItem;
|
||||
import org.solovyev.android.view.ViewBuilder;
|
||||
import org.solovyev.android.view.ViewFromLayoutBuilder;
|
||||
|
||||
public class PlotFunctionListItem implements ListItem {
|
||||
|
||||
private static final String PREFIX = "plot_function_";
|
||||
|
||||
@NotNull
|
||||
private PlotFunction plotFunction;
|
||||
|
||||
@NotNull
|
||||
private ViewBuilder<View> viewBuilder;
|
||||
|
||||
@NotNull
|
||||
private String tag;
|
||||
|
||||
public PlotFunctionListItem(@NotNull PlotFunction plotFunction) {
|
||||
this.plotFunction = plotFunction;
|
||||
this.viewBuilder = ViewFromLayoutBuilder.newInstance(R.layout.cpp_plot_function_list_item);
|
||||
this.tag = PREFIX + plotFunction.getXyFunction().getExpressionString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OnClickAction getOnClickAction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OnClickAction getOnLongClickAction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public View updateView(@NotNull Context context, @NotNull View view) {
|
||||
final Object viewTag = view.getTag();
|
||||
if ( viewTag instanceof String ) {
|
||||
if ( this.tag.equals(viewTag) ) {
|
||||
return view;
|
||||
} else if (((String) viewTag).startsWith(PREFIX)) {
|
||||
fillView(view);
|
||||
return view;
|
||||
} else {
|
||||
return build(context);
|
||||
}
|
||||
}
|
||||
|
||||
return build(context);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public View build(@NotNull Context context) {
|
||||
final View root = buildView(context);
|
||||
fillView(root);
|
||||
return root;
|
||||
}
|
||||
|
||||
private View buildView(@NotNull Context context) {
|
||||
return viewBuilder.build(context);
|
||||
}
|
||||
|
||||
private void fillView(@NotNull View root) {
|
||||
root.setTag(tag);
|
||||
|
||||
final CalculatorPlotter plotter = Locator.getInstance().getPlotter();
|
||||
|
||||
final TextView expressionTextView = (TextView) root.findViewById(R.id.cpp_plot_function_expression_textview);
|
||||
expressionTextView.setText(plotFunction.getXyFunction().getExpressionString());
|
||||
|
||||
final CheckBox pinnedCheckBox = (CheckBox) root.findViewById(R.id.cpp_plot_function_pinned_checkbox);
|
||||
pinnedCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean pin) {
|
||||
if (pin) {
|
||||
if (!plotFunction.isPinned()) {
|
||||
plotFunction = plotter.pin(plotFunction);
|
||||
}
|
||||
} else {
|
||||
if (plotFunction.isPinned()) {
|
||||
plotFunction = plotter.unpin(plotFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
pinnedCheckBox.setChecked(plotFunction.isPinned());
|
||||
|
||||
final CheckBox visibleCheckBox = (CheckBox) root.findViewById(R.id.cpp_plot_function_visible_checkbox);
|
||||
visibleCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean show) {
|
||||
if (show) {
|
||||
if (!plotFunction.isVisible()) {
|
||||
plotFunction = plotter.show(plotFunction);
|
||||
}
|
||||
} else {
|
||||
if (plotFunction.isVisible()) {
|
||||
plotFunction = plotter.hide(plotFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
visibleCheckBox.setChecked(plotFunction.isVisible());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user