package net.sf.jasperreports.charts.design;

import net.sf.jasperreports.charts.JRChartAxis;
import net.sf.jasperreports.charts.base.JRBaseMultiAxisPlot;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.design.JRDesignChart;

public class JRDesignMultiAxisPlot extends JRBaseMultiAxisPlot {
  public static final String PROPERTY_CHART = "chart";
  
  public static final String PROPERTY_AXES = "axes";
  
  private JRDesignChart chart = null;
  
  private static final long serialVersionUID = 10200L;
  
  public JRDesignMultiAxisPlot(JRChartPlot multiAxisPlot, JRChart chart) {
    super(multiAxisPlot, chart);
  }
  
  public void addAxis(JRChartAxis axis) {
    this.axes.add(axis);
    if (this.axes.size() == 1)
      this.chart.setDataset(axis.getChart().getDataset()); 
    getEventSupport().fireCollectionElementAddedEvent("axes", axis, this.axes.size() - 1);
  }
  
  public void clearAxes() {
    this.axes.clear();
    this.chart.setDataset(null);
  }
  
  public JRChart getChart() {
    return (JRChart)this.chart;
  }
  
  public void setChart(JRDesignChart chart) {
    Object old = this.chart;
    this.chart = chart;
    getEventSupport().firePropertyChange("chart", old, this.chart);
  }
}
