2
* JasperReports - Free Java Reporting Library.
3
* Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
4
* http://www.jaspersoft.com
6
* Unless you have purchased a commercial license agreement from Jaspersoft,
7
* the following license terms apply:
9
* This program is part of JasperReports.
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.
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.
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/>.
24
package net.sf.jasperreports.charts.base;
26
import java.awt.Color;
27
import java.io.IOException;
28
import java.io.ObjectInputStream;
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;
44
* @author Ionut Nedelcu (ionutned@users.sourceforge.net)
45
* @version $Id: JRBaseCandlestickPlot.java 3715 2010-04-08 18:08:49Z teodord $
47
public class JRBaseCandlestickPlot extends JRBaseChartPlot implements JRCandlestickPlot
52
private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
54
public static final String PROPERTY_SHOW_VOLUME = "showVolume";
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;
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;
78
protected Boolean showVolume = null;
83
protected JRBaseCandlestickPlot(JRChartPlot plot, JRChart chart)
87
JRCandlestickPlot candlestickPlot = plot instanceof JRCandlestickPlot ? (JRCandlestickPlot)plot : null;
88
if (candlestickPlot == null)
90
timeAxisLabelFont = new JRBaseFont(chart, null);
91
timeAxisTickLabelFont = new JRBaseFont(chart, null);
92
valueAxisLabelFont = new JRBaseFont(chart, null);
93
valueAxisTickLabelFont = new JRBaseFont(chart, null);
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());
108
public JRBaseCandlestickPlot(JRCandlestickPlot candlestickPlot, JRBaseObjectFactory factory)
110
super(candlestickPlot, factory);
112
showVolume = candlestickPlot.getShowVolume();
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();
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();
141
public JRExpression getTimeAxisLabelExpression(){
142
return timeAxisLabelExpression;
148
public JRFont getTimeAxisLabelFont()
150
return timeAxisLabelFont;
156
public Color getTimeAxisLabelColor()
158
return JRStyleResolver.getTimeAxisLabelColor(this, this);
164
public Color getOwnTimeAxisLabelColor()
166
return timeAxisLabelColor;
172
public JRFont getTimeAxisTickLabelFont()
174
return timeAxisTickLabelFont;
180
public Color getTimeAxisTickLabelColor()
182
return JRStyleResolver.getTimeAxisTickLabelColor(this, this);
188
public Color getOwnTimeAxisTickLabelColor()
190
return timeAxisTickLabelColor;
196
public String getTimeAxisTickLabelMask()
198
return timeAxisTickLabelMask;
204
public Boolean getTimeAxisVerticalTickLabels()
206
return timeAxisVerticalTickLabels;
212
public Color getTimeAxisLineColor()
214
return JRStyleResolver.getTimeAxisLineColor(this, this);
220
public Color getOwnTimeAxisLineColor()
222
return timeAxisLineColor;
228
public JRExpression getValueAxisLabelExpression(){
229
return valueAxisLabelExpression;
235
public JRExpression getDomainAxisMinValueExpression(){
236
return domainAxisMinValueExpression;
242
public JRExpression getDomainAxisMaxValueExpression(){
243
return domainAxisMaxValueExpression;
249
public JRExpression getRangeAxisMinValueExpression(){
250
return rangeAxisMinValueExpression;
256
public JRExpression getRangeAxisMaxValueExpression(){
257
return rangeAxisMaxValueExpression;
263
public JRFont getValueAxisLabelFont()
265
return valueAxisLabelFont;
271
public Color getValueAxisLabelColor()
273
return JRStyleResolver.getValueAxisLabelColor(this, this);
279
public Color getOwnValueAxisLabelColor()
281
return valueAxisLabelColor;
287
public JRFont getValueAxisTickLabelFont()
289
return valueAxisTickLabelFont;
295
public Color getValueAxisTickLabelColor()
297
return JRStyleResolver.getValueAxisTickLabelColor(this, this);
303
public Color getOwnValueAxisTickLabelColor()
305
return valueAxisTickLabelColor;
311
public String getValueAxisTickLabelMask()
313
return valueAxisTickLabelMask;
319
public Boolean getValueAxisVerticalTickLabels()
321
return valueAxisVerticalTickLabels;
327
public Color getValueAxisLineColor()
329
return JRStyleResolver.getValueAxisLineColor(this, this);
335
public Color getOwnValueAxisLineColor()
337
return valueAxisLineColor;
341
* @deprecated Replaced by {@link #getShowVolume()}
343
public boolean isShowVolume()
345
return showVolume == null ? true : showVolume.booleanValue();
351
public Boolean getShowVolume()
358
* @deprecated Replaced by {@link #setShowVolume(Boolean)}
360
public void setShowVolume(boolean isShowVolume)
362
setShowVolume(Boolean.valueOf(isShowVolume));
368
public void setShowVolume(Boolean showVolume)
370
Boolean old = this.showVolume;
371
this.showVolume = showVolume;
372
getEventSupport().firePropertyChange(PROPERTY_SHOW_VOLUME, old, this.showVolume);
378
public void collectExpressions(JRExpressionCollector collector)
380
collector.collect(this);
386
public Object clone(JRChart parentChart)
388
JRBaseCandlestickPlot clone = (JRBaseCandlestickPlot)super.clone(parentChart);
389
if (timeAxisLabelExpression != null)
391
clone.timeAxisLabelExpression = (JRExpression)timeAxisLabelExpression.clone();
393
if (valueAxisLabelExpression != null)
395
clone.valueAxisLabelExpression = (JRExpression)valueAxisLabelExpression.clone();
397
if (domainAxisMinValueExpression != null)
399
clone.domainAxisMinValueExpression = (JRExpression)domainAxisMinValueExpression.clone();
401
if (domainAxisMaxValueExpression != null)
403
clone.domainAxisMaxValueExpression = (JRExpression)domainAxisMaxValueExpression.clone();
405
if (rangeAxisMinValueExpression != null)
407
clone.rangeAxisMinValueExpression = (JRExpression)rangeAxisMinValueExpression.clone();
409
if (rangeAxisMaxValueExpression != null)
411
clone.rangeAxisMaxValueExpression = (JRExpression)rangeAxisMaxValueExpression.clone();
417
* These fields are only for serialization backward compatibility.
419
private int PSEUDO_SERIAL_VERSION_UID = JRConstants.PSEUDO_SERIAL_VERSION_UID; //NOPMD
423
private boolean isShowVolume = true;
425
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
427
in.defaultReadObject();
429
if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_1_3)
431
showVolume = Boolean.valueOf(isShowVolume);