1 /*
2  * JasperReports - Free Java Reporting Library.
3  * Copyright (C) 2001 - 2019 TIBCO Software Inc. All rights reserved.
4  * http://www.jaspersoft.com
5  *
6  * Unless you have purchased a commercial license agreement from Jaspersoft,
7  * the following license terms apply:
8  *
9  * This program is part of JasperReports.
10  *
11  * JasperReports is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * JasperReports is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
23  */

24 package net.sf.jasperreports.engine.fill;
25
26 import net.sf.jasperreports.engine.JRException;
27 import net.sf.jasperreports.engine.JRExpressionCollector;
28 import net.sf.jasperreports.engine.JRPrintElement;
29 import net.sf.jasperreports.engine.JRPrintRectangle;
30 import net.sf.jasperreports.engine.JRRectangle;
31 import net.sf.jasperreports.engine.JRVisitor;
32
33
34 /**
35  * @author Teodor Danciu (teodord@users.sourceforge.net)
36  */

37 public class JRFillRectangle extends JRFillGraphicElement implements JRRectangle
38 {
39
40
41     /**
42      *
43      */

44     protected JRFillRectangle(
45         JRBaseFiller filler,
46         JRRectangle rectangle, 
47         JRFillObjectFactory factory
48         )
49     {
50         super(filler, rectangle, factory);
51     }
52
53
54     protected JRFillRectangle(JRFillRectangle rectangle, JRFillCloneFactory factory)
55     {
56         super(rectangle, factory);
57     }
58
59
60     @Override
61     public int getRadius()
62     {
63         return getStyleResolver().getRadius(this);
64     }
65         
66     @Override
67     public Integer getOwnRadius()
68     {
69         return providerStyle == null || providerStyle.getOwnRadius() == null ? ((JRRectangle)this.parent).getOwnRadius() : providerStyle.getOwnRadius();
70     }
71
72     /**
73      * @deprecated Replaced by {@link #setRadius(Integer)}.
74      */

75     @Override
76     public void setRadius(int radius)
77     {
78     }
79
80     @Override
81     public void setRadius(Integer radius)
82     {
83     }
84
85     /**
86      *
87      */

88     protected JRTemplateRectangle getJRTemplateRectangle()
89     {
90         return (JRTemplateRectangle) getElementTemplate();
91     }
92
93
94     @Override
95     protected JRTemplateElement createElementTemplate()
96     {
97         return new JRTemplateRectangle(
98                 getElementOrigin(), 
99                 filler.getJasperPrint().getDefaultStyleProvider(), 
100                 this
101                 );
102     }
103
104
105     @Override
106     protected void evaluate(
107         byte evaluation
108         ) throws JRException
109     {
110         this.reset();
111         
112         this.evaluatePrintWhenExpression(evaluation);
113         evaluateProperties(evaluation);
114         evaluateStyle(evaluation);
115         
116         setValueRepeating(true);
117     }
118
119
120     @Override
121     protected JRPrintElement fill()
122     {
123         JRPrintRectangle printRectangle = null;
124
125         printRectangle = new JRTemplatePrintRectangle(this.getJRTemplateRectangle(), printElementOriginator);
126         printRectangle.setUUID(this.getUUID());
127         printRectangle.setX(this.getX());
128         printRectangle.setY(this.getRelativeY());
129         printRectangle.setWidth(getWidth());
130         printRectangle.setHeight(this.getStretchHeight());
131         transferProperties(printRectangle);
132         
133         return printRectangle;
134     }
135
136
137     @Override
138     public void collectExpressions(JRExpressionCollector collector)
139     {
140         collector.collect(this);
141     }
142
143     @Override
144     public void visit(JRVisitor visitor)
145     {
146         visitor.visitRectangle(this);
147     }
148
149     @Override
150     protected void resolveElement (JRPrintElement element, byte evaluation)
151     {
152         // nothing
153     }
154
155
156     @Override
157     public JRFillCloneable createClone(JRFillCloneFactory factory)
158     {
159         return new JRFillRectangle(this, factory);
160     }
161
162 }
163