* @param flag to determine frequency or time domain
* @return A dataset.
*/
private XYDataset createDataset(SpectrumArray sp, int flag) {
XYSeriesCollection dataset = new XYSeriesCollection();
if (flag == 1) {
for (int i = 0; i < sp.getNumberOfTraces(); i++) {
double[] fdabs = sp.getFrequencyAxisValuesHz();
ComplexArray spec = sp.getSpec(i);
XYSeries series = new XYSeries("Frequency Domain Abscissa");
for (int j = 0; j < fdabs.length; j++) {
series.add(fdabs[j] + this.xoffset * i, spec.getElement(j).abs() + this.yoffset * i);
}
dataset.addSeries(series);
XYSeries realseries = new XYSeries("Real Plot");
for (int j = 0; j < fdabs.length; j++) {
realseries.add(fdabs[j] + this.xoffset * i, spec.getElement(j).real() + this.yoffset * i);
}
dataset.addSeries(realseries);
XYSeries imagseries = new XYSeries("Imaginary Plot");
for (int j = 0; j < fdabs.length; j++) {
imagseries.add(fdabs[j] + this.xoffset * i, spec.getElement(j).imag() + this.yoffset * i);
}
dataset.addSeries(imagseries);
}
} else if (flag == 0) {
for (int i = 0; i < sp.getNumberOfTraces(); i++) {
double[] tdabs = sp.getTimeAxisValues();
ComplexArray spec = sp.getFid(i);
XYSeries series = new XYSeries("Time Domain Abscissa");
for (int j = 0; j < tdabs.length; j++) {
series.add(tdabs[j], spec.getElement(j).abs());
}
dataset.addSeries(series);
XYSeries realseries = new XYSeries("Real Plot");
for (int j = 0; j < tdabs.length; j++) {
realseries.add(tdabs[j], spec.getElement(j).real());
}
dataset.addSeries(realseries);
XYSeries imagseries = new XYSeries("Imaginary Plot");
for (int j = 0; j < tdabs.length; j++) {
imagseries.add(tdabs[j], spec.getElement(j).imag());
}
dataset.addSeries(imagseries);
}
} else if (flag == 2) {
for (int i = 0; i < sp.getNumberOfTraces(); i++) {
double[] fdabs = sp.getFrequencyAxisValuesPPM();
ComplexArray spec = sp.getSpec(i);
XYSeries series = new XYSeries("Frequency Domain Abscissa");
for (int j = 0; j < fdabs.length; j++) {
series.add(fdabs[j] + this.xoffset * i, spec.getElement(j).abs() + this.yoffset * i);
}
dataset.addSeries(series);
XYSeries realseries = new XYSeries("Real Plot");
for (int j = 0; j < fdabs.length; j++) {
realseries.add(fdabs[j] + this.xoffset * i, spec.getElement(j).real() + this.yoffset * i);
}
dataset.addSeries(realseries);
XYSeries imagseries = new XYSeries("Imaginary Plot");
for (int j = 0; j < fdabs.length; j++) {
imagseries.add(fdabs[j] + this.xoffset * i, spec.getElement(j).imag() + this.yoffset * i);
}
dataset.addSeries(imagseries);
}
} else if (flag == 3) {
for (int i = 0; i < sp.getNumberOfTraces(); i++) {
double[] tdabs = sp.getTimeAxisValues();
ComplexArray spec = sp.getFid(i);
XYSeries series = new XYSeries("Time Domain Abscissa");
for (int j = 0; j < tdabs.length; j++) {
series.add(tdabs[j] * 1000, spec.getElement(j).abs());
}
dataset.addSeries(series);
XYSeries realseries = new XYSeries("Real Plot");
for (int j = 0; j < tdabs.length; j++) {
realseries.add(tdabs[j] * 1000, spec.getElement(j).real());
}
dataset.addSeries(realseries);
XYSeries imagseries = new XYSeries("Imaginary Plot");
for (int j = 0; j < tdabs.length; j++) {
imagseries.add(tdabs[j] * 1000, spec.getElement(j).imag());
}
dataset.addSeries(imagseries);
}
}
return dataset;
}