KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Created Jun 19, 2006
14  * @author rtroyer
15  */

16
17 package org.pentaho.plugin.jfreechart;
18
19 import java.awt.Color JavaDoc;
20 import java.awt.Font JavaDoc;
21 import java.awt.Image JavaDoc;
22 import java.awt.Paint JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.dom4j.Node;
28 import org.jfree.chart.plot.PlotOrientation;
29 import org.jfree.chart.title.TextTitle;
30 import org.jfree.data.xy.XYSeriesCollection;
31 import org.jfree.data.xy.XYSeries;
32 import org.jfree.ui.RectangleEdge;
33 import org.pentaho.core.connection.IPentahoResultSet;
34 import org.pentaho.core.session.IPentahoSession;
35
36 public class XYSeriesCollectionChartDefinition extends XYSeriesCollection implements ChartDefinition {
37
38     private static final String JavaDoc STACKED_NODE_NAME = "is-stacked"; //$NON-NLS-1$
39

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

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

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

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

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

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

52     private static final String JavaDoc DOMAIN_INCLUDES_ZERO_NODE_NAME = "domain-includes-zero"; //$NON-NLS-1$
53

54     private static final String JavaDoc DOMAIN_STICKY_ZERO_NODE_NAME = "domain-sticky-zero"; //$NON-NLS-1$
55

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

58     private int chartType = JFreeChartEngine.UNDEFINED_CHART_TYPE;
59
60     // JFreeChart Customizations
61
private String JavaDoc title = ""; //$NON-NLS-1$
62

63     private RectangleEdge titlePosition = RectangleEdge.TOP;
64
65     private Font JavaDoc titleFont = TextTitle.DEFAULT_FONT;
66
67     private List JavaDoc subTitles = new ArrayList JavaDoc();
68
69     private Paint JavaDoc chartBackgroundPaint = Color.WHITE;
70
71     private Image JavaDoc chartBackgroundImage = null;
72
73     private boolean borderVisible = false;
74
75     private Paint JavaDoc borderPaint = Color.BLACK;
76
77     private int width = 200;
78
79     private int height = 200;
80
81     // Plot Customizations
82
private PlotOrientation orientation = PlotOrientation.VERTICAL;
83
84     private Paint JavaDoc plotBackgroundPaint = Color.WHITE;
85
86     private Image JavaDoc plotBackgroundImage = null;
87
88     private boolean legendIncluded = true;
89
90     private boolean threeD = false;
91
92     private boolean stacked = false;
93     
94     private boolean domainVerticalTickLabels = false;
95     
96     private boolean domainIncludesZero = true;
97     
98     private boolean domainStickyZero = true;
99
100     private Paint JavaDoc[] paintSequence = null;
101
102     private String JavaDoc domainTitle = null;
103
104     private Font JavaDoc domainTitleFont = TextTitle.DEFAULT_FONT;
105
106     private String JavaDoc rangeTitle = null;
107
108     private Font JavaDoc rangeTitleFont = TextTitle.DEFAULT_FONT;
109     
110     // Other stuff
111
private IPentahoSession session;
112
113     /**
114      *
115      */

116     private static final long serialVersionUID = 1717509132920946530L;
117
118     public XYSeriesCollectionChartDefinition(IPentahoSession session) {
119         super();
120         this.session = session;
121     }
122
123     public XYSeriesCollectionChartDefinition(int chartType, IPentahoResultSet data, boolean byRow, IPentahoSession session) {
124         this(session);
125         this.chartType = chartType;
126         if (byRow) {
127             setDataByRow(data);
128         } else {
129             setDataByColumn(data);
130         }
131     }
132
133     public XYSeriesCollectionChartDefinition(IPentahoResultSet data, boolean byRow, Node chartAttributes, IPentahoSession session) {
134         this(JFreeChartEngine.UNDEFINED_CHART_TYPE, data, byRow, session);
135         setChartAttributes(chartAttributes);
136     }
137
138     private void setChartAttributes(Node chartAttributes) {
139         if (chartAttributes == null) {
140             return;
141         }
142         // get the chart type from the chart node -- this overrides the current
143
// chart type
144
setChartType(chartAttributes.selectSingleNode(TYPE_NODE_NAME));
145
146         // set the chart background
147
setChartBackground(chartAttributes.selectSingleNode(CHART_BACKGROUND_NODE_NAME));
148
149         // set the plot background
150
setPlotBackground(chartAttributes.selectSingleNode(PLOT_BACKGROUND_NODE_NAME));
151
152         // set the orientation
153
setOrientation(chartAttributes.selectSingleNode(ORIENTATION_NODE_NAME));
154
155         // do we want a legend
156
setLegendIncluded(chartAttributes.selectSingleNode(INCLUDE_LEGEND_NODE_NAME));
157
158         // get the chart title
159
setTitle(chartAttributes.selectSingleNode(TITLE_NODE_NAME));
160
161         // get the chart subtitles
162
addSubTitles(chartAttributes.selectNodes(SUBTITLE_NODE_NAME));
163
164         // get the paint sequence
165
setPaintSequence(chartAttributes.selectSingleNode(PALETTE_NODE_NAME));
166
167         // get the stacked value
168
setStacked(chartAttributes.selectSingleNode(STACKED_NODE_NAME));
169
170         // get the 3D value
171
setThreeD(chartAttributes.selectSingleNode(THREED_NODE_NAME));
172
173         // set the width
174
setWidth(chartAttributes.selectSingleNode(WIDTH_NODE_NAME));
175
176         // set the height
177
setHeight(chartAttributes.selectSingleNode(HEIGHT_NODE_NAME));
178
179         // set vertical tick labels flag
180
setDomainVerticalTickLabels(chartAttributes.selectSingleNode(DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME));
181
182         // set the border on or off
183
setBorderVisible(chartAttributes.selectSingleNode(CHART_BORDER_VISIBLE_NODE_NAME));
184
185         // set the border Paint
186
setBorderPaint(JFreeChartEngine.getPaint(chartAttributes.selectSingleNode(CHART_BORDER_PAINT_NODE_NAME)));
187
188         // set the title location
189
setTitlePosition(chartAttributes.selectSingleNode(TITLE_POSITION_NODE_NAME));
190
191         // set the title font
192
setTitleFont(chartAttributes.selectSingleNode(TITLE_FONT_NODE_NAME));
193
194         // set the domain title
195
setDomainTitle(chartAttributes.selectSingleNode(DOMAIN_TITLE_NODE_NAME));
196
197         // set the domain font
198
setDomainTitleFont(chartAttributes.selectSingleNode(DOMAIN_TITLE_FONT_NODE_NAME));
199
200         // set the range title
201
setRangeTitle(chartAttributes.selectSingleNode(RANGE_TITLE_NODE_NAME));
202
203         // the the range font
204
setRangeTitleFont(chartAttributes.selectSingleNode(RANGE_TITLE_FONT_NODE_NAME));
205         
206         // set we want domain to include zero
207
setDomainIncludesZero(chartAttributes.selectSingleNode(DOMAIN_INCLUDES_ZERO_NODE_NAME));
208         
209         // set we want domain to force zero
210
setDomainStickyZero(chartAttributes.selectSingleNode(DOMAIN_STICKY_ZERO_NODE_NAME));
211     }
212
213     private void setDataByColumn(IPentahoResultSet data) {
214         // TODO Make this routine MDX friendly
215
if (data == null) {
216             return; // No data so we've got nothing to set
217
// TODO come up with some sort of error strategy here.
218
}
219         boolean firstPass = true;
220         String JavaDoc lastSeries = ""; //$NON-NLS-1$
221
String JavaDoc seriesName = ""; //$NON-NLS-1$
222
Object JavaDoc[] rowData = data.next();
223         XYSeries wrkSeries = new XYSeries( seriesName );
224         while (rowData != null) {
225             seriesName = rowData[0].toString();
226             if ( firstPass || !seriesName.equalsIgnoreCase( lastSeries ) ) {
227                 if ( !firstPass ) {
228                     addSeries( wrkSeries );
229                 }
230                 wrkSeries = new XYSeries( seriesName );
231                 lastSeries = seriesName;
232                 firstPass = false;
233             }
234             if (rowData[1] instanceof Number JavaDoc && rowData[2] instanceof Number JavaDoc) {
235                 wrkSeries.add( ((Number JavaDoc) rowData[1]).doubleValue(), ((Number JavaDoc) rowData[2]).doubleValue() );
236             }
237             rowData = data.next();
238         }
239         if ( !firstPass ) {
240             addSeries( wrkSeries );
241         }
242     }
243
244     private void setDataByRow(IPentahoResultSet data) {
245         // TODO Make this routine MDX friendly
246
if (data == null) {
247             return; // No data so we've got nothing to set
248
// TODO come up with some sort of error strategy here.
249
}
250         Object JavaDoc[] rowData = data.next();
251         while (rowData != null) {
252             String JavaDoc seriesName = (String JavaDoc) rowData[0];
253             XYSeries wrkSeries = new XYSeries( seriesName );
254             for (int column = 1; column < rowData.length - 1; column = column + 2) {
255                  wrkSeries.add( ((Number JavaDoc) rowData[column]).doubleValue(), ((Number JavaDoc) rowData[column+1]).doubleValue() );
256             }
257             addSeries( wrkSeries );
258             rowData = data.next();
259         }
260     }
261
262     /**
263      * @param backgroundPaint
264      * The backgroundPaint to set.
265      */

266     public void setChartBackgroundPaint(Paint JavaDoc chartBackgroundPaint) {
267         if (chartBackgroundPaint != null) {
268             this.chartBackgroundPaint = chartBackgroundPaint;
269         }
270     }
271
272     /**
273      * Return the java.awt.Font to be used to display the dial title
274      *
275      * @return Font The Font for the title of this Pie
276      */

277     public Font JavaDoc getTitleFont() {
278         return titleFont;
279     }
280
281     public void setTitleFont(Font JavaDoc titleFont) {
282         this.titleFont = titleFont;
283     }
284
285     public void setTitleFont(Node titleFontNode) {
286         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
287         if (font != null) {
288             setTitleFont(font);
289         }
290     }
291
292     /**
293      * @return Returns the backgroundPaint.
294      */

295     public Paint JavaDoc getChartBackgroundPaint() {
296         return chartBackgroundPaint;
297     }
298
299     /**
300      * @return Returns the chartType.
301      */

302     public int getChartType() {
303         return chartType;
304     }
305
306     public static int getChartType(String JavaDoc typeStr) {
307         if (typeStr != null) {
308             if (LINE_CHART_STR.equalsIgnoreCase(typeStr)) {
309                 return JFreeChartEngine.LINE_CHART_TYPE;
310             } else if (AREA_CHART_STR.equalsIgnoreCase(typeStr)) {
311                 return JFreeChartEngine.AREA_CHART_TYPE;
312             } else if (STEP_CHART_STR.equalsIgnoreCase(typeStr)) {
313                 return JFreeChartEngine.STEP_CHART_TYPE;
314             } else if (STEP_AREA_CHART_STR.equalsIgnoreCase(typeStr)) {
315                 return JFreeChartEngine.STEP_AREA_CHART_TYPE;
316             } else if (DIFFERENCE_CHART_STR.equalsIgnoreCase(typeStr)) {
317                 return JFreeChartEngine.DIFFERENCE_CHART_TYPE;
318             } else if (DOT_CHART_STR.equalsIgnoreCase(typeStr)) {
319                 return JFreeChartEngine.DOT_CHART_TYPE;
320             }
321         }
322         return JFreeChartEngine.UNDEFINED_CHART_TYPE;
323     }
324
325     public void setChartType(Node chartTypeNode) {
326         if (chartTypeNode != null) {
327             String JavaDoc typeStr = chartTypeNode.getText();
328             setChartType(getChartType(typeStr));
329         }
330     }
331
332     /**
333      * @param chartType
334      * The chartType to set.
335      */

336     public void setChartType(int chartType) {
337         this.chartType = chartType;
338     }
339
340     /**
341      * @return Returns the threeD.
342      */

343     public boolean isThreeD() {
344         return threeD;
345     }
346
347     public void setThreeD(Node threeDNode) {
348         if (threeDNode != null) {
349             String JavaDoc boolStr = threeDNode.getText();
350             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
351             setThreeD(booleanValue.booleanValue());
352         }
353     }
354
355     /**
356      * @param threeD
357      * The threeD to set.
358      */

359     public void setThreeD(boolean threeD) {
360         this.threeD = threeD;
361     }
362
363     /**
364      * @return Returns the stacked.
365      */

366     public boolean isStacked() {
367         return stacked;
368     }
369
370     public void setStacked(Node stackedNode) {
371         if (stackedNode != null) {
372             String JavaDoc boolStr = stackedNode.getText();
373             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
374             setStacked(booleanValue.booleanValue());
375         }
376     }
377
378     /**
379      * @param stacked
380      * The stacked to set.
381      */

382     public void setStacked(boolean stacked) {
383         this.stacked = stacked;
384     }
385
386     /**
387      * @return Returns the verticalTickLabels.
388      */

389     public boolean isDomainVerticalTickLabels() {
390         return domainVerticalTickLabels;
391     }
392
393     public void setDomainVerticalTickLabels(Node domainVerticalTickLabelsNode) {
394         if (domainVerticalTickLabelsNode != null) {
395             String JavaDoc boolStr = domainVerticalTickLabelsNode.getText();
396             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
397             setDomainVerticalTickLabels(booleanValue.booleanValue());
398         }
399     }
400
401     /**
402      * @param domainVerticalTickLabels
403      * The domainVerticalLabels to set.
404      */

405     public void setDomainVerticalTickLabels(boolean domainVerticalTickLabels) {
406         this.domainVerticalTickLabels = domainVerticalTickLabels;
407     }
408
409     /**
410      * @return Returns the domainIncludeZero.
411      */

412     public boolean isDomainIncludesZero() {
413         return domainIncludesZero;
414     }
415
416     public void setDomainIncludesZero(Node domainIncludesZeroNode) {
417         if (domainIncludesZeroNode != null) {
418             String JavaDoc boolStr = domainIncludesZeroNode.getText();
419             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
420             setDomainIncludesZero(booleanValue.booleanValue());
421         }
422     }
423
424     /**
425      * @param domainIncludesZero
426      * The domainIncludesZero to set.
427      */

428     public void setDomainIncludesZero(boolean domainIncludesZero) {
429         this.domainIncludesZero = domainIncludesZero;
430     }
431
432     /**
433      * @return Returns the domainStickyZero.
434      */

435     public boolean isDomainStickyZero() {
436         return domainStickyZero;
437     }
438
439     public void setDomainStickyZero(Node domainStickyZeroNode) {
440         if (domainStickyZeroNode != null) {
441             String JavaDoc boolStr = domainStickyZeroNode.getText();
442             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
443             setDomainStickyZero(booleanValue.booleanValue());
444         }
445     }
446
447     /**
448      * @param domainStickyZero
449      * The domainStickyZero to set.
450      */

451     public void setDomainStickyZero(boolean domainStickyZero) {
452         this.domainStickyZero = domainStickyZero;
453     }
454
455     /**
456      * @return Returns the height.
457      */

458     public int getHeight() {
459         return height;
460     }
461
462     public void setHeight(Node heightNode) {
463         if (heightNode != null) {
464             setHeight(Integer.parseInt(heightNode.getText()));
465         }
466     }
467
468     /**
469      * @param height
470      * The height to set.
471      */

472     public void setHeight(int height) {
473         this.height = height;
474     }
475
476     /**
477      * @return Returns the width.
478      */

479     public int getWidth() {
480         return width;
481     }
482
483     public void setWidth(Node widthNode) {
484         if (widthNode != null) {
485             setWidth(Integer.parseInt(widthNode.getText()));
486         }
487     }
488
489     /**
490      * @param width
491      * The width to set.
492      */

493     public void setWidth(int width) {
494         this.width = width;
495     }
496
497     /**
498      * @return Returns the title.
499      */

500     public String JavaDoc getTitle() {
501         return title;
502     }
503
504     public void setTitle(Node chartTitleNode) {
505         if (chartTitleNode != null) {
506             setTitle(chartTitleNode.getText());
507         }
508     }
509
510     /**
511      * @param title
512      * The title to set.
513      */

514     public void setTitle(String JavaDoc title) {
515         this.title = title;
516     }
517
518     /**
519      * @return Returns the paintSequence.
520      */

521     public Paint JavaDoc[] getPaintSequence() {
522         return paintSequence;
523     }
524
525     public void setPaintSequence(Node paletteNode) {
526         if (paletteNode != null) {
527             List JavaDoc colorNodes = paletteNode.selectNodes(COLOR_NODE_NAME);
528             Paint JavaDoc[] paints = new Paint JavaDoc[colorNodes.size()];
529             for (int i = 0; i < colorNodes.size(); i++) {
530                 paints[i] = JFreeChartEngine.getPaint((Node) colorNodes.get(i));
531             }
532             setPaintSequence(paints);
533         }
534     }
535
536     /**
537      * @param paintSequence
538      * The paintSequence to set.
539      */

540     public void setPaintSequence(Paint JavaDoc[] paintSequence) {
541         this.paintSequence = paintSequence;
542     }
543
544     /**
545      * @return Returns the subTitles.
546      */

547     public List JavaDoc getSubtitles() {
548         return subTitles;
549     }
550
551     public void addSubTitles(List JavaDoc subTitleNodes) {
552         if (subTitleNodes != null) {
553             Iterator JavaDoc iter = subTitleNodes.iterator();
554             while (iter.hasNext()) {
555                 addSubTitle(((Node) iter.next()).getText());
556             }
557         }
558     }
559
560     public void addSubTitle(String JavaDoc subTitle) {
561         subTitles.add(subTitle);
562     }
563
564     /**
565      * @return Returns the chartBackgroundImage.
566      */

567     public Image JavaDoc getChartBackgroundImage() {
568         return chartBackgroundImage;
569     }
570
571     public void setChartBackgroundImage(Node chartBackgroundImageNode) {
572         setChartBackgroundImage(JFreeChartEngine.getImage(chartBackgroundImageNode, getSession()));
573     }
574
575     /**
576      * @param chartBackgroundImage
577      * The chartBackgroundImage to set.
578      */

579     public void setChartBackgroundImage(Image JavaDoc chartBackgroundImage) {
580         this.chartBackgroundImage = chartBackgroundImage;
581     }
582
583     /**
584      * @return Returns the legendIncluded.
585      */

586     public boolean isLegendIncluded() {
587         return legendIncluded;
588     }
589
590     public void setLegendIncluded(Node legendNode) {
591         if (legendNode != null) {
592             String JavaDoc boolStr = legendNode.getText();
593             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
594             setLegendIncluded(booleanValue.booleanValue());
595         }
596     }
597
598     /**
599      * @param legendIncluded
600      * The legendIncluded to set.
601      */

602     public void setLegendIncluded(boolean legendIncluded) {
603         this.legendIncluded = legendIncluded;
604     }
605
606     public void setPlotBackgroundPaint(Paint JavaDoc plotBackgroundPaint) {
607         if (plotBackgroundPaint != null) {
608             this.plotBackgroundPaint = plotBackgroundPaint;
609         }
610     }
611
612     public Paint JavaDoc getPlotBackgroundPaint() {
613         return plotBackgroundPaint;
614     }
615
616     /**
617      * @return Returns the plotBackgroundImage.
618      */

619     public Image JavaDoc getPlotBackgroundImage() {
620         return plotBackgroundImage;
621     }
622
623     public void setPlotBackgroundImage(Node plotBackgroundImageNode) {
624         setPlotBackgroundImage(JFreeChartEngine.getImage(plotBackgroundImageNode, getSession()));
625     }
626
627     /**
628      * @param plotBackgroundImage
629      * The plotBackgroundImage to set.
630      */

631     public void setPlotBackgroundImage(Image JavaDoc plotBackgroundImage) {
632         this.plotBackgroundImage = plotBackgroundImage;
633     }
634
635     /**
636      * @return Returns the orientation.
637      */

638     public PlotOrientation getOrientation() {
639         return orientation;
640     }
641
642     public void setOrientation(Node orientationNode) {
643         if (orientationNode != null) {
644             String JavaDoc orientationStr = orientationNode.getText();
645             if (VERTICAL_ORIENTATION.equalsIgnoreCase(orientationStr)) {
646                 setOrientation(PlotOrientation.VERTICAL);
647             } else if (HORIZONTAL_ORIENTATION.equalsIgnoreCase(orientationStr)) {
648                 setOrientation(PlotOrientation.HORIZONTAL);
649             }
650         }
651     }
652
653     /**
654      * @param orientation
655      * The orientation to set.
656      */

657     public void setOrientation(PlotOrientation orientation) {
658         this.orientation = orientation;
659     }
660
661     /**
662      * @return Returns the borderVisible.
663      */

664     public boolean isBorderVisible() {
665         return borderVisible;
666     }
667
668     public void setBorderVisible(Node borderVisibleNode) {
669         if (borderVisibleNode != null) {
670             String JavaDoc boolStr = borderVisibleNode.getText();
671             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
672             setBorderVisible(booleanValue.booleanValue());
673         }
674     }
675
676     /**
677      * @param borderVisible
678      * The borderVisible to set.
679      */

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

687     public Paint JavaDoc getBorderPaint() {
688         return borderPaint;
689     }
690
691     /**
692      * @param borderPaint
693      * The borderPaint to set.
694      */

695     public void setBorderPaint(Paint JavaDoc borderPaint) {
696         this.borderPaint = borderPaint;
697     }
698
699     public void setTitlePosition(Node titlePositionNode) {
700         if (titlePositionNode != null) {
701             String JavaDoc titlePositionStr = titlePositionNode.getText();
702             if ("top".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
703
setTitlePosition(RectangleEdge.TOP);
704             } else if ("left".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
705
setTitlePosition(RectangleEdge.LEFT);
706             } else if ("bottom".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
707
setTitlePosition(RectangleEdge.BOTTOM);
708             } else if ("right".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
709
setTitlePosition(RectangleEdge.RIGHT);
710             }
711         }
712     }
713
714     /**
715      * @return Returns the titlePosition.
716      */

717     public RectangleEdge getTitlePosition() {
718         return titlePosition;
719     }
720
721     /**
722      * @param titlePosition
723      * The titlePosition to set.
724      */

725     public void setTitlePosition(RectangleEdge titlePosition) {
726         this.titlePosition = titlePosition;
727     }
728
729     public void setChartBackground(Node chartBackgroundNode) {
730         if (chartBackgroundNode != null) {
731             Node backgroundTypeNode = chartBackgroundNode.selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
732             if (backgroundTypeNode != null) {
733                 String JavaDoc backgroundTypeStr = backgroundTypeNode.getText();
734                 if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
735                     setChartBackgroundPaint(JFreeChartEngine.getPaint(chartBackgroundNode));
736                     setChartBackgroundImage((Image JavaDoc) null);
737                 } else if (IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
738                     setChartBackgroundImage(chartBackgroundNode);
739                     setChartBackgroundPaint(null);
740                 } else if (TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
741                     setChartBackgroundPaint(JFreeChartEngine.getTexturePaint(chartBackgroundNode, getWidth(), getHeight(), getSession()));
742                     setChartBackgroundImage((Image JavaDoc) null);
743                 } else if (GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
744                     setChartBackgroundPaint(JFreeChartEngine.getGradientPaint(chartBackgroundNode, getWidth(), getHeight()));
745                     setChartBackgroundImage((Image JavaDoc) null);
746                 }
747             }
748         }
749     }
750
751     public void setPlotBackground(Node plotBackgroundNode) {
752         if (plotBackgroundNode != null) {
753             Node backgroundTypeNode = plotBackgroundNode.selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
754             if (backgroundTypeNode != null) {
755                 String JavaDoc backgroundTypeStr = backgroundTypeNode.getText();
756                 if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
757                     setPlotBackgroundPaint(JFreeChartEngine.getPaint(plotBackgroundNode));
758                     setPlotBackgroundImage((Image JavaDoc) null);
759                 } else if (IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
760                     setPlotBackgroundImage(plotBackgroundNode);
761                     setPlotBackgroundPaint(null);
762                 } else if (TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
763                     setPlotBackgroundPaint(JFreeChartEngine.getTexturePaint(plotBackgroundNode, getWidth(), getHeight(), getSession()));
764                     setPlotBackgroundImage((Image JavaDoc) null);
765                 } else if (GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
766                     setPlotBackgroundPaint(JFreeChartEngine.getGradientPaint(plotBackgroundNode, getWidth(), getHeight()));
767                     setPlotBackgroundImage((Image JavaDoc) null);
768                 }
769             }
770         }
771     }
772
773     public void setDomainTitle(Node titleNode) {
774         if (titleNode != null) {
775             setDomainTitle(titleNode.getText());
776         }
777     }
778
779     /**
780      * @return Returns the domainTitle.
781      */

782     public String JavaDoc getDomainTitle() {
783         return domainTitle;
784     }
785
786     /**
787      * @param domainTitle
788      * The domainTitle to set.
789      */

790     public void setDomainTitle(String JavaDoc domainTitle) {
791         this.domainTitle = domainTitle;
792     }
793
794     public void setRangeTitle(Node titleNode) {
795         if (titleNode != null) {
796             setRangeTitle(titleNode.getText());
797         }
798     }
799
800     /**
801      * @return Returns the rangeTitle.
802      */

803     public String JavaDoc getRangeTitle() {
804         return rangeTitle;
805     }
806
807     /**
808      * @param rangeTitle
809      * The rangeTitle to set.
810      */

811     public void setRangeTitle(String JavaDoc rangeTitle) {
812         this.rangeTitle = rangeTitle;
813     }
814
815     public void setDomainTitleFont(Node titleFontNode) {
816         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
817         if (font != null) {
818             setDomainTitleFont(font);
819         }
820     }
821
822     /**
823      * @return Returns the domainTitleFont.
824      */

825     public Font JavaDoc getDomainTitleFont() {
826         return domainTitleFont;
827     }
828
829     /**
830      * @param domainTitleFont
831      * The domainTitleFont to set.
832      */

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

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

855     public void setRangeTitleFont(Font JavaDoc rangeTitleFont) {
856         this.rangeTitleFont = rangeTitleFont;
857     }
858
859     public boolean isDisplayLabels() {
860         // TODO Auto-generated method stub
861
return false;
862     }
863
864     public IPentahoSession getSession() {
865         return session;
866     }
867
868     public void setSession(IPentahoSession session) {
869         this.session = session;
870     }
871 }
872
Popular Tags