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