package net.sf.jasperreports.charts.base;

import java.io.IOException;
import java.io.ObjectInputStream;
import net.sf.jasperreports.charts.JRPiePlot;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.base.JRBaseChartPlot;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;

public class JRBasePiePlot extends JRBaseChartPlot implements JRPiePlot {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_CIRCULAR = "circular";
  
  protected boolean isCircular = true;
  
  public JRBasePiePlot(JRChartPlot piePlot, JRChart chart) {
    super(piePlot, chart);
  }
  
  public JRBasePiePlot(JRPiePlot piePlot, JRBaseObjectFactory factory) {
    super((JRChartPlot)piePlot, factory);
    this.isCircular = piePlot.isCircular();
  }
  
  public void collectExpressions(JRExpressionCollector collector) {}
  
  public boolean isCircular() {
    return this.isCircular;
  }
  
  public void setCircular(boolean isCircular) {
    boolean old = this.isCircular;
    this.isCircular = isCircular;
    getEventSupport().firePropertyChange("circular", old, this.isCircular);
  }
  
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField fields = in.readFields();
    this.isCircular = fields.get("isCircular", true);
  }
}
