package net.sf.jasperreports.charts.design;

import net.sf.jasperreports.charts.JRPieDataset;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.design.JRDesignChartDataset;
import net.sf.jasperreports.engine.design.JRVerifier;

public class JRDesignPieDataset extends JRDesignChartDataset implements JRPieDataset {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_KEY_EXPRESSION = "keyExpression";
  
  public static final String PROPERTY_LABEL_EXPRESSION = "labelExpression";
  
  public static final String PROPERTY_SECTION_HYPERLINK = "sectionHyperlink";
  
  public static final String PROPERTY_VALUE_EXPRESSION = "valueExpression";
  
  protected JRExpression keyExpression = null;
  
  protected JRExpression valueExpression = null;
  
  protected JRExpression labelExpression = null;
  
  private JRHyperlink sectionHyperlink;
  
  public JRDesignPieDataset(JRChartDataset dataset) {
    super(dataset);
  }
  
  public JRExpression getKeyExpression() {
    return this.keyExpression;
  }
  
  public void setKeyExpression(JRExpression keyExpression) {
    Object old = this.keyExpression;
    this.keyExpression = keyExpression;
    getEventSupport().firePropertyChange("keyExpression", old, this.keyExpression);
  }
  
  public JRExpression getValueExpression() {
    return this.valueExpression;
  }
  
  public void setValueExpression(JRExpression valueExpression) {
    Object old = this.valueExpression;
    this.valueExpression = valueExpression;
    getEventSupport().firePropertyChange("valueExpression", old, this.valueExpression);
  }
  
  public JRExpression getLabelExpression() {
    return this.labelExpression;
  }
  
  public void setLabelExpression(JRExpression labelExpression) {
    Object old = this.labelExpression;
    this.labelExpression = labelExpression;
    getEventSupport().firePropertyChange("labelExpression", old, this.labelExpression);
  }
  
  public byte getDatasetType() {
    return 1;
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public JRHyperlink getSectionHyperlink() {
    return this.sectionHyperlink;
  }
  
  public void setSectionHyperlink(JRHyperlink sectionHyperlink) {
    Object old = this.sectionHyperlink;
    this.sectionHyperlink = sectionHyperlink;
    getEventSupport().firePropertyChange("sectionHyperlink", old, this.sectionHyperlink);
  }
  
  public void validate(JRVerifier verifier) {
    verifier.verify(this);
  }
  
  public Object clone() {
    JRDesignPieDataset clone = (JRDesignPieDataset)super.clone();
    if (this.keyExpression != null)
      clone.keyExpression = (JRExpression)this.keyExpression.clone(); 
    if (this.valueExpression != null)
      clone.valueExpression = (JRExpression)this.valueExpression.clone(); 
    if (this.labelExpression != null)
      clone.labelExpression = (JRExpression)this.labelExpression.clone(); 
    if (this.sectionHyperlink != null)
      clone.sectionHyperlink = (JRHyperlink)this.sectionHyperlink.clone(); 
    return clone;
  }
}
