This commit is contained in:
Sergey Solovyev 2012-12-05 14:08:02 +04:00
parent 555f6d9a61
commit 776a162b2d

View File

@ -24,6 +24,7 @@ import jscl.math.Generic;
import jscl.math.function.Constant;
import jscl.text.ParseException;
import org.achartengine.chart.XYChart;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.tools.PanListener;
@ -325,22 +326,23 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul
public void run() {
final XYMultipleSeriesRenderer dr = chart.getRenderer();
final MyXYSeries realSeries = (MyXYSeries) chart.getDataset().getSeriesAt(0);
final XYMultipleSeriesDataset dataset = chart.getDataset();
if (dataset != null && dr != null) {
final MyXYSeries realSeries = (MyXYSeries) dataset.getSeriesAt(0);
if (realSeries != null) {
final MyXYSeries imagSeries;
if (chart.getDataset().getSeriesCount() > 1) {
imagSeries = (MyXYSeries) chart.getDataset().getSeriesAt(1);
if (dataset.getSeriesCount() > 1) {
imagSeries = (MyXYSeries) dataset.getSeriesAt(1);
} else {
imagSeries = new MyXYSeries(PlotUtils.getImagFunctionName(variable), PlotUtils.DEFAULT_NUMBER_OF_STEPS * 2);
}
try {
if (dr != null) {
if (PlotUtils.addXY(dr.getXAxisMin(), dr.getXAxisMax(), expression, variable, realSeries, imagSeries, true, PlotUtils.DEFAULT_NUMBER_OF_STEPS)) {
if (chart.getDataset().getSeriesCount() <= 1) {
chart.getDataset().addSeries(imagSeries);
chart.getRenderer().addSeriesRenderer(PlotUtils.createImagRenderer(imagLineColor.getColor()));
}
if (dataset.getSeriesCount() <= 1) {
dataset.addSeries(imagSeries);
dr.addSeriesRenderer(PlotUtils.createImagRenderer(imagLineColor.getColor()));
}
}
} catch (ArithmeticException e) {
@ -354,6 +356,8 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul
}
});
}
}
}
});
}
}