package net.sf.jasperreports.engine.fill;

import net.sf.jasperreports.engine.JRCommonRectangle;
import net.sf.jasperreports.engine.JRDefaultStyleProvider;
import net.sf.jasperreports.engine.JRElement;
import net.sf.jasperreports.engine.JRGraphicElement;
import net.sf.jasperreports.engine.JROrigin;
import net.sf.jasperreports.engine.JRPen;
import net.sf.jasperreports.engine.JRPenContainer;
import net.sf.jasperreports.engine.JRRectangle;
import net.sf.jasperreports.engine.JRSubreport;
import net.sf.jasperreports.engine.base.JRBasePen;
import net.sf.jasperreports.engine.util.JRStyleResolver;

public class JRTemplateRectangle extends JRTemplateGraphicElement implements JRCommonRectangle {
  private static final long serialVersionUID = 10200L;
  
  private Integer radius = null;
  
  protected JRTemplateRectangle(JROrigin origin, JRDefaultStyleProvider defaultStyleProvider, JRRectangle rectangle) {
    super(origin, defaultStyleProvider);
    setRectangle(rectangle);
  }
  
  protected JRTemplateRectangle(JROrigin origin, JRDefaultStyleProvider defaultStyleProvider, JRSubreport subreport) {
    super(origin, defaultStyleProvider);
    setSubreport(subreport);
  }
  
  protected void setRectangle(JRRectangle rectangle) {
    setGraphicElement((JRGraphicElement)rectangle);
    setRadius(rectangle.getRadius());
  }
  
  protected void setSubreport(JRSubreport subreport) {
    setElement((JRElement)subreport);
    setMode(subreport.getMode());
    this.linePen = (JRPen)new JRBasePen((JRPenContainer)this);
    getLinePen().setLineWidth(0.0F);
    setFill((byte)1);
  }
  
  public int getRadius() {
    return JRStyleResolver.getRadius(this);
  }
  
  public Integer getOwnRadius() {
    return this.radius;
  }
  
  protected void setRadius(int radius) {
    this.radius = new Integer(radius);
  }
  
  protected void setRadius(Integer radius) {
    this.radius = radius;
  }
}
