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.base;
25
26 import net.sf.jasperreports.engine.JRConstants;
27 import net.sf.jasperreports.engine.JRExpressionCollector;
28 import net.sf.jasperreports.engine.JRRectangle;
29 import net.sf.jasperreports.engine.JRVisitor;
30
31
32 /**
33  * The actual implementation of a graphic element representing a rectangle.
34  *
35  * @author Teodor Danciu (teodord@users.sourceforge.net)
36  */

37 public class JRBaseRectangle extends JRBaseGraphicElement implements JRRectangle
38 {
39
40
41     /**
42      *
43      */

44     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
45     
46     /**
47      *
48      */

49     protected Integer radius;
50
51
52     /**
53      * Initializes properties that are specific to rectangles. Common properties are initialized by its
54      * parent constructors.
55      * @param rectangle an element whose properties are copied to this element. Usually it is a
56      * {@link net.sf.jasperreports.engine.design.JRDesignRectangle} that must be transformed into an
57      * <tt>JRBaseRectangle</tt> at compile time.
58      * @param factory a factory used in the compile process
59      */

60     protected JRBaseRectangle(JRRectangle rectangle, JRBaseObjectFactory factory)
61     {
62         super(rectangle, factory);
63
64         radius = rectangle.getOwnRadius();
65     }
66
67
68     @Override
69     public int getRadius()
70     {
71         return getStyleResolver().getRadius(this);
72     }
73
74     @Override
75     public Integer getOwnRadius()
76     {
77         return this.radius;
78     }
79
80     /**
81      * @deprecated Replaced by {@link #setRadius(Integer)}.
82      */

83     @Override
84     public void setRadius(int radius)
85     {
86         setRadius((Integer)radius);
87     }
88
89     @Override
90     public void setRadius(Integer radius)
91     {
92         Object old = this.radius;
93         this.radius = radius;
94         getEventSupport().firePropertyChange(JRBaseStyle.PROPERTY_RADIUS, old, this.radius);
95     }
96
97     @Override
98     public void collectExpressions(JRExpressionCollector collector)
99     {
100         collector.collect(this);
101     }
102
103     @Override
104     public void visit(JRVisitor visitor)
105     {
106         visitor.visitRectangle(this);
107     }
108
109
110 }
111