package net.sf.jasperreports.engine.fill;

import java.awt.Color;
import java.awt.Font;
import java.awt.Paint;
import java.awt.geom.Rectangle2D;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.List;
import java.util.SortedSet;
import net.sf.jasperreports.charts.JRAreaPlot;
import net.sf.jasperreports.charts.JRBar3DPlot;
import net.sf.jasperreports.charts.JRBarPlot;
import net.sf.jasperreports.charts.JRBubblePlot;
import net.sf.jasperreports.charts.JRCandlestickPlot;
import net.sf.jasperreports.charts.JRCategoryDataset;
import net.sf.jasperreports.charts.JRDataRange;
import net.sf.jasperreports.charts.JRHighLowDataset;
import net.sf.jasperreports.charts.JRHighLowPlot;
import net.sf.jasperreports.charts.JRLinePlot;
import net.sf.jasperreports.charts.JRMeterPlot;
import net.sf.jasperreports.charts.JRMultiAxisPlot;
import net.sf.jasperreports.charts.JRPie3DPlot;
import net.sf.jasperreports.charts.JRPieDataset;
import net.sf.jasperreports.charts.JRPiePlot;
import net.sf.jasperreports.charts.JRScatterPlot;
import net.sf.jasperreports.charts.JRThermometerPlot;
import net.sf.jasperreports.charts.JRTimePeriodDataset;
import net.sf.jasperreports.charts.JRTimeSeriesDataset;
import net.sf.jasperreports.charts.JRTimeSeriesPlot;
import net.sf.jasperreports.charts.JRValueDataset;
import net.sf.jasperreports.charts.JRValueDisplay;
import net.sf.jasperreports.charts.JRXyDataset;
import net.sf.jasperreports.charts.JRXyzDataset;
import net.sf.jasperreports.charts.fill.JRFillAreaPlot;
import net.sf.jasperreports.charts.fill.JRFillBar3DPlot;
import net.sf.jasperreports.charts.fill.JRFillBarPlot;
import net.sf.jasperreports.charts.fill.JRFillCategoryDataset;
import net.sf.jasperreports.charts.fill.JRFillChartAxis;
import net.sf.jasperreports.charts.fill.JRFillHighLowDataset;
import net.sf.jasperreports.charts.fill.JRFillLinePlot;
import net.sf.jasperreports.charts.fill.JRFillMeterPlot;
import net.sf.jasperreports.charts.fill.JRFillMultiAxisPlot;
import net.sf.jasperreports.charts.fill.JRFillPie3DPlot;
import net.sf.jasperreports.charts.fill.JRFillPieDataset;
import net.sf.jasperreports.charts.fill.JRFillPiePlot;
import net.sf.jasperreports.charts.fill.JRFillThermometerPlot;
import net.sf.jasperreports.charts.fill.JRFillTimePeriodDataset;
import net.sf.jasperreports.charts.fill.JRFillTimeSeriesDataset;
import net.sf.jasperreports.charts.fill.JRFillXyDataset;
import net.sf.jasperreports.charts.fill.JRFillXyzDataset;
import net.sf.jasperreports.charts.util.CategoryChartHyperlinkProvider;
import net.sf.jasperreports.charts.util.ChartHyperlinkProvider;
import net.sf.jasperreports.charts.util.ChartRendererFactory;
import net.sf.jasperreports.charts.util.HighLowChartHyperlinkProvider;
import net.sf.jasperreports.charts.util.JRMeterInterval;
import net.sf.jasperreports.charts.util.PieChartHyperlinkProvider;
import net.sf.jasperreports.charts.util.PieLabelGenerator;
import net.sf.jasperreports.charts.util.TimePeriodChartHyperlinkProvider;
import net.sf.jasperreports.charts.util.TimeSeriesChartHyperlinkProvider;
import net.sf.jasperreports.charts.util.XYChartHyperlinkProvider;
import net.sf.jasperreports.engine.JRAbstractChartCustomizer;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartCustomizer;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.JRFont;
import net.sf.jasperreports.engine.JRGroup;
import net.sf.jasperreports.engine.JRHyperlink;
import net.sf.jasperreports.engine.JRHyperlinkParameter;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.JRPrintElement;
import net.sf.jasperreports.engine.JRPrintHyperlinkParameters;
import net.sf.jasperreports.engine.JRPrintImage;
import net.sf.jasperreports.engine.JRRenderable;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRStyleContainer;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.base.JRBaseFont;
import net.sf.jasperreports.engine.util.JRClassLoader;
import net.sf.jasperreports.engine.util.JRFontUtil;
import net.sf.jasperreports.engine.util.JRPenUtil;
import net.sf.jasperreports.engine.util.JRProperties;
import net.sf.jasperreports.engine.util.JRSingletonCache;
import net.sf.jasperreports.engine.util.JRStyleResolver;
import net.sf.jasperreports.engine.util.LineBoxWrapper;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.Axis;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.CategoryItemLabelGenerator;
import org.jfree.chart.labels.PieSectionLabelGenerator;
import org.jfree.chart.labels.XYItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DefaultDrawingSupplier;
import org.jfree.chart.plot.DialShape;
import org.jfree.chart.plot.DrawingSupplier;
import org.jfree.chart.plot.MeterInterval;
import org.jfree.chart.plot.MeterPlot;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.ThermometerPlot;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.category.StackedBarRenderer3D;
import org.jfree.chart.renderer.xy.CandlestickRenderer;
import org.jfree.chart.renderer.xy.HighLowRenderer;
import org.jfree.chart.renderer.xy.XYBubbleRenderer;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.title.Title;
import org.jfree.data.Range;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.data.general.ValueDataset;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.data.xy.OHLCDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYZDataset;
import org.jfree.ui.RectangleEdge;

public class JRFillChart extends JRFillElement implements JRChart {
  private static final Color TRANSPARENT_PAINT = new Color(0, 0, 0, 0);
  
  private static final JRSingletonCache chartRendererFactoryCache = new JRSingletonCache(ChartRendererFactory.class);
  
  protected byte chartType = 0;
  
  protected JRFont titleFont = null;
  
  protected JRFont subtitleFont = null;
  
  protected JRFont legendFont = null;
  
  protected JRGroup evaluationGroup = null;
  
  protected JRFillChartDataset dataset = null;
  
  protected JRChartPlot plot = null;
  
  protected JRRenderable renderer = null;
  
  private String anchorName = null;
  
  private String hyperlinkReference = null;
  
  private String hyperlinkAnchor = null;
  
  private Integer hyperlinkPage = null;
  
  private String hyperlinkTooltip;
  
  private JRPrintHyperlinkParameters hyperlinkParameters;
  
  protected String customizerClass;
  
  protected JRChartCustomizer chartCustomizer;
  
  protected String renderType;
  
  protected JFreeChart chart;
  
  protected ChartHyperlinkProvider chartHyperlinkProvider;
  
  protected JRFillChart(JRBaseFiller filler, JRChart chart, JRFillObjectFactory factory) {
    super(filler, (JRElement)chart, factory);
    this.chartType = chart.getChartType();
    switch (this.chartType) {
      case 1:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getAreaPlot((JRAreaPlot)chart.getPlot());
        break;
      case 3:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getBarPlot((JRBarPlot)chart.getPlot());
        break;
      case 2:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getBar3DPlot((JRBar3DPlot)chart.getPlot());
        break;
      case 4:
        this.dataset = (JRFillChartDataset)factory.getXyzDataset((JRXyzDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getBubblePlot((JRBubblePlot)chart.getPlot());
        break;
      case 5:
        this.dataset = (JRFillChartDataset)factory.getHighLowDataset((JRHighLowDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getCandlestickPlot((JRCandlestickPlot)chart.getPlot());
        break;
      case 6:
        this.dataset = (JRFillChartDataset)factory.getHighLowDataset((JRHighLowDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getHighLowPlot((JRHighLowPlot)chart.getPlot());
        break;
      case 7:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getLinePlot((JRLinePlot)chart.getPlot());
        break;
      case 17:
        this.dataset = (JRFillChartDataset)factory.getValueDataset((JRValueDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getMeterPlot((JRMeterPlot)chart.getPlot());
        break;
      case 19:
        this.plot = (JRChartPlot)factory.getMultiAxisPlot((JRMultiAxisPlot)chart.getPlot());
        this.dataset = ((JRFillMultiAxisPlot)this.plot).getMainDataset();
        break;
      case 9:
        this.dataset = (JRFillChartDataset)factory.getPieDataset((JRPieDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getPiePlot((JRPiePlot)chart.getPlot());
        break;
      case 8:
        this.dataset = (JRFillChartDataset)factory.getPieDataset((JRPieDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getPie3DPlot((JRPie3DPlot)chart.getPlot());
        break;
      case 10:
        this.dataset = (JRFillChartDataset)factory.getXyDataset((JRXyDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getScatterPlot((JRScatterPlot)chart.getPlot());
        break;
      case 12:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getBarPlot((JRBarPlot)chart.getPlot());
        break;
      case 11:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getBar3DPlot((JRBar3DPlot)chart.getPlot());
        break;
      case 18:
        this.dataset = (JRFillChartDataset)factory.getValueDataset((JRValueDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getThermometerPlot((JRThermometerPlot)chart.getPlot());
        break;
      case 16:
        this.dataset = (JRFillChartDataset)factory.getTimeSeriesDataset((JRTimeSeriesDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getTimeSeriesPlot((JRTimeSeriesPlot)chart.getPlot());
        break;
      case 13:
        this.dataset = (JRFillChartDataset)factory.getXyDataset((JRXyDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getAreaPlot((JRAreaPlot)chart.getPlot());
        break;
      case 14:
        switch (chart.getDataset().getDatasetType()) {
          case 6:
            this.dataset = (JRFillChartDataset)factory.getTimeSeriesDataset((JRTimeSeriesDataset)chart.getDataset());
            break;
          case 5:
            this.dataset = (JRFillChartDataset)factory.getTimePeriodDataset((JRTimePeriodDataset)chart.getDataset());
            break;
          case 3:
            this.dataset = (JRFillChartDataset)factory.getXyDataset((JRXyDataset)chart.getDataset());
            break;
        } 
        this.plot = (JRChartPlot)factory.getBarPlot((JRBarPlot)chart.getPlot());
        break;
      case 15:
        this.dataset = (JRFillChartDataset)factory.getXyDataset((JRXyDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getLinePlot((JRLinePlot)chart.getPlot());
        break;
      case 20:
        this.dataset = (JRFillChartDataset)factory.getCategoryDataset((JRCategoryDataset)chart.getDataset());
        this.plot = (JRChartPlot)factory.getAreaPlot((JRAreaPlot)chart.getPlot());
        break;
      default:
        throw new JRRuntimeException("Chart type not supported.");
    } 
    this.titleFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)chart, chart.getTitleFont());
    this.subtitleFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)chart, chart.getSubtitleFont());
    this.legendFont = (JRFont)new JRBaseFont(null, null, (JRStyleContainer)chart, chart.getLegendFont());
    this.evaluationGroup = factory.getGroup(chart.getEvaluationGroup());
    this.customizerClass = chart.getCustomizerClass();
    if (this.customizerClass != null && this.customizerClass.length() > 0) {
      try {
        Class myClass = JRClassLoader.loadClassForName(this.customizerClass);
        this.chartCustomizer = myClass.newInstance();
      } catch (Exception e) {
        throw new JRRuntimeException("Could not create chart customizer instance.", e);
      } 
      if (this.chartCustomizer instanceof JRAbstractChartCustomizer)
        ((JRAbstractChartCustomizer)this.chartCustomizer).init(filler, this); 
    } 
    this.renderType = chart.getRenderType();
    if (this.renderType == null)
      this.renderType = JRProperties.getProperty(getParentProperties(), "net.sf.jasperreports.chart.render.type"); 
  }
  
  public byte getMode() {
    return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
  }
  
  public boolean isShowLegend() {
    return ((JRChart)this.parent).isShowLegend();
  }
  
  public void setShowLegend(boolean isShowLegend) {}
  
  public String getRenderType() {
    return this.renderType;
  }
  
  public void setRenderType(String renderType) {}
  
  public byte getEvaluationTime() {
    return ((JRChart)this.parent).getEvaluationTime();
  }
  
  public JRGroup getEvaluationGroup() {
    return this.evaluationGroup;
  }
  
  public JRBox getBox() {
    return (JRBox)new LineBoxWrapper(getLineBox());
  }
  
  public JRLineBox getLineBox() {
    return ((JRBoxContainer)this.parent).getLineBox();
  }
  
  public byte getBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getPen());
  }
  
  public Byte getOwnBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getPen());
  }
  
  public void setBorder(byte border) {
    JRPenUtil.setLinePenFromPen(border, (JRPen)getLineBox().getPen());
  }
  
  public void setBorder(Byte border) {
    JRPenUtil.setLinePenFromPen(border, (JRPen)getLineBox().getPen());
  }
  
  public Color getBorderColor() {
    return getLineBox().getPen().getLineColor();
  }
  
  public Color getOwnBorderColor() {
    return getLineBox().getPen().getOwnLineColor();
  }
  
  public void setBorderColor(Color borderColor) {
    getLineBox().getPen().setLineColor(borderColor);
  }
  
  public int getPadding() {
    return getLineBox().getPadding().intValue();
  }
  
  public Integer getOwnPadding() {
    return getLineBox().getOwnPadding();
  }
  
  public void setPadding(int padding) {
    getLineBox().setPadding(padding);
  }
  
  public void setPadding(Integer padding) {
    getLineBox().setPadding(padding);
  }
  
  public byte getTopBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getTopPen());
  }
  
  public Byte getOwnTopBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getTopPen());
  }
  
  public void setTopBorder(byte topBorder) {
    JRPenUtil.setLinePenFromPen(topBorder, (JRPen)getLineBox().getTopPen());
  }
  
  public void setTopBorder(Byte topBorder) {
    JRPenUtil.setLinePenFromPen(topBorder, (JRPen)getLineBox().getTopPen());
  }
  
  public Color getTopBorderColor() {
    return getLineBox().getTopPen().getLineColor();
  }
  
  public Color getOwnTopBorderColor() {
    return getLineBox().getTopPen().getOwnLineColor();
  }
  
  public void setTopBorderColor(Color topBorderColor) {
    getLineBox().getTopPen().setLineColor(topBorderColor);
  }
  
  public int getTopPadding() {
    return getLineBox().getTopPadding().intValue();
  }
  
  public Integer getOwnTopPadding() {
    return getLineBox().getOwnTopPadding();
  }
  
  public void setTopPadding(int topPadding) {
    getLineBox().setTopPadding(topPadding);
  }
  
  public void setTopPadding(Integer topPadding) {
    getLineBox().setTopPadding(topPadding);
  }
  
  public byte getLeftBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getLeftPen());
  }
  
  public Byte getOwnLeftBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getLeftPen());
  }
  
  public void setLeftBorder(byte leftBorder) {
    JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)getLineBox().getLeftPen());
  }
  
  public void setLeftBorder(Byte leftBorder) {
    JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)getLineBox().getLeftPen());
  }
  
  public Color getLeftBorderColor() {
    return getLineBox().getLeftPen().getLineColor();
  }
  
  public Color getOwnLeftBorderColor() {
    return getLineBox().getLeftPen().getOwnLineColor();
  }
  
  public void setLeftBorderColor(Color leftBorderColor) {
    getLineBox().getLeftPen().setLineColor(leftBorderColor);
  }
  
  public int getLeftPadding() {
    return getLineBox().getLeftPadding().intValue();
  }
  
  public Integer getOwnLeftPadding() {
    return getLineBox().getOwnLeftPadding();
  }
  
  public void setLeftPadding(int leftPadding) {
    getLineBox().setLeftPadding(leftPadding);
  }
  
  public void setLeftPadding(Integer leftPadding) {
    getLineBox().setLeftPadding(leftPadding);
  }
  
  public byte getBottomBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getBottomPen());
  }
  
  public Byte getOwnBottomBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getBottomPen());
  }
  
  public void setBottomBorder(byte bottomBorder) {
    JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)getLineBox().getBottomPen());
  }
  
  public void setBottomBorder(Byte bottomBorder) {
    JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)getLineBox().getBottomPen());
  }
  
  public Color getBottomBorderColor() {
    return getLineBox().getBottomPen().getLineColor();
  }
  
  public Color getOwnBottomBorderColor() {
    return getLineBox().getBottomPen().getOwnLineColor();
  }
  
  public void setBottomBorderColor(Color bottomBorderColor) {
    getLineBox().getBottomPen().setLineColor(bottomBorderColor);
  }
  
  public int getBottomPadding() {
    return getLineBox().getBottomPadding().intValue();
  }
  
  public Integer getOwnBottomPadding() {
    return getLineBox().getOwnBottomPadding();
  }
  
  public void setBottomPadding(int bottomPadding) {
    getLineBox().setBottomPadding(bottomPadding);
  }
  
  public void setBottomPadding(Integer bottomPadding) {
    getLineBox().setBottomPadding(bottomPadding);
  }
  
  public byte getRightBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)getLineBox().getRightPen());
  }
  
  public Byte getOwnRightBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)getLineBox().getRightPen());
  }
  
  public void setRightBorder(byte rightBorder) {
    JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)getLineBox().getRightPen());
  }
  
  public void setRightBorder(Byte rightBorder) {
    JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)getLineBox().getRightPen());
  }
  
  public Color getRightBorderColor() {
    return getLineBox().getRightPen().getLineColor();
  }
  
  public Color getOwnRightBorderColor() {
    return getLineBox().getRightPen().getOwnLineColor();
  }
  
  public void setRightBorderColor(Color rightBorderColor) {
    getLineBox().getRightPen().setLineColor(rightBorderColor);
  }
  
  public int getRightPadding() {
    return getLineBox().getRightPadding().intValue();
  }
  
  public Integer getOwnRightPadding() {
    return getLineBox().getOwnRightPadding();
  }
  
  public void setRightPadding(int rightPadding) {
    getLineBox().setRightPadding(rightPadding);
  }
  
  public void setRightPadding(Integer rightPadding) {
    getLineBox().setRightPadding(rightPadding);
  }
  
  public JRFont getTitleFont() {
    return this.titleFont;
  }
  
  public byte getTitlePosition() {
    return ((JRChart)this.parent).getTitlePosition();
  }
  
  public void setTitlePosition(byte titlePosition) {}
  
  public Color getTitleColor() {
    return JRStyleResolver.getTitleColor(this);
  }
  
  public Color getOwnTitleColor() {
    return ((JRChart)this.parent).getOwnTitleColor();
  }
  
  public void setTitleColor(Color titleColor) {}
  
  public JRFont getSubtitleFont() {
    return this.subtitleFont;
  }
  
  public Color getOwnSubtitleColor() {
    return ((JRChart)this.parent).getOwnSubtitleColor();
  }
  
  public Color getSubtitleColor() {
    return JRStyleResolver.getSubtitleColor(this);
  }
  
  public void setSubtitleColor(Color subtitleColor) {}
  
  public Color getOwnLegendColor() {
    return ((JRChart)this.parent).getOwnLegendColor();
  }
  
  public Color getLegendColor() {
    return JRStyleResolver.getLegendColor(this);
  }
  
  public void setLegendColor(Color legendColor) {}
  
  public Color getOwnLegendBackgroundColor() {
    return ((JRChart)this.parent).getOwnLegendBackgroundColor();
  }
  
  public Color getLegendBackgroundColor() {
    return JRStyleResolver.getLegendBackgroundColor(this);
  }
  
  public void setLegendBackgroundColor(Color legendBackgroundColor) {}
  
  public JRFont getLegendFont() {
    return this.legendFont;
  }
  
  public byte getLegendPosition() {
    return ((JRChart)this.parent).getLegendPosition();
  }
  
  public void setLegendPosition(byte legendPosition) {}
  
  public JRExpression getTitleExpression() {
    return ((JRChart)this.parent).getTitleExpression();
  }
  
  public JRExpression getSubtitleExpression() {
    return ((JRChart)this.parent).getSubtitleExpression();
  }
  
  public byte getHyperlinkType() {
    return ((JRChart)this.parent).getHyperlinkType();
  }
  
  public byte getHyperlinkTarget() {
    return ((JRChart)this.parent).getHyperlinkTarget();
  }
  
  public JRExpression getAnchorNameExpression() {
    return ((JRChart)this.parent).getAnchorNameExpression();
  }
  
  public JRExpression getHyperlinkReferenceExpression() {
    return ((JRChart)this.parent).getHyperlinkReferenceExpression();
  }
  
  public JRExpression getHyperlinkAnchorExpression() {
    return ((JRChart)this.parent).getHyperlinkAnchorExpression();
  }
  
  public JRExpression getHyperlinkPageExpression() {
    return ((JRChart)this.parent).getHyperlinkPageExpression();
  }
  
  public JRChartDataset getDataset() {
    return this.dataset;
  }
  
  public void setDataset(JRFillChartDataset dataset) {
    this.dataset = dataset;
  }
  
  public JRChartPlot getPlot() {
    return this.plot;
  }
  
  protected JRRenderable getRenderer() {
    return this.renderer;
  }
  
  protected String getAnchorName() {
    return this.anchorName;
  }
  
  protected String getHyperlinkReference() {
    return this.hyperlinkReference;
  }
  
  protected String getHyperlinkAnchor() {
    return this.hyperlinkAnchor;
  }
  
  protected Integer getHyperlinkPage() {
    return this.hyperlinkPage;
  }
  
  protected String getHyperlinkTooltip() {
    return this.hyperlinkTooltip;
  }
  
  public Color getDefaultLineColor() {
    return getForecolor();
  }
  
  protected JRTemplateImage getJRTemplateImage() {
    JRStyle style = getStyle();
    JRTemplateImage template = (JRTemplateImage)getTemplate(style);
    if (template == null) {
      template = new JRTemplateImage(this.band.getOrigin(), this.filler.getJasperPrint().getDefaultStyleProvider(), this);
      transferProperties(template);
      registerTemplate(style, template);
    } 
    return template;
  }
  
  protected void rewind() {}
  
  protected void evaluate(byte evaluation) throws JRException {
    reset();
    evaluatePrintWhenExpression(evaluation);
    if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue()))
      if (getEvaluationTime() == 1)
        evaluateRenderer(evaluation);  
  }
  
  protected void evaluateRenderer(byte evaluation) throws JRException {
    evaluateChart(evaluation);
    Rectangle2D rectangle = new Rectangle2D.Double(0.0D, 0.0D, getWidth(), getHeight());
    this.renderer = getChartRendererFactory(getRenderType()).getRenderer(this.chart, this.chartHyperlinkProvider, rectangle);
  }
  
  protected static ChartRendererFactory getChartRendererFactory(String renderType) {
    ChartRendererFactory chartRendererFactory = null;
    String factoryClass = JRProperties.getProperty("net.sf.jasperreports.chart.renderer.factory." + renderType);
    if (factoryClass == null)
      throw new JRRuntimeException("No chart renderer factory specifyed for '" + renderType + "' render type."); 
    try {
      chartRendererFactory = (ChartRendererFactory)chartRendererFactoryCache.getCachedInstance(factoryClass);
    } catch (JRException e) {
      throw new JRRuntimeException(e);
    } 
    return chartRendererFactory;
  }
  
  protected JFreeChart evaluateChart(byte evaluation) throws JRException {
    evaluateProperties(evaluation);
    evaluateDatasetRun(evaluation);
    switch (this.chartType) {
      case 1:
        evaluateAreaChart(evaluation);
        break;
      case 3:
        evaluateBarChart(evaluation);
        break;
      case 2:
        evaluateBar3DChart(evaluation);
        break;
      case 4:
        evaluateBubbleChart(evaluation);
        break;
      case 5:
        evaluateCandlestickChart(evaluation);
        break;
      case 6:
        evaluateHighLowChart(evaluation);
        break;
      case 7:
        evaluateLineChart(evaluation);
        break;
      case 17:
        evaluateMeterChart(evaluation);
        break;
      case 19:
        evaluateMultiAxisChart(evaluation);
        break;
      case 9:
        evaluatePieChart(evaluation);
        break;
      case 8:
        evaluatePie3DChart(evaluation);
        break;
      case 10:
        evaluateScatterChart(evaluation);
        break;
      case 12:
        evaluateStackedBarChart(evaluation);
        break;
      case 11:
        evaluateStackedBar3DChart(evaluation);
        break;
      case 18:
        evaluateThermometerChart(evaluation);
        break;
      case 16:
        evaluateTimeSeriesChart(evaluation);
        break;
      case 13:
        evaluateXyAreaChart(evaluation);
        break;
      case 14:
        evaluateXYBarChart(evaluation);
        break;
      case 15:
        evaluateXyLineChart(evaluation);
        break;
      case 20:
        evaluateStackedAreaChart(evaluation);
        break;
      default:
        throw new JRRuntimeException("Chart type " + getChartType() + " not supported.");
    } 
    if (this.chartCustomizer != null)
      this.chartCustomizer.customize(this.chart, this); 
    this.anchorName = (String)evaluateExpression(getAnchorNameExpression(), evaluation);
    this.hyperlinkReference = (String)evaluateExpression(getHyperlinkReferenceExpression(), evaluation);
    this.hyperlinkAnchor = (String)evaluateExpression(getHyperlinkAnchorExpression(), evaluation);
    this.hyperlinkPage = (Integer)evaluateExpression(getHyperlinkPageExpression(), evaluation);
    this.hyperlinkTooltip = (String)evaluateExpression(getHyperlinkTooltipExpression(), evaluation);
    this.hyperlinkParameters = JRFillHyperlinkHelper.evaluateHyperlinkParameters((JRHyperlink)this, this.expressionEvaluator, evaluation);
    return this.chart;
  }
  
  protected boolean prepare(int availableStretchHeight, boolean isOverflow) {
    boolean willOverflow = false;
    if (isPrintWhenExpressionNull() || (!isPrintWhenExpressionNull() && isPrintWhenTrue())) {
      setToPrint(true);
    } else {
      setToPrint(false);
    } 
    if (!isToPrint())
      return willOverflow; 
    boolean isToPrint = true;
    boolean isReprinted = false;
    if (getEvaluationTime() == 1) {
      if (isOverflow && isAlreadyPrinted() && !isPrintWhenDetailOverflows())
        isToPrint = false; 
      if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
        isToPrint = false;
        willOverflow = true;
      } 
      if (isToPrint && isOverflow && isPrintWhenDetailOverflows() && (isAlreadyPrinted() || (!isAlreadyPrinted() && !isPrintRepeatedValues())))
        isReprinted = true; 
      if (isToPrint && isRemoveLineWhenBlank() && getRenderer() == null)
        isToPrint = false; 
    } else {
      if (isOverflow && isAlreadyPrinted() && !isPrintWhenDetailOverflows())
        isToPrint = false; 
      if (isToPrint && availableStretchHeight < getRelativeY() - getY() - getBandBottomY()) {
        isToPrint = false;
        willOverflow = true;
      } 
      if (isToPrint && isOverflow && isPrintWhenDetailOverflows() && (isAlreadyPrinted() || (!isAlreadyPrinted() && !isPrintRepeatedValues())))
        isReprinted = true; 
    } 
    setToPrint(isToPrint);
    setReprinted(isReprinted);
    return willOverflow;
  }
  
  protected JRPrintElement fill() {
    JRTemplatePrintImage printImage = new JRTemplatePrintImage(getJRTemplateImage());
    printImage.setX(getX());
    printImage.setY(getRelativeY());
    printImage.setWidth(getWidth());
    printImage.setHeight(getStretchHeight());
    byte evaluationType = getEvaluationTime();
    if (evaluationType == 1) {
      copy(printImage);
    } else {
      this.filler.addBoundElement(this, printImage, evaluationType, getEvaluationGroup(), this.band);
    } 
    return printImage;
  }
  
  protected void copy(JRPrintImage printImage) {
    printImage.setRenderer(getRenderer());
    printImage.setAnchorName(getAnchorName());
    printImage.setHyperlinkReference(getHyperlinkReference());
    printImage.setHyperlinkAnchor(getHyperlinkAnchor());
    printImage.setHyperlinkPage(getHyperlinkPage());
    printImage.setHyperlinkTooltip(getHyperlinkTooltip());
    printImage.setBookmarkLevel(getBookmarkLevel());
    printImage.setHyperlinkParameters(this.hyperlinkParameters);
    transferProperties((JRPrintElement)printImage);
  }
  
  public byte getChartType() {
    return this.chartType;
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public void visit(JRVisitor visitor) {
    visitor.visitChart(this);
  }
  
  private void configureChart(JRChartPlot jrPlot, byte evaluation) throws JRException {
    if (getMode() == 1) {
      this.chart.setBackgroundPaint(getBackcolor());
    } else {
      this.chart.setBackgroundPaint(TRANSPARENT_PAINT);
    } 
    RectangleEdge titleEdge = getEdge(getTitlePosition());
    if (this.chart.getTitle() != null) {
      TextTitle title = this.chart.getTitle();
      title.setPaint(getTitleColor());
      title.setFont(new Font(JRFontUtil.getAttributes(getTitleFont())));
      title.setPosition(titleEdge);
    } 
    String subtitleText = (String)evaluateExpression(getSubtitleExpression(), evaluation);
    if (subtitleText != null) {
      TextTitle subtitle = new TextTitle(subtitleText);
      subtitle.setPaint(getSubtitleColor());
      subtitle.setFont(new Font(JRFontUtil.getAttributes(getSubtitleFont())));
      subtitle.setPosition(titleEdge);
      this.chart.addSubtitle((Title)subtitle);
    } 
    LegendTitle legend = this.chart.getLegend();
    if (legend != null) {
      legend.setItemPaint(getLegendColor());
      if (getOwnLegendBackgroundColor() == null) {
        legend.setBackgroundPaint(TRANSPARENT_PAINT);
      } else {
        legend.setBackgroundPaint(getLegendBackgroundColor());
      } 
      this.chart.getLegend().setItemFont(new Font(JRFontUtil.getAttributes(getLegendFont())));
      this.chart.getLegend().setPosition(getEdge(getLegendPosition()));
    } 
    configurePlot(this.chart.getPlot(), jrPlot);
  }
  
  private void configurePlot(Plot p, JRChartPlot jrPlot) {
    p.setOutlinePaint(TRANSPARENT_PAINT);
    if (getPlot().getOwnBackcolor() == null) {
      p.setBackgroundPaint(TRANSPARENT_PAINT);
    } else {
      p.setBackgroundPaint(getPlot().getBackcolor());
    } 
    p.setBackgroundAlpha(getPlot().getBackgroundAlpha());
    p.setForegroundAlpha(getPlot().getForegroundAlpha());
    SortedSet seriesColors = getPlot().getSeriesColors();
    if (p instanceof CategoryPlot) {
      CategoryAxis axis = ((CategoryPlot)p).getDomainAxis();
      double labelRotation = getPlot().getLabelRotation();
      if (labelRotation == 90.0D) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
      } else if (labelRotation == -90.0D) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
      } else if (labelRotation < 0.0D) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(-labelRotation / 180.0D * Math.PI));
      } else if (labelRotation > 0.0D) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(labelRotation / 180.0D * Math.PI));
      } 
    } 
    if (seriesColors != null)
      if (seriesColors.size() == 1) {
        Paint[] colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + 1];
        colors[0] = ((JRChartPlot.JRSeriesColor)seriesColors.first()).getColor();
        for (int i = 0; i < DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length; i++)
          colors[i + 1] = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i]; 
        p.setDrawingSupplier((DrawingSupplier)new DefaultDrawingSupplier(colors, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
      } else if (seriesColors.size() > 1) {
        Color[] colors = new Color[seriesColors.size()];
        JRChartPlot.JRSeriesColor[] colorSequence = new JRChartPlot.JRSeriesColor[seriesColors.size()];
        seriesColors.toArray((Object[])colorSequence);
        for (int i = 0; i < colorSequence.length; i++)
          colors[i] = colorSequence[i].getColor(); 
        p.setDrawingSupplier((DrawingSupplier)new DefaultDrawingSupplier((Paint[])colors, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
      }  
  }
  
  private void configureAxisSeriesColors(CategoryItemRenderer renderer, JRChartPlot jrPlot) {
    SortedSet seriesColors = jrPlot.getSeriesColors();
    if (seriesColors != null) {
      Iterator iter = seriesColors.iterator();
      while (iter.hasNext()) {
        JRChartPlot.JRSeriesColor seriesColor = iter.next();
        renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor());
      } 
    } 
  }
  
  private void configureAxisSeriesColors(XYItemRenderer renderer, JRChartPlot jrPlot) {
    SortedSet seriesColors = jrPlot.getSeriesColors();
    if (seriesColors != null) {
      Iterator iter = seriesColors.iterator();
      while (iter.hasNext()) {
        JRChartPlot.JRSeriesColor seriesColor = iter.next();
        renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor());
      } 
    } 
  }
  
  private void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont, Color tickLabelColor, String tickLabelMask, Color lineColor) {
    axis.setLabelFont(new Font(JRFontUtil.getAttributes(labelFont)));
    axis.setTickLabelFont(new Font(JRFontUtil.getAttributes(tickLabelFont)));
    if (labelColor != null)
      axis.setLabelPaint(labelColor); 
    if (tickLabelColor != null)
      axis.setTickLabelPaint(tickLabelColor); 
    if (lineColor != null) {
      axis.setAxisLinePaint(lineColor);
      axis.setTickMarkPaint(lineColor);
    } 
    if (tickLabelMask != null)
      if (axis instanceof NumberAxis) {
        NumberFormat fmt = NumberFormat.getInstance();
        if (fmt instanceof DecimalFormat)
          ((DecimalFormat)fmt).applyPattern(tickLabelMask); 
        ((NumberAxis)axis).setNumberFormatOverride(fmt);
      } else if (axis instanceof DateAxis) {
        DateFormat fmt = null;
        if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) {
          fmt = DateFormat.getDateInstance(3);
        } else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) {
          fmt = DateFormat.getDateInstance(2);
        } else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) {
          fmt = DateFormat.getDateInstance(1);
        } else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) {
          fmt = DateFormat.getDateInstance(0);
        } else {
          fmt = new SimpleDateFormat(tickLabelMask);
        } 
        ((DateAxis)axis).setDateFormatOverride(fmt);
      }  
  }
  
  protected void evaluateAreaChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createAreaChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (CategoryDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    JRFillAreaPlot areaPlot = (JRFillAreaPlot)getPlot();
    configureAxis((Axis)((CategoryPlot)this.chart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisLineColor());
    configureAxis((Axis)((CategoryPlot)this.chart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateBar3DChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createBarChart3D((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (CategoryDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    CategoryPlot categoryPlot = (CategoryPlot)this.chart.getPlot();
    JRFillBar3DPlot bar3DPlot = (JRFillBar3DPlot)getPlot();
    BarRenderer3D barRenderer3D = new BarRenderer3D(bar3DPlot.getXOffset(), bar3DPlot.getYOffset());
    categoryPlot.setRenderer((CategoryItemRenderer)barRenderer3D);
    barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)((JRFillCategoryDataset)getDataset()).getLabelGenerator());
    barRenderer3D.setItemLabelsVisible(bar3DPlot.isShowLabels());
    configureAxis((Axis)categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisLineColor());
    configureAxis((Axis)categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateBarChart(byte evaluation) throws JRException {
    CategoryDataset categoryDataset = (CategoryDataset)this.dataset.getDataset();
    this.chart = ChartFactory.createBarChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression(), evaluation), categoryDataset, getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    CategoryPlot categoryPlot = (CategoryPlot)this.chart.getPlot();
    JRFillBarPlot barPlot = (JRFillBarPlot)getPlot();
    categoryPlot.getDomainAxis().setTickMarksVisible(barPlot.isShowTickMarks());
    categoryPlot.getDomainAxis().setTickLabelsVisible(barPlot.isShowTickLabels());
    configureAxis((Axis)categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisLineColor());
    ((NumberAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(barPlot.isShowTickMarks());
    ((NumberAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(barPlot.isShowTickLabels());
    configureAxis((Axis)categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisLineColor());
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)((JRFillCategoryDataset)getDataset()).getLabelGenerator());
    categoryRenderer.setItemLabelsVisible(barPlot.isShowLabels());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateBubbleChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createBubbleChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRBubblePlot)getPlot()).getXAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRBubblePlot)getPlot()).getYAxisLabelExpression(), evaluation), (XYZDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    XYPlot xyPlot = (XYPlot)this.chart.getPlot();
    JRBubblePlot bubblePlot = (JRBubblePlot)getPlot();
    XYBubbleRenderer bubbleRenderer = new XYBubbleRenderer(bubblePlot.getScaleType());
    xyPlot.setRenderer((XYItemRenderer)bubbleRenderer);
    configureAxis((Axis)xyPlot.getDomainAxis(), bubblePlot.getXAxisLabelFont(), bubblePlot.getXAxisLabelColor(), bubblePlot.getXAxisTickLabelFont(), bubblePlot.getXAxisTickLabelColor(), bubblePlot.getXAxisTickLabelMask(), bubblePlot.getXAxisLineColor());
    configureAxis((Axis)xyPlot.getRangeAxis(), bubblePlot.getYAxisLabelFont(), bubblePlot.getYAxisLabelColor(), bubblePlot.getYAxisTickLabelFont(), bubblePlot.getYAxisTickLabelColor(), bubblePlot.getYAxisTickLabelMask(), bubblePlot.getYAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new XYChartHyperlinkProvider(((JRFillXyzDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateCandlestickChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createCandlestickChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRCandlestickPlot)getPlot()).getTimeAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRCandlestickPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (OHLCDataset)this.dataset.getDataset(), isShowLegend());
    configureChart(getPlot(), evaluation);
    XYPlot xyPlot = (XYPlot)this.chart.getPlot();
    JRCandlestickPlot candlestickPlot = (JRCandlestickPlot)getPlot();
    CandlestickRenderer candlestickRenderer = (CandlestickRenderer)xyPlot.getRenderer();
    candlestickRenderer.setDrawVolume(candlestickPlot.isShowVolume());
    configureAxis((Axis)xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(), candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(), candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(), candlestickPlot.getTimeAxisLineColor());
    configureAxis((Axis)xyPlot.getRangeAxis(), candlestickPlot.getValueAxisLabelFont(), candlestickPlot.getValueAxisLabelColor(), candlestickPlot.getValueAxisTickLabelFont(), candlestickPlot.getValueAxisTickLabelColor(), candlestickPlot.getValueAxisTickLabelMask(), candlestickPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new HighLowChartHyperlinkProvider(((JRFillHighLowDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateHighLowChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createHighLowChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRHighLowPlot)getPlot()).getTimeAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRHighLowPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (OHLCDataset)this.dataset.getDataset(), isShowLegend());
    configureChart(getPlot(), evaluation);
    XYPlot xyPlot = (XYPlot)this.chart.getPlot();
    JRHighLowPlot highLowPlot = (JRHighLowPlot)getPlot();
    HighLowRenderer hlRenderer = (HighLowRenderer)xyPlot.getRenderer();
    hlRenderer.setDrawOpenTicks(highLowPlot.isShowOpenTicks());
    hlRenderer.setDrawCloseTicks(highLowPlot.isShowCloseTicks());
    configureAxis((Axis)xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(), highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(), highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(), highLowPlot.getTimeAxisLineColor());
    configureAxis((Axis)xyPlot.getRangeAxis(), highLowPlot.getValueAxisLabelFont(), highLowPlot.getValueAxisLabelColor(), highLowPlot.getValueAxisTickLabelFont(), highLowPlot.getValueAxisTickLabelColor(), highLowPlot.getValueAxisTickLabelMask(), highLowPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new HighLowChartHyperlinkProvider(((JRFillHighLowDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateLineChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createLineChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRLinePlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRLinePlot)getPlot()).getValueAxisLabelExpression(), evaluation), (CategoryDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    CategoryPlot categoryPlot = (CategoryPlot)this.chart.getPlot();
    JRFillLinePlot linePlot = (JRFillLinePlot)getPlot();
    LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
    lineRenderer.setShapesVisible(linePlot.isShowShapes());
    lineRenderer.setLinesVisible(linePlot.isShowLines());
    configureAxis((Axis)categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisLineColor());
    configureAxis((Axis)categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluatePie3DChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createPieChart3D((String)evaluateExpression(getTitleExpression(), evaluation), (PieDataset)this.dataset.getDataset(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    PiePlot3D piePlot3D = (PiePlot3D)this.chart.getPlot();
    piePlot3D.setDepthFactor(((JRFillPie3DPlot)getPlot()).getDepthFactor());
    piePlot3D.setCircular(((JRFillPie3DPlot)getPlot()).isCircular());
    PieLabelGenerator pieLabelGenerator = ((JRFillPieDataset)getDataset()).getLabelGenerator();
    if (pieLabelGenerator != null)
      piePlot3D.setLabelGenerator((PieSectionLabelGenerator)pieLabelGenerator); 
    piePlot3D.setLabelFont(new Font(JRFontUtil.getAttributes((JRFont)new JRBaseFont(null, null, (JRStyleContainer)this, null))));
    piePlot3D.setLabelPaint(getForecolor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new PieChartHyperlinkProvider(((JRFillPieDataset)getDataset()).getSectionHyperlinks());
  }
  
  protected void evaluatePieChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createPieChart((String)evaluateExpression(getTitleExpression(), evaluation), (PieDataset)this.dataset.getDataset(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    PiePlot piePlot = (PiePlot)this.chart.getPlot();
    piePlot.setCircular(((JRFillPiePlot)getPlot()).isCircular());
    PieLabelGenerator pieLabelGenerator = ((JRFillPieDataset)getDataset()).getLabelGenerator();
    if (pieLabelGenerator != null)
      piePlot.setLabelGenerator((PieSectionLabelGenerator)pieLabelGenerator); 
    piePlot.setLabelFont(new Font(JRFontUtil.getAttributes((JRFont)new JRBaseFont(null, null, (JRStyleContainer)this, null))));
    piePlot.setLabelPaint(getForecolor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new PieChartHyperlinkProvider(((JRFillPieDataset)getDataset()).getSectionHyperlinks());
  }
  
  protected void evaluateScatterChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createScatterPlot((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRScatterPlot)getPlot()).getXAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRScatterPlot)getPlot()).getYAxisLabelExpression(), evaluation), (XYDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    XYLineAndShapeRenderer plotRenderer = (XYLineAndShapeRenderer)((XYPlot)this.chart.getPlot()).getRenderer();
    JRScatterPlot scatterPlot = (JRScatterPlot)getPlot();
    plotRenderer.setLinesVisible(scatterPlot.isShowLines());
    plotRenderer.setShapesVisible(scatterPlot.isShowShapes());
    configureAxis((Axis)this.chart.getXYPlot().getDomainAxis(), scatterPlot.getXAxisLabelFont(), scatterPlot.getXAxisLabelColor(), scatterPlot.getXAxisTickLabelFont(), scatterPlot.getXAxisTickLabelColor(), scatterPlot.getXAxisTickLabelMask(), scatterPlot.getXAxisLineColor());
    configureAxis((Axis)this.chart.getXYPlot().getRangeAxis(), scatterPlot.getYAxisLabelFont(), scatterPlot.getYAxisLabelColor(), scatterPlot.getYAxisTickLabelFont(), scatterPlot.getYAxisTickLabelColor(), scatterPlot.getYAxisTickLabelMask(), scatterPlot.getYAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new XYChartHyperlinkProvider(((JRFillXyDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateStackedBar3DChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createStackedBarChart3D((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (CategoryDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    CategoryPlot categoryPlot = (CategoryPlot)this.chart.getPlot();
    JRFillBar3DPlot bar3DPlot = (JRFillBar3DPlot)getPlot();
    StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D(bar3DPlot.getXOffset(), bar3DPlot.getYOffset());
    categoryPlot.setRenderer((CategoryItemRenderer)stackedBarRenderer3D);
    stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)((JRFillCategoryDataset)getDataset()).getLabelGenerator());
    stackedBarRenderer3D.setItemLabelsVisible(bar3DPlot.isShowLabels());
    configureAxis((Axis)categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(), bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(), bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisLineColor());
    configureAxis((Axis)categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(), bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(), bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateStackedBarChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createStackedBarChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (CategoryDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    CategoryPlot categoryPlot = (CategoryPlot)this.chart.getPlot();
    JRFillBarPlot barPlot = (JRFillBarPlot)getPlot();
    categoryPlot.getDomainAxis().setTickMarksVisible(barPlot.isShowTickMarks());
    categoryPlot.getDomainAxis().setTickLabelsVisible(barPlot.isShowTickLabels());
    ((NumberAxis)categoryPlot.getRangeAxis()).setTickMarksVisible(barPlot.isShowTickMarks());
    ((NumberAxis)categoryPlot.getRangeAxis()).setTickLabelsVisible(barPlot.isShowTickLabels());
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)((JRFillCategoryDataset)getDataset()).getLabelGenerator());
    categoryRenderer.setItemLabelsVisible(((JRFillBarPlot)getPlot()).isShowLabels());
    configureAxis((Axis)categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisLineColor());
    configureAxis((Axis)categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateStackedAreaChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createStackedAreaChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (CategoryDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    JRFillAreaPlot areaPlot = (JRFillAreaPlot)getPlot();
    configureAxis((Axis)((CategoryPlot)this.chart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisLineColor());
    configureAxis((Axis)((CategoryPlot)this.chart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new CategoryChartHyperlinkProvider(((JRFillCategoryDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateXyAreaChart(byte evaluation) throws JRException {
    this.chart = ChartFactory.createXYAreaChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRAreaPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(((JRAreaPlot)getPlot()).getValueAxisLabelExpression(), evaluation), (XYDataset)this.dataset.getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    JRAreaPlot areaPlot = (JRAreaPlot)getPlot();
    configureAxis((Axis)this.chart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisLineColor());
    configureAxis((Axis)this.chart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new XYChartHyperlinkProvider(((JRFillXyDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateXYBarChart(byte evaluation) throws JRException {
    IntervalXYDataset tmpDataset = (IntervalXYDataset)this.dataset.getDataset();
    boolean isDate = true;
    if (this.dataset.getDatasetType() == 3)
      isDate = false; 
    this.chart = ChartFactory.createXYBarChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression(), evaluation), isDate, (String)evaluateExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression(), evaluation), tmpDataset, getPlot().getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    XYPlot xyPlot = (XYPlot)this.chart.getPlot();
    XYItemRenderer itemRenderer = xyPlot.getRenderer();
    if (getDataset().getDatasetType() == 6) {
      itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)((JRFillTimeSeriesDataset)getDataset()).getLabelGenerator());
    } else if (getDataset().getDatasetType() == 5) {
      itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)((JRFillTimePeriodDataset)getDataset()).getLabelGenerator());
    } else if (getDataset().getDatasetType() == 3) {
      itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)((JRFillXyDataset)getDataset()).getLabelGenerator());
    } 
    JRFillBarPlot barPlot = (JRFillBarPlot)getPlot();
    itemRenderer.setBaseItemLabelsVisible(barPlot.isShowLabels());
    configureAxis((Axis)xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(), barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(), barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisLineColor());
    configureAxis((Axis)xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisLineColor());
    if (getDataset().getDatasetType() == 6) {
      this.chartHyperlinkProvider = (ChartHyperlinkProvider)new TimeSeriesChartHyperlinkProvider(((JRFillTimeSeriesDataset)getDataset()).getItemHyperlinks());
    } else if (getDataset().getDatasetType() == 5) {
      this.chartHyperlinkProvider = (ChartHyperlinkProvider)new TimePeriodChartHyperlinkProvider(((JRFillTimePeriodDataset)getDataset()).getItemHyperlinks());
    } else if (getDataset().getDatasetType() == 3) {
      this.chartHyperlinkProvider = (ChartHyperlinkProvider)new XYChartHyperlinkProvider(((JRFillXyDataset)getDataset()).getItemHyperlinks());
    } else {
      this.chartHyperlinkProvider = null;
    } 
  }
  
  protected void evaluateXyLineChart(byte evaluation) throws JRException {
    JRLinePlot linePlot = (JRLinePlot)getPlot();
    this.chart = ChartFactory.createXYLineChart((String)evaluateExpression(getTitleExpression(), evaluation), (String)evaluateExpression(linePlot.getCategoryAxisLabelExpression(), evaluation), (String)evaluateExpression(linePlot.getValueAxisLabelExpression(), evaluation), (XYDataset)this.dataset.getDataset(), linePlot.getOrientation(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    configureAxis((Axis)this.chart.getXYPlot().getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisLineColor());
    configureAxis((Axis)this.chart.getXYPlot().getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisLineColor());
    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer)this.chart.getXYPlot().getRenderer();
    lineRenderer.setShapesVisible(linePlot.isShowShapes());
    lineRenderer.setLinesVisible(linePlot.isShowLines());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new XYChartHyperlinkProvider(((JRFillXyDataset)getDataset()).getItemHyperlinks());
  }
  
  protected void evaluateTimeSeriesChart(byte evaluation) throws JRException {
    String timeAxisLabel = (String)evaluateExpression(((JRTimeSeriesPlot)getPlot()).getTimeAxisLabelExpression(), evaluation);
    String valueAxisLabel = (String)evaluateExpression(((JRTimeSeriesPlot)getPlot()).getValueAxisLabelExpression(), evaluation);
    this.chart = ChartFactory.createTimeSeriesChart((String)evaluateExpression(getTitleExpression(), evaluation), timeAxisLabel, valueAxisLabel, (XYDataset)this.dataset.getDataset(), isShowLegend(), true, false);
    configureChart(getPlot(), evaluation);
    XYPlot xyPlot = (XYPlot)this.chart.getPlot();
    JRTimeSeriesPlot timeSeriesPlot = (JRTimeSeriesPlot)getPlot();
    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer)xyPlot.getRenderer();
    lineRenderer.setLinesVisible(((JRTimeSeriesPlot)getPlot()).isShowLines());
    lineRenderer.setShapesVisible(((JRTimeSeriesPlot)getPlot()).isShowShapes());
    configureAxis((Axis)xyPlot.getDomainAxis(), timeSeriesPlot.getTimeAxisLabelFont(), timeSeriesPlot.getTimeAxisLabelColor(), timeSeriesPlot.getTimeAxisTickLabelFont(), timeSeriesPlot.getTimeAxisTickLabelColor(), timeSeriesPlot.getTimeAxisTickLabelMask(), timeSeriesPlot.getTimeAxisLineColor());
    configureAxis((Axis)xyPlot.getRangeAxis(), timeSeriesPlot.getValueAxisLabelFont(), timeSeriesPlot.getValueAxisLabelColor(), timeSeriesPlot.getValueAxisTickLabelFont(), timeSeriesPlot.getValueAxisTickLabelColor(), timeSeriesPlot.getValueAxisTickLabelMask(), timeSeriesPlot.getValueAxisLineColor());
    this.chartHyperlinkProvider = (ChartHyperlinkProvider)new TimeSeriesChartHyperlinkProvider(((JRFillTimeSeriesDataset)getDataset()).getItemHyperlinks());
  }
  
  protected Range convertRange(JRDataRange dataRange, byte evaluation) throws JRException {
    if (dataRange == null)
      return null; 
    Number low = (Number)evaluateExpression(dataRange.getLowExpression(), evaluation);
    Number high = (Number)evaluateExpression(dataRange.getHighExpression(), evaluation);
    return new Range((low != null) ? low.doubleValue() : 0.0D, (high != null) ? high.doubleValue() : 100.0D);
  }
  
  protected MeterInterval convertInterval(JRMeterInterval interval, byte evaluation) throws JRException {
    String label = interval.getLabel();
    if (label == null)
      label = ""; 
    Range range = convertRange(interval.getDataRange(), evaluation);
    Color color = interval.getBackgroundColor();
    float[] components = color.getRGBColorComponents(null);
    Color alphaColor = new Color(components[0], components[1], components[2], (float)interval.getAlpha());
    return new MeterInterval(label, range, alphaColor, null, alphaColor);
  }
  
  protected void evaluateMeterChart(byte evaluation) throws JRException {
    JRFillMeterPlot jrPlot = (JRFillMeterPlot)getPlot();
    MeterPlot chartPlot = new MeterPlot((ValueDataset)this.dataset.getDataset());
    int shape = jrPlot.getShape();
    if (shape == 0) {
      chartPlot.setDialShape(DialShape.CHORD);
    } else if (shape == 1) {
      chartPlot.setDialShape(DialShape.CIRCLE);
    } else {
      chartPlot.setDialShape(DialShape.PIE);
    } 
    chartPlot.setRange(convertRange(jrPlot.getDataRange(), evaluation));
    chartPlot.setMeterAngle(jrPlot.getMeterAngle());
    String units = jrPlot.getUnits();
    if (units != null && units.length() > 0)
      chartPlot.setUnits(units); 
    chartPlot.setTickSize(jrPlot.getTickInterval());
    Color color = jrPlot.getMeterBackgroundColor();
    if (color != null)
      chartPlot.setDialBackgroundPaint(color); 
    color = jrPlot.getNeedleColor();
    if (color != null)
      chartPlot.setNeedlePaint(color); 
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
      if (display.getColor() != null)
        chartPlot.setValuePaint(display.getColor()); 
      if (display.getMask() != null)
        chartPlot.setTickLabelFormat(new DecimalFormat(display.getMask())); 
      if (display.getFont() != null)
        chartPlot.setValueFont(new Font(JRFontUtil.getAttributes(display.getFont()))); 
    } 
    color = jrPlot.getTickColor();
    if (color != null)
      chartPlot.setTickPaint(color); 
    List intervals = jrPlot.getIntervals();
    if (intervals != null) {
      Iterator iter = intervals.iterator();
      while (iter.hasNext()) {
        JRMeterInterval interval = iter.next();
        chartPlot.addInterval(convertInterval(interval, evaluation));
      } 
    } 
    this.chart = new JFreeChart((String)evaluateExpression(getTitleExpression(), evaluation), null, (Plot)chartPlot, isShowLegend());
    configureChart(getPlot(), evaluation);
    this.chartHyperlinkProvider = null;
  }
  
  protected void evaluateThermometerChart(byte evaluation) throws JRException {
    JRFillThermometerPlot jrPlot = (JRFillThermometerPlot)getPlot();
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)this.dataset.getDataset());
    Range range = convertRange(jrPlot.getDataRange(), evaluation);
    chartPlot.setLowerBound(range.getLowerBound());
    chartPlot.setUpperBound(range.getUpperBound());
    chartPlot.setShowValueLines(jrPlot.isShowValueLines());
    chartPlot.setUnits(0);
    Color color = jrPlot.getMercuryColor();
    if (color != null)
      chartPlot.setMercuryPaint(color); 
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
      if (display.getColor() != null)
        chartPlot.setValuePaint(display.getColor()); 
      if (display.getMask() != null)
        chartPlot.setValueFormat(new DecimalFormat(display.getMask())); 
      if (display.getFont() != null)
        chartPlot.setValueFont(new Font(JRFontUtil.getAttributes(display.getFont()))); 
    } 
    switch (jrPlot.getValueLocation()) {
      case 0:
        chartPlot.setValueLocation(0);
        break;
      case 1:
        chartPlot.setValueLocation(2);
        break;
      case 2:
        chartPlot.setValueLocation(1);
        break;
      default:
        chartPlot.setValueLocation(3);
        break;
    } 
    range = convertRange(jrPlot.getLowRange(), evaluation);
    if (range != null)
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound()); 
    range = convertRange(jrPlot.getMediumRange(), evaluation);
    if (range != null)
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound()); 
    range = convertRange(jrPlot.getHighRange(), evaluation);
    if (range != null)
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound()); 
    this.chart = new JFreeChart((Plot)chartPlot);
    configureChart(getPlot(), evaluation);
    this.chartHyperlinkProvider = null;
  }
  
  protected void evaluateMultiAxisChart(byte evaluation) throws JRException {
    Plot mainPlot = null;
    JRFillMultiAxisPlot jrPlot = (JRFillMultiAxisPlot)getPlot();
    Iterator iter = jrPlot.getAxes().iterator();
    if (iter.hasNext()) {
      JRFillChartAxis axis = iter.next();
      JRFillChart fillChart = axis.getFillChart();
      this.chart = fillChart.evaluateChart(evaluation);
      configureChart(getPlot(), evaluation);
      mainPlot = this.chart.getPlot();
      if (axis.getPosition() == 2) {
        if (mainPlot instanceof CategoryPlot)
          ((CategoryPlot)mainPlot).setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); 
        if (mainPlot instanceof XYPlot)
          ((XYPlot)mainPlot).setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); 
      } else {
        if (mainPlot instanceof CategoryPlot)
          ((CategoryPlot)mainPlot).setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); 
        if (mainPlot instanceof XYPlot)
          ((XYPlot)mainPlot).setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); 
      } 
    } 
    int axisNumber = 0;
    while (iter.hasNext()) {
      axisNumber++;
      JRFillChartAxis chartAxis = iter.next();
      JRFillChart fillChart = chartAxis.getFillChart();
      JFreeChart axisChart = fillChart.evaluateChart(evaluation);
      if (mainPlot instanceof CategoryPlot) {
        CategoryPlot mainCatPlot = (CategoryPlot)mainPlot;
        if (!(axisChart.getPlot() instanceof CategoryPlot))
          throw new JRException("You can not mix plot types in a MultiAxisChart"); 
        CategoryPlot axisPlot = (CategoryPlot)axisChart.getPlot();
        mainCatPlot.setRangeAxis(axisNumber, axisPlot.getRangeAxis());
        if (chartAxis.getPosition() == 2) {
          mainCatPlot.setRangeAxisLocation(axisNumber, AxisLocation.BOTTOM_OR_RIGHT);
        } else {
          mainCatPlot.setRangeAxisLocation(axisNumber, AxisLocation.TOP_OR_LEFT);
        } 
        mainCatPlot.setDataset(axisNumber, axisPlot.getDataset());
        mainCatPlot.mapDatasetToRangeAxis(axisNumber, axisNumber);
        mainCatPlot.setRenderer(axisNumber, axisPlot.getRenderer());
        configureAxisSeriesColors(axisPlot.getRenderer(), fillChart.getPlot());
        continue;
      } 
      if (mainPlot instanceof XYPlot) {
        XYPlot mainXyPlot = (XYPlot)mainPlot;
        if (!(axisChart.getPlot() instanceof XYPlot))
          throw new JRException("You can not mix plot types in a MultiAxisChart"); 
        XYPlot axisPlot = (XYPlot)axisChart.getPlot();
        mainXyPlot.setRangeAxis(axisNumber, axisPlot.getRangeAxis());
        if (chartAxis.getPosition() == 2) {
          mainXyPlot.setRangeAxisLocation(axisNumber, AxisLocation.BOTTOM_OR_RIGHT);
        } else {
          mainXyPlot.setRangeAxisLocation(axisNumber, AxisLocation.TOP_OR_LEFT);
        } 
        mainXyPlot.setDataset(axisNumber, axisPlot.getDataset());
        mainXyPlot.mapDatasetToRangeAxis(axisNumber, axisNumber);
        mainXyPlot.setRenderer(axisNumber, axisPlot.getRenderer());
        configureAxisSeriesColors(axisPlot.getRenderer(), fillChart.getPlot());
        continue;
      } 
      throw new JRException("MultiAxis charts only support Category and XY plots.");
    } 
    this.chartHyperlinkProvider = null;
  }
  
  protected void resolveElement(JRPrintElement element, byte evaluation) throws JRException {
    evaluateRenderer(evaluation);
    copy((JRPrintImage)element);
  }
  
  public int getBookmarkLevel() {
    return ((JRChart)this.parent).getBookmarkLevel();
  }
  
  public String getCustomizerClass() {
    return this.customizerClass;
  }
  
  private void evaluateDatasetRun(byte evaluation) throws JRException {
    this.dataset.evaluateDatasetRun(evaluation);
  }
  
  public JRFillCloneable createClone(JRFillCloneFactory factory) {
    return null;
  }
  
  public JRHyperlinkParameter[] getHyperlinkParameters() {
    return ((JRChart)this.parent).getHyperlinkParameters();
  }
  
  public String getLinkType() {
    return ((JRChart)this.parent).getLinkType();
  }
  
  public JRExpression getHyperlinkTooltipExpression() {
    return ((JRChart)this.parent).getHyperlinkTooltipExpression();
  }
  
  private static RectangleEdge getEdge(byte position) {
    RectangleEdge edge = RectangleEdge.TOP;
    switch (position) {
      case 1:
        edge = RectangleEdge.TOP;
        break;
      case 2:
        edge = RectangleEdge.BOTTOM;
        break;
      case 3:
        edge = RectangleEdge.LEFT;
        break;
      case 4:
        edge = RectangleEdge.RIGHT;
        break;
    } 
    return edge;
  }
}
