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;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29 import net.sf.jasperreports.charts.JRAreaPlot;
30 import net.sf.jasperreports.charts.JRBar3DPlot;
31 import net.sf.jasperreports.charts.JRBarPlot;
32 import net.sf.jasperreports.charts.JRBubblePlot;
33 import net.sf.jasperreports.charts.JRCandlestickPlot;
34 import net.sf.jasperreports.charts.JRCategoryDataset;
35 import net.sf.jasperreports.charts.JRCategorySeries;
36 import net.sf.jasperreports.charts.JRLinePlot;
37 import net.sf.jasperreports.charts.JRPie3DPlot;
38 import net.sf.jasperreports.charts.JRPieDataset;
39 import net.sf.jasperreports.charts.JRPiePlot;
40 import net.sf.jasperreports.charts.JRPieSeries;
41 import net.sf.jasperreports.charts.JRTimePeriodDataset;
42 import net.sf.jasperreports.charts.JRTimePeriodSeries;
43 import net.sf.jasperreports.charts.JRTimeSeries;
44 import net.sf.jasperreports.charts.JRTimeSeriesDataset;
45 import net.sf.jasperreports.charts.JRXyzDataset;
46 import net.sf.jasperreports.charts.JRXyzSeries;
47 import net.sf.jasperreports.engine.base.JRBaseFont;
48
49
50 /**
51  * @author Teodor Danciu (teodord@users.sourceforge.net)
52  */

53 public abstract class JRAbstractObjectFactory implements JRVisitor
54 {
55
56
57     /**
58      *
59      */

60     private Map<Object,Object> objectsMap = new HashMap<Object,Object>();
61     private Object visitResult;
62
63
64     /**
65      *
66      */

67     protected Object get(Object object)
68     {
69         return objectsMap.get(object);
70     }
71
72     /**
73      *
74      */

75     public void put(Object object, Object copy)
76     {
77         objectsMap.put(object, copy);
78     }
79
80
81     /**
82      *
83      */

84     public Object getVisitResult(JRVisitable visitable)
85     {
86         if (visitable != null)
87         {
88             visitable.visit(this);
89             return visitResult;
90         }
91         return null;
92     }
93
94
95     /**
96      *
97      */

98     protected void setVisitResult(Object visitResult)
99     {
100         this.visitResult = visitResult;
101     }
102
103
104     /**
105      *
106      */

107     public abstract JRDefaultStyleProvider getDefaultStyleProvider();
108
109
110     /**
111      *
112      */

113     public abstract JRStyle getStyle(JRStyle style);
114
115     /**
116      * Sets a style or a style reference on an object.
117      * <p/>
118      * If the container includes a style (see {@link JRStyleContainer#getStyle() getStyle()},
119      * a copy of this style will be created via {@link #getStyle(JRStyle) getStyle(JRStyle)}
120      * and set on the object.
121      * <p/>
122      * In addition to this, the implementation needs to handle the case when the container includes
123      * an external style reference (see {@link JRStyleContainer#getStyleNameReference() getStyleNameReference()}.
124      * 
125      * @param setter a setter for the object on which the style should be set.
126      * @param styleContainer the original style container
127      * @see #getStyle(JRStyle)
128      */

129     public abstract void setStyle(JRStyleSetter setter, JRStyleContainer styleContainer);
130     
131     
132     /**
133      *
134      */

135     public JRFont getFont(JRStyleContainer styleContainer, JRFont font)
136     {
137         JRBaseFont baseFont = null;
138
139         if (font != null)
140         {
141             baseFont = (JRBaseFont)get(font);
142             if (baseFont == null)
143             {
144                 baseFont = new JRBaseFont(styleContainer, font, this);
145             }
146         }
147
148         return baseFont;
149     }
150
151     
152     /**
153      *
154      */

155     public abstract JRPieDataset getPieDataset(JRPieDataset pieDataset);
156
157     /**
158      *
159      */

160     public abstract JRPiePlot getPiePlot(JRPiePlot piePlot);
161
162
163     /**
164      *
165      */

166     public abstract JRPie3DPlot getPie3DPlot(JRPie3DPlot pie3DPlot);
167
168
169     /**
170      *
171      */

172     public abstract JRCategoryDataset getCategoryDataset(JRCategoryDataset categoryDataset);
173
174
175     /**
176      * 
177      */

178     public abstract JRTimeSeriesDataset getTimeSeriesDataset( JRTimeSeriesDataset timeSeriesDataset );
179
180     /**
181      * 
182      */

183     public abstract JRTimePeriodDataset getTimePeriodDataset( JRTimePeriodDataset timePeriodDataset );
184
185     /**
186      * 
187      */

188     public abstract JRTimePeriodSeries getTimePeriodSeries( JRTimePeriodSeries timePeriodSeries );
189
190     /**
191      * 
192      */

193     public abstract JRTimeSeries getTimeSeries( JRTimeSeries timeSeries );
194
195     /**
196      *
197      */

198     public abstract JRPieSeries getPieSeries(JRPieSeries pieSeries);
199
200     /**
201      *
202      */

203     public abstract JRCategorySeries getCategorySeries(JRCategorySeries categorySeries);
204
205     /**
206      *
207      */

208     public abstract JRXyzDataset getXyzDataset( JRXyzDataset xyzDataset );
209
210     /**
211      *
212      */

213     public abstract JRXyzSeries getXyzSeries( JRXyzSeries xyzSeries );
214
215
216     /**
217      *
218      */

219     public abstract JRBarPlot getBarPlot(JRBarPlot barPlot);
220
221     /**
222      *
223      */

224     public abstract JRBar3DPlot getBar3DPlot( JRBar3DPlot barPlot );
225
226
227     /**
228      *
229      */

230     public abstract JRLinePlot getLinePlot( JRLinePlot linePlot );
231
232
233     /**
234      *
235      */

236     public abstract JRAreaPlot getAreaPlot( JRAreaPlot areaPlot );
237
238
239     /**
240      *
241      */

242     public abstract JRBubblePlot getBubblePlot( JRBubblePlot bubblePlot );
243
244
245     /**
246      *
247      */

248     public abstract JRCandlestickPlot getCandlestickPlot(JRCandlestickPlot candlestickPlot);
249
250
251     /**
252      *
253      */

254     public abstract JRConditionalStyle getConditionalStyle(JRConditionalStyle conditionalStyle, JRStyle parentStyle);
255
256     public abstract JRExpression getExpression(JRExpression expression, boolean assignNotUsedId);
257     
258     public JRExpression getExpression(JRExpression expression)
259     {
260         return getExpression(expression, false);
261     }
262 }
263