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