KickJava   Java API By Example, From Geeks To Geeks.

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


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 Nov 17, 2005
14  * @author wseyler
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.axis.CategoryLabelPositions;
29 import org.jfree.chart.plot.PlotOrientation;
30 import org.jfree.chart.title.TextTitle;
31 import org.jfree.data.UnknownKeyException;
32 import org.jfree.data.category.DefaultCategoryDataset;
33 import org.jfree.ui.RectangleEdge;
34 import org.pentaho.core.connection.IPentahoDataTypes;
35 import org.pentaho.core.connection.IPentahoResultSet;
36 import org.pentaho.core.connection.PentahoDataTransmuter;
37 import org.pentaho.core.session.IPentahoSession;
38
39 public class CategoryDatasetChartDefinition extends DefaultCategoryDataset implements ChartDefinition {
40
41     private static final String JavaDoc STACKED_NODE_NAME = "is-stacked"; //$NON-NLS-1$
42

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

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

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

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

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

53     private static final String JavaDoc DOMAIN_LABEL_ROTATION_ANGLE_NODE_NAME = "domain-label-rotation"; //$NON-NLS-1$
54

55     private static final String JavaDoc DOMAIN_LABEL_ROTATION_DIRECTION_NODE_NAME = "domain-label-rotation-dir"; //$NON-NLS-1$
56

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

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

110     private static final long serialVersionUID = 1717509132920946530L;
111
112     public CategoryDatasetChartDefinition(IPentahoSession session) {
113         super();
114         this.session = session;
115     }
116
117     public CategoryDatasetChartDefinition(int chartType, IPentahoResultSet data, boolean byRow, IPentahoSession session) {
118         this(session);
119         this.chartType = chartType;
120         if (byRow) {
121             setDataByRow(data);
122         } else {
123             setDataByColumn(data);
124         }
125     }
126
127     public CategoryDatasetChartDefinition(IPentahoResultSet data, boolean byRow, Node chartAttributes, IPentahoSession session) {
128         this(JFreeChartEngine.UNDEFINED_CHART_TYPE, data, byRow, session);
129         setChartAttributes(chartAttributes);
130     }
131
132     private void setChartAttributes(Node chartAttributes) {
133         if (chartAttributes == null) {
134             return;
135         }
136         // get the chart type from the chart node -- this overrides the current
137
// chart type
138
setChartType(chartAttributes.selectSingleNode(TYPE_NODE_NAME));
139
140         // set the chart background
141
setChartBackground(chartAttributes.selectSingleNode(CHART_BACKGROUND_NODE_NAME));
142
143         // set the plot background
144
setPlotBackground(chartAttributes.selectSingleNode(PLOT_BACKGROUND_NODE_NAME));
145
146         // set the orientation
147
setOrientation(chartAttributes.selectSingleNode(ORIENTATION_NODE_NAME));
148
149         // do we want a legend
150
setLegendIncluded(chartAttributes.selectSingleNode(INCLUDE_LEGEND_NODE_NAME));
151
152         // get the chart title
153
setTitle(chartAttributes.selectSingleNode(TITLE_NODE_NAME));
154
155         // get the chart subtitles
156
addSubTitles(chartAttributes.selectNodes(SUBTITLE_NODE_NAME));
157
158         // get the paint sequence
159
setPaintSequence(chartAttributes.selectSingleNode(PALETTE_NODE_NAME));
160
161         // get the stacked value
162
setStacked(chartAttributes.selectSingleNode(STACKED_NODE_NAME));
163
164         // get the 3D value
165
setThreeD(chartAttributes.selectSingleNode(THREED_NODE_NAME));
166
167         // set the width
168
setWidth(chartAttributes.selectSingleNode(WIDTH_NODE_NAME));
169
170         // set the height
171
setHeight(chartAttributes.selectSingleNode(HEIGHT_NODE_NAME));
172
173         // set category rotation direction
174
setCategoryLabelRotation(chartAttributes.selectSingleNode(DOMAIN_LABEL_ROTATION_DIRECTION_NODE_NAME), chartAttributes.selectSingleNode(DOMAIN_LABEL_ROTATION_ANGLE_NODE_NAME));
175
176         // set the border on or off
177
setBorderVisible(chartAttributes.selectSingleNode(CHART_BORDER_VISIBLE_NODE_NAME));
178
179         // set the border Paint
180
setBorderPaint(JFreeChartEngine.getPaint(chartAttributes.selectSingleNode(CHART_BORDER_PAINT_NODE_NAME)));
181
182         // set the title location
183
setTitlePosition(chartAttributes.selectSingleNode(TITLE_POSITION_NODE_NAME));
184
185         // set the title font
186
setTitleFont(chartAttributes.selectSingleNode(TITLE_FONT_NODE_NAME));
187
188         // set the domain title
189
setDomainTitle(chartAttributes.selectSingleNode(DOMAIN_TITLE_NODE_NAME));
190
191         // set the domain font
192
setDomainTitleFont(chartAttributes.selectSingleNode(DOMAIN_TITLE_FONT_NODE_NAME));
193
194         // set the range title
195
setRangeTitle(chartAttributes.selectSingleNode(RANGE_TITLE_NODE_NAME));
196
197         // the the range font
198
setRangeTitleFont(chartAttributes.selectSingleNode(RANGE_TITLE_FONT_NODE_NAME));
199     }
200
201     private void setDataByColumn(IPentahoResultSet data) {
202         setDataByRow(PentahoDataTransmuter.pivot(data));
203     }
204
205     private void setDataByRow(IPentahoResultSet data) {
206         if (data == null) {
207             return; // No data so we've got nothing to set
208
// TODO come up with some sort of error strategy here.
209
}
210         boolean hasRowHeaders = data.getMetaData().getRowHeaders() != null;
211         boolean hasColumnHeaders = data.getMetaData().getColumnHeaders() != null;
212         if (!hasRowHeaders || !hasColumnHeaders) {
213             data = PentahoDataTransmuter.transmute(data, false);
214         }
215         String JavaDoc[] rowHeaders = null;
216         String JavaDoc[] columnHeaders = null;
217         try {
218             rowHeaders = PentahoDataTransmuter.getCollapsedHeaders(IPentahoDataTypes.AXIS_ROW, data, '|');
219             columnHeaders = PentahoDataTransmuter.getCollapsedHeaders(IPentahoDataTypes.AXIS_COLUMN, data, '|');
220         } catch (Exception JavaDoc e) {
221             // should really NEVER get here
222
e.printStackTrace();
223         }
224         int row = 0;
225         Object JavaDoc[] rowData = data.next();
226         while (rowData != null) {
227             for (int column = 0; column < rowData.length; column++) {
228                 if (rowData[column] instanceof Number JavaDoc) {
229                     Number JavaDoc currentNumber = null;
230                     try { // If value has been set then we get it
231
currentNumber = getValue(rowHeaders[row], columnHeaders[column]);
232                     } catch (UnknownKeyException uke) { // else we just set it
233
// to zero
234
currentNumber = new Double JavaDoc(0.0);
235                     }
236                     if (currentNumber == null) {
237                         currentNumber = new Double JavaDoc(0.0);
238                     }
239                     double currentValue = currentNumber.doubleValue();
240                     double newValue = ((Number JavaDoc) rowData[column]).doubleValue();
241                     setValue(new Double JavaDoc(currentValue + newValue), rowHeaders[row], columnHeaders[column]);
242                 }
243             }
244             row++;
245             rowData = data.next();
246         }
247     }
248
249     /**
250      * @param backgroundPaint
251      * The backgroundPaint to set.
252      */

253     public void setChartBackgroundPaint(Paint JavaDoc chartBackgroundPaint) {
254         if (chartBackgroundPaint != null) {
255             this.chartBackgroundPaint = chartBackgroundPaint;
256         }
257     }
258
259     /**
260      * Return the java.awt.Font to be used to display the dial title
261      *
262      * @return Font The Font for the title of this Pie
263      */

264     public Font JavaDoc getTitleFont() {
265         return titleFont;
266     }
267
268     public void setTitleFont(Font JavaDoc titleFont) {
269         this.titleFont = titleFont;
270     }
271
272     public void setTitleFont(Node titleFontNode) {
273         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
274         if (font != null) {
275             setTitleFont(font);
276         }
277     }
278
279     /**
280      * @return Returns the backgroundPaint.
281      */

282     public Paint JavaDoc getChartBackgroundPaint() {
283         return chartBackgroundPaint;
284     }
285
286     /**
287      * @return Returns the chartType.
288      */

289     public int getChartType() {
290         return chartType;
291     }
292
293     public static int getChartType(String JavaDoc typeStr) {
294         if (typeStr != null) {
295             if (PIE_CHART_STR.equalsIgnoreCase(typeStr)) {
296                 return JFreeChartEngine.PIE_CHART_TYPE;
297             } else if (PIE_GRID_CHART_STR.equalsIgnoreCase(typeStr)) {
298                 return JFreeChartEngine.PIE_GRID_CHART_TYPE;
299             } else if (BAR_CHART_STR.equalsIgnoreCase(typeStr)) {
300                 return JFreeChartEngine.BAR_CHART_TYPE;
301             } else if (LINE_CHART_STR.equalsIgnoreCase(typeStr)) {
302                 return JFreeChartEngine.LINE_CHART_TYPE;
303             } else if (AREA_CHART_STR.equalsIgnoreCase(typeStr)) {
304                 return JFreeChartEngine.AREA_CHART_TYPE;
305             }
306         }
307         return JFreeChartEngine.UNDEFINED_CHART_TYPE;
308     }
309
310     public void setChartType(Node chartTypeNode) {
311         if (chartTypeNode != null) {
312             String JavaDoc typeStr = chartTypeNode.getText();
313             setChartType(getChartType(typeStr));
314         }
315     }
316
317     /**
318      * @param chartType
319      * The chartType to set.
320      */

321     public void setChartType(int chartType) {
322         this.chartType = chartType;
323     }
324
325     /**
326      * @return Returns the threeD.
327      */

328     public boolean isThreeD() {
329         return threeD;
330     }
331
332     public void setThreeD(Node threeDNode) {
333         if (threeDNode != null) {
334             String JavaDoc boolStr = threeDNode.getText();
335             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
336             setThreeD(booleanValue.booleanValue());
337         }
338     }
339
340     /**
341      * @param threeD
342      * The threeD to set.
343      */

344     public void setThreeD(boolean threeD) {
345         this.threeD = threeD;
346     }
347
348     /**
349      * @return Returns the stacked.
350      */

351     public boolean isStacked() {
352         return stacked;
353     }
354
355     public void setStacked(Node stackedNode) {
356         if (stackedNode != null) {
357             String JavaDoc boolStr = stackedNode.getText();
358             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
359             setStacked(booleanValue.booleanValue());
360         }
361     }
362
363     /**
364      * @param stacked
365      * The stacked to set.
366      */

367     public void setStacked(boolean stacked) {
368         this.stacked = stacked;
369     }
370
371     /**
372      * @return Returns the height.
373      */

374     public int getHeight() {
375         return height;
376     }
377
378     public void setHeight(Node heightNode) {
379         if (heightNode != null) {
380             setHeight(Integer.parseInt(heightNode.getText()));
381         }
382     }
383
384     /**
385      * @param height
386      * The height to set.
387      */

388     public void setHeight(int height) {
389         this.height = height;
390     }
391
392     /**
393      * @return Returns the width.
394      */

395     public int getWidth() {
396         return width;
397     }
398
399     public void setWidth(Node widthNode) {
400         if (widthNode != null) {
401             setWidth(Integer.parseInt(widthNode.getText()));
402         }
403     }
404
405     /**
406      * @param width
407      * The width to set.
408      */

409     public void setWidth(int width) {
410         this.width = width;
411     }
412
413     /**
414      * @return Returns the title.
415      */

416     public String JavaDoc getTitle() {
417         return title;
418     }
419
420     public void setTitle(Node chartTitleNode) {
421         if (chartTitleNode != null) {
422             setTitle(chartTitleNode.getText());
423         }
424     }
425
426     /**
427      * @param title
428      * The title to set.
429      */

430     public void setTitle(String JavaDoc title) {
431         this.title = title;
432     }
433
434     /**
435      * @return Returns the paintSequence.
436      */

437     public Paint JavaDoc[] getPaintSequence() {
438         return paintSequence;
439     }
440
441     public void setPaintSequence(Node paletteNode) {
442         if (paletteNode != null) {
443             List JavaDoc colorNodes = paletteNode.selectNodes(COLOR_NODE_NAME);
444             Paint JavaDoc[] paints = new Paint JavaDoc[colorNodes.size()];
445             for (int i = 0; i < colorNodes.size(); i++) {
446                 paints[i] = JFreeChartEngine.getPaint((Node) colorNodes.get(i));
447             }
448             setPaintSequence(paints);
449         }
450     }
451
452     /**
453      * @param paintSequence
454      * The paintSequence to set.
455      */

456     public void setPaintSequence(Paint JavaDoc[] paintSequence) {
457         this.paintSequence = paintSequence;
458     }
459
460     /**
461      * @return Returns the subTitles.
462      */

463     public List JavaDoc getSubtitles() {
464         return subTitles;
465     }
466
467     public void addSubTitles(List JavaDoc subTitleNodes) {
468         if (subTitleNodes != null) {
469             Iterator JavaDoc iter = subTitleNodes.iterator();
470             while (iter.hasNext()) {
471                 addSubTitle(((Node) iter.next()).getText());
472             }
473         }
474     }
475
476     public void addSubTitle(String JavaDoc subTitle) {
477         subTitles.add(subTitle);
478     }
479
480     /**
481      * @return Returns the chartBackgroundImage.
482      */

483     public Image JavaDoc getChartBackgroundImage() {
484         return chartBackgroundImage;
485     }
486
487     public void setChartBackgroundImage(Node chartBackgroundImageNode) {
488         setChartBackgroundImage(JFreeChartEngine.getImage(chartBackgroundImageNode, getSession()));
489     }
490
491     /**
492      * @param chartBackgroundImage
493      * The chartBackgroundImage to set.
494      */

495     public void setChartBackgroundImage(Image JavaDoc chartBackgroundImage) {
496         this.chartBackgroundImage = chartBackgroundImage;
497     }
498
499     /**
500      * @return Returns the legendIncluded.
501      */

502     public boolean isLegendIncluded() {
503         return legendIncluded;
504     }
505
506     public void setLegendIncluded(Node legendNode) {
507         if (legendNode != null) {
508             String JavaDoc boolStr = legendNode.getText();
509             Boolean JavaDoc booleanValue = new Boolean JavaDoc(boolStr);
510             setLegendIncluded(booleanValue.booleanValue());
511         }
512     }
513
514     /**
515      * @param legendIncluded
516      * The legendIncluded to set.
517      */

518     public void setLegendIncluded(boolean legendIncluded) {
519         this.legendIncluded = legendIncluded;
520     }
521
522     public void setPlotBackgroundPaint(Paint JavaDoc plotBackgroundPaint) {
523         if (plotBackgroundPaint != null) {
524             this.plotBackgroundPaint = plotBackgroundPaint;
525         }
526     }
527
528     public Paint JavaDoc getPlotBackgroundPaint() {
529         return plotBackgroundPaint;
530     }
531
532     /**
533      * @return Returns the plotBackgroundImage.
534      */

535     public Image JavaDoc getPlotBackgroundImage() {
536         return plotBackgroundImage;
537     }
538
539     public void setPlotBackgroundImage(Node plotBackgroundImageNode) {
540         setPlotBackgroundImage(JFreeChartEngine.getImage(plotBackgroundImageNode, getSession()));
541     }
542
543     /**
544      * @param plotBackgroundImage
545      * The plotBackgroundImage to set.
546      */

547     public void setPlotBackgroundImage(Image JavaDoc plotBackgroundImage) {
548         this.plotBackgroundImage = plotBackgroundImage;
549     }
550
551     /**
552      * @return Returns the orientation.
553      */

554     public PlotOrientation getOrientation() {
555         return orientation;
556     }
557
558     public void setOrientation(Node orientationNode) {
559         if (orientationNode != null) {
560             String JavaDoc orientationStr = orientationNode.getText();
561             if (VERTICAL_ORIENTATION.equalsIgnoreCase(orientationStr)) {
562                 setOrientation(PlotOrientation.VERTICAL);
563             } else if (HORIZONTAL_ORIENTATION.equalsIgnoreCase(orientationStr)) {
564                 setOrientation(PlotOrientation.HORIZONTAL);
565             }
566         }
567     }
568
569     /**
570      * @param orientation
571      * The orientation to set.
572      */

573     public void setOrientation(PlotOrientation orientation) {
574         this.orientation = orientation;
575     }
576
577     public CategoryLabelPositions getCategoryLabelPositions() {
578         return domainLabelPositions;
579     }
580
581     public void setCategoryLabelRotation(Node rotationDirection, Node rotationAngle) {
582         // down is the default
583
String JavaDoc direction = "down"; //$NON-NLS-1$
584
if (rotationDirection != null) {
585             direction = rotationDirection.getText();
586         }
587
588         if (rotationAngle != null) {
589             if ("up".equalsIgnoreCase(direction)) { //$NON-NLS-1$
590
setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Double.parseDouble(rotationAngle.getText())));
591             } else {
592                 setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(Double.parseDouble(rotationAngle.getText())));
593             }
594         }
595     }
596
597     /**
598      * @param categoryLabelPositions
599      * The categoryLabelPositions to set.
600      */

601     public void setCategoryLabelPositions(CategoryLabelPositions categoryLabelPositions) {
602         this.domainLabelPositions = categoryLabelPositions;
603     }
604
605     /**
606      * @return Returns the borderVisible.
607      */

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

624     public void setBorderVisible(boolean borderVisible) {
625         this.borderVisible = borderVisible;
626     }
627
628     /**
629      * @return Returns the borderPaint.
630      */

631     public Paint JavaDoc getBorderPaint() {
632         return borderPaint;
633     }
634
635     /**
636      * @param borderPaint
637      * The borderPaint to set.
638      */

639     public void setBorderPaint(Paint JavaDoc borderPaint) {
640         if (borderPaint != null) {
641             this.borderPaint = borderPaint;
642         }
643     }
644
645     public void setTitlePosition(Node titlePositionNode) {
646         if (titlePositionNode != null) {
647             String JavaDoc titlePositionStr = titlePositionNode.getText();
648             if ("top".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
649
setTitlePosition(RectangleEdge.TOP);
650             } else if ("left".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
651
setTitlePosition(RectangleEdge.LEFT);
652             } else if ("bottom".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
653
setTitlePosition(RectangleEdge.BOTTOM);
654             } else if ("right".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
655
setTitlePosition(RectangleEdge.RIGHT);
656             }
657         }
658     }
659
660     /**
661      * @return Returns the titlePosition.
662      */

663     public RectangleEdge getTitlePosition() {
664         return titlePosition;
665     }
666
667     /**
668      * @param titlePosition
669      * The titlePosition to set.
670      */

671     public void setTitlePosition(RectangleEdge titlePosition) {
672         this.titlePosition = titlePosition;
673     }
674
675     public void setChartBackground(Node chartBackgroundNode) {
676         if (chartBackgroundNode != null) {
677             Node backgroundTypeNode = chartBackgroundNode.selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
678             if (backgroundTypeNode != null) {
679                 String JavaDoc backgroundTypeStr = backgroundTypeNode.getText();
680                 if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
681                     setChartBackgroundPaint(JFreeChartEngine.getPaint(chartBackgroundNode));
682                     setChartBackgroundImage((Image JavaDoc) null);
683                 } else if (IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
684                     setChartBackgroundImage(chartBackgroundNode);
685                     setChartBackgroundPaint(null);
686                 } else if (TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
687                     setChartBackgroundPaint(JFreeChartEngine.getTexturePaint(chartBackgroundNode, getWidth(), getHeight(), getSession()));
688                     setChartBackgroundImage((Image JavaDoc) null);
689                 } else if (GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
690                     setChartBackgroundPaint(JFreeChartEngine.getGradientPaint(chartBackgroundNode, getWidth(), getHeight()));
691                     setChartBackgroundImage((Image JavaDoc) null);
692                 }
693             }
694         }
695     }
696
697     public void setPlotBackground(Node plotBackgroundNode) {
698         if (plotBackgroundNode != null) {
699             Node backgroundTypeNode = plotBackgroundNode.selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
700             if (backgroundTypeNode != null) {
701                 String JavaDoc backgroundTypeStr = backgroundTypeNode.getText();
702                 if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
703                     setPlotBackgroundPaint(JFreeChartEngine.getPaint(plotBackgroundNode));
704                     setPlotBackgroundImage((Image JavaDoc) null);
705                 } else if (IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
706                     setPlotBackgroundImage(plotBackgroundNode);
707                     setPlotBackgroundPaint(null);
708                 } else if (TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
709                     setPlotBackgroundPaint(JFreeChartEngine.getTexturePaint(plotBackgroundNode, getWidth(), getHeight(), getSession()));
710                     setPlotBackgroundImage((Image JavaDoc) null);
711                 } else if (GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
712                     setPlotBackgroundPaint(JFreeChartEngine.getGradientPaint(plotBackgroundNode, getWidth(), getHeight()));
713                     setPlotBackgroundImage((Image JavaDoc) null);
714                 }
715             }
716         }
717     }
718
719     public void setDomainTitle(Node titleNode) {
720         if (titleNode != null) {
721             setDomainTitle(titleNode.getText());
722         }
723     }
724
725     /**
726      * @return Returns the domainTitle.
727      */

728     public String JavaDoc getDomainTitle() {
729         return domainTitle;
730     }
731
732     /**
733      * @param domainTitle
734      * The domainTitle to set.
735      */

736     public void setDomainTitle(String JavaDoc domainTitle) {
737         this.domainTitle = domainTitle;
738     }
739
740     public void setRangeTitle(Node titleNode) {
741         if (titleNode != null) {
742             setRangeTitle(titleNode.getText());
743         }
744     }
745
746     /**
747      * @return Returns the rangeTitle.
748      */

749     public String JavaDoc getRangeTitle() {
750         return rangeTitle;
751     }
752
753     /**
754      * @param rangeTitle
755      * The rangeTitle to set.
756      */

757     public void setRangeTitle(String JavaDoc rangeTitle) {
758         this.rangeTitle = rangeTitle;
759     }
760
761     public void setDomainTitleFont(Node titleFontNode) {
762         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
763         if (font != null) {
764             setDomainTitleFont(font);
765         }
766     }
767
768     /**
769      * @return Returns the domainTitleFont.
770      */

771     public Font JavaDoc getDomainTitleFont() {
772         return domainTitleFont;
773     }
774
775     /**
776      * @param domainTitleFont
777      * The domainTitleFont to set.
778      */

779     public void setDomainTitleFont(Font JavaDoc domainTitleFont) {
780         this.domainTitleFont = domainTitleFont;
781     }
782
783     public void setRangeTitleFont(Node titleFontNode) {
784         Font JavaDoc font = JFreeChartEngine.getFont(titleFontNode);
785         if (font != null) {
786             setRangeTitleFont(font);
787         }
788     }
789
790     /**
791      * @return Returns the rangeTitleFont.
792      */

793     public Font JavaDoc getRangeTitleFont() {
794         return rangeTitleFont;
795     }
796
797     /**
798      * @param rangeTitleFont
799      * The rangeTitleFont to set.
800      */

801     public void setRangeTitleFont(Font JavaDoc rangeTitleFont) {
802         this.rangeTitleFont = rangeTitleFont;
803     }
804
805     public boolean isDisplayLabels() {
806         // TODO Auto-generated method stub
807
return false;
808     }
809
810     public IPentahoSession getSession() {
811         return session;
812     }
813
814     public void setSession(IPentahoSession session) {
815         this.session = session;
816     }
817 }
818
Popular Tags