package net.sf.jasperreports.charts.base;

import net.sf.jasperreports.charts.JRXyzDataset;
import net.sf.jasperreports.charts.JRXyzSeries;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.base.JRBaseChartDataset;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
import net.sf.jasperreports.engine.design.JRVerifier;

public class JRBaseXyzDataset extends JRBaseChartDataset implements JRXyzDataset {
  public static final long serialVersionUID = 10200L;
  
  protected JRXyzSeries[] xyzSeries = null;
  
  public JRBaseXyzDataset(JRChartDataset dataset) {
    super(dataset);
  }
  
  public JRBaseXyzDataset(JRXyzDataset dataset, JRBaseObjectFactory factory) {
    super((JRChartDataset)dataset, factory);
    JRXyzSeries[] srcXyzSeries = dataset.getSeries();
    if (srcXyzSeries != null && srcXyzSeries.length > 0) {
      this.xyzSeries = new JRXyzSeries[srcXyzSeries.length];
      for (int i = 0; i < srcXyzSeries.length; i++)
        this.xyzSeries[i] = factory.getXyzSeries(srcXyzSeries[i]); 
    } 
  }
  
  public JRXyzSeries[] getSeries() {
    return this.xyzSeries;
  }
  
  public byte getDatasetType() {
    return 4;
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public void validate(JRVerifier verifier) {
    verifier.verify(this);
  }
  
  public Object clone() {
    JRBaseXyzDataset clone = (JRBaseXyzDataset)super.clone();
    if (this.xyzSeries != null) {
      clone.xyzSeries = new JRXyzSeries[this.xyzSeries.length];
      for (int i = 0; i < this.xyzSeries.length; i++)
        this.xyzSeries[i] = (JRXyzSeries)this.xyzSeries[i].clone(); 
    } 
    return clone;
  }
}
