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