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