92 lines
2.4 KiB
Java
92 lines
2.4 KiB
Java
package net.sf.jasperreports.charts.util;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import org.jfree.data.xy.AbstractXYZDataset;
|
|
import org.jfree.data.xy.XYZDataset;
|
|
|
|
public class DefaultXYZDataset extends AbstractXYZDataset implements XYZDataset {
|
|
private static final long serialVersionUID = 10200L;
|
|
|
|
List dataset = null;
|
|
|
|
public DefaultXYZDataset() {
|
|
this.dataset = new ArrayList();
|
|
}
|
|
|
|
public void addValue(Comparable series, Number xValue, Number yValue, Number zValue) {
|
|
boolean found = false;
|
|
for (Iterator it = this.dataset.iterator(); it.hasNext(); ) {
|
|
XYZElement element = it.next();
|
|
if (element.getSeries().equals(series)) {
|
|
element.addElement(xValue, yValue, zValue);
|
|
found = true;
|
|
}
|
|
}
|
|
if (!found) {
|
|
XYZElement element = new XYZElement();
|
|
element.setSeries(series);
|
|
element.addElement(xValue, yValue, zValue);
|
|
this.dataset.add(element);
|
|
}
|
|
}
|
|
|
|
public int getSeriesCount() {
|
|
int retVal = 0;
|
|
if (this.dataset != null)
|
|
retVal = this.dataset.size();
|
|
return retVal;
|
|
}
|
|
|
|
public Number getZ(int series, int index) {
|
|
Number retVal = null;
|
|
if (this.dataset != null &&
|
|
series < getSeriesCount()) {
|
|
XYZElement element = this.dataset.get(series);
|
|
retVal = element.getZElement(index);
|
|
}
|
|
return retVal;
|
|
}
|
|
|
|
public int getItemCount(int series) {
|
|
int retVal = 0;
|
|
if (this.dataset != null &&
|
|
series < getSeriesCount()) {
|
|
XYZElement element = this.dataset.get(series);
|
|
retVal = element.getCount();
|
|
}
|
|
return retVal;
|
|
}
|
|
|
|
public Number getX(int series, int index) {
|
|
Number retVal = null;
|
|
if (this.dataset != null &&
|
|
series < getSeriesCount()) {
|
|
XYZElement element = this.dataset.get(series);
|
|
retVal = element.getXElement(index);
|
|
}
|
|
return retVal;
|
|
}
|
|
|
|
public Number getY(int series, int index) {
|
|
Number retVal = null;
|
|
if (this.dataset != null &&
|
|
series < getSeriesCount()) {
|
|
XYZElement element = this.dataset.get(series);
|
|
retVal = element.getYElement(index);
|
|
}
|
|
return retVal;
|
|
}
|
|
|
|
public Comparable getSeriesKey(int index) {
|
|
String retVal = null;
|
|
if (this.dataset != null &&
|
|
index < getSeriesCount()) {
|
|
XYZElement element = this.dataset.get(index);
|
|
retVal = element.getSeries().toString();
|
|
}
|
|
return retVal;
|
|
}
|
|
}
|