diff --git a/android-app-core/res/values/arrays.xml b/android-app-core/res/values/arrays.xml
new file mode 100644
index 00000000..9e386e2c
--- /dev/null
+++ b/android-app-core/res/values/arrays.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ - @string/cpp_solid_line_style
+ - @string/cpp_dashed_line_style
+ - @string/cpp_dotted_line_style
+ - @string/cpp_dash_dotted_line_style
+
+
+
+ - @string/cpp_monochrome_line_color_type
+ - @string/cpp_color_map_line_color_type
+
+
+
+ - @string/p_white_line_color
+ - @string/p_grey_line_color
+ - @string/p_red_line_color
+ - @string/p_blue_line_color
+ - @string/p_green_line_color
+
+
+ - white
+ - grey
+ - red
+ - blue
+ - green
+
+
+
\ No newline at end of file
diff --git a/android-app-core/res/values/text_strings.xml b/android-app-core/res/values/text_strings.xml
index 4865d4cb..fe48e74f 100644
--- a/android-app-core/res/values/text_strings.xml
+++ b/android-app-core/res/values/text_strings.xml
@@ -289,5 +289,13 @@
Plot imaginary part of function
If checked imaginary part of function will be plotted
+ Monochrome
+ Color map
+
+ Solid (-----)
+ Dashed (- - -)
+ Dotted (. . .)
+ Dash dotted (-.-.-)
+
\ No newline at end of file
diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java
index 0aee0bcf..11d6da38 100644
--- a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java
+++ b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorPreferences.java
@@ -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 interpolate = new BooleanPreference("graph_interpolate", true);
- public static final Preference lineColorReal = StringPreference.newInstance("graph_line_color_real", GraphLineColor.white, GraphLineColor.class);
- public static final Preference lineColorImag = StringPreference.newInstance("graph_line_color_imag", GraphLineColor.blue, GraphLineColor.class);
+ public static final Preference lineColorReal = StringPreference.newInstance("graph_line_color_real", PlotLineColor.white, PlotLineColor.class);
+ public static final Preference lineColorImag = StringPreference.newInstance("graph_line_color_imag", PlotLineColor.blue, PlotLineColor.class);
public static final Preference plotImag = new BooleanPreference("graph_plot_imag", false);
}
diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/plot/AndroidCalculatorPlotter.java b/android-app-core/src/main/java/org/solovyev/android/calculator/plot/AndroidCalculatorPlotter.java
index f19e9b49..fcfe0842 100644
--- a/android-app-core/src/main/java/org/solovyev/android/calculator/plot/AndroidCalculatorPlotter.java
+++ b/android-app-core/src/main/java/org/solovyev/android/calculator/plot/AndroidCalculatorPlotter.java
@@ -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 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);
}
}
diff --git a/android-app/AndroidManifest.xml b/android-app/AndroidManifest.xml
index 08d16d36..4b1d1037 100644
--- a/android-app/AndroidManifest.xml
+++ b/android-app/AndroidManifest.xml
@@ -53,6 +53,7 @@
+
diff --git a/android-app/project.properties b/android-app/project.properties
index 542cf64d..1b8a55be 100644
--- a/android-app/project.properties
+++ b/android-app/project.properties
@@ -12,19 +12,19 @@ target=android-15
android.library.reference.1=../android-app-core
android.library.reference.2=../android-app-widget
android.library.reference.3=../android-app-onscreen
-android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-all_1.0.6
-android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.6
-android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.6
-android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.6
-android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.6
-android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-http_1.0.6
-android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.6
-android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.6
-android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.6
-android.library.reference.13=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.6
-android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.6
-android.library.reference.15=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.6
-android.library.reference.16=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
-android.library.reference.17=gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.6
+android.library.reference.4=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-all_1.0.6
+android.library.reference.5=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.6
+android.library.reference.6=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-core_1.0.6
+android.library.reference.7=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.6
+android.library.reference.8=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-db_1.0.6
+android.library.reference.9=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-http_1.0.6
+android.library.reference.10=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-list_1.0.6
+android.library.reference.11=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-view_1.0.6
+android.library.reference.12=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.6
+android.library.reference.13=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.6
+android.library.reference.14=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-other_1.0.6
+android.library.reference.15=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.6
+android.library.reference.16=../android-app-core/gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
+android.library.reference.17=../android-app-core/gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.6
diff --git a/android-app/res/layout/plot_fragment.xml b/android-app/res/layout/cpp_plot_fragment.xml
similarity index 100%
rename from android-app/res/layout/plot_fragment.xml
rename to android-app/res/layout/cpp_plot_fragment.xml
diff --git a/android-app-core/res/layout/cpp_plot_function_list_item.xml b/android-app/res/layout/cpp_plot_function_list_item.xml
similarity index 74%
rename from android-app-core/res/layout/cpp_plot_function_list_item.xml
rename to android-app/res/layout/cpp_plot_function_list_item.xml
index 8c594072..ac16cb80 100644
--- a/android-app-core/res/layout/cpp_plot_function_list_item.xml
+++ b/android-app/res/layout/cpp_plot_function_list_item.xml
@@ -9,7 +9,7 @@
a:id="@+id/cpp_plot_function_expression_textview"
a:layout_width="0dp"
a:layout_height="wrap_content"
- a:layout_weight="5"/>
+ a:layout_weight="3"/>
+
+
\ No newline at end of file
diff --git a/android-app/res/layout/cpp_plot_function_settings_dialog.xml b/android-app/res/layout/cpp_plot_function_settings_dialog.xml
new file mode 100644
index 00000000..742f0b5c
--- /dev/null
+++ b/android-app/res/layout/cpp_plot_function_settings_dialog.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/android-app/res/layout/cpp_plot_function_settings_fragment.xml b/android-app/res/layout/cpp_plot_function_settings_fragment.xml
new file mode 100644
index 00000000..3c7dcf38
--- /dev/null
+++ b/android-app/res/layout/cpp_plot_function_settings_fragment.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android-app/res/layout/plot_functions_fragment.xml b/android-app/res/layout/cpp_plot_functions_fragment.xml
similarity index 82%
rename from android-app/res/layout/plot_functions_fragment.xml
rename to android-app/res/layout/cpp_plot_functions_fragment.xml
index 951516a4..1a93d806 100644
--- a/android-app/res/layout/plot_functions_fragment.xml
+++ b/android-app/res/layout/cpp_plot_functions_fragment.xml
@@ -6,12 +6,6 @@
a:layout_width="match_parent"
a:layout_height="match_parent">
-
-
+
diff --git a/android-app/res/values/arrays.xml b/android-app/res/values/arrays.xml
index c0361620..63f8345c 100644
--- a/android-app/res/values/arrays.xml
+++ b/android-app/res/values/arrays.xml
@@ -87,19 +87,4 @@
- bin
-
- - @string/p_white_line_color
- - @string/p_grey_line_color
- - @string/p_red_line_color
- - @string/p_blue_line_color
- - @string/p_green_line_color
-
-
- - white
- - grey
- - red
- - blue
- - green
-
-
\ No newline at end of file
diff --git a/android-app/res/xml/preferences_plot.xml b/android-app/res/xml/preferences_plot.xml
index 81808993..345e31de 100644
--- a/android-app/res/xml/preferences_plot.xml
+++ b/android-app/res/xml/preferences_plot.xml
@@ -19,14 +19,14 @@
+ a:entries="@array/cpp_plot_line_color_names"
+ a:entryValues="@array/cpp_plot_line_color_values"/>
+ a:entries="@array/cpp_plot_line_color_names"
+ a:entryValues="@array/cpp_plot_line_color_values"/>
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
index 1aa1cfcd..4e262f7e 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
@@ -23,7 +23,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.plot.CalculatorPlotActivity;
import org.solovyev.android.fragments.FragmentUtils;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelper.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelper.java
index 0cbc2187..e1fd8090 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelper.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelper.java
@@ -7,7 +7,6 @@ import android.view.View;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java
index c79d319b..b9015a17 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorActivityHelperImpl.java
@@ -19,7 +19,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.AndroidUtils;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.sherlock.tabs.ActionBarFragmentTabListener;
/**
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java
index a3a53bd1..f3af186b 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragment.java
@@ -7,7 +7,6 @@ import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
import org.jetbrains.annotations.NotNull;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: Solovyev_S
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorFragmentType.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragmentType.java
similarity index 81%
rename from android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorFragmentType.java
rename to android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragmentType.java
index ac0b70ad..3997624f 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorFragmentType.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorFragmentType.java
@@ -1,9 +1,9 @@
-package org.solovyev.android.calculator.about;
+package org.solovyev.android.calculator;
import android.support.v4.app.Fragment;
import org.jetbrains.annotations.NotNull;
-import org.solovyev.android.calculator.CalculatorEditorFragment;
-import org.solovyev.android.calculator.R;
+import org.solovyev.android.calculator.about.CalculatorAboutFragment;
+import org.solovyev.android.calculator.about.CalculatorReleaseNotesFragment;
import org.solovyev.android.calculator.help.CalculatorHelpFaqFragment;
import org.solovyev.android.calculator.help.CalculatorHelpHintsFragment;
import org.solovyev.android.calculator.help.CalculatorHelpScreensFragment;
@@ -14,7 +14,8 @@ import org.solovyev.android.calculator.math.edit.CalculatorOperatorsFragment;
import org.solovyev.android.calculator.math.edit.CalculatorVarsFragment;
import org.solovyev.android.calculator.matrix.CalculatorMatrixEditFragment;
import org.solovyev.android.calculator.plot.CalculatorArityPlotFragment;
-import org.solovyev.android.calculator.plot.CalculatorPlotFunctionsFragment;
+import org.solovyev.android.calculator.plot.CalculatorPlotFunctionSettingsActivity;
+import org.solovyev.android.calculator.plot.CalculatorPlotFunctionsActivity;
/**
* User: Solovyev_S
@@ -31,10 +32,12 @@ public enum CalculatorFragmentType {
variables(CalculatorVarsFragment.class, R.layout.vars_fragment, R.string.c_vars),
functions(CalculatorFunctionsFragment.class, R.layout.math_entities_fragment, R.string.c_functions),
operators(CalculatorOperatorsFragment.class, R.layout.math_entities_fragment, R.string.c_operators),
- plotter(CalculatorArityPlotFragment.class, R.layout.plot_fragment, R.string.c_graph),
+ plotter(CalculatorArityPlotFragment.class, R.layout.cpp_plot_fragment, R.string.c_graph),
// todo serso: strings
- plotter_functions(CalculatorPlotFunctionsFragment.class, R.layout.plot_functions_fragment, R.string.c_graph),
+ plotter_functions(CalculatorPlotFunctionsActivity.CalculatorPlotFunctionsFragment.class, R.layout.cpp_plot_functions_fragment, R.string.c_graph),
+ plotter_function_settings(CalculatorPlotFunctionSettingsActivity.CalculatorPlotFunctionSettingsFragment.class, R.layout.cpp_plot_function_settings_fragment, R.string.c_graph),
+
about(CalculatorAboutFragment.class, R.layout.about_fragment, R.string.c_about),
faq(CalculatorHelpFaqFragment.class, R.layout.help_faq_fragment, R.string.c_faq),
hints(CalculatorHelpHintsFragment.class, R.layout.help_hints_fragment, R.string.c_hints),
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorListFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorListFragment.java
index e5a0bfa5..c9bba456 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorListFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorListFragment.java
@@ -7,7 +7,6 @@ import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockListFragment;
import org.jetbrains.annotations.NotNull;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: Solovyev_S
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutActivity.java
index 6f9d2c66..735cb517 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutActivity.java
@@ -8,6 +8,7 @@ package org.solovyev.android.calculator.about;
import android.os.Bundle;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.CalculatorFragmentActivity;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
/**
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutFragment.java
index 1968eedd..2bba5084 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorAboutFragment.java
@@ -11,6 +11,7 @@ import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.TextView;
import org.solovyev.android.calculator.CalculatorFragment;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
/**
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java
index 24c9b8ad..56754d85 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/about/CalculatorReleaseNotesFragment.java
@@ -16,6 +16,7 @@ import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.calculator.CalculatorApplication;
import org.solovyev.android.calculator.CalculatorFragment;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
import org.solovyev.common.text.StringUtils;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpActivity.java
index 39e65320..974ffff6 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpActivity.java
@@ -9,8 +9,8 @@ package org.solovyev.android.calculator.help;
import android.os.Bundle;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.CalculatorFragmentActivity;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpFaqFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpFaqFragment.java
index 12d39285..ba5a87a8 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpFaqFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpFaqFragment.java
@@ -7,7 +7,7 @@
package org.solovyev.android.calculator.help;
import org.solovyev.android.calculator.CalculatorFragment;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpHintsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpHintsFragment.java
index 5cebfc86..5e130cc2 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpHintsFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpHintsFragment.java
@@ -7,7 +7,7 @@
package org.solovyev.android.calculator.help;
import org.solovyev.android.calculator.CalculatorFragment;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpScreensFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpScreensFragment.java
index d1ebb4de..52e34479 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpScreensFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/help/CalculatorHelpScreensFragment.java
@@ -7,7 +7,7 @@
package org.solovyev.android.calculator.help;
import org.solovyev.android.calculator.CalculatorFragment;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java
index 7bbe516e..49c6ca98 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/history/AbstractCalculatorHistoryFragment.java
@@ -22,7 +22,7 @@ import com.actionbarsherlock.view.MenuItem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.menu.*;
import org.solovyev.android.sherlock.menu.SherlockMenuHelper;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryActivity.java
index 30896450..2ecc4fd5 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryActivity.java
@@ -11,7 +11,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java
index a16aaacd..61b0aeb6 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorHistoryFragment.java
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import java.util.ArrayList;
import java.util.List;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java
index c2d26e00..90a1c4c0 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/history/CalculatorSavedHistoryFragment.java
@@ -7,9 +7,9 @@
package org.solovyev.android.calculator.history;
import org.jetbrains.annotations.NotNull;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
import java.util.ArrayList;
import java.util.List;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java
index 8f9f8576..bc80f59f 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/AbstractMathEntityListFragment.java
@@ -19,7 +19,7 @@ import com.actionbarsherlock.app.SherlockListFragment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.menu.AMenuBuilder;
import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsActivity.java
index 77c55249..3ea2c359 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsActivity.java
@@ -13,7 +13,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
/**
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java
index 68a1d79a..22a1307e 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorFunctionsFragment.java
@@ -20,7 +20,7 @@ import jscl.math.function.IFunction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.function.FunctionEditDialogFragment;
import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsActivity.java
index ec0432d6..ce31edc7 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsActivity.java
@@ -11,7 +11,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
/**
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java
index fd7938d9..d8672c65 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorOperatorsFragment.java
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.CalculatorEventType;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.common.text.StringUtils;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java
index e9e93952..c6f4a569 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsActivity.java
@@ -12,7 +12,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.history.CalculatorHistoryActivity;
import org.solovyev.android.calculator.AndroidVarCategory;
import org.solovyev.android.calculator.VarCategory;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java
index 5ebf84b5..66276187 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/CalculatorVarsFragment.java
@@ -17,7 +17,7 @@ import jscl.math.function.IConstant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.*;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.menu.AMenuItem;
import org.solovyev.android.menu.LabeledMenuItem;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java
index 3ec80741..941a64d8 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixActivity.java
@@ -3,8 +3,8 @@ package org.solovyev.android.calculator.matrix;
import android.app.ActionBar;
import android.os.Bundle;
import org.solovyev.android.calculator.CalculatorFragmentActivity;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: Solovyev_S
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixEditFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixEditFragment.java
index 9f8e3c8e..5ca7f521 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixEditFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/matrix/CalculatorMatrixEditFragment.java
@@ -5,8 +5,8 @@ import android.view.View;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.CalculatorFragment;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
import org.solovyev.android.view.IntegerRange;
import org.solovyev.android.view.Picker;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java
index 9569dad9..592a8e7c 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/AbstractCalculatorPlotFragment.java
@@ -80,7 +80,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
public AbstractCalculatorPlotFragment() {
- super(CalculatorApplication.getInstance().createFragmentHelper(R.layout.plot_fragment, R.string.c_graph, false));
+ super(CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_plot_fragment, R.string.c_graph, false));
}
@@ -119,7 +119,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
plotData = Locator.getInstance().getPlotter().getPlotData();
createChart(plotData);
createGraphicalView(getView(), plotData);
- getActivity().invalidateOptionsMenu();
+ getSherlockActivity().invalidateOptionsMenu();
}
@Override
@@ -138,7 +138,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
getUiHandler().post(new Runnable() {
@Override
public void run() {
- getActivity().invalidateOptionsMenu();
+ getSherlockActivity().invalidateOptionsMenu();
createChart(plotData);
@@ -361,17 +361,17 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
}
}
- public static void applyToPaint(@NotNull PlotFunctionLineDef plotFunctionLineDef, @NotNull Paint paint) {
- paint.setColor(plotFunctionLineDef.getLineColor());
+ public static void applyToPaint(@NotNull PlotLineDef plotLineDef, @NotNull Paint paint) {
+ paint.setColor(plotLineDef.getLineColor());
paint.setStyle(Paint.Style.STROKE);
- if ( plotFunctionLineDef.getLineWidth() == PlotFunctionLineDef.DEFAULT_LINE_WIDTH ) {
+ if ( plotLineDef.getLineWidth() == PlotLineDef.DEFAULT_LINE_WIDTH ) {
paint.setStrokeWidth(0);
} else {
- paint.setStrokeWidth(plotFunctionLineDef.getLineWidth());
+ paint.setStrokeWidth(plotLineDef.getLineWidth());
}
- final AndroidPlotLineStyle androidPlotLineStyle = AndroidPlotLineStyle.valueOf(plotFunctionLineDef.getLineStyle());
+ final AndroidPlotLineStyle androidPlotLineStyle = AndroidPlotLineStyle.valueOf(plotLineDef.getLineStyle());
if (androidPlotLineStyle != null) {
androidPlotLineStyle.applyToPaint(paint);
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/ArityPlotFunction.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/ArityPlotFunction.java
index 2734dff5..ede47c20 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/ArityPlotFunction.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/ArityPlotFunction.java
@@ -14,18 +14,18 @@ public class ArityPlotFunction {
private Function function;
@NotNull
- private PlotFunctionLineDef lineDef;
+ private PlotLineDef lineDef;
private ArityPlotFunction() {
}
@NotNull
public static ArityPlotFunction newInstance(@NotNull Function function) {
- return newInstance(function, PlotFunctionLineDef.newDefaultInstance());
+ return newInstance(function, PlotLineDef.newDefaultInstance());
}
@NotNull
- public static ArityPlotFunction newInstance(@NotNull Function function, @NotNull PlotFunctionLineDef lineDef) {
+ public static ArityPlotFunction newInstance(@NotNull Function function, @NotNull PlotLineDef lineDef) {
final ArityPlotFunction result = new ArityPlotFunction();
result.function = function;
@@ -40,7 +40,7 @@ public class ArityPlotFunction {
}
@NotNull
- public PlotFunctionLineDef getLineDef() {
+ public PlotLineDef getLineDef() {
return lineDef;
}
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorArityPlotFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorArityPlotFragment.java
index 61d27dfb..c664d988 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorArityPlotFragment.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorArityPlotFragment.java
@@ -54,7 +54,7 @@ public class CalculatorArityPlotFragment extends AbstractCalculatorPlotFragment
final Constant xVariable = xyFunction.getXVariable();
final Constant yVariable = xyFunction.getYVariable();
- final int arity = xVariable == null ? 0 : (yVariable == null ? 1 : 2);
+ final int arity = xyFunction.getArity();
final Function arityFunction;
if (xyFunction.isImag()) {
@@ -63,7 +63,7 @@ public class CalculatorArityPlotFragment extends AbstractCalculatorPlotFragment
arityFunction = new RealArityFunction(arity, expression, xVariable, yVariable);
}
- arityFunctions.add(ArityPlotFunction.newInstance(arityFunction, plotFunction.getPlotFunctionLineDef()));
+ arityFunctions.add(ArityPlotFunction.newInstance(arityFunction, plotFunction.getPlotLineDef()));
}
if ( plotData.isPlot3d() ) {
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotActivity.java
index cc638b55..3a50b081 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotActivity.java
@@ -6,8 +6,8 @@ import android.os.Bundle;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.android.calculator.CalculatorFragmentActivity;
+import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
/**
* User: serso
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionSettingsActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionSettingsActivity.java
new file mode 100644
index 00000000..dfbdeee3
--- /dev/null
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionSettingsActivity.java
@@ -0,0 +1,166 @@
+package org.solovyev.android.calculator.plot;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.Button;
+import android.widget.Spinner;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.solovyev.android.calculator.CalculatorFragment;
+import org.solovyev.android.calculator.CalculatorFragmentType;
+import org.solovyev.android.calculator.Locator;
+import org.solovyev.android.calculator.R;
+import org.solovyev.android.fragments.FragmentUtils;
+
+public class CalculatorPlotFunctionSettingsActivity extends SherlockFragmentActivity {
+
+ private static final String INPUT_FUNCTION_ID = "plot-function-id";
+
+ public static void startActivity(@NotNull Context context, @NotNull PlotFunction plotFunction) {
+ final Intent intent = new Intent(context, CalculatorPlotFunctionSettingsActivity.class);
+ intent.putExtra(INPUT_FUNCTION_ID, plotFunction.getXyFunction().getId());
+ context.startActivity(intent);
+
+ }
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.cpp_plot_function_settings_dialog);
+
+ final Intent intent = getIntent();
+
+ if (intent != null) {
+ final String plotFunctionId = intent.getStringExtra(INPUT_FUNCTION_ID);
+
+ if (plotFunctionId != null) {
+ final Bundle parameters = new Bundle();
+ parameters.putString(INPUT_FUNCTION_ID, plotFunctionId);
+ FragmentUtils.createFragment(this, CalculatorPlotFunctionSettingsFragment.class, R.id.dialog_layout, "plot-function-settings", parameters);
+ } else {
+ finish();
+ }
+ } else {
+ finish();
+ }
+ }
+
+ public static class CalculatorPlotFunctionSettingsFragment extends CalculatorFragment {
+
+ @Nullable
+ private PlotFunction plotFunction;
+
+ public CalculatorPlotFunctionSettingsFragment() {
+ super(CalculatorFragmentType.plotter_function_settings);
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final String functionId = getArguments().getString(INPUT_FUNCTION_ID);
+ if (functionId != null) {
+ plotFunction = Locator.getInstance().getPlotter().getFunctionById(functionId);
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return super.onCreateView(inflater, container, savedInstanceState);
+ }
+
+ @Override
+ public void onViewCreated(View root, Bundle savedInstanceState) {
+ super.onViewCreated(root, savedInstanceState);
+
+ final CalculatorPlotter plotter = Locator.getInstance().getPlotter();
+
+ final Spinner plotLineColorSpinner = (Spinner)root.findViewById(R.id.cpp_plot_function_line_color_spinner);
+ final Spinner plotLineColorTypeSpinner = (Spinner)root.findViewById(R.id.cpp_plot_function_line_color_type_spinner);
+ final Spinner plotLineStyleSpinner = (Spinner)root.findViewById(R.id.cpp_plot_function_line_style_spinner);
+ final Button okButton = (Button)root.findViewById(R.id.cpp_ok_button);
+
+ if (plotFunction != null) {
+
+ plotLineColorSpinner.setSelection(PlotLineColor.valueOf(plotFunction.getPlotLineDef().getLineColor()).ordinal());
+ plotLineColorSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ final PlotLineColor newPlotLineColor = PlotLineColor.values()[position];
+ int newLineColor = newPlotLineColor.getColor();
+ if ( newLineColor != plotFunction.getPlotLineDef().getLineColor() ) {
+ final PlotFunction newPlotFunction = new PlotFunction(plotFunction.getXyFunction(), PlotLineDef.changeLineColor(plotFunction.getPlotLineDef(), newLineColor));
+ if(plotter.updateFunction(newPlotFunction)) {
+ plotFunction = newPlotFunction;
+ }
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ }
+ });
+
+ plotLineColorTypeSpinner.setSelection(plotFunction.getPlotLineDef().getLineColorType().ordinal());
+ plotLineColorTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ final PlotLineColorType newPlotLineColorType = PlotLineColorType.values()[position];
+ if ( newPlotLineColorType != plotFunction.getPlotLineDef().getLineColorType() ) {
+ final PlotFunction newPlotFunction = new PlotFunction(plotFunction.getXyFunction(), PlotLineDef.changeLineColorType(plotFunction.getPlotLineDef(), newPlotLineColorType));
+ if(plotter.updateFunction(newPlotFunction)) {
+ plotFunction = newPlotFunction;
+ }
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ }
+ });
+
+ plotLineStyleSpinner.setSelection(plotFunction.getPlotLineDef().getLineStyle().ordinal());
+ plotLineStyleSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ final PlotLineStyle newPlotLineStyle = PlotLineStyle.values()[position];
+ if ( newPlotLineStyle != plotFunction.getPlotLineDef().getLineStyle() ) {
+ final PlotFunction newPlotFunction = new PlotFunction(plotFunction.getXyFunction(), PlotLineDef.changeLineStyle(plotFunction.getPlotLineDef(), newPlotLineStyle));
+ if(plotter.updateFunction(newPlotFunction)) {
+ plotFunction = newPlotFunction;
+ }
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ }
+ });
+
+ okButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final Activity activity = getActivity();
+ if ( activity != null ) {
+ activity.finish();
+ }
+ }
+ });
+
+ } else {
+ plotLineColorSpinner.setEnabled(false);
+ plotLineColorTypeSpinner.setEnabled(false);
+ plotLineStyleSpinner.setEnabled(false);
+ okButton.setEnabled(false);
+ }
+ }
+ }
+}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java
index e52b431c..47fb05a3 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsActivity.java
@@ -2,9 +2,18 @@ package org.solovyev.android.calculator.plot;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.solovyev.android.calculator.CalculatorFragmentType;
+import org.solovyev.android.calculator.CalculatorListFragment;
+import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
import org.solovyev.android.fragments.FragmentUtils;
+import org.solovyev.android.list.ListItemArrayAdapter;
+
+import java.util.List;
/**
* User: serso
@@ -21,4 +30,29 @@ public class CalculatorPlotFunctionsActivity extends SherlockFragmentActivity {
FragmentUtils.createFragment(this, CalculatorPlotFunctionsFragment.class, R.id.dialog_layout, "plot-functions");
}
+
+ public static class CalculatorPlotFunctionsFragment extends CalculatorListFragment {
+
+ @NotNull
+ public static final String INPUT = "plot_input";
+
+ public CalculatorPlotFunctionsFragment() {
+ super(CalculatorFragmentType.plotter_functions);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ final List items = Lists.transform(Locator.getInstance().getPlotter().getFunctions(), new Function() {
+ @Override
+ public PlotFunctionListItem apply(@javax.annotation.Nullable PlotFunction input) {
+ assert input != null;
+ return new PlotFunctionListItem(input);
+ }
+ });
+
+ ListItemArrayAdapter.createAndAttach(getListView(), this.getActivity(), items);
+ }
+ }
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsFragment.java
deleted file mode 100644
index aebd3e43..00000000
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotFunctionsFragment.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.solovyev.android.calculator.plot;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-import org.jetbrains.annotations.NotNull;
-import org.solovyev.android.calculator.CalculatorListFragment;
-import org.solovyev.android.calculator.Locator;
-import org.solovyev.android.calculator.about.CalculatorFragmentType;
-import org.solovyev.android.list.ListItemArrayAdapter;
-
-import javax.annotation.Nullable;
-import java.util.List;
-
-public class CalculatorPlotFunctionsFragment extends CalculatorListFragment {
-
- @NotNull
- public static final String INPUT = "plot_input";
-
- public CalculatorPlotFunctionsFragment() {
- super(CalculatorFragmentType.plotter_functions);
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- final List items = Lists.transform(Locator.getInstance().getPlotter().getFunctions(), new Function() {
- @Override
- public PlotFunctionListItem apply(@Nullable PlotFunction input) {
- assert input != null;
- return new PlotFunctionListItem(input);
- }
- });
-
- ListItemArrayAdapter.createAndAttach(getListView(), this.getActivity(), items);
- }
-}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/plot/Graph3d.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/Graph3d.java
index 114c90f4..1de16160 100755
--- a/android-app/src/main/java/org/solovyev/android/calculator/plot/Graph3d.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/Graph3d.java
@@ -94,7 +94,7 @@ class Graph3d {
public void update(@NotNull GL11 gl, @NotNull ArityPlotFunction fpd, float zoom) {
final Function function = fpd.getFunction();
- final PlotFunctionLineDef lineDef = fpd.getLineDef();
+ final PlotLineDef lineDef = fpd.getLineDef();
final int NTICK = useHighQuality3d ? 5 : 0;
final float size = 4 * zoom;
@@ -285,7 +285,7 @@ class Graph3d {
return maxAbsZ;
}
- private byte[] prepareFunctionPolygonColors(PlotFunctionLineDef lineDef, float[] vertices, float maxAbsZ) {
+ private byte[] prepareFunctionPolygonColors(PlotLineDef lineDef, float[] vertices, float maxAbsZ) {
// 4 color components per polygon (color[i] = red, color[i+1] = green, color[i+2] = blue, color[i+3] = alpha )
final byte colors[] = new byte[polygonsⁿ * COLOR_COMPONENTS_COUNT];
@@ -295,7 +295,7 @@ class Graph3d {
final float z = vertices[j];
if (!Float.isNaN(z)) {
- if (lineDef.getLineColorType() == PlotFunctionLineColorType.color_map) {
+ if (lineDef.getLineColorType() == PlotLineColorType.color_map) {
final float color = z / maxAbsZ;
final float abs = Math.abs(color);
colors[i] = floatToByte(color);
diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionListItem.java b/android-app/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionListItem.java
similarity index 85%
rename from android-app-core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionListItem.java
rename to android-app/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionListItem.java
index 49282194..7526b60a 100644
--- a/android-app-core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionListItem.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionListItem.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
+import android.widget.ImageButton;
import android.widget.TextView;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -52,7 +53,7 @@ public class PlotFunctionListItem implements ListItem {
if ( this.tag.equals(viewTag) ) {
return view;
} else if (((String) viewTag).startsWith(PREFIX)) {
- fillView(view);
+ fillView(view, context);
return view;
} else {
return build(context);
@@ -66,7 +67,7 @@ public class PlotFunctionListItem implements ListItem {
@Override
public View build(@NotNull Context context) {
final View root = buildView(context);
- fillView(root);
+ fillView(root, context);
return root;
}
@@ -74,7 +75,7 @@ public class PlotFunctionListItem implements ListItem {
return viewBuilder.build(context);
}
- private void fillView(@NotNull View root) {
+ private void fillView(@NotNull View root, @NotNull final Context context) {
root.setTag(tag);
final CalculatorPlotter plotter = Locator.getInstance().getPlotter();
@@ -115,5 +116,13 @@ public class PlotFunctionListItem implements ListItem {
}
});
visibleCheckBox.setChecked(plotFunction.isVisible());
+
+ final ImageButton settingsButton = (ImageButton) root.findViewById(R.id.cpp_plot_function_settings_button);
+ settingsButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ CalculatorPlotFunctionSettingsActivity.startActivity(context, plotFunction);
+ }
+ });
}
}
diff --git a/android-app/src/main/java/org/solovyev/android/fragments/FragmentUtils.java b/android-app/src/main/java/org/solovyev/android/fragments/FragmentUtils.java
index e3d56482..f1e44288 100644
--- a/android-app/src/main/java/org/solovyev/android/fragments/FragmentUtils.java
+++ b/android-app/src/main/java/org/solovyev/android/fragments/FragmentUtils.java
@@ -1,14 +1,15 @@
package org.solovyev.android.fragments;
+import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.solovyev.common.collections.CollectionsUtils;
-import java.util.Collections;
import java.util.List;
/**
@@ -18,10 +19,18 @@ import java.util.List;
*/
public class FragmentUtils {
+ public static void createFragment(@NotNull FragmentActivity activity,
+ @NotNull Class extends Fragment> fragmentClass,
+ int parentViewId,
+ @NotNull String tag) {
+ createFragment(activity, fragmentClass, parentViewId, tag, null);
+ }
+
public static void createFragment(@NotNull FragmentActivity activity,
- @NotNull Class extends Fragment> fragmentClass,
- int parentViewId,
- @NotNull String tag) {
+ @NotNull Class extends Fragment> fragmentClass,
+ int parentViewId,
+ @NotNull String tag,
+ @Nullable Bundle args) {
final FragmentManager fm = activity.getSupportFragmentManager();
Fragment messagesFragment = fm.findFragmentByTag(tag);
@@ -29,7 +38,7 @@ public class FragmentUtils {
final FragmentTransaction ft = fm.beginTransaction();
try {
if (messagesFragment == null) {
- messagesFragment = Fragment.instantiate(activity, fragmentClass.getName(), null);
+ messagesFragment = Fragment.instantiate(activity, fragmentClass.getName(), args);
ft.add(parentViewId, messagesFragment, tag);
} else {
if (messagesFragment.isDetached()) {
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotter.java b/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotter.java
index 6ac7bdf1..c6c593d4 100644
--- a/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotter.java
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/CalculatorPlotter.java
@@ -2,6 +2,7 @@ package org.solovyev.android.calculator.plot;
import jscl.math.Generic;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
@@ -18,10 +19,10 @@ public interface CalculatorPlotter {
boolean addFunction(@NotNull Generic expression);
boolean addFunction(@NotNull PlotFunction plotFunction);
boolean addFunction(@NotNull XyFunction xyFunction);
- boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef);
+ boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef);
boolean updateFunction(@NotNull PlotFunction newFunction);
- boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef);
+ boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef);
boolean removeFunction(@NotNull PlotFunction plotFunction);
boolean removeFunction(@NotNull XyFunction xyFunction);
@@ -40,6 +41,9 @@ public interface CalculatorPlotter {
void clearAllFunctions();
+ @Nullable
+ PlotFunction getFunctionById(@NotNull String functionId);
+
@NotNull
List getFunctions();
@@ -59,7 +63,7 @@ public interface CalculatorPlotter {
void setPlotImag(boolean plotImag);
- void setRealLineColor(@NotNull GraphLineColor realLineColor);
+ void setRealLineColor(@NotNull PlotLineColor realLineColor);
- void setImagLineColor(@NotNull GraphLineColor imagLineColor);
+ void setImagLineColor(@NotNull PlotLineColor imagLineColor);
}
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 19478641..8abb77be 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
@@ -36,10 +36,10 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
private int arity = 0;
@NotNull
- private GraphLineColor realLineColor;
+ private PlotLineColor realLineColor;
@NotNull
- private GraphLineColor imagLineColor;
+ private PlotLineColor imagLineColor;
public CalculatorPlotterImpl(@NotNull Calculator calculator) {
this.calculator = calculator;
@@ -164,12 +164,12 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
}
@Override
- public boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef) {
+ public boolean addFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef) {
return addFunction(new PlotFunction(xyFunction, functionLineDef));
}
@Override
- public boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotFunctionLineDef functionLineDef) {
+ public boolean updateFunction(@NotNull XyFunction xyFunction, @NotNull PlotLineDef functionLineDef) {
final PlotFunction newFunction = new PlotFunction(xyFunction, functionLineDef);
return updateFunction(newFunction);
@@ -251,7 +251,20 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
}
}
- // NOTE: this method must be called from synchronized block
+ @org.jetbrains.annotations.Nullable
+ @Override
+ public PlotFunction getFunctionById(@NotNull final String functionId) {
+ synchronized (functions) {
+ return Iterables.find(functions, new Predicate() {
+ @Override
+ public boolean apply(@Nullable PlotFunction function) {
+ return function != null && function.getXyFunction().getId().equals(functionId);
+ }
+ }, null);
+ }
+ }
+
+ // NOTE: this method must be called from synchronized block
private void onFunctionsChanged() {
assert Thread.holdsLock(functions);
@@ -345,12 +358,12 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
}
@Override
- public void setRealLineColor(@NotNull GraphLineColor realLineColor) {
+ public void setRealLineColor(@NotNull PlotLineColor realLineColor) {
this.realLineColor = realLineColor;
}
@Override
- public void setImagLineColor(@NotNull GraphLineColor imagLineColor) {
+ public void setImagLineColor(@NotNull PlotLineColor imagLineColor) {
this.imagLineColor = imagLineColor;
}
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunction.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunction.java
index 5f7d755d..25fab115 100644
--- a/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunction.java
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunction.java
@@ -13,7 +13,7 @@ public class PlotFunction {
private XyFunction xyFunction;
@NotNull
- private PlotFunctionLineDef plotFunctionLineDef;
+ private PlotLineDef mPlotLineDef;
private boolean pinned = false;
@@ -21,20 +21,20 @@ public class PlotFunction {
public PlotFunction(@NotNull XyFunction xyFunction) {
this.xyFunction = xyFunction;
- this.plotFunctionLineDef = PlotFunctionLineDef.newDefaultInstance();
+ this.mPlotLineDef = PlotLineDef.newDefaultInstance();
}
public PlotFunction(@NotNull XyFunction xyFunction,
- @NotNull PlotFunctionLineDef plotFunctionLineDef) {
+ @NotNull PlotLineDef plotLineDef) {
this.xyFunction = xyFunction;
- this.plotFunctionLineDef = plotFunctionLineDef;
+ this.mPlotLineDef = plotLineDef;
}
@NotNull
private PlotFunction copy() {
final PlotFunction copy = new PlotFunction(this.xyFunction);
- copy.plotFunctionLineDef = this.plotFunctionLineDef;
+ copy.mPlotLineDef = this.mPlotLineDef;
copy.pinned = this.pinned;
copy.visible = this.visible;
@@ -80,8 +80,8 @@ public class PlotFunction {
}
@NotNull
- public PlotFunctionLineDef getPlotFunctionLineDef() {
- return plotFunctionLineDef;
+ public PlotLineDef getPlotLineDef() {
+ return mPlotLineDef;
}
public boolean isPinned() {
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionLineDef.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionLineDef.java
deleted file mode 100644
index 93016d86..00000000
--- a/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionLineDef.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.solovyev.android.calculator.plot;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * User: serso
- * Date: 1/5/13
- * Time: 7:41 PM
- */
-public class PlotFunctionLineDef {
-
- /*
- **********************************************************************
- *
- * CONSTANTS
- *
- **********************************************************************
- */
-
- @NotNull
- public static final Float DEFAULT_LINE_WIDTH = -1f;
-
- private static final int WHITE = 0xFFFFFFFF;
-
-
- /*
- **********************************************************************
- *
- * FIELDS
- *
- **********************************************************************
- */
-
- @NotNull
- private PlotFunctionLineColorType lineColorType = PlotFunctionLineColorType.solid;
-
- private int lineColor = WHITE;
-
- @NotNull
- private PlotLineStyle lineStyle = PlotLineStyle.solid;
-
- private float lineWidth = -DEFAULT_LINE_WIDTH;
-
- private PlotFunctionLineDef() {
- }
-
- @NotNull
- public static PlotFunctionLineDef newInstance(int lineColor, @NotNull PlotLineStyle lineStyle) {
- final PlotFunctionLineDef result = new PlotFunctionLineDef();
- result.lineColor = lineColor;
- result.lineStyle = lineStyle;
- return result;
- }
-
- @NotNull
- public static PlotFunctionLineDef newInstance(int lineColor, @NotNull PlotLineStyle lineStyle, float lineWidth) {
- final PlotFunctionLineDef result = new PlotFunctionLineDef();
- result.lineColor = lineColor;
- result.lineStyle = lineStyle;
- result.lineWidth = lineWidth;
- return result;
- }
-
- @NotNull
- public static PlotFunctionLineDef newInstance(int lineColor, @NotNull PlotLineStyle lineStyle, float lineWidth, @NotNull PlotFunctionLineColorType lineColorType) {
- final PlotFunctionLineDef result = new PlotFunctionLineDef();
- result.lineColor = lineColor;
- result.lineColorType = lineColorType;
- result.lineStyle = lineStyle;
- result.lineWidth = lineWidth;
- return result;
- }
-
- @NotNull
- public static PlotFunctionLineDef newDefaultInstance() {
- return new PlotFunctionLineDef();
- }
-
- public int getLineColor() {
- return lineColor;
- }
-
- @NotNull
- public PlotLineStyle getLineStyle() {
- return lineStyle;
- }
-
- public float getLineWidth() {
- return lineWidth;
- }
-
- @NotNull
- public PlotFunctionLineColorType getLineColorType() {
- return lineColorType;
- }
-}
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/GraphLineColor.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java
similarity index 55%
rename from core/src/main/java/org/solovyev/android/calculator/plot/GraphLineColor.java
rename to core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java
index 90f8fa22..8b9e614c 100644
--- a/core/src/main/java/org/solovyev/android/calculator/plot/GraphLineColor.java
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColor.java
@@ -1,11 +1,13 @@
package org.solovyev.android.calculator.plot;
+import org.jetbrains.annotations.NotNull;
+
/**
* User: serso
* Date: 10/4/12
* Time: 10:08 PM
*/
-public enum GraphLineColor {
+public enum PlotLineColor {
// Color.WHITE
white(0xFFFFFFFF),
@@ -23,7 +25,7 @@ public enum GraphLineColor {
private final int color;
- private GraphLineColor(int color) {
+ private PlotLineColor(int color) {
this.color = color;
}
@@ -31,4 +33,15 @@ public enum GraphLineColor {
public int getColor() {
return this.color;
}
+
+ @NotNull
+ public static PlotLineColor valueOf(int color) {
+ for (PlotLineColor plotLineColor : PlotLineColor.values()) {
+ if ( plotLineColor.color == color ) {
+ return plotLineColor;
+ }
+ }
+
+ return PlotLineColor.white;
+ }
}
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionLineColorType.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColorType.java
similarity index 61%
rename from core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionLineColorType.java
rename to core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColorType.java
index 25be77e5..a4977179 100644
--- a/core/src/main/java/org/solovyev/android/calculator/plot/PlotFunctionLineColorType.java
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineColorType.java
@@ -5,8 +5,8 @@ package org.solovyev.android.calculator.plot;
* Date: 1/5/13
* Time: 10:45 PM
*/
-public enum PlotFunctionLineColorType {
+public enum PlotLineColorType {
- color_map,
- solid;
+ monochrome,
+ color_map;
}
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineDef.java b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineDef.java
new file mode 100644
index 00000000..3323315f
--- /dev/null
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/PlotLineDef.java
@@ -0,0 +1,137 @@
+package org.solovyev.android.calculator.plot;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * User: serso
+ * Date: 1/5/13
+ * Time: 7:41 PM
+ */
+public class PlotLineDef {
+
+ /*
+ **********************************************************************
+ *
+ * CONSTANTS
+ *
+ **********************************************************************
+ */
+
+ @NotNull
+ public static final Float DEFAULT_LINE_WIDTH = -1f;
+
+ private static final int WHITE = 0xFFFFFFFF;
+
+
+ /*
+ **********************************************************************
+ *
+ * FIELDS
+ *
+ **********************************************************************
+ */
+
+ @NotNull
+ private PlotLineColorType lineColorType = PlotLineColorType.monochrome;
+
+ private int lineColor = WHITE;
+
+ @NotNull
+ private PlotLineStyle lineStyle = PlotLineStyle.solid;
+
+ private float lineWidth = -DEFAULT_LINE_WIDTH;
+
+ private PlotLineDef() {
+ }
+
+ @NotNull
+ public static PlotLineDef newInstance(int lineColor, @NotNull PlotLineStyle lineStyle) {
+ final PlotLineDef result = new PlotLineDef();
+ result.lineColor = lineColor;
+ result.lineStyle = lineStyle;
+ return result;
+ }
+
+ @NotNull
+ public static PlotLineDef newInstance(int lineColor, @NotNull PlotLineStyle lineStyle, float lineWidth) {
+ final PlotLineDef result = new PlotLineDef();
+ result.lineColor = lineColor;
+ result.lineStyle = lineStyle;
+ result.lineWidth = lineWidth;
+ return result;
+ }
+
+ @NotNull
+ public static PlotLineDef newInstance(int lineColor, @NotNull PlotLineStyle lineStyle, float lineWidth, @NotNull PlotLineColorType lineColorType) {
+ final PlotLineDef result = new PlotLineDef();
+ result.lineColor = lineColor;
+ result.lineColorType = lineColorType;
+ result.lineStyle = lineStyle;
+ result.lineWidth = lineWidth;
+ return result;
+ }
+
+ @NotNull
+ private PlotLineDef copy() {
+ final PlotLineDef copy = new PlotLineDef();
+ copy.lineColor = lineColor;
+ copy.lineColorType = lineColorType;
+ copy.lineStyle = lineStyle;
+ copy.lineWidth = lineWidth;
+ return copy;
+ }
+
+ @NotNull
+ public static PlotLineDef changeLineColor(@NotNull PlotLineDef plotLineDef, int newLineColor) {
+ final PlotLineDef result = plotLineDef.copy();
+ result.lineColor = newLineColor;
+ return result;
+ }
+
+ @NotNull
+ public static PlotLineDef changeLineColorType(@NotNull PlotLineDef plotLineDef, @NotNull PlotLineColorType newPlotLineColorType) {
+ final PlotLineDef result = plotLineDef.copy();
+ result.lineColorType = newPlotLineColorType;
+ return result;
+ }
+
+ @NotNull
+ public static PlotLineDef changeLineStyle(@NotNull PlotLineDef plotLineDef, @NotNull PlotLineStyle newPlotLineStyle) {
+ final PlotLineDef result = plotLineDef.copy();
+ result.lineStyle = newPlotLineStyle;
+ return result;
+ }
+
+ @NotNull
+ public static PlotLineDef changeColor(@NotNull PlotLineDef plotLineDef, int newLineColor) {
+ final PlotLineDef result = plotLineDef.copy();
+ result.lineColor = newLineColor;
+ return result;
+ }
+
+
+
+
+ @NotNull
+ public static PlotLineDef newDefaultInstance() {
+ return new PlotLineDef();
+ }
+
+ public int getLineColor() {
+ return lineColor;
+ }
+
+ @NotNull
+ public PlotLineStyle getLineStyle() {
+ return lineStyle;
+ }
+
+ public float getLineWidth() {
+ return lineWidth;
+ }
+
+ @NotNull
+ public PlotLineColorType getLineColorType() {
+ return lineColorType;
+ }
+}
diff --git a/core/src/main/java/org/solovyev/android/calculator/plot/XyFunction.java b/core/src/main/java/org/solovyev/android/calculator/plot/XyFunction.java
index e2f2a0be..b66f99d9 100644
--- a/core/src/main/java/org/solovyev/android/calculator/plot/XyFunction.java
+++ b/core/src/main/java/org/solovyev/android/calculator/plot/XyFunction.java
@@ -4,6 +4,7 @@ import jscl.math.Generic;
import jscl.math.function.Constant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.solovyev.common.text.StringUtils;
public class XyFunction {
@@ -15,22 +16,25 @@ public class XyFunction {
**********************************************************************
*/
+ @NotNull
+ private final String id;
+
@NotNull
- private final Generic expression;
+ private Generic expression;
@NotNull
private String expressionString;
@Nullable
- private final Constant xVariable;
+ private Constant xVariable;
@Nullable
private String xVariableName;
@Nullable
- private final Constant yVariable;
+ private Constant yVariable;
- private final boolean imag;
+ private boolean imag;
@Nullable
private String yVariableName;
@@ -62,6 +66,8 @@ public class XyFunction {
this.arity--;
}
+ this.id = this.expressionString + "_" + StringUtils.getNotEmpty(this.xVariableName, "") + "_" + StringUtils.getNotEmpty(this.yVariableName, "");
+
}
public boolean isImag() {
@@ -92,6 +98,11 @@ public class XyFunction {
return expressionString;
}
+ @NotNull
+ public String getId() {
+ return id;
+ }
+
@Nullable
public String getXVariableName() {
return xVariableName;
@@ -102,6 +113,7 @@ public class XyFunction {
return yVariableName;
}
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -109,20 +121,13 @@ public class XyFunction {
final XyFunction that = (XyFunction) o;
- if (!expressionString.equals(that.expressionString)) 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;
+ if (!id.equals(that.id)) return false;
return true;
}
@Override
public int hashCode() {
- int result = expressionString.hashCode();
- result = 31 * result + (xVariableName != null ? xVariableName.hashCode() : 0);
- result = 31 * result + (yVariableName != null ? yVariableName.hashCode() : 0);
- return result;
+ return id.hashCode();
}
}