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.math.function.Constant;
import jscl.text.ParseException; import jscl.text.ParseException;
import org.achartengine.chart.XYChart; import org.achartengine.chart.XYChart;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries; import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer; import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.tools.PanListener; import org.achartengine.tools.PanListener;
@ -323,37 +324,40 @@ public class CalculatorPlotFragment extends CalculatorFragment implements Calcul
plotExecutor.execute(new Runnable() { plotExecutor.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
final XYMultipleSeriesRenderer dr = chart.getRenderer(); 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);
final MyXYSeries imagSeries; if (realSeries != null) {
if (chart.getDataset().getSeriesCount() > 1) { final MyXYSeries imagSeries;
imagSeries = (MyXYSeries) chart.getDataset().getSeriesAt(1); if (dataset.getSeriesCount() > 1) {
} else { imagSeries = (MyXYSeries) dataset.getSeriesAt(1);
imagSeries = new MyXYSeries(PlotUtils.getImagFunctionName(variable), PlotUtils.DEFAULT_NUMBER_OF_STEPS * 2); } 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()));
}
} }
}
} catch (ArithmeticException e) {
PlotUtils.handleArithmeticException(e, CalculatorPlotFragment.this);
}
uiHandler.post(new Runnable() { try {
@Override if (PlotUtils.addXY(dr.getXAxisMin(), dr.getXAxisMax(), expression, variable, realSeries, imagSeries, true, PlotUtils.DEFAULT_NUMBER_OF_STEPS)) {
public void run() { if (dataset.getSeriesCount() <= 1) {
graphicalView.repaint(); dataset.addSeries(imagSeries);
} dr.addSeriesRenderer(PlotUtils.createImagRenderer(imagLineColor.getColor()));
}); }
} }
} catch (ArithmeticException e) {
PlotUtils.handleArithmeticException(e, CalculatorPlotFragment.this);
}
uiHandler.post(new Runnable() {
@Override
public void run() {
graphicalView.repaint();
}
});
}
}
}
}); });
} }
} }