package net.sf.jasperreports.charts.base;

import java.awt.Color;
import net.sf.jasperreports.charts.JRTimeAxisFormat;
import net.sf.jasperreports.charts.JRTimeSeriesPlot;
import net.sf.jasperreports.charts.JRValueAxisFormat;
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 JRBaseTimeSeriesPlot extends JRBaseChartPlot implements JRTimeSeriesPlot {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_SHOW_LINES = "showLines";
  
  public static final String PROPERTY_SHOW_SHAPES = "showShapes";
  
  protected JRExpression timeAxisLabelExpression = null;
  
  protected JRFont timeAxisLabelFont = null;
  
  protected Color timeAxisLabelColor = null;
  
  protected JRFont timeAxisTickLabelFont = null;
  
  protected Color timeAxisTickLabelColor = null;
  
  protected String timeAxisTickLabelMask = null;
  
  protected Color timeAxisLineColor = null;
  
  protected JRExpression valueAxisLabelExpression = null;
  
  protected JRFont valueAxisLabelFont = null;
  
  protected Color valueAxisLabelColor = null;
  
  protected JRFont valueAxisTickLabelFont = null;
  
  protected Color valueAxisTickLabelColor = null;
  
  protected String valueAxisTickLabelMask = null;
  
  protected Color valueAxisLineColor = null;
  
  boolean isShowShapes = true;
  
  boolean isShowLines = true;
  
  protected JRBaseTimeSeriesPlot(JRChartPlot plot, JRChart chart) {
    super(plot, chart);
  }
  
  public JRBaseTimeSeriesPlot(JRTimeSeriesPlot plot, JRBaseObjectFactory factory) {
    super((JRChartPlot)plot, factory);
    this.isShowLines = plot.isShowLines();
    this.isShowShapes = plot.isShowShapes();
    this.timeAxisLabelExpression = factory.getExpression(plot.getTimeAxisLabelExpression());
    this.timeAxisLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)plot.getChart(), plot.getTimeAxisLabelFont());
    this.timeAxisLabelColor = plot.getOwnTimeAxisLabelColor();
    this.timeAxisTickLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)plot.getChart(), plot.getTimeAxisTickLabelFont());
    this.timeAxisTickLabelColor = plot.getOwnTimeAxisTickLabelColor();
    this.timeAxisTickLabelMask = plot.getTimeAxisTickLabelMask();
    this.timeAxisLineColor = plot.getTimeAxisLineColor();
    this.valueAxisLabelExpression = factory.getExpression(plot.getValueAxisLabelExpression());
    this.valueAxisLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)plot.getChart(), plot.getValueAxisLabelFont());
    this.valueAxisLabelColor = plot.getOwnValueAxisLabelColor();
    this.valueAxisTickLabelFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)plot.getChart(), plot.getValueAxisTickLabelFont());
    this.valueAxisTickLabelColor = plot.getOwnValueAxisTickLabelColor();
    this.valueAxisTickLabelMask = plot.getValueAxisTickLabelMask();
    this.valueAxisLineColor = plot.getValueAxisTickLabelColor();
  }
  
  public JRExpression getTimeAxisLabelExpression() {
    return this.timeAxisLabelExpression;
  }
  
  public JRFont getTimeAxisLabelFont() {
    return this.timeAxisLabelFont;
  }
  
  public Color getTimeAxisLabelColor() {
    return JRStyleResolver.getTimeAxisLabelColor((JRTimeAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnTimeAxisLabelColor() {
    return this.timeAxisLabelColor;
  }
  
  public JRFont getTimeAxisTickLabelFont() {
    return this.timeAxisTickLabelFont;
  }
  
  public Color getTimeAxisTickLabelColor() {
    return JRStyleResolver.getTimeAxisTickLabelColor((JRTimeAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnTimeAxisTickLabelColor() {
    return this.timeAxisTickLabelColor;
  }
  
  public String getTimeAxisTickLabelMask() {
    return this.timeAxisTickLabelMask;
  }
  
  public Color getTimeAxisLineColor() {
    return JRStyleResolver.getTimeAxisLineColor((JRTimeAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnTimeAxisLineColor() {
    return this.timeAxisLineColor;
  }
  
  public JRExpression getValueAxisLabelExpression() {
    return this.valueAxisLabelExpression;
  }
  
  public JRFont getValueAxisLabelFont() {
    return this.valueAxisLabelFont;
  }
  
  public Color getValueAxisLabelColor() {
    return JRStyleResolver.getValueAxisLabelColor((JRValueAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnValueAxisLabelColor() {
    return this.valueAxisLabelColor;
  }
  
  public JRFont getValueAxisTickLabelFont() {
    return this.valueAxisTickLabelFont;
  }
  
  public Color getValueAxisTickLabelColor() {
    return JRStyleResolver.getValueAxisTickLabelColor((JRValueAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnValueAxisTickLabelColor() {
    return this.valueAxisTickLabelColor;
  }
  
  public String getValueAxisTickLabelMask() {
    return this.valueAxisTickLabelMask;
  }
  
  public Color getValueAxisLineColor() {
    return JRStyleResolver.getValueAxisLineColor((JRValueAxisFormat)this, (JRChartPlot)this);
  }
  
  public Color getOwnValueAxisLineColor() {
    return this.valueAxisLineColor;
  }
  
  public boolean isShowLines() {
    return this.isShowLines;
  }
  
  public boolean isShowShapes() {
    return this.isShowShapes;
  }
  
  public void setShowLines(boolean val) {
    boolean old = this.isShowLines;
    this.isShowLines = val;
    getEventSupport().firePropertyChange("showLines", old, this.isShowLines);
  }
  
  public void setShowShapes(boolean val) {
    boolean old = this.isShowShapes;
    this.isShowShapes = val;
    getEventSupport().firePropertyChange("showShapes", old, this.isShowShapes);
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public Object clone(JRChart parentChart) {
    JRBaseTimeSeriesPlot clone = (JRBaseTimeSeriesPlot)super.clone(parentChart);
    if (this.timeAxisLabelExpression != null)
      clone.timeAxisLabelExpression = (JRExpression)this.timeAxisLabelExpression.clone(); 
    if (this.valueAxisLabelExpression != null)
      clone.valueAxisLabelExpression = (JRExpression)this.valueAxisLabelExpression.clone(); 
    return clone;
  }
}
