~brian-thomason/+junk/jasperreports3.7

« back to all changes in this revision

Viewing changes to src/net/sf/jasperreports/charts/base/JRBaseCandlestickPlot.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:51:16 UTC
  • Revision ID: brian.thomason@canonical.com-20111220175116-apwo6unuaedvgzo3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * JasperReports - Free Java Reporting Library.
 
3
 * Copyright (C) 2001 - 2009 Jaspersoft Corporation. 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.charts.base;
 
25
 
 
26
import java.awt.Color;
 
27
import java.io.IOException;
 
28
import java.io.ObjectInputStream;
 
29
 
 
30
import net.sf.jasperreports.charts.JRCandlestickPlot;
 
31
import net.sf.jasperreports.engine.JRChart;
 
32
import net.sf.jasperreports.engine.JRChartPlot;
 
33
import net.sf.jasperreports.engine.JRConstants;
 
34
import net.sf.jasperreports.engine.JRExpression;
 
35
import net.sf.jasperreports.engine.JRExpressionCollector;
 
36
import net.sf.jasperreports.engine.JRFont;
 
37
import net.sf.jasperreports.engine.base.JRBaseChartPlot;
 
38
import net.sf.jasperreports.engine.base.JRBaseFont;
 
39
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;
 
40
import net.sf.jasperreports.engine.util.JRStyleResolver;
 
41
 
 
42
 
 
43
/**
 
44
 * @author Ionut Nedelcu (ionutned@users.sourceforge.net)
 
45
 * @version $Id: JRBaseCandlestickPlot.java 3715 2010-04-08 18:08:49Z teodord $
 
46
 */
 
47
public class JRBaseCandlestickPlot extends JRBaseChartPlot implements JRCandlestickPlot
 
48
{
 
49
        /**
 
50
         *
 
51
         */
 
52
        private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
 
53
        
 
54
        public static final String PROPERTY_SHOW_VOLUME = "showVolume";
 
55
 
 
56
        protected JRExpression timeAxisLabelExpression = null;
 
57
        protected JRFont timeAxisLabelFont = null;
 
58
        protected Color timeAxisLabelColor = null;
 
59
        protected JRFont timeAxisTickLabelFont = null;
 
60
        protected Color timeAxisTickLabelColor = null;
 
61
        protected String timeAxisTickLabelMask = null;
 
62
        protected Boolean timeAxisVerticalTickLabels = null;
 
63
        protected Color timeAxisLineColor = null;
 
64
 
 
65
        protected JRExpression valueAxisLabelExpression = null;
 
66
        protected JRExpression rangeAxisMinValueExpression = null;
 
67
        protected JRExpression rangeAxisMaxValueExpression = null;
 
68
        protected JRExpression domainAxisMinValueExpression = null;
 
69
        protected JRExpression domainAxisMaxValueExpression = null;
 
70
        protected JRFont valueAxisLabelFont = null;
 
71
        protected Color valueAxisLabelColor = null;
 
72
        protected JRFont valueAxisTickLabelFont = null;
 
73
        protected Color valueAxisTickLabelColor = null;
 
74
        protected String valueAxisTickLabelMask = null;
 
75
        protected Boolean valueAxisVerticalTickLabels = null;
 
76
        protected Color valueAxisLineColor = null;
 
77
 
 
78
        protected Boolean showVolume = null;
 
79
 
 
80
        /**
 
81
         *
 
82
         */
 
83
        protected JRBaseCandlestickPlot(JRChartPlot plot, JRChart chart)
 
84
        {
 
85
                super(plot, chart);
 
86
                
 
87
                JRCandlestickPlot candlestickPlot = plot instanceof JRCandlestickPlot ? (JRCandlestickPlot)plot : null;
 
88
                if (candlestickPlot == null)
 
89
                {
 
90
                        timeAxisLabelFont = new JRBaseFont(chart, null);
 
91
                        timeAxisTickLabelFont = new JRBaseFont(chart, null);
 
92
                        valueAxisLabelFont = new JRBaseFont(chart, null);
 
93
                        valueAxisTickLabelFont = new JRBaseFont(chart, null);
 
94
                }
 
95
                else
 
96
                {
 
97
                        timeAxisLabelFont = new JRBaseFont(chart, candlestickPlot.getTimeAxisLabelFont());
 
98
                        timeAxisTickLabelFont = new JRBaseFont(chart, candlestickPlot.getTimeAxisTickLabelFont());
 
99
                        valueAxisLabelFont = new JRBaseFont(chart, candlestickPlot.getValueAxisLabelFont());
 
100
                        valueAxisTickLabelFont = new JRBaseFont(chart, candlestickPlot.getValueAxisTickLabelFont());
 
101
                }
 
102
        }
 
103
 
 
104
 
 
105
        /**
 
106
         *
 
107
         */
 
108
        public JRBaseCandlestickPlot(JRCandlestickPlot candlestickPlot, JRBaseObjectFactory factory)
 
109
        {
 
110
                super(candlestickPlot, factory);
 
111
 
 
112
                showVolume = candlestickPlot.getShowVolume();
 
113
 
 
114
                timeAxisLabelExpression = factory.getExpression( candlestickPlot.getTimeAxisLabelExpression() );
 
115
                timeAxisLabelFont = new JRBaseFont(candlestickPlot.getChart(), candlestickPlot.getTimeAxisLabelFont());
 
116
                timeAxisLabelColor = candlestickPlot.getOwnTimeAxisLabelColor();
 
117
                timeAxisTickLabelFont = new JRBaseFont(candlestickPlot.getChart(), candlestickPlot.getTimeAxisTickLabelFont());
 
118
                timeAxisTickLabelColor = candlestickPlot.getOwnTimeAxisTickLabelColor();
 
119
                timeAxisTickLabelMask = candlestickPlot.getTimeAxisTickLabelMask();
 
120
                timeAxisVerticalTickLabels = candlestickPlot.getTimeAxisVerticalTickLabels();
 
121
                timeAxisLineColor = candlestickPlot.getOwnTimeAxisLineColor();
 
122
                
 
123
                valueAxisLabelExpression = factory.getExpression( candlestickPlot.getValueAxisLabelExpression() );
 
124
                domainAxisMinValueExpression = factory.getExpression( candlestickPlot.getDomainAxisMinValueExpression() );
 
125
                domainAxisMaxValueExpression = factory.getExpression( candlestickPlot.getDomainAxisMaxValueExpression() );
 
126
                rangeAxisMinValueExpression = factory.getExpression( candlestickPlot.getRangeAxisMinValueExpression() );
 
127
                rangeAxisMaxValueExpression = factory.getExpression( candlestickPlot.getRangeAxisMaxValueExpression() );
 
128
                valueAxisLabelFont = new JRBaseFont(candlestickPlot.getChart(), candlestickPlot.getValueAxisLabelFont());
 
129
                valueAxisLabelColor = candlestickPlot.getOwnValueAxisLabelColor();
 
130
                valueAxisTickLabelFont = new JRBaseFont(candlestickPlot.getChart(), candlestickPlot.getValueAxisTickLabelFont());
 
131
                valueAxisTickLabelColor = candlestickPlot.getOwnValueAxisTickLabelColor();
 
132
                valueAxisTickLabelMask = candlestickPlot.getValueAxisTickLabelMask();
 
133
                valueAxisVerticalTickLabels = candlestickPlot.getValueAxisVerticalTickLabels();
 
134
                valueAxisLineColor = candlestickPlot.getOwnValueAxisTickLabelColor();
 
135
        }
 
136
 
 
137
 
 
138
        /**
 
139
         * 
 
140
         */
 
141
        public JRExpression getTimeAxisLabelExpression(){
 
142
                return timeAxisLabelExpression;
 
143
        }
 
144
        
 
145
        /**
 
146
         * 
 
147
         */
 
148
        public JRFont getTimeAxisLabelFont()
 
149
        {
 
150
                return timeAxisLabelFont;
 
151
        }
 
152
        
 
153
        /**
 
154
         * 
 
155
         */
 
156
        public Color getTimeAxisLabelColor()
 
157
        {
 
158
                return JRStyleResolver.getTimeAxisLabelColor(this, this);
 
159
        }
 
160
        
 
161
        /**
 
162
         * 
 
163
         */
 
164
        public Color getOwnTimeAxisLabelColor()
 
165
        {
 
166
                return timeAxisLabelColor;
 
167
        }
 
168
        
 
169
        /**
 
170
         * 
 
171
         */
 
172
        public JRFont getTimeAxisTickLabelFont()
 
173
        {
 
174
                return timeAxisTickLabelFont;
 
175
        }
 
176
        
 
177
        /**
 
178
         * 
 
179
         */
 
180
        public Color getTimeAxisTickLabelColor()
 
181
        {
 
182
                return JRStyleResolver.getTimeAxisTickLabelColor(this, this);
 
183
        }
 
184
 
 
185
        /**
 
186
         * 
 
187
         */
 
188
        public Color getOwnTimeAxisTickLabelColor()
 
189
        {
 
190
                return timeAxisTickLabelColor;
 
191
        }
 
192
 
 
193
        /**
 
194
         * 
 
195
         */
 
196
        public String getTimeAxisTickLabelMask()
 
197
        {
 
198
                return timeAxisTickLabelMask;
 
199
        }
 
200
 
 
201
        /**
 
202
         * 
 
203
         */
 
204
        public Boolean getTimeAxisVerticalTickLabels()
 
205
        {
 
206
                return timeAxisVerticalTickLabels;
 
207
        }
 
208
 
 
209
        /**
 
210
         * 
 
211
         */
 
212
        public Color getTimeAxisLineColor()
 
213
        {
 
214
                return JRStyleResolver.getTimeAxisLineColor(this, this);
 
215
        }
 
216
 
 
217
        /**
 
218
         * 
 
219
         */
 
220
        public Color getOwnTimeAxisLineColor()
 
221
        {
 
222
                return timeAxisLineColor;
 
223
        }
 
224
 
 
225
        /**
 
226
         * 
 
227
         */
 
228
        public JRExpression getValueAxisLabelExpression(){
 
229
                return valueAxisLabelExpression;
 
230
        }
 
231
 
 
232
        /**
 
233
         * 
 
234
         */
 
235
        public JRExpression getDomainAxisMinValueExpression(){
 
236
                return domainAxisMinValueExpression;
 
237
        }
 
238
 
 
239
        /**
 
240
         * 
 
241
         */
 
242
        public JRExpression getDomainAxisMaxValueExpression(){
 
243
                return domainAxisMaxValueExpression;
 
244
        }
 
245
 
 
246
        /**
 
247
         * 
 
248
         */
 
249
        public JRExpression getRangeAxisMinValueExpression(){
 
250
                return rangeAxisMinValueExpression;
 
251
        }
 
252
 
 
253
        /**
 
254
         * 
 
255
         */
 
256
        public JRExpression getRangeAxisMaxValueExpression(){
 
257
                return rangeAxisMaxValueExpression;
 
258
        }
 
259
 
 
260
        /**
 
261
         * 
 
262
         */
 
263
        public JRFont getValueAxisLabelFont()
 
264
        {
 
265
                return valueAxisLabelFont;
 
266
        }
 
267
        
 
268
        /**
 
269
         * 
 
270
         */
 
271
        public Color getValueAxisLabelColor()
 
272
        {
 
273
                return JRStyleResolver.getValueAxisLabelColor(this, this);
 
274
        }
 
275
        
 
276
        /**
 
277
         * 
 
278
         */
 
279
        public Color getOwnValueAxisLabelColor()
 
280
        {
 
281
                return valueAxisLabelColor;
 
282
        }
 
283
        
 
284
        /**
 
285
         * 
 
286
         */
 
287
        public JRFont getValueAxisTickLabelFont()
 
288
        {
 
289
                return valueAxisTickLabelFont;
 
290
        }
 
291
        
 
292
        /**
 
293
         * 
 
294
         */
 
295
        public Color getValueAxisTickLabelColor()
 
296
        {
 
297
                return JRStyleResolver.getValueAxisTickLabelColor(this, this);
 
298
        }
 
299
 
 
300
        /**
 
301
         * 
 
302
         */
 
303
        public Color getOwnValueAxisTickLabelColor()
 
304
        {
 
305
                return valueAxisTickLabelColor;
 
306
        }
 
307
 
 
308
        /**
 
309
         * 
 
310
         */
 
311
        public String getValueAxisTickLabelMask()
 
312
        {
 
313
                return valueAxisTickLabelMask;
 
314
        }
 
315
 
 
316
        /**
 
317
         * 
 
318
         */
 
319
        public Boolean getValueAxisVerticalTickLabels()
 
320
        {
 
321
                return valueAxisVerticalTickLabels;
 
322
        }
 
323
 
 
324
        /**
 
325
         * 
 
326
         */
 
327
        public Color getValueAxisLineColor()
 
328
        {
 
329
                return JRStyleResolver.getValueAxisLineColor(this, this);
 
330
        }
 
331
        
 
332
        /**
 
333
         * 
 
334
         */
 
335
        public Color getOwnValueAxisLineColor()
 
336
        {
 
337
                return valueAxisLineColor;
 
338
        }
 
339
        
 
340
        /**
 
341
         * @deprecated Replaced by {@link #getShowVolume()}
 
342
         */
 
343
        public boolean isShowVolume()
 
344
        {
 
345
                return showVolume == null ? true : showVolume.booleanValue();
 
346
        }
 
347
 
 
348
        /**
 
349
         * 
 
350
         */
 
351
        public Boolean getShowVolume()
 
352
        {
 
353
                return showVolume;
 
354
        }
 
355
 
 
356
 
 
357
        /**
 
358
         * @deprecated Replaced by {@link #setShowVolume(Boolean)}
 
359
         */
 
360
        public void setShowVolume(boolean isShowVolume)
 
361
        {
 
362
                setShowVolume(Boolean.valueOf(isShowVolume));
 
363
        }
 
364
 
 
365
        /**
 
366
         * 
 
367
         */
 
368
        public void setShowVolume(Boolean showVolume)
 
369
        {
 
370
                Boolean old = this.showVolume;
 
371
                this.showVolume = showVolume;
 
372
                getEventSupport().firePropertyChange(PROPERTY_SHOW_VOLUME, old, this.showVolume);
 
373
        }
 
374
 
 
375
        /**
 
376
         *
 
377
         */
 
378
        public void collectExpressions(JRExpressionCollector collector)
 
379
        {
 
380
                collector.collect(this);
 
381
        }
 
382
 
 
383
        /**
 
384
         *
 
385
         */
 
386
        public Object clone(JRChart parentChart) 
 
387
        {
 
388
                JRBaseCandlestickPlot clone = (JRBaseCandlestickPlot)super.clone(parentChart);
 
389
                if (timeAxisLabelExpression != null)
 
390
                {
 
391
                        clone.timeAxisLabelExpression = (JRExpression)timeAxisLabelExpression.clone();
 
392
                }
 
393
                if (valueAxisLabelExpression != null)
 
394
                {
 
395
                        clone.valueAxisLabelExpression = (JRExpression)valueAxisLabelExpression.clone();
 
396
                }
 
397
                if (domainAxisMinValueExpression != null)
 
398
                {
 
399
                        clone.domainAxisMinValueExpression = (JRExpression)domainAxisMinValueExpression.clone();
 
400
                }
 
401
                if (domainAxisMaxValueExpression != null)
 
402
                {
 
403
                        clone.domainAxisMaxValueExpression = (JRExpression)domainAxisMaxValueExpression.clone();
 
404
                }
 
405
                if (rangeAxisMinValueExpression != null)
 
406
                {
 
407
                        clone.rangeAxisMinValueExpression = (JRExpression)rangeAxisMinValueExpression.clone();
 
408
                }
 
409
                if (rangeAxisMaxValueExpression != null)
 
410
                {
 
411
                        clone.rangeAxisMaxValueExpression = (JRExpression)rangeAxisMaxValueExpression.clone();
 
412
                }
 
413
                return clone;
 
414
        }
 
415
        
 
416
        /*
 
417
         * These fields are only for serialization backward compatibility.
 
418
         */
 
419
        private int PSEUDO_SERIAL_VERSION_UID = JRConstants.PSEUDO_SERIAL_VERSION_UID; //NOPMD
 
420
        /**
 
421
         * @deprecated
 
422
         */
 
423
        private boolean isShowVolume = true;
 
424
        
 
425
        private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
 
426
        {
 
427
                in.defaultReadObject();
 
428
                
 
429
                if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_1_3)
 
430
                {
 
431
                        showVolume = Boolean.valueOf(isShowVolume);
 
432
                }
 
433
        }
 
434
        
 
435
}