package net.sf.jasperreports.engine.base;

import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import net.sf.jasperreports.engine.JRAbstractObjectFactory;
import net.sf.jasperreports.engine.JRBoxContainer;
import net.sf.jasperreports.engine.JRConditionalStyle;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.JRLineBox;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.JRPenContainer;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRStyle;
import net.sf.jasperreports.engine.JRStyleContainer;
import net.sf.jasperreports.engine.JRStyleSetter;
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;
import net.sf.jasperreports.engine.util.JRBoxUtil;
import net.sf.jasperreports.engine.util.JRPenUtil;
import net.sf.jasperreports.engine.util.JRStyleResolver;

public class JRBaseStyle implements JRStyle, Serializable, JRChangeEventsSupport {
  private static final long serialVersionUID = 10001L;
  
  public static final String PROPERTY_BACKCOLOR = "backcolor";
  
  public static final String PROPERTY_BLANK_WHEN_NULL = "blankWhenNull";
  
  public static final String PROPERTY_BOLD = "bold";
  
  public static final String PROPERTY_FILL = "fill";
  
  public static final String PROPERTY_FONT_NAME = "fontName";
  
  public static final String PROPERTY_FONT_SIZE = "fontSize";
  
  public static final String PROPERTY_FORECOLOR = "forecolor";
  
  public static final String PROPERTY_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
  
  public static final String PROPERTY_ITALIC = "italic";
  
  public static final String PROPERTY_LINE_SPACING = "lineSpacing";
  
  public static final String PROPERTY_MODE = "mode";
  
  public static final String PROPERTY_PATTERN = "pattern";
  
  public static final String PROPERTY_PDF_EMBEDDED = "pdfEmbedded";
  
  public static final String PROPERTY_PDF_ENCODING = "pdfEncoding";
  
  public static final String PROPERTY_PDF_FONT_NAME = "pdfFontName";
  
  public static final String PROPERTY_RADIUS = "radius";
  
  public static final String PROPERTY_ROTATION = "rotation";
  
  public static final String PROPERTY_SCALE_IMAGE = "scaleImage";
  
  public static final String PROPERTY_STRIKE_THROUGH = "strikeThrough";
  
  public static final String PROPERTY_IS_STYLED_TEXT = "isStyledText";
  
  public static final String PROPERTY_MARKUP = "markup";
  
  public static final String PROPERTY_UNDERLINE = "underline";
  
  public static final String PROPERTY_VERTICAL_ALIGNMENT = "verticalAlignment";
  
  protected JRDefaultStyleProvider defaultStyleProvider = null;
  
  protected JRStyle parentStyle = null;
  
  protected String parentStyleNameReference;
  
  protected String name = null;
  
  protected boolean isDefault = false;
  
  protected Byte positionType = null;
  
  protected Byte stretchType = null;
  
  protected Byte mode = null;
  
  protected Color forecolor = null;
  
  protected Color backcolor = null;
  
  protected JRPen linePen = null;
  
  protected Byte fill = null;
  
  protected Integer radius = null;
  
  protected Byte scaleImage = null;
  
  protected Byte horizontalAlignment = null;
  
  protected Byte verticalAlignment = null;
  
  protected JRLineBox lineBox = null;
  
  protected String fontName = null;
  
  protected Boolean isBold = null;
  
  protected Boolean isItalic = null;
  
  protected Boolean isUnderline = null;
  
  protected Boolean isStrikeThrough = null;
  
  protected Integer fontSize = null;
  
  protected String pdfFontName = null;
  
  protected String pdfEncoding = null;
  
  protected Boolean isPdfEmbedded = null;
  
  protected Byte rotation = null;
  
  protected Byte lineSpacing = null;
  
  protected String markup = null;
  
  protected String pattern = null;
  
  protected Boolean isBlankWhenNull = null;
  
  protected JRConditionalStyle[] conditionalStyles;
  
  private transient JRPropertyChangeSupport eventSupport;
  
  private Byte pen;
  
  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;
  
  private Boolean isStyledText;
  
  protected void setParentStyle(JRStyle parentStyle) {
    this.parentStyle = parentStyle;
    checkCircularParent();
  }
  
  protected void checkCircularParent() {
    for (JRStyle ancestor = this.parentStyle; ancestor != null; ancestor = ancestor.getStyle()) {
      if (ancestor == this)
        throw new JRRuntimeException("Circular dependency detected for style " + getName()); 
    } 
  }
  
  public JRDefaultStyleProvider getDefaultStyleProvider() {
    return this.defaultStyleProvider;
  }
  
  public JRStyle getStyle() {
    return this.parentStyle;
  }
  
  public String getName() {
    return this.name;
  }
  
  public void rename(String newName) {
    this.name = newName;
  }
  
  public boolean isDefault() {
    return this.isDefault;
  }
  
  public Color getForecolor() {
    return JRStyleResolver.getForecolor(this);
  }
  
  public Color getOwnForecolor() {
    return this.forecolor;
  }
  
  public Color getBackcolor() {
    return JRStyleResolver.getBackcolor(this);
  }
  
  public Color getOwnBackcolor() {
    return this.backcolor;
  }
  
  public JRPen getLinePen() {
    return this.linePen;
  }
  
  public Byte getPen() {
    return new Byte(JRPenUtil.getPenFromLinePen(this.linePen));
  }
  
  public Byte getOwnPen() {
    return JRPenUtil.getOwnPenFromLinePen(this.linePen);
  }
  
  public void setPen(byte pen) {
    setPen(new Byte(pen));
  }
  
  public void setPen(Byte pen) {
    JRPenUtil.setLinePenFromPen(pen, this.linePen);
  }
  
  public Byte getFill() {
    return JRStyleResolver.getFill(this);
  }
  
  public Byte getOwnFill() {
    return this.fill;
  }
  
  public Integer getRadius() {
    return JRStyleResolver.getRadius(this);
  }
  
  public Integer getOwnRadius() {
    return this.radius;
  }
  
  public Byte getScaleImage() {
    return JRStyleResolver.getScaleImage(this);
  }
  
  public Byte getOwnScaleImage() {
    return this.scaleImage;
  }
  
  public Byte getHorizontalAlignment() {
    return JRStyleResolver.getHorizontalAlignment(this);
  }
  
  public Byte getOwnHorizontalAlignment() {
    return this.horizontalAlignment;
  }
  
  public Byte getVerticalAlignment() {
    return JRStyleResolver.getVerticalAlignment(this);
  }
  
  public Byte getOwnVerticalAlignment() {
    return this.verticalAlignment;
  }
  
  public JRLineBox getLineBox() {
    return this.lineBox;
  }
  
  public Byte getBorder() {
    return new Byte(JRPenUtil.getPenFromLinePen(this.lineBox.getPen()));
  }
  
  public Byte getOwnBorder() {
    return JRPenUtil.getOwnPenFromLinePen(this.lineBox.getPen());
  }
  
  public Color getBorderColor() {
    return this.lineBox.getPen().getLineColor();
  }
  
  public Color getOwnBorderColor() {
    return this.lineBox.getPen().getOwnLineColor();
  }
  
  public Integer getPadding() {
    return this.lineBox.getPadding();
  }
  
  public Integer getOwnPadding() {
    return this.lineBox.getOwnPadding();
  }
  
  public Byte getTopBorder() {
    return new Byte(JRPenUtil.getPenFromLinePen(this.lineBox.getTopPen()));
  }
  
  public Byte getOwnTopBorder() {
    return JRPenUtil.getOwnPenFromLinePen(this.lineBox.getTopPen());
  }
  
  public Color getTopBorderColor() {
    return this.lineBox.getTopPen().getLineColor();
  }
  
  public Color getOwnTopBorderColor() {
    return this.lineBox.getTopPen().getOwnLineColor();
  }
  
  public Integer getTopPadding() {
    return this.lineBox.getTopPadding();
  }
  
  public Integer getOwnTopPadding() {
    return this.lineBox.getOwnTopPadding();
  }
  
  public Byte getLeftBorder() {
    return new Byte(JRPenUtil.getPenFromLinePen(this.lineBox.getLeftPen()));
  }
  
  public Byte getOwnLeftBorder() {
    return JRPenUtil.getOwnPenFromLinePen(this.lineBox.getLeftPen());
  }
  
  public Color getLeftBorderColor() {
    return this.lineBox.getLeftPen().getLineColor();
  }
  
  public Color getOwnLeftBorderColor() {
    return this.lineBox.getLeftPen().getOwnLineColor();
  }
  
  public Integer getLeftPadding() {
    return this.lineBox.getLeftPadding();
  }
  
  public Integer getOwnLeftPadding() {
    return this.lineBox.getOwnLeftPadding();
  }
  
  public Byte getBottomBorder() {
    return new Byte(JRPenUtil.getPenFromLinePen(this.lineBox.getBottomPen()));
  }
  
  public Byte getOwnBottomBorder() {
    return JRPenUtil.getOwnPenFromLinePen(this.lineBox.getBottomPen());
  }
  
  public Color getBottomBorderColor() {
    return this.lineBox.getBottomPen().getLineColor();
  }
  
  public Color getOwnBottomBorderColor() {
    return this.lineBox.getBottomPen().getOwnLineColor();
  }
  
  public Integer getBottomPadding() {
    return this.lineBox.getBottomPadding();
  }
  
  public Integer getOwnBottomPadding() {
    return this.lineBox.getOwnBottomPadding();
  }
  
  public Byte getRightBorder() {
    return new Byte(JRPenUtil.getPenFromLinePen(this.lineBox.getRightPen()));
  }
  
  public Byte getOwnRightBorder() {
    return JRPenUtil.getOwnPenFromLinePen(this.lineBox.getRightPen());
  }
  
  public Color getRightBorderColor() {
    return this.lineBox.getRightPen().getLineColor();
  }
  
  public Color getOwnRightBorderColor() {
    return this.lineBox.getRightPen().getOwnLineColor();
  }
  
  public Integer getRightPadding() {
    return this.lineBox.getRightPadding();
  }
  
  public Integer getOwnRightPadding() {
    return this.lineBox.getOwnRightPadding();
  }
  
  public Byte getRotation() {
    return JRStyleResolver.getRotation(this);
  }
  
  public Byte getOwnRotation() {
    return this.rotation;
  }
  
  public Byte getLineSpacing() {
    return JRStyleResolver.getLineSpacing(this);
  }
  
  public Byte getOwnLineSpacing() {
    return this.lineSpacing;
  }
  
  public Boolean isStyledText() {
    String mkp = getMarkup();
    return "styled".equals(mkp) ? Boolean.TRUE : ((mkp == null) ? null : Boolean.FALSE);
  }
  
  public Boolean isOwnStyledText() {
    String mkp = getOwnMarkup();
    return "styled".equals(mkp) ? Boolean.TRUE : ((mkp == null) ? null : Boolean.FALSE);
  }
  
  public String getMarkup() {
    return JRStyleResolver.getMarkup(this);
  }
  
  public String getOwnMarkup() {
    return this.markup;
  }
  
  public Boolean isBlankWhenNull() {
    return JRStyleResolver.isBlankWhenNull(this);
  }
  
  public Boolean isOwnBlankWhenNull() {
    return this.isBlankWhenNull;
  }
  
  public String getFontName() {
    return JRStyleResolver.getFontName(this);
  }
  
  public String getOwnFontName() {
    return this.fontName;
  }
  
  public Boolean isBold() {
    return JRStyleResolver.isBold(this);
  }
  
  public Boolean isOwnBold() {
    return this.isBold;
  }
  
  public Boolean isItalic() {
    return JRStyleResolver.isItalic(this);
  }
  
  public Boolean isOwnItalic() {
    return this.isItalic;
  }
  
  public Boolean isUnderline() {
    return JRStyleResolver.isUnderline(this);
  }
  
  public Boolean isOwnUnderline() {
    return this.isUnderline;
  }
  
  public Boolean isStrikeThrough() {
    return JRStyleResolver.isStrikeThrough(this);
  }
  
  public Boolean isOwnStrikeThrough() {
    return this.isStrikeThrough;
  }
  
  public Integer getFontSize() {
    return JRStyleResolver.getFontSize(this);
  }
  
  public Integer getOwnFontSize() {
    return this.fontSize;
  }
  
  public String getPdfFontName() {
    return JRStyleResolver.getPdfFontName(this);
  }
  
  public String getOwnPdfFontName() {
    return this.pdfFontName;
  }
  
  public String getPdfEncoding() {
    return JRStyleResolver.getPdfEncoding(this);
  }
  
  public String getOwnPdfEncoding() {
    return this.pdfEncoding;
  }
  
  public Boolean isPdfEmbedded() {
    return JRStyleResolver.isPdfEmbedded(this);
  }
  
  public Boolean isOwnPdfEmbedded() {
    return this.isPdfEmbedded;
  }
  
  public String getPattern() {
    return JRStyleResolver.getPattern(this);
  }
  
  public String getOwnPattern() {
    return this.pattern;
  }
  
  public Byte getMode() {
    return JRStyleResolver.getMode(this);
  }
  
  public Byte getOwnMode() {
    return this.mode;
  }
  
  public void setForecolor(Color forecolor) {
    Object old = this.forecolor;
    this.forecolor = forecolor;
    getEventSupport().firePropertyChange("forecolor", old, this.forecolor);
  }
  
  public void setBackcolor(Color backcolor) {
    Object old = this.backcolor;
    this.backcolor = backcolor;
    getEventSupport().firePropertyChange("backcolor", old, this.backcolor);
  }
  
  public void setMode(byte mode) {
    setMode(new Byte(mode));
  }
  
  public void setMode(Byte mode) {
    Object old = this.mode;
    this.mode = mode;
    getEventSupport().firePropertyChange("mode", old, this.mode);
  }
  
  public void setFill(byte fill) {
    setFill(new Byte(fill));
  }
  
  public void setFill(Byte fill) {
    Object old = this.fill;
    this.fill = fill;
    getEventSupport().firePropertyChange("fill", old, this.fill);
  }
  
  public void setRadius(int radius) {
    setRadius(new Integer(radius));
  }
  
  public void setRadius(Integer radius) {
    Object old = this.radius;
    this.radius = radius;
    getEventSupport().firePropertyChange("radius", old, this.radius);
  }
  
  public void setScaleImage(byte scaleImage) {
    setScaleImage(new Byte(scaleImage));
  }
  
  public void setScaleImage(Byte scaleImage) {
    Object old = this.scaleImage;
    this.scaleImage = scaleImage;
    getEventSupport().firePropertyChange("scaleImage", old, this.scaleImage);
  }
  
  public void setHorizontalAlignment(byte horizontalAlignment) {
    setHorizontalAlignment(new Byte(horizontalAlignment));
  }
  
  public void setHorizontalAlignment(Byte horizontalAlignment) {
    Object old = this.horizontalAlignment;
    this.horizontalAlignment = horizontalAlignment;
    getEventSupport().firePropertyChange("horizontalAlignment", old, this.horizontalAlignment);
  }
  
  public void setVerticalAlignment(byte verticalAlignment) {
    setVerticalAlignment(new Byte(verticalAlignment));
  }
  
  public void setVerticalAlignment(Byte verticalAlignment) {
    Object old = this.verticalAlignment;
    this.verticalAlignment = verticalAlignment;
    getEventSupport().firePropertyChange("verticalAlignment", old, this.verticalAlignment);
  }
  
  public void setBorder(byte border) {
    JRPenUtil.setLinePenFromPen(border, this.lineBox.getPen());
  }
  
  public void setBorder(Byte border) {
    JRPenUtil.setLinePenFromPen(border, this.lineBox.getPen());
  }
  
  public void setBorderColor(Color borderColor) {
    this.lineBox.getPen().setLineColor(borderColor);
  }
  
  public void setPadding(int padding) {
    this.lineBox.setPadding(padding);
  }
  
  public void setPadding(Integer padding) {
    this.lineBox.setPadding(padding);
  }
  
  public void setTopBorder(byte topBorder) {
    JRPenUtil.setLinePenFromPen(topBorder, this.lineBox.getTopPen());
  }
  
  public void setTopBorder(Byte topBorder) {
    JRPenUtil.setLinePenFromPen(topBorder, this.lineBox.getTopPen());
  }
  
  public void setTopBorderColor(Color topBorderColor) {
    this.lineBox.getTopPen().setLineColor(topBorderColor);
  }
  
  public void setTopPadding(int topPadding) {
    this.lineBox.setTopPadding(topPadding);
  }
  
  public void setTopPadding(Integer topPadding) {
    this.lineBox.setTopPadding(topPadding);
  }
  
  public void setLeftBorder(byte leftBorder) {
    JRPenUtil.setLinePenFromPen(leftBorder, this.lineBox.getLeftPen());
  }
  
  public void setLeftBorder(Byte leftBorder) {
    JRPenUtil.setLinePenFromPen(leftBorder, this.lineBox.getLeftPen());
  }
  
  public void setLeftBorderColor(Color leftBorderColor) {
    this.lineBox.getLeftPen().setLineColor(leftBorderColor);
  }
  
  public void setLeftPadding(int leftPadding) {
    this.lineBox.setLeftPadding(leftPadding);
  }
  
  public void setLeftPadding(Integer leftPadding) {
    this.lineBox.setLeftPadding(leftPadding);
  }
  
  public void setBottomBorder(byte bottomBorder) {
    JRPenUtil.setLinePenFromPen(bottomBorder, this.lineBox.getBottomPen());
  }
  
  public void setBottomBorder(Byte bottomBorder) {
    JRPenUtil.setLinePenFromPen(bottomBorder, this.lineBox.getBottomPen());
  }
  
  public void setBottomBorderColor(Color bottomBorderColor) {
    this.lineBox.getBottomPen().setLineColor(bottomBorderColor);
  }
  
  public void setBottomPadding(int bottomPadding) {
    this.lineBox.setBottomPadding(bottomPadding);
  }
  
  public void setBottomPadding(Integer bottomPadding) {
    this.lineBox.setBottomPadding(bottomPadding);
  }
  
  public void setRightBorder(byte rightBorder) {
    JRPenUtil.setLinePenFromPen(rightBorder, this.lineBox.getRightPen());
  }
  
  public void setRightBorder(Byte rightBorder) {
    JRPenUtil.setLinePenFromPen(rightBorder, this.lineBox.getRightPen());
  }
  
  public void setRightBorderColor(Color rightBorderColor) {
    this.lineBox.getRightPen().setLineColor(rightBorderColor);
  }
  
  public void setRightPadding(int rightPadding) {
    this.lineBox.setRightPadding(rightPadding);
  }
  
  public void setRightPadding(Integer rightPadding) {
    this.lineBox.setRightPadding(rightPadding);
  }
  
  public void setRotation(byte rotation) {
    setRotation(new Byte(rotation));
  }
  
  public void setRotation(Byte rotation) {
    Object old = this.rotation;
    this.rotation = rotation;
    getEventSupport().firePropertyChange("rotation", old, this.rotation);
  }
  
  public void setFontName(String fontName) {
    Object old = this.fontName;
    this.fontName = fontName;
    getEventSupport().firePropertyChange("fontName", old, this.fontName);
  }
  
  public void setBold(boolean bold) {
    setBold(bold ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setBold(Boolean bold) {
    Object old = this.isBold;
    this.isBold = bold;
    getEventSupport().firePropertyChange("bold", old, this.isBold);
  }
  
  public void setItalic(boolean italic) {
    setItalic(italic ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setItalic(Boolean italic) {
    Object old = this.isItalic;
    this.isItalic = italic;
    getEventSupport().firePropertyChange("italic", old, this.isItalic);
  }
  
  public void setPdfEmbedded(boolean pdfEmbedded) {
    setPdfEmbedded(pdfEmbedded ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setPdfEmbedded(Boolean pdfEmbedded) {
    Object old = this.isPdfEmbedded;
    this.isPdfEmbedded = pdfEmbedded;
    getEventSupport().firePropertyChange("pdfEmbedded", old, this.isPdfEmbedded);
  }
  
  public void setStrikeThrough(boolean strikeThrough) {
    setStrikeThrough(strikeThrough ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setStrikeThrough(Boolean strikeThrough) {
    Object old = this.isStrikeThrough;
    this.isStrikeThrough = strikeThrough;
    getEventSupport().firePropertyChange("strikeThrough", old, this.isStrikeThrough);
  }
  
  public void setStyledText(boolean styledText) {
    setStyledText(styledText ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setStyledText(Boolean styledText) {
    if (styledText == null) {
      setMarkup(null);
    } else {
      setMarkup(styledText.booleanValue() ? "styled" : "none");
    } 
  }
  
  public void setMarkup(String markup) {
    Object old = this.markup;
    this.markup = markup;
    getEventSupport().firePropertyChange("markup", old, this.markup);
  }
  
  public void setBlankWhenNull(boolean isBlankWhenNull) {
    setBlankWhenNull(isBlankWhenNull ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setBlankWhenNull(Boolean isBlankWhenNull) {
    Object old = this.isBlankWhenNull;
    this.isBlankWhenNull = isBlankWhenNull;
    getEventSupport().firePropertyChange("blankWhenNull", old, this.isBlankWhenNull);
  }
  
  public void setUnderline(boolean underline) {
    setUnderline(underline ? Boolean.TRUE : Boolean.FALSE);
  }
  
  public void setUnderline(Boolean underline) {
    Object old = this.isUnderline;
    this.isUnderline = underline;
    getEventSupport().firePropertyChange("underline", old, this.isUnderline);
  }
  
  public void setLineSpacing(byte lineSpacing) {
    setLineSpacing(new Byte(lineSpacing));
  }
  
  public void setLineSpacing(Byte lineSpacing) {
    Object old = this.lineSpacing;
    this.lineSpacing = lineSpacing;
    getEventSupport().firePropertyChange("lineSpacing", old, this.lineSpacing);
  }
  
  public void setPattern(String pattern) {
    Object old = this.pattern;
    this.pattern = pattern;
    getEventSupport().firePropertyChange("pattern", old, this.pattern);
  }
  
  public void setPdfEncoding(String pdfEncoding) {
    Object old = this.pdfEncoding;
    this.pdfEncoding = pdfEncoding;
    getEventSupport().firePropertyChange("pdfEncoding", old, this.pdfEncoding);
  }
  
  public void setPdfFontName(String pdfFontName) {
    Object old = this.pdfFontName;
    this.pdfFontName = pdfFontName;
    getEventSupport().firePropertyChange("pdfFontName", old, this.pdfFontName);
  }
  
  public void setFontSize(int fontSize) {
    setFontSize(new Integer(fontSize));
  }
  
  public void setFontSize(Integer fontSize) {
    Object old = this.fontSize;
    this.fontSize = fontSize;
    getEventSupport().firePropertyChange("fontSize", old, this.fontSize);
  }
  
  public JRConditionalStyle[] getConditionalStyles() {
    return this.conditionalStyles;
  }
  
  public String getStyleNameReference() {
    return this.parentStyleNameReference;
  }
  
  public Float getDefaultLineWidth() {
    return null;
  }
  
  public Color getDefaultLineColor() {
    return getForecolor();
  }
  
  public JRPropertyChangeSupport getEventSupport() {
    synchronized (this) {
      if (this.eventSupport == null)
        this.eventSupport = new JRPropertyChangeSupport(this); 
    } 
    return this.eventSupport;
  }
  
  public JRBaseStyle() {
    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;
    this.isStyledText = null;
    this.linePen = new JRBasePen((JRPenContainer)this);
    this.lineBox = new JRBaseLineBox((JRBoxContainer)this);
  }
  
  public JRBaseStyle(String name) {
    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;
    this.isStyledText = null;
    this.name = name;
    this.linePen = new JRBasePen((JRPenContainer)this);
    this.lineBox = new JRBaseLineBox((JRBoxContainer)this);
  }
  
  public JRBaseStyle(JRStyle style, JRAbstractObjectFactory factory) {
    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;
    this.isStyledText = null;
    this.name = style.getName();
    factory.setStyle(new JRStyleSetter() {
          private final JRBaseStyle this$0;
          
          public void setStyle(JRStyle aStyle) {
            JRBaseStyle.this.setParentStyle(aStyle);
          }
          
          public void setStyleNameReference(String name) {
            JRBaseStyle.this.parentStyleNameReference = name;
          }
        },  (JRStyleContainer)style);
    this.isDefault = style.isDefault();
    this.mode = style.getOwnMode();
    this.forecolor = style.getOwnForecolor();
    this.backcolor = style.getOwnBackcolor();
    this.linePen = style.getLinePen().clone((JRPenContainer)this);
    this.fill = style.getOwnFill();
    this.radius = style.getOwnRadius();
    this.scaleImage = style.getOwnScaleImage();
    this.horizontalAlignment = style.getOwnHorizontalAlignment();
    this.verticalAlignment = style.getOwnVerticalAlignment();
    this.lineBox = style.getLineBox().clone((JRBoxContainer)this);
    this.rotation = style.getOwnRotation();
    this.lineSpacing = style.getOwnLineSpacing();
    this.markup = style.getOwnMarkup();
    this.pattern = style.getOwnPattern();
    this.fontName = style.getOwnFontName();
    this.isBold = style.isOwnBold();
    this.isItalic = style.isOwnItalic();
    this.isUnderline = style.isOwnUnderline();
    this.isStrikeThrough = style.isOwnStrikeThrough();
    this.fontSize = style.getOwnFontSize();
    this.pdfFontName = style.getOwnPdfFontName();
    this.pdfEncoding = style.getOwnPdfEncoding();
    this.isPdfEmbedded = style.isOwnPdfEmbedded();
    this.isBlankWhenNull = style.isOwnBlankWhenNull();
    JRConditionalStyle[] condStyles = style.getConditionalStyles();
    if (condStyles != null && condStyles.length > 0) {
      this.conditionalStyles = new JRConditionalStyle[condStyles.length];
      for (int i = 0; i < condStyles.length; i++)
        this.conditionalStyles[i] = factory.getConditionalStyle(condStyles[i], this); 
    } 
  }
  
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    if (this.linePen == null) {
      this.linePen = new JRBasePen((JRPenContainer)this);
      JRPenUtil.setLinePenFromPen(this.pen, this.linePen);
      this.pen = null;
    } 
    if (this.lineBox == null) {
      this.lineBox = 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;
    } 
    if (this.isStyledText != null) {
      this.markup = this.isStyledText.booleanValue() ? "styled" : "none";
      this.isStyledText = null;
    } 
  }
}
