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