Source Code Cross Referenced for PieDatasetChartDefinition.java in  » Report » pentaho-report » org » pentaho » plugin » jfreechart » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » pentaho report » org.pentaho.plugin.jfreechart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007:         * BI Platform.  The Initial Developer is Pentaho Corporation.
008:         *
009:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
011:         * the license for the specific language governing your rights and limitations.
012:         *
013:         * Created Feb 15, 2006
014:         * @author wseyler
015:         */
016:
017:        package org.pentaho.plugin.jfreechart;
018:
019:        import java.awt.Color;
020:        import java.awt.Font;
021:        import java.awt.Image;
022:        import java.awt.Paint;
023:        import java.util.ArrayList;
024:        import java.util.Iterator;
025:        import java.util.List;
026:
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:        import org.dom4j.Node;
030:        import org.jfree.chart.title.TextTitle;
031:        import org.jfree.data.UnknownKeyException;
032:        import org.jfree.data.general.DefaultPieDataset;
033:        import org.jfree.ui.RectangleEdge;
034:        import org.pentaho.commons.connection.IPentahoDataTypes;
035:        import org.pentaho.commons.connection.IPentahoResultSet;
036:        import org.pentaho.commons.connection.PentahoDataTransmuter;
037:        import org.pentaho.core.session.IPentahoSession;
038:        import org.pentaho.messages.Messages;
039:
040:        public class PieDatasetChartDefinition extends DefaultPieDataset
041:                implements  ChartDefinition {
042:            /**
043:             *
044:             */
045:            private static final long serialVersionUID = 1L;
046:
047:            private static final String INTERIOR_GAP_NODE_NAME = "interior-gap"; //$NON-NLS-1$
048:
049:            private static final String START_ANGLE_NODE_NAME = "start-angle"; //$NON-NLS-1$
050:
051:            private static final String LABEL_FONT_NODE_NAME = "label-font"; //$NON-NLS-1$
052:
053:            private static final String LABEL_PAINT_NODE_NAME = "label-paint"; //$NON-NLS-1$
054:
055:            private static final String LABEL_BACKGROUND_PAINT_NODE_NAME = "label-background-paint"; //$NON-NLS-1$
056:
057:            private static final String LABEL_GAP_NODE_NAME = "label-gap"; //$NON-NLS-1$
058:
059:            private static final String SLICE_NODE_NAME = "slice"; //$NON-NLS-1$
060:
061:            private static final String EXPLODE_SLICE_NODE_NAME = "explode-slices"; //$NON-NLS-1$
062:
063:            // JFreeChart Customizations
064:            private String title = ""; //$NON-NLS-1$
065:
066:            private String noDataMessage = null;
067:
068:            private RectangleEdge titlePosition = RectangleEdge.TOP;
069:
070:            private Font titleFont = TextTitle.DEFAULT_FONT;
071:
072:            private List subTitles = new ArrayList();
073:
074:            private List explodeSlices = new ArrayList();
075:
076:            private Paint chartBackgroundPaint = Color.WHITE;
077:
078:            private Image chartBackgroundImage = null;
079:
080:            private boolean borderVisible = false;
081:
082:            private Paint borderPaint = Color.BLACK;
083:
084:            private int width = 200;
085:
086:            private int height = 200;
087:
088:            // Plot Customizations
089:            private Paint plotBackgroundPaint = Color.WHITE;
090:
091:            private Image plotBackgroundImage = null;
092:
093:            private Paint[] paintSequence = null;
094:
095:            private boolean legendIncluded = true;
096:
097:            private boolean threeD = false;
098:
099:            private boolean displayLabels = true;
100:
101:            // PiePlot Customizations
102:            private double interiorGap = 0.25;
103:
104:            private double startAngle = 90.0;
105:
106:            private Font labelFont = new Font("SansSerif", Font.PLAIN, 10); //$NON-NLS-1$
107:
108:            private Paint labelPaint = Color.BLACK;
109:
110:            private Paint labelBackgroundPaint = new Color(255, 255, 204);
111:
112:            private double labelGap = 0.10;
113:
114:            // Other stuff
115:            private IPentahoSession session;
116:
117:            private Font legendFont = null;
118:
119:            private boolean legendBorderVisible = true;
120:
121:            /**
122:             *
123:             */
124:            public PieDatasetChartDefinition(IPentahoSession session) {
125:                super ();
126:                this .session = session;
127:            }
128:
129:            /**
130:             * @param data
131:             */
132:            public PieDatasetChartDefinition(IPentahoResultSet data,
133:                    boolean byRow, IPentahoSession session) {
134:                this (session);
135:                if (byRow) {
136:                    setDataByRow(data);
137:                } else {
138:                    setDataByColumn(data);
139:                }
140:            }
141:
142:            public PieDatasetChartDefinition(IPentahoResultSet data,
143:                    boolean byRow, Node chartAttributes, IPentahoSession session) {
144:                this (data, byRow, session);
145:                setChartAttributes(chartAttributes);
146:            }
147:
148:            public static Log getLogger() {
149:                return LogFactory.getLog(PieDatasetChartDefinition.class);
150:            }
151:
152:            private void setChartAttributes(Node chartAttributes) {
153:                if (chartAttributes == null) {
154:                    return;
155:                }
156:                // set the chart background
157:                setChartBackground(chartAttributes
158:                        .selectSingleNode(CHART_BACKGROUND_NODE_NAME));
159:
160:                // set the plot background
161:                setPlotBackground(chartAttributes
162:                        .selectSingleNode(PLOT_BACKGROUND_NODE_NAME));
163:
164:                // do we want a legend
165:                setLegendIncluded(chartAttributes
166:                        .selectSingleNode(INCLUDE_LEGEND_NODE_NAME));
167:
168:                // get the chart title
169:                setTitle(chartAttributes.selectSingleNode(TITLE_NODE_NAME));
170:
171:                // get the chart subtitles
172:
173:                // A list of <subtitle> nodes should not be allowed to exist as a child of the main XML element (for XML schema to 
174:                // be well constructed and validate the XML . 
175:                // We have deprecated <subtitle> as a child of the main node , and now require a <subtitles> parent node 
176:                // under which <subtitle> can exist. 
177:
178:                List subtitles = chartAttributes
179:                        .selectNodes(SUBTITLE_NODE_NAME);
180:
181:                if ((subtitles == null) || (subtitles.isEmpty())) {
182:                    Node subTitlesNode = chartAttributes
183:                            .selectSingleNode(SUBTITLES_NODE_NAME);
184:                    if (subTitlesNode != null) {
185:                        subtitles = subTitlesNode
186:                                .selectNodes(SUBTITLE_NODE_NAME);
187:                    }
188:                } else {
189:                    // log a deprecation warning for this property...
190:                    getLogger()
191:                            .warn(
192:                                    Messages
193:                                            .getString(
194:                                                    "CHART.WARN_DEPRECATED_CHILD", SUBTITLE_NODE_NAME, SUBTITLES_NODE_NAME));//$NON-NLS-1$ 
195:                    getLogger()
196:                            .warn(
197:                                    Messages
198:                                            .getString(
199:                                                    "CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", SUBTITLE_NODE_NAME));//$NON-NLS-1$  
200:                }
201:
202:                if (subtitles != null) {
203:                    addSubTitles(subtitles);
204:                }
205:
206:                // get the chart's exploded sections
207:
208:                List slicesNodes = null;
209:                Node slicesNode = chartAttributes
210:                        .selectSingleNode(EXPLODE_SLICE_NODE_NAME);
211:                if (slicesNode != null) {
212:                    slicesNodes = slicesNode.selectNodes(SLICE_NODE_NAME);
213:                }
214:
215:                if (slicesNodes != null) {
216:                    addExplodedSlices(slicesNodes);
217:                }
218:
219:                // get the paint sequence
220:                setPaintSequence(chartAttributes
221:                        .selectSingleNode(PALETTE_NODE_NAME));
222:
223:                // get the 3D value
224:                setThreeD(chartAttributes.selectSingleNode(THREED_NODE_NAME));
225:
226:                // set the width
227:                setWidth(chartAttributes.selectSingleNode(WIDTH_NODE_NAME));
228:
229:                // set the height
230:                setHeight(chartAttributes.selectSingleNode(HEIGHT_NODE_NAME));
231:
232:                // set the border on or off
233:                setBorderVisible(chartAttributes
234:                        .selectSingleNode(CHART_BORDER_VISIBLE_NODE_NAME));
235:
236:                // set the border Paint
237:                setBorderPaint(JFreeChartEngine.getPaint(chartAttributes
238:                        .selectSingleNode(CHART_BORDER_PAINT_NODE_NAME)));
239:
240:                // set the title location
241:                setTitlePosition(chartAttributes
242:                        .selectSingleNode(TITLE_POSITION_NODE_NAME));
243:
244:                // set the title font
245:                setTitleFont(chartAttributes
246:                        .selectSingleNode(TITLE_FONT_NODE_NAME));
247:
248:                // set the interior gap
249:                setInteriorGap(chartAttributes
250:                        .selectSingleNode(INTERIOR_GAP_NODE_NAME));
251:
252:                // set the start angle
253:                setStartAngle(chartAttributes
254:                        .selectSingleNode(START_ANGLE_NODE_NAME));
255:
256:                // set if we want labels
257:                setDisplayLabels(chartAttributes
258:                        .selectSingleNode(DISPLAY_LABELS_NODE_NAME));
259:
260:                // set the label font
261:                setLabelFont(chartAttributes
262:                        .selectSingleNode(LABEL_FONT_NODE_NAME));
263:
264:                // set the label paint
265:                setLabelPaint(JFreeChartEngine.getPaint(chartAttributes
266:                        .selectSingleNode(LABEL_PAINT_NODE_NAME)));
267:
268:                // set the label background paint
269:                setLabelBackgroundPaint(JFreeChartEngine
270:                        .getPaint(chartAttributes
271:                                .selectSingleNode(LABEL_BACKGROUND_PAINT_NODE_NAME)));
272:
273:                // set the label gap
274:                setLabelGap(chartAttributes
275:                        .selectSingleNode(LABEL_GAP_NODE_NAME));
276:
277:                // set legend font
278:                setLegendFont(chartAttributes
279:                        .selectSingleNode(LEGEND_FONT_NODE_NAME));
280:
281:                // set legend border visible
282:                setLegendBorderVisible(chartAttributes
283:                        .selectSingleNode(DISPLAY_LEGEND_BORDER_NODE_NAME));
284:            }
285:
286:            private void setDataByColumn(IPentahoResultSet data) {
287:                setDataByRow(PentahoDataTransmuter.pivot(data));
288:            }
289:
290:            private void setDataByRow(IPentahoResultSet data) {
291:                if (data == null) {
292:                    noDataMessage = Messages
293:                            .getString("CHART.USER_NO_DATA_AVAILABLE"); //$NON-NLS-1$
294:                    return; // No data so we've got nothing to set
295:                    // TODO come up with some sort of error strategy here.
296:                }
297:                boolean hasColumnHeaders = data.getMetaData()
298:                        .getColumnHeaders() != null;
299:                if (!hasColumnHeaders) {
300:                    data = PentahoDataTransmuter.transmute(data, false);
301:                }
302:                String[] columnHeaders = null;
303:                try {
304:                    columnHeaders = PentahoDataTransmuter.getCollapsedHeaders(
305:                            IPentahoDataTypes.AXIS_COLUMN, data, '|');
306:                } catch (Exception e) {
307:                    // should really NEVER get here
308:                    e.printStackTrace();
309:                }
310:                int row = 0;
311:                if (!hasColumnHeaders) {
312:                    data.next();
313:                    row = 1;
314:                }
315:                Object[] rowData = data.next();
316:                while (rowData != null && row < data.getRowCount() + 1) {
317:                    for (int column = 0; column < rowData.length; column++) {
318:                        if (rowData[column] instanceof  Number) {
319:
320:                            Number currentNumber = null;
321:                            try { // If value has been set then we get it
322:                                currentNumber = getValue(columnHeaders[column]);
323:                            } catch (UnknownKeyException uke) { // else we just set it
324:                                // to zero
325:                                currentNumber = new Double(0.0);
326:                            }
327:                            if (currentNumber == null) {
328:                                currentNumber = new Double(0.0);
329:                            }
330:                            double currentValue = currentNumber.doubleValue();
331:
332:                            double newValue = ((Number) rowData[column])
333:                                    .doubleValue();
334:                            setValue(columnHeaders[column], new Double(newValue
335:                                    + currentValue));
336:                        }
337:                    }
338:                    rowData = data.next();
339:                    row++;
340:                }
341:
342:                if ((data.getRowCount() > 0) && (this .getItemCount() <= 0)) {
343:                    noDataMessage = Messages
344:                            .getString("CHART.USER_INCORRECT_DATA_FORMAT"); //$NON-NLS-1$
345:                }
346:
347:            }
348:
349:            public void setHeight(Node heightNode) {
350:                if (heightNode != null) {
351:                    setHeight(Integer.parseInt(heightNode.getText()));
352:                }
353:            }
354:
355:            /**
356:             * @param height
357:             *            The height to set.
358:             */
359:            public void setHeight(int height) {
360:                this .height = height;
361:            }
362:
363:            public int getHeight() {
364:                return height;
365:            }
366:
367:            public void setWidth(Node widthNode) {
368:                if (widthNode != null) {
369:                    setWidth(Integer.parseInt(widthNode.getText()));
370:                }
371:            }
372:
373:            /**
374:             * @param width
375:             *            The width to set.
376:             */
377:            public void setWidth(int width) {
378:                this .width = width;
379:            }
380:
381:            public int getWidth() {
382:                return width;
383:            }
384:
385:            public void setTitle(Node chartTitleNode) {
386:                if (chartTitleNode != null) {
387:                    setTitle(chartTitleNode.getText());
388:                }
389:            }
390:
391:            /**
392:             * @param title
393:             *            The title to set.
394:             */
395:            public void setTitle(String title) {
396:                this .title = title;
397:            }
398:
399:            public String getTitle() {
400:                return title;
401:            }
402:
403:            public void setTitleFont(Font titleFont) {
404:                this .titleFont = titleFont;
405:            }
406:
407:            public void setTitleFont(Node titleFontNode) {
408:                Font font = JFreeChartEngine.getFont(titleFontNode);
409:                if (font != null) {
410:                    setTitleFont(font);
411:                }
412:            }
413:
414:            public Font getTitleFont() {
415:                return titleFont;
416:            }
417:
418:            public void addSubTitles(List subTitleNodes) {
419:                if (subTitleNodes != null) {
420:                    Iterator iter = subTitleNodes.iterator();
421:                    while (iter.hasNext()) {
422:                        addSubTitle(((Node) iter.next()).getText());
423:                    }
424:                }
425:            }
426:
427:            public void addSubTitle(String subTitle) {
428:                subTitles.add(subTitle);
429:            }
430:
431:            public List getSubtitles() {
432:                return subTitles;
433:            }
434:
435:            public void addExplodedSlices(List nodes) {
436:                if (nodes != null) {
437:                    Iterator iter = nodes.iterator();
438:                    while (iter.hasNext()) {
439:                        addExplodedSlice(((Node) iter.next()).getText());
440:                    }
441:                }
442:            }
443:
444:            public void addExplodedSlice(String slice) {
445:                explodeSlices.add(slice);
446:            }
447:
448:            public List getExplodedSlices() {
449:                return explodeSlices;
450:            }
451:
452:            public void setChartBackground(Node chartBackgroundNode) {
453:                if (chartBackgroundNode != null) {
454:                    Node backgroundTypeNode = chartBackgroundNode
455:                            .selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
456:                    if (backgroundTypeNode != null) {
457:                        String backgroundTypeStr = backgroundTypeNode.getText();
458:                        if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
459:                            setChartBackgroundPaint(JFreeChartEngine
460:                                    .getPaint(chartBackgroundNode));
461:                            setChartBackgroundImage((Image) null);
462:                        } else if (IMAGE_TYPE_NAME
463:                                .equalsIgnoreCase(backgroundTypeStr)) {
464:                            setChartBackgroundImage(chartBackgroundNode);
465:                            setChartBackgroundPaint(null);
466:                        } else if (TEXTURE_TYPE_NAME
467:                                .equalsIgnoreCase(backgroundTypeStr)) {
468:                            setChartBackgroundPaint(JFreeChartEngine
469:                                    .getTexturePaint(chartBackgroundNode,
470:                                            getWidth(), getHeight(),
471:                                            getSession()));
472:                            setChartBackgroundImage((Image) null);
473:                        } else if (GRADIENT_TYPE_NAME
474:                                .equalsIgnoreCase(backgroundTypeStr)) {
475:                            setChartBackgroundPaint(JFreeChartEngine
476:                                    .getGradientPaint(chartBackgroundNode,
477:                                            getWidth(), getHeight()));
478:                            setChartBackgroundImage((Image) null);
479:                        }
480:                    }
481:                }
482:            }
483:
484:            /**
485:             * @param backgroundPaint
486:             *            The backgroundPaint to set.
487:             */
488:            public void setChartBackgroundPaint(Paint chartBackgroundPaint) {
489:                if (chartBackgroundPaint != null) {
490:                    this .chartBackgroundPaint = chartBackgroundPaint;
491:                }
492:            }
493:
494:            public Paint getChartBackgroundPaint() {
495:                return chartBackgroundPaint;
496:            }
497:
498:            public void setChartBackgroundImage(Node chartBackgroundImageNode) {
499:                setChartBackgroundImage(JFreeChartEngine.getImage(
500:                        chartBackgroundImageNode, getSession()));
501:            }
502:
503:            /**
504:             * @param chartBackgroundImage
505:             *            The chartBackgroundImage to set.
506:             */
507:            public void setChartBackgroundImage(Image chartBackgroundImage) {
508:                this .chartBackgroundImage = chartBackgroundImage;
509:            }
510:
511:            public Image getChartBackgroundImage() {
512:                return chartBackgroundImage;
513:            }
514:
515:            public void setBorderVisible(Node borderVisibleNode) {
516:                if (borderVisibleNode != null) {
517:                    String boolStr = borderVisibleNode.getText();
518:                    Boolean booleanValue = new Boolean(boolStr);
519:                    setBorderVisible(booleanValue.booleanValue());
520:                }
521:            }
522:
523:            /**
524:             * @param borderVisible
525:             *            The borderVisible to set.
526:             */
527:            public void setBorderVisible(boolean borderVisible) {
528:                this .borderVisible = borderVisible;
529:            }
530:
531:            public boolean isBorderVisible() {
532:                return borderVisible;
533:            }
534:
535:            public Paint getBorderPaint() {
536:                return borderPaint;
537:            }
538:
539:            /**
540:             * @param borderPaint
541:             *            The borderPaint to set.
542:             */
543:            public void setBorderPaint(Paint borderPaint) {
544:                if (borderPaint != null) {
545:                    this .borderPaint = borderPaint;
546:                }
547:            }
548:
549:            public void setTitlePosition(Node titlePositionNode) {
550:                if (titlePositionNode != null) {
551:                    String titlePositionStr = titlePositionNode.getText();
552:                    if ("top".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
553:                        setTitlePosition(RectangleEdge.TOP);
554:                    } else if ("left".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
555:                        setTitlePosition(RectangleEdge.LEFT);
556:                    } else if ("bottom".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
557:                        setTitlePosition(RectangleEdge.BOTTOM);
558:                    } else if ("right".equalsIgnoreCase(titlePositionStr)) { //$NON-NLS-1$
559:                        setTitlePosition(RectangleEdge.RIGHT);
560:                    }
561:                }
562:            }
563:
564:            /**
565:             * @param titlePosition
566:             *            The titlePosition to set.
567:             */
568:            public void setTitlePosition(RectangleEdge titlePosition) {
569:                this .titlePosition = titlePosition;
570:            }
571:
572:            public RectangleEdge getTitlePosition() {
573:                return titlePosition;
574:            }
575:
576:            public void setPaintSequence(Node paletteNode) {
577:                if (paletteNode != null) {
578:                    List colorNodes = paletteNode.selectNodes(COLOR_NODE_NAME);
579:                    Paint[] paints = new Paint[colorNodes.size()];
580:                    for (int i = 0; i < colorNodes.size(); i++) {
581:                        paints[i] = JFreeChartEngine.getPaint((Node) colorNodes
582:                                .get(i));
583:                    }
584:                    setPaintSequence(paints);
585:                }
586:            }
587:
588:            /**
589:             * @param paintSequence
590:             *            The paintSequence to set.
591:             */
592:            public void setPaintSequence(Paint[] paintSequence) {
593:                this .paintSequence = paintSequence;
594:            }
595:
596:            public Paint[] getPaintSequence() {
597:                return paintSequence;
598:            }
599:
600:            public void setPlotBackground(Node plotBackgroundNode) {
601:                if (plotBackgroundNode != null) {
602:                    Node backgroundTypeNode = plotBackgroundNode
603:                            .selectSingleNode(BACKGROUND_TYPE_ATTRIBUTE_NAME);
604:                    if (backgroundTypeNode != null) {
605:                        String backgroundTypeStr = backgroundTypeNode.getText();
606:                        if (COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
607:                            setPlotBackgroundPaint(JFreeChartEngine
608:                                    .getPaint(plotBackgroundNode));
609:                            setPlotBackgroundImage((Image) null);
610:                        } else if (IMAGE_TYPE_NAME
611:                                .equalsIgnoreCase(backgroundTypeStr)) {
612:                            setPlotBackgroundImage(plotBackgroundNode);
613:                            setPlotBackgroundPaint(null);
614:                        } else if (TEXTURE_TYPE_NAME
615:                                .equalsIgnoreCase(backgroundTypeStr)) {
616:                            setPlotBackgroundPaint(JFreeChartEngine
617:                                    .getTexturePaint(plotBackgroundNode,
618:                                            getWidth(), getHeight(),
619:                                            getSession()));
620:                            setPlotBackgroundImage((Image) null);
621:                        } else if (GRADIENT_TYPE_NAME
622:                                .equalsIgnoreCase(backgroundTypeStr)) {
623:                            setPlotBackgroundPaint(JFreeChartEngine
624:                                    .getGradientPaint(plotBackgroundNode,
625:                                            getWidth(), getHeight()));
626:                            setPlotBackgroundImage((Image) null);
627:                        }
628:                    }
629:                }
630:            }
631:
632:            public void setPlotBackgroundPaint(Paint plotBackgroundPaint) {
633:                if (plotBackgroundPaint != null) {
634:                    this .plotBackgroundPaint = plotBackgroundPaint;
635:                }
636:            }
637:
638:            public Paint getPlotBackgroundPaint() {
639:                return plotBackgroundPaint;
640:            }
641:
642:            /**
643:             * @param plotBackgroundImage
644:             *            The plotBackgroundImage to set.
645:             */
646:            public void setPlotBackgroundImage(Image plotBackgroundImage) {
647:                this .plotBackgroundImage = plotBackgroundImage;
648:            }
649:
650:            public void setPlotBackgroundImage(Node plotBackgroundImageNode) {
651:                setPlotBackgroundImage(JFreeChartEngine.getImage(
652:                        plotBackgroundImageNode, getSession()));
653:            }
654:
655:            public Image getPlotBackgroundImage() {
656:                return plotBackgroundImage;
657:            }
658:
659:            public void setLegendIncluded(Node legendNode) {
660:                if (legendNode != null) {
661:                    String boolStr = legendNode.getText();
662:                    Boolean booleanValue = new Boolean(boolStr);
663:                    setLegendIncluded(booleanValue.booleanValue());
664:                }
665:            }
666:
667:            /**
668:             * @param legendIncluded
669:             *            The legendIncluded to set.
670:             */
671:            public void setLegendIncluded(boolean legendIncluded) {
672:                this .legendIncluded = legendIncluded;
673:            }
674:
675:            public boolean isLegendIncluded() {
676:                return legendIncluded;
677:            }
678:
679:            public void setThreeD(Node threeDNode) {
680:                if (threeDNode != null) {
681:                    String boolStr = threeDNode.getText();
682:                    Boolean booleanValue = new Boolean(boolStr);
683:                    setThreeD(booleanValue.booleanValue());
684:                }
685:            }
686:
687:            /**
688:             * @param threeD
689:             *            The threeD to set.
690:             */
691:            public void setThreeD(boolean threeD) {
692:                this .threeD = threeD;
693:            }
694:
695:            public boolean isThreeD() {
696:                return threeD;
697:            }
698:
699:            private void setInteriorGap(Node interiorGapNode) {
700:                if (interiorGapNode != null) {
701:                    String gapNodeStr = interiorGapNode.getText();
702:                    Double doubleValue = new Double(gapNodeStr);
703:                    setInteriorGap(doubleValue.doubleValue());
704:                }
705:            }
706:
707:            /**
708:             * @param interiorGap
709:             *            The interiorGap to set.
710:             */
711:            public void setInteriorGap(double interiorGap) {
712:                this .interiorGap = interiorGap;
713:            }
714:
715:            public double getInteriorGap() {
716:                return interiorGap;
717:            }
718:
719:            private void setStartAngle(Node startAngleNode) {
720:                if (startAngleNode != null) {
721:                    String gapNodeStr = startAngleNode.getText();
722:                    Double doubleValue = new Double(gapNodeStr);
723:                    setStartAngle(doubleValue.doubleValue());
724:                }
725:            }
726:
727:            /**
728:             * @param startAngle
729:             *            The startAngle to set.
730:             */
731:            public void setStartAngle(double startAngle) {
732:                this .startAngle = startAngle;
733:            }
734:
735:            public double getStartAngle() {
736:                return startAngle;
737:            }
738:
739:            private void setLabelFont(Node labelFontNode) {
740:                Font font = JFreeChartEngine.getFont(labelFontNode);
741:                if (font != null) {
742:                    setLabelFont(font);
743:                }
744:            }
745:
746:            public void setLabelFont(Font font) {
747:                labelFont = font;
748:            }
749:
750:            public Font getLabelFont() {
751:                // TODO Auto-generated method stub
752:                return labelFont;
753:            }
754:
755:            /**
756:             * @param labelPaint
757:             *            The labelPaint to set.
758:             */
759:            public void setLabelPaint(Paint labelPaint) {
760:                if (labelPaint != null) {
761:                    this .labelPaint = labelPaint;
762:                }
763:            }
764:
765:            /**
766:             * @return Returns the labelPaint.
767:             */
768:            public Paint getLabelPaint() {
769:                return labelPaint;
770:            }
771:
772:            public Paint getLabelBackgroundPaint() {
773:                // TODO Auto-generated method stub
774:                return labelBackgroundPaint;
775:            }
776:
777:            /**
778:             * @param labelBackgroundPaint
779:             *            The labelBackgroundPaint to set.
780:             */
781:            public void setLabelBackgroundPaint(Paint labelBackgroundPaint) {
782:                if (labelBackgroundPaint != null) {
783:                    this .labelBackgroundPaint = labelBackgroundPaint;
784:                }
785:            }
786:
787:            public double getLabelGap() {
788:                return labelGap;
789:            }
790:
791:            /**
792:             * @param node
793:             *            The labelGap to set.
794:             */
795:            public void setLabelGap(Node labelGapNode) {
796:                if (labelGapNode != null) {
797:                    String gapNodeStr = labelGapNode.getText();
798:                    Double doubleValue = new Double(gapNodeStr);
799:                    setLabelGap(doubleValue.doubleValue());
800:                }
801:            }
802:
803:            public void setLabelGap(double labelGap) {
804:                this .labelGap = labelGap;
805:            }
806:
807:            public boolean isDisplayLabels() {
808:                return displayLabels;
809:            }
810:
811:            public void setDisplayLabels(Node threeDNode) {
812:                if (threeDNode != null) {
813:                    String boolStr = threeDNode.getText();
814:                    Boolean booleanValue = new Boolean(boolStr);
815:                    setDisplayLabels(booleanValue.booleanValue());
816:                }
817:            }
818:
819:            public void setDisplayLabels(boolean displayLabels) {
820:                this .displayLabels = displayLabels;
821:            }
822:
823:            public IPentahoSession getSession() {
824:                return session;
825:            }
826:
827:            public void setSession(IPentahoSession session) {
828:                this .session = session;
829:            }
830:
831:            /**
832:             * Return the java.awt.Font to be used to display the legend items
833:             *
834:             * @return Font The font for the legend items
835:             */
836:            public Font getLegendFont() {
837:                // TODO Auto-generated method stub
838:                return legendFont;
839:            }
840:
841:            /**
842:             * Set java.awt.Font to be used to display the legend items
843:             *
844:             * @param Font The java.awt.Font for the legend items
845:             */
846:            public void setLegendFont(Font legendFont) {
847:                this .legendFont = legendFont;
848:            }
849:
850:            public void setLegendFont(Node legendFontNode) {
851:                Font font = JFreeChartEngine.getFont(legendFontNode);
852:                if (font != null) {
853:                    setLegendFont(font);
854:                }
855:            }
856:
857:            public void setLegendBorderVisible(Node legendBorderVisibleNode) {
858:                if (legendBorderVisibleNode != null) {
859:                    boolean legBorderVisible = (new Boolean(
860:                            legendBorderVisibleNode.getText())).booleanValue();
861:                    setLegendBorderVisible(legBorderVisible);
862:                }
863:            }
864:
865:            /**
866:             * @param boolean legendBorderVisible
867:             *        Set the visibility of the legend border.
868:             */
869:            public void setLegendBorderVisible(boolean legendBorderVisible) {
870:                this .legendBorderVisible = legendBorderVisible;
871:            }
872:
873:            /**
874:             * Return the boolen that states if the legend border is visible
875:             *
876:             * @return boolean Is the legend border visible
877:             */
878:            public boolean isLegendBorderVisible() {
879:                // TODO Auto-generated method stub
880:                return legendBorderVisible;
881:            }
882:
883:            public String getNoDataMessage() {
884:                return noDataMessage;
885:            }
886:
887:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.