Source Code Cross Referenced for ChartFactory.java in  » Chart » jfreechart » org » jfree » chart » 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 » Chart » jfreechart » org.jfree.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* ===========================================================
0002:         * JFreeChart : a free chart library for the Java(tm) platform
0003:         * ===========================================================
0004:         *
0005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
0006:         *
0007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
0008:         *
0009:         * This library is free software; you can redistribute it and/or modify it 
0010:         * under the terms of the GNU Lesser General Public License as published by 
0011:         * the Free Software Foundation; either version 2.1 of the License, or 
0012:         * (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful, but 
0015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
0016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
0017:         * License for more details.
0018:         *
0019:         * You should have received a copy of the GNU Lesser General Public
0020:         * License along with this library; if not, write to the Free Software
0021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
0022:         * USA.  
0023:         *
0024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
0025:         * in the United States and other countries.]
0026:         *
0027:         * -----------------
0028:         * ChartFactory.java
0029:         * -----------------
0030:         * (C) Copyright 2001-2007, by Object Refinery Limited and Contributors.
0031:         *
0032:         * Original Author:  David Gilbert (for Object Refinery Limited);
0033:         * Contributor(s):   Serge V. Grachov;
0034:         *                   Joao Guilherme Del Valle;
0035:         *                   Bill Kelemen;
0036:         *                   Jon Iles;
0037:         *                   Jelai Wang;
0038:         *                   Richard Atkinson;
0039:         *                   David Browning (for Australian Institute of Marine 
0040:         *                       Science);
0041:         *                   Benoit Xhenseval;
0042:         *
0043:         * $Id: ChartFactory.java,v 1.22.2.11 2007/06/11 13:36:54 mungady Exp $
0044:         *
0045:         * Changes
0046:         * -------
0047:         * 19-Oct-2001 : Version 1, most methods transferred from JFreeChart.java (DG);
0048:         * 22-Oct-2001 : Added methods to create stacked bar charts (DG);
0049:         *               Renamed DataSource.java --> Dataset.java etc. (DG);
0050:         * 31-Oct-2001 : Added 3D-effect vertical bar and stacked-bar charts, 
0051:         *               contributed by Serge V. Grachov (DG);
0052:         * 07-Nov-2001 : Added a flag to control whether or not a legend is added to 
0053:         *               the chart (DG);
0054:         * 17-Nov-2001 : For pie chart, changed dataset from CategoryDataset to 
0055:         *               PieDataset (DG);
0056:         * 30-Nov-2001 : Removed try/catch handlers from chart creation, as the 
0057:         *               exception are now RuntimeExceptions, as suggested by Joao 
0058:         *               Guilherme Del Valle (DG);
0059:         * 06-Dec-2001 : Added createCombinableXXXXXCharts methods (BK);
0060:         * 12-Dec-2001 : Added createCandlestickChart() method (DG);
0061:         * 13-Dec-2001 : Updated methods for charts with new renderers (DG);
0062:         * 08-Jan-2002 : Added import for 
0063:         *               com.jrefinery.chart.combination.CombinedChart (DG);
0064:         * 31-Jan-2002 : Changed the createCombinableVerticalXYBarChart() method to use
0065:         *               renderer (DG);
0066:         * 06-Feb-2002 : Added new method createWindPlot() (DG);
0067:         * 23-Apr-2002 : Updates to the chart and plot constructor API (DG);
0068:         * 21-May-2002 : Added new method createAreaChart() (JI);
0069:         * 06-Jun-2002 : Added new method createGanttChart() (DG);
0070:         * 11-Jun-2002 : Renamed createHorizontalStackedBarChart() 
0071:         *               --> createStackedHorizontalBarChart() for consistency (DG);
0072:         * 06-Aug-2002 : Updated Javadoc comments (DG);
0073:         * 21-Aug-2002 : Added createPieChart(CategoryDataset) method (DG);
0074:         * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
0075:         * 09-Oct-2002 : Added methods including tooltips and URL flags (DG);
0076:         * 06-Nov-2002 : Moved renderers into a separate package (DG);
0077:         * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG);
0078:         * 21-Mar-2003 : Incorporated HorizontalCategoryAxis3D, see bug id 685501 (DG);
0079:         * 13-May-2003 : Merged some horizontal and vertical methods (DG);
0080:         * 24-May-2003 : Added support for timeline in createHighLowChart (BK);
0081:         * 07-Jul-2003 : Added createHistogram() method contributed by Jelai Wang (DG);
0082:         * 27-Jul-2003 : Added createStackedAreaXYChart() method (RA);
0083:         * 05-Aug-2003 : added new method createBoxAndWhiskerChart (DB);
0084:         * 08-Sep-2003 : Changed ValueAxis API (DG);
0085:         * 07-Oct-2003 : Added stepped area XY chart contributed by Matthias Rose (DG);
0086:         * 06-Nov-2003 : Added createWaterfallChart() method (DG);
0087:         * 20-Nov-2003 : Set rendering order for 3D bar charts to fix overlapping 
0088:         *               problems (DG);
0089:         * 25-Nov-2003 : Added createWaferMapChart() method (DG);
0090:         * 23-Dec-2003 : Renamed createPie3DChart() --> createPieChart3D for 
0091:         *               consistency (DG);
0092:         * 20-Jan-2004 : Added createPolarChart() method (DG);
0093:         * 28-Jan-2004 : Fixed bug (882890) with axis range in 
0094:         *               createStackedXYAreaChart() method (DG);
0095:         * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG);
0096:         * 11-Mar-2004 : Updated for pie chart changes (DG);
0097:         * 27-Apr-2004 : Added new createPieChart() method contributed by Benoit 
0098:         *               Xhenseval (see RFE 942195) (DG);
0099:         * 11-May-2004 : Split StandardCategoryItemLabelGenerator 
0100:         *               --> StandardCategoryToolTipGenerator and
0101:         *               StandardCategoryLabelGenerator (DG);
0102:         * 06-Jan-2005 : Removed deprecated methods (DG);
0103:         * 27-Jan-2005 : Added new constructor to LineAndShapeRenderer (DG);
0104:         * 28-Feb-2005 : Added docs to createBubbleChart() method (DG);
0105:         * 17-Mar-2005 : Added createRingPlot() method (DG);
0106:         * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG);
0107:         * 29-Nov-2005 : Removed signal chart (DG);
0108:         * ------------- JFREECHART 1.0.x ---------------------------------------------
0109:         * 26-Jan-2006 : Corrected API docs for createScatterPlot() (DG);
0110:         * 23-Aug-2006 : Modified createStackedXYAreaChart() to use 
0111:         *               StackedXYAreaRenderer2, because StackedXYAreaRenderer doesn't
0112:         *               handle negative values (DG);
0113:         * 27-Sep-2006 : Update createPieChart() method for deprecated code (DG);
0114:         * 29-Nov-2006 : Update createXYBarChart() to use a time based tool tip 
0115:         *               generator is a DateAxis is requested (DG);
0116:         * 17-Jan-2007 : Added createBoxAndWhiskerChart() method from patch 1603937
0117:         *               submitted by Darren Jung (DG);
0118:         *
0119:         */
0120:
0121:        package org.jfree.chart;
0122:
0123:        import java.awt.Color;
0124:        import java.awt.Font;
0125:        import java.text.DateFormat;
0126:        import java.text.NumberFormat;
0127:        import java.util.Iterator;
0128:        import java.util.List;
0129:
0130:        import org.jfree.chart.axis.CategoryAxis;
0131:        import org.jfree.chart.axis.CategoryAxis3D;
0132:        import org.jfree.chart.axis.DateAxis;
0133:        import org.jfree.chart.axis.NumberAxis;
0134:        import org.jfree.chart.axis.NumberAxis3D;
0135:        import org.jfree.chart.axis.Timeline;
0136:        import org.jfree.chart.axis.ValueAxis;
0137:        import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator;
0138:        import org.jfree.chart.labels.HighLowItemLabelGenerator;
0139:        import org.jfree.chart.labels.IntervalCategoryToolTipGenerator;
0140:        import org.jfree.chart.labels.ItemLabelAnchor;
0141:        import org.jfree.chart.labels.ItemLabelPosition;
0142:        import org.jfree.chart.labels.PieToolTipGenerator;
0143:        import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
0144:        import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
0145:        import org.jfree.chart.labels.StandardPieToolTipGenerator;
0146:        import org.jfree.chart.labels.StandardXYToolTipGenerator;
0147:        import org.jfree.chart.labels.StandardXYZToolTipGenerator;
0148:        import org.jfree.chart.labels.XYToolTipGenerator;
0149:        import org.jfree.chart.plot.CategoryPlot;
0150:        import org.jfree.chart.plot.Marker;
0151:        import org.jfree.chart.plot.MultiplePiePlot;
0152:        import org.jfree.chart.plot.PiePlot;
0153:        import org.jfree.chart.plot.PiePlot3D;
0154:        import org.jfree.chart.plot.PlotOrientation;
0155:        import org.jfree.chart.plot.PolarPlot;
0156:        import org.jfree.chart.plot.RingPlot;
0157:        import org.jfree.chart.plot.ValueMarker;
0158:        import org.jfree.chart.plot.WaferMapPlot;
0159:        import org.jfree.chart.plot.XYPlot;
0160:        import org.jfree.chart.renderer.DefaultPolarItemRenderer;
0161:        import org.jfree.chart.renderer.WaferMapRenderer;
0162:        import org.jfree.chart.renderer.category.AreaRenderer;
0163:        import org.jfree.chart.renderer.category.BarRenderer;
0164:        import org.jfree.chart.renderer.category.BarRenderer3D;
0165:        import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
0166:        import org.jfree.chart.renderer.category.CategoryItemRenderer;
0167:        import org.jfree.chart.renderer.category.GanttRenderer;
0168:        import org.jfree.chart.renderer.category.LineAndShapeRenderer;
0169:        import org.jfree.chart.renderer.category.LineRenderer3D;
0170:        import org.jfree.chart.renderer.category.StackedAreaRenderer;
0171:        import org.jfree.chart.renderer.category.StackedBarRenderer;
0172:        import org.jfree.chart.renderer.category.StackedBarRenderer3D;
0173:        import org.jfree.chart.renderer.category.WaterfallBarRenderer;
0174:        import org.jfree.chart.renderer.xy.CandlestickRenderer;
0175:        import org.jfree.chart.renderer.xy.HighLowRenderer;
0176:        import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
0177:        import org.jfree.chart.renderer.xy.WindItemRenderer;
0178:        import org.jfree.chart.renderer.xy.XYAreaRenderer;
0179:        import org.jfree.chart.renderer.xy.XYBarRenderer;
0180:        import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer;
0181:        import org.jfree.chart.renderer.xy.XYBubbleRenderer;
0182:        import org.jfree.chart.renderer.xy.XYItemRenderer;
0183:        import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
0184:        import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
0185:        import org.jfree.chart.renderer.xy.XYStepRenderer;
0186:        import org.jfree.chart.title.TextTitle;
0187:        import org.jfree.chart.urls.PieURLGenerator;
0188:        import org.jfree.chart.urls.StandardCategoryURLGenerator;
0189:        import org.jfree.chart.urls.StandardPieURLGenerator;
0190:        import org.jfree.chart.urls.StandardXYURLGenerator;
0191:        import org.jfree.chart.urls.StandardXYZURLGenerator;
0192:        import org.jfree.chart.urls.XYURLGenerator;
0193:        import org.jfree.data.category.CategoryDataset;
0194:        import org.jfree.data.category.IntervalCategoryDataset;
0195:        import org.jfree.data.general.DefaultPieDataset;
0196:        import org.jfree.data.general.PieDataset;
0197:        import org.jfree.data.general.WaferMapDataset;
0198:        import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset;
0199:        import org.jfree.data.statistics.BoxAndWhiskerXYDataset;
0200:        import org.jfree.data.xy.IntervalXYDataset;
0201:        import org.jfree.data.xy.OHLCDataset;
0202:        import org.jfree.data.xy.TableXYDataset;
0203:        import org.jfree.data.xy.WindDataset;
0204:        import org.jfree.data.xy.XYDataset;
0205:        import org.jfree.data.xy.XYZDataset;
0206:        import org.jfree.ui.Layer;
0207:        import org.jfree.ui.RectangleEdge;
0208:        import org.jfree.ui.RectangleInsets;
0209:        import org.jfree.ui.TextAnchor;
0210:        import org.jfree.util.SortOrder;
0211:        import org.jfree.util.TableOrder;
0212:
0213:        /**
0214:         * A collection of utility methods for creating some standard charts with 
0215:         * JFreeChart.
0216:         */
0217:        public abstract class ChartFactory {
0218:
0219:            /**
0220:             * Creates a pie chart with default settings.
0221:             * <P>
0222:             * The chart object returned by this method uses a {@link PiePlot} instance 
0223:             * as the plot.
0224:             *
0225:             * @param title  the chart title (<code>null</code> permitted).
0226:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0227:             * @param legend  a flag specifying whether or not a legend is required.
0228:             * @param tooltips  configure chart to generate tool tips?
0229:             * @param urls  configure chart to generate URLs?
0230:             *
0231:             * @return A pie chart.
0232:             */
0233:            public static JFreeChart createPieChart(String title,
0234:                    PieDataset dataset, boolean legend, boolean tooltips,
0235:                    boolean urls) {
0236:
0237:                PiePlot plot = new PiePlot(dataset);
0238:                plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
0239:                plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
0240:                if (tooltips) {
0241:                    plot
0242:                            .setToolTipGenerator(new StandardPieToolTipGenerator(
0243:                                    StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
0244:                }
0245:                if (urls) {
0246:                    plot.setURLGenerator(new StandardPieURLGenerator());
0247:                }
0248:                return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
0249:                        plot, legend);
0250:
0251:            }
0252:
0253:            /**
0254:             * Creates a pie chart with default settings that compares 2 datasets.  
0255:             * The colour of each section will be determined by the move from the value
0256:             * for the same key in <code>previousDataset</code>. ie if value1 > value2 
0257:             * then the section will be in green (unless <code>greenForIncrease</code> 
0258:             * is <code>false</code>, in which case it would be <code>red</code>).  
0259:             * Each section can have a shade of red or green as the difference can be 
0260:             * tailored between 0% (black) and percentDiffForMaxScale% (bright 
0261:             * red/green).
0262:             * <p>
0263:             * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a 
0264:             * difference of 5% will have a half shade of red/green, a difference of 
0265:             * 10% or more will have a maximum shade/brightness of red/green.
0266:             * <P>
0267:             * The chart object returned by this method uses a {@link PiePlot} instance
0268:             * as the plot.
0269:             * <p>
0270:             * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit 
0271:             * Xhenseval</a>.
0272:             *
0273:             * @param title  the chart title (<code>null</code> permitted).
0274:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0275:             * @param previousDataset  the dataset for the last run, this will be used 
0276:             *                         to compare each key in the dataset
0277:             * @param percentDiffForMaxScale scale goes from bright red/green to black,
0278:             *                               percentDiffForMaxScale indicate the change 
0279:             *                               required to reach top scale.
0280:             * @param greenForIncrease  an increase since previousDataset will be 
0281:             *                          displayed in green (decrease red) if true.
0282:             * @param legend  a flag specifying whether or not a legend is required.
0283:             * @param tooltips  configure chart to generate tool tips?
0284:             * @param urls  configure chart to generate URLs?
0285:             * @param subTitle displays a subtitle with colour scheme if true
0286:             * @param showDifference  create a new dataset that will show the % 
0287:             *                        difference between the two datasets. 
0288:             *
0289:             * @return A pie chart.
0290:             */
0291:            public static JFreeChart createPieChart(String title,
0292:                    PieDataset dataset, PieDataset previousDataset,
0293:                    int percentDiffForMaxScale, boolean greenForIncrease,
0294:                    boolean legend, boolean tooltips, boolean urls,
0295:                    boolean subTitle, boolean showDifference) {
0296:
0297:                PiePlot plot = new PiePlot(dataset);
0298:                plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
0299:                plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
0300:
0301:                if (tooltips) {
0302:                    plot
0303:                            .setToolTipGenerator(new StandardPieToolTipGenerator(
0304:                                    StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
0305:                }
0306:                if (urls) {
0307:                    plot.setURLGenerator(new StandardPieURLGenerator());
0308:                }
0309:
0310:                List keys = dataset.getKeys();
0311:                DefaultPieDataset series = null;
0312:                if (showDifference) {
0313:                    series = new DefaultPieDataset();
0314:                }
0315:
0316:                double colorPerPercent = 255.0 / percentDiffForMaxScale;
0317:                for (Iterator it = keys.iterator(); it.hasNext();) {
0318:                    Comparable key = (Comparable) it.next();
0319:                    Number newValue = dataset.getValue(key);
0320:                    Number oldValue = previousDataset.getValue(key);
0321:
0322:                    if (oldValue == null) {
0323:                        if (greenForIncrease) {
0324:                            plot.setSectionPaint(key, Color.green);
0325:                        } else {
0326:                            plot.setSectionPaint(key, Color.red);
0327:                        }
0328:                        if (showDifference) {
0329:                            series.setValue(key + " (+100%)", newValue);
0330:                        }
0331:                    } else {
0332:                        double percentChange = (newValue.doubleValue()
0333:                                / oldValue.doubleValue() - 1.0) * 100.0;
0334:                        double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
0335:                                : Math.abs(percentChange) * colorPerPercent);
0336:                        if (greenForIncrease
0337:                                && newValue.doubleValue() > oldValue
0338:                                        .doubleValue()
0339:                                || !greenForIncrease
0340:                                && newValue.doubleValue() < oldValue
0341:                                        .doubleValue()) {
0342:                            plot.setSectionPaint(key, new Color(0, (int) shade,
0343:                                    0));
0344:                        } else {
0345:                            plot.setSectionPaint(key, new Color((int) shade, 0,
0346:                                    0));
0347:                        }
0348:                        if (showDifference) {
0349:                            series.setValue(key
0350:                                    + " ("
0351:                                    + (percentChange >= 0 ? "+" : "")
0352:                                    + NumberFormat.getPercentInstance().format(
0353:                                            percentChange / 100.0) + ")",
0354:                                    newValue);
0355:                        }
0356:                    }
0357:                }
0358:
0359:                if (showDifference) {
0360:                    plot.setDataset(series);
0361:                }
0362:
0363:                JFreeChart chart = new JFreeChart(title,
0364:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0365:
0366:                if (subTitle) {
0367:                    TextTitle subtitle = null;
0368:                    subtitle = new TextTitle("Bright "
0369:                            + (greenForIncrease ? "red" : "green")
0370:                            + "=change >=-" + percentDiffForMaxScale
0371:                            + "%, Bright "
0372:                            + (!greenForIncrease ? "red" : "green")
0373:                            + "=change >=+" + percentDiffForMaxScale + "%",
0374:                            new Font("SansSerif", Font.PLAIN, 10));
0375:                    chart.addSubtitle(subtitle);
0376:                }
0377:
0378:                return chart;
0379:            }
0380:
0381:            /**
0382:             * Creates a ring chart with default settings.
0383:             * <P>
0384:             * The chart object returned by this method uses a {@link RingPlot} 
0385:             * instance as the plot.
0386:             *
0387:             * @param title  the chart title (<code>null</code> permitted).
0388:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0389:             * @param legend  a flag specifying whether or not a legend is required.
0390:             * @param tooltips  configure chart to generate tool tips?
0391:             * @param urls  configure chart to generate URLs?
0392:             *
0393:             * @return A pie chart.
0394:             */
0395:            public static JFreeChart createRingChart(String title,
0396:                    PieDataset dataset, boolean legend, boolean tooltips,
0397:                    boolean urls) {
0398:
0399:                RingPlot plot = new RingPlot(dataset);
0400:                plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
0401:                plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
0402:                if (tooltips) {
0403:                    plot
0404:                            .setToolTipGenerator(new StandardPieToolTipGenerator(
0405:                                    StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
0406:                }
0407:                if (urls) {
0408:                    plot.setURLGenerator(new StandardPieURLGenerator());
0409:                }
0410:                return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
0411:                        plot, legend);
0412:
0413:            }
0414:
0415:            /**
0416:             * Creates a chart that displays multiple pie plots.  The chart object 
0417:             * returned by this method uses a {@link MultiplePiePlot} instance as the
0418:             * plot.
0419:             *
0420:             * @param title  the chart title (<code>null</code> permitted).
0421:             * @param dataset  the dataset (<code>null</code> permitted).
0422:             * @param order  the order that the data is extracted (by row or by column)
0423:             *               (<code>null</code> not permitted).
0424:             * @param legend  include a legend?
0425:             * @param tooltips  generate tooltips?
0426:             * @param urls  generate URLs?
0427:             *
0428:             * @return A chart.
0429:             */
0430:            public static JFreeChart createMultiplePieChart(String title,
0431:                    CategoryDataset dataset, TableOrder order, boolean legend,
0432:                    boolean tooltips, boolean urls) {
0433:
0434:                if (order == null) {
0435:                    throw new IllegalArgumentException("Null 'order' argument.");
0436:                }
0437:                MultiplePiePlot plot = new MultiplePiePlot(dataset);
0438:                plot.setDataExtractOrder(order);
0439:                plot.setBackgroundPaint(null);
0440:                plot.setOutlineStroke(null);
0441:
0442:                if (tooltips) {
0443:                    PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator();
0444:                    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
0445:                    pp.setToolTipGenerator(tooltipGenerator);
0446:                }
0447:
0448:                if (urls) {
0449:                    PieURLGenerator urlGenerator = new StandardPieURLGenerator();
0450:                    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
0451:                    pp.setURLGenerator(urlGenerator);
0452:                }
0453:
0454:                JFreeChart chart = new JFreeChart(title,
0455:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0456:
0457:                return chart;
0458:
0459:            }
0460:
0461:            /**
0462:             * Creates a 3D pie chart using the specified dataset.  The chart object 
0463:             * returned by this method uses a {@link PiePlot3D} instance as the
0464:             * plot.
0465:             *
0466:             * @param title  the chart title (<code>null</code> permitted).
0467:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0468:             * @param legend  a flag specifying whether or not a legend is required.
0469:             * @param tooltips  configure chart to generate tool tips?
0470:             * @param urls  configure chart to generate URLs?
0471:             *
0472:             * @return A pie chart.
0473:             */
0474:            public static JFreeChart createPieChart3D(String title,
0475:                    PieDataset dataset, boolean legend, boolean tooltips,
0476:                    boolean urls) {
0477:
0478:                PiePlot3D plot = new PiePlot3D(dataset);
0479:                plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
0480:                if (tooltips) {
0481:                    plot.setToolTipGenerator(new StandardPieToolTipGenerator());
0482:                }
0483:                if (urls) {
0484:                    plot.setURLGenerator(new StandardPieURLGenerator());
0485:                }
0486:                return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
0487:                        plot, legend);
0488:
0489:            }
0490:
0491:            /**
0492:             * Creates a chart that displays multiple pie plots.  The chart object 
0493:             * returned by this method uses a {@link MultiplePiePlot} instance as the
0494:             * plot.
0495:             *
0496:             * @param title  the chart title (<code>null</code> permitted).
0497:             * @param dataset  the dataset (<code>null</code> permitted).
0498:             * @param order  the order that the data is extracted (by row or by column) 
0499:             *               (<code>null</code> not permitted).
0500:             * @param legend  include a legend?
0501:             * @param tooltips  generate tooltips?
0502:             * @param urls  generate URLs?
0503:             *
0504:             * @return A chart.
0505:             */
0506:            public static JFreeChart createMultiplePieChart3D(String title,
0507:                    CategoryDataset dataset, TableOrder order, boolean legend,
0508:                    boolean tooltips, boolean urls) {
0509:
0510:                if (order == null) {
0511:                    throw new IllegalArgumentException("Null 'order' argument.");
0512:                }
0513:                MultiplePiePlot plot = new MultiplePiePlot(dataset);
0514:                plot.setDataExtractOrder(order);
0515:                plot.setBackgroundPaint(null);
0516:                plot.setOutlineStroke(null);
0517:
0518:                JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
0519:                TextTitle seriesTitle = new TextTitle("Series Title", new Font(
0520:                        "SansSerif", Font.BOLD, 12));
0521:                seriesTitle.setPosition(RectangleEdge.BOTTOM);
0522:                pieChart.setTitle(seriesTitle);
0523:                pieChart.removeLegend();
0524:                pieChart.setBackgroundPaint(null);
0525:                plot.setPieChart(pieChart);
0526:
0527:                if (tooltips) {
0528:                    PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator();
0529:                    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
0530:                    pp.setToolTipGenerator(tooltipGenerator);
0531:                }
0532:
0533:                if (urls) {
0534:                    PieURLGenerator urlGenerator = new StandardPieURLGenerator();
0535:                    PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
0536:                    pp.setURLGenerator(urlGenerator);
0537:                }
0538:
0539:                JFreeChart chart = new JFreeChart(title,
0540:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0541:
0542:                return chart;
0543:
0544:            }
0545:
0546:            /**
0547:             * Creates a bar chart.  The chart object returned by this method uses a 
0548:             * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} 
0549:             * for the domain axis, a {@link NumberAxis} as the range axis, and a 
0550:             * {@link BarRenderer} as the renderer.
0551:             *
0552:             * @param title  the chart title (<code>null</code> permitted).
0553:             * @param categoryAxisLabel  the label for the category axis 
0554:             *                           (<code>null</code> permitted).
0555:             * @param valueAxisLabel  the label for the value axis 
0556:             *                        (<code>null</code> permitted).
0557:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0558:             * @param orientation  the plot orientation (horizontal or vertical) 
0559:             *                     (<code>null</code> not permitted).
0560:             * @param legend  a flag specifying whether or not a legend is required.
0561:             * @param tooltips  configure chart to generate tool tips?
0562:             * @param urls  configure chart to generate URLs?
0563:             *
0564:             * @return A bar chart.
0565:             */
0566:            public static JFreeChart createBarChart(String title,
0567:                    String categoryAxisLabel, String valueAxisLabel,
0568:                    CategoryDataset dataset, PlotOrientation orientation,
0569:                    boolean legend, boolean tooltips, boolean urls) {
0570:
0571:                if (orientation == null) {
0572:                    throw new IllegalArgumentException(
0573:                            "Null 'orientation' argument.");
0574:                }
0575:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
0576:                ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
0577:
0578:                BarRenderer renderer = new BarRenderer();
0579:                if (orientation == PlotOrientation.HORIZONTAL) {
0580:                    ItemLabelPosition position1 = new ItemLabelPosition(
0581:                            ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
0582:                    renderer.setBasePositiveItemLabelPosition(position1);
0583:                    ItemLabelPosition position2 = new ItemLabelPosition(
0584:                            ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
0585:                    renderer.setBaseNegativeItemLabelPosition(position2);
0586:                } else if (orientation == PlotOrientation.VERTICAL) {
0587:                    ItemLabelPosition position1 = new ItemLabelPosition(
0588:                            ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
0589:                    renderer.setBasePositiveItemLabelPosition(position1);
0590:                    ItemLabelPosition position2 = new ItemLabelPosition(
0591:                            ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
0592:                    renderer.setBaseNegativeItemLabelPosition(position2);
0593:                }
0594:                if (tooltips) {
0595:                    renderer
0596:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0597:                }
0598:                if (urls) {
0599:                    renderer
0600:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0601:                }
0602:
0603:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0604:                        valueAxis, renderer);
0605:                plot.setOrientation(orientation);
0606:                JFreeChart chart = new JFreeChart(title,
0607:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0608:
0609:                return chart;
0610:
0611:            }
0612:
0613:            /**
0614:             * Creates a stacked bar chart with default settings.  The chart object 
0615:             * returned by this method uses a {@link CategoryPlot} instance as the
0616:             * plot, with a {@link CategoryAxis} for the domain axis, a 
0617:             * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer} 
0618:             * as the renderer.
0619:             *
0620:             * @param title  the chart title (<code>null</code> permitted).
0621:             * @param domainAxisLabel  the label for the category axis 
0622:             *                         (<code>null</code> permitted).
0623:             * @param rangeAxisLabel  the label for the value axis 
0624:             *                        (<code>null</code> permitted).
0625:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0626:             * @param orientation  the orientation of the chart (horizontal or 
0627:             *                     vertical) (<code>null</code> not permitted).
0628:             * @param legend  a flag specifying whether or not a legend is required.
0629:             * @param tooltips  configure chart to generate tool tips?
0630:             * @param urls  configure chart to generate URLs?
0631:             *
0632:             * @return A stacked bar chart.
0633:             */
0634:            public static JFreeChart createStackedBarChart(String title,
0635:                    String domainAxisLabel, String rangeAxisLabel,
0636:                    CategoryDataset dataset, PlotOrientation orientation,
0637:                    boolean legend, boolean tooltips, boolean urls) {
0638:
0639:                if (orientation == null) {
0640:                    throw new IllegalArgumentException(
0641:                            "Null 'orientation' argument.");
0642:                }
0643:
0644:                CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
0645:                ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);
0646:
0647:                StackedBarRenderer renderer = new StackedBarRenderer();
0648:                if (tooltips) {
0649:                    renderer
0650:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0651:                }
0652:                if (urls) {
0653:                    renderer
0654:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0655:                }
0656:
0657:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0658:                        valueAxis, renderer);
0659:                plot.setOrientation(orientation);
0660:                JFreeChart chart = new JFreeChart(title,
0661:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0662:
0663:                return chart;
0664:
0665:            }
0666:
0667:            /**
0668:             * Creates a bar chart with a 3D effect. The chart object returned by this 
0669:             * method uses a {@link CategoryPlot} instance as the plot, with a 
0670:             * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as 
0671:             * the range axis, and a {@link BarRenderer3D} as the renderer.
0672:             *
0673:             * @param title  the chart title (<code>null</code> permitted).
0674:             * @param categoryAxisLabel  the label for the category axis 
0675:             *                           (<code>null</code> permitted).
0676:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
0677:             *                        permitted).
0678:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0679:             * @param orientation  the plot orientation (horizontal or vertical) 
0680:             *                     (<code>null</code> not permitted).
0681:             * @param legend  a flag specifying whether or not a legend is required.
0682:             * @param tooltips  configure chart to generate tool tips?
0683:             * @param urls  configure chart to generate URLs?
0684:             *
0685:             * @return A bar chart with a 3D effect.
0686:             */
0687:            public static JFreeChart createBarChart3D(String title,
0688:                    String categoryAxisLabel, String valueAxisLabel,
0689:                    CategoryDataset dataset, PlotOrientation orientation,
0690:                    boolean legend, boolean tooltips, boolean urls) {
0691:
0692:                if (orientation == null) {
0693:                    throw new IllegalArgumentException(
0694:                            "Null 'orientation' argument.");
0695:                }
0696:                CategoryAxis categoryAxis = new CategoryAxis3D(
0697:                        categoryAxisLabel);
0698:                ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
0699:
0700:                BarRenderer3D renderer = new BarRenderer3D();
0701:                if (tooltips) {
0702:                    renderer
0703:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0704:                }
0705:                if (urls) {
0706:                    renderer
0707:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0708:                }
0709:
0710:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0711:                        valueAxis, renderer);
0712:                plot.setOrientation(orientation);
0713:                if (orientation == PlotOrientation.HORIZONTAL) {
0714:                    // change rendering order to ensure that bar overlapping is the 
0715:                    // right way around
0716:                    plot.setRowRenderingOrder(SortOrder.DESCENDING);
0717:                    plot.setColumnRenderingOrder(SortOrder.DESCENDING);
0718:                }
0719:                plot.setForegroundAlpha(0.75f);
0720:
0721:                JFreeChart chart = new JFreeChart(title,
0722:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0723:
0724:                return chart;
0725:
0726:            }
0727:
0728:            /**
0729:             * Creates a stacked bar chart with a 3D effect and default settings. The 
0730:             * chart object returned by this method uses a {@link CategoryPlot} 
0731:             * instance as the plot, with a {@link CategoryAxis3D} for the domain axis, 
0732:             * a {@link NumberAxis3D} as the range axis, and a 
0733:             * {@link StackedBarRenderer3D} as the renderer.
0734:             *
0735:             * @param title  the chart title (<code>null</code> permitted).
0736:             * @param categoryAxisLabel  the label for the category axis 
0737:             *                           (<code>null</code> permitted).
0738:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
0739:             *                        permitted).
0740:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0741:             * @param orientation  the orientation (horizontal or vertical) 
0742:             *                     (<code>null</code> not permitted).
0743:             * @param legend  a flag specifying whether or not a legend is required.
0744:             * @param tooltips  configure chart to generate tool tips?
0745:             * @param urls  configure chart to generate URLs?
0746:             *
0747:             * @return A stacked bar chart with a 3D effect.
0748:             */
0749:            public static JFreeChart createStackedBarChart3D(String title,
0750:                    String categoryAxisLabel, String valueAxisLabel,
0751:                    CategoryDataset dataset, PlotOrientation orientation,
0752:                    boolean legend, boolean tooltips, boolean urls) {
0753:
0754:                if (orientation == null) {
0755:                    throw new IllegalArgumentException(
0756:                            "Null 'orientation' argument.");
0757:                }
0758:                CategoryAxis categoryAxis = new CategoryAxis3D(
0759:                        categoryAxisLabel);
0760:                ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
0761:
0762:                // create the renderer...
0763:                CategoryItemRenderer renderer = new StackedBarRenderer3D();
0764:                if (tooltips) {
0765:                    renderer
0766:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0767:                }
0768:                if (urls) {
0769:                    renderer
0770:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0771:                }
0772:
0773:                // create the plot...
0774:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0775:                        valueAxis, renderer);
0776:                plot.setOrientation(orientation);
0777:                if (orientation == PlotOrientation.HORIZONTAL) {
0778:                    // change rendering order to ensure that bar overlapping is the 
0779:                    // right way around
0780:                    plot.setColumnRenderingOrder(SortOrder.DESCENDING);
0781:                }
0782:
0783:                // create the chart...
0784:                JFreeChart chart = new JFreeChart(title,
0785:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0786:
0787:                return chart;
0788:
0789:            }
0790:
0791:            /**
0792:             * Creates an area chart with default settings.  The chart object returned
0793:             * by this method uses a {@link CategoryPlot} instance as the plot, with a 
0794:             * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
0795:             * range axis, and an {@link AreaRenderer} as the renderer.
0796:             *
0797:             * @param title  the chart title (<code>null</code> permitted).
0798:             * @param categoryAxisLabel  the label for the category axis 
0799:             *                           (<code>null</code> permitted).
0800:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
0801:             *                        permitted).
0802:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0803:             * @param orientation  the plot orientation (<code>null</code> not 
0804:             *                     permitted).
0805:             * @param legend  a flag specifying whether or not a legend is required.
0806:             * @param tooltips  configure chart to generate tool tips?
0807:             * @param urls  configure chart to generate URLs?
0808:             *
0809:             * @return An area chart.
0810:             */
0811:            public static JFreeChart createAreaChart(String title,
0812:                    String categoryAxisLabel, String valueAxisLabel,
0813:                    CategoryDataset dataset, PlotOrientation orientation,
0814:                    boolean legend, boolean tooltips, boolean urls) {
0815:
0816:                if (orientation == null) {
0817:                    throw new IllegalArgumentException(
0818:                            "Null 'orientation' argument.");
0819:                }
0820:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
0821:                categoryAxis.setCategoryMargin(0.0);
0822:
0823:                ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
0824:
0825:                AreaRenderer renderer = new AreaRenderer();
0826:                if (tooltips) {
0827:                    renderer
0828:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0829:                }
0830:                if (urls) {
0831:                    renderer
0832:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0833:                }
0834:
0835:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0836:                        valueAxis, renderer);
0837:                plot.setOrientation(orientation);
0838:                JFreeChart chart = new JFreeChart(title,
0839:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0840:
0841:                return chart;
0842:
0843:            }
0844:
0845:            /**
0846:             * Creates a stacked area chart with default settings.  The chart object 
0847:             * returned by this method uses a {@link CategoryPlot} instance as the
0848:             * plot, with a {@link CategoryAxis} for the domain axis, a 
0849:             * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer} 
0850:             * as the renderer.
0851:             *
0852:             * @param title  the chart title (<code>null</code> permitted).
0853:             * @param categoryAxisLabel  the label for the category axis 
0854:             *                           (<code>null</code> permitted).
0855:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
0856:             *                        permitted).
0857:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0858:             * @param orientation  the plot orientation (horizontal or vertical) 
0859:             *                     (<code>null</code> not permitted).
0860:             * @param legend  a flag specifying whether or not a legend is required.
0861:             * @param tooltips  configure chart to generate tool tips?
0862:             * @param urls  configure chart to generate URLs?
0863:             *
0864:             * @return A stacked area chart.
0865:             */
0866:            public static JFreeChart createStackedAreaChart(String title,
0867:                    String categoryAxisLabel, String valueAxisLabel,
0868:                    CategoryDataset dataset, PlotOrientation orientation,
0869:                    boolean legend, boolean tooltips, boolean urls) {
0870:
0871:                if (orientation == null) {
0872:                    throw new IllegalArgumentException(
0873:                            "Null 'orientation' argument.");
0874:                }
0875:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
0876:                ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
0877:
0878:                StackedAreaRenderer renderer = new StackedAreaRenderer();
0879:                if (tooltips) {
0880:                    renderer
0881:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0882:                }
0883:                if (urls) {
0884:                    renderer
0885:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0886:                }
0887:
0888:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0889:                        valueAxis, renderer);
0890:                plot.setOrientation(orientation);
0891:                JFreeChart chart = new JFreeChart(title,
0892:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0893:
0894:                return chart;
0895:
0896:            }
0897:
0898:            /**
0899:             * Creates a line chart with default settings.  The chart object returned 
0900:             * by this method uses a {@link CategoryPlot} instance as the plot, with a 
0901:             * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the 
0902:             * range axis, and a {@link LineAndShapeRenderer} as the renderer.
0903:             *
0904:             * @param title  the chart title (<code>null</code> permitted).
0905:             * @param categoryAxisLabel  the label for the category axis 
0906:             *                           (<code>null</code> permitted).
0907:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
0908:             *                        permitted).
0909:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0910:             * @param orientation  the chart orientation (horizontal or vertical) 
0911:             *                     (<code>null</code> not permitted).
0912:             * @param legend  a flag specifying whether or not a legend is required.
0913:             * @param tooltips  configure chart to generate tool tips?
0914:             * @param urls  configure chart to generate URLs?
0915:             *
0916:             * @return A line chart.
0917:             */
0918:            public static JFreeChart createLineChart(String title,
0919:                    String categoryAxisLabel, String valueAxisLabel,
0920:                    CategoryDataset dataset, PlotOrientation orientation,
0921:                    boolean legend, boolean tooltips, boolean urls) {
0922:
0923:                if (orientation == null) {
0924:                    throw new IllegalArgumentException(
0925:                            "Null 'orientation' argument.");
0926:                }
0927:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
0928:                ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
0929:
0930:                LineAndShapeRenderer renderer = new LineAndShapeRenderer(true,
0931:                        false);
0932:                if (tooltips) {
0933:                    renderer
0934:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0935:                }
0936:                if (urls) {
0937:                    renderer
0938:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0939:                }
0940:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0941:                        valueAxis, renderer);
0942:                plot.setOrientation(orientation);
0943:                JFreeChart chart = new JFreeChart(title,
0944:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0945:
0946:                return chart;
0947:
0948:            }
0949:
0950:            /**
0951:             * Creates a line chart with default settings. The chart object returned by 
0952:             * this method uses a {@link CategoryPlot} instance as the plot, with a 
0953:             * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as 
0954:             * the range axis, and a {@link LineRenderer3D} as the renderer.
0955:             *
0956:             * @param title  the chart title (<code>null</code> permitted).
0957:             * @param categoryAxisLabel  the label for the category axis 
0958:             *                           (<code>null</code> permitted).
0959:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
0960:             *                        permitted).
0961:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
0962:             * @param orientation  the chart orientation (horizontal or vertical) 
0963:             *                     (<code>null</code> not permitted).
0964:             * @param legend  a flag specifying whether or not a legend is required.
0965:             * @param tooltips  configure chart to generate tool tips?
0966:             * @param urls  configure chart to generate URLs?
0967:             *
0968:             * @return A line chart.
0969:             */
0970:            public static JFreeChart createLineChart3D(String title,
0971:                    String categoryAxisLabel, String valueAxisLabel,
0972:                    CategoryDataset dataset, PlotOrientation orientation,
0973:                    boolean legend, boolean tooltips, boolean urls) {
0974:
0975:                if (orientation == null) {
0976:                    throw new IllegalArgumentException(
0977:                            "Null 'orientation' argument.");
0978:                }
0979:                CategoryAxis categoryAxis = new CategoryAxis3D(
0980:                        categoryAxisLabel);
0981:                ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
0982:
0983:                LineRenderer3D renderer = new LineRenderer3D();
0984:                if (tooltips) {
0985:                    renderer
0986:                            .setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
0987:                }
0988:                if (urls) {
0989:                    renderer
0990:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
0991:                }
0992:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
0993:                        valueAxis, renderer);
0994:                plot.setOrientation(orientation);
0995:                JFreeChart chart = new JFreeChart(title,
0996:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
0997:
0998:                return chart;
0999:
1000:            }
1001:
1002:            /**
1003:             * Creates a Gantt chart using the supplied attributes plus default values 
1004:             * where required.  The chart object returned by this method uses a 
1005:             * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} 
1006:             * for the domain axis, a {@link DateAxis} as the range axis, and a 
1007:             * {@link GanttRenderer} as the renderer.
1008:             *
1009:             * @param title  the chart title (<code>null</code> permitted).
1010:             * @param categoryAxisLabel  the label for the category axis 
1011:             *                           (<code>null</code> permitted).
1012:             * @param dateAxisLabel  the label for the date axis 
1013:             *                       (<code>null</code> permitted).
1014:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1015:             * @param legend  a flag specifying whether or not a legend is required.
1016:             * @param tooltips  configure chart to generate tool tips?
1017:             * @param urls  configure chart to generate URLs?
1018:             *
1019:             * @return A Gantt chart.
1020:             */
1021:            public static JFreeChart createGanttChart(String title,
1022:                    String categoryAxisLabel, String dateAxisLabel,
1023:                    IntervalCategoryDataset dataset, boolean legend,
1024:                    boolean tooltips, boolean urls) {
1025:
1026:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1027:                DateAxis dateAxis = new DateAxis(dateAxisLabel);
1028:
1029:                CategoryItemRenderer renderer = new GanttRenderer();
1030:                if (tooltips) {
1031:                    renderer
1032:                            .setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator(
1033:                                    "{3} - {4}", DateFormat.getDateInstance()));
1034:                }
1035:                if (urls) {
1036:                    renderer
1037:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
1038:                }
1039:
1040:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
1041:                        dateAxis, renderer);
1042:                plot.setOrientation(PlotOrientation.HORIZONTAL);
1043:                JFreeChart chart = new JFreeChart(title,
1044:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1045:
1046:                return chart;
1047:
1048:            }
1049:
1050:            /**
1051:             * Creates a waterfall chart.  The chart object returned by this method 
1052:             * uses a {@link CategoryPlot} instance as the plot, with a 
1053:             * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1054:             * range axis, and a {@link WaterfallBarRenderer} as the renderer.
1055:             *
1056:             * @param title  the chart title (<code>null</code> permitted).
1057:             * @param categoryAxisLabel  the label for the category axis 
1058:             *                           (<code>null</code> permitted).
1059:             * @param valueAxisLabel  the label for the value axis (<code>null</code> 
1060:             *                        permitted).
1061:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1062:             * @param orientation  the plot orientation (horizontal or vertical) 
1063:             *                     (<code>null</code> NOT permitted).
1064:             * @param legend  a flag specifying whether or not a legend is required.
1065:             * @param tooltips  configure chart to generate tool tips?
1066:             * @param urls  configure chart to generate URLs?
1067:             *
1068:             * @return A waterfall chart.
1069:             */
1070:            public static JFreeChart createWaterfallChart(String title,
1071:                    String categoryAxisLabel, String valueAxisLabel,
1072:                    CategoryDataset dataset, PlotOrientation orientation,
1073:                    boolean legend, boolean tooltips, boolean urls) {
1074:
1075:                if (orientation == null) {
1076:                    throw new IllegalArgumentException(
1077:                            "Null 'orientation' argument.");
1078:                }
1079:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1080:                categoryAxis.setCategoryMargin(0.0);
1081:
1082:                ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1083:
1084:                WaterfallBarRenderer renderer = new WaterfallBarRenderer();
1085:                if (orientation == PlotOrientation.HORIZONTAL) {
1086:                    ItemLabelPosition position = new ItemLabelPosition(
1087:                            ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1088:                            TextAnchor.CENTER, Math.PI / 2.0);
1089:                    renderer.setBasePositiveItemLabelPosition(position);
1090:                    renderer.setBaseNegativeItemLabelPosition(position);
1091:                } else if (orientation == PlotOrientation.VERTICAL) {
1092:                    ItemLabelPosition position = new ItemLabelPosition(
1093:                            ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1094:                            TextAnchor.CENTER, 0.0);
1095:                    renderer.setBasePositiveItemLabelPosition(position);
1096:                    renderer.setBaseNegativeItemLabelPosition(position);
1097:                }
1098:                if (tooltips) {
1099:                    StandardCategoryToolTipGenerator generator = new StandardCategoryToolTipGenerator();
1100:                    renderer.setBaseToolTipGenerator(generator);
1101:                }
1102:                if (urls) {
1103:                    renderer
1104:                            .setBaseItemURLGenerator(new StandardCategoryURLGenerator());
1105:                }
1106:
1107:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
1108:                        valueAxis, renderer);
1109:                plot.clearRangeMarkers();
1110:                Marker baseline = new ValueMarker(0.0);
1111:                baseline.setPaint(Color.black);
1112:                plot.addRangeMarker(baseline, Layer.FOREGROUND);
1113:                plot.setOrientation(orientation);
1114:                JFreeChart chart = new JFreeChart(title,
1115:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1116:
1117:                return chart;
1118:
1119:            }
1120:
1121:            /**
1122:             * Creates a polar plot for the specified dataset (x-values interpreted as 
1123:             * angles in degrees).  The chart object returned by this method uses a 
1124:             * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for 
1125:             * the radial axis.
1126:             *
1127:             * @param title  the chart title (<code>null</code> permitted).
1128:             * @param dataset  the dataset (<code>null</code> permitted).
1129:             * @param legend  legend required?
1130:             * @param tooltips  tooltips required?
1131:             * @param urls  URLs required?
1132:             *
1133:             * @return A chart.
1134:             */
1135:            public static JFreeChart createPolarChart(String title,
1136:                    XYDataset dataset, boolean legend, boolean tooltips,
1137:                    boolean urls) {
1138:
1139:                PolarPlot plot = new PolarPlot();
1140:                plot.setDataset(dataset);
1141:                NumberAxis rangeAxis = new NumberAxis();
1142:                rangeAxis.setAxisLineVisible(false);
1143:                rangeAxis.setTickMarksVisible(false);
1144:                rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0,
1145:                        0.0));
1146:                plot.setAxis(rangeAxis);
1147:                plot.setRenderer(new DefaultPolarItemRenderer());
1148:                JFreeChart chart = new JFreeChart(title,
1149:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1150:                return chart;
1151:
1152:            }
1153:
1154:            /**
1155:             * Creates a scatter plot with default settings.  The chart object 
1156:             * returned by this method uses an {@link XYPlot} instance as the plot, 
1157:             * with a {@link NumberAxis} for the domain axis, a  {@link NumberAxis} 
1158:             * as the range axis, and an {@link XYLineAndShapeRenderer} as the 
1159:             * renderer.
1160:             *
1161:             * @param title  the chart title (<code>null</code> permitted).
1162:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1163:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1164:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1165:             * @param orientation  the plot orientation (horizontal or vertical) 
1166:             *                     (<code>null</code> NOT permitted).
1167:             * @param legend  a flag specifying whether or not a legend is required.
1168:             * @param tooltips  configure chart to generate tool tips?
1169:             * @param urls  configure chart to generate URLs?
1170:             *
1171:             * @return A scatter plot.
1172:             */
1173:            public static JFreeChart createScatterPlot(String title,
1174:                    String xAxisLabel, String yAxisLabel, XYDataset dataset,
1175:                    PlotOrientation orientation, boolean legend,
1176:                    boolean tooltips, boolean urls) {
1177:
1178:                if (orientation == null) {
1179:                    throw new IllegalArgumentException(
1180:                            "Null 'orientation' argument.");
1181:                }
1182:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1183:                xAxis.setAutoRangeIncludesZero(false);
1184:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1185:                yAxis.setAutoRangeIncludesZero(false);
1186:
1187:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1188:
1189:                XYToolTipGenerator toolTipGenerator = null;
1190:                if (tooltips) {
1191:                    toolTipGenerator = new StandardXYToolTipGenerator();
1192:                }
1193:
1194:                XYURLGenerator urlGenerator = null;
1195:                if (urls) {
1196:                    urlGenerator = new StandardXYURLGenerator();
1197:                }
1198:                XYItemRenderer renderer = new XYLineAndShapeRenderer(false,
1199:                        true);
1200:                renderer.setBaseToolTipGenerator(toolTipGenerator);
1201:                renderer.setURLGenerator(urlGenerator);
1202:                plot.setRenderer(renderer);
1203:                plot.setOrientation(orientation);
1204:
1205:                JFreeChart chart = new JFreeChart(title,
1206:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1207:                return chart;
1208:
1209:            }
1210:
1211:            /**
1212:             * Creates and returns a default instance of an XY bar chart.
1213:             * <P>
1214:             * The chart object returned by this method uses an {@link XYPlot} instance
1215:             * as the plot, with a {@link DateAxis} for the domain axis, a 
1216:             * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the 
1217:             * renderer.
1218:             *
1219:             * @param title  the chart title (<code>null</code> permitted).
1220:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1221:             * @param dateAxis  make the domain axis display dates?
1222:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1223:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1224:             * @param orientation  the orientation (horizontal or vertical) 
1225:             *                     (<code>null</code> NOT permitted).
1226:             * @param legend  a flag specifying whether or not a legend is required.
1227:             * @param tooltips  configure chart to generate tool tips?
1228:             * @param urls  configure chart to generate URLs?
1229:             *
1230:             * @return An XY bar chart.
1231:             */
1232:            public static JFreeChart createXYBarChart(String title,
1233:                    String xAxisLabel, boolean dateAxis, String yAxisLabel,
1234:                    IntervalXYDataset dataset, PlotOrientation orientation,
1235:                    boolean legend, boolean tooltips, boolean urls) {
1236:
1237:                if (orientation == null) {
1238:                    throw new IllegalArgumentException(
1239:                            "Null 'orientation' argument.");
1240:                }
1241:                ValueAxis domainAxis = null;
1242:                if (dateAxis) {
1243:                    domainAxis = new DateAxis(xAxisLabel);
1244:                } else {
1245:                    NumberAxis axis = new NumberAxis(xAxisLabel);
1246:                    axis.setAutoRangeIncludesZero(false);
1247:                    domainAxis = axis;
1248:                }
1249:                ValueAxis valueAxis = new NumberAxis(yAxisLabel);
1250:
1251:                XYBarRenderer renderer = new XYBarRenderer();
1252:                if (tooltips) {
1253:                    XYToolTipGenerator tt;
1254:                    if (dateAxis) {
1255:                        tt = StandardXYToolTipGenerator.getTimeSeriesInstance();
1256:                    } else {
1257:                        tt = new StandardXYToolTipGenerator();
1258:                    }
1259:                    renderer.setBaseToolTipGenerator(tt);
1260:                }
1261:                if (urls) {
1262:                    renderer.setURLGenerator(new StandardXYURLGenerator());
1263:                }
1264:
1265:                XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis,
1266:                        renderer);
1267:                plot.setOrientation(orientation);
1268:
1269:                JFreeChart chart = new JFreeChart(title,
1270:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1271:
1272:                return chart;
1273:
1274:            }
1275:
1276:            /**
1277:             * Creates an area chart using an {@link XYDataset}.
1278:             * <P>
1279:             * The chart object returned by this method uses an {@link XYPlot} instance 
1280:             * as the plot, with a {@link NumberAxis} for the domain axis, a 
1281:             * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as 
1282:             * the renderer.
1283:             *
1284:             * @param title  the chart title (<code>null</code> permitted).
1285:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1286:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1287:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1288:             * @param orientation  the plot orientation (horizontal or vertical) 
1289:             *                     (<code>null</code> NOT permitted).
1290:             * @param legend  a flag specifying whether or not a legend is required.
1291:             * @param tooltips  configure chart to generate tool tips?
1292:             * @param urls  configure chart to generate URLs?
1293:             *
1294:             * @return An XY area chart.
1295:             */
1296:            public static JFreeChart createXYAreaChart(String title,
1297:                    String xAxisLabel, String yAxisLabel, XYDataset dataset,
1298:                    PlotOrientation orientation, boolean legend,
1299:                    boolean tooltips, boolean urls) {
1300:
1301:                if (orientation == null) {
1302:                    throw new IllegalArgumentException(
1303:                            "Null 'orientation' argument.");
1304:                }
1305:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1306:                xAxis.setAutoRangeIncludesZero(false);
1307:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1308:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1309:                plot.setOrientation(orientation);
1310:                plot.setForegroundAlpha(0.5f);
1311:
1312:                XYToolTipGenerator tipGenerator = null;
1313:                if (tooltips) {
1314:                    tipGenerator = new StandardXYToolTipGenerator();
1315:                }
1316:
1317:                XYURLGenerator urlGenerator = null;
1318:                if (urls) {
1319:                    urlGenerator = new StandardXYURLGenerator();
1320:                }
1321:
1322:                plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA,
1323:                        tipGenerator, urlGenerator));
1324:                JFreeChart chart = new JFreeChart(title,
1325:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1326:
1327:                return chart;
1328:
1329:            }
1330:
1331:            /**
1332:             * Creates a stacked XY area plot.  The chart object returned by this 
1333:             * method uses an {@link XYPlot} instance as the plot, with a 
1334:             * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
1335:             * range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
1336:             *
1337:             * @param title  the chart title (<code>null</code> permitted).
1338:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1339:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1340:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1341:             * @param orientation  the plot orientation (horizontal or vertical) 
1342:             *                     (<code>null</code> NOT permitted).
1343:             * @param legend  a flag specifying whether or not a legend is required.
1344:             * @param tooltips  configure chart to generate tool tips?
1345:             * @param urls  configure chart to generate URLs?
1346:             *
1347:             * @return A stacked XY area chart.
1348:             */
1349:            public static JFreeChart createStackedXYAreaChart(String title,
1350:                    String xAxisLabel, String yAxisLabel,
1351:                    TableXYDataset dataset, PlotOrientation orientation,
1352:                    boolean legend, boolean tooltips, boolean urls) {
1353:
1354:                if (orientation == null) {
1355:                    throw new IllegalArgumentException(
1356:                            "Null 'orientation' argument.");
1357:                }
1358:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1359:                xAxis.setAutoRangeIncludesZero(false);
1360:                xAxis.setLowerMargin(0.0);
1361:                xAxis.setUpperMargin(0.0);
1362:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1363:                XYToolTipGenerator toolTipGenerator = null;
1364:                if (tooltips) {
1365:                    toolTipGenerator = new StandardXYToolTipGenerator();
1366:                }
1367:
1368:                XYURLGenerator urlGenerator = null;
1369:                if (urls) {
1370:                    urlGenerator = new StandardXYURLGenerator();
1371:                }
1372:                StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(
1373:                        toolTipGenerator, urlGenerator);
1374:                renderer.setOutline(true);
1375:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1376:                plot.setOrientation(orientation);
1377:
1378:                plot.setRangeAxis(yAxis); // forces recalculation of the axis range
1379:
1380:                JFreeChart chart = new JFreeChart(title,
1381:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1382:                return chart;
1383:
1384:            }
1385:
1386:            /**
1387:             * Creates a line chart (based on an {@link XYDataset}) with default 
1388:             * settings.
1389:             *
1390:             * @param title  the chart title (<code>null</code> permitted).
1391:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1392:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1393:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1394:             * @param orientation  the plot orientation (horizontal or vertical) 
1395:             *                     (<code>null</code> NOT permitted).
1396:             * @param legend  a flag specifying whether or not a legend is required.
1397:             * @param tooltips  configure chart to generate tool tips?
1398:             * @param urls  configure chart to generate URLs?
1399:             *
1400:             * @return The chart.
1401:             */
1402:            public static JFreeChart createXYLineChart(String title,
1403:                    String xAxisLabel, String yAxisLabel, XYDataset dataset,
1404:                    PlotOrientation orientation, boolean legend,
1405:                    boolean tooltips, boolean urls) {
1406:
1407:                if (orientation == null) {
1408:                    throw new IllegalArgumentException(
1409:                            "Null 'orientation' argument.");
1410:                }
1411:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1412:                xAxis.setAutoRangeIncludesZero(false);
1413:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1414:                XYItemRenderer renderer = new XYLineAndShapeRenderer(true,
1415:                        false);
1416:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1417:                plot.setOrientation(orientation);
1418:                if (tooltips) {
1419:                    renderer
1420:                            .setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1421:                }
1422:                if (urls) {
1423:                    renderer.setURLGenerator(new StandardXYURLGenerator());
1424:                }
1425:
1426:                JFreeChart chart = new JFreeChart(title,
1427:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1428:
1429:                return chart;
1430:
1431:            }
1432:
1433:            /**
1434:             * Creates a stepped XY plot with default settings.
1435:             *
1436:             * @param title  the chart title (<code>null</code> permitted).
1437:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1438:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1439:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1440:             * @param orientation  the plot orientation (horizontal or vertical) 
1441:             *                     (<code>null</code> NOT permitted).
1442:             * @param legend  a flag specifying whether or not a legend is required.
1443:             * @param tooltips  configure chart to generate tool tips?
1444:             * @param urls  configure chart to generate URLs?
1445:             *
1446:             * @return A chart.
1447:             */
1448:            public static JFreeChart createXYStepChart(String title,
1449:                    String xAxisLabel, String yAxisLabel, XYDataset dataset,
1450:                    PlotOrientation orientation, boolean legend,
1451:                    boolean tooltips, boolean urls) {
1452:
1453:                if (orientation == null) {
1454:                    throw new IllegalArgumentException(
1455:                            "Null 'orientation' argument.");
1456:                }
1457:                DateAxis xAxis = new DateAxis(xAxisLabel);
1458:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1459:                yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
1460:
1461:                XYToolTipGenerator toolTipGenerator = null;
1462:                if (tooltips) {
1463:                    toolTipGenerator = new StandardXYToolTipGenerator();
1464:                }
1465:
1466:                XYURLGenerator urlGenerator = null;
1467:                if (urls) {
1468:                    urlGenerator = new StandardXYURLGenerator();
1469:                }
1470:                XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator,
1471:                        urlGenerator);
1472:
1473:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1474:                plot.setRenderer(renderer);
1475:                plot.setOrientation(orientation);
1476:                plot.setDomainCrosshairVisible(false);
1477:                plot.setRangeCrosshairVisible(false);
1478:                JFreeChart chart = new JFreeChart(title,
1479:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1480:                return chart;
1481:
1482:            }
1483:
1484:            /**
1485:             * Creates a filled stepped XY plot with default settings.
1486:             *
1487:             * @param title  the chart title (<code>null</code> permitted).
1488:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1489:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1490:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1491:             * @param orientation  the plot orientation (horizontal or vertical) 
1492:             *                     (<code>null</code> NOT permitted).
1493:             * @param legend  a flag specifying whether or not a legend is required.
1494:             * @param tooltips  configure chart to generate tool tips?
1495:             * @param urls  configure chart to generate URLs?
1496:             *
1497:             * @return A chart.
1498:             */
1499:            public static JFreeChart createXYStepAreaChart(String title,
1500:                    String xAxisLabel, String yAxisLabel, XYDataset dataset,
1501:                    PlotOrientation orientation, boolean legend,
1502:                    boolean tooltips, boolean urls) {
1503:
1504:                if (orientation == null) {
1505:                    throw new IllegalArgumentException(
1506:                            "Null 'orientation' argument.");
1507:                }
1508:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1509:                xAxis.setAutoRangeIncludesZero(false);
1510:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1511:
1512:                XYToolTipGenerator toolTipGenerator = null;
1513:                if (tooltips) {
1514:                    toolTipGenerator = new StandardXYToolTipGenerator();
1515:                }
1516:
1517:                XYURLGenerator urlGenerator = null;
1518:                if (urls) {
1519:                    urlGenerator = new StandardXYURLGenerator();
1520:                }
1521:                XYItemRenderer renderer = new XYStepAreaRenderer(
1522:                        XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator,
1523:                        urlGenerator);
1524:
1525:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1526:                plot.setRenderer(renderer);
1527:                plot.setOrientation(orientation);
1528:                plot.setDomainCrosshairVisible(false);
1529:                plot.setRangeCrosshairVisible(false);
1530:                JFreeChart chart = new JFreeChart(title,
1531:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1532:                return chart;
1533:            }
1534:
1535:            /**
1536:             * Creates and returns a time series chart.  A time series chart is an 
1537:             * {@link XYPlot} with a {@link DateAxis} for the x-axis and a 
1538:             * {@link NumberAxis} for the y-axis.  The default renderer is an
1539:             * {@link XYLineAndShapeRenderer}.
1540:             * <P>
1541:             * A convenient dataset to use with this chart is a 
1542:             * {@link org.jfree.data.time.TimeSeriesCollection}.
1543:             *
1544:             * @param title  the chart title (<code>null</code> permitted).
1545:             * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1546:             *                       permitted).
1547:             * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1548:             *                        permitted).
1549:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1550:             * @param legend  a flag specifying whether or not a legend is required.
1551:             * @param tooltips  configure chart to generate tool tips?
1552:             * @param urls  configure chart to generate URLs?
1553:             *
1554:             * @return A time series chart.
1555:             */
1556:            public static JFreeChart createTimeSeriesChart(String title,
1557:                    String timeAxisLabel, String valueAxisLabel,
1558:                    XYDataset dataset, boolean legend, boolean tooltips,
1559:                    boolean urls) {
1560:
1561:                ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1562:                timeAxis.setLowerMargin(0.02); // reduce the default margins 
1563:                timeAxis.setUpperMargin(0.02);
1564:                NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1565:                valueAxis.setAutoRangeIncludesZero(false); // override default
1566:                XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1567:
1568:                XYToolTipGenerator toolTipGenerator = null;
1569:                if (tooltips) {
1570:                    toolTipGenerator = StandardXYToolTipGenerator
1571:                            .getTimeSeriesInstance();
1572:                }
1573:
1574:                XYURLGenerator urlGenerator = null;
1575:                if (urls) {
1576:                    urlGenerator = new StandardXYURLGenerator();
1577:                }
1578:
1579:                XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(
1580:                        true, false);
1581:                renderer.setBaseToolTipGenerator(toolTipGenerator);
1582:                renderer.setURLGenerator(urlGenerator);
1583:                plot.setRenderer(renderer);
1584:
1585:                JFreeChart chart = new JFreeChart(title,
1586:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1587:                return chart;
1588:
1589:            }
1590:
1591:            /**
1592:             * Creates and returns a default instance of a candlesticks chart.
1593:             *
1594:             * @param title  the chart title (<code>null</code> permitted).
1595:             * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1596:             *                       permitted).
1597:             * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1598:             *                        permitted).
1599:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1600:             * @param legend  a flag specifying whether or not a legend is required.
1601:             *
1602:             * @return A candlestick chart.
1603:             */
1604:            public static JFreeChart createCandlestickChart(String title,
1605:                    String timeAxisLabel, String valueAxisLabel,
1606:                    OHLCDataset dataset, boolean legend) {
1607:
1608:                ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1609:                NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1610:                XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1611:                plot.setRenderer(new CandlestickRenderer());
1612:                JFreeChart chart = new JFreeChart(title,
1613:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1614:                return chart;
1615:
1616:            }
1617:
1618:            /**
1619:             * Creates and returns a default instance of a high-low-open-close chart.
1620:             *
1621:             * @param title  the chart title (<code>null</code> permitted).
1622:             * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1623:             *                       permitted).
1624:             * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1625:             *                        permitted).
1626:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1627:             * @param legend  a flag specifying whether or not a legend is required.
1628:             *
1629:             * @return A high-low-open-close chart.
1630:             */
1631:            public static JFreeChart createHighLowChart(String title,
1632:                    String timeAxisLabel, String valueAxisLabel,
1633:                    OHLCDataset dataset, boolean legend) {
1634:
1635:                ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1636:                NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1637:                HighLowRenderer renderer = new HighLowRenderer();
1638:                renderer
1639:                        .setBaseToolTipGenerator(new HighLowItemLabelGenerator());
1640:                XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1641:                JFreeChart chart = new JFreeChart(title,
1642:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1643:                return chart;
1644:
1645:            }
1646:
1647:            /**
1648:             * Creates and returns a default instance of a high-low-open-close chart 
1649:             * with a special timeline. This timeline can be a 
1650:             * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday 
1651:             * through Friday timeline that will remove Saturdays and Sundays from
1652:             * the axis.
1653:             *
1654:             * @param title  the chart title (<code>null</code> permitted).
1655:             * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1656:             *                       permitted).
1657:             * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1658:             *                        permitted).
1659:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1660:             * @param timeline  the timeline.
1661:             * @param legend  a flag specifying whether or not a legend is required.
1662:             *
1663:             * @return A high-low-open-close chart.
1664:             */
1665:            public static JFreeChart createHighLowChart(String title,
1666:                    String timeAxisLabel, String valueAxisLabel,
1667:                    OHLCDataset dataset, Timeline timeline, boolean legend) {
1668:
1669:                DateAxis timeAxis = new DateAxis(timeAxisLabel);
1670:                timeAxis.setTimeline(timeline);
1671:                NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1672:                HighLowRenderer renderer = new HighLowRenderer();
1673:                renderer
1674:                        .setBaseToolTipGenerator(new HighLowItemLabelGenerator());
1675:                XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1676:                JFreeChart chart = new JFreeChart(title,
1677:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1678:                return chart;
1679:
1680:            }
1681:
1682:            /**
1683:             * Creates a bubble chart with default settings.  The chart is composed of
1684:             * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
1685:             * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
1686:             * to draw the data items.
1687:             *
1688:             * @param title  the chart title (<code>null</code> permitted).
1689:             * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1690:             * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1691:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1692:             * @param orientation  the orientation (horizontal or vertical) 
1693:             *                     (<code>null</code> NOT permitted).
1694:             * @param legend  a flag specifying whether or not a legend is required.
1695:             * @param tooltips  configure chart to generate tool tips?
1696:             * @param urls  configure chart to generate URLs?
1697:             *
1698:             * @return A bubble chart.
1699:             */
1700:            public static JFreeChart createBubbleChart(String title,
1701:                    String xAxisLabel, String yAxisLabel, XYZDataset dataset,
1702:                    PlotOrientation orientation, boolean legend,
1703:                    boolean tooltips, boolean urls) {
1704:
1705:                if (orientation == null) {
1706:                    throw new IllegalArgumentException(
1707:                            "Null 'orientation' argument.");
1708:                }
1709:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1710:                xAxis.setAutoRangeIncludesZero(false);
1711:                NumberAxis yAxis = new NumberAxis(yAxisLabel);
1712:                yAxis.setAutoRangeIncludesZero(false);
1713:
1714:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1715:
1716:                XYItemRenderer renderer = new XYBubbleRenderer(
1717:                        XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
1718:                if (tooltips) {
1719:                    renderer
1720:                            .setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
1721:                }
1722:                if (urls) {
1723:                    renderer.setURLGenerator(new StandardXYZURLGenerator());
1724:                }
1725:                plot.setRenderer(renderer);
1726:                plot.setOrientation(orientation);
1727:
1728:                JFreeChart chart = new JFreeChart(title,
1729:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1730:
1731:                return chart;
1732:
1733:            }
1734:
1735:            /**
1736:             * Creates a histogram chart.  This chart is constructed with an 
1737:             * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range 
1738:             * axes are {@link NumberAxis} instances.
1739:             *
1740:             * @param title  the chart title (<code>null</code> permitted).
1741:             * @param xAxisLabel  the x axis label (<code>null</code> permitted).
1742:             * @param yAxisLabel  the y axis label (<code>null</code> permitted).
1743:             * @param dataset  the dataset (<code>null</code> permitted).
1744:             * @param orientation  the orientation (horizontal or vertical) 
1745:             *                     (<code>null</code> NOT permitted).
1746:             * @param legend  create a legend?
1747:             * @param tooltips  display tooltips?
1748:             * @param urls  generate URLs?
1749:             *
1750:             * @return The chart.
1751:             */
1752:            public static JFreeChart createHistogram(String title,
1753:                    String xAxisLabel, String yAxisLabel,
1754:                    IntervalXYDataset dataset, PlotOrientation orientation,
1755:                    boolean legend, boolean tooltips, boolean urls) {
1756:
1757:                if (orientation == null) {
1758:                    throw new IllegalArgumentException(
1759:                            "Null 'orientation' argument.");
1760:                }
1761:                NumberAxis xAxis = new NumberAxis(xAxisLabel);
1762:                xAxis.setAutoRangeIncludesZero(false);
1763:                ValueAxis yAxis = new NumberAxis(yAxisLabel);
1764:
1765:                XYItemRenderer renderer = new XYBarRenderer();
1766:                if (tooltips) {
1767:                    renderer
1768:                            .setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1769:                }
1770:                if (urls) {
1771:                    renderer.setURLGenerator(new StandardXYURLGenerator());
1772:                }
1773:
1774:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1775:                plot.setOrientation(orientation);
1776:                JFreeChart chart = new JFreeChart(title,
1777:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1778:                return chart;
1779:
1780:            }
1781:
1782:            /**
1783:             * Creates and returns a default instance of a box and whisker chart
1784:             * based on data from a {@link BoxAndWhiskerCategoryDataset}.
1785:             *
1786:             * @param title  the chart title (<code>null</code> permitted).
1787:             * @param categoryAxisLabel  a label for the category axis 
1788:             *     (<code>null</code> permitted).
1789:             * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1790:             *     permitted).
1791:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1792:             * @param legend  a flag specifying whether or not a legend is required.
1793:             *
1794:             * @return A box and whisker chart.
1795:             * 
1796:             * @since 1.0.4
1797:             */
1798:            public static JFreeChart createBoxAndWhiskerChart(String title,
1799:                    String categoryAxisLabel, String valueAxisLabel,
1800:                    BoxAndWhiskerCategoryDataset dataset, boolean legend) {
1801:
1802:                CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1803:                NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1804:                valueAxis.setAutoRangeIncludesZero(false);
1805:
1806:                BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
1807:                renderer
1808:                        .setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
1809:
1810:                CategoryPlot plot = new CategoryPlot(dataset, categoryAxis,
1811:                        valueAxis, renderer);
1812:                return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1813:                        plot, legend);
1814:            }
1815:
1816:            /**
1817:             * Creates and returns a default instance of a box and whisker chart.
1818:             *
1819:             * @param title  the chart title (<code>null</code> permitted).
1820:             * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1821:             *                       permitted).
1822:             * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1823:             *                        permitted).
1824:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1825:             * @param legend  a flag specifying whether or not a legend is required.
1826:             *
1827:             * @return A box and whisker chart.
1828:             */
1829:            public static JFreeChart createBoxAndWhiskerChart(String title,
1830:                    String timeAxisLabel, String valueAxisLabel,
1831:                    BoxAndWhiskerXYDataset dataset, boolean legend) {
1832:
1833:                ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1834:                NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1835:                valueAxis.setAutoRangeIncludesZero(false);
1836:                XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(
1837:                        10.0);
1838:                XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1839:                return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1840:                        plot, legend);
1841:
1842:            }
1843:
1844:            /**
1845:             * Creates a wind plot with default settings.
1846:             *
1847:             * @param title  the chart title (<code>null</code> permitted).
1848:             * @param xAxisLabel  a label for the x-axis (<code>null</code> permitted).
1849:             * @param yAxisLabel  a label for the y-axis (<code>null</code> permitted).
1850:             * @param dataset  the dataset for the chart (<code>null</code> permitted).
1851:             * @param legend  a flag that controls whether or not a legend is created.
1852:             * @param tooltips  configure chart to generate tool tips?
1853:             * @param urls  configure chart to generate URLs?
1854:             *
1855:             * @return A wind plot.
1856:             *
1857:             */
1858:            public static JFreeChart createWindPlot(String title,
1859:                    String xAxisLabel, String yAxisLabel, WindDataset dataset,
1860:                    boolean legend, boolean tooltips, boolean urls) {
1861:
1862:                ValueAxis xAxis = new DateAxis(xAxisLabel);
1863:                ValueAxis yAxis = new NumberAxis(yAxisLabel);
1864:                yAxis.setRange(-12.0, 12.0);
1865:
1866:                WindItemRenderer renderer = new WindItemRenderer();
1867:                if (tooltips) {
1868:                    renderer
1869:                            .setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1870:                }
1871:                if (urls) {
1872:                    renderer.setURLGenerator(new StandardXYURLGenerator());
1873:                }
1874:                XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1875:                JFreeChart chart = new JFreeChart(title,
1876:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1877:
1878:                return chart;
1879:
1880:            }
1881:
1882:            /**
1883:             * Creates a wafer map chart.
1884:             *
1885:             * @param title  the chart title (<code>null</code> permitted).
1886:             * @param dataset  the dataset (<code>null</code> permitted).
1887:             * @param orientation  the plot orientation (horizontal or vertical) 
1888:             *                     (<code>null</code> NOT permitted.
1889:             * @param legend  display a legend?
1890:             * @param tooltips  generate tooltips?
1891:             * @param urls  generate URLs?
1892:             *
1893:             * @return A wafer map chart.
1894:             */
1895:            public static JFreeChart createWaferMapChart(String title,
1896:                    WaferMapDataset dataset, PlotOrientation orientation,
1897:                    boolean legend, boolean tooltips, boolean urls) {
1898:
1899:                if (orientation == null) {
1900:                    throw new IllegalArgumentException(
1901:                            "Null 'orientation' argument.");
1902:                }
1903:                WaferMapPlot plot = new WaferMapPlot(dataset);
1904:                WaferMapRenderer renderer = new WaferMapRenderer();
1905:                plot.setRenderer(renderer);
1906:
1907:                JFreeChart chart = new JFreeChart(title,
1908:                        JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1909:
1910:                return chart;
1911:            }
1912:
1913:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.