plot changes
This commit is contained in:
parent
62eb80c89d
commit
fa7727d666
@ -317,6 +317,8 @@
|
||||
<string name="cpp_plot_range">Интервал построения</string>
|
||||
<string name="cpp_plot_range_x_min">X мин</string>
|
||||
<string name="cpp_plot_range_x_max">X макс</string>
|
||||
<string name="cpp_plot_range_y_min">Y мин</string>
|
||||
<string name="cpp_plot_range_y_max">Y макс</string>
|
||||
<string name="cpp_invalid_number">Неправильное число!</string>
|
||||
<string name="cpp_plot_boundaries_should_differ">Границы графика не могут быть равны!</string>
|
||||
<string name="cpp_apply">Применить</string>
|
||||
|
@ -158,6 +158,11 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
plotter.setPlotImag(plotImag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePlotBoundaries(@NotNull PlotBoundaries plotBoundaries) {
|
||||
plotter.savePlotBoundaries(plotBoundaries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlotBoundaries(@NotNull PlotBoundaries plotBoundaries) {
|
||||
plotter.setPlotBoundaries(plotBoundaries);
|
||||
@ -169,9 +174,4 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
||||
setPlotImag(CalculatorPreferences.Graph.plotImag.getPreference(preferences));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlotData(boolean plot3d, @NotNull PlotBoundaries plotBoundaries) {
|
||||
plotter.setPlotData(plot3d, plotBoundaries);
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +95,11 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
private void saveBoundaries(@NotNull PlotBoundaries boundaries) {
|
||||
Locator.getInstance().getPlotter().setPlotBoundaries(boundaries);
|
||||
private void savePlotBoundaries() {
|
||||
final PlotBoundaries plotBoundaries = getPlotBoundaries();
|
||||
if (plotBoundaries != null) {
|
||||
Locator.getInstance().getPlotter().savePlotBoundaries(plotBoundaries);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -106,10 +109,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
public void onPause() {
|
||||
PreferenceManager.getDefaultSharedPreferences(this.getActivity()).unregisterOnSharedPreferenceChangeListener(this);
|
||||
|
||||
final PlotBoundaries plotBoundaries = getPlotBoundaries();
|
||||
if (plotBoundaries != null) {
|
||||
saveBoundaries(plotBoundaries);
|
||||
}
|
||||
savePlotBoundaries();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
@ -203,10 +203,25 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
final List<IdentifiableMenuItem<MenuItem>> menuItems = new ArrayList<IdentifiableMenuItem<MenuItem>>();
|
||||
menuItems.add(PlotMenu.range);
|
||||
menuItems.add(PlotMenu.preferences);
|
||||
menuItems.add(PlotMenu.functions);
|
||||
|
||||
final IdentifiableMenuItem<MenuItem> plotRangeMenuItem = new IdentifiableMenuItem<MenuItem>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Integer getItemId() {
|
||||
return R.id.menu_plot_range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
savePlotBoundaries();
|
||||
|
||||
context.startActivity(new Intent(context, CalculatorPlotRangeActivity.class));
|
||||
}
|
||||
};
|
||||
menuItems.add(plotRangeMenuItem);
|
||||
|
||||
final IdentifiableMenuItem<MenuItem> plot3dMenuItem = new IdentifiableMenuItem<MenuItem>() {
|
||||
@NotNull
|
||||
@Override
|
||||
@ -216,14 +231,10 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
final PlotBoundaries plotBoundaries = getPlotBoundaries();
|
||||
savePlotBoundaries();
|
||||
|
||||
if (plotBoundaries != null) {
|
||||
Locator.getInstance().getPlotter().setPlotData(true, plotBoundaries);
|
||||
} else {
|
||||
Locator.getInstance().getPlotter().setPlot3d(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
menuItems.add(plot3dMenuItem);
|
||||
|
||||
@ -237,14 +248,10 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
final PlotBoundaries plotBoundaries = getPlotBoundaries();
|
||||
savePlotBoundaries();
|
||||
|
||||
if (plotBoundaries != null) {
|
||||
Locator.getInstance().getPlotter().setPlotData(false, plotBoundaries);
|
||||
} else {
|
||||
Locator.getInstance().getPlotter().setPlot3d(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
menuItems.add(plot2dMenuItem);
|
||||
|
||||
@ -275,7 +282,7 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
return !plot2dVisible;
|
||||
} else if ( menuItem == captureScreenshotMenuItem ) {
|
||||
return !captureScreenshotVisible;
|
||||
} else if ( menuItem == PlotMenu.range ) {
|
||||
} else if ( menuItem == plotRangeMenuItem ) {
|
||||
return !plotRangeVisible;
|
||||
}
|
||||
|
||||
@ -343,13 +350,6 @@ public abstract class AbstractCalculatorPlotFragment extends CalculatorFragment
|
||||
|
||||
private static enum PlotMenu implements IdentifiableMenuItem<MenuItem> {
|
||||
|
||||
range(R.id.menu_plot_range) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
context.startActivity(new Intent(context, CalculatorPlotRangeActivity.class));
|
||||
}
|
||||
},
|
||||
|
||||
functions(R.id.menu_plot_functions) {
|
||||
@Override
|
||||
public void onClick(@NotNull MenuItem data, @NotNull Context context) {
|
||||
|
@ -167,7 +167,8 @@ public class CalculatorGraph3dView extends GLView implements GraphView {
|
||||
|
||||
@Override
|
||||
public void setXRange(float xMin, float xMax) {
|
||||
dimensions.setRanges(1, 1, 1, 1);
|
||||
dimensions.setXRange(PlotBoundaries.DEFAULT_MIN_NUMBER, PlotBoundaries.DEFAULT_MAX_NUMBER);
|
||||
dimensions.setXY(dimensions.getX0(), 0);
|
||||
|
||||
zoomLevel = 1;
|
||||
dirty = true;
|
||||
|
@ -58,11 +58,11 @@ public interface CalculatorPlotter {
|
||||
boolean isPlotPossibleFor(@NotNull Generic expression);
|
||||
|
||||
void setPlot3d(boolean plot3d);
|
||||
void setPlotData(boolean plot3d, @NotNull PlotBoundaries plotBoundaries);
|
||||
|
||||
void removeAllUnpinned();
|
||||
|
||||
void setPlotImag(boolean plotImag);
|
||||
|
||||
void savePlotBoundaries(@NotNull PlotBoundaries plotBoundaries);
|
||||
void setPlotBoundaries(@NotNull PlotBoundaries plotBoundaries);
|
||||
}
|
||||
|
@ -372,18 +372,13 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlotData(boolean plot3d, @NotNull PlotBoundaries plotBoundaries) {
|
||||
if (this.plot3d != plot3d || this.plotBoundaries.equals(plotBoundaries)) {
|
||||
this.plot3d = plot3d;
|
||||
this.plotBoundaries = plotBoundaries;
|
||||
firePlotDataChangedEvent();
|
||||
}
|
||||
private void firePlotDataChangedEvent() {
|
||||
updatePlotData();
|
||||
calculator.fireCalculatorEvent(CalculatorEventType.plot_data_changed, plotData);
|
||||
}
|
||||
|
||||
private void firePlotDataChangedEvent() {
|
||||
private void updatePlotData() {
|
||||
plotData = new PlotData(getVisibleFunctions(), plot3d, plotBoundaries);
|
||||
calculator.fireCalculatorEvent(CalculatorEventType.plot_data_changed, plotData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -396,6 +391,14 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePlotBoundaries(@NotNull PlotBoundaries plotBoundaries) {
|
||||
if ( !this.plotBoundaries.equals(plotBoundaries) ) {
|
||||
this.plotBoundaries = plotBoundaries;
|
||||
updatePlotData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlotBoundaries(@NotNull PlotBoundaries plotBoundaries) {
|
||||
if ( !this.plotBoundaries.equals(plotBoundaries) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user