package net.sf.jasperreports.crosstabs.design;

import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import net.sf.jasperreports.crosstabs.JRCellContents;
import net.sf.jasperreports.engine.JRBox;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.base.JRBaseLineBox;
import net.sf.jasperreports.engine.design.JRDesignElementGroup;
import net.sf.jasperreports.engine.util.JRBoxUtil;
import net.sf.jasperreports.engine.util.LineBoxWrapper;

public class JRDesignCellContents extends JRDesignElementGroup implements JRCellContents {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_BOX = "box";
  
  public static final String PROPERTY_STYLE = "style";
  
  public static final String PROPERTY_STYLE_NAME_REFERENCE = "styleNameReference";
  
  protected JRDefaultStyleProvider defaultStyleProvider;
  
  protected JRStyle style;
  
  protected String styleNameReference;
  
  protected Byte mode;
  
  private Color backcolor;
  
  private JRLineBox lineBox;
  
  private int width = Integer.MIN_VALUE;
  
  private int height = Integer.MIN_VALUE;
  
  private JRCrosstabOrigin origin;
  
  private JRBox box;
  
  public Color getBackcolor() {
    return this.backcolor;
  }
  
  public void setBackcolor(Color color) {
    Object old = this.backcolor;
    this.backcolor = color;
    getEventSupport().firePropertyChange("backcolor", old, this.backcolor);
  }
  
  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 int getHeight() {
    return this.height;
  }
  
  protected void setHeight(int height) {
    this.height = height;
  }
  
  public int getWidth() {
    return this.width;
  }
  
  protected void setWidth(int width) {
    this.width = width;
  }
  
  public JRDefaultStyleProvider getDefaultStyleProvider() {
    return this.defaultStyleProvider;
  }
  
  public JRStyle getStyle() {
    return this.style;
  }
  
  public void setStyle(JRStyle style) {
    Object old = this.style;
    this.style = style;
    getEventSupport().firePropertyChange("style", old, this.style);
  }
  
  public Byte getMode() {
    return this.mode;
  }
  
  public void setMode(Byte mode) {
    Object old = this.mode;
    this.mode = mode;
    getEventSupport().firePropertyChange("mode", old, this.mode);
  }
  
  public String getStyleNameReference() {
    return this.styleNameReference;
  }
  
  public void setStyleNameReference(String styleName) {
    Object old = this.styleNameReference;
    this.styleNameReference = styleName;
    getEventSupport().firePropertyChange("styleNameReference", old, this.styleNameReference);
  }
  
  public JRCrosstabOrigin getOrigin() {
    return this.origin;
  }
  
  public void setOrigin(JRCrosstabOrigin origin) {
    this.origin = origin;
  }
  
  public Color getDefaultLineColor() {
    return Color.black;
  }
  
  public Object clone() {
    return null;
  }
  
  public JRDesignCellContents() {
    this.box = null;
    this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
  }
  
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    if (this.lineBox == null) {
      this.lineBox = (JRLineBox)new JRBaseLineBox((JRBoxContainer)this);
      JRBoxUtil.setBoxToLineBox(this.box, this.lineBox);
      this.box = null;
    } 
  }
}
