package net.sf.jasperreports.charts.base;

import java.awt.Color;
import net.sf.jasperreports.charts.JRScatterPlot;
import net.sf.jasperreports.charts.JRXAxisFormat;
import net.sf.jasperreports.charts.JRYAxisFormat;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRFont;
import net.sf.jasperreports.engine.JRStyleContainer;
import net.sf.jasperreports.engine.base.JRBaseChartPlot;
import net.sf.jasperreports.engine.base.JRBaseFont;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
import net.sf.jasperreports.engine.util.JRStyleResolver;

public class JRBaseScatterPlot extends JRBaseChartPlot implements JRScatterPlot {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_SHOW_LINES = "showLines";
  
  public static final String PROPERTY_SHOW_SHAPES = "showShapes";
  
  protected JRExpression xAxisLabelExpression = null;
  
  protected JRFont xAxisLabelFont = null;
  
  protected Color xAxisLabelColor = null;
  
  protected JRFont xAxisTickLabelFont = null;
  
  protected Color xAxisTickLabelColor = null;
  
  protected String xAxisTickLabelMask = null;
  
  protected Color xAxisLineColor = null;
  
  protected JRExpression yAxisLabelExpression = null;
  
  protected JRFont yAxisLabelFont = null;
  
  protected Color yAxisLabelColor = null;
  
  protected JRFont yAxisTickLabelFont = null;
  
  protected Color yAxisTickLabelColor = null;
  
  protected String yAxisTickLabelMask = null;
  
  protected Color yAxisLineColor = null;
  
  boolean isShowShapes = true;
  
  boolean isShowLines = true;
  
  public JRBaseScatterPlot(JRChartPlot scattedPlot, JRChart chart) {
    super(scattedPlot, chart);
  }
  
  public JRBaseScatterPlot(JRScatterPlot scattedPlot, JRBaseObjectFactory factory) {
    super((JRChartPlot)scattedPlot, factory);
    this.isShowShapes = scattedPlot.isShowShapes();
    this.isShowLines = scattedPlot.isShowLines();
    this.xAxisLabelExpression = factory.getExpression(scattedPlot.getXAxisLabelExpression());
    this.xAxisLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)scattedPlot.getChart(), scattedPlot.getXAxisLabelFont());
    this.xAxisLabelColor = scattedPlot.getOwnXAxisLabelColor();
    this.xAxisTickLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)scattedPlot.getChart(), scattedPlot.getXAxisTickLabelFont());
    this.xAxisTickLabelColor = scattedPlot.getOwnXAxisTickLabelColor();
    this.xAxisTickLabelMask = scattedPlot.getXAxisTickLabelMask();
    this.xAxisLineColor = scattedPlot.getXAxisLineColor();
    this.yAxisLabelExpression = factory.getExpression(scattedPlot.getYAxisLabelExpression());
    this.yAxisLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)scattedPlot.getChart(), scattedPlot.getYAxisLabelFont());
    this.yAxisLabelColor = scattedPlot.getOwnYAxisLabelColor();
    this.yAxisTickLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)scattedPlot.getChart(), scattedPlot.getYAxisTickLabelFont());
    this.yAxisTickLabelColor = scattedPlot.getOwnYAxisTickLabelColor();
    this.yAxisTickLabelMask = scattedPlot.getYAxisTickLabelMask();
    this.yAxisLineColor = scattedPlot.getYAxisLineColor();
  }
  
  public JRExpression getXAxisLabelExpression() {
    return this.xAxisLabelExpression;
  }
  
  public JRFont getXAxisLabelFont() {
    return this.xAxisLabelFont;
  }
  
  public Color getXAxisLabelColor() {
    return JRStyleResolver.getXAxisLabelColor((JRXAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnXAxisLabelColor() {
    return this.xAxisLabelColor;
  }
  
  public JRFont getXAxisTickLabelFont() {
    return this.xAxisTickLabelFont;
  }
  
  public Color getXAxisTickLabelColor() {
    return JRStyleResolver.getXAxisTickLabelColor((JRXAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnXAxisTickLabelColor() {
    return this.xAxisTickLabelColor;
  }
  
  public String getXAxisTickLabelMask() {
    return this.xAxisTickLabelMask;
  }
  
  public Color getXAxisLineColor() {
    return JRStyleResolver.getXAxisLineColor((JRXAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnXAxisLineColor() {
    return this.xAxisLineColor;
  }
  
  public JRExpression getYAxisLabelExpression() {
    return this.yAxisLabelExpression;
  }
  
  public JRFont getYAxisLabelFont() {
    return this.yAxisLabelFont;
  }
  
  public Color getYAxisLabelColor() {
    return JRStyleResolver.getYAxisLabelColor((JRYAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnYAxisLabelColor() {
    return this.yAxisLabelColor;
  }
  
  public JRFont getYAxisTickLabelFont() {
    return this.yAxisTickLabelFont;
  }
  
  public Color getYAxisTickLabelColor() {
    return JRStyleResolver.getYAxisTickLabelColor((JRYAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnYAxisTickLabelColor() {
    return this.yAxisTickLabelColor;
  }
  
  public String getYAxisTickLabelMask() {
    return this.yAxisTickLabelMask;
  }
  
  public Color getYAxisLineColor() {
    return JRStyleResolver.getYAxisLineColor((JRYAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnYAxisLineColor() {
    return this.yAxisLineColor;
  }
  
  public boolean isShowShapes() {
    return this.isShowShapes;
  }
  
  public boolean isShowLines() {
    return this.isShowLines;
  }
  
  public void setShowShapes(boolean value) {
    boolean old = this.isShowShapes;
    this.isShowShapes = value;
    getEventSupport().firePropertyChange("showShapes", old, this.isShowShapes);
  }
  
  public void setShowLines(boolean value) {
    boolean old = this.isShowLines;
    this.isShowLines = value;
    getEventSupport().firePropertyChange("showLines", old, this.isShowLines);
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public Object clone(JRChart parentChart) {
    JRBaseScatterPlot clone = (JRBaseScatterPlot)super.clone(parentChart);
    if (this.xAxisLabelExpression != null)
      clone.xAxisLabelExpression = (JRExpression)this.xAxisLabelExpression.clone(); 
    if (this.yAxisLabelExpression != null)
      clone.yAxisLabelExpression = (JRExpression)this.yAxisLabelExpression.clone(); 
    return clone;
  }
}
