new plotter
This commit is contained in:
BIN
android-app-core/res/drawable-hdpi/ab_list.png
Normal file
BIN
android-app-core/res/drawable-hdpi/ab_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
android-app-core/res/drawable-hdpi/ab_plot_2d.png
Normal file
BIN
android-app-core/res/drawable-hdpi/ab_plot_2d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 891 B |
BIN
android-app-core/res/drawable-hdpi/ab_plot_3d.png
Normal file
BIN
android-app-core/res/drawable-hdpi/ab_plot_3d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
android-app-core/res/drawable-xhdpi/ab_list.png
Normal file
BIN
android-app-core/res/drawable-xhdpi/ab_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 698 B |
BIN
android-app-core/res/drawable-xhdpi/ab_plot_2d.png
Normal file
BIN
android-app-core/res/drawable-xhdpi/ab_plot_2d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
android-app-core/res/drawable-xhdpi/ab_plot_3d.png
Normal file
BIN
android-app-core/res/drawable-xhdpi/ab_plot_3d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
26
android-app-core/res/layout/cpp_plot_function_list_item.xml
Normal file
26
android-app-core/res/layout/cpp_plot_function_list_item.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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>
|
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextView xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="wrap_content"/>
|
@@ -282,7 +282,9 @@
|
||||
<string name="cpp_onscreen_remove_icon_message">You can remove second icon in applications\' list from application settings or by pressing next button</string>
|
||||
<string name="cpp_onscreen_remove_icon_button_text">Remove icon</string>
|
||||
<string name="cpp_this_change_may_require_reboot">This change may require reboot</string>
|
||||
<string name="cpp_plot_3d">3D</string>
|
||||
<string name="cpp_plot_2d">2D plot</string>
|
||||
<string name="cpp_plot_3d">3D plot</string>
|
||||
<string name="cpp_plot_functions">Graph functions</string>
|
||||
|
||||
<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>
|
||||
|
@@ -152,7 +152,30 @@
|
||||
|
||||
<item name="dropDownListViewStyle">@style/cpp_default_actionbar_dropdown_listview_style</item>
|
||||
<item name="android:dropDownListViewStyle">@style/cpp_default_actionbar_dropdown_listview_style</item>
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style name="cpp_gray_dialog_theme" parent="Theme.Sherlock.Dialog">
|
||||
<!-- buttons -->
|
||||
<item name="cpp_digit_button_style">@style/cpp_default_digit_button_style</item>
|
||||
<item name="cpp_control_button_style">@style/cpp_default_control_button_style</item>
|
||||
<item name="cpp_control_image_button_style">@style/cpp_default_control_image_button_style</item>
|
||||
<item name="cpp_operation_button_style">@style/cpp_default_operation_button_style</item>
|
||||
|
||||
<!-- other -->
|
||||
<item name="cpp_fragment_title_style">@style/cpp_default_fragment_title_style</item>
|
||||
<item name="cpp_fragment_list_view_style">@style/cpp_default_fragment_list_view_style</item>
|
||||
<item name="cpp_fragment_list_view_item_style">@style/cpp_default_fragment_list_view_item_style</item>
|
||||
<item name="cpp_button_style">@style/cpp_default_button_style</item>
|
||||
|
||||
<item name="cpp_main_layout_style">@style/cpp_default_main_layout_style</item>
|
||||
<item name="cpp_main_multi_pane_layout_style">@style/cpp_default_main_multi_pane_layout_style</item>
|
||||
|
||||
<item name="cpp_fragment_layout_style">@style/cpp_default_fragment_layout_style</item>
|
||||
|
||||
<item name="cpp_dialog_style">@style/cpp_default_dialog_style</item>
|
||||
|
||||
<item name="cpp_pane_style">@style/cpp_default_pane_style</item>
|
||||
<item name="cpp_pane_style_transparent">@style/cpp_default_pane_style_transparent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
@@ -86,7 +86,7 @@ public enum CalculatorDisplayMenuItem implements LabeledMenuItem<CalculatorDispl
|
||||
|
||||
@Override
|
||||
protected boolean isItemVisibleFor(@NotNull Generic generic, @NotNull JsclOperation operation) {
|
||||
return Locator.getInstance().getPlotter().isPlotPossible(generic);
|
||||
return Locator.getInstance().getPlotter().isPlotPossibleFor(generic);
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -77,24 +77,28 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
return plotter.removeFunction(xyFunction);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void pin(@NotNull PlotFunction plotFunction) {
|
||||
plotter.pin(plotFunction);
|
||||
public PlotFunction pin(@NotNull PlotFunction plotFunction) {
|
||||
return plotter.pin(plotFunction);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void unpin(@NotNull PlotFunction plotFunction) {
|
||||
plotter.unpin(plotFunction);
|
||||
public PlotFunction unpin(@NotNull PlotFunction plotFunction) {
|
||||
return plotter.unpin(plotFunction);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void show(@NotNull PlotFunction plotFunction) {
|
||||
plotter.show(plotFunction);
|
||||
public PlotFunction show(@NotNull PlotFunction plotFunction) {
|
||||
return plotter.show(plotFunction);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void hide(@NotNull PlotFunction plotFunction) {
|
||||
plotter.hide(plotFunction);
|
||||
public PlotFunction hide(@NotNull PlotFunction plotFunction) {
|
||||
return plotter.hide(plotFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,8 +124,13 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlotPossible(@NotNull Generic expression) {
|
||||
return plotter.isPlotPossible(expression);
|
||||
public boolean is2dPlotPossible() {
|
||||
return plotter.is2dPlotPossible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlotPossibleFor(@NotNull Generic expression) {
|
||||
return plotter.isPlotPossibleFor(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,57 +0,0 @@
|
||||
package org.solovyev.android.calculator.plot;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.android.calculator.core.R;
|
||||
import org.solovyev.android.list.ListItem;
|
||||
import org.solovyev.android.view.TextViewBuilder;
|
||||
import org.solovyev.android.view.UpdatableViewBuilder;
|
||||
|
||||
public class ParcelablePlotInputListItem implements ListItem {
|
||||
|
||||
@NotNull
|
||||
private XyFunction plotInput;
|
||||
|
||||
@NotNull
|
||||
private UpdatableViewBuilder<TextView> viewBuilder;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
// todo serso: optimize
|
||||
return build(context);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public View build(@NotNull Context context) {
|
||||
TextView textView = viewBuilder.build(context);
|
||||
fill(textView);
|
||||
return textView;
|
||||
}
|
||||
|
||||
private void fill(@NotNull TextView textView) {
|
||||
textView.setText(plotInput.getExpressionString());
|
||||
}
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
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