KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > plugin > jfreechart > TimeSeriesCollectionChartDefinition


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12 */

13 /*
14  * Copyright 2006 Pentaho Corporation. All rights reserved.
15  * This software was developed by Pentaho Corporation and is provided under the terms
16  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
17  * this file except in compliance with the license. If you need a copy of the license,
18  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
19  * BI Platform. The Initial Developer is Pentaho Corporation.
20  *
21  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
22  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
23  * the license for the specific language governing your rights and limitations.
24  *
25  * Created Jun 19, 2006
26  * @author rtroyer
27  */

28
29 package org.pentaho.plugin.jfreechart;
30
31 import java.awt.Color JavaDoc;
32 import java.awt.Font JavaDoc;
33 import java.awt.Image JavaDoc;
34 import java.awt.Paint JavaDoc;
35 import java.util.ArrayList JavaDoc;
36 import java.util.Date JavaDoc;
37 import java.util.Iterator JavaDoc;
38 import java.util.List JavaDoc;
39
40 import org.dom4j.Node;
41 import org.jfree.chart.plot.PlotOrientation;
42 import org.jfree.chart.title.TextTitle;
43 import org.jfree.data.time.TimeSeriesCollection;
44 import org.jfree.data.time.TimeSeries;
45 import org.jfree.data.time.TimeSeriesDataItem;
46 import org.jfree.data.time.Day;
47 import org.jfree.data.time.Hour;
48 import org.jfree.data.time.Millisecond;
49 import org.jfree.data.time.Minute;
50 import org.jfree.data.time.Month;
51 import org.jfree.data.time.Quarter;
52 import org.jfree.data.time.RegularTimePeriod;
53 import org.jfree.data.time.Second;
54 import org.jfree.data.time.Week;
55 import org.jfree.data.time.Year;
56 import org.jfree.ui.RectangleEdge;
57 import org.pentaho.core.connection.IPentahoResultSet;
58 import org.pentaho.core.session.IPentahoSession;
59
60 public class TimeSeriesCollectionChartDefinition extends TimeSeriesCollection implements ChartDefinition {
61
62     private static final String JavaDoc STACKED_NODE_NAME = "is-stacked"; //$NON-NLS-1$
63

64     private static final String JavaDoc ORIENTATION_NODE_NAME = "orientation"; //$NON-NLS-1$
65

66     private static final String JavaDoc DOMAIN_TITLE_NODE_NAME = "domain-title"; //$NON-NLS-1$
67

68     private static final String JavaDoc DOMAIN_TITLE_FONT_NODE_NAME = "domain-title-font"; //$NON-NLS-1$
69

70     private static final String JavaDoc RANGE_TITLE_NODE_NAME = "range-title"; //$NON-NLS-1$
71

72     private static final String JavaDoc RANGE_TITLE_FONT_NODE_NAME = "range-title-font"; //$NON-NLS-1$
73

74     private static final String JavaDoc DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME = "domain-vertical-tick-labels"; //$NON-NLS-1$
75

76     private static final String JavaDoc DOMAIN_PERIOD_TYPE_NODE_NAME = "domain-period-type"; //$NON-NLS-1$
77

78     private static final String JavaDoc CHART_BORDER_PAINT_NODE_NAME = "border-paint"; //$NON-NLS-1$
79

80     private int chartType = JFreeChartEngine.UNDEFINED_CHART_TYPE;
81
82     // JFreeChart Customizations
83
private String JavaDoc title = ""; //$NON-NLS-1$
84

85     private RectangleEdge titlePosition = RectangleEdge.TOP;
86
87     private Font JavaDoc titleFont = TextTitle.DEFAULT_FONT;
88
89     private List JavaDoc subTitles = new ArrayList JavaDoc();
90
91     private Paint JavaDoc chartBackgroundPaint = Color.WHITE;
92
93     private Image JavaDoc chartBackgroundImage = null;
94
95     private boolean borderVisible = false;
96
97     private Paint JavaDoc borderPaint = Color.BLACK;
98
99     private int width = 200;
100
101     private int height = 200;
102
103     // Plot Customizations
104
private PlotOrientation orientation = PlotOrientation.VERTICAL;
105
106     private Paint JavaDoc plotBackgroundPaint = Color.WHITE;
107
108     private Image JavaDoc plotBackgroundImage = null;
109
110     private boolean legendIncluded = true;
111
112     private boolean threeD = false;
113
114     private boolean stacked = false;
115
116     private boolean domainVerticalTickLabels = false;
117
118     private String JavaDoc domainPeriodType = "Millisecond"; //$NON-NLS-1$
119

120     private Paint JavaDoc[] paintSequence = null;
121
122     private String JavaDoc domainTitle = null;
123
124     private Font JavaDoc domainTitleFont = TextTitle.DEFAULT_FONT;
125
126     private String JavaDoc rangeTitle = null;
127
128     private Font JavaDoc rangeTitleFont = TextTitle.DEFAULT_FONT;
129     
130     // Other stuff
131
private IPentahoSession session;
132
133     /**
134      *
135      */

136     private static final long serialVersionUID = 1717509132920946530L;
137
138     public TimeSeriesCollectionChartDefinition(IPentahoSession session) {
139         super();
140         this.session = session;
141     }
142
143     public TimeSeriesCollectionChartDefinition(int chartType, IPentahoResultSet data, boolean byRow, Node chartAttributes, IPentahoSession session) {
144         this(session);
145         this.chartType = chartType;
146         setChartAttributes(chartAttributes);
147         if (byRow) {
148             setDataByRow(data);
149         } else {
150             setDataByColumn(data);
151         }
152     }
153
154     public TimeSeriesCollectionChartDefinition(IPentahoResultSet data, boolean byRow, Node chartAttributes, IPentahoSession session) {
155         this(JFreeChartEngine.UNDEFINED_CHART_TYPE, data, byRow, chartAttributes, session);
156     }
157
158     private void setChartAttributes(Node chartAttributes) {
159         if (chartAttributes == null) {
160             return;
161         }
162         // get the chart type from the chart node -- this overrides the current
163
// chart type
164
setChartType(chartAttributes.selectSingleNode(TYPE_NODE_NAME));
165
166         // set the chart background
167
setChartBackground(chartAttributes.selectSingleNode(CHART_BACKGROUND_NODE_NAME));
168
169         // set the plot background
170
setPlotBackground(chartAttributes.selectSingleNode(PLOT_BACKGROUND_NODE_NAME));
171
172         // set the orientation
173
setOrientation(chartAttributes.selectSingleNode(ORIENTATION_NODE_NAME));
174
175         // do we want a legend
176
setLegendIncluded(chartAttributes.selectSingleNode(INCLUDE_LEGEND_NODE_NAME));
177
178         // get the chart title
179
setTitle(chartAttributes.selectSingleNode(TITLE_NODE_NAME));
180
181         // get the chart subtitles
182
addSubTitles(chartAttributes.selectNodes(SUBTITLE_NODE_NAME));
183
184         // get the paint sequence
185
setPaintSequence(chartAttributes.selectSingleNode(PALETTE_NODE_NAME));
186
187         // get the stacked value
188
setStacked(chartAttributes.selectSingleNode(STACKED_NODE_NAME));
189
190         // get the 3D value
191
setThreeD(chartAttributes.selectSingleNode(THREED_NODE_NAME));
192
193         // set the width
194
setWidth(chartAttributes.selectSingleNode(WIDTH_NODE_NAME));
195
196         // set the height
197
setHeight(chartAttributes.selectSingleNode(HEIGHT_NODE_NAME));
198
199         // set vertical tick labels flag
200
setDomainVerticalTickLabels(chartAttributes.selectSingleNode(DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME));
201
202         // set the border on or off
203
setBorderVisible(chartAttributes.selectSingleNode(CHART_BORDER_VISIBLE_NODE_NAME));
204
205         // set the border Paint
206
setBorderPaint(JFreeChartEngine.getPaint(chartAttributes.selectSingleNode(CHART_BORDER_PAINT_NODE_NAME)));
207
208         // set the title location
209
setTitlePosition(chartAttributes.selectSingleNode(TITLE_POSITION_NODE_NAME));
210
211         // set the title font
212
setTitleFont(chartAttributes.selectSingleNode(TITLE_FONT_NODE_NAME));
213
214         // set the domain title
215
setDomainTitle(chartAttributes.selectSingleNode(DOMAIN_TITLE_NODE_NAME));
216
217         // set the domain font
218
setDomainTitleFont(chartAttributes.selectSingleNode(DOMAIN_TITLE_FONT_NODE_NAME));
219
220         // set the range title
221
setRangeTitle(chartAttributes.selectSingleNode(RANGE_TITLE_NODE_NAME));
222
223         // the the range font
224
setRangeTitleFont(chartAttributes.selectSingleNode(RANGE_TITLE_FONT_NODE_NAME));
225
226         // set the Period type
227
setDomainPeriodType(chartAttributes.selectSingleNode(DOMAIN_PERIOD_TYPE_NODE_NAME));
228     }
229
230     private void setDataByColumn(IPentahoResultSet data) {
231         // TODO Make this routine MDX friendly
232
if (data == null) {
233             return; // No data so we've got nothing to set
234
// TODO come up with some sort of error strategy here.
235
}
236         boolean firstPass = true;
237         String JavaDoc lastSeries = ""; //$NON-NLS-1$
238
String JavaDoc seriesName = ""; //$NON-NLS-1$
239
Class JavaDoc timePeriodClass = getTimePeriodClass( getDomainPeriodType() );
240         Object JavaDoc[] rowData = data.next();
241         TimeSeries wrkSeries = null;
242         while (rowData != null) {
243             seriesName = (String JavaDoc) rowData[0];
244             if ( firstPass || !seriesName.equalsIgnoreCase( lastSeries ) ) {
245                 if ( !firstPass ) {
246                     addSeries( wrkSeries );
247                 }
248                 wrkSeries = new TimeSeries( seriesName, timePeriodClass );
249                 lastSeries = seriesName;
250                 firstPass = false;
251             }
252             RegularTimePeriod regularTimePeriod = RegularTimePeriod.createInstance( timePeriodClass,
253                                                                                     (Date JavaDoc) rowData[1],
254                                                                                     RegularTimePeriod.DEFAULT_TIME_ZONE );
255             TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem(
256                            regularTimePeriod,
257                           ((Number JavaDoc) rowData[2]).doubleValue() );
258             wrkSeries.add( timeSeriesDataItem );
259             rowData = data.next();
260         }
261         if ( !firstPass ) {
262             addSeries( wrkSeries );
263         }
264     }
265
266     private void setDataByRow(IPentahoResultSet data) {
267         // TODO Make this routine MDX friendly
268
if (data == null) {
269             return; // No data so we've got nothing to set
270
// TODO come up with some sort of error strategy here.
271
}
272         Class JavaDoc timePeriodClass = getTimePeriodClass( getDomainPeriodType() );
273         Object JavaDoc[] rowData = data.next();
274         while (rowData != null) {
275             String JavaDoc seriesName = (String JavaDoc) rowData[0];
276             TimeSeries wrkSeries = new TimeSeries( seriesName, timePeriodClass );
277             for (int column = 1; column < rowData.length - 1; column = column + 2) {
278                 TimeSeriesDataItem timeSeriesDataItem = new TimeSeriesDataItem(
279                                RegularTimePeriod.createInstance(timePeriodClass, (Date JavaDoc) rowData[column], RegularTimePeriod.DEFAULT_TIME_ZONE),
280                                ((Number JavaDoc) rowData[column+1]).doubleValue() );
281                 wrkSeries.add( timeSeriesDataItem );
282             }
283             addSeries( wrkSeries );
284             rowData = data.next();
285         }
286     }
287     
288     private Class JavaDoc getTimePeriodClass( String JavaDoc timePeriodStr ) {
289        Class JavaDoc retClass = Millisecond.class;
290        if (timePeriodStr.equalsIgnoreCase( SECOND_PERIOD_TYPE_STR )) {
291           retClass = Second.class;
292        } else if (timePeriodStr.equalsIgnoreCase( MINUTE_PERIOD_TYPE_STR )) {
293           retClass = Minute.class;
294        } else if (timePeriodStr.equalsIgnoreCase( HOUR_PERIOD_TYPE_STR )) {
295           retClass = Hour.class;
296        } else if (timePeriodStr.equalsIgnoreCase( DAY_PERIOD_TYPE_STR )) {
297           retClass = Day.class;
298        } else if (timePeriodStr.equalsIgnoreCase( WEEK_PERIOD_TYPE_STR )) {
299           retClass = Week.class;
300        } else if (timePeriodStr.equalsIgnoreCase( MONTH_PERIOD_TYPE_STR )) {
301           retClass = Month.class;
302        } else if (timePeriodStr.equalsIgnoreCase( QUARTER_PERIOD_TYPE_STR )) {
303           retClass = Quarter.class;
304        } else if (timePeriodStr.equalsIgnoreCase( YEAR_PERIOD_TYPE_STR )) {
305           retClass = Year.class;
306        }
307        return retClass;
308     }
309
310     /**
311      * @param backgroundPaint
312      * The backgroundPaint to set.
313      */

314     public void setChartBackgroundPaint(Paint JavaDoc chartBackgroundPaint) {
315         if (chartBackgroundPaint != null) {
316             this.chartBackgroundPaint = chartBackgroundPaint;
317         }
318     }
319
320     /**
321      * Return the java.awt.Font to be used to display the dial title
322      *
323      * @return Font The Font for the title of this Pie
324      */

325     public Font JavaDoc getTitleFont() {
326         return titleFont;
327     }
328
329     public void setTitleFont(Font JavaDoc titleFont) {
330         this.titleFont = titleFont;
331     }
332
333     public void setTitleFont(Node titleFontNode) {
334         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
335         if (font != null) {
336             setTitleFont(font);
337         }
338     }
339
340     /**
341      * @return Returns the backgroundPaint.
342      */

343     public Paint JavaDoc getChartBackgroundPaint() {
344         return chartBackgroundPaint;
345     }
346
347     /**
348      * @return Returns the chartType.
349      */

350     public int getChartType() {
351         return chartType;
352     }
353
354     public static int getChartType(String JavaDoc typeStr) {
355         if (typeStr != null) {
356             if (LINE_CHART_STR.equalsIgnoreCase(typeStr)) {
357                 return JFreeChartEngine.LINE_CHART_TYPE;
358             } else if (AREA_CHART_STR.equalsIgnoreCase(typeStr)) {
359                 return JFreeChartEngine.AREA_CHART_TYPE;
360             } else if (STEP_CHART_STR.equalsIgnoreCase(typeStr)) {
361                 return JFreeChartEngine.STEP_CHART_TYPE;
362             } else if (STEP_AREA_CHART_STR.equalsIgnoreCase(typeStr)) {
363                 return JFreeChartEngine.STEP_AREA_CHART_TYPE;
364             } else if (DIFFERENCE_CHART_STR.equalsIgnoreCase(typeStr)) {
365                 return JFreeChartEngine.DIFFERENCE_CHART_TYPE;
366             } else if (DOT_CHART_STR.equalsIgnoreCase(typeStr)) {
367                 return JFreeChartEngine.DOT_CHART_TYPE;
368             }
369         }
370         return JFreeChartEngine.UNDEFINED_CHART_TYPE;
371     }
372
373     public void setChartType(Node chartTypeNode) {
374         if (chartTypeNode != null) {
375             String JavaDoc typeStr = chartTypeNode.getText();
376             setChartType(getChartType(typeStr));
377         }
378     }
379
380     /**
381      * @param chartType
382      * The chartType to set.
383      */

384     public void setChartType(int chartType) {
385         this.chartType = chartType;
386     }
387
388     /**
389      * @return Returns the threeD.
390      */

391     public boolean isThreeD() {
392         return threeD;
393     }
394
395     public void setThreeD(Node threeDNode) {
396         if (threeDNode != null) {
397             String JavaDoc boolStr = threeDNode.getText();
398             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
399             setThreeD(booleanValue.booleanValue());
400         }
401     }
402
403     /**
404      * @param threeD
405      * The threeD to set.
406      */

407     public void setThreeD(boolean threeD) {
408         this.threeD = threeD;
409     }
410
411     /**
412      * @return Returns the stacked.
413      */

414     public boolean isStacked() {
415         return stacked;
416     }
417
418     public void setStacked(Node stackedNode) {
419         if (stackedNode != null) {
420             String JavaDoc boolStr = stackedNode.getText();
421             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
422             setStacked(booleanValue.booleanValue());
423         }
424     }
425
426     /**
427      * @param stacked
428      * The stacked to set.
429      */

430     public void setStacked(boolean stacked) {
431         this.stacked = stacked;
432     }
433
434     /**
435      * @return Returns the verticalTickLabels.
436      */

437     public boolean isDomainVerticalTickLabels() {
438         return domainVerticalTickLabels;
439     }
440
441     public void setDomainVerticalTickLabels(Node domainVerticalTickLabelsNode) {
442         if (domainVerticalTickLabelsNode != null) {
443             String JavaDoc boolStr = domainVerticalTickLabelsNode.getText();
444             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
445             setDomainVerticalTickLabels(booleanValue.booleanValue());
446         }
447     }
448
449     /**
450      * @param domainVerticalTickLabels
451      * The domainVerticalLabels to set.
452      */

453     public void setDomainVerticalTickLabels(boolean domainVerticalTickLabels) {
454         this.domainVerticalTickLabels = domainVerticalTickLabels;
455     }
456
457     /**
458      * @return Returns the domainPeriodType.
459      */

460     public String JavaDoc getDomainPeriodType() {
461         return domainPeriodType;
462     }
463
464     public void setDomainPeriodType(Node domainPeriodTypeNode) {
465         if (domainPeriodTypeNode != null) {
466             setDomainPeriodType(domainPeriodTypeNode.getText());
467         }
468     }
469
470     /**
471      * @param domainPeriodType
472      * The domainPeriodType to set.
473      */

474     public void setDomainPeriodType(String JavaDoc domainPeriodType) {
475         this.domainPeriodType = domainPeriodType;
476     }
477
478     /**
479      * @return Returns the height.
480      */

481     public int getHeight() {
482         return height;
483     }
484
485     public void setHeight(Node heightNode) {
486         if (heightNode != null) {
487             setHeight(Integer.parseInt(heightNode.getText()));
488         }
489     }
490
491     /**
492      * @param height
493      * The height to set.
494      */

495     public void setHeight(int height) {
496         this.height = height;
497     }
498
499     /**
500      * @return Returns the width.
501      */

502     public int getWidth() {
503         return width;
504     }
505
506     public void setWidth(Node widthNode) {
507         if (widthNode != null) {
508             setWidth(Integer.parseInt(widthNode.getText()));
509         }
510     }
511
512     /**
513      * @param width
514      * The width to set.
515      */

516     public void setWidth(int width) {
517         this.width = width;
518     }
519
520     /**
521      * @return Returns the title.
522      */

523     public String JavaDoc getTitle() {
524         return title;
525     }
526
527     public void setTitle(Node chartTitleNode) {
528         if (chartTitleNode != null) {
529             setTitle(chartTitleNode.getText());
530         }
531     }
532
533     /**
534      * @param title
535      * The title to set.
536      */

537     public void setTitle(String JavaDoc title) {
538         this.title = title;
539     }
540
541     /**
542      * @return Returns the paintSequence.
543      */

544     public Paint JavaDoc[] getPaintSequence() {
545         return paintSequence;
546     }
547
548     public void setPaintSequence(Node paletteNode) {
549         if (paletteNode != null) {
550             List JavaDoc colorNodes = paletteNode.selectNodes(COLOR_NODE_NAME);
551             Paint JavaDoc[] paints = new Paint JavaDoc[colorNodes.size()];
552             for (int i = 0; i < colorNodes.size(); i++) {
553                 paints[i] = JFreeChartEngine.getPaint((Node) colorNodes.get(i));
554             }
555             setPaintSequence(paints);
556         }
557     }
558
559     /**
560      * @param paintSequence
561      * The paintSequence to set.
562      */

563     public void setPaintSequence(Paint JavaDoc[] paintSequence) {
564         this.paintSequence = paintSequence;
565     }
566
567     /**
568      * @return Returns the subTitles.
569      */

570     public List JavaDoc getSubtitles() {
571         return subTitles;
572     }
573
574     public void addSubTitles(List JavaDoc subTitleNodes) {
575         if (subTitleNodes != null) {
576             Iterator JavaDoc iter = subTitleNodes.iterator();
577             while (iter.hasNext()) {
578                 addSubTitle(((Node) iter.next()).getText());
579             }
580         }
581     }
582
583     public void addSubTitle(String JavaDoc subTitle) {
584         subTitles.add(subTitle);
585     }
586
587     /**
588      * @return Returns the chartBackgroundImage.
589      */

590     public Image JavaDoc getChartBackgroundImage() {
591         return chartBackgroundImage;
592     }
593
594     public void setChartBackgroundImage(Node chartBackgroundImageNode) {
595         setChartBackgroundImage(JFreeChartEngine.getImage(chartBackgroundImageNode, getSession()));
596     }
597
598     /**
599      * @param chartBackgroundImage
600      * The chartBackgroundImage to set.
601      */

602     public void setChartBackgroundImage(Image JavaDoc chartBackgroundImage) {
603         this.chartBackgroundImage = chartBackgroundImage;
604     }
605
606     /**
607      * @return Returns the legendIncluded.
608      */

609     public boolean isLegendIncluded() {
610         return legendIncluded;
611     }
612
613     public void setLegendIncluded(Node legendNode) {
614         if (legendNode != null) {
615             String JavaDoc boolStr = legendNode.getText();
616             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
617             setLegendIncluded(booleanValue.booleanValue());
618         }
619     }
620
621     /**
622      * @param legendIncluded
623      * The legendIncluded to set.
624      */

625     public void setLegendIncluded(boolean legendIncluded) {
626         this.legendIncluded = legendIncluded;
627     }
628
629     public void setPlotBackgroundPaint(Paint JavaDoc plotBackgroundPaint) {
630         if (plotBackgroundPaint != null) {
631             this.plotBackgroundPaint = plotBackgroundPaint;
632         }
633     }
634
635     public Paint JavaDoc getPlotBackgroundPaint() {
636         return plotBackgroundPaint;
637     }
638
639     /**
640      * @return Returns the plotBackgroundImage.
641      */

642     public Image JavaDoc getPlotBackgroundImage() {
643         return plotBackgroundImage;
644     }
645
646     public void setPlotBackgroundImage(Node plotBackgroundImageNode) {
647         setPlotBackgroundImage(JFreeChartEngine.getImage(plotBackgroundImageNode, getSession()));
648     }
649
650     /**
651      * @param plotBackgroundImage
652      * The plotBackgroundImage to set.
653      */

654     public void setPlotBackgroundImage(Image JavaDoc plotBackgroundImage) {
655         this.plotBackgroundImage = plotBackgroundImage;
656     }
657
658     /**
659      * @return Returns the orientation.
660      */

661     public PlotOrientation getOrientation() {
662         return orientation;
663     }
664
665     public void setOrientation(Node orientationNode) {
666         if (orientationNode != null) {
667             String JavaDoc orientationStr = orientationNode.getText();
668             if (VERTICAL_ORIENTATION.equalsIgnoreCase(orientationStr)) {
669                 setOrientation(PlotOrientation.VERTICAL);
670             } else if (HORIZONTAL_ORIENTATION.equalsIgnoreCase(orientationStr)) {
671                 setOrientation(PlotOrientation.HORIZONTAL);
672             }
673         }
674     }
675
676     /**
677      * @param orientation
678      * The orientation to set.
679      */

680     public void setOrientation(PlotOrientation orientation) {
681         this.orientation = orientation;
682     }
683
684     /**
685      * @return Returns the borderVisible.
686      */

687     public boolean isBorderVisible() {
688         return borderVisible;
689     }
690
691     public void setBorderVisible(Node borderVisibleNode) {
692         if (borderVisibleNode != null) {
693             String JavaDoc boolStr = borderVisibleNode.getText();
694             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
695             setBorderVisible(booleanValue.booleanValue());
696         }
697     }
698
699     /**
700      * @param borderVisible
701      * The borderVisible to set.
702      */

703     public void setBorderVisible(boolean borderVisible) {
704         this.borderVisible = borderVisible;
705     }
706
707     /**
708      * @return Returns the borderPaint.
709      */

710     public Paint JavaDoc getBorderPaint() {
711         return borderPaint;
712     }
713
714     /**
715      * @param borderPaint
716      * The borderPaint to set.
717      */

718     public void setBorderPaint(Paint JavaDoc borderPaint) {
719         this.borderPaint = borderPaint;
720     }
721
722     public void setTitlePosition(Node titlePositionNode) {
723         if (titlePositionNode != null) {
724             String JavaDoc titlePositionStr = titlePositionNode.getText();
725             if ("top".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
726
setTitlePosition(RectangleEdge.TOP);
727             } else if ("left".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
728
setTitlePosition(RectangleEdge.LEFT);
729             } else if ("bottom".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
730
setTitlePosition(RectangleEdge.BOTTOM);
731             } else if ("right".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
732
setTitlePosition(RectangleEdge.RIGHT);
733             }
734         }
735     }
736
737     /**
738      * @return Returns the titlePosition.
739      */

740     public RectangleEdge getTitlePosition() {
741         return titlePosition;
742     }
743
744     /**
745      * @param titlePosition
746      * The titlePosition to set.
747      */

748     public void setTitlePosition(RectangleEdge titlePosition) {
749         this.titlePosition = titlePosition;
750     }
751
752     public void setChartBackground(Node chartBackgroundNode) {
753         if (chartBackgroundNode != null) {
754             Node backgroundTypeNode = chartBackgroundNode.selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
755             if (backgroundTypeNode != null) {
756                 String JavaDoc backgroundTypeStr = backgroundTypeNode.getText();
757                 if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
758                     setChartBackgroundPaint(JFreeChartEngine.getPaint(chartBackgroundNode));
759                     setChartBackgroundImage((Image JavaDoc) null);
760                 } else if (IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
761                     setChartBackgroundImage(chartBackgroundNode);
762                     setChartBackgroundPaint(null);
763                 } else if (TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
764                     setChartBackgroundPaint(JFreeChartEngine.getTexturePaint(chartBackgroundNode, getWidth(), getHeight(), getSession()));
765                     setChartBackgroundImage((Image JavaDoc) null);
766                 } else if (GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
767                     setChartBackgroundPaint(JFreeChartEngine.getGradientPaint(chartBackgroundNode, getWidth(), getHeight()));
768                     setChartBackgroundImage((Image JavaDoc) null);
769                 }
770             }
771         }
772     }
773
774     public void setPlotBackground(Node plotBackgroundNode) {
775         if (plotBackgroundNode != null) {
776             Node backgroundTypeNode = plotBackgroundNode.selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
777             if (backgroundTypeNode != null) {
778                 String JavaDoc backgroundTypeStr = backgroundTypeNode.getText();
779                 if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
780                     setPlotBackgroundPaint(JFreeChartEngine.getPaint(plotBackgroundNode));
781                     setPlotBackgroundImage((Image JavaDoc) null);
782                 } else if (IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
783                     setPlotBackgroundImage(plotBackgroundNode);
784                     setPlotBackgroundPaint(null);
785                 } else if (TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
786                     setPlotBackgroundPaint(JFreeChartEngine.getTexturePaint(plotBackgroundNode, getWidth(), getHeight(), getSession()));
787                     setPlotBackgroundImage((Image JavaDoc) null);
788                 } else if (GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
789                     setPlotBackgroundPaint(JFreeChartEngine.getGradientPaint(plotBackgroundNode, getWidth(), getHeight()));
790                     setPlotBackgroundImage((Image JavaDoc) null);
791                 }
792             }
793         }
794     }
795
796     public void setDomainTitle(Node titleNode) {
797         if (titleNode != null) {
798             setDomainTitle(titleNode.getText());
799         }
800     }
801
802     /**
803      * @return Returns the domainTitle.
804      */

805     public String JavaDoc getDomainTitle() {
806         return domainTitle;
807     }
808
809     /**
810      * @param domainTitle
811      * The domainTitle to set.
812      */

813     public void setDomainTitle(String JavaDoc domainTitle) {
814         this.domainTitle = domainTitle;
815     }
816
817     public void setRangeTitle(Node titleNode) {
818         if (titleNode != null) {
819             setRangeTitle(titleNode.getText());
820         }
821     }
822
823     /**
824      * @return Returns the rangeTitle.
825      */

826     public String JavaDoc getRangeTitle() {
827         return rangeTitle;
828     }
829
830     /**
831      * @param rangeTitle
832      * The rangeTitle to set.
833      */

834     public void setRangeTitle(String JavaDoc rangeTitle) {
835         this.rangeTitle = rangeTitle;
836     }
837
838     public void setDomainTitleFont(Node titleFontNode) {
839         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
840         if (font != null) {
841             setDomainTitleFont(font);
842         }
843     }
844
845     /**
846      * @return Returns the domainTitleFont.
847      */

848     public Font JavaDoc getDomainTitleFont() {
849         return domainTitleFont;
850     }
851
852     /**
853      * @param domainTitleFont
854      * The domainTitleFont to set.
855      */

856     public void setDomainTitleFont(Font JavaDoc domainTitleFont) {
857         this.domainTitleFont = domainTitleFont;
858     }
859
860     public void setRangeTitleFont(Node titleFontNode) {
861         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
862         if (font != null) {
863             setRangeTitleFont(font);
864         }
865     }
866
867     /**
868      * @return Returns the rangeTitleFont.
869      */

870     public Font JavaDoc getRangeTitleFont() {
871         return rangeTitleFont;
872     }
873
874     /**
875      * @param rangeTitleFont
876      * The rangeTitleFont to set.
877      */

878     public void setRangeTitleFont(Font JavaDoc rangeTitleFont) {
879         this.rangeTitleFont = rangeTitleFont;
880     }
881
882     public boolean isDisplayLabels() {
883         // TODO Auto-generated method stub
884
return false;
885     }
886
887     public IPentahoSession getSession() {
888         return session;
889     }
890
891     public void setSession(IPentahoSession session) {
892         this.session = session;
893     }
894 }
895
Popular Tags