package net.sf.jasperreports.engine.design;

import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import net.sf.jasperreports.charts.design.JRDesignAreaPlot;
import net.sf.jasperreports.charts.design.JRDesignBar3DPlot;
import net.sf.jasperreports.charts.design.JRDesignBarPlot;
import net.sf.jasperreports.charts.design.JRDesignBubblePlot;
import net.sf.jasperreports.charts.design.JRDesignCandlestickPlot;
import net.sf.jasperreports.charts.design.JRDesignCategoryDataset;
import net.sf.jasperreports.charts.design.JRDesignHighLowDataset;
import net.sf.jasperreports.charts.design.JRDesignHighLowPlot;
import net.sf.jasperreports.charts.design.JRDesignLinePlot;
import net.sf.jasperreports.charts.design.JRDesignMeterPlot;
import net.sf.jasperreports.charts.design.JRDesignMultiAxisPlot;
import net.sf.jasperreports.charts.design.JRDesignPie3DPlot;
import net.sf.jasperreports.charts.design.JRDesignPieDataset;
import net.sf.jasperreports.charts.design.JRDesignPiePlot;
import net.sf.jasperreports.charts.design.JRDesignScatterPlot;
import net.sf.jasperreports.charts.design.JRDesignThermometerPlot;
import net.sf.jasperreports.charts.design.JRDesignTimeSeriesDataset;
import net.sf.jasperreports.charts.design.JRDesignTimeSeriesPlot;
import net.sf.jasperreports.charts.design.JRDesignValueDataset;
import net.sf.jasperreports.charts.design.JRDesignXyDataset;
import net.sf.jasperreports.charts.design.JRDesignXyzDataset;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartDataset;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRCommonElement;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
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.JRHyperlinkHelper;
import net.sf.jasperreports.engine.JRHyperlinkParameter;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRVisitor;
import net.sf.jasperreports.engine.base.JRBaseLineBox;
import net.sf.jasperreports.engine.util.JRBoxUtil;
import net.sf.jasperreports.engine.util.JRPenUtil;
import net.sf.jasperreports.engine.util.JRStyleResolver;
import net.sf.jasperreports.engine.util.LineBoxWrapper;

public class JRDesignChart extends JRDesignElement implements JRChart {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_ANCHOR_NAME_EXPRESSION = "anchorNameExpression";
  
  public static final String PROPERTY_BOOKMARK_LEVEL = "bookmarkLevel";
  
  public static final String PROPERTY_EVALUATION_GROUP = "evaluationGroup";
  
  public static final String PROPERTY_EVALUATION_TIME = "evaluationTime";
  
  public static final String PROPERTY_CHART_TYPE = "chartType";
  
  public static final String PROPERTY_CUSTOMIZER_CLASS = "customizerClass";
  
  public static final String PROPERTY_DATASET = "dataset";
  
  public static final String PROPERTY_LEGEND_FONT = "legendFont";
  
  public static final String PROPERTY_SUBTITLE_EXPRESSION = "subtitleExpression";
  
  public static final String PROPERTY_SUBTITLE_FONT = "subtitleFont";
  
  public static final String PROPERTY_TITLE_EXPRESSION = "titleExpression";
  
  public static final String PROPERTY_TITLE_FONT = "titleFont";
  
  protected byte chartType = 0;
  
  protected boolean isShowLegend = false;
  
  protected byte evaluationTime = 1;
  
  protected byte hyperlinkType = 0;
  
  protected String linkType;
  
  protected byte hyperlinkTarget = 1;
  
  protected byte titlePosition = 1;
  
  protected Color titleColor = null;
  
  protected Color subtitleColor = null;
  
  protected Color legendColor = null;
  
  protected Color legendBackgroundColor = null;
  
  protected byte legendPosition = 2;
  
  protected String renderType;
  
  protected JRFont titleFont = null;
  
  protected JRFont subtitleFont = null;
  
  protected JRFont legendFont = null;
  
  protected String customizerClass;
  
  protected JRGroup evaluationGroup = null;
  
  protected JRExpression titleExpression = null;
  
  protected JRExpression subtitleExpression = null;
  
  protected JRExpression anchorNameExpression = null;
  
  protected JRExpression hyperlinkReferenceExpression = null;
  
  protected JRExpression hyperlinkAnchorExpression = null;
  
  protected JRExpression hyperlinkPageExpression = null;
  
  private JRExpression hyperlinkTooltipExpression;
  
  private List hyperlinkParameters;
  
  protected JRChartDataset dataset = null;
  
  protected JRChartPlot plot = null;
  
  protected JRLineBox lineBox;
  
  protected int bookmarkLevel = 0;
  
  private Byte border;
  
  private Byte topBorder;
  
  private Byte leftBorder;
  
  private Byte bottomBorder;
  
  private Byte rightBorder;
  
  private Color borderColor;
  
  private Color topBorderColor;
  
  private Color leftBorderColor;
  
  private Color bottomBorderColor;
  
  private Color rightBorderColor;
  
  private Integer padding;
  
  private Integer topPadding;
  
  private Integer leftPadding;
  
  private Integer bottomPadding;
  
  private Integer rightPadding;
  
  public JRDesignChart(JRDefaultStyleProvider defaultStyleProvider, byte chartType) {
    super(defaultStyleProvider);
    this.border = null;
    this.topBorder = null;
    this.leftBorder = null;
    this.bottomBorder = null;
    this.rightBorder = null;
    this.borderColor = null;
    this.topBorderColor = null;
    this.leftBorderColor = null;
    this.bottomBorderColor = null;
    this.rightBorderColor = null;
    this.padding = null;
    this.topPadding = null;
    this.leftPadding = null;
    this.bottomPadding = null;
    this.rightPadding = null;
    setChartType(chartType);
    this.hyperlinkParameters = new ArrayList();
    this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
  }
  
  public boolean isShowLegend() {
    return this.isShowLegend;
  }
  
  public void setShowLegend(boolean isShowLegend) {
    boolean old = this.isShowLegend;
    this.isShowLegend = isShowLegend;
    getEventSupport().firePropertyChange("showLegend", old, this.isShowLegend);
  }
  
  public String getRenderType() {
    return this.renderType;
  }
  
  public void setRenderType(String renderType) {
    String old = this.renderType;
    this.renderType = renderType;
    getEventSupport().firePropertyChange("renderType", old, this.renderType);
  }
  
  public byte getEvaluationTime() {
    return this.evaluationTime;
  }
  
  public void setEvaluationTime(byte evaluationTime) {
    byte old = this.evaluationTime;
    this.evaluationTime = evaluationTime;
    getEventSupport().firePropertyChange("evaluationTime", old, this.evaluationTime);
  }
  
  public JRGroup getEvaluationGroup() {
    return this.evaluationGroup;
  }
  
  public void setEvaluationGroup(JRGroup group) {
    Object old = this.evaluationGroup;
    this.evaluationGroup = group;
    getEventSupport().firePropertyChange("evaluationGroup", old, this.evaluationGroup);
  }
  
  public JRBox getBox() {
    return (JRBox)new LineBoxWrapper(getLineBox());
  }
  
  public JRLineBox getLineBox() {
    return this.lineBox;
  }
  
  public void setBox(JRBox box) {
    JRBoxUtil.setBoxToLineBox(box, this.lineBox);
  }
  
  public JRFont getTitleFont() {
    return this.titleFont;
  }
  
  public void setTitleFont(JRFont font) {
    Object old = this.titleFont;
    this.titleFont = font;
    getEventSupport().firePropertyChange("titleFont", old, this.titleFont);
  }
  
  public byte getTitlePosition() {
    return this.titlePosition;
  }
  
  public void setTitlePosition(byte titlePosition) {
    byte old = this.titlePosition;
    this.titlePosition = titlePosition;
    getEventSupport().firePropertyChange("titlePosition", old, this.titlePosition);
  }
  
  public Color getTitleColor() {
    return JRStyleResolver.getTitleColor(this);
  }
  
  public Color getOwnTitleColor() {
    return this.titleColor;
  }
  
  public void setTitleColor(Color titleColor) {
    Object old = this.titleColor;
    this.titleColor = titleColor;
    getEventSupport().firePropertyChange("titleColor", old, this.titleColor);
  }
  
  public JRFont getSubtitleFont() {
    return this.subtitleFont;
  }
  
  public void setSubtitleFont(JRFont font) {
    Object old = this.subtitleFont;
    this.subtitleFont = font;
    getEventSupport().firePropertyChange("subtitleFont", old, this.subtitleFont);
  }
  
  public Color getSubtitleColor() {
    return JRStyleResolver.getSubtitleColor(this);
  }
  
  public Color getOwnSubtitleColor() {
    return this.subtitleColor;
  }
  
  public void setSubtitleColor(Color subtitleColor) {
    Object old = this.subtitleColor;
    this.subtitleColor = subtitleColor;
    getEventSupport().firePropertyChange("subtitleColor", old, this.subtitleColor);
  }
  
  public Color getOwnLegendColor() {
    return this.legendColor;
  }
  
  public Color getLegendColor() {
    return JRStyleResolver.getLegendColor(this);
  }
  
  public void setLegendColor(Color legendColor) {
    Object old = this.legendColor;
    this.legendColor = legendColor;
    getEventSupport().firePropertyChange("legendColor", old, this.legendColor);
  }
  
  public Color getOwnLegendBackgroundColor() {
    return this.legendBackgroundColor;
  }
  
  public Color getLegendBackgroundColor() {
    return JRStyleResolver.getLegendBackgroundColor(this);
  }
  
  public void setLegendBackgroundColor(Color legendBackgroundColor) {
    Object old = this.legendBackgroundColor;
    this.legendBackgroundColor = legendBackgroundColor;
    getEventSupport().firePropertyChange("legendBackgroundColor", old, this.legendBackgroundColor);
  }
  
  public JRFont getLegendFont() {
    return this.legendFont;
  }
  
  public void setLegendFont(JRFont legendFont) {
    Object old = this.legendFont;
    this.legendFont = legendFont;
    getEventSupport().firePropertyChange("legendFont", old, this.legendFont);
  }
  
  public byte getLegendPosition() {
    return this.legendPosition;
  }
  
  public void setLegendPosition(byte legendPosition) {
    byte old = this.legendPosition;
    this.legendPosition = legendPosition;
    getEventSupport().firePropertyChange("legendPosition", old, this.legendPosition);
  }
  
  public byte getHyperlinkType() {
    return JRHyperlinkHelper.getHyperlinkType((JRHyperlink)this);
  }
  
  public void setHyperlinkType(byte hyperlinkType) {
    setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType));
  }
  
  public byte getHyperlinkTarget() {
    return this.hyperlinkTarget;
  }
  
  public void setHyperlinkTarget(byte hyperlinkTarget) {
    byte old = this.hyperlinkTarget;
    this.hyperlinkTarget = hyperlinkTarget;
    getEventSupport().firePropertyChange("hyperlinkTarget", old, this.hyperlinkTarget);
  }
  
  public JRExpression getTitleExpression() {
    return this.titleExpression;
  }
  
  public void setTitleExpression(JRExpression expression) {
    Object old = this.titleExpression;
    this.titleExpression = expression;
    getEventSupport().firePropertyChange("titleExpression", old, this.titleExpression);
  }
  
  public JRExpression getSubtitleExpression() {
    return this.subtitleExpression;
  }
  
  public void setSubtitleExpression(JRExpression expression) {
    Object old = this.subtitleExpression;
    this.subtitleExpression = expression;
    getEventSupport().firePropertyChange("subtitleExpression", old, this.subtitleExpression);
  }
  
  public JRExpression getAnchorNameExpression() {
    return this.anchorNameExpression;
  }
  
  public void setAnchorNameExpression(JRExpression anchorNameExpression) {
    Object old = this.anchorNameExpression;
    this.anchorNameExpression = anchorNameExpression;
    getEventSupport().firePropertyChange("anchorNameExpression", old, this.anchorNameExpression);
  }
  
  public JRExpression getHyperlinkReferenceExpression() {
    return this.hyperlinkReferenceExpression;
  }
  
  public void setHyperlinkReferenceExpression(JRExpression hyperlinkReferenceExpression) {
    Object old = this.hyperlinkReferenceExpression;
    this.hyperlinkReferenceExpression = hyperlinkReferenceExpression;
    getEventSupport().firePropertyChange("hyperlinkReferenceExpression", old, this.hyperlinkReferenceExpression);
  }
  
  public JRExpression getHyperlinkAnchorExpression() {
    return this.hyperlinkAnchorExpression;
  }
  
  public void setHyperlinkAnchorExpression(JRExpression hyperlinkAnchorExpression) {
    Object old = this.hyperlinkAnchorExpression;
    this.hyperlinkAnchorExpression = hyperlinkAnchorExpression;
    getEventSupport().firePropertyChange("hyperlinkAnchorExpression", old, this.hyperlinkAnchorExpression);
  }
  
  public JRExpression getHyperlinkPageExpression() {
    return this.hyperlinkPageExpression;
  }
  
  public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression) {
    Object old = this.hyperlinkPageExpression;
    this.hyperlinkPageExpression = hyperlinkPageExpression;
    getEventSupport().firePropertyChange("hyperlinkPageExpression", old, this.hyperlinkPageExpression);
  }
  
  public JRChartDataset getDataset() {
    return this.dataset;
  }
  
  public JRChartPlot getPlot() {
    return this.plot;
  }
  
  public byte getChartType() {
    return this.chartType;
  }
  
  public void setChartType(byte chartType) {
    byte old = this.chartType;
    this.chartType = chartType;
    switch (chartType) {
      case 1:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignAreaPlot(this.plot, this);
        break;
      case 3:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignBarPlot(this.plot, this);
        break;
      case 2:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignBar3DPlot(this.plot, this);
        break;
      case 4:
        this.dataset = (JRChartDataset)new JRDesignXyzDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignBubblePlot(this.plot, this);
        break;
      case 5:
        this.dataset = (JRChartDataset)new JRDesignHighLowDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignCandlestickPlot(this.plot, this);
        break;
      case 6:
        this.dataset = (JRChartDataset)new JRDesignHighLowDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignHighLowPlot(this.plot, this);
        break;
      case 7:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignLinePlot(this.plot, this);
        break;
      case 17:
        this.dataset = (JRChartDataset)new JRDesignValueDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignMeterPlot(this.plot, this);
        break;
      case 19:
        this.plot = (JRChartPlot)new JRDesignMultiAxisPlot(this.plot, this);
        this.dataset = null;
        break;
      case 9:
        this.dataset = (JRChartDataset)new JRDesignPieDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignPiePlot(this.plot, this);
        break;
      case 8:
        this.dataset = (JRChartDataset)new JRDesignPieDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignPie3DPlot(this.plot, this);
        break;
      case 10:
        this.dataset = (JRChartDataset)new JRDesignXyDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignScatterPlot(this.plot, this);
        break;
      case 12:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignBarPlot(this.plot, this);
        break;
      case 11:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignBar3DPlot(this.plot, this);
        break;
      case 18:
        this.dataset = (JRChartDataset)new JRDesignValueDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignThermometerPlot(this.plot, this);
        break;
      case 16:
        this.dataset = (JRChartDataset)new JRDesignTimeSeriesDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignTimeSeriesPlot(this.plot, this);
        break;
      case 13:
        this.dataset = (JRChartDataset)new JRDesignXyDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignAreaPlot(this.plot, this);
        break;
      case 14:
        this.plot = (JRChartPlot)new JRDesignBarPlot(this.plot, this);
        break;
      case 15:
        this.dataset = (JRChartDataset)new JRDesignXyDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignLinePlot(this.plot, this);
        break;
      case 20:
        this.dataset = (JRChartDataset)new JRDesignCategoryDataset(this.dataset);
        this.plot = (JRChartPlot)new JRDesignAreaPlot(this.plot, this);
        break;
      default:
        throw new JRRuntimeException("Chart type not supported.");
    } 
    getEventSupport().firePropertyChange("chartType", old, this.chartType);
  }
  
  public void setDataset(JRChartDataset ds) {
    Object old = this.dataset;
    switch (ds.getDatasetType()) {
      case 2:
        this.dataset = ds;
        break;
      case 7:
        this.dataset = ds;
        break;
      case 1:
        this.dataset = ds;
        break;
      case 5:
        this.dataset = ds;
        break;
      case 6:
        this.dataset = ds;
        break;
      case 8:
        this.dataset = ds;
        break;
      case 3:
        this.dataset = ds;
        break;
      case 4:
        this.dataset = ds;
        break;
    } 
    getEventSupport().firePropertyChange("dataset", old, this.dataset);
  }
  
  public void collectExpressions(JRExpressionCollector collector) {
    collector.collect(this);
  }
  
  public void visit(JRVisitor visitor) {
    visitor.visitChart(this);
  }
  
  public int getBookmarkLevel() {
    return this.bookmarkLevel;
  }
  
  public void setBookmarkLevel(int bookmarkLevel) {
    int old = this.bookmarkLevel;
    this.bookmarkLevel = bookmarkLevel;
    getEventSupport().firePropertyChange("bookmarkLevel", old, this.bookmarkLevel);
  }
  
  public String getCustomizerClass() {
    return this.customizerClass;
  }
  
  public void setCustomizerClass(String customizerClass) {
    Object old = this.customizerClass;
    this.customizerClass = customizerClass;
    getEventSupport().firePropertyChange("customizerClass", old, this.customizerClass);
  }
  
  public byte getMode() {
    return JRStyleResolver.getMode((JRCommonElement)this, (byte)2);
  }
  
  public byte getBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getPen());
  }
  
  public Byte getOwnBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getPen());
  }
  
  public void setBorder(byte border) {
    JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
  }
  
  public void setBorder(Byte border) {
    JRPenUtil.setLinePenFromPen(border, (JRPen)this.lineBox.getPen());
  }
  
  public Color getBorderColor() {
    return this.lineBox.getPen().getLineColor();
  }
  
  public Color getOwnBorderColor() {
    return this.lineBox.getPen().getOwnLineColor();
  }
  
  public void setBorderColor(Color borderColor) {
    this.lineBox.getPen().setLineColor(borderColor);
  }
  
  public int getPadding() {
    return this.lineBox.getPadding().intValue();
  }
  
  public Integer getOwnPadding() {
    return this.lineBox.getOwnPadding();
  }
  
  public void setPadding(int padding) {
    this.lineBox.setPadding(padding);
  }
  
  public void setPadding(Integer padding) {
    this.lineBox.setPadding(padding);
  }
  
  public byte getTopBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getTopPen());
  }
  
  public Byte getOwnTopBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getTopPen());
  }
  
  public void setTopBorder(byte topBorder) {
    JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
  }
  
  public void setTopBorder(Byte topBorder) {
    JRPenUtil.setLinePenFromPen(topBorder, (JRPen)this.lineBox.getTopPen());
  }
  
  public Color getTopBorderColor() {
    return this.lineBox.getTopPen().getLineColor();
  }
  
  public Color getOwnTopBorderColor() {
    return this.lineBox.getTopPen().getOwnLineColor();
  }
  
  public void setTopBorderColor(Color topBorderColor) {
    this.lineBox.getTopPen().setLineColor(topBorderColor);
  }
  
  public int getTopPadding() {
    return this.lineBox.getTopPadding().intValue();
  }
  
  public Integer getOwnTopPadding() {
    return this.lineBox.getOwnTopPadding();
  }
  
  public void setTopPadding(int topPadding) {
    this.lineBox.setTopPadding(topPadding);
  }
  
  public void setTopPadding(Integer topPadding) {
    this.lineBox.setTopPadding(topPadding);
  }
  
  public byte getLeftBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getLeftPen());
  }
  
  public Byte getOwnLeftBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getLeftPen());
  }
  
  public void setLeftBorder(byte leftBorder) {
    JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
  }
  
  public void setLeftBorder(Byte leftBorder) {
    JRPenUtil.setLinePenFromPen(leftBorder, (JRPen)this.lineBox.getLeftPen());
  }
  
  public Color getLeftBorderColor() {
    return this.lineBox.getLeftPen().getLineColor();
  }
  
  public Color getOwnLeftBorderColor() {
    return this.lineBox.getLeftPen().getOwnLineColor();
  }
  
  public void setLeftBorderColor(Color leftBorderColor) {
    this.lineBox.getLeftPen().setLineColor(leftBorderColor);
  }
  
  public int getLeftPadding() {
    return this.lineBox.getLeftPadding().intValue();
  }
  
  public Integer getOwnLeftPadding() {
    return this.lineBox.getOwnLeftPadding();
  }
  
  public void setLeftPadding(int leftPadding) {
    this.lineBox.setLeftPadding(leftPadding);
  }
  
  public void setLeftPadding(Integer leftPadding) {
    this.lineBox.setLeftPadding(leftPadding);
  }
  
  public byte getBottomBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getBottomPen());
  }
  
  public Byte getOwnBottomBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getBottomPen());
  }
  
  public void setBottomBorder(byte bottomBorder) {
    JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
  }
  
  public void setBottomBorder(Byte bottomBorder) {
    JRPenUtil.setLinePenFromPen(bottomBorder, (JRPen)this.lineBox.getBottomPen());
  }
  
  public Color getBottomBorderColor() {
    return this.lineBox.getBottomPen().getLineColor();
  }
  
  public Color getOwnBottomBorderColor() {
    return this.lineBox.getBottomPen().getOwnLineColor();
  }
  
  public void setBottomBorderColor(Color bottomBorderColor) {
    this.lineBox.getBottomPen().setLineColor(bottomBorderColor);
  }
  
  public int getBottomPadding() {
    return this.lineBox.getBottomPadding().intValue();
  }
  
  public Integer getOwnBottomPadding() {
    return this.lineBox.getOwnBottomPadding();
  }
  
  public void setBottomPadding(int bottomPadding) {
    this.lineBox.setBottomPadding(bottomPadding);
  }
  
  public void setBottomPadding(Integer bottomPadding) {
    this.lineBox.setBottomPadding(bottomPadding);
  }
  
  public byte getRightBorder() {
    return JRPenUtil.getPenFromLinePen((JRPen)this.lineBox.getRightPen());
  }
  
  public Byte getOwnRightBorder() {
    return JRPenUtil.getOwnPenFromLinePen((JRPen)this.lineBox.getRightPen());
  }
  
  public void setRightBorder(byte rightBorder) {
    JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
  }
  
  public void setRightBorder(Byte rightBorder) {
    JRPenUtil.setLinePenFromPen(rightBorder, (JRPen)this.lineBox.getRightPen());
  }
  
  public Color getRightBorderColor() {
    return this.lineBox.getRightPen().getLineColor();
  }
  
  public Color getOwnRightBorderColor() {
    return this.lineBox.getRightPen().getOwnLineColor();
  }
  
  public void setRightBorderColor(Color rightBorderColor) {
    this.lineBox.getRightPen().setLineColor(rightBorderColor);
  }
  
  public int getRightPadding() {
    return this.lineBox.getRightPadding().intValue();
  }
  
  public Integer getOwnRightPadding() {
    return this.lineBox.getOwnRightPadding();
  }
  
  public void setRightPadding(int rightPadding) {
    this.lineBox.setRightPadding(rightPadding);
  }
  
  public void setRightPadding(Integer rightPadding) {
    this.lineBox.setRightPadding(rightPadding);
  }
  
  public String getLinkType() {
    return this.linkType;
  }
  
  public void setLinkType(String type) {
    Object old = this.linkType;
    this.linkType = type;
    getEventSupport().firePropertyChange("linkType", old, this.linkType);
  }
  
  public JRHyperlinkParameter[] getHyperlinkParameters() {
    JRHyperlinkParameter[] parameters;
    if (this.hyperlinkParameters.isEmpty()) {
      parameters = null;
    } else {
      parameters = new JRHyperlinkParameter[this.hyperlinkParameters.size()];
      this.hyperlinkParameters.toArray((Object[])parameters);
    } 
    return parameters;
  }
  
  public List getHyperlinkParametersList() {
    return this.hyperlinkParameters;
  }
  
  public void addHyperlinkParameter(JRHyperlinkParameter parameter) {
    this.hyperlinkParameters.add(parameter);
    getEventSupport().fireCollectionElementAddedEvent("hyperlinkParameters", parameter, this.hyperlinkParameters.size() - 1);
  }
  
  public void removeHyperlinkParameter(JRHyperlinkParameter parameter) {
    int idx = this.hyperlinkParameters.indexOf(parameter);
    if (idx >= 0) {
      this.hyperlinkParameters.remove(idx);
      getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, idx);
    } 
  }
  
  public void removeHyperlinkParameter(String parameterName) {
    for (ListIterator it = this.hyperlinkParameters.listIterator(); it.hasNext(); ) {
      JRHyperlinkParameter parameter = it.next();
      if (parameter.getName() != null && parameter.getName().equals(parameterName)) {
        it.remove();
        getEventSupport().fireCollectionElementRemovedEvent("hyperlinkParameters", parameter, it.nextIndex());
      } 
    } 
  }
  
  protected void normalizeLinkType() {
    if (this.linkType == null)
      this.linkType = JRHyperlinkHelper.getLinkType(this.hyperlinkType); 
    this.hyperlinkType = 0;
  }
  
  public JRExpression getHyperlinkTooltipExpression() {
    return this.hyperlinkTooltipExpression;
  }
  
  public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression) {
    Object old = this.hyperlinkTooltipExpression;
    this.hyperlinkTooltipExpression = hyperlinkTooltipExpression;
    getEventSupport().firePropertyChange("hyperlinkTooltipExpression", old, this.hyperlinkTooltipExpression);
  }
  
  public Color getDefaultLineColor() {
    return getForecolor();
  }
  
  public Object clone() {
    JRDesignChart clone = (JRDesignChart)super.clone();
    if (this.hyperlinkParameters != null) {
      clone.hyperlinkParameters = new ArrayList(this.hyperlinkParameters.size());
      for (int i = 0; i < this.hyperlinkParameters.size(); i++)
        clone.hyperlinkParameters.add(((JRHyperlinkParameter)this.hyperlinkParameters.get(i)).clone()); 
    } 
    if (this.titleExpression != null)
      clone.titleExpression = (JRExpression)this.titleExpression.clone(); 
    if (this.subtitleExpression != null)
      clone.subtitleExpression = (JRExpression)this.subtitleExpression.clone(); 
    if (this.anchorNameExpression != null)
      clone.anchorNameExpression = (JRExpression)this.anchorNameExpression.clone(); 
    if (this.hyperlinkReferenceExpression != null)
      clone.hyperlinkReferenceExpression = (JRExpression)this.hyperlinkReferenceExpression.clone(); 
    if (this.hyperlinkAnchorExpression != null)
      clone.hyperlinkAnchorExpression = (JRExpression)this.hyperlinkAnchorExpression.clone(); 
    if (this.hyperlinkPageExpression != null)
      clone.hyperlinkPageExpression = (JRExpression)this.hyperlinkPageExpression.clone(); 
    if (this.hyperlinkTooltipExpression != null)
      clone.hyperlinkTooltipExpression = (JRExpression)this.hyperlinkTooltipExpression.clone(); 
    if (this.dataset != null)
      clone.dataset = (JRChartDataset)this.dataset.clone(); 
    if (this.plot != null)
      clone.plot = (JRChartPlot)this.plot.clone(clone); 
    return clone;
  }
  
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    if (this.lineBox == null) {
      this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
      JRBoxUtil.setToBox(this.border, this.topBorder, this.leftBorder, this.bottomBorder, this.rightBorder, this.borderColor, this.topBorderColor, this.leftBorderColor, this.bottomBorderColor, this.rightBorderColor, this.padding, this.topPadding, this.leftPadding, this.bottomPadding, this.rightPadding, this.lineBox);
      this.border = null;
      this.topBorder = null;
      this.leftBorder = null;
      this.bottomBorder = null;
      this.rightBorder = null;
      this.borderColor = null;
      this.topBorderColor = null;
      this.leftBorderColor = null;
      this.bottomBorderColor = null;
      this.rightBorderColor = null;
      this.padding = null;
      this.topPadding = null;
      this.leftPadding = null;
      this.bottomPadding = null;
      this.rightPadding = null;
    } 
    normalizeLinkType();
  }
}
