Fixed an ArrayIndexOutOfBoundsException exception
@@ -39,7 +39,9 @@ public class DataPointsDataSet extends AbstractXYDataset implements IntervalXYDa
public DataPointsDataSet(String label, DataPoint mzPeaks[]) {
this.label = label;
this.mzPeaks = mzPeaks;
- // remove all extra zeros
+
+ // if we have some data points, remove extra zeros
+ if (mzPeaks.length > 0) {
List<DataPoint> dp = new ArrayList<>();
dp.add(mzPeaks[0]);
for (int i = 1; i < mzPeaks.length - 1; i++) {
@@ -53,6 +55,7 @@ public class DataPointsDataSet extends AbstractXYDataset implements IntervalXYDa
dp.add(mzPeaks[mzPeaks.length - 1]);
this.mzPeaks = dp.toArray(new DataPoint[0]);
}
+ }
@Override
public int getSeriesCount() {
