001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006 *
007 * Project Info:  http://www.jfree.org/jfreechart/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it 
010 * under the terms of the GNU Lesser General Public License as published by 
011 * the Free Software Foundation; either version 2.1 of the License, or 
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but 
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022 * USA.  
023 *
024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025 * in the United States and other countries.]
026 *
027 * -----------------
028 * ChartFactory.java
029 * -----------------
030 * (C) Copyright 2001-2007, by Object Refinery Limited and Contributors.
031 *
032 * Original Author:  David Gilbert (for Object Refinery Limited);
033 * Contributor(s):   Serge V. Grachov;
034 *                   Joao Guilherme Del Valle;
035 *                   Bill Kelemen;
036 *                   Jon Iles;
037 *                   Jelai Wang;
038 *                   Richard Atkinson;
039 *                   David Browning (for Australian Institute of Marine 
040 *                       Science);
041 *                   Benoit Xhenseval;
042 *
043 * Changes
044 * -------
045 * 19-Oct-2001 : Version 1, most methods transferred from JFreeChart.java (DG);
046 * 22-Oct-2001 : Added methods to create stacked bar charts (DG);
047 *               Renamed DataSource.java --> Dataset.java etc. (DG);
048 * 31-Oct-2001 : Added 3D-effect vertical bar and stacked-bar charts, 
049 *               contributed by Serge V. Grachov (DG);
050 * 07-Nov-2001 : Added a flag to control whether or not a legend is added to 
051 *               the chart (DG);
052 * 17-Nov-2001 : For pie chart, changed dataset from CategoryDataset to 
053 *               PieDataset (DG);
054 * 30-Nov-2001 : Removed try/catch handlers from chart creation, as the 
055 *               exception are now RuntimeExceptions, as suggested by Joao 
056 *               Guilherme Del Valle (DG);
057 * 06-Dec-2001 : Added createCombinableXXXXXCharts methods (BK);
058 * 12-Dec-2001 : Added createCandlestickChart() method (DG);
059 * 13-Dec-2001 : Updated methods for charts with new renderers (DG);
060 * 08-Jan-2002 : Added import for 
061 *               com.jrefinery.chart.combination.CombinedChart (DG);
062 * 31-Jan-2002 : Changed the createCombinableVerticalXYBarChart() method to use
063 *               renderer (DG);
064 * 06-Feb-2002 : Added new method createWindPlot() (DG);
065 * 23-Apr-2002 : Updates to the chart and plot constructor API (DG);
066 * 21-May-2002 : Added new method createAreaChart() (JI);
067 * 06-Jun-2002 : Added new method createGanttChart() (DG);
068 * 11-Jun-2002 : Renamed createHorizontalStackedBarChart() 
069 *               --> createStackedHorizontalBarChart() for consistency (DG);
070 * 06-Aug-2002 : Updated Javadoc comments (DG);
071 * 21-Aug-2002 : Added createPieChart(CategoryDataset) method (DG);
072 * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
073 * 09-Oct-2002 : Added methods including tooltips and URL flags (DG);
074 * 06-Nov-2002 : Moved renderers into a separate package (DG);
075 * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG);
076 * 21-Mar-2003 : Incorporated HorizontalCategoryAxis3D, see bug id 685501 (DG);
077 * 13-May-2003 : Merged some horizontal and vertical methods (DG);
078 * 24-May-2003 : Added support for timeline in createHighLowChart (BK);
079 * 07-Jul-2003 : Added createHistogram() method contributed by Jelai Wang (DG);
080 * 27-Jul-2003 : Added createStackedAreaXYChart() method (RA);
081 * 05-Aug-2003 : added new method createBoxAndWhiskerChart (DB);
082 * 08-Sep-2003 : Changed ValueAxis API (DG);
083 * 07-Oct-2003 : Added stepped area XY chart contributed by Matthias Rose (DG);
084 * 06-Nov-2003 : Added createWaterfallChart() method (DG);
085 * 20-Nov-2003 : Set rendering order for 3D bar charts to fix overlapping 
086 *               problems (DG);
087 * 25-Nov-2003 : Added createWaferMapChart() method (DG);
088 * 23-Dec-2003 : Renamed createPie3DChart() --> createPieChart3D for 
089 *               consistency (DG);
090 * 20-Jan-2004 : Added createPolarChart() method (DG);
091 * 28-Jan-2004 : Fixed bug (882890) with axis range in 
092 *               createStackedXYAreaChart() method (DG);
093 * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG);
094 * 11-Mar-2004 : Updated for pie chart changes (DG);
095 * 27-Apr-2004 : Added new createPieChart() method contributed by Benoit 
096 *               Xhenseval (see RFE 942195) (DG);
097 * 11-May-2004 : Split StandardCategoryItemLabelGenerator 
098 *               --> StandardCategoryToolTipGenerator and
099 *               StandardCategoryLabelGenerator (DG);
100 * 06-Jan-2005 : Removed deprecated methods (DG);
101 * 27-Jan-2005 : Added new constructor to LineAndShapeRenderer (DG);
102 * 28-Feb-2005 : Added docs to createBubbleChart() method (DG);
103 * 17-Mar-2005 : Added createRingPlot() method (DG);
104 * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG);
105 * 29-Nov-2005 : Removed signal chart (DG);
106 * ------------- JFREECHART 1.0.x ---------------------------------------------
107 * 26-Jan-2006 : Corrected API docs for createScatterPlot() (DG);
108 * 23-Aug-2006 : Modified createStackedXYAreaChart() to use 
109 *               StackedXYAreaRenderer2, because StackedXYAreaRenderer doesn't
110 *               handle negative values (DG);
111 * 27-Sep-2006 : Update createPieChart() method for deprecated code (DG);
112 * 29-Nov-2006 : Update createXYBarChart() to use a time based tool tip 
113 *               generator is a DateAxis is requested (DG);
114 * 17-Jan-2007 : Added createBoxAndWhiskerChart() method from patch 1603937
115 *               submitted by Darren Jung (DG);
116 * 10-Jul-2007 : Added new methods to create pie charts with locale for
117 *               section label and tool tip formatting (DG);
118 *
119 */
120
121package org.jfree.chart;
122
123import java.awt.Color;
124import java.awt.Font;
125import java.text.DateFormat;
126import java.text.NumberFormat;
127import java.util.Iterator;
128import java.util.List;
129import java.util.Locale;
130
131import org.jfree.chart.axis.CategoryAxis;
132import org.jfree.chart.axis.CategoryAxis3D;
133import org.jfree.chart.axis.DateAxis;
134import org.jfree.chart.axis.NumberAxis;
135import org.jfree.chart.axis.NumberAxis3D;
136import org.jfree.chart.axis.Timeline;
137import org.jfree.chart.axis.ValueAxis;
138import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator;
139import org.jfree.chart.labels.HighLowItemLabelGenerator;
140import org.jfree.chart.labels.IntervalCategoryToolTipGenerator;
141import org.jfree.chart.labels.ItemLabelAnchor;
142import org.jfree.chart.labels.ItemLabelPosition;
143import org.jfree.chart.labels.PieToolTipGenerator;
144import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
145import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
146import org.jfree.chart.labels.StandardPieToolTipGenerator;
147import org.jfree.chart.labels.StandardXYToolTipGenerator;
148import org.jfree.chart.labels.StandardXYZToolTipGenerator;
149import org.jfree.chart.labels.XYToolTipGenerator;
150import org.jfree.chart.plot.CategoryPlot;
151import org.jfree.chart.plot.Marker;
152import org.jfree.chart.plot.MultiplePiePlot;
153import org.jfree.chart.plot.PiePlot;
154import org.jfree.chart.plot.PiePlot3D;
155import org.jfree.chart.plot.PlotOrientation;
156import org.jfree.chart.plot.PolarPlot;
157import org.jfree.chart.plot.RingPlot;
158import org.jfree.chart.plot.ValueMarker;
159import org.jfree.chart.plot.WaferMapPlot;
160import org.jfree.chart.plot.XYPlot;
161import org.jfree.chart.renderer.DefaultPolarItemRenderer;
162import org.jfree.chart.renderer.WaferMapRenderer;
163import org.jfree.chart.renderer.category.AreaRenderer;
164import org.jfree.chart.renderer.category.BarRenderer;
165import org.jfree.chart.renderer.category.BarRenderer3D;
166import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
167import org.jfree.chart.renderer.category.CategoryItemRenderer;
168import org.jfree.chart.renderer.category.GanttRenderer;
169import org.jfree.chart.renderer.category.LineAndShapeRenderer;
170import org.jfree.chart.renderer.category.LineRenderer3D;
171import org.jfree.chart.renderer.category.StackedAreaRenderer;
172import org.jfree.chart.renderer.category.StackedBarRenderer;
173import org.jfree.chart.renderer.category.StackedBarRenderer3D;
174import org.jfree.chart.renderer.category.WaterfallBarRenderer;
175import org.jfree.chart.renderer.xy.CandlestickRenderer;
176import org.jfree.chart.renderer.xy.HighLowRenderer;
177import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
178import org.jfree.chart.renderer.xy.WindItemRenderer;
179import org.jfree.chart.renderer.xy.XYAreaRenderer;
180import org.jfree.chart.renderer.xy.XYBarRenderer;
181import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer;
182import org.jfree.chart.renderer.xy.XYBubbleRenderer;
183import org.jfree.chart.renderer.xy.XYItemRenderer;
184import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
185import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
186import org.jfree.chart.renderer.xy.XYStepRenderer;
187import org.jfree.chart.title.TextTitle;
188import org.jfree.chart.urls.PieURLGenerator;
189import org.jfree.chart.urls.StandardCategoryURLGenerator;
190import org.jfree.chart.urls.StandardPieURLGenerator;
191import org.jfree.chart.urls.StandardXYURLGenerator;
192import org.jfree.chart.urls.StandardXYZURLGenerator;
193import org.jfree.chart.urls.XYURLGenerator;
194import org.jfree.data.category.CategoryDataset;
195import org.jfree.data.category.IntervalCategoryDataset;
196import org.jfree.data.general.DefaultPieDataset;
197import org.jfree.data.general.PieDataset;
198import org.jfree.data.general.WaferMapDataset;
199import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset;
200import org.jfree.data.statistics.BoxAndWhiskerXYDataset;
201import org.jfree.data.xy.IntervalXYDataset;
202import org.jfree.data.xy.OHLCDataset;
203import org.jfree.data.xy.TableXYDataset;
204import org.jfree.data.xy.WindDataset;
205import org.jfree.data.xy.XYDataset;
206import org.jfree.data.xy.XYZDataset;
207import org.jfree.ui.Layer;
208import org.jfree.ui.RectangleEdge;
209import org.jfree.ui.RectangleInsets;
210import org.jfree.ui.TextAnchor;
211import org.jfree.util.SortOrder;
212import org.jfree.util.TableOrder;
213
214/**
215 * A collection of utility methods for creating some standard charts with 
216 * JFreeChart.
217 */
218public abstract class ChartFactory {
219
220    /**
221     * Creates a pie chart with default settings.
222     * <P>
223     * The chart object returned by this method uses a {@link PiePlot} instance 
224     * as the plot.
225     *
226     * @param title  the chart title (<code>null</code> permitted).
227     * @param dataset  the dataset for the chart (<code>null</code> permitted).
228     * @param legend  a flag specifying whether or not a legend is required.
229     * @param tooltips  configure chart to generate tool tips?
230     * @param locale  the locale (<code>null</code> not permitted).
231     *
232     * @return A pie chart.
233     * 
234     * @since 1.0.7
235     */
236    public static JFreeChart createPieChart(String title, PieDataset dataset,
237            boolean legend, boolean tooltips, Locale locale) {
238
239        PiePlot plot = new PiePlot(dataset);
240        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
241        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
242        if (tooltips) {
243            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
244        }
245        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
246                legend);
247
248    }
249
250    /**
251     * Creates a pie chart with default settings.
252     * <P>
253     * The chart object returned by this method uses a {@link PiePlot} instance 
254     * as the plot.
255     *
256     * @param title  the chart title (<code>null</code> permitted).
257     * @param dataset  the dataset for the chart (<code>null</code> permitted).
258     * @param legend  a flag specifying whether or not a legend is required.
259     * @param tooltips  configure chart to generate tool tips?
260     * @param urls  configure chart to generate URLs?
261     *
262     * @return A pie chart.
263     */
264    public static JFreeChart createPieChart(String title,
265                                            PieDataset dataset,
266                                            boolean legend,
267                                            boolean tooltips,
268                                            boolean urls) {
269
270        PiePlot plot = new PiePlot(dataset);
271        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
272        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
273        if (tooltips) {
274            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
275        }
276        if (urls) {
277            plot.setURLGenerator(new StandardPieURLGenerator());
278        }
279        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
280                legend);
281
282    }
283
284    /**
285     * Creates a pie chart with default settings that compares 2 datasets.  
286     * The colour of each section will be determined by the move from the value
287     * for the same key in <code>previousDataset</code>. ie if value1 > value2 
288     * then the section will be in green (unless <code>greenForIncrease</code> 
289     * is <code>false</code>, in which case it would be <code>red</code>).  
290     * Each section can have a shade of red or green as the difference can be 
291     * tailored between 0% (black) and percentDiffForMaxScale% (bright 
292     * red/green).
293     * <p>
294     * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a 
295     * difference of 5% will have a half shade of red/green, a difference of 
296     * 10% or more will have a maximum shade/brightness of red/green.
297     * <P>
298     * The chart object returned by this method uses a {@link PiePlot} instance
299     * as the plot.
300     * <p>
301     * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit 
302     * Xhenseval</a>.
303     *
304     * @param title  the chart title (<code>null</code> permitted).
305     * @param dataset  the dataset for the chart (<code>null</code> permitted).
306     * @param previousDataset  the dataset for the last run, this will be used 
307     *                         to compare each key in the dataset
308     * @param percentDiffForMaxScale scale goes from bright red/green to black,
309     *                               percentDiffForMaxScale indicate the change 
310     *                               required to reach top scale.
311     * @param greenForIncrease  an increase since previousDataset will be 
312     *                          displayed in green (decrease red) if true.
313     * @param legend  a flag specifying whether or not a legend is required.
314     * @param tooltips  configure chart to generate tool tips?
315     * @param locale  the locale (<code>null</code> not permitted).
316     * @param subTitle displays a subtitle with colour scheme if true
317     * @param showDifference  create a new dataset that will show the % 
318     *                        difference between the two datasets. 
319     *
320     * @return A pie chart.
321     * 
322     * @since 1.0.7
323     */
324    public static JFreeChart createPieChart(String title, PieDataset dataset,
325            PieDataset previousDataset, int percentDiffForMaxScale,
326            boolean greenForIncrease, boolean legend, boolean tooltips,
327            Locale locale, boolean subTitle, boolean showDifference) {
328
329        PiePlot plot = new PiePlot(dataset);
330        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
331        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
332
333        if (tooltips) {
334            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
335        }
336
337        List keys = dataset.getKeys();
338        DefaultPieDataset series = null;
339        if (showDifference) {
340            series = new DefaultPieDataset();
341        }
342
343        double colorPerPercent = 255.0 / percentDiffForMaxScale;
344        for (Iterator it = keys.iterator(); it.hasNext();) {
345            Comparable key = (Comparable) it.next();
346            Number newValue = dataset.getValue(key);
347            Number oldValue = previousDataset.getValue(key);
348
349            if (oldValue == null) {
350                if (greenForIncrease) {
351                    plot.setSectionPaint(key, Color.green);
352                } 
353                else {
354                    plot.setSectionPaint(key, Color.red);
355                }
356                if (showDifference) {
357                    series.setValue(key + " (+100%)", newValue);
358                }
359            }
360            else {
361                double percentChange = (newValue.doubleValue() 
362                        / oldValue.doubleValue() - 1.0) * 100.0;
363                double shade
364                    = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
365                    : Math.abs(percentChange) * colorPerPercent);
366                if (greenForIncrease 
367                        && newValue.doubleValue() > oldValue.doubleValue()
368                        || !greenForIncrease && newValue.doubleValue() 
369                        < oldValue.doubleValue()) {
370                    plot.setSectionPaint(key, new Color(0, (int) shade, 0));
371                }
372                else {
373                    plot.setSectionPaint(key, new Color((int) shade, 0, 0));
374                }
375                if (showDifference) {
376                    series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")
377                            + NumberFormat.getPercentInstance().format(
378                            percentChange / 100.0) + ")", newValue);
379                }
380            }
381        }
382
383        if (showDifference) {
384            plot.setDataset(series);
385        }
386
387        JFreeChart chart =  new JFreeChart(title, 
388                JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
389
390        if (subTitle) {
391            TextTitle subtitle = null;
392            subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" 
393                    : "green") + "=change >=-" + percentDiffForMaxScale 
394                    + "%, Bright " + (!greenForIncrease ? "red" : "green") 
395                    + "=change >=+" + percentDiffForMaxScale + "%", 
396                    new Font("SansSerif", Font.PLAIN, 10));
397            chart.addSubtitle(subtitle);
398        }
399
400        return chart;
401    }
402
403    /**
404     * Creates a pie chart with default settings that compares 2 datasets.  
405     * The colour of each section will be determined by the move from the value
406     * for the same key in <code>previousDataset</code>. ie if value1 > value2 
407     * then the section will be in green (unless <code>greenForIncrease</code> 
408     * is <code>false</code>, in which case it would be <code>red</code>).  
409     * Each section can have a shade of red or green as the difference can be 
410     * tailored between 0% (black) and percentDiffForMaxScale% (bright 
411     * red/green).
412     * <p>
413     * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a 
414     * difference of 5% will have a half shade of red/green, a difference of 
415     * 10% or more will have a maximum shade/brightness of red/green.
416     * <P>
417     * The chart object returned by this method uses a {@link PiePlot} instance
418     * as the plot.
419     * <p>
420     * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit 
421     * Xhenseval</a>.
422     *
423     * @param title  the chart title (<code>null</code> permitted).
424     * @param dataset  the dataset for the chart (<code>null</code> permitted).
425     * @param previousDataset  the dataset for the last run, this will be used 
426     *                         to compare each key in the dataset
427     * @param percentDiffForMaxScale scale goes from bright red/green to black,
428     *                               percentDiffForMaxScale indicate the change 
429     *                               required to reach top scale.
430     * @param greenForIncrease  an increase since previousDataset will be 
431     *                          displayed in green (decrease red) if true.
432     * @param legend  a flag specifying whether or not a legend is required.
433     * @param tooltips  configure chart to generate tool tips?
434     * @param urls  configure chart to generate URLs?
435     * @param subTitle displays a subtitle with colour scheme if true
436     * @param showDifference  create a new dataset that will show the % 
437     *                        difference between the two datasets. 
438     *
439     * @return A pie chart.
440     */
441    public static JFreeChart createPieChart(String title,
442                                            PieDataset dataset,
443                                            PieDataset previousDataset,
444                                            int percentDiffForMaxScale,
445                                            boolean greenForIncrease,
446                                            boolean legend,
447                                            boolean tooltips,
448                                            boolean urls,
449                                            boolean subTitle,
450                                            boolean showDifference) {
451
452        PiePlot plot = new PiePlot(dataset);
453        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
454        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
455
456        if (tooltips) {
457            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
458        }
459        if (urls) {
460            plot.setURLGenerator(new StandardPieURLGenerator());
461        }
462
463        List keys = dataset.getKeys();
464        DefaultPieDataset series = null;
465        if (showDifference) {
466            series = new DefaultPieDataset();
467        }
468
469        double colorPerPercent = 255.0 / percentDiffForMaxScale;
470        for (Iterator it = keys.iterator(); it.hasNext();) {
471            Comparable key = (Comparable) it.next();
472            Number newValue = dataset.getValue(key);
473            Number oldValue = previousDataset.getValue(key);
474
475            if (oldValue == null) {
476                if (greenForIncrease) {
477                    plot.setSectionPaint(key, Color.green);
478                } 
479                else {
480                    plot.setSectionPaint(key, Color.red);
481                }
482                if (showDifference) {
483                    series.setValue(key + " (+100%)", newValue);
484                }
485            }
486            else {
487                double percentChange = (newValue.doubleValue() 
488                        / oldValue.doubleValue() - 1.0) * 100.0;
489                double shade
490                    = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
491                    : Math.abs(percentChange) * colorPerPercent);
492                if (greenForIncrease 
493                        && newValue.doubleValue() > oldValue.doubleValue()
494                        || !greenForIncrease && newValue.doubleValue() 
495                        < oldValue.doubleValue()) {
496                    plot.setSectionPaint(key, new Color(0, (int) shade, 0));
497                }
498                else {
499                    plot.setSectionPaint(key, new Color((int) shade, 0, 0));
500                }
501                if (showDifference) {
502                    series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")
503                            + NumberFormat.getPercentInstance().format(
504                            percentChange / 100.0) + ")", newValue);
505                }
506            }
507        }
508
509        if (showDifference) {
510            plot.setDataset(series);
511        }
512
513        JFreeChart chart =  new JFreeChart(title, 
514                JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
515
516        if (subTitle) {
517            TextTitle subtitle = null;
518            subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" 
519                    : "green") + "=change >=-" + percentDiffForMaxScale 
520                    + "%, Bright " + (!greenForIncrease ? "red" : "green") 
521                    + "=change >=+" + percentDiffForMaxScale + "%", 
522                    new Font("SansSerif", Font.PLAIN, 10));
523            chart.addSubtitle(subtitle);
524        }
525
526        return chart;
527    }
528
529    /**
530     * Creates a ring chart with default settings.
531     * <P>
532     * The chart object returned by this method uses a {@link RingPlot} 
533     * instance as the plot.
534     *
535     * @param title  the chart title (<code>null</code> permitted).
536     * @param dataset  the dataset for the chart (<code>null</code> permitted).
537     * @param legend  a flag specifying whether or not a legend is required.
538     * @param tooltips  configure chart to generate tool tips?
539     * @param locale  the locale (<code>null</code> not permitted).
540     *
541     * @return A ring chart.
542     * 
543     * @since 1.0.7
544     */
545    public static JFreeChart createRingChart(String title, PieDataset dataset,
546            boolean legend, boolean tooltips, Locale locale) {
547
548        RingPlot plot = new RingPlot(dataset);
549        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
550        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
551        if (tooltips) {
552            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
553        }
554        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
555                legend);
556
557    }
558
559    /**
560     * Creates a ring chart with default settings.
561     * <P>
562     * The chart object returned by this method uses a {@link RingPlot} 
563     * instance as the plot.
564     *
565     * @param title  the chart title (<code>null</code> permitted).
566     * @param dataset  the dataset for the chart (<code>null</code> permitted).
567     * @param legend  a flag specifying whether or not a legend is required.
568     * @param tooltips  configure chart to generate tool tips?
569     * @param urls  configure chart to generate URLs?
570     *
571     * @return A ring chart.
572     */
573    public static JFreeChart createRingChart(String title,
574                                             PieDataset dataset,
575                                             boolean legend,
576                                             boolean tooltips,
577                                             boolean urls) {
578
579        RingPlot plot = new RingPlot(dataset);
580        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
581        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
582        if (tooltips) {
583            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
584        }
585        if (urls) {
586            plot.setURLGenerator(new StandardPieURLGenerator());
587        }
588        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
589                legend);
590
591    }
592
593    /**
594     * Creates a chart that displays multiple pie plots.  The chart object 
595     * returned by this method uses a {@link MultiplePiePlot} instance as the
596     * plot.
597     *
598     * @param title  the chart title (<code>null</code> permitted).
599     * @param dataset  the dataset (<code>null</code> permitted).
600     * @param order  the order that the data is extracted (by row or by column)
601     *               (<code>null</code> not permitted).
602     * @param legend  include a legend?
603     * @param tooltips  generate tooltips?
604     * @param urls  generate URLs?
605     *
606     * @return A chart.
607     */
608    public static JFreeChart createMultiplePieChart(String title,
609                                                    CategoryDataset dataset,
610                                                    TableOrder order,
611                                                    boolean legend,
612                                                    boolean tooltips,
613                                                    boolean urls) {
614
615        if (order == null) {
616            throw new IllegalArgumentException("Null 'order' argument.");
617        }
618        MultiplePiePlot plot = new MultiplePiePlot(dataset);
619        plot.setDataExtractOrder(order);
620        plot.setBackgroundPaint(null);
621        plot.setOutlineStroke(null);
622
623        if (tooltips) {
624            PieToolTipGenerator tooltipGenerator 
625                = new StandardPieToolTipGenerator();
626            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
627            pp.setToolTipGenerator(tooltipGenerator);
628        }
629
630        if (urls) {
631            PieURLGenerator urlGenerator = new StandardPieURLGenerator();
632            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
633            pp.setURLGenerator(urlGenerator);
634        }
635
636        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
637                plot, legend);
638
639        return chart;
640
641    }
642
643    /**
644     * Creates a 3D pie chart using the specified dataset.  The chart object 
645     * returned by this method uses a {@link PiePlot3D} instance as the
646     * plot.
647     *
648     * @param title  the chart title (<code>null</code> permitted).
649     * @param dataset  the dataset for the chart (<code>null</code> permitted).
650     * @param legend  a flag specifying whether or not a legend is required.
651     * @param tooltips  configure chart to generate tool tips?
652     * @param locale  the locale (<code>null</code> not permitted).
653     *
654     * @return A pie chart.
655     * 
656     * @since 1.0.7
657     */
658    public static JFreeChart createPieChart3D(String title, PieDataset dataset,
659            boolean legend, boolean tooltips, Locale locale) {
660
661        PiePlot3D plot = new PiePlot3D(dataset);
662        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
663        if (tooltips) {
664            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
665        }
666        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
667                legend);
668
669    }
670
671    /**
672     * Creates a 3D pie chart using the specified dataset.  The chart object 
673     * returned by this method uses a {@link PiePlot3D} instance as the
674     * plot.
675     *
676     * @param title  the chart title (<code>null</code> permitted).
677     * @param dataset  the dataset for the chart (<code>null</code> permitted).
678     * @param legend  a flag specifying whether or not a legend is required.
679     * @param tooltips  configure chart to generate tool tips?
680     * @param urls  configure chart to generate URLs?
681     *
682     * @return A pie chart.
683     */
684    public static JFreeChart createPieChart3D(String title,
685                                              PieDataset dataset,
686                                              boolean legend,
687                                              boolean tooltips,
688                                              boolean urls) {
689
690        PiePlot3D plot = new PiePlot3D(dataset);
691        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
692        if (tooltips) {
693            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
694        }
695        if (urls) {
696            plot.setURLGenerator(new StandardPieURLGenerator());
697        }
698        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
699                legend);
700
701    }
702
703    /**
704     * Creates a chart that displays multiple pie plots.  The chart object 
705     * returned by this method uses a {@link MultiplePiePlot} instance as the
706     * plot.
707     *
708     * @param title  the chart title (<code>null</code> permitted).
709     * @param dataset  the dataset (<code>null</code> permitted).
710     * @param order  the order that the data is extracted (by row or by column) 
711     *               (<code>null</code> not permitted).
712     * @param legend  include a legend?
713     * @param tooltips  generate tooltips?
714     * @param urls  generate URLs?
715     *
716     * @return A chart.
717     */
718    public static JFreeChart createMultiplePieChart3D(String title,
719                                                      CategoryDataset dataset,
720                                                      TableOrder order,
721                                                      boolean legend,
722                                                      boolean tooltips,
723                                                      boolean urls) {
724
725        if (order == null) {
726            throw new IllegalArgumentException("Null 'order' argument.");
727        }
728        MultiplePiePlot plot = new MultiplePiePlot(dataset);
729        plot.setDataExtractOrder(order);
730        plot.setBackgroundPaint(null);
731        plot.setOutlineStroke(null);
732
733        JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
734        TextTitle seriesTitle = new TextTitle("Series Title", 
735                new Font("SansSerif", Font.BOLD, 12));
736        seriesTitle.setPosition(RectangleEdge.BOTTOM);
737        pieChart.setTitle(seriesTitle);
738        pieChart.removeLegend();
739        pieChart.setBackgroundPaint(null);
740        plot.setPieChart(pieChart);
741
742        if (tooltips) {
743            PieToolTipGenerator tooltipGenerator 
744                = new StandardPieToolTipGenerator();
745            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
746            pp.setToolTipGenerator(tooltipGenerator);
747        }
748
749        if (urls) {
750            PieURLGenerator urlGenerator = new StandardPieURLGenerator();
751            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
752            pp.setURLGenerator(urlGenerator);
753        }
754
755        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
756                plot, legend);
757
758        return chart;
759
760    }
761
762    /**
763     * Creates a bar chart.  The chart object returned by this method uses a 
764     * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} 
765     * for the domain axis, a {@link NumberAxis} as the range axis, and a 
766     * {@link BarRenderer} as the renderer.
767     *
768     * @param title  the chart title (<code>null</code> permitted).
769     * @param categoryAxisLabel  the label for the category axis 
770     *                           (<code>null</code> permitted).
771     * @param valueAxisLabel  the label for the value axis 
772     *                        (<code>null</code> permitted).
773     * @param dataset  the dataset for the chart (<code>null</code> permitted).
774     * @param orientation  the plot orientation (horizontal or vertical) 
775     *                     (<code>null</code> not permitted).
776     * @param legend  a flag specifying whether or not a legend is required.
777     * @param tooltips  configure chart to generate tool tips?
778     * @param urls  configure chart to generate URLs?
779     *
780     * @return A bar chart.
781     */
782    public static JFreeChart createBarChart(String title,
783                                            String categoryAxisLabel,
784                                            String valueAxisLabel,
785                                            CategoryDataset dataset,
786                                            PlotOrientation orientation,
787                                            boolean legend,
788                                            boolean tooltips,
789                                            boolean urls) {
790
791        if (orientation == null) {
792            throw new IllegalArgumentException("Null 'orientation' argument.");
793        }
794        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
795        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
796
797        BarRenderer renderer = new BarRenderer();
798        if (orientation == PlotOrientation.HORIZONTAL) {
799            ItemLabelPosition position1 = new ItemLabelPosition(
800                    ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
801            renderer.setBasePositiveItemLabelPosition(position1);
802            ItemLabelPosition position2 = new ItemLabelPosition(
803                    ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
804            renderer.setBaseNegativeItemLabelPosition(position2);
805         }
806        else if (orientation == PlotOrientation.VERTICAL) {
807            ItemLabelPosition position1 = new ItemLabelPosition(
808                    ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
809            renderer.setBasePositiveItemLabelPosition(position1);
810            ItemLabelPosition position2 = new ItemLabelPosition(
811                    ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
812            renderer.setBaseNegativeItemLabelPosition(position2);
813        }
814        if (tooltips) {
815            renderer.setBaseToolTipGenerator(
816                    new StandardCategoryToolTipGenerator());
817        }
818        if (urls) {
819            renderer.setBaseItemURLGenerator(
820                    new StandardCategoryURLGenerator());
821        }
822
823        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
824                renderer);
825        plot.setOrientation(orientation);
826        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
827                plot, legend);
828
829        return chart;
830
831    }
832
833    /**
834     * Creates a stacked bar chart with default settings.  The chart object 
835     * returned by this method uses a {@link CategoryPlot} instance as the
836     * plot, with a {@link CategoryAxis} for the domain axis, a 
837     * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer} 
838     * as the renderer.
839     *
840     * @param title  the chart title (<code>null</code> permitted).
841     * @param domainAxisLabel  the label for the category axis 
842     *                         (<code>null</code> permitted).
843     * @param rangeAxisLabel  the label for the value axis 
844     *                        (<code>null</code> permitted).
845     * @param dataset  the dataset for the chart (<code>null</code> permitted).
846     * @param orientation  the orientation of the chart (horizontal or 
847     *                     vertical) (<code>null</code> not permitted).
848     * @param legend  a flag specifying whether or not a legend is required.
849     * @param tooltips  configure chart to generate tool tips?
850     * @param urls  configure chart to generate URLs?
851     *
852     * @return A stacked bar chart.
853     */
854    public static JFreeChart createStackedBarChart(String title,
855                                                   String domainAxisLabel,
856                                                   String rangeAxisLabel,
857                                                   CategoryDataset dataset,
858                                                   PlotOrientation orientation,
859                                                   boolean legend,
860                                                   boolean tooltips,
861                                                   boolean urls) {
862
863        if (orientation == null) {
864            throw new IllegalArgumentException("Null 'orientation' argument.");
865        }
866
867        CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
868        ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);
869
870        StackedBarRenderer renderer = new StackedBarRenderer();
871        if (tooltips) {
872            renderer.setBaseToolTipGenerator(
873                    new StandardCategoryToolTipGenerator());
874        }
875        if (urls) {
876            renderer.setBaseItemURLGenerator(
877                    new StandardCategoryURLGenerator());
878        }
879
880        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
881                renderer);
882        plot.setOrientation(orientation);
883        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
884                plot, legend);
885
886        return chart;
887
888    }
889
890    /**
891     * Creates a bar chart with a 3D effect. The chart object returned by this 
892     * method uses a {@link CategoryPlot} instance as the plot, with a 
893     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as 
894     * the range axis, and a {@link BarRenderer3D} as the renderer.
895     *
896     * @param title  the chart title (<code>null</code> permitted).
897     * @param categoryAxisLabel  the label for the category axis 
898     *                           (<code>null</code> permitted).
899     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
900     *                        permitted).
901     * @param dataset  the dataset for the chart (<code>null</code> permitted).
902     * @param orientation  the plot orientation (horizontal or vertical) 
903     *                     (<code>null</code> not permitted).
904     * @param legend  a flag specifying whether or not a legend is required.
905     * @param tooltips  configure chart to generate tool tips?
906     * @param urls  configure chart to generate URLs?
907     *
908     * @return A bar chart with a 3D effect.
909     */
910    public static JFreeChart createBarChart3D(String title,
911                                              String categoryAxisLabel,
912                                              String valueAxisLabel,
913                                              CategoryDataset dataset,
914                                              PlotOrientation orientation,
915                                              boolean legend,
916                                              boolean tooltips,
917                                              boolean urls) {
918
919        if (orientation == null) {
920            throw new IllegalArgumentException("Null 'orientation' argument.");
921        }
922        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
923        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
924
925        BarRenderer3D renderer = new BarRenderer3D();
926        if (tooltips) {
927            renderer.setBaseToolTipGenerator(
928                    new StandardCategoryToolTipGenerator());
929        }
930        if (urls) {
931            renderer.setBaseItemURLGenerator(
932                    new StandardCategoryURLGenerator());
933        }
934
935        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
936                renderer);
937        plot.setOrientation(orientation);
938        if (orientation == PlotOrientation.HORIZONTAL) {
939            // change rendering order to ensure that bar overlapping is the 
940            // right way around
941            plot.setRowRenderingOrder(SortOrder.DESCENDING);
942            plot.setColumnRenderingOrder(SortOrder.DESCENDING);
943        }
944        plot.setForegroundAlpha(0.75f);
945
946        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
947                plot, legend);
948
949        return chart;
950
951    }
952
953    /**
954     * Creates a stacked bar chart with a 3D effect and default settings. The 
955     * chart object returned by this method uses a {@link CategoryPlot} 
956     * instance as the plot, with a {@link CategoryAxis3D} for the domain axis, 
957     * a {@link NumberAxis3D} as the range axis, and a 
958     * {@link StackedBarRenderer3D} as the renderer.
959     *
960     * @param title  the chart title (<code>null</code> permitted).
961     * @param categoryAxisLabel  the label for the category axis 
962     *                           (<code>null</code> permitted).
963     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
964     *                        permitted).
965     * @param dataset  the dataset for the chart (<code>null</code> permitted).
966     * @param orientation  the orientation (horizontal or vertical) 
967     *                     (<code>null</code> not permitted).
968     * @param legend  a flag specifying whether or not a legend is required.
969     * @param tooltips  configure chart to generate tool tips?
970     * @param urls  configure chart to generate URLs?
971     *
972     * @return A stacked bar chart with a 3D effect.
973     */
974    public static JFreeChart createStackedBarChart3D(String title,
975                                                    String categoryAxisLabel,
976                                                    String valueAxisLabel,
977                                                    CategoryDataset dataset,
978                                                    PlotOrientation orientation,
979                                                    boolean legend,
980                                                    boolean tooltips,
981                                                    boolean urls) {
982
983        if (orientation == null) {
984            throw new IllegalArgumentException("Null 'orientation' argument.");
985        }
986        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
987        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
988
989        // create the renderer...
990        CategoryItemRenderer renderer = new StackedBarRenderer3D();
991        if (tooltips) {
992            renderer.setBaseToolTipGenerator(
993                    new StandardCategoryToolTipGenerator());
994        }
995        if (urls) {
996            renderer.setBaseItemURLGenerator(
997                    new StandardCategoryURLGenerator());
998        }
999
1000        // create the plot...
1001        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
1002                renderer);
1003        plot.setOrientation(orientation);
1004        if (orientation == PlotOrientation.HORIZONTAL) {
1005            // change rendering order to ensure that bar overlapping is the 
1006            // right way around
1007            plot.setColumnRenderingOrder(SortOrder.DESCENDING);
1008        }
1009
1010        // create the chart...
1011        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, 
1012                plot, legend);
1013
1014        return chart;
1015
1016    }
1017
1018    /**
1019     * Creates an area chart with default settings.  The chart object returned
1020     * by this method uses a {@link CategoryPlot} instance as the plot, with a 
1021     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1022     * range axis, and an {@link AreaRenderer} as the renderer.
1023     *
1024     * @param title  the chart title (<code>null</code> permitted).
1025     * @param categoryAxisLabel  the label for the category axis 
1026     *                           (<code>null</code> permitted).
1027     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
1028     *                        permitted).
1029     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1030     * @param orientation  the plot orientation (<code>null</code> not 
1031     *                     permitted).
1032     * @param legend  a flag specifying whether or not a legend is required.
1033     * @param tooltips  configure chart to generate tool tips?
1034     * @param urls  configure chart to generate URLs?
1035     *
1036     * @return An area chart.
1037     */
1038    public static JFreeChart createAreaChart(String title,
1039                                             String categoryAxisLabel,
1040                                             String valueAxisLabel,
1041                                             CategoryDataset dataset,
1042                                             PlotOrientation orientation,
1043                                             boolean legend,
1044                                             boolean tooltips,
1045                                             boolean urls) {
1046
1047        if (orientation == null) {
1048            throw new IllegalArgumentException("Null 'orientation' argument.");
1049        }
1050        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1051        categoryAxis.setCategoryMargin(0.0);
1052
1053        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1054
1055        AreaRenderer renderer = new AreaRenderer();
1056        if (tooltips) {
1057            renderer.setBaseToolTipGenerator(
1058                    new StandardCategoryToolTipGenerator());
1059        }
1060        if (urls) {
1061            renderer.setBaseItemURLGenerator(
1062                    new StandardCategoryURLGenerator());
1063        }
1064
1065        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
1066                renderer);
1067        plot.setOrientation(orientation);
1068        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1069                plot, legend);
1070
1071        return chart;
1072
1073    }
1074
1075    /**
1076     * Creates a stacked area chart with default settings.  The chart object 
1077     * returned by this method uses a {@link CategoryPlot} instance as the
1078     * plot, with a {@link CategoryAxis} for the domain axis, a 
1079     * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer} 
1080     * as the renderer.
1081     *
1082     * @param title  the chart title (<code>null</code> permitted).
1083     * @param categoryAxisLabel  the label for the category axis 
1084     *                           (<code>null</code> permitted).
1085     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
1086     *                        permitted).
1087     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1088     * @param orientation  the plot orientation (horizontal or vertical) 
1089     *                     (<code>null</code> not permitted).
1090     * @param legend  a flag specifying whether or not a legend is required.
1091     * @param tooltips  configure chart to generate tool tips?
1092     * @param urls  configure chart to generate URLs?
1093     *
1094     * @return A stacked area chart.
1095     */
1096    public static JFreeChart createStackedAreaChart(String title,
1097                                                    String categoryAxisLabel,
1098                                                    String valueAxisLabel,
1099                                                    CategoryDataset dataset,
1100                                                    PlotOrientation orientation,
1101                                                    boolean legend,
1102                                                    boolean tooltips,
1103                                                    boolean urls) {
1104
1105        if (orientation == null) {
1106            throw new IllegalArgumentException("Null 'orientation' argument.");
1107        }
1108        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1109        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1110
1111        StackedAreaRenderer renderer = new StackedAreaRenderer();
1112        if (tooltips) {
1113            renderer.setBaseToolTipGenerator(
1114                    new StandardCategoryToolTipGenerator());
1115        }
1116        if (urls) {
1117            renderer.setBaseItemURLGenerator(
1118                    new StandardCategoryURLGenerator());
1119        }
1120
1121        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
1122                renderer);
1123        plot.setOrientation(orientation);
1124        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, 
1125                plot, legend);
1126
1127        return chart;
1128
1129    }
1130
1131    /**
1132     * Creates a line chart with default settings.  The chart object returned 
1133     * by this method uses a {@link CategoryPlot} instance as the plot, with a 
1134     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the 
1135     * range axis, and a {@link LineAndShapeRenderer} as the renderer.
1136     *
1137     * @param title  the chart title (<code>null</code> permitted).
1138     * @param categoryAxisLabel  the label for the category axis 
1139     *                           (<code>null</code> permitted).
1140     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
1141     *                        permitted).
1142     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1143     * @param orientation  the chart orientation (horizontal or vertical) 
1144     *                     (<code>null</code> not permitted).
1145     * @param legend  a flag specifying whether or not a legend is required.
1146     * @param tooltips  configure chart to generate tool tips?
1147     * @param urls  configure chart to generate URLs?
1148     *
1149     * @return A line chart.
1150     */
1151    public static JFreeChart createLineChart(String title,
1152                                             String categoryAxisLabel,
1153                                             String valueAxisLabel,
1154                                             CategoryDataset dataset,
1155                                             PlotOrientation orientation,
1156                                             boolean legend,
1157                                             boolean tooltips,
1158                                             boolean urls) {
1159
1160        if (orientation == null) {
1161            throw new IllegalArgumentException("Null 'orientation' argument.");
1162        }
1163        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1164        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1165
1166        LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
1167        if (tooltips) {
1168            renderer.setBaseToolTipGenerator(
1169                    new StandardCategoryToolTipGenerator());
1170        }
1171        if (urls) {
1172            renderer.setBaseItemURLGenerator(
1173                    new StandardCategoryURLGenerator());
1174        }
1175        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
1176                renderer);
1177        plot.setOrientation(orientation);
1178        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1179                plot, legend);
1180
1181        return chart;
1182
1183    }
1184
1185    /**
1186     * Creates a line chart with default settings. The chart object returned by 
1187     * this method uses a {@link CategoryPlot} instance as the plot, with a 
1188     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as 
1189     * the range axis, and a {@link LineRenderer3D} as the renderer.
1190     *
1191     * @param title  the chart title (<code>null</code> permitted).
1192     * @param categoryAxisLabel  the label for the category axis 
1193     *                           (<code>null</code> permitted).
1194     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
1195     *                        permitted).
1196     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1197     * @param orientation  the chart orientation (horizontal or vertical) 
1198     *                     (<code>null</code> not permitted).
1199     * @param legend  a flag specifying whether or not a legend is required.
1200     * @param tooltips  configure chart to generate tool tips?
1201     * @param urls  configure chart to generate URLs?
1202     *
1203     * @return A line chart.
1204     */
1205    public static JFreeChart createLineChart3D(String title,
1206                                               String categoryAxisLabel,
1207                                               String valueAxisLabel,
1208                                               CategoryDataset dataset,
1209                                               PlotOrientation orientation,
1210                                               boolean legend,
1211                                               boolean tooltips,
1212                                               boolean urls) {
1213
1214        if (orientation == null) {
1215            throw new IllegalArgumentException("Null 'orientation' argument.");
1216        }
1217        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
1218        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
1219
1220        LineRenderer3D renderer = new LineRenderer3D();
1221        if (tooltips) {
1222            renderer.setBaseToolTipGenerator(
1223                    new StandardCategoryToolTipGenerator());
1224        }
1225        if (urls) {
1226            renderer.setBaseItemURLGenerator(
1227                    new StandardCategoryURLGenerator());
1228        }
1229        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
1230                renderer);
1231        plot.setOrientation(orientation);
1232        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1233                plot, legend);
1234
1235        return chart;
1236
1237    }
1238
1239    /**
1240     * Creates a Gantt chart using the supplied attributes plus default values 
1241     * where required.  The chart object returned by this method uses a 
1242     * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} 
1243     * for the domain axis, a {@link DateAxis} as the range axis, and a 
1244     * {@link GanttRenderer} as the renderer.
1245     *
1246     * @param title  the chart title (<code>null</code> permitted).
1247     * @param categoryAxisLabel  the label for the category axis 
1248     *                           (<code>null</code> permitted).
1249     * @param dateAxisLabel  the label for the date axis 
1250     *                       (<code>null</code> permitted).
1251     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1252     * @param legend  a flag specifying whether or not a legend is required.
1253     * @param tooltips  configure chart to generate tool tips?
1254     * @param urls  configure chart to generate URLs?
1255     *
1256     * @return A Gantt chart.
1257     */
1258    public static JFreeChart createGanttChart(String title,
1259                                              String categoryAxisLabel,
1260                                              String dateAxisLabel,
1261                                              IntervalCategoryDataset dataset,
1262                                              boolean legend,
1263                                              boolean tooltips,
1264                                              boolean urls) {
1265
1266        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1267        DateAxis dateAxis = new DateAxis(dateAxisLabel);
1268
1269        CategoryItemRenderer renderer = new GanttRenderer();
1270        if (tooltips) {
1271            renderer.setBaseToolTipGenerator(
1272                    new IntervalCategoryToolTipGenerator(
1273                    "{3} - {4}", DateFormat.getDateInstance()));
1274        }
1275        if (urls) {
1276            renderer.setBaseItemURLGenerator(
1277                    new StandardCategoryURLGenerator());
1278        }
1279
1280        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, 
1281                renderer);
1282        plot.setOrientation(PlotOrientation.HORIZONTAL);
1283        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1284                plot, legend);
1285
1286        return chart;
1287
1288    }
1289
1290    /**
1291     * Creates a waterfall chart.  The chart object returned by this method 
1292     * uses a {@link CategoryPlot} instance as the plot, with a 
1293     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1294     * range axis, and a {@link WaterfallBarRenderer} as the renderer.
1295     *
1296     * @param title  the chart title (<code>null</code> permitted).
1297     * @param categoryAxisLabel  the label for the category axis 
1298     *                           (<code>null</code> permitted).
1299     * @param valueAxisLabel  the label for the value axis (<code>null</code> 
1300     *                        permitted).
1301     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1302     * @param orientation  the plot orientation (horizontal or vertical) 
1303     *                     (<code>null</code> NOT permitted).
1304     * @param legend  a flag specifying whether or not a legend is required.
1305     * @param tooltips  configure chart to generate tool tips?
1306     * @param urls  configure chart to generate URLs?
1307     *
1308     * @return A waterfall chart.
1309     */
1310    public static JFreeChart createWaterfallChart(String title,
1311                                                  String categoryAxisLabel,
1312                                                  String valueAxisLabel,
1313                                                  CategoryDataset dataset,
1314                                                  PlotOrientation orientation,
1315                                                  boolean legend,
1316                                                  boolean tooltips,
1317                                                  boolean urls) {
1318
1319        if (orientation == null) {
1320            throw new IllegalArgumentException("Null 'orientation' argument.");
1321        }
1322        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1323        categoryAxis.setCategoryMargin(0.0);
1324
1325        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1326
1327        WaterfallBarRenderer renderer = new WaterfallBarRenderer();
1328        if (orientation == PlotOrientation.HORIZONTAL) {
1329            ItemLabelPosition position = new ItemLabelPosition(
1330                    ItemLabelAnchor.CENTER, TextAnchor.CENTER, 
1331                    TextAnchor.CENTER, Math.PI / 2.0);
1332            renderer.setBasePositiveItemLabelPosition(position);
1333            renderer.setBaseNegativeItemLabelPosition(position);
1334         }
1335        else if (orientation == PlotOrientation.VERTICAL) {
1336            ItemLabelPosition position = new ItemLabelPosition(
1337                    ItemLabelAnchor.CENTER, TextAnchor.CENTER, 
1338                    TextAnchor.CENTER, 0.0);
1339            renderer.setBasePositiveItemLabelPosition(position);
1340            renderer.setBaseNegativeItemLabelPosition(position);
1341        }
1342        if (tooltips) {
1343            StandardCategoryToolTipGenerator generator 
1344                = new StandardCategoryToolTipGenerator();
1345            renderer.setBaseToolTipGenerator(generator);
1346        }
1347        if (urls) {
1348            renderer.setBaseItemURLGenerator(
1349                    new StandardCategoryURLGenerator());
1350        }
1351
1352        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
1353                renderer);
1354        plot.clearRangeMarkers();
1355        Marker baseline = new ValueMarker(0.0);
1356        baseline.setPaint(Color.black);
1357        plot.addRangeMarker(baseline, Layer.FOREGROUND);
1358        plot.setOrientation(orientation);
1359        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, 
1360                plot, legend);
1361
1362        return chart;
1363
1364    }
1365
1366    /**
1367     * Creates a polar plot for the specified dataset (x-values interpreted as 
1368     * angles in degrees).  The chart object returned by this method uses a 
1369     * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for 
1370     * the radial axis.
1371     *
1372     * @param title  the chart title (<code>null</code> permitted).
1373     * @param dataset  the dataset (<code>null</code> permitted).
1374     * @param legend  legend required?
1375     * @param tooltips  tooltips required?
1376     * @param urls  URLs required?
1377     *
1378     * @return A chart.
1379     */
1380    public static JFreeChart createPolarChart(String title,
1381                                              XYDataset dataset,
1382                                              boolean legend,
1383                                              boolean tooltips,
1384                                              boolean urls) {
1385
1386        PolarPlot plot = new PolarPlot();
1387        plot.setDataset(dataset);
1388        NumberAxis rangeAxis = new NumberAxis();
1389        rangeAxis.setAxisLineVisible(false);
1390        rangeAxis.setTickMarksVisible(false);
1391        rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
1392        plot.setAxis(rangeAxis);
1393        plot.setRenderer(new DefaultPolarItemRenderer());
1394        JFreeChart chart = new JFreeChart(
1395                title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1396        return chart;
1397
1398    }
1399
1400    /**
1401     * Creates a scatter plot with default settings.  The chart object 
1402     * returned by this method uses an {@link XYPlot} instance as the plot, 
1403     * with a {@link NumberAxis} for the domain axis, a  {@link NumberAxis} 
1404     * as the range axis, and an {@link XYLineAndShapeRenderer} as the 
1405     * renderer.
1406     *
1407     * @param title  the chart title (<code>null</code> permitted).
1408     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1409     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1410     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1411     * @param orientation  the plot orientation (horizontal or vertical) 
1412     *                     (<code>null</code> NOT permitted).
1413     * @param legend  a flag specifying whether or not a legend is required.
1414     * @param tooltips  configure chart to generate tool tips?
1415     * @param urls  configure chart to generate URLs?
1416     *
1417     * @return A scatter plot.
1418     */
1419    public static JFreeChart createScatterPlot(String title, String xAxisLabel,
1420            String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
1421            boolean legend, boolean tooltips, boolean urls) {
1422
1423        if (orientation == null) {
1424            throw new IllegalArgumentException("Null 'orientation' argument.");
1425        }
1426        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1427        xAxis.setAutoRangeIncludesZero(false);
1428        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1429        yAxis.setAutoRangeIncludesZero(false);
1430
1431        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1432
1433        XYToolTipGenerator toolTipGenerator = null;
1434        if (tooltips) {
1435            toolTipGenerator = new StandardXYToolTipGenerator();
1436        }
1437
1438        XYURLGenerator urlGenerator = null;
1439        if (urls) {
1440            urlGenerator = new StandardXYURLGenerator();
1441        }
1442        XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);
1443        renderer.setBaseToolTipGenerator(toolTipGenerator);
1444        renderer.setURLGenerator(urlGenerator);
1445        plot.setRenderer(renderer);
1446        plot.setOrientation(orientation);
1447
1448        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1449                plot, legend);
1450        return chart;
1451
1452    }
1453
1454    /**
1455     * Creates and returns a default instance of an XY bar chart.
1456     * <P>
1457     * The chart object returned by this method uses an {@link XYPlot} instance
1458     * as the plot, with a {@link DateAxis} for the domain axis, a 
1459     * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the 
1460     * renderer.
1461     *
1462     * @param title  the chart title (<code>null</code> permitted).
1463     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1464     * @param dateAxis  make the domain axis display dates?
1465     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1466     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1467     * @param orientation  the orientation (horizontal or vertical) 
1468     *                     (<code>null</code> NOT permitted).
1469     * @param legend  a flag specifying whether or not a legend is required.
1470     * @param tooltips  configure chart to generate tool tips?
1471     * @param urls  configure chart to generate URLs?
1472     *
1473     * @return An XY bar chart.
1474     */
1475    public static JFreeChart createXYBarChart(String title,
1476                                              String xAxisLabel,
1477                                              boolean dateAxis,
1478                                              String yAxisLabel,
1479                                              IntervalXYDataset dataset,
1480                                              PlotOrientation orientation,
1481                                              boolean legend,
1482                                              boolean tooltips,
1483                                              boolean urls) {
1484
1485        if (orientation == null) {
1486            throw new IllegalArgumentException("Null 'orientation' argument.");
1487        }
1488        ValueAxis domainAxis = null;
1489        if (dateAxis) {
1490            domainAxis = new DateAxis(xAxisLabel);
1491        }
1492        else {
1493            NumberAxis axis = new NumberAxis(xAxisLabel);
1494            axis.setAutoRangeIncludesZero(false);
1495            domainAxis = axis;
1496        }
1497        ValueAxis valueAxis = new NumberAxis(yAxisLabel);
1498
1499        XYBarRenderer renderer = new XYBarRenderer();
1500        if (tooltips) {
1501            XYToolTipGenerator tt;
1502            if (dateAxis) {
1503                tt = StandardXYToolTipGenerator.getTimeSeriesInstance();
1504            }
1505            else {
1506                tt = new StandardXYToolTipGenerator();
1507            }
1508            renderer.setBaseToolTipGenerator(tt);
1509        }
1510        if (urls) {
1511            renderer.setURLGenerator(new StandardXYURLGenerator());
1512        }
1513
1514        XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer);
1515        plot.setOrientation(orientation);
1516
1517        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1518                plot, legend);
1519
1520        return chart;
1521
1522    }
1523
1524    /**
1525     * Creates an area chart using an {@link XYDataset}.
1526     * <P>
1527     * The chart object returned by this method uses an {@link XYPlot} instance 
1528     * as the plot, with a {@link NumberAxis} for the domain axis, a 
1529     * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as 
1530     * the renderer.
1531     *
1532     * @param title  the chart title (<code>null</code> permitted).
1533     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1534     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1535     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1536     * @param orientation  the plot orientation (horizontal or vertical) 
1537     *                     (<code>null</code> NOT permitted).
1538     * @param legend  a flag specifying whether or not a legend is required.
1539     * @param tooltips  configure chart to generate tool tips?
1540     * @param urls  configure chart to generate URLs?
1541     *
1542     * @return An XY area chart.
1543     */
1544    public static JFreeChart createXYAreaChart(String title,
1545                                               String xAxisLabel,
1546                                               String yAxisLabel,
1547                                               XYDataset dataset,
1548                                               PlotOrientation orientation,
1549                                               boolean legend,
1550                                               boolean tooltips,
1551                                               boolean urls) {
1552
1553        if (orientation == null) {
1554            throw new IllegalArgumentException("Null 'orientation' argument.");
1555        }
1556        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1557        xAxis.setAutoRangeIncludesZero(false);
1558        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1559        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1560        plot.setOrientation(orientation);
1561        plot.setForegroundAlpha(0.5f);
1562
1563        XYToolTipGenerator tipGenerator = null;
1564        if (tooltips) {
1565            tipGenerator = new StandardXYToolTipGenerator();
1566        }
1567
1568        XYURLGenerator urlGenerator = null;
1569        if (urls) {
1570            urlGenerator = new StandardXYURLGenerator();
1571        }
1572
1573        plot.setRenderer(
1574            new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator)
1575        );
1576        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1577                plot, legend);
1578
1579        return chart;
1580
1581    }
1582
1583    /**
1584     * Creates a stacked XY area plot.  The chart object returned by this 
1585     * method uses an {@link XYPlot} instance as the plot, with a 
1586     * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
1587     * range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
1588     *
1589     * @param title  the chart title (<code>null</code> permitted).
1590     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1591     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1592     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1593     * @param orientation  the plot orientation (horizontal or vertical) 
1594     *                     (<code>null</code> NOT permitted).
1595     * @param legend  a flag specifying whether or not a legend is required.
1596     * @param tooltips  configure chart to generate tool tips?
1597     * @param urls  configure chart to generate URLs?
1598     *
1599     * @return A stacked XY area chart.
1600     */
1601    public static JFreeChart createStackedXYAreaChart(String title,
1602                                                    String xAxisLabel,
1603                                                    String yAxisLabel,
1604                                                    TableXYDataset dataset,
1605                                                    PlotOrientation orientation,
1606                                                    boolean legend,
1607                                                    boolean tooltips,
1608                                                    boolean urls) {
1609
1610        if (orientation == null) {
1611            throw new IllegalArgumentException("Null 'orientation' argument.");
1612        }
1613        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1614        xAxis.setAutoRangeIncludesZero(false);
1615        xAxis.setLowerMargin(0.0);
1616        xAxis.setUpperMargin(0.0);
1617        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1618        XYToolTipGenerator toolTipGenerator = null;
1619        if (tooltips) {
1620            toolTipGenerator = new StandardXYToolTipGenerator();
1621        }
1622
1623        XYURLGenerator urlGenerator = null;
1624        if (urls) {
1625            urlGenerator = new StandardXYURLGenerator();
1626        }
1627        StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(
1628                toolTipGenerator, urlGenerator);
1629        renderer.setOutline(true);
1630        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1631        plot.setOrientation(orientation);
1632
1633        plot.setRangeAxis(yAxis);  // forces recalculation of the axis range
1634
1635        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1636                plot, legend);
1637        return chart;
1638
1639    }
1640
1641    /**
1642     * Creates a line chart (based on an {@link XYDataset}) with default 
1643     * settings.
1644     *
1645     * @param title  the chart title (<code>null</code> permitted).
1646     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1647     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1648     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1649     * @param orientation  the plot orientation (horizontal or vertical) 
1650     *                     (<code>null</code> NOT permitted).
1651     * @param legend  a flag specifying whether or not a legend is required.
1652     * @param tooltips  configure chart to generate tool tips?
1653     * @param urls  configure chart to generate URLs?
1654     *
1655     * @return The chart.
1656     */
1657    public static JFreeChart createXYLineChart(String title,
1658                                               String xAxisLabel,
1659                                               String yAxisLabel,
1660                                               XYDataset dataset,
1661                                               PlotOrientation orientation,
1662                                               boolean legend,
1663                                               boolean tooltips,
1664                                               boolean urls) {
1665
1666        if (orientation == null) {
1667            throw new IllegalArgumentException("Null 'orientation' argument.");
1668        }
1669        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1670        xAxis.setAutoRangeIncludesZero(false);
1671        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1672        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
1673        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1674        plot.setOrientation(orientation);
1675        if (tooltips) {
1676            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1677        }
1678        if (urls) {
1679            renderer.setURLGenerator(new StandardXYURLGenerator());
1680        }
1681
1682        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1683                plot, legend);
1684
1685        return chart;
1686
1687    }
1688
1689    /**
1690     * Creates a stepped XY plot with default settings.
1691     *
1692     * @param title  the chart title (<code>null</code> permitted).
1693     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1694     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1695     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1696     * @param orientation  the plot orientation (horizontal or vertical) 
1697     *                     (<code>null</code> NOT permitted).
1698     * @param legend  a flag specifying whether or not a legend is required.
1699     * @param tooltips  configure chart to generate tool tips?
1700     * @param urls  configure chart to generate URLs?
1701     *
1702     * @return A chart.
1703     */
1704    public static JFreeChart createXYStepChart(String title,
1705                                               String xAxisLabel,
1706                                               String yAxisLabel,
1707                                               XYDataset dataset,
1708                                               PlotOrientation orientation,
1709                                               boolean legend,
1710                                               boolean tooltips,
1711                                               boolean urls) {
1712
1713        if (orientation == null) {
1714            throw new IllegalArgumentException("Null 'orientation' argument.");
1715        }
1716        DateAxis xAxis = new DateAxis(xAxisLabel);
1717        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1718        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
1719
1720        XYToolTipGenerator toolTipGenerator = null;
1721        if (tooltips) {
1722            toolTipGenerator = new StandardXYToolTipGenerator();
1723        }
1724
1725        XYURLGenerator urlGenerator = null;
1726        if (urls) {
1727            urlGenerator = new StandardXYURLGenerator();
1728        }
1729        XYItemRenderer renderer 
1730            = new XYStepRenderer(toolTipGenerator, urlGenerator);
1731
1732        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1733        plot.setRenderer(renderer);
1734        plot.setOrientation(orientation);
1735        plot.setDomainCrosshairVisible(false);
1736        plot.setRangeCrosshairVisible(false);
1737        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1738                plot, legend);
1739        return chart;
1740
1741    }
1742
1743    /**
1744     * Creates a filled stepped XY plot with default settings.
1745     *
1746     * @param title  the chart title (<code>null</code> permitted).
1747     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1748     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1749     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1750     * @param orientation  the plot orientation (horizontal or vertical) 
1751     *                     (<code>null</code> NOT permitted).
1752     * @param legend  a flag specifying whether or not a legend is required.
1753     * @param tooltips  configure chart to generate tool tips?
1754     * @param urls  configure chart to generate URLs?
1755     *
1756     * @return A chart.
1757     */
1758    public static JFreeChart createXYStepAreaChart(String title,
1759                                                   String xAxisLabel,
1760                                                   String yAxisLabel,
1761                                                   XYDataset dataset,
1762                                                   PlotOrientation orientation,
1763                                                   boolean legend,
1764                                                   boolean tooltips,
1765                                                   boolean urls) {
1766
1767        if (orientation == null) {
1768            throw new IllegalArgumentException("Null 'orientation' argument.");
1769        }
1770        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1771        xAxis.setAutoRangeIncludesZero(false);
1772        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1773
1774        XYToolTipGenerator toolTipGenerator = null;
1775        if (tooltips) {
1776            toolTipGenerator = new StandardXYToolTipGenerator();
1777        }
1778
1779        XYURLGenerator urlGenerator = null;
1780        if (urls) {
1781            urlGenerator = new StandardXYURLGenerator();
1782        }
1783        XYItemRenderer renderer = new XYStepAreaRenderer(
1784                XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, 
1785                urlGenerator);
1786
1787        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1788        plot.setRenderer(renderer);
1789        plot.setOrientation(orientation);
1790        plot.setDomainCrosshairVisible(false);
1791        plot.setRangeCrosshairVisible(false);
1792        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1793                plot, legend);
1794        return chart;
1795    }
1796
1797    /**
1798     * Creates and returns a time series chart.  A time series chart is an 
1799     * {@link XYPlot} with a {@link DateAxis} for the x-axis and a 
1800     * {@link NumberAxis} for the y-axis.  The default renderer is an
1801     * {@link XYLineAndShapeRenderer}.
1802     * <P>
1803     * A convenient dataset to use with this chart is a 
1804     * {@link org.jfree.data.time.TimeSeriesCollection}.
1805     *
1806     * @param title  the chart title (<code>null</code> permitted).
1807     * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1808     *                       permitted).
1809     * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1810     *                        permitted).
1811     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1812     * @param legend  a flag specifying whether or not a legend is required.
1813     * @param tooltips  configure chart to generate tool tips?
1814     * @param urls  configure chart to generate URLs?
1815     *
1816     * @return A time series chart.
1817     */
1818    public static JFreeChart createTimeSeriesChart(String title,
1819                                                   String timeAxisLabel,
1820                                                   String valueAxisLabel,
1821                                                   XYDataset dataset,
1822                                                   boolean legend,
1823                                                   boolean tooltips,
1824                                                   boolean urls) {
1825
1826        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1827        timeAxis.setLowerMargin(0.02);  // reduce the default margins 
1828        timeAxis.setUpperMargin(0.02);
1829        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1830        valueAxis.setAutoRangeIncludesZero(false);  // override default
1831        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1832
1833        XYToolTipGenerator toolTipGenerator = null;
1834        if (tooltips) {
1835            toolTipGenerator 
1836                = StandardXYToolTipGenerator.getTimeSeriesInstance();
1837        }
1838
1839        XYURLGenerator urlGenerator = null;
1840        if (urls) {
1841            urlGenerator = new StandardXYURLGenerator();
1842        }
1843
1844        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, 
1845                false);
1846        renderer.setBaseToolTipGenerator(toolTipGenerator);
1847        renderer.setURLGenerator(urlGenerator);
1848        plot.setRenderer(renderer);
1849        
1850        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1851                plot, legend);
1852        return chart;
1853
1854    }
1855
1856    /**
1857     * Creates and returns a default instance of a candlesticks chart.
1858     *
1859     * @param title  the chart title (<code>null</code> permitted).
1860     * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1861     *                       permitted).
1862     * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1863     *                        permitted).
1864     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1865     * @param legend  a flag specifying whether or not a legend is required.
1866     *
1867     * @return A candlestick chart.
1868     */
1869    public static JFreeChart createCandlestickChart(String title,
1870                                                    String timeAxisLabel,
1871                                                    String valueAxisLabel,
1872                                                    OHLCDataset dataset,
1873                                                    boolean legend) {
1874
1875        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1876        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1877        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1878        plot.setRenderer(new CandlestickRenderer());
1879        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1880                plot, legend);
1881        return chart;
1882
1883    }
1884
1885    /**
1886     * Creates and returns a default instance of a high-low-open-close chart.
1887     *
1888     * @param title  the chart title (<code>null</code> permitted).
1889     * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1890     *                       permitted).
1891     * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1892     *                        permitted).
1893     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1894     * @param legend  a flag specifying whether or not a legend is required.
1895     *
1896     * @return A high-low-open-close chart.
1897     */
1898    public static JFreeChart createHighLowChart(String title,
1899                                                String timeAxisLabel,
1900                                                String valueAxisLabel,
1901                                                OHLCDataset dataset,
1902                                                boolean legend) {
1903
1904        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1905        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1906        HighLowRenderer renderer = new HighLowRenderer();
1907        renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
1908        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1909        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1910                plot, legend);
1911        return chart;
1912
1913    }
1914
1915    /**
1916     * Creates and returns a default instance of a high-low-open-close chart 
1917     * with a special timeline. This timeline can be a 
1918     * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday 
1919     * through Friday timeline that will remove Saturdays and Sundays from
1920     * the axis.
1921     *
1922     * @param title  the chart title (<code>null</code> permitted).
1923     * @param timeAxisLabel  a label for the time axis (<code>null</code> 
1924     *                       permitted).
1925     * @param valueAxisLabel  a label for the value axis (<code>null</code> 
1926     *                        permitted).
1927     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1928     * @param timeline  the timeline.
1929     * @param legend  a flag specifying whether or not a legend is required.
1930     *
1931     * @return A high-low-open-close chart.
1932     */
1933    public static JFreeChart createHighLowChart(String title,
1934                                                String timeAxisLabel,
1935                                                String valueAxisLabel,
1936                                                OHLCDataset dataset,
1937                                                Timeline timeline,
1938                                                boolean legend) {
1939
1940        DateAxis timeAxis = new DateAxis(timeAxisLabel);
1941        timeAxis.setTimeline(timeline);
1942        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1943        HighLowRenderer renderer = new HighLowRenderer();
1944        renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
1945        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1946        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1947                plot, legend);
1948        return chart;
1949
1950    }
1951
1952    /**
1953     * Creates a bubble chart with default settings.  The chart is composed of
1954     * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
1955     * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
1956     * to draw the data items.
1957     *
1958     * @param title  the chart title (<code>null</code> permitted).
1959     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1960     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1961     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1962     * @param orientation  the orientation (horizontal or vertical) 
1963     *                     (<code>null</code> NOT permitted).
1964     * @param legend  a flag specifying whether or not a legend is required.
1965     * @param tooltips  configure chart to generate tool tips?
1966     * @param urls  configure chart to generate URLs?
1967     *
1968     * @return A bubble chart.
1969     */
1970    public static JFreeChart createBubbleChart(String title,
1971                                               String xAxisLabel,
1972                                               String yAxisLabel,
1973                                               XYZDataset dataset,
1974                                               PlotOrientation orientation,
1975                                               boolean legend,
1976                                               boolean tooltips,
1977                                               boolean urls) {
1978
1979        if (orientation == null) {
1980            throw new IllegalArgumentException("Null 'orientation' argument.");
1981        }
1982        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1983        xAxis.setAutoRangeIncludesZero(false);
1984        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1985        yAxis.setAutoRangeIncludesZero(false);
1986
1987        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1988
1989        XYItemRenderer renderer = new XYBubbleRenderer(
1990                XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
1991        if (tooltips) {
1992            renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
1993        }
1994        if (urls) {
1995            renderer.setURLGenerator(new StandardXYZURLGenerator());
1996        }
1997        plot.setRenderer(renderer);
1998        plot.setOrientation(orientation);
1999
2000        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2001                plot, legend);
2002
2003        return chart;
2004
2005    }
2006
2007    /**
2008     * Creates a histogram chart.  This chart is constructed with an 
2009     * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range 
2010     * axes are {@link NumberAxis} instances.
2011     *
2012     * @param title  the chart title (<code>null</code> permitted).
2013     * @param xAxisLabel  the x axis label (<code>null</code> permitted).
2014     * @param yAxisLabel  the y axis label (<code>null</code> permitted).
2015     * @param dataset  the dataset (<code>null</code> permitted).
2016     * @param orientation  the orientation (horizontal or vertical) 
2017     *                     (<code>null</code> NOT permitted).
2018     * @param legend  create a legend?
2019     * @param tooltips  display tooltips?
2020     * @param urls  generate URLs?
2021     *
2022     * @return The chart.
2023     */
2024    public static JFreeChart createHistogram(String title,
2025                                             String xAxisLabel,
2026                                             String yAxisLabel,
2027                                             IntervalXYDataset dataset,
2028                                             PlotOrientation orientation,
2029                                             boolean legend,
2030                                             boolean tooltips,
2031                                             boolean urls) {
2032
2033        if (orientation == null) {
2034            throw new IllegalArgumentException("Null 'orientation' argument.");
2035        }
2036        NumberAxis xAxis = new NumberAxis(xAxisLabel);
2037        xAxis.setAutoRangeIncludesZero(false);
2038        ValueAxis yAxis = new NumberAxis(yAxisLabel);
2039
2040        XYItemRenderer renderer = new XYBarRenderer();
2041        if (tooltips) {
2042            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2043        }
2044        if (urls) {
2045            renderer.setURLGenerator(new StandardXYURLGenerator());
2046        }
2047
2048        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2049        plot.setOrientation(orientation);
2050        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2051                plot, legend);
2052        return chart;
2053
2054    }
2055
2056    /**
2057     * Creates and returns a default instance of a box and whisker chart
2058     * based on data from a {@link BoxAndWhiskerCategoryDataset}.
2059     *
2060     * @param title  the chart title (<code>null</code> permitted).
2061     * @param categoryAxisLabel  a label for the category axis 
2062     *     (<code>null</code> permitted).
2063     * @param valueAxisLabel  a label for the value axis (<code>null</code> 
2064     *     permitted).
2065     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2066     * @param legend  a flag specifying whether or not a legend is required.
2067     *
2068     * @return A box and whisker chart.
2069     * 
2070     * @since 1.0.4
2071     */
2072    public static JFreeChart createBoxAndWhiskerChart(String title,
2073            String categoryAxisLabel, String valueAxisLabel,
2074            BoxAndWhiskerCategoryDataset dataset, boolean legend) {
2075        
2076        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
2077        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2078        valueAxis.setAutoRangeIncludesZero(false);
2079        
2080        BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
2081        renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
2082           
2083        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
2084                renderer);
2085        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
2086                legend);
2087    } 
2088
2089    /**
2090     * Creates and returns a default instance of a box and whisker chart.
2091     *
2092     * @param title  the chart title (<code>null</code> permitted).
2093     * @param timeAxisLabel  a label for the time axis (<code>null</code> 
2094     *                       permitted).
2095     * @param valueAxisLabel  a label for the value axis (<code>null</code> 
2096     *                        permitted).
2097     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2098     * @param legend  a flag specifying whether or not a legend is required.
2099     *
2100     * @return A box and whisker chart.
2101     */
2102    public static JFreeChart createBoxAndWhiskerChart(String title,
2103                                                 String timeAxisLabel,
2104                                                 String valueAxisLabel,
2105                                                 BoxAndWhiskerXYDataset dataset,
2106                                                 boolean legend) {
2107
2108        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
2109        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2110        valueAxis.setAutoRangeIncludesZero(false);
2111        XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
2112        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
2113        return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
2114                legend);
2115
2116    }
2117
2118    /**
2119     * Creates a wind plot with default settings.
2120     *
2121     * @param title  the chart title (<code>null</code> permitted).
2122     * @param xAxisLabel  a label for the x-axis (<code>null</code> permitted).
2123     * @param yAxisLabel  a label for the y-axis (<code>null</code> permitted).
2124     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2125     * @param legend  a flag that controls whether or not a legend is created.
2126     * @param tooltips  configure chart to generate tool tips?
2127     * @param urls  configure chart to generate URLs?
2128     *
2129     * @return A wind plot.
2130     *
2131     */
2132    public static JFreeChart createWindPlot(String title,
2133                                            String xAxisLabel,
2134                                            String yAxisLabel,
2135                                            WindDataset dataset,
2136                                            boolean legend,
2137                                            boolean tooltips,
2138                                            boolean urls) {
2139
2140        ValueAxis xAxis = new DateAxis(xAxisLabel);
2141        ValueAxis yAxis = new NumberAxis(yAxisLabel);
2142        yAxis.setRange(-12.0, 12.0);
2143
2144        WindItemRenderer renderer = new WindItemRenderer();
2145        if (tooltips) {
2146            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2147        }
2148        if (urls) {
2149            renderer.setURLGenerator(new StandardXYURLGenerator());
2150        }
2151        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2152        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2153                plot, legend);
2154
2155        return chart;
2156
2157    }
2158
2159    /**
2160     * Creates a wafer map chart.
2161     *
2162     * @param title  the chart title (<code>null</code> permitted).
2163     * @param dataset  the dataset (<code>null</code> permitted).
2164     * @param orientation  the plot orientation (horizontal or vertical) 
2165     *                     (<code>null</code> NOT permitted.
2166     * @param legend  display a legend?
2167     * @param tooltips  generate tooltips?
2168     * @param urls  generate URLs?
2169     *
2170     * @return A wafer map chart.
2171     */
2172    public static JFreeChart createWaferMapChart(String title,
2173                                                 WaferMapDataset dataset,
2174                                                 PlotOrientation orientation,
2175                                                 boolean legend,
2176                                                 boolean tooltips,
2177                                                 boolean urls) {
2178
2179        if (orientation == null) {
2180            throw new IllegalArgumentException("Null 'orientation' argument.");
2181        }
2182        WaferMapPlot plot = new WaferMapPlot(dataset);
2183        WaferMapRenderer renderer = new WaferMapRenderer();
2184        plot.setRenderer(renderer);
2185
2186        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2187                plot, legend);
2188
2189        return chart;
2190    }
2191
2192}