001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2014, 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 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
025 * Other names may be trademarks of their respective owners.]
026 *
027 * -----------------
028 * ChartFactory.java
029 * -----------------
030 * (C) Copyright 2001-2014, 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 * 14-Aug-2008 : Added ChartTheme facility (DG);
119 * 23-Oct-2008 : Check for legacy theme in setChartTheme() and reset default
120 *               bar painters (DG);
121 * 20-Dec-2008 : In createStackedAreaChart(), set category margin to 0.0 (DG);
122 * 02-Jul-2013 : Use ParamChecks class (DG);
123 * 
124 */
125
126package org.jfree.chart;
127
128import java.awt.Color;
129import java.awt.Font;
130import java.text.DateFormat;
131import java.text.NumberFormat;
132import java.util.Iterator;
133import java.util.List;
134import java.util.Locale;
135
136import org.jfree.chart.axis.CategoryAxis;
137import org.jfree.chart.axis.CategoryAxis3D;
138import org.jfree.chart.axis.DateAxis;
139import org.jfree.chart.axis.NumberAxis;
140import org.jfree.chart.axis.NumberAxis3D;
141import org.jfree.chart.axis.Timeline;
142import org.jfree.chart.axis.ValueAxis;
143import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator;
144import org.jfree.chart.labels.HighLowItemLabelGenerator;
145import org.jfree.chart.labels.IntervalCategoryToolTipGenerator;
146import org.jfree.chart.labels.ItemLabelAnchor;
147import org.jfree.chart.labels.ItemLabelPosition;
148import org.jfree.chart.labels.PieToolTipGenerator;
149import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
150import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
151import org.jfree.chart.labels.StandardPieToolTipGenerator;
152import org.jfree.chart.labels.StandardXYToolTipGenerator;
153import org.jfree.chart.labels.StandardXYZToolTipGenerator;
154import org.jfree.chart.labels.XYToolTipGenerator;
155import org.jfree.chart.plot.CategoryPlot;
156import org.jfree.chart.plot.Marker;
157import org.jfree.chart.plot.MultiplePiePlot;
158import org.jfree.chart.plot.PiePlot;
159import org.jfree.chart.plot.PiePlot3D;
160import org.jfree.chart.plot.PlotOrientation;
161import org.jfree.chart.plot.PolarPlot;
162import org.jfree.chart.plot.RingPlot;
163import org.jfree.chart.plot.ValueMarker;
164import org.jfree.chart.plot.WaferMapPlot;
165import org.jfree.chart.plot.XYPlot;
166import org.jfree.chart.renderer.DefaultPolarItemRenderer;
167import org.jfree.chart.renderer.WaferMapRenderer;
168import org.jfree.chart.renderer.category.AreaRenderer;
169import org.jfree.chart.renderer.category.BarRenderer;
170import org.jfree.chart.renderer.category.BarRenderer3D;
171import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer;
172import org.jfree.chart.renderer.category.CategoryItemRenderer;
173import org.jfree.chart.renderer.category.GanttRenderer;
174import org.jfree.chart.renderer.category.GradientBarPainter;
175import org.jfree.chart.renderer.category.LineAndShapeRenderer;
176import org.jfree.chart.renderer.category.LineRenderer3D;
177import org.jfree.chart.renderer.category.StackedAreaRenderer;
178import org.jfree.chart.renderer.category.StackedBarRenderer;
179import org.jfree.chart.renderer.category.StackedBarRenderer3D;
180import org.jfree.chart.renderer.category.StandardBarPainter;
181import org.jfree.chart.renderer.category.WaterfallBarRenderer;
182import org.jfree.chart.renderer.xy.CandlestickRenderer;
183import org.jfree.chart.renderer.xy.GradientXYBarPainter;
184import org.jfree.chart.renderer.xy.HighLowRenderer;
185import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
186import org.jfree.chart.renderer.xy.StandardXYBarPainter;
187import org.jfree.chart.renderer.xy.WindItemRenderer;
188import org.jfree.chart.renderer.xy.XYAreaRenderer;
189import org.jfree.chart.renderer.xy.XYBarRenderer;
190import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer;
191import org.jfree.chart.renderer.xy.XYBubbleRenderer;
192import org.jfree.chart.renderer.xy.XYItemRenderer;
193import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
194import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
195import org.jfree.chart.renderer.xy.XYStepRenderer;
196import org.jfree.chart.title.TextTitle;
197import org.jfree.chart.urls.PieURLGenerator;
198import org.jfree.chart.urls.StandardCategoryURLGenerator;
199import org.jfree.chart.urls.StandardPieURLGenerator;
200import org.jfree.chart.urls.StandardXYURLGenerator;
201import org.jfree.chart.urls.StandardXYZURLGenerator;
202import org.jfree.chart.urls.XYURLGenerator;
203import org.jfree.chart.util.ParamChecks;
204import org.jfree.data.category.CategoryDataset;
205import org.jfree.data.category.IntervalCategoryDataset;
206import org.jfree.data.general.DefaultPieDataset;
207import org.jfree.data.general.PieDataset;
208import org.jfree.data.general.WaferMapDataset;
209import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset;
210import org.jfree.data.statistics.BoxAndWhiskerXYDataset;
211import org.jfree.data.xy.IntervalXYDataset;
212import org.jfree.data.xy.OHLCDataset;
213import org.jfree.data.xy.TableXYDataset;
214import org.jfree.data.xy.WindDataset;
215import org.jfree.data.xy.XYDataset;
216import org.jfree.data.xy.XYZDataset;
217import org.jfree.ui.Layer;
218import org.jfree.ui.RectangleEdge;
219import org.jfree.ui.RectangleInsets;
220import org.jfree.ui.TextAnchor;
221import org.jfree.util.SortOrder;
222import org.jfree.util.TableOrder;
223
224/**
225 * A collection of utility methods for creating some standard charts with
226 * JFreeChart.
227 */
228public abstract class ChartFactory {
229
230    /** The chart theme. */
231    private static ChartTheme currentTheme = new StandardChartTheme("JFree");
232
233    /**
234     * Returns the current chart theme used by the factory.
235     *
236     * @return The chart theme.
237     *
238     * @see #setChartTheme(ChartTheme)
239     * @see ChartUtilities#applyCurrentTheme(JFreeChart)
240     *
241     * @since 1.0.11
242     */
243    public static ChartTheme getChartTheme() {
244        return currentTheme;
245    }
246
247    /**
248     * Sets the current chart theme.  This will be applied to all new charts
249     * created via methods in this class.
250     *
251     * @param theme  the theme (<code>null</code> not permitted).
252     *
253     * @see #getChartTheme()
254     * @see ChartUtilities#applyCurrentTheme(JFreeChart)
255     *
256     * @since 1.0.11
257     */
258    public static void setChartTheme(ChartTheme theme) {
259        ParamChecks.nullNotPermitted(theme, "theme");
260        currentTheme = theme;
261
262        // here we do a check to see if the user is installing the "Legacy"
263        // theme, and reset the bar painters in that case...
264        if (theme instanceof StandardChartTheme) {
265            StandardChartTheme sct = (StandardChartTheme) theme;
266            if (sct.getName().equals("Legacy")) {
267                BarRenderer.setDefaultBarPainter(new StandardBarPainter());
268                XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
269            }
270            else {
271                BarRenderer.setDefaultBarPainter(new GradientBarPainter());
272                XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
273            }
274        }
275    }
276
277    /**
278     * Creates a pie chart with default settings.
279     * <P>
280     * The chart object returned by this method uses a {@link PiePlot} instance
281     * as the plot.
282     *
283     * @param title  the chart title (<code>null</code> permitted).
284     * @param dataset  the dataset for the chart (<code>null</code> permitted).
285     * @param legend  a flag specifying whether or not a legend is required.
286     * @param tooltips  configure chart to generate tool tips?
287     * @param locale  the locale (<code>null</code> not permitted).
288     *
289     * @return A pie chart.
290     *
291     * @since 1.0.7
292     */
293    public static JFreeChart createPieChart(String title, PieDataset dataset,
294            boolean legend, boolean tooltips, Locale locale) {
295
296        PiePlot plot = new PiePlot(dataset);
297        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
298        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
299        if (tooltips) {
300            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
301        }
302        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
303                plot, legend);
304        currentTheme.apply(chart);
305        return chart;
306
307    }
308
309    /**
310     * Creates a pie chart with default settings.
311     * <P>
312     * The chart object returned by this method uses a {@link PiePlot} instance
313     * as the plot.
314     *
315     * @param title  the chart title (<code>null</code> permitted).
316     * @param dataset  the dataset for the chart (<code>null</code> permitted).
317     *
318     * @return A pie chart.
319     * 
320     * @since 1.0.16
321     */
322    public static JFreeChart createPieChart(String title, PieDataset dataset) {
323        return createPieChart(title, dataset, true, true, false);
324    }
325    
326    /**
327     * Creates a pie chart with default settings.
328     * <P>
329     * The chart object returned by this method uses a {@link PiePlot} instance
330     * as the plot.
331     *
332     * @param title  the chart title (<code>null</code> permitted).
333     * @param dataset  the dataset for the chart (<code>null</code> permitted).
334     * @param legend  a flag specifying whether or not a legend is required.
335     * @param tooltips  configure chart to generate tool tips?
336     * @param urls  configure chart to generate URLs?
337     *
338     * @return A pie chart.
339     */
340    public static JFreeChart createPieChart(String title, PieDataset dataset,
341            boolean legend, boolean tooltips, boolean urls) {
342
343        PiePlot plot = new PiePlot(dataset);
344        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
345        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
346        if (tooltips) {
347            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
348        }
349        if (urls) {
350            plot.setURLGenerator(new StandardPieURLGenerator());
351        }
352        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
353                plot, legend);
354        currentTheme.apply(chart);
355        return chart;
356    }
357
358    /**
359     * Creates a pie chart with default settings that compares 2 datasets.
360     * The colour of each section will be determined by the move from the value
361     * for the same key in <code>previousDataset</code>. ie if value1 &gt; 
362     * value2 then the section will be in green (unless 
363     * <code>greenForIncrease</code> is <code>false</code>, in which case it 
364     * would be <code>red</code>). Each section can have a shade of red or 
365     * green as the difference can be tailored between 0% (black) and 
366     * percentDiffForMaxScale% (bright red/green).
367     * <p>
368     * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a
369     * difference of 5% will have a half shade of red/green, a difference of
370     * 10% or more will have a maximum shade/brightness of red/green.
371     * <P>
372     * The chart object returned by this method uses a {@link PiePlot} instance
373     * as the plot.
374     * <p>
375     * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit
376     * Xhenseval</a>.
377     *
378     * @param title  the chart title (<code>null</code> permitted).
379     * @param dataset  the dataset for the chart (<code>null</code> permitted).
380     * @param previousDataset  the dataset for the last run, this will be used
381     *                         to compare each key in the dataset
382     * @param percentDiffForMaxScale scale goes from bright red/green to black,
383     *                               percentDiffForMaxScale indicate the change
384     *                               required to reach top scale.
385     * @param greenForIncrease  an increase since previousDataset will be
386     *                          displayed in green (decrease red) if true.
387     * @param legend  a flag specifying whether or not a legend is required.
388     * @param tooltips  configure chart to generate tool tips?
389     * @param locale  the locale (<code>null</code> not permitted).
390     * @param subTitle displays a subtitle with colour scheme if true
391     * @param showDifference  create a new dataset that will show the %
392     *                        difference between the two datasets.
393     *
394     * @return A pie chart.
395     *
396     * @since 1.0.7
397     */
398    public static JFreeChart createPieChart(String title, PieDataset dataset,
399            PieDataset previousDataset, int percentDiffForMaxScale,
400            boolean greenForIncrease, boolean legend, boolean tooltips,
401            Locale locale, boolean subTitle, boolean showDifference) {
402
403        PiePlot plot = new PiePlot(dataset);
404        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
405        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
406
407        if (tooltips) {
408            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
409        }
410
411        List keys = dataset.getKeys();
412        DefaultPieDataset series = null;
413        if (showDifference) {
414            series = new DefaultPieDataset();
415        }
416
417        double colorPerPercent = 255.0 / percentDiffForMaxScale;
418        for (Iterator it = keys.iterator(); it.hasNext();) {
419            Comparable key = (Comparable) it.next();
420            Number newValue = dataset.getValue(key);
421            Number oldValue = previousDataset.getValue(key);
422
423            if (oldValue == null) {
424                if (greenForIncrease) {
425                    plot.setSectionPaint(key, Color.green);
426                }
427                else {
428                    plot.setSectionPaint(key, Color.red);
429                }
430                if (showDifference) {
431                    assert series != null; // suppresses compiler warning
432                    series.setValue(key + " (+100%)", newValue);
433                }
434            }
435            else {
436                double percentChange = (newValue.doubleValue()
437                        / oldValue.doubleValue() - 1.0) * 100.0;
438                double shade
439                    = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
440                    : Math.abs(percentChange) * colorPerPercent);
441                if (greenForIncrease
442                        && newValue.doubleValue() > oldValue.doubleValue()
443                        || !greenForIncrease && newValue.doubleValue()
444                        < oldValue.doubleValue()) {
445                    plot.setSectionPaint(key, new Color(0, (int) shade, 0));
446                }
447                else {
448                    plot.setSectionPaint(key, new Color((int) shade, 0, 0));
449                }
450                if (showDifference) {
451                    assert series != null; // suppresses compiler warning
452                    series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")
453                            + NumberFormat.getPercentInstance().format(
454                            percentChange / 100.0) + ")", newValue);
455                }
456            }
457        }
458
459        if (showDifference) {
460            plot.setDataset(series);
461        }
462
463        JFreeChart chart =  new JFreeChart(title,
464                JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
465
466        if (subTitle) {
467            TextTitle subtitle = new TextTitle("Bright " + (greenForIncrease 
468                    ? "red" : "green") + "=change >=-" + percentDiffForMaxScale
469                    + "%, Bright " + (!greenForIncrease ? "red" : "green")
470                    + "=change >=+" + percentDiffForMaxScale + "%",
471                    new Font("SansSerif", Font.PLAIN, 10));
472            chart.addSubtitle(subtitle);
473        }
474        currentTheme.apply(chart);
475        return chart;
476    }
477
478    /**
479     * Creates a pie chart with default settings that compares 2 datasets.
480     * The colour of each section will be determined by the move from the value
481     * for the same key in <code>previousDataset</code>. ie if value1 &gt; 
482     * value2 then the section will be in green (unless 
483     * <code>greenForIncrease</code> is <code>false</code>, in which case it 
484     * would be <code>red</code>). Each section can have a shade of red or 
485     * green as the difference can be tailored between 0% (black) and 
486     * percentDiffForMaxScale% (bright red/green).
487     * <p>
488     * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a
489     * difference of 5% will have a half shade of red/green, a difference of
490     * 10% or more will have a maximum shade/brightness of red/green.
491     * <P>
492     * The chart object returned by this method uses a {@link PiePlot} instance
493     * as the plot.
494     * <p>
495     * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit
496     * Xhenseval</a>.
497     *
498     * @param title  the chart title (<code>null</code> permitted).
499     * @param dataset  the dataset for the chart (<code>null</code> permitted).
500     * @param previousDataset  the dataset for the last run, this will be used
501     *                         to compare each key in the dataset
502     * @param percentDiffForMaxScale scale goes from bright red/green to black,
503     *                               percentDiffForMaxScale indicate the change
504     *                               required to reach top scale.
505     * @param greenForIncrease  an increase since previousDataset will be
506     *                          displayed in green (decrease red) if true.
507     * @param legend  a flag specifying whether or not a legend is required.
508     * @param tooltips  configure chart to generate tool tips?
509     * @param urls  configure chart to generate URLs?
510     * @param subTitle displays a subtitle with colour scheme if true
511     * @param showDifference  create a new dataset that will show the %
512     *                        difference between the two datasets.
513     *
514     * @return A pie chart.
515     */
516    public static JFreeChart createPieChart(String title, PieDataset dataset,
517            PieDataset previousDataset, int percentDiffForMaxScale,
518            boolean greenForIncrease, boolean legend, boolean tooltips, 
519            boolean urls, boolean subTitle, boolean showDifference) {
520
521        PiePlot plot = new PiePlot(dataset);
522        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
523        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
524
525        if (tooltips) {
526            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
527        }
528        if (urls) {
529            plot.setURLGenerator(new StandardPieURLGenerator());
530        }
531
532        List keys = dataset.getKeys();
533        DefaultPieDataset series = null;
534        if (showDifference) {
535            series = new DefaultPieDataset();
536        }
537
538        double colorPerPercent = 255.0 / percentDiffForMaxScale;
539        for (Iterator it = keys.iterator(); it.hasNext();) {
540            Comparable key = (Comparable) it.next();
541            Number newValue = dataset.getValue(key);
542            Number oldValue = previousDataset.getValue(key);
543
544            if (oldValue == null) {
545                if (greenForIncrease) {
546                    plot.setSectionPaint(key, Color.green);
547                }
548                else {
549                    plot.setSectionPaint(key, Color.red);
550                }
551                if (showDifference) {
552                    assert series != null; // suppresses compiler warning
553                    series.setValue(key + " (+100%)", newValue);
554                }
555            }
556            else {
557                double percentChange = (newValue.doubleValue()
558                        / oldValue.doubleValue() - 1.0) * 100.0;
559                double shade
560                    = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
561                    : Math.abs(percentChange) * colorPerPercent);
562                if (greenForIncrease
563                        && newValue.doubleValue() > oldValue.doubleValue()
564                        || !greenForIncrease && newValue.doubleValue()
565                        < oldValue.doubleValue()) {
566                    plot.setSectionPaint(key, new Color(0, (int) shade, 0));
567                }
568                else {
569                    plot.setSectionPaint(key, new Color((int) shade, 0, 0));
570                }
571                if (showDifference) {
572                    assert series != null; // suppresses compiler warning
573                    series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")
574                            + NumberFormat.getPercentInstance().format(
575                            percentChange / 100.0) + ")", newValue);
576                }
577            }
578        }
579
580        if (showDifference) {
581            plot.setDataset(series);
582        }
583
584        JFreeChart chart =  new JFreeChart(title,
585                JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
586
587        if (subTitle) {
588            TextTitle subtitle = new TextTitle("Bright " + (greenForIncrease 
589                    ? "red" : "green") + "=change >=-" + percentDiffForMaxScale
590                    + "%, Bright " + (!greenForIncrease ? "red" : "green")
591                    + "=change >=+" + percentDiffForMaxScale + "%",
592                    new Font("SansSerif", Font.PLAIN, 10));
593            chart.addSubtitle(subtitle);
594        }
595        currentTheme.apply(chart);
596        return chart;
597    }
598
599    /**
600     * Creates a ring chart with default settings.
601     * <P>
602     * The chart object returned by this method uses a {@link RingPlot}
603     * instance as the plot.
604     *
605     * @param title  the chart title (<code>null</code> permitted).
606     * @param dataset  the dataset for the chart (<code>null</code> permitted).
607     * @param legend  a flag specifying whether or not a legend is required.
608     * @param tooltips  configure chart to generate tool tips?
609     * @param locale  the locale (<code>null</code> not permitted).
610     *
611     * @return A ring chart.
612     *
613     * @since 1.0.7
614     */
615    public static JFreeChart createRingChart(String title, PieDataset dataset,
616            boolean legend, boolean tooltips, Locale locale) {
617
618        RingPlot plot = new RingPlot(dataset);
619        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
620        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
621        if (tooltips) {
622            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
623        }
624        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
625                plot, legend);
626        currentTheme.apply(chart);
627        return chart;
628    }
629
630    /**
631     * Creates a ring chart with default settings.
632     * <P>
633     * The chart object returned by this method uses a {@link RingPlot}
634     * instance as the plot.
635     *
636     * @param title  the chart title (<code>null</code> permitted).
637     * @param dataset  the dataset for the chart (<code>null</code> permitted).
638     * @param legend  a flag specifying whether or not a legend is required.
639     * @param tooltips  configure chart to generate tool tips?
640     * @param urls  configure chart to generate URLs?
641     *
642     * @return A ring chart.
643     */
644    public static JFreeChart createRingChart(String title, PieDataset dataset,
645            boolean legend, boolean tooltips, boolean urls) {
646
647        RingPlot plot = new RingPlot(dataset);
648        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
649        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
650        if (tooltips) {
651            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
652        }
653        if (urls) {
654            plot.setURLGenerator(new StandardPieURLGenerator());
655        }
656        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
657                plot, legend);
658        currentTheme.apply(chart);
659        return chart;
660
661    }
662
663    /**
664     * Creates a chart that displays multiple pie plots.  The chart object
665     * returned by this method uses a {@link MultiplePiePlot} instance as the
666     * plot.
667     *
668     * @param title  the chart title (<code>null</code> permitted).
669     * @param dataset  the dataset (<code>null</code> permitted).
670     * @param order  the order that the data is extracted (by row or by column)
671     *               (<code>null</code> not permitted).
672     * @param legend  include a legend?
673     * @param tooltips  generate tooltips?
674     * @param urls  generate URLs?
675     *
676     * @return A chart.
677     */
678    public static JFreeChart createMultiplePieChart(String title,
679            CategoryDataset dataset, TableOrder order, boolean legend,
680            boolean tooltips, boolean urls) {
681
682        ParamChecks.nullNotPermitted(order, "order");
683        MultiplePiePlot plot = new MultiplePiePlot(dataset);
684        plot.setDataExtractOrder(order);
685        plot.setBackgroundPaint(null);
686        plot.setOutlineStroke(null);
687
688        if (tooltips) {
689            PieToolTipGenerator tooltipGenerator
690                = new StandardPieToolTipGenerator();
691            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
692            pp.setToolTipGenerator(tooltipGenerator);
693        }
694
695        if (urls) {
696            PieURLGenerator urlGenerator = new StandardPieURLGenerator();
697            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
698            pp.setURLGenerator(urlGenerator);
699        }
700
701        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
702                plot, legend);
703        currentTheme.apply(chart);
704        return chart;
705
706    }
707
708    /**
709     * Creates a 3D pie chart using the specified dataset.  The chart object
710     * returned by this method uses a {@link PiePlot3D} instance as the
711     * plot.
712     *
713     * @param title  the chart title (<code>null</code> permitted).
714     * @param dataset  the dataset for the chart (<code>null</code> permitted).
715     * @param legend  a flag specifying whether or not a legend is required.
716     * @param tooltips  configure chart to generate tool tips?
717     * @param locale  the locale (<code>null</code> not permitted).
718     *
719     * @return A pie chart.
720     *
721     * @since 1.0.7
722     */
723    public static JFreeChart createPieChart3D(String title, PieDataset dataset,
724            boolean legend, boolean tooltips, Locale locale) {
725
726        ParamChecks.nullNotPermitted(locale, "locale");
727        PiePlot3D plot = new PiePlot3D(dataset);
728        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
729        if (tooltips) {
730            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
731        }
732        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
733                plot, legend);
734        currentTheme.apply(chart);
735        return chart;
736
737    }
738
739    /**
740     * Creates a 3D pie chart using the specified dataset.  The chart object
741     * returned by this method uses a {@link PiePlot3D} instance as the
742     * plot.
743     *
744     * @param title  the chart title (<code>null</code> permitted).
745     * @param dataset  the dataset for the chart (<code>null</code> permitted).
746     *
747     * @return A pie chart.
748     * 
749     * @since 1.0.16
750     */
751    public static JFreeChart createPieChart3D(String title,
752            PieDataset dataset) {
753        return createPieChart3D(title, dataset, true, true, false);
754    }
755    
756    /**
757     * Creates a 3D pie chart using the specified dataset.  The chart object
758     * returned by this method uses a {@link PiePlot3D} instance as the
759     * plot.
760     *
761     * @param title  the chart title (<code>null</code> permitted).
762     * @param dataset  the dataset for the chart (<code>null</code> permitted).
763     * @param legend  a flag specifying whether or not a legend is required.
764     * @param tooltips  configure chart to generate tool tips?
765     * @param urls  configure chart to generate URLs?
766     *
767     * @return A pie chart.
768     */
769    public static JFreeChart createPieChart3D(String title, PieDataset dataset,
770            boolean legend, boolean tooltips, boolean urls) {
771
772        PiePlot3D plot = new PiePlot3D(dataset);
773        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
774        if (tooltips) {
775            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
776        }
777        if (urls) {
778            plot.setURLGenerator(new StandardPieURLGenerator());
779        }
780        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
781                plot, legend);
782        currentTheme.apply(chart);
783        return chart;
784
785    }
786
787    /**
788     * Creates a chart that displays multiple pie plots.  The chart object
789     * returned by this method uses a {@link MultiplePiePlot} instance as the
790     * plot.
791     *
792     * @param title  the chart title (<code>null</code> permitted).
793     * @param dataset  the dataset (<code>null</code> permitted).
794     * @param order  the order that the data is extracted (by row or by column)
795     *               (<code>null</code> not permitted).
796     * @param legend  include a legend?
797     * @param tooltips  generate tooltips?
798     * @param urls  generate URLs?
799     *
800     * @return A chart.
801     */
802    public static JFreeChart createMultiplePieChart3D(String title,
803            CategoryDataset dataset, TableOrder order, boolean legend,
804            boolean tooltips, boolean urls) {
805
806        ParamChecks.nullNotPermitted(order, "order");
807        MultiplePiePlot plot = new MultiplePiePlot(dataset);
808        plot.setDataExtractOrder(order);
809        plot.setBackgroundPaint(null);
810        plot.setOutlineStroke(null);
811
812        JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
813        TextTitle seriesTitle = new TextTitle("Series Title",
814                new Font("SansSerif", Font.BOLD, 12));
815        seriesTitle.setPosition(RectangleEdge.BOTTOM);
816        pieChart.setTitle(seriesTitle);
817        pieChart.removeLegend();
818        pieChart.setBackgroundPaint(null);
819        plot.setPieChart(pieChart);
820
821        if (tooltips) {
822            PieToolTipGenerator tooltipGenerator
823                = new StandardPieToolTipGenerator();
824            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
825            pp.setToolTipGenerator(tooltipGenerator);
826        }
827
828        if (urls) {
829            PieURLGenerator urlGenerator = new StandardPieURLGenerator();
830            PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
831            pp.setURLGenerator(urlGenerator);
832        }
833
834        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
835                plot, legend);
836        currentTheme.apply(chart);
837        return chart;
838
839    }
840
841    /**
842     * Creates a bar chart with a vertical orientation.  The chart object
843     * returned by this method uses a {@link CategoryPlot} instance as the
844     * plot, with a {@link CategoryAxis} for the domain axis, a
845     * {@link NumberAxis} as the range axis, and a {@link BarRenderer} as the
846     * renderer.
847     *
848     * @param title  the chart title (<code>null</code> permitted).
849     * @param categoryAxisLabel  the label for the category axis
850     *                           (<code>null</code> permitted).
851     * @param valueAxisLabel  the label for the value axis
852     *                        (<code>null</code> permitted).
853     * @param dataset  the dataset for the chart (<code>null</code> permitted).
854     *
855     * @return A bar chart.
856     * 
857     * @since 1.0.16
858     */
859    public static JFreeChart createBarChart(String title,
860            String categoryAxisLabel, String valueAxisLabel,
861            CategoryDataset dataset) {
862        return createBarChart(title, categoryAxisLabel, valueAxisLabel, dataset,
863                PlotOrientation.VERTICAL, true, true, false);
864    }
865 
866    /**
867     * Creates a bar chart.  The chart object returned by this method uses a
868     * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
869     * for the domain axis, a {@link NumberAxis} as the range axis, and a
870     * {@link BarRenderer} as the renderer.
871     *
872     * @param title  the chart title (<code>null</code> permitted).
873     * @param categoryAxisLabel  the label for the category axis
874     *                           (<code>null</code> permitted).
875     * @param valueAxisLabel  the label for the value axis
876     *                        (<code>null</code> permitted).
877     * @param dataset  the dataset for the chart (<code>null</code> permitted).
878     * @param orientation  the plot orientation (horizontal or vertical)
879     *                     (<code>null</code> not permitted).
880     * @param legend  a flag specifying whether or not a legend is required.
881     * @param tooltips  configure chart to generate tool tips?
882     * @param urls  configure chart to generate URLs?
883     *
884     * @return A bar chart.
885     */
886    public static JFreeChart createBarChart(String title,
887            String categoryAxisLabel, String valueAxisLabel,
888            CategoryDataset dataset, PlotOrientation orientation,
889            boolean legend, boolean tooltips, boolean urls) {
890
891        ParamChecks.nullNotPermitted(orientation, "orientation");
892        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
893        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
894
895        BarRenderer renderer = new BarRenderer();
896        if (orientation == PlotOrientation.HORIZONTAL) {
897            ItemLabelPosition position1 = new ItemLabelPosition(
898                    ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
899            renderer.setBasePositiveItemLabelPosition(position1);
900            ItemLabelPosition position2 = new ItemLabelPosition(
901                    ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
902            renderer.setBaseNegativeItemLabelPosition(position2);
903        } else if (orientation == PlotOrientation.VERTICAL) {
904            ItemLabelPosition position1 = new ItemLabelPosition(
905                    ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
906            renderer.setBasePositiveItemLabelPosition(position1);
907            ItemLabelPosition position2 = new ItemLabelPosition(
908                    ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
909            renderer.setBaseNegativeItemLabelPosition(position2);
910        }
911        if (tooltips) {
912            renderer.setBaseToolTipGenerator(
913                    new StandardCategoryToolTipGenerator());
914        }
915        if (urls) {
916            renderer.setBaseItemURLGenerator(
917                    new StandardCategoryURLGenerator());
918        }
919
920        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
921                renderer);
922        plot.setOrientation(orientation);
923        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
924                plot, legend);
925        currentTheme.apply(chart);
926        return chart;
927
928    }
929
930    /**
931     * Creates a stacked bar chart with default settings.  The chart object
932     * returned by this method uses a {@link CategoryPlot} instance as the
933     * plot, with a {@link CategoryAxis} for the domain axis, a
934     * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}
935     * as the renderer.
936     *
937     * @param title  the chart title (<code>null</code> permitted).
938     * @param domainAxisLabel  the label for the category axis
939     *                         (<code>null</code> permitted).
940     * @param rangeAxisLabel  the label for the value axis
941     *                        (<code>null</code> permitted).
942     * @param dataset  the dataset for the chart (<code>null</code> permitted).
943     *
944     * @return A stacked bar chart.
945     * 
946     * @since 1.0.16
947     */
948    public static JFreeChart createStackedBarChart(String title,
949            String domainAxisLabel, String rangeAxisLabel,
950            CategoryDataset dataset) {
951        return createStackedBarChart(title, domainAxisLabel, rangeAxisLabel,
952                dataset, PlotOrientation.VERTICAL, true, true, false);
953    }
954    
955    /**
956     * Creates a stacked bar chart with default settings.  The chart object
957     * returned by this method uses a {@link CategoryPlot} instance as the
958     * plot, with a {@link CategoryAxis} for the domain axis, a
959     * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}
960     * as the renderer.
961     *
962     * @param title  the chart title (<code>null</code> permitted).
963     * @param domainAxisLabel  the label for the category axis
964     *                         (<code>null</code> permitted).
965     * @param rangeAxisLabel  the label for the value axis
966     *                        (<code>null</code> permitted).
967     * @param dataset  the dataset for the chart (<code>null</code> permitted).
968     * @param orientation  the orientation of the chart (horizontal or
969     *                     vertical) (<code>null</code> not permitted).
970     * @param legend  a flag specifying whether or not a legend is required.
971     * @param tooltips  configure chart to generate tool tips?
972     * @param urls  configure chart to generate URLs?
973     *
974     * @return A stacked bar chart.
975     */
976    public static JFreeChart createStackedBarChart(String title,
977            String domainAxisLabel, String rangeAxisLabel,
978            CategoryDataset dataset, PlotOrientation orientation,
979            boolean legend, boolean tooltips, boolean urls) {
980
981        ParamChecks.nullNotPermitted(orientation, "orientation");
982
983        CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
984        ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);
985
986        StackedBarRenderer renderer = new StackedBarRenderer();
987        if (tooltips) {
988            renderer.setBaseToolTipGenerator(
989                    new StandardCategoryToolTipGenerator());
990        }
991        if (urls) {
992            renderer.setBaseItemURLGenerator(
993                    new StandardCategoryURLGenerator());
994        }
995
996        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
997                renderer);
998        plot.setOrientation(orientation);
999        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1000                plot, legend);
1001        currentTheme.apply(chart);
1002        return chart;
1003
1004    }
1005
1006    /**
1007     * Creates a bar chart with a 3D effect. The chart object returned by this
1008     * method uses a {@link CategoryPlot} instance as the plot, with a
1009     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
1010     * the range axis, and a {@link BarRenderer3D} as the renderer.
1011     *
1012     * @param title  the chart title (<code>null</code> permitted).
1013     * @param categoryAxisLabel  the label for the category axis
1014     *                           (<code>null</code> permitted).
1015     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1016     *                        permitted).
1017     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1018     *
1019     * @return A bar chart with a 3D effect.
1020     * 
1021     * @since 1.0.16
1022     */
1023    public static JFreeChart createBarChart3D(String title,
1024            String categoryAxisLabel, String valueAxisLabel,
1025            CategoryDataset dataset) {
1026        return createBarChart3D(title, categoryAxisLabel, valueAxisLabel,
1027                dataset, PlotOrientation.VERTICAL, true, true, false);
1028    }
1029    
1030    /**
1031     * Creates a bar chart with a 3D effect. The chart object returned by this
1032     * method uses a {@link CategoryPlot} instance as the plot, with a
1033     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
1034     * the range axis, and a {@link BarRenderer3D} as the renderer.
1035     *
1036     * @param title  the chart title (<code>null</code> permitted).
1037     * @param categoryAxisLabel  the label for the category axis
1038     *                           (<code>null</code> permitted).
1039     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1040     *                        permitted).
1041     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1042     * @param orientation  the plot orientation (horizontal or vertical)
1043     *                     (<code>null</code> not permitted).
1044     * @param legend  a flag specifying whether or not a legend is required.
1045     * @param tooltips  configure chart to generate tool tips?
1046     * @param urls  configure chart to generate URLs?
1047     *
1048     * @return A bar chart with a 3D effect.
1049     */
1050    public static JFreeChart createBarChart3D(String title,
1051            String categoryAxisLabel, String valueAxisLabel,
1052            CategoryDataset dataset, PlotOrientation orientation,
1053            boolean legend, boolean tooltips, boolean urls) {
1054
1055        ParamChecks.nullNotPermitted(orientation, "orientation");
1056        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
1057        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
1058
1059        BarRenderer3D renderer = new BarRenderer3D();
1060        if (tooltips) {
1061            renderer.setBaseToolTipGenerator(
1062                    new StandardCategoryToolTipGenerator());
1063        }
1064        if (urls) {
1065            renderer.setBaseItemURLGenerator(
1066                    new StandardCategoryURLGenerator());
1067        }
1068
1069        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1070                renderer);
1071        plot.setOrientation(orientation);
1072        if (orientation == PlotOrientation.HORIZONTAL) {
1073            // change rendering order to ensure that bar overlapping is the
1074            // right way around
1075            plot.setRowRenderingOrder(SortOrder.DESCENDING);
1076            plot.setColumnRenderingOrder(SortOrder.DESCENDING);
1077        }
1078        plot.setForegroundAlpha(0.75f);
1079
1080        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1081                plot, legend);
1082        currentTheme.apply(chart);
1083        return chart;
1084
1085    }
1086
1087    /**
1088     * Creates a stacked bar chart with a 3D effect and default settings. The
1089     * chart object returned by this method uses a {@link CategoryPlot}
1090     * instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
1091     * a {@link NumberAxis3D} as the range axis, and a
1092     * {@link StackedBarRenderer3D} as the renderer.
1093     *
1094     * @param title  the chart title (<code>null</code> permitted).
1095     * @param categoryAxisLabel  the label for the category axis
1096     *                           (<code>null</code> permitted).
1097     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1098     *                        permitted).
1099     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1100     *
1101     * @return A stacked bar chart with a 3D effect.
1102     * 
1103     * @since 1.0.16
1104     */
1105    public static JFreeChart createStackedBarChart3D(String title,
1106            String categoryAxisLabel, String valueAxisLabel,
1107            CategoryDataset dataset) {
1108        return createStackedBarChart3D(title, categoryAxisLabel, valueAxisLabel,
1109                dataset, PlotOrientation.VERTICAL, true, true, false);
1110    }
1111    
1112    /**
1113     * Creates a stacked bar chart with a 3D effect and default settings. The
1114     * chart object returned by this method uses a {@link CategoryPlot}
1115     * instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
1116     * a {@link NumberAxis3D} as the range axis, and a
1117     * {@link StackedBarRenderer3D} as the renderer.
1118     *
1119     * @param title  the chart title (<code>null</code> permitted).
1120     * @param categoryAxisLabel  the label for the category axis
1121     *                           (<code>null</code> permitted).
1122     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1123     *                        permitted).
1124     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1125     * @param orientation  the orientation (horizontal or vertical)
1126     *                     (<code>null</code> not permitted).
1127     * @param legend  a flag specifying whether or not a legend is required.
1128     * @param tooltips  configure chart to generate tool tips?
1129     * @param urls  configure chart to generate URLs?
1130     *
1131     * @return A stacked bar chart with a 3D effect.
1132     */
1133    public static JFreeChart createStackedBarChart3D(String title,
1134            String categoryAxisLabel, String valueAxisLabel,
1135            CategoryDataset dataset, PlotOrientation orientation,
1136            boolean legend, boolean tooltips, boolean urls) {
1137
1138        ParamChecks.nullNotPermitted(orientation, "orientation");
1139        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
1140        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
1141
1142        // create the renderer...
1143        CategoryItemRenderer renderer = new StackedBarRenderer3D();
1144        if (tooltips) {
1145            renderer.setBaseToolTipGenerator(
1146                    new StandardCategoryToolTipGenerator());
1147        }
1148        if (urls) {
1149            renderer.setBaseItemURLGenerator(
1150                    new StandardCategoryURLGenerator());
1151        }
1152
1153        // create the plot...
1154        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1155                renderer);
1156        plot.setOrientation(orientation);
1157        if (orientation == PlotOrientation.HORIZONTAL) {
1158            // change rendering order to ensure that bar overlapping is the
1159            // right way around
1160            plot.setColumnRenderingOrder(SortOrder.DESCENDING);
1161        }
1162
1163        // create the chart...
1164        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1165                plot, legend);
1166        currentTheme.apply(chart);
1167        return chart;
1168
1169    }
1170
1171    /**
1172     * Creates an area chart with default settings.  The chart object returned
1173     * by this method uses a {@link CategoryPlot} instance as the plot, with a
1174     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1175     * range axis, and an {@link AreaRenderer} as the renderer.
1176     *
1177     * @param title  the chart title (<code>null</code> permitted).
1178     * @param categoryAxisLabel  the label for the category axis
1179     *                           (<code>null</code> permitted).
1180     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1181     *                        permitted).
1182     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1183     *
1184     * @return An area chart.
1185     * 
1186     * @since 1.0.16
1187     */
1188    public static JFreeChart createAreaChart(String title,
1189            String categoryAxisLabel, String valueAxisLabel,
1190            CategoryDataset dataset) {
1191        return createAreaChart(title, categoryAxisLabel, valueAxisLabel,
1192                dataset, PlotOrientation.VERTICAL, true, true, false);
1193    }
1194            
1195    /**
1196     * Creates an area chart with default settings.  The chart object returned
1197     * by this method uses a {@link CategoryPlot} instance as the plot, with a
1198     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1199     * range axis, and an {@link AreaRenderer} as the renderer.
1200     *
1201     * @param title  the chart title (<code>null</code> permitted).
1202     * @param categoryAxisLabel  the label for the category axis
1203     *                           (<code>null</code> permitted).
1204     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1205     *                        permitted).
1206     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1207     * @param orientation  the plot orientation (<code>null</code> not
1208     *                     permitted).
1209     * @param legend  a flag specifying whether or not a legend is required.
1210     * @param tooltips  configure chart to generate tool tips?
1211     * @param urls  configure chart to generate URLs?
1212     *
1213     * @return An area chart.
1214     */
1215    public static JFreeChart createAreaChart(String title,
1216            String categoryAxisLabel, String valueAxisLabel,
1217            CategoryDataset dataset, PlotOrientation orientation,
1218            boolean legend, boolean tooltips, boolean urls) {
1219
1220        ParamChecks.nullNotPermitted(orientation, "orientation");
1221        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1222        categoryAxis.setCategoryMargin(0.0);
1223
1224        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1225
1226        AreaRenderer renderer = new AreaRenderer();
1227        if (tooltips) {
1228            renderer.setBaseToolTipGenerator(
1229                    new StandardCategoryToolTipGenerator());
1230        }
1231        if (urls) {
1232            renderer.setBaseItemURLGenerator(
1233                    new StandardCategoryURLGenerator());
1234        }
1235
1236        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1237                renderer);
1238        plot.setOrientation(orientation);
1239        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1240                plot, legend);
1241        currentTheme.apply(chart);
1242        return chart;
1243
1244    }
1245
1246    /**
1247     * Creates a stacked area chart with default settings.  The chart object
1248     * returned by this method uses a {@link CategoryPlot} instance as the
1249     * plot, with a {@link CategoryAxis} for the domain axis, a
1250     * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer}
1251     * as the renderer.
1252     *
1253     * @param title  the chart title (<code>null</code> permitted).
1254     * @param categoryAxisLabel  the label for the category axis
1255     *                           (<code>null</code> permitted).
1256     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1257     *                        permitted).
1258     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1259     *
1260     * @return A stacked area chart.
1261     * 
1262     * @since 1.0.16
1263     */
1264    public static JFreeChart createStackedAreaChart(String title,
1265            String categoryAxisLabel, String valueAxisLabel,
1266            CategoryDataset dataset) {
1267        return createStackedAreaChart(title, categoryAxisLabel, valueAxisLabel,
1268                dataset, PlotOrientation.VERTICAL, true, true, false);
1269    }
1270    
1271    /**
1272     * Creates a stacked area chart with default settings.  The chart object
1273     * returned by this method uses a {@link CategoryPlot} instance as the
1274     * plot, with a {@link CategoryAxis} for the domain axis, a
1275     * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer}
1276     * as the renderer.
1277     *
1278     * @param title  the chart title (<code>null</code> permitted).
1279     * @param categoryAxisLabel  the label for the category axis
1280     *                           (<code>null</code> permitted).
1281     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1282     *                        permitted).
1283     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1284     * @param orientation  the plot orientation (horizontal or vertical)
1285     *                     (<code>null</code> not permitted).
1286     * @param legend  a flag specifying whether or not a legend is required.
1287     * @param tooltips  configure chart to generate tool tips?
1288     * @param urls  configure chart to generate URLs?
1289     *
1290     * @return A stacked area chart.
1291     */
1292    public static JFreeChart createStackedAreaChart(String title,
1293            String categoryAxisLabel, String valueAxisLabel,
1294            CategoryDataset dataset, PlotOrientation orientation,
1295            boolean legend, boolean tooltips, boolean urls) {
1296
1297        ParamChecks.nullNotPermitted(orientation, "orientation");
1298        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1299        categoryAxis.setCategoryMargin(0.0);
1300        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1301
1302        StackedAreaRenderer renderer = new StackedAreaRenderer();
1303        if (tooltips) {
1304            renderer.setBaseToolTipGenerator(
1305                    new StandardCategoryToolTipGenerator());
1306        }
1307        if (urls) {
1308            renderer.setBaseItemURLGenerator(
1309                    new StandardCategoryURLGenerator());
1310        }
1311
1312        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1313                renderer);
1314        plot.setOrientation(orientation);
1315        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1316                plot, legend);
1317        currentTheme.apply(chart);
1318        return chart;
1319
1320    }
1321
1322    /**
1323     * Creates a line chart with default settings.  The chart object returned
1324     * by this method uses a {@link CategoryPlot} instance as the plot, with a
1325     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1326     * range axis, and a {@link LineAndShapeRenderer} as the renderer.
1327     *
1328     * @param title  the chart title (<code>null</code> permitted).
1329     * @param categoryAxisLabel  the label for the category axis
1330     *                           (<code>null</code> permitted).
1331     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1332     *                        permitted).
1333     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1334     *
1335     * @return A line chart.
1336     * 
1337     * @since 1.0.16
1338     */
1339    public static JFreeChart createLineChart(String title,
1340            String categoryAxisLabel, String valueAxisLabel,
1341            CategoryDataset dataset) {
1342        return createLineChart(title, categoryAxisLabel, valueAxisLabel,
1343                dataset, PlotOrientation.VERTICAL, true, true, false);
1344    }
1345    
1346    /**
1347     * Creates a line chart with default settings.  The chart object returned
1348     * by this method uses a {@link CategoryPlot} instance as the plot, with a
1349     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1350     * range axis, and a {@link LineAndShapeRenderer} as the renderer.
1351     *
1352     * @param title  the chart title (<code>null</code> permitted).
1353     * @param categoryAxisLabel  the label for the category axis
1354     *                           (<code>null</code> permitted).
1355     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1356     *                        permitted).
1357     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1358     * @param orientation  the chart orientation (horizontal or vertical)
1359     *                     (<code>null</code> not permitted).
1360     * @param legend  a flag specifying whether or not a legend is required.
1361     * @param tooltips  configure chart to generate tool tips?
1362     * @param urls  configure chart to generate URLs?
1363     *
1364     * @return A line chart.
1365     */
1366    public static JFreeChart createLineChart(String title,
1367            String categoryAxisLabel, String valueAxisLabel,
1368            CategoryDataset dataset, PlotOrientation orientation,
1369            boolean legend, boolean tooltips, boolean urls) {
1370
1371        ParamChecks.nullNotPermitted(orientation, "orientation");
1372        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1373        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1374
1375        LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
1376        if (tooltips) {
1377            renderer.setBaseToolTipGenerator(
1378                    new StandardCategoryToolTipGenerator());
1379        }
1380        if (urls) {
1381            renderer.setBaseItemURLGenerator(
1382                    new StandardCategoryURLGenerator());
1383        }
1384        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1385                renderer);
1386        plot.setOrientation(orientation);
1387        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1388                plot, legend);
1389        currentTheme.apply(chart);
1390        return chart;
1391
1392    }
1393
1394    /**
1395     * Creates a line chart with default settings. The chart object returned by
1396     * this method uses a {@link CategoryPlot} instance as the plot, with a
1397     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
1398     * the range axis, and a {@link LineRenderer3D} as the renderer.
1399     *
1400     * @param title  the chart title (<code>null</code> permitted).
1401     * @param categoryAxisLabel  the label for the category axis
1402     *                           (<code>null</code> permitted).
1403     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1404     *                        permitted).
1405     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1406     *
1407     * @return A line chart.
1408     * 
1409     * @since 1.0.16
1410     */
1411    public static JFreeChart createLineChart3D(String title,
1412            String categoryAxisLabel, String valueAxisLabel,
1413            CategoryDataset dataset) {
1414        return createLineChart3D(title, categoryAxisLabel, valueAxisLabel,
1415                dataset, PlotOrientation.VERTICAL, true, true, false);
1416    }    
1417        
1418    /**
1419     * Creates a line chart with default settings. The chart object returned by
1420     * this method uses a {@link CategoryPlot} instance as the plot, with a
1421     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
1422     * the range axis, and a {@link LineRenderer3D} as the renderer.
1423     *
1424     * @param title  the chart title (<code>null</code> permitted).
1425     * @param categoryAxisLabel  the label for the category axis
1426     *                           (<code>null</code> permitted).
1427     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1428     *                        permitted).
1429     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1430     * @param orientation  the chart orientation (horizontal or vertical)
1431     *                     (<code>null</code> not permitted).
1432     * @param legend  a flag specifying whether or not a legend is required.
1433     * @param tooltips  configure chart to generate tool tips?
1434     * @param urls  configure chart to generate URLs?
1435     *
1436     * @return A line chart.
1437     */
1438    public static JFreeChart createLineChart3D(String title,
1439            String categoryAxisLabel, String valueAxisLabel,
1440            CategoryDataset dataset, PlotOrientation orientation,
1441            boolean legend, boolean tooltips, boolean urls) {
1442
1443        ParamChecks.nullNotPermitted(orientation, "orientation");
1444        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
1445        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
1446
1447        LineRenderer3D renderer = new LineRenderer3D();
1448        if (tooltips) {
1449            renderer.setBaseToolTipGenerator(
1450                    new StandardCategoryToolTipGenerator());
1451        }
1452        if (urls) {
1453            renderer.setBaseItemURLGenerator(
1454                    new StandardCategoryURLGenerator());
1455        }
1456        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1457                renderer);
1458        plot.setOrientation(orientation);
1459        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1460                plot, legend);
1461        currentTheme.apply(chart);
1462        return chart;
1463
1464    }
1465
1466    /**
1467     * Creates a Gantt chart using the supplied attributes plus default values
1468     * where required.  The chart object returned by this method uses a
1469     * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
1470     * for the domain axis, a {@link DateAxis} as the range axis, and a
1471     * {@link GanttRenderer} as the renderer.
1472     *
1473     * @param title  the chart title (<code>null</code> permitted).
1474     * @param categoryAxisLabel  the label for the category axis
1475     *                           (<code>null</code> permitted).
1476     * @param dateAxisLabel  the label for the date axis
1477     *                       (<code>null</code> permitted).
1478     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1479     *
1480     * @return A Gantt chart.
1481     * 
1482     * @since 1.0.16
1483     */
1484    public static JFreeChart createGanttChart(String title,
1485            String categoryAxisLabel, String dateAxisLabel,
1486            IntervalCategoryDataset dataset) {
1487        return createGanttChart(title, categoryAxisLabel, dateAxisLabel,
1488                dataset, true, true, false);
1489    }
1490    
1491    /**
1492     * Creates a Gantt chart using the supplied attributes plus default values
1493     * where required.  The chart object returned by this method uses a
1494     * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
1495     * for the domain axis, a {@link DateAxis} as the range axis, and a
1496     * {@link GanttRenderer} as the renderer.
1497     *
1498     * @param title  the chart title (<code>null</code> permitted).
1499     * @param categoryAxisLabel  the label for the category axis
1500     *                           (<code>null</code> permitted).
1501     * @param dateAxisLabel  the label for the date axis
1502     *                       (<code>null</code> permitted).
1503     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1504     * @param legend  a flag specifying whether or not a legend is required.
1505     * @param tooltips  configure chart to generate tool tips?
1506     * @param urls  configure chart to generate URLs?
1507     *
1508     * @return A Gantt chart.
1509     */
1510    public static JFreeChart createGanttChart(String title,
1511            String categoryAxisLabel, String dateAxisLabel,
1512            IntervalCategoryDataset dataset, boolean legend, boolean tooltips,
1513            boolean urls) {
1514
1515        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1516        DateAxis dateAxis = new DateAxis(dateAxisLabel);
1517
1518        CategoryItemRenderer renderer = new GanttRenderer();
1519        if (tooltips) {
1520            renderer.setBaseToolTipGenerator(
1521                    new IntervalCategoryToolTipGenerator(
1522                    "{3} - {4}", DateFormat.getDateInstance()));
1523        }
1524        if (urls) {
1525            renderer.setBaseItemURLGenerator(
1526                    new StandardCategoryURLGenerator());
1527        }
1528
1529        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis,
1530                renderer);
1531        plot.setOrientation(PlotOrientation.HORIZONTAL);
1532        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1533                plot, legend);
1534        currentTheme.apply(chart);
1535        return chart;
1536
1537    }
1538
1539    /**
1540     * Creates a waterfall chart.  The chart object returned by this method
1541     * uses a {@link CategoryPlot} instance as the plot, with a
1542     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1543     * range axis, and a {@link WaterfallBarRenderer} as the renderer.
1544     *
1545     * @param title  the chart title (<code>null</code> permitted).
1546     * @param categoryAxisLabel  the label for the category axis
1547     *                           (<code>null</code> permitted).
1548     * @param valueAxisLabel  the label for the value axis (<code>null</code>
1549     *                        permitted).
1550     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1551     * @param orientation  the plot orientation (horizontal or vertical)
1552     *                     (<code>null</code> NOT permitted).
1553     * @param legend  a flag specifying whether or not a legend is required.
1554     * @param tooltips  configure chart to generate tool tips?
1555     * @param urls  configure chart to generate URLs?
1556     *
1557     * @return A waterfall chart.
1558     */
1559    public static JFreeChart createWaterfallChart(String title,
1560            String categoryAxisLabel, String valueAxisLabel,
1561            CategoryDataset dataset, PlotOrientation orientation,
1562            boolean legend, boolean tooltips, boolean urls) {
1563
1564        ParamChecks.nullNotPermitted(orientation, "orientation");
1565        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1566        categoryAxis.setCategoryMargin(0.0);
1567
1568        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1569
1570        WaterfallBarRenderer renderer = new WaterfallBarRenderer();
1571        if (orientation == PlotOrientation.HORIZONTAL) {
1572            ItemLabelPosition position = new ItemLabelPosition(
1573                    ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1574                    TextAnchor.CENTER, Math.PI / 2.0);
1575            renderer.setBasePositiveItemLabelPosition(position);
1576            renderer.setBaseNegativeItemLabelPosition(position);
1577         }
1578        else if (orientation == PlotOrientation.VERTICAL) {
1579            ItemLabelPosition position = new ItemLabelPosition(
1580                    ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1581                    TextAnchor.CENTER, 0.0);
1582            renderer.setBasePositiveItemLabelPosition(position);
1583            renderer.setBaseNegativeItemLabelPosition(position);
1584        }
1585        if (tooltips) {
1586            StandardCategoryToolTipGenerator generator
1587                = new StandardCategoryToolTipGenerator();
1588            renderer.setBaseToolTipGenerator(generator);
1589        }
1590        if (urls) {
1591            renderer.setBaseItemURLGenerator(
1592                    new StandardCategoryURLGenerator());
1593        }
1594
1595        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1596                renderer);
1597        plot.clearRangeMarkers();
1598        Marker baseline = new ValueMarker(0.0);
1599        baseline.setPaint(Color.black);
1600        plot.addRangeMarker(baseline, Layer.FOREGROUND);
1601        plot.setOrientation(orientation);
1602        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1603                plot, legend);
1604        currentTheme.apply(chart);
1605        return chart;
1606
1607    }
1608
1609    /**
1610     * Creates a polar plot for the specified dataset (x-values interpreted as
1611     * angles in degrees).  The chart object returned by this method uses a
1612     * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for
1613     * the radial axis.
1614     *
1615     * @param title  the chart title (<code>null</code> permitted).
1616     * @param dataset  the dataset (<code>null</code> permitted).
1617     * @param legend  legend required?
1618     * @param tooltips  tooltips required?
1619     * @param urls  URLs required?
1620     *
1621     * @return A chart.
1622     */
1623    public static JFreeChart createPolarChart(String title, XYDataset dataset,
1624            boolean legend, boolean tooltips, boolean urls) {
1625
1626        PolarPlot plot = new PolarPlot();
1627        plot.setDataset(dataset);
1628        NumberAxis rangeAxis = new NumberAxis();
1629        rangeAxis.setAxisLineVisible(false);
1630        rangeAxis.setTickMarksVisible(false);
1631        rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
1632        plot.setAxis(rangeAxis);
1633        plot.setRenderer(new DefaultPolarItemRenderer());
1634        JFreeChart chart = new JFreeChart(
1635                title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1636        currentTheme.apply(chart);
1637        return chart;
1638
1639    }
1640    
1641    /**
1642     * Creates a scatter plot with default settings.  The chart object
1643     * returned by this method uses an {@link XYPlot} instance as the plot,
1644     * with a {@link NumberAxis} for the domain axis, a  {@link NumberAxis}
1645     * as the range axis, and an {@link XYLineAndShapeRenderer} as the
1646     * renderer.
1647     *
1648     * @param title  the chart title (<code>null</code> permitted).
1649     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1650     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1651     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1652     *
1653     * @return A scatter plot.
1654     * 
1655     * @since 1.0.16
1656     */
1657    public static JFreeChart createScatterPlot(String title, String xAxisLabel,
1658            String yAxisLabel, XYDataset dataset) {
1659        return createScatterPlot(title, xAxisLabel, yAxisLabel, dataset,
1660                PlotOrientation.VERTICAL, true, true, false);
1661    }
1662
1663    /**
1664     * Creates a scatter plot with default settings.  The chart object
1665     * returned by this method uses an {@link XYPlot} instance as the plot,
1666     * with a {@link NumberAxis} for the domain axis, a  {@link NumberAxis}
1667     * as the range axis, and an {@link XYLineAndShapeRenderer} as the
1668     * renderer.
1669     *
1670     * @param title  the chart title (<code>null</code> permitted).
1671     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1672     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1673     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1674     * @param orientation  the plot orientation (horizontal or vertical)
1675     *                     (<code>null</code> NOT permitted).
1676     * @param legend  a flag specifying whether or not a legend is required.
1677     * @param tooltips  configure chart to generate tool tips?
1678     * @param urls  configure chart to generate URLs?
1679     *
1680     * @return A scatter plot.
1681     */
1682    public static JFreeChart createScatterPlot(String title, String xAxisLabel,
1683            String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
1684            boolean legend, boolean tooltips, boolean urls) {
1685
1686        ParamChecks.nullNotPermitted(orientation, "orientation");
1687        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1688        xAxis.setAutoRangeIncludesZero(false);
1689        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1690        yAxis.setAutoRangeIncludesZero(false);
1691
1692        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1693
1694        XYToolTipGenerator toolTipGenerator = null;
1695        if (tooltips) {
1696            toolTipGenerator = new StandardXYToolTipGenerator();
1697        }
1698
1699        XYURLGenerator urlGenerator = null;
1700        if (urls) {
1701            urlGenerator = new StandardXYURLGenerator();
1702        }
1703        XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);
1704        renderer.setBaseToolTipGenerator(toolTipGenerator);
1705        renderer.setURLGenerator(urlGenerator);
1706        plot.setRenderer(renderer);
1707        plot.setOrientation(orientation);
1708
1709        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1710                plot, legend);
1711        currentTheme.apply(chart);
1712        return chart;
1713
1714    }
1715
1716    /**
1717     * Creates and returns a default instance of an XY bar chart.
1718     * <P>
1719     * The chart object returned by this method uses an {@link XYPlot} instance
1720     * as the plot, with a {@link DateAxis} for the domain axis, a
1721     * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the
1722     * renderer.
1723     *
1724     * @param title  the chart title (<code>null</code> permitted).
1725     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1726     * @param dateAxis  make the domain axis display dates?
1727     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1728     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1729     *
1730     * @return An XY bar chart.
1731     * 
1732     * @since 1.0.16
1733     */
1734    public static JFreeChart createXYBarChart(String title, String xAxisLabel,
1735            boolean dateAxis, String yAxisLabel, IntervalXYDataset dataset) {
1736        return createXYBarChart(title, xAxisLabel, dateAxis, yAxisLabel,
1737                dataset, PlotOrientation.VERTICAL, true, true, false);
1738    }
1739    
1740    /**
1741     * Creates and returns a default instance of an XY bar chart.
1742     * <P>
1743     * The chart object returned by this method uses an {@link XYPlot} instance
1744     * as the plot, with a {@link DateAxis} for the domain axis, a
1745     * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the
1746     * renderer.
1747     *
1748     * @param title  the chart title (<code>null</code> permitted).
1749     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1750     * @param dateAxis  make the domain axis display dates?
1751     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1752     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1753     * @param orientation  the orientation (horizontal or vertical)
1754     *                     (<code>null</code> NOT permitted).
1755     * @param legend  a flag specifying whether or not a legend is required.
1756     * @param tooltips  configure chart to generate tool tips?
1757     * @param urls  configure chart to generate URLs?
1758     *
1759     * @return An XY bar chart.
1760     */
1761    public static JFreeChart createXYBarChart(String title, String xAxisLabel,
1762            boolean dateAxis, String yAxisLabel, IntervalXYDataset dataset,
1763            PlotOrientation orientation, boolean legend, boolean tooltips,
1764            boolean urls) {
1765
1766        ParamChecks.nullNotPermitted(orientation, "orientation");
1767        ValueAxis domainAxis;
1768        if (dateAxis) {
1769            domainAxis = new DateAxis(xAxisLabel);
1770        }
1771        else {
1772            NumberAxis axis = new NumberAxis(xAxisLabel);
1773            axis.setAutoRangeIncludesZero(false);
1774            domainAxis = axis;
1775        }
1776        ValueAxis valueAxis = new NumberAxis(yAxisLabel);
1777
1778        XYBarRenderer renderer = new XYBarRenderer();
1779        if (tooltips) {
1780            XYToolTipGenerator tt;
1781            if (dateAxis) {
1782                tt = StandardXYToolTipGenerator.getTimeSeriesInstance();
1783            }
1784            else {
1785                tt = new StandardXYToolTipGenerator();
1786            }
1787            renderer.setBaseToolTipGenerator(tt);
1788        }
1789        if (urls) {
1790            renderer.setURLGenerator(new StandardXYURLGenerator());
1791        }
1792
1793        XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer);
1794        plot.setOrientation(orientation);
1795
1796        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1797                plot, legend);
1798        currentTheme.apply(chart);
1799        return chart;
1800
1801    }
1802
1803    /**
1804     * Creates an area chart using an {@link XYDataset}.
1805     * <P>
1806     * The chart object returned by this method uses an {@link XYPlot} instance
1807     * as the plot, with a {@link NumberAxis} for the domain axis, a
1808     * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as
1809     * the renderer.
1810     *
1811     * @param title  the chart title (<code>null</code> permitted).
1812     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1813     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1814     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1815     *
1816     * @return An XY area chart.
1817     * 
1818     * @since 1.0.16
1819     */
1820    public static JFreeChart createXYAreaChart(String title,String xAxisLabel,
1821            String yAxisLabel, XYDataset dataset) {
1822        return createXYAreaChart(title, xAxisLabel, yAxisLabel, dataset, 
1823                PlotOrientation.VERTICAL, true, true, false);
1824    }
1825    
1826    /**
1827     * Creates an area chart using an {@link XYDataset}.
1828     * <P>
1829     * The chart object returned by this method uses an {@link XYPlot} instance
1830     * as the plot, with a {@link NumberAxis} for the domain axis, a
1831     * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as
1832     * the renderer.
1833     *
1834     * @param title  the chart title (<code>null</code> permitted).
1835     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1836     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1837     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1838     * @param orientation  the plot orientation (horizontal or vertical)
1839     *                     (<code>null</code> NOT permitted).
1840     * @param legend  a flag specifying whether or not a legend is required.
1841     * @param tooltips  configure chart to generate tool tips?
1842     * @param urls  configure chart to generate URLs?
1843     *
1844     * @return An XY area chart.
1845     */
1846    public static JFreeChart createXYAreaChart(String title, String xAxisLabel,
1847            String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
1848            boolean legend, boolean tooltips, boolean urls) {
1849
1850        ParamChecks.nullNotPermitted(orientation, "orientation");
1851        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1852        xAxis.setAutoRangeIncludesZero(false);
1853        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1854        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1855        plot.setOrientation(orientation);
1856        plot.setForegroundAlpha(0.5f);
1857
1858        XYToolTipGenerator tipGenerator = null;
1859        if (tooltips) {
1860            tipGenerator = new StandardXYToolTipGenerator();
1861        }
1862
1863        XYURLGenerator urlGenerator = null;
1864        if (urls) {
1865            urlGenerator = new StandardXYURLGenerator();
1866        }
1867
1868        plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator,
1869                urlGenerator));
1870        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1871                plot, legend);
1872        currentTheme.apply(chart);
1873        return chart;
1874
1875    }
1876
1877    /**
1878     * Creates a stacked XY area plot.  The chart object returned by this
1879     * method uses an {@link XYPlot} instance as the plot, with a
1880     * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
1881     * range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
1882     *
1883     * @param title  the chart title (<code>null</code> permitted).
1884     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1885     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1886     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1887     *
1888     * @return A stacked XY area chart.
1889     * 
1890     * @since 1.0.16
1891     */
1892    public static JFreeChart createStackedXYAreaChart(String title,
1893            String xAxisLabel, String yAxisLabel, TableXYDataset dataset) {
1894        return createStackedXYAreaChart(title, xAxisLabel, yAxisLabel,
1895                dataset, PlotOrientation.VERTICAL, true, true, false);
1896    }
1897    
1898    /**
1899     * Creates a stacked XY area plot.  The chart object returned by this
1900     * method uses an {@link XYPlot} instance as the plot, with a
1901     * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
1902     * range axis, and a {@link StackedXYAreaRenderer2} as the renderer.
1903     *
1904     * @param title  the chart title (<code>null</code> permitted).
1905     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1906     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1907     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1908     * @param orientation  the plot orientation (horizontal or vertical)
1909     *                     (<code>null</code> NOT permitted).
1910     * @param legend  a flag specifying whether or not a legend is required.
1911     * @param tooltips  configure chart to generate tool tips?
1912     * @param urls  configure chart to generate URLs?
1913     *
1914     * @return A stacked XY area chart.
1915     */
1916    public static JFreeChart createStackedXYAreaChart(String title,
1917            String xAxisLabel, String yAxisLabel, TableXYDataset dataset,
1918            PlotOrientation orientation, boolean legend, boolean tooltips,
1919            boolean urls) {
1920
1921        ParamChecks.nullNotPermitted(orientation, "orientation");
1922        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1923        xAxis.setAutoRangeIncludesZero(false);
1924        xAxis.setLowerMargin(0.0);
1925        xAxis.setUpperMargin(0.0);
1926        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1927        XYToolTipGenerator toolTipGenerator = null;
1928        if (tooltips) {
1929            toolTipGenerator = new StandardXYToolTipGenerator();
1930        }
1931
1932        XYURLGenerator urlGenerator = null;
1933        if (urls) {
1934            urlGenerator = new StandardXYURLGenerator();
1935        }
1936        StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(
1937                toolTipGenerator, urlGenerator);
1938        renderer.setOutline(true);
1939        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1940        plot.setOrientation(orientation);
1941
1942        plot.setRangeAxis(yAxis);  // forces recalculation of the axis range
1943
1944        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1945                plot, legend);
1946        currentTheme.apply(chart);
1947        return chart;
1948
1949    }
1950
1951    /**
1952     * Creates a line chart (based on an {@link XYDataset}) with default
1953     * settings.
1954     *
1955     * @param title  the chart title (<code>null</code> permitted).
1956     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1957     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1958     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1959     *
1960     * @return The chart.
1961     */
1962    public static JFreeChart createXYLineChart(String title,
1963            String xAxisLabel, String yAxisLabel, XYDataset dataset) {
1964        return createXYLineChart(title, xAxisLabel, yAxisLabel, dataset,
1965                PlotOrientation.VERTICAL, true, true, false);
1966    }
1967
1968    /**
1969     * Creates a line chart (based on an {@link XYDataset}) with default
1970     * settings.
1971     *
1972     * @param title  the chart title (<code>null</code> permitted).
1973     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
1974     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
1975     * @param dataset  the dataset for the chart (<code>null</code> permitted).
1976     * @param orientation  the plot orientation (horizontal or vertical)
1977     *                     (<code>null</code> NOT permitted).
1978     * @param legend  a flag specifying whether or not a legend is required.
1979     * @param tooltips  configure chart to generate tool tips?
1980     * @param urls  configure chart to generate URLs?
1981     *
1982     * @return The chart.
1983     */
1984    public static JFreeChart createXYLineChart(String title, String xAxisLabel,
1985            String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
1986            boolean legend, boolean tooltips, boolean urls) {
1987
1988        ParamChecks.nullNotPermitted(orientation, "orientation");
1989        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1990        xAxis.setAutoRangeIncludesZero(false);
1991        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1992        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
1993        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1994        plot.setOrientation(orientation);
1995        if (tooltips) {
1996            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1997        }
1998        if (urls) {
1999            renderer.setURLGenerator(new StandardXYURLGenerator());
2000        }
2001
2002        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2003                plot, legend);
2004        currentTheme.apply(chart);
2005        return chart;
2006
2007    }
2008
2009    /**
2010     * Creates a stepped XY plot with default settings.
2011     *
2012     * @param title  the chart title (<code>null</code> permitted).
2013     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
2014     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
2015     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2016     *
2017     * @return A chart.
2018     * 
2019     * @since 1.0.16
2020     */
2021    public static JFreeChart createXYStepChart(String title, String xAxisLabel,
2022            String yAxisLabel, XYDataset dataset) {
2023        return createXYStepChart(title, xAxisLabel, yAxisLabel, dataset,
2024                PlotOrientation.VERTICAL, true, true, false);
2025    }
2026    
2027    /**
2028     * Creates a stepped XY plot with default settings.
2029     *
2030     * @param title  the chart title (<code>null</code> permitted).
2031     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
2032     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
2033     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2034     * @param orientation  the plot orientation (horizontal or vertical)
2035     *                     (<code>null</code> NOT permitted).
2036     * @param legend  a flag specifying whether or not a legend is required.
2037     * @param tooltips  configure chart to generate tool tips?
2038     * @param urls  configure chart to generate URLs?
2039     *
2040     * @return A chart.
2041     */
2042    public static JFreeChart createXYStepChart(String title, String xAxisLabel,
2043            String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
2044            boolean legend, boolean tooltips, boolean urls) {
2045
2046        ParamChecks.nullNotPermitted(orientation, "orientation");
2047        DateAxis xAxis = new DateAxis(xAxisLabel);
2048        NumberAxis yAxis = new NumberAxis(yAxisLabel);
2049        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
2050
2051        XYToolTipGenerator toolTipGenerator = null;
2052        if (tooltips) {
2053            toolTipGenerator = new StandardXYToolTipGenerator();
2054        }
2055
2056        XYURLGenerator urlGenerator = null;
2057        if (urls) {
2058            urlGenerator = new StandardXYURLGenerator();
2059        }
2060        XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator,
2061                urlGenerator);
2062
2063        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
2064        plot.setRenderer(renderer);
2065        plot.setOrientation(orientation);
2066        plot.setDomainCrosshairVisible(false);
2067        plot.setRangeCrosshairVisible(false);
2068        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2069                plot, legend);
2070        currentTheme.apply(chart);
2071        return chart;
2072
2073    }
2074
2075    /**
2076     * Creates a filled stepped XY plot with default settings.
2077     *
2078     * @param title  the chart title (<code>null</code> permitted).
2079     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
2080     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
2081     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2082     *
2083     * @return A chart.
2084     * 
2085     * @since 1.0.16
2086     */
2087    public static JFreeChart createXYStepAreaChart(String title,
2088            String xAxisLabel, String yAxisLabel, XYDataset dataset) {
2089        return createXYStepAreaChart(title, xAxisLabel, yAxisLabel, dataset,
2090                PlotOrientation.VERTICAL, true, true, false);   
2091    }
2092 
2093    /**
2094     * Creates a filled stepped XY plot with default settings.
2095     *
2096     * @param title  the chart title (<code>null</code> permitted).
2097     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
2098     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
2099     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2100     * @param orientation  the plot orientation (horizontal or vertical)
2101     *                     (<code>null</code> NOT permitted).
2102     * @param legend  a flag specifying whether or not a legend is required.
2103     * @param tooltips  configure chart to generate tool tips?
2104     * @param urls  configure chart to generate URLs?
2105     *
2106     * @return A chart.
2107     */
2108    public static JFreeChart createXYStepAreaChart(String title, 
2109            String xAxisLabel, String yAxisLabel, XYDataset dataset,
2110            PlotOrientation orientation, boolean legend, boolean tooltips,
2111            boolean urls) {
2112
2113        ParamChecks.nullNotPermitted(orientation, "orientation");
2114        NumberAxis xAxis = new NumberAxis(xAxisLabel);
2115        xAxis.setAutoRangeIncludesZero(false);
2116        NumberAxis yAxis = new NumberAxis(yAxisLabel);
2117
2118        XYToolTipGenerator toolTipGenerator = null;
2119        if (tooltips) {
2120            toolTipGenerator = new StandardXYToolTipGenerator();
2121        }
2122
2123        XYURLGenerator urlGenerator = null;
2124        if (urls) {
2125            urlGenerator = new StandardXYURLGenerator();
2126        }
2127        XYItemRenderer renderer = new XYStepAreaRenderer(
2128                XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator,
2129                urlGenerator);
2130
2131        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
2132        plot.setRenderer(renderer);
2133        plot.setOrientation(orientation);
2134        plot.setDomainCrosshairVisible(false);
2135        plot.setRangeCrosshairVisible(false);
2136        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2137                plot, legend);
2138        currentTheme.apply(chart);
2139        return chart;
2140    }
2141
2142    /**
2143     * Creates and returns a time series chart.  A time series chart is an
2144     * {@link XYPlot} with a {@link DateAxis} for the x-axis and a
2145     * {@link NumberAxis} for the y-axis.  The default renderer is an
2146     * {@link XYLineAndShapeRenderer}.
2147     * <P>
2148     * A convenient dataset to use with this chart is a
2149     * {@link org.jfree.data.time.TimeSeriesCollection}.
2150     *
2151     * @param title  the chart title (<code>null</code> permitted).
2152     * @param timeAxisLabel  a label for the time axis (<code>null</code>
2153     *                       permitted).
2154     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2155     *                        permitted).
2156     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2157     *
2158     * @return A time series chart.
2159     * 
2160     * @since 1.0.16
2161     */
2162    public static JFreeChart createTimeSeriesChart(String title, 
2163            String timeAxisLabel, String valueAxisLabel, XYDataset dataset) {
2164        return createTimeSeriesChart(title, timeAxisLabel, valueAxisLabel, 
2165                dataset, true, true, false);
2166    }
2167    
2168    /**
2169     * Creates and returns a time series chart.  A time series chart is an
2170     * {@link XYPlot} with a {@link DateAxis} for the x-axis and a
2171     * {@link NumberAxis} for the y-axis.  The default renderer is an
2172     * {@link XYLineAndShapeRenderer}.
2173     * <P>
2174     * A convenient dataset to use with this chart is a
2175     * {@link org.jfree.data.time.TimeSeriesCollection}.
2176     *
2177     * @param title  the chart title (<code>null</code> permitted).
2178     * @param timeAxisLabel  a label for the time axis (<code>null</code>
2179     *                       permitted).
2180     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2181     *                        permitted).
2182     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2183     * @param legend  a flag specifying whether or not a legend is required.
2184     * @param tooltips  configure chart to generate tool tips?
2185     * @param urls  configure chart to generate URLs?
2186     *
2187     * @return A time series chart.
2188     */
2189    public static JFreeChart createTimeSeriesChart(String title,
2190            String timeAxisLabel, String valueAxisLabel, XYDataset dataset,
2191            boolean legend, boolean tooltips, boolean urls) {
2192
2193        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
2194        timeAxis.setLowerMargin(0.02);  // reduce the default margins
2195        timeAxis.setUpperMargin(0.02);
2196        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2197        valueAxis.setAutoRangeIncludesZero(false);  // override default
2198        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
2199
2200        XYToolTipGenerator toolTipGenerator = null;
2201        if (tooltips) {
2202            toolTipGenerator
2203                = StandardXYToolTipGenerator.getTimeSeriesInstance();
2204        }
2205
2206        XYURLGenerator urlGenerator = null;
2207        if (urls) {
2208            urlGenerator = new StandardXYURLGenerator();
2209        }
2210
2211        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,
2212                false);
2213        renderer.setBaseToolTipGenerator(toolTipGenerator);
2214        renderer.setURLGenerator(urlGenerator);
2215        plot.setRenderer(renderer);
2216
2217        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2218                plot, legend);
2219        currentTheme.apply(chart);
2220        return chart;
2221
2222    }
2223
2224    /**
2225     * Creates and returns a default instance of a candlesticks chart.
2226     *
2227     * @param title  the chart title (<code>null</code> permitted).
2228     * @param timeAxisLabel  a label for the time axis (<code>null</code>
2229     *                       permitted).
2230     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2231     *                        permitted).
2232     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2233     * @param legend  a flag specifying whether or not a legend is required.
2234     *
2235     * @return A candlestick chart.
2236     */
2237    public static JFreeChart createCandlestickChart(String title,
2238            String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
2239            boolean legend) {
2240
2241        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
2242        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2243        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
2244        plot.setRenderer(new CandlestickRenderer());
2245        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2246                plot, legend);
2247        currentTheme.apply(chart);
2248        return chart;
2249
2250    }
2251
2252    /**
2253     * Creates and returns a default instance of a high-low-open-close chart.
2254     *
2255     * @param title  the chart title (<code>null</code> permitted).
2256     * @param timeAxisLabel  a label for the time axis (<code>null</code>
2257     *                       permitted).
2258     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2259     *                        permitted).
2260     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2261     * @param legend  a flag specifying whether or not a legend is required.
2262     *
2263     * @return A high-low-open-close chart.
2264     */
2265    public static JFreeChart createHighLowChart(String title,
2266            String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
2267            boolean legend) {
2268
2269        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
2270        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2271        HighLowRenderer renderer = new HighLowRenderer();
2272        renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
2273        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
2274        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2275                plot, legend);
2276        currentTheme.apply(chart);
2277        return chart;
2278
2279    }
2280
2281    /**
2282     * Creates and returns a default instance of a high-low-open-close chart
2283     * with a special timeline. This timeline can be a
2284     * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday
2285     * through Friday timeline that will remove Saturdays and Sundays from
2286     * the axis.
2287     *
2288     * @param title  the chart title (<code>null</code> permitted).
2289     * @param timeAxisLabel  a label for the time axis (<code>null</code>
2290     *                       permitted).
2291     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2292     *                        permitted).
2293     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2294     * @param timeline  the timeline.
2295     * @param legend  a flag specifying whether or not a legend is required.
2296     *
2297     * @return A high-low-open-close chart.
2298     */
2299    public static JFreeChart createHighLowChart(String title,
2300            String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset,
2301            Timeline timeline, boolean legend) {
2302
2303        DateAxis timeAxis = new DateAxis(timeAxisLabel);
2304        timeAxis.setTimeline(timeline);
2305        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2306        HighLowRenderer renderer = new HighLowRenderer();
2307        renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
2308        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
2309        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2310                plot, legend);
2311        currentTheme.apply(chart);
2312        return chart;
2313
2314    }
2315
2316    /**
2317     * Creates a bubble chart with default settings.  The chart is composed of
2318     * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
2319     * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
2320     * to draw the data items.
2321     *
2322     * @param title  the chart title (<code>null</code> permitted).
2323     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
2324     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
2325     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2326     *
2327     * @return A bubble chart.
2328     * 
2329     * @since 1.0.16
2330     */
2331    public static JFreeChart createBubbleChart(String title, String xAxisLabel,
2332            String yAxisLabel, XYZDataset dataset) {
2333        return createBubbleChart(title, xAxisLabel, yAxisLabel, dataset,
2334                PlotOrientation.VERTICAL, true, true, false);
2335    }
2336    
2337    /**
2338     * Creates a bubble chart with default settings.  The chart is composed of
2339     * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
2340     * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
2341     * to draw the data items.
2342     *
2343     * @param title  the chart title (<code>null</code> permitted).
2344     * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
2345     * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
2346     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2347     * @param orientation  the orientation (horizontal or vertical)
2348     *                     (<code>null</code> NOT permitted).
2349     * @param legend  a flag specifying whether or not a legend is required.
2350     * @param tooltips  configure chart to generate tool tips?
2351     * @param urls  configure chart to generate URLs?
2352     *
2353     * @return A bubble chart.
2354     */
2355    public static JFreeChart createBubbleChart(String title, String xAxisLabel,
2356            String yAxisLabel, XYZDataset dataset, PlotOrientation orientation,
2357            boolean legend, boolean tooltips, boolean urls) {
2358
2359        ParamChecks.nullNotPermitted(orientation, "orientation");
2360        NumberAxis xAxis = new NumberAxis(xAxisLabel);
2361        xAxis.setAutoRangeIncludesZero(false);
2362        NumberAxis yAxis = new NumberAxis(yAxisLabel);
2363        yAxis.setAutoRangeIncludesZero(false);
2364
2365        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
2366
2367        XYItemRenderer renderer = new XYBubbleRenderer(
2368                XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
2369        if (tooltips) {
2370            renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
2371        }
2372        if (urls) {
2373            renderer.setURLGenerator(new StandardXYZURLGenerator());
2374        }
2375        plot.setRenderer(renderer);
2376        plot.setOrientation(orientation);
2377
2378        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2379                plot, legend);
2380        currentTheme.apply(chart);
2381        return chart;
2382
2383    }
2384
2385    /**
2386     * Creates a histogram chart.  This chart is constructed with an
2387     * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range
2388     * axes are {@link NumberAxis} instances.
2389     *
2390     * @param title  the chart title (<code>null</code> permitted).
2391     * @param xAxisLabel  the x axis label (<code>null</code> permitted).
2392     * @param yAxisLabel  the y axis label (<code>null</code> permitted).
2393     * @param dataset  the dataset (<code>null</code> permitted).
2394     * @param orientation  the orientation (horizontal or vertical)
2395     *                     (<code>null</code> NOT permitted).
2396     * @param legend  create a legend?
2397     * @param tooltips  display tooltips?
2398     * @param urls  generate URLs?
2399     *
2400     * @return The chart.
2401     */
2402    public static JFreeChart createHistogram(String title,
2403            String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset,
2404            PlotOrientation orientation, boolean legend, boolean tooltips,
2405            boolean urls) {
2406
2407        ParamChecks.nullNotPermitted(orientation, "orientation");
2408        NumberAxis xAxis = new NumberAxis(xAxisLabel);
2409        xAxis.setAutoRangeIncludesZero(false);
2410        ValueAxis yAxis = new NumberAxis(yAxisLabel);
2411
2412        XYItemRenderer renderer = new XYBarRenderer();
2413        if (tooltips) {
2414            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2415        }
2416        if (urls) {
2417            renderer.setURLGenerator(new StandardXYURLGenerator());
2418        }
2419
2420        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2421        plot.setOrientation(orientation);
2422        plot.setDomainZeroBaselineVisible(true);
2423        plot.setRangeZeroBaselineVisible(true);
2424        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2425                plot, legend);
2426        currentTheme.apply(chart);
2427        return chart;
2428
2429    }
2430
2431    /**
2432     * Creates and returns a default instance of a box and whisker chart
2433     * based on data from a {@link BoxAndWhiskerCategoryDataset}.
2434     *
2435     * @param title  the chart title (<code>null</code> permitted).
2436     * @param categoryAxisLabel  a label for the category axis
2437     *     (<code>null</code> permitted).
2438     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2439     *     permitted).
2440     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2441     * @param legend  a flag specifying whether or not a legend is required.
2442     *
2443     * @return A box and whisker chart.
2444     *
2445     * @since 1.0.4
2446     */
2447    public static JFreeChart createBoxAndWhiskerChart(String title,
2448            String categoryAxisLabel, String valueAxisLabel,
2449            BoxAndWhiskerCategoryDataset dataset, boolean legend) {
2450
2451        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
2452        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2453        valueAxis.setAutoRangeIncludesZero(false);
2454
2455        BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
2456        renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
2457
2458        CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
2459                renderer);
2460        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2461                plot, legend);
2462        currentTheme.apply(chart);
2463        return chart;
2464    }
2465
2466    /**
2467     * Creates and returns a default instance of a box and whisker chart.
2468     *
2469     * @param title  the chart title (<code>null</code> permitted).
2470     * @param timeAxisLabel  a label for the time axis (<code>null</code>
2471     *                       permitted).
2472     * @param valueAxisLabel  a label for the value axis (<code>null</code>
2473     *                        permitted).
2474     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2475     * @param legend  a flag specifying whether or not a legend is required.
2476     *
2477     * @return A box and whisker chart.
2478     */
2479    public static JFreeChart createBoxAndWhiskerChart(String title,
2480            String timeAxisLabel, String valueAxisLabel,
2481            BoxAndWhiskerXYDataset dataset, boolean legend) {
2482
2483        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
2484        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2485        valueAxis.setAutoRangeIncludesZero(false);
2486        XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
2487        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
2488        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2489                plot, legend);
2490        currentTheme.apply(chart);
2491        return chart;
2492
2493    }
2494
2495    /**
2496     * Creates a wind plot with default settings.
2497     *
2498     * @param title  the chart title (<code>null</code> permitted).
2499     * @param xAxisLabel  a label for the x-axis (<code>null</code> permitted).
2500     * @param yAxisLabel  a label for the y-axis (<code>null</code> permitted).
2501     * @param dataset  the dataset for the chart (<code>null</code> permitted).
2502     * @param legend  a flag that controls whether or not a legend is created.
2503     * @param tooltips  configure chart to generate tool tips?
2504     * @param urls  configure chart to generate URLs?
2505     *
2506     * @return A wind plot.
2507     *
2508     */
2509    public static JFreeChart createWindPlot(String title, String xAxisLabel,
2510            String yAxisLabel, WindDataset dataset, boolean legend,
2511            boolean tooltips, boolean urls) {
2512
2513        ValueAxis xAxis = new DateAxis(xAxisLabel);
2514        ValueAxis yAxis = new NumberAxis(yAxisLabel);
2515        yAxis.setRange(-12.0, 12.0);
2516
2517        WindItemRenderer renderer = new WindItemRenderer();
2518        if (tooltips) {
2519            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2520        }
2521        if (urls) {
2522            renderer.setURLGenerator(new StandardXYURLGenerator());
2523        }
2524        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2525        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2526                plot, legend);
2527        currentTheme.apply(chart);
2528        return chart;
2529
2530    }
2531
2532    /**
2533     * Creates a wafer map chart.
2534     *
2535     * @param title  the chart title (<code>null</code> permitted).
2536     * @param dataset  the dataset (<code>null</code> permitted).
2537     * @param orientation  the plot orientation (horizontal or vertical)
2538     *                     (<code>null</code> NOT permitted.
2539     * @param legend  display a legend?
2540     * @param tooltips  generate tooltips?
2541     * @param urls  generate URLs?
2542     *
2543     * @return A wafer map chart.
2544     */
2545    public static JFreeChart createWaferMapChart(String title,
2546            WaferMapDataset dataset, PlotOrientation orientation,
2547            boolean legend, boolean tooltips, boolean urls) {
2548
2549        ParamChecks.nullNotPermitted(orientation, "orientation");
2550        WaferMapPlot plot = new WaferMapPlot(dataset);
2551        WaferMapRenderer renderer = new WaferMapRenderer();
2552        plot.setRenderer(renderer);
2553
2554        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2555                plot, legend);
2556        currentTheme.apply(chart);
2557        return chart;
2558    }
2559
2560}