KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > chart > ChartFactory


1 /* ===========================================================
2  * JFreeChart : a free chart library for the Java(tm) platform
3  * ===========================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jfreechart/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
24  * in the United States and other countries.]
25  *
26  * -----------------
27  * ChartFactory.java
28  * -----------------
29  * (C) Copyright 2001-2005, by Object Refinery Limited and Contributors.
30  *
31  * Original Author: David Gilbert (for Object Refinery Limited);
32  * Contributor(s): Serge V. Grachov;
33  * Joao Guilherme Del Valle;
34  * Bill Kelemen;
35  * Jon Iles;
36  * Jelai Wang;
37  * Richard Atkinson;
38  * David Browning (for Australian Institute of Marine
39  * Science);
40  * Benoit Xhenseval;
41  *
42  * $Id: ChartFactory.java,v 1.22 2005/06/02 08:34:44 mungady Exp $
43  *
44  * Changes
45  * -------
46  * 19-Oct-2001 : Version 1, most methods transferred from JFreeChart.java (DG);
47  * 22-Oct-2001 : Added methods to create stacked bar charts (DG);
48  * Renamed DataSource.java --> Dataset.java etc. (DG);
49  * 31-Oct-2001 : Added 3D-effect vertical bar and stacked-bar charts,
50  * contributed by Serge V. Grachov (DG);
51  * 07-Nov-2001 : Added a flag to control whether or not a legend is added to
52  * the chart (DG);
53  * 17-Nov-2001 : For pie chart, changed dataset from CategoryDataset to
54  * PieDataset (DG);
55  * 30-Nov-2001 : Removed try/catch handlers from chart creation, as the
56  * exception are now RuntimeExceptions, as suggested by Joao
57  * Guilherme Del Valle (DG);
58  * 06-Dec-2001 : Added createCombinableXXXXXCharts methods (BK);
59  * 12-Dec-2001 : Added createCandlestickChart() method (DG);
60  * 13-Dec-2001 : Updated methods for charts with new renderers (DG);
61  * 08-Jan-2002 : Added import for
62  * com.jrefinery.chart.combination.CombinedChart (DG);
63  * 31-Jan-2002 : Changed the createCombinableVerticalXYBarChart() method to use
64  * renderer (DG);
65  * 06-Feb-2002 : Added new method createWindPlot() (DG);
66  * 23-Apr-2002 : Updates to the chart and plot constructor API (DG);
67  * 21-May-2002 : Added new method createAreaChart() (JI);
68  * 06-Jun-2002 : Added new method createGanttChart() (DG);
69  * 11-Jun-2002 : Renamed createHorizontalStackedBarChart()
70  * --> createStackedHorizontalBarChart() for consistency (DG);
71  * 06-Aug-2002 : Updated Javadoc comments (DG);
72  * 21-Aug-2002 : Added createPieChart(CategoryDataset) method (DG);
73  * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG);
74  * 09-Oct-2002 : Added methods including tooltips and URL flags (DG);
75  * 06-Nov-2002 : Moved renderers into a separate package (DG);
76  * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG);
77  * 21-Mar-2003 : Incorporated HorizontalCategoryAxis3D, see bug id 685501 (DG);
78  * 13-May-2003 : Merged some horizontal and vertical methods (DG);
79  * 24-May-2003 : Added support for timeline in createHighLowChart (BK);
80  * 07-Jul-2003 : Added createHistogram() method contributed by Jelai Wang (DG);
81  * 27-Jul-2003 : Added createStackedAreaXYChart() method (RA);
82  * 05-Aug-2003 : added new method createBoxAndWhiskerChart (DB);
83  * 08-Sep-2003 : Changed ValueAxis API (DG);
84  * 07-Oct-2003 : Added stepped area XY chart contributed by Matthias Rose (DG);
85  * 06-Nov-2003 : Added createWaterfallChart() method (DG);
86  * 20-Nov-2003 : Set rendering order for 3D bar charts to fix overlapping
87  * problems (DG);
88  * 25-Nov-2003 : Added createWaferMapChart() method (DG);
89  * 23-Dec-2003 : Renamed createPie3DChart() --> createPieChart3D for
90  * consistency (DG);
91  * 20-Jan-2004 : Added createPolarChart() method (DG);
92  * 28-Jan-2004 : Fixed bug (882890) with axis range in
93  * createStackedXYAreaChart() method (DG);
94  * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG);
95  * 11-Mar-2004 : Updated for pie chart changes (DG);
96  * 27-Apr-2004 : Added new createPieChart() method contributed by Benoit
97  * Xhenseval (see RFE 942195) (DG);
98  * 11-May-2004 : Split StandardCategoryItemLabelGenerator
99  * --> StandardCategoryToolTipGenerator and
100  * StandardCategoryLabelGenerator (DG);
101  * 06-Jan-2005 : Removed deprecated methods (DG);
102  * 27-Jan-2005 : Added new constructor to LineAndShapeRenderer (DG);
103  * 28-Feb-2005 : Added docs to createBubbleChart() method (DG);
104  * 17-Mar-2005 : Added createRingPlot() method (DG);
105  * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG);
106  *
107  */

108
109 package org.jfree.chart;
110
111 import java.awt.Color JavaDoc;
112 import java.awt.Font JavaDoc;
113 import java.text.DateFormat JavaDoc;
114 import java.text.NumberFormat JavaDoc;
115 import java.util.Iterator JavaDoc;
116 import java.util.List JavaDoc;
117
118 import org.jfree.chart.axis.CategoryAxis;
119 import org.jfree.chart.axis.CategoryAxis3D;
120 import org.jfree.chart.axis.DateAxis;
121 import org.jfree.chart.axis.NumberAxis;
122 import org.jfree.chart.axis.NumberAxis3D;
123 import org.jfree.chart.axis.Timeline;
124 import org.jfree.chart.axis.ValueAxis;
125 import org.jfree.chart.labels.HighLowItemLabelGenerator;
126 import org.jfree.chart.labels.IntervalCategoryToolTipGenerator;
127 import org.jfree.chart.labels.ItemLabelAnchor;
128 import org.jfree.chart.labels.ItemLabelPosition;
129 import org.jfree.chart.labels.PieToolTipGenerator;
130 import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
131 import org.jfree.chart.labels.StandardPieItemLabelGenerator;
132 import org.jfree.chart.labels.StandardXYToolTipGenerator;
133 import org.jfree.chart.labels.StandardXYZToolTipGenerator;
134 import org.jfree.chart.labels.XYToolTipGenerator;
135 import org.jfree.chart.plot.CategoryPlot;
136 import org.jfree.chart.plot.Marker;
137 import org.jfree.chart.plot.MultiplePiePlot;
138 import org.jfree.chart.plot.PiePlot;
139 import org.jfree.chart.plot.PiePlot3D;
140 import org.jfree.chart.plot.PlotOrientation;
141 import org.jfree.chart.plot.PolarPlot;
142 import org.jfree.chart.plot.RingPlot;
143 import org.jfree.chart.plot.ValueMarker;
144 import org.jfree.chart.plot.WaferMapPlot;
145 import org.jfree.chart.plot.XYPlot;
146 import org.jfree.chart.renderer.DefaultPolarItemRenderer;
147 import org.jfree.chart.renderer.WaferMapRenderer;
148 import org.jfree.chart.renderer.category.AreaRenderer;
149 import org.jfree.chart.renderer.category.BarRenderer;
150 import org.jfree.chart.renderer.category.BarRenderer3D;
151 import org.jfree.chart.renderer.category.CategoryItemRenderer;
152 import org.jfree.chart.renderer.category.GanttRenderer;
153 import org.jfree.chart.renderer.category.LineAndShapeRenderer;
154 import org.jfree.chart.renderer.category.LineRenderer3D;
155 import org.jfree.chart.renderer.category.StackedAreaRenderer;
156 import org.jfree.chart.renderer.category.StackedBarRenderer;
157 import org.jfree.chart.renderer.category.StackedBarRenderer3D;
158 import org.jfree.chart.renderer.category.WaterfallBarRenderer;
159 import org.jfree.chart.renderer.xy.CandlestickRenderer;
160 import org.jfree.chart.renderer.xy.HighLowRenderer;
161 import org.jfree.chart.renderer.xy.SignalRenderer;
162 import org.jfree.chart.renderer.xy.StackedXYAreaRenderer;
163 import org.jfree.chart.renderer.xy.StandardXYItemRenderer;
164 import org.jfree.chart.renderer.xy.WindItemRenderer;
165 import org.jfree.chart.renderer.xy.XYAreaRenderer;
166 import org.jfree.chart.renderer.xy.XYBarRenderer;
167 import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer;
168 import org.jfree.chart.renderer.xy.XYBubbleRenderer;
169 import org.jfree.chart.renderer.xy.XYItemRenderer;
170 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
171 import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
172 import org.jfree.chart.renderer.xy.XYStepRenderer;
173 import org.jfree.chart.title.TextTitle;
174 import org.jfree.chart.urls.PieURLGenerator;
175 import org.jfree.chart.urls.StandardCategoryURLGenerator;
176 import org.jfree.chart.urls.StandardPieURLGenerator;
177 import org.jfree.chart.urls.StandardXYURLGenerator;
178 import org.jfree.chart.urls.StandardXYZURLGenerator;
179 import org.jfree.chart.urls.XYURLGenerator;
180 import org.jfree.data.category.CategoryDataset;
181 import org.jfree.data.category.IntervalCategoryDataset;
182 import org.jfree.data.general.DefaultPieDataset;
183 import org.jfree.data.general.PieDataset;
184 import org.jfree.data.general.WaferMapDataset;
185 import org.jfree.data.statistics.BoxAndWhiskerXYDataset;
186 import org.jfree.data.xy.IntervalXYDataset;
187 import org.jfree.data.xy.OHLCDataset;
188 import org.jfree.data.xy.SignalsDataset;
189 import org.jfree.data.xy.TableXYDataset;
190 import org.jfree.data.xy.WindDataset;
191 import org.jfree.data.xy.XYDataset;
192 import org.jfree.data.xy.XYZDataset;
193 import org.jfree.ui.Layer;
194 import org.jfree.ui.RectangleEdge;
195 import org.jfree.ui.RectangleInsets;
196 import org.jfree.ui.TextAnchor;
197 import org.jfree.util.SortOrder;
198 import org.jfree.util.TableOrder;
199
200 /**
201  * A collection of utility methods for creating some standard charts with
202  * JFreeChart.
203  */

204 public abstract class ChartFactory {
205
206     /**
207      * Creates a pie chart with default settings.
208      * <P>
209      * The chart object returned by this method uses a {@link PiePlot} instance
210      * as the plot.
211      *
212      * @param title the chart title (<code>null</code> permitted).
213      * @param dataset the dataset for the chart (<code>null</code> permitted).
214      * @param legend a flag specifying whether or not a legend is required.
215      * @param tooltips configure chart to generate tool tips?
216      * @param urls configure chart to generate URLs?
217      *
218      * @return A pie chart.
219      */

220     public static JFreeChart createPieChart(String JavaDoc title,
221                                             PieDataset dataset,
222                                             boolean legend,
223                                             boolean tooltips,
224                                             boolean urls) {
225
226         PiePlot plot = new PiePlot(dataset);
227         plot.setLabelGenerator(new StandardPieItemLabelGenerator());
228         plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
229         if (tooltips) {
230             plot.setToolTipGenerator(
231                 new StandardPieItemLabelGenerator(
232                     StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT
233                 )
234             );
235         }
236         if (urls) {
237             plot.setURLGenerator(new StandardPieURLGenerator());
238         }
239         return new JFreeChart(
240             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
241         );
242
243     }
244
245     /**
246      * Creates a pie chart with default settings that compares 2 datasets.
247      * The colour of each section will be determined by the move from the value
248      * for the same key in <code>previousDataset</code>. ie if value1 > value2
249      * then the section will be in green (unless <code>greenForIncrease</code>
250      * is <code>false</code>, in which case it would be <code>red</code>).
251      * Each section can have a shade of red or green as the difference can be
252      * tailored between 0% (black) and percentDiffForMaxScale% (bright
253      * red/green).
254      * <p>
255      * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a
256      * difference of 5% will have a half shade of red/green, a difference of
257      * 10% or more will have a maximum shade/brightness of red/green.
258      * <P>
259      * The chart object returned by this method uses a {@link PiePlot} instance
260      * as the plot.
261      * <p>
262      * Written by <a HREF="mailto:opensource@objectlab.co.uk">Benoit
263      * Xhenseval</a>.
264      *
265      * @param title the chart title (<code>null</code> permitted).
266      * @param dataset the dataset for the chart (<code>null</code> permitted).
267      * @param previousDataset the dataset for the last run, this will be used
268      * to compare each key in the dataset
269      * @param percentDiffForMaxScale scale goes from bright red/green to black,
270      * percentDiffForMaxScale indicate the change
271      * required to reach top scale.
272      * @param greenForIncrease an increase since previousDataset will be
273      * displayed in green (decrease red) if true.
274      * @param legend a flag specifying whether or not a legend is required.
275      * @param tooltips configure chart to generate tool tips?
276      * @param urls configure chart to generate URLs?
277      * @param subTitle displays a subtitle with colour scheme if true
278      * @param showDifference create a new dataset that will show the %
279      * difference between the two datasets.
280      *
281      * @return A pie chart.
282      */

283     public static JFreeChart createPieChart(String JavaDoc title,
284                                             PieDataset dataset,
285                                             PieDataset previousDataset,
286                                             int percentDiffForMaxScale,
287                                             boolean greenForIncrease,
288                                             boolean legend,
289                                             boolean tooltips,
290                                             boolean urls,
291                                             boolean subTitle,
292                                             boolean showDifference) {
293
294         PiePlot plot = new PiePlot(dataset);
295         plot.setLabelGenerator(new StandardPieItemLabelGenerator());
296         plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
297
298         if (tooltips) {
299             plot.setToolTipGenerator(
300                 new StandardPieItemLabelGenerator(
301                     StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT
302                 )
303             );
304         }
305         if (urls) {
306             plot.setURLGenerator(new StandardPieURLGenerator());
307         }
308
309         List JavaDoc keys = dataset.getKeys();
310         DefaultPieDataset series = null;
311         if (showDifference) {
312             series = new DefaultPieDataset();
313         }
314
315         double colorPerPercent = 255.0 / percentDiffForMaxScale;
316         for (Iterator JavaDoc it = keys.iterator(); it.hasNext();) {
317             Comparable JavaDoc key = (Comparable JavaDoc) it.next();
318             Number JavaDoc newValue = dataset.getValue(key);
319             Number JavaDoc oldValue = previousDataset.getValue(key);
320             int section = dataset.getIndex(key);
321
322             if (oldValue == null) {
323                 if (greenForIncrease) {
324                     plot.setSectionPaint(section, Color.green);
325                 }
326                 else {
327                     plot.setSectionPaint(section, Color.red);
328                 }
329                 if (showDifference) {
330                     series.setValue(key + " (+100%)", newValue);
331                 }
332             }
333             else {
334                 double percentChange = (newValue.doubleValue()
335                         / oldValue.doubleValue() - 1.0) * 100.0;
336                 double shade
337                     = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
338                     : Math.abs(percentChange) * colorPerPercent);
339                 if (greenForIncrease
340                         && newValue.doubleValue() > oldValue.doubleValue()
341                         || !greenForIncrease && newValue.doubleValue()
342                         < oldValue.doubleValue()) {
343                     plot.setSectionPaint(section, new Color JavaDoc(0, (int) shade, 0));
344                 }
345                 else {
346                     plot.setSectionPaint(section, new Color JavaDoc((int) shade, 0, 0));
347                 }
348                 if (showDifference) {
349                     series.setValue(
350                         key + " (" + (percentChange >= 0 ? "+" : "")
351                         + NumberFormat.getPercentInstance().format(
352                                 percentChange / 100.0) + ")", newValue
353                     );
354                 }
355             }
356         }
357
358         if (showDifference) {
359             plot.setDataset(series);
360         }
361
362         JFreeChart chart = new JFreeChart(
363             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
364         );
365
366         if (subTitle) {
367             TextTitle subtitle = null;
368             subtitle = new TextTitle(
369                 "Bright " + (greenForIncrease ? "red" : "green")
370                 + "=change >=-" + percentDiffForMaxScale + "%, Bright "
371                 + (!greenForIncrease ? "red" : "green") + "=change >=+"
372                 + percentDiffForMaxScale + "%",
373                 new Font JavaDoc("SansSerif", Font.PLAIN, 10)
374             );
375             chart.addSubtitle(subtitle);
376         }
377
378         return chart;
379     }
380
381     /**
382      * Creates a ring chart with default settings.
383      * <P>
384      * The chart object returned by this method uses a {@link RingPlot}
385      * instance as the plot.
386      *
387      * @param title the chart title (<code>null</code> permitted).
388      * @param dataset the dataset for the chart (<code>null</code> permitted).
389      * @param legend a flag specifying whether or not a legend is required.
390      * @param tooltips configure chart to generate tool tips?
391      * @param urls configure chart to generate URLs?
392      *
393      * @return A pie chart.
394      */

395     public static JFreeChart createRingChart(String JavaDoc title,
396                                              PieDataset dataset,
397                                              boolean legend,
398                                              boolean tooltips,
399                                              boolean urls) {
400
401         RingPlot plot = new RingPlot(dataset);
402         plot.setLabelGenerator(new StandardPieItemLabelGenerator());
403         plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
404         if (tooltips) {
405             plot.setToolTipGenerator(
406                 new StandardPieItemLabelGenerator(
407                     StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT
408                 )
409             );
410         }
411         if (urls) {
412             plot.setURLGenerator(new StandardPieURLGenerator());
413         }
414         return new JFreeChart(
415             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
416         );
417
418     }
419
420     /**
421      * Creates a chart that displays multiple pie plots. The chart object
422      * returned by this method uses a {@link MultiplePiePlot} instance as the
423      * plot.
424      *
425      * @param title the chart title (<code>null</code> permitted).
426      * @param dataset the dataset (<code>null</code> permitted).
427      * @param order the order that the data is extracted (by row or by column)
428      * (<code>null</code> not permitted).
429      * @param legend include a legend?
430      * @param tooltips generate tooltips?
431      * @param urls generate URLs?
432      *
433      * @return A chart.
434      */

435     public static JFreeChart createMultiplePieChart(String JavaDoc title,
436                                                     CategoryDataset dataset,
437                                                     TableOrder order,
438                                                     boolean legend,
439                                                     boolean tooltips,
440                                                     boolean urls) {
441
442         if (order == null) {
443             throw new IllegalArgumentException JavaDoc("Null 'order' argument.");
444         }
445         MultiplePiePlot plot = new MultiplePiePlot(dataset);
446         plot.setDataExtractOrder(order);
447         plot.setBackgroundPaint(null);
448         plot.setOutlineStroke(null);
449
450         if (tooltips) {
451             PieToolTipGenerator tooltipGenerator
452                 = new StandardPieItemLabelGenerator();
453             PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
454             pp.setToolTipGenerator(tooltipGenerator);
455         }
456
457         if (urls) {
458             PieURLGenerator urlGenerator = new StandardPieURLGenerator();
459             PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
460             pp.setURLGenerator(urlGenerator);
461         }
462
463         JFreeChart chart = new JFreeChart(
464             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
465         );
466
467         return chart;
468
469     }
470
471     /**
472      * Creates a 3D pie chart using the specified dataset. The chart object
473      * returned by this method uses a {@link PiePlot3D} instance as the
474      * plot.
475      *
476      * @param title the chart title (<code>null</code> permitted).
477      * @param dataset the dataset for the chart (<code>null</code> permitted).
478      * @param legend a flag specifying whether or not a legend is required.
479      * @param tooltips configure chart to generate tool tips?
480      * @param urls configure chart to generate URLs?
481      *
482      * @return A pie chart.
483      */

484     public static JFreeChart createPieChart3D(String JavaDoc title,
485                                               PieDataset dataset,
486                                               boolean legend,
487                                               boolean tooltips,
488                                               boolean urls) {
489
490         PiePlot3D plot = new PiePlot3D(dataset);
491         plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
492         if (tooltips) {
493             plot.setToolTipGenerator(new StandardPieItemLabelGenerator());
494         }
495         if (urls) {
496             plot.setURLGenerator(new StandardPieURLGenerator());
497         }
498         return new JFreeChart(
499             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
500         );
501
502     }
503
504     /**
505      * Creates a chart that displays multiple pie plots. The chart object
506      * returned by this method uses a {@link MultiplePiePlot} instance as the
507      * plot.
508      *
509      * @param title the chart title (<code>null</code> permitted).
510      * @param dataset the dataset (<code>null</code> permitted).
511      * @param order the order that the data is extracted (by row or by column)
512      * (<code>null</code> not permitted).
513      * @param legend include a legend?
514      * @param tooltips generate tooltips?
515      * @param urls generate URLs?
516      *
517      * @return A chart.
518      */

519     public static JFreeChart createMultiplePieChart3D(String JavaDoc title,
520                                                       CategoryDataset dataset,
521                                                       TableOrder order,
522                                                       boolean legend,
523                                                       boolean tooltips,
524                                                       boolean urls) {
525
526         if (order == null) {
527             throw new IllegalArgumentException JavaDoc("Null 'order' argument.");
528         }
529         MultiplePiePlot plot = new MultiplePiePlot(dataset);
530         plot.setDataExtractOrder(order);
531         plot.setBackgroundPaint(null);
532         plot.setOutlineStroke(null);
533
534         JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
535         TextTitle seriesTitle = new TextTitle(
536             "Series Title", new Font JavaDoc("SansSerif", Font.BOLD, 12)
537         );
538         seriesTitle.setPosition(RectangleEdge.BOTTOM);
539         pieChart.setTitle(seriesTitle);
540         pieChart.removeLegend();
541         pieChart.setBackgroundPaint(null);
542         plot.setPieChart(pieChart);
543
544         if (tooltips) {
545             PieToolTipGenerator tooltipGenerator
546                 = new StandardPieItemLabelGenerator();
547             PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
548             pp.setToolTipGenerator(tooltipGenerator);
549         }
550
551         if (urls) {
552             PieURLGenerator urlGenerator = new StandardPieURLGenerator();
553             PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
554             pp.setURLGenerator(urlGenerator);
555         }
556
557         JFreeChart chart = new JFreeChart(
558             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
559         );
560
561         return chart;
562
563     }
564
565     /**
566      * Creates a bar chart. The chart object returned by this method uses a
567      * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
568      * for the domain axis, a {@link NumberAxis} as the range axis, and a
569      * {@link BarRenderer} as the renderer.
570      *
571      * @param title the chart title (<code>null</code> permitted).
572      * @param categoryAxisLabel the label for the category axis
573      * (<code>null</code> permitted).
574      * @param valueAxisLabel the label for the value axis
575      * (<code>null</code> permitted).
576      * @param dataset the dataset for the chart (<code>null</code> permitted).
577      * @param orientation the plot orientation (horizontal or vertical)
578      * (<code>null</code> not permitted).
579      * @param legend a flag specifying whether or not a legend is required.
580      * @param tooltips configure chart to generate tool tips?
581      * @param urls configure chart to generate URLs?
582      *
583      * @return A bar chart.
584      */

585     public static JFreeChart createBarChart(String JavaDoc title,
586                                             String JavaDoc categoryAxisLabel,
587                                             String JavaDoc valueAxisLabel,
588                                             CategoryDataset dataset,
589                                             PlotOrientation orientation,
590                                             boolean legend,
591                                             boolean tooltips,
592                                             boolean urls) {
593
594         if (orientation == null) {
595             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
596         }
597         CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
598         ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
599
600         BarRenderer renderer = new BarRenderer();
601         if (orientation == PlotOrientation.HORIZONTAL) {
602             ItemLabelPosition position1 = new ItemLabelPosition(
603                 ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT
604             );
605             renderer.setPositiveItemLabelPosition(position1);
606             ItemLabelPosition position2 = new ItemLabelPosition(
607                 ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT
608             );
609             renderer.setNegativeItemLabelPosition(position2);
610          }
611         else if (orientation == PlotOrientation.VERTICAL) {
612             ItemLabelPosition position1 = new ItemLabelPosition(
613                 ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER
614             );
615             renderer.setPositiveItemLabelPosition(position1);
616             ItemLabelPosition position2 = new ItemLabelPosition(
617                 ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER
618             );
619             renderer.setNegativeItemLabelPosition(position2);
620         }
621         if (tooltips) {
622             renderer.setBaseToolTipGenerator(
623                 new StandardCategoryToolTipGenerator()
624             );
625         }
626         if (urls) {
627             renderer.setBaseItemURLGenerator(
628                 new StandardCategoryURLGenerator()
629             );
630         }
631
632         CategoryPlot plot = new CategoryPlot(
633             dataset, categoryAxis, valueAxis, renderer
634         );
635         plot.setOrientation(orientation);
636         JFreeChart chart = new JFreeChart(
637             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
638         );
639
640         return chart;
641
642     }
643
644     /**
645      * Creates a stacked bar chart with default settings. The chart object
646      * returned by this method uses a {@link CategoryPlot} instance as the
647      * plot, with a {@link CategoryAxis} for the domain axis, a
648      * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}
649      * as the renderer.
650      *
651      * @param title the chart title (<code>null</code> permitted).
652      * @param domainAxisLabel the label for the category axis
653      * (<code>null</code> permitted).
654      * @param rangeAxisLabel the label for the value axis
655      * (<code>null</code> permitted).
656      * @param dataset the dataset for the chart (<code>null</code> permitted).
657      * @param orientation the orientation of the chart (horizontal or
658      * vertical) (<code>null</code> not permitted).
659      * @param legend a flag specifying whether or not a legend is required.
660      * @param tooltips configure chart to generate tool tips?
661      * @param urls configure chart to generate URLs?
662      *
663      * @return A stacked bar chart.
664      */

665     public static JFreeChart createStackedBarChart(String JavaDoc title,
666                                                    String JavaDoc domainAxisLabel,
667                                                    String JavaDoc rangeAxisLabel,
668                                                    CategoryDataset dataset,
669                                                    PlotOrientation orientation,
670                                                    boolean legend,
671                                                    boolean tooltips,
672                                                    boolean urls) {
673
674         if (orientation == null) {
675             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
676         }
677
678         CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
679         ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);
680
681         StackedBarRenderer renderer = new StackedBarRenderer();
682         if (tooltips) {
683             renderer.setBaseToolTipGenerator(
684                 new StandardCategoryToolTipGenerator()
685             );
686         }
687         if (urls) {
688             renderer.setBaseItemURLGenerator(
689                 new StandardCategoryURLGenerator()
690             );
691         }
692
693         CategoryPlot plot = new CategoryPlot(
694             dataset, categoryAxis, valueAxis, renderer
695         );
696         plot.setOrientation(orientation);
697         JFreeChart chart = new JFreeChart(
698             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
699         );
700
701         return chart;
702
703     }
704
705     /**
706      * Creates a bar chart with a 3D effect. The chart object returned by this
707      * method uses a {@link CategoryPlot} instance as the plot, with a
708      * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
709      * the range axis, and a {@link BarRenderer3D} as the renderer.
710      *
711      * @param title the chart title (<code>null</code> permitted).
712      * @param categoryAxisLabel the label for the category axis
713      * (<code>null</code> permitted).
714      * @param valueAxisLabel the label for the value axis (<code>null</code>
715      * permitted).
716      * @param dataset the dataset for the chart (<code>null</code> permitted).
717      * @param orientation the plot orientation (horizontal or vertical)
718      * (<code>null</code> not permitted).
719      * @param legend a flag specifying whether or not a legend is required.
720      * @param tooltips configure chart to generate tool tips?
721      * @param urls configure chart to generate URLs?
722      *
723      * @return A bar chart with a 3D effect.
724      */

725     public static JFreeChart createBarChart3D(String JavaDoc title,
726                                               String JavaDoc categoryAxisLabel,
727                                               String JavaDoc valueAxisLabel,
728                                               CategoryDataset dataset,
729                                               PlotOrientation orientation,
730                                               boolean legend,
731                                               boolean tooltips,
732                                               boolean urls) {
733
734         if (orientation == null) {
735             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
736         }
737         CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
738         ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
739
740         BarRenderer3D renderer = new BarRenderer3D();
741         if (tooltips) {
742             renderer.setBaseToolTipGenerator(
743                 new StandardCategoryToolTipGenerator()
744             );
745         }
746         if (urls) {
747             renderer.setBaseItemURLGenerator(
748                 new StandardCategoryURLGenerator()
749             );
750         }
751
752         CategoryPlot plot = new CategoryPlot(
753             dataset, categoryAxis, valueAxis, renderer
754         );
755         plot.setOrientation(orientation);
756         if (orientation == PlotOrientation.HORIZONTAL) {
757             // change rendering order to ensure that bar overlapping is the
758
// right way around
759
plot.setRowRenderingOrder(SortOrder.DESCENDING);
760             plot.setColumnRenderingOrder(SortOrder.DESCENDING);
761         }
762         plot.setForegroundAlpha(0.75f);
763
764         JFreeChart chart = new JFreeChart(
765             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
766         );
767
768         return chart;
769
770     }
771
772     /**
773      * Creates a stacked bar chart with a 3D effect and default settings. The
774      * chart object returned by this method uses a {@link CategoryPlot}
775      * instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
776      * a {@link NumberAxis3D} as the range axis, and a
777      * {@link StackedBarRenderer3D} as the renderer.
778      *
779      * @param title the chart title (<code>null</code> permitted).
780      * @param categoryAxisLabel the label for the category axis
781      * (<code>null</code> permitted).
782      * @param valueAxisLabel the label for the value axis (<code>null</code>
783      * permitted).
784      * @param dataset the dataset for the chart (<code>null</code> permitted).
785      * @param orientation the orientation (horizontal or vertical)
786      * (<code>null</code> not permitted).
787      * @param legend a flag specifying whether or not a legend is required.
788      * @param tooltips configure chart to generate tool tips?
789      * @param urls configure chart to generate URLs?
790      *
791      * @return A stacked bar chart with a 3D effect.
792      */

793     public static JFreeChart createStackedBarChart3D(String JavaDoc title,
794                                                     String JavaDoc categoryAxisLabel,
795                                                     String JavaDoc valueAxisLabel,
796                                                     CategoryDataset dataset,
797                                                     PlotOrientation orientation,
798                                                     boolean legend,
799                                                     boolean tooltips,
800                                                     boolean urls) {
801
802         if (orientation == null) {
803             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
804         }
805         CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
806         ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
807
808         // create the renderer...
809
CategoryItemRenderer renderer = new StackedBarRenderer3D();
810         if (tooltips) {
811             renderer.setBaseToolTipGenerator(
812                 new StandardCategoryToolTipGenerator()
813             );
814         }
815         if (urls) {
816             renderer.setBaseItemURLGenerator(
817                 new StandardCategoryURLGenerator()
818             );
819         }
820
821         // create the plot...
822
CategoryPlot plot = new CategoryPlot(
823             dataset, categoryAxis, valueAxis, renderer
824         );
825         plot.setOrientation(orientation);
826         if (orientation == PlotOrientation.HORIZONTAL) {
827             // change rendering order to ensure that bar overlapping is the
828
// right way around
829
plot.setColumnRenderingOrder(SortOrder.DESCENDING);
830         }
831
832         // create the chart...
833
JFreeChart chart = new JFreeChart(
834             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
835         );
836
837         return chart;
838
839     }
840
841     /**
842      * Creates an area chart with default settings. The chart object returned
843      * by this method uses a {@link CategoryPlot} instance as the plot, with a
844      * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
845      * range axis, and an {@link AreaRenderer} as the renderer.
846      *
847      * @param title the chart title (<code>null</code> permitted).
848      * @param categoryAxisLabel the label for the category axis
849      * (<code>null</code> permitted).
850      * @param valueAxisLabel the label for the value axis (<code>null</code>
851      * permitted).
852      * @param dataset the dataset for the chart (<code>null</code> permitted).
853      * @param orientation the plot orientation (<code>null</code> not
854      * permitted).
855      * @param legend a flag specifying whether or not a legend is required.
856      * @param tooltips configure chart to generate tool tips?
857      * @param urls configure chart to generate URLs?
858      *
859      * @return An area chart.
860      */

861     public static JFreeChart createAreaChart(String JavaDoc title,
862                                              String JavaDoc categoryAxisLabel,
863                                              String JavaDoc valueAxisLabel,
864                                              CategoryDataset dataset,
865                                              PlotOrientation orientation,
866                                              boolean legend,
867                                              boolean tooltips,
868                                              boolean urls) {
869
870         if (orientation == null) {
871             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
872         }
873         CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
874         categoryAxis.setCategoryMargin(0.0);
875
876         ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
877
878         AreaRenderer renderer = new AreaRenderer();
879         if (tooltips) {
880             renderer.setBaseToolTipGenerator(
881                 new StandardCategoryToolTipGenerator()
882             );
883         }
884         if (urls) {
885             renderer.setBaseItemURLGenerator(
886                 new StandardCategoryURLGenerator()
887             );
888         }
889
890         CategoryPlot plot = new CategoryPlot(
891             dataset, categoryAxis, valueAxis, renderer
892         );
893         plot.setOrientation(orientation);
894         JFreeChart chart = new JFreeChart(
895             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
896         );
897
898         return chart;
899
900     }
901
902     /**
903      * Creates a stacked area chart with default settings. The chart object
904      * returned by this method uses a {@link CategoryPlot} instance as the
905      * plot, with a {@link CategoryAxis} for the domain axis, a
906      * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer}
907      * as the renderer.
908      *
909      * @param title the chart title (<code>null</code> permitted).
910      * @param categoryAxisLabel the label for the category axis
911      * (<code>null</code> permitted).
912      * @param valueAxisLabel the label for the value axis (<code>null</code>
913      * permitted).
914      * @param dataset the dataset for the chart (<code>null</code> permitted).
915      * @param orientation the plot orientation (horizontal or vertical)
916      * (<code>null</code> not permitted).
917      * @param legend a flag specifying whether or not a legend is required.
918      * @param tooltips configure chart to generate tool tips?
919      * @param urls configure chart to generate URLs?
920      *
921      * @return A stacked area chart.
922      */

923     public static JFreeChart createStackedAreaChart(String JavaDoc title,
924                                                     String JavaDoc categoryAxisLabel,
925                                                     String JavaDoc valueAxisLabel,
926                                                     CategoryDataset dataset,
927                                                     PlotOrientation orientation,
928                                                     boolean legend,
929                                                     boolean tooltips,
930                                                     boolean urls) {
931
932         if (orientation == null) {
933             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
934         }
935         CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
936         ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
937
938         StackedAreaRenderer renderer = new StackedAreaRenderer();
939         if (tooltips) {
940             renderer.setBaseToolTipGenerator(
941                 new StandardCategoryToolTipGenerator()
942             );
943         }
944         if (urls) {
945             renderer.setBaseItemURLGenerator(
946                 new StandardCategoryURLGenerator()
947             );
948         }
949
950         CategoryPlot plot = new CategoryPlot(
951             dataset, categoryAxis, valueAxis, renderer
952         );
953         plot.setOrientation(orientation);
954         JFreeChart chart = new JFreeChart(
955             title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
956         );
957
958         return chart;
959
960     }
961
962     /**
963      * Creates a line chart with default settings. The chart object returned
964      * by this method uses a {@link CategoryPlot} instance as the plot, with a
965      * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
966      * range axis, and a {@link LineAndShapeRenderer} as the renderer.
967      *
968      * @param title the chart title (<code>null</code> permitted).
969      * @param categoryAxisLabel the label for the category axis
970      * (<code>null</code> permitted).
971      * @param valueAxisLabel the label for the value axis (<code>null</code>
972      * permitted).
973      * @param dataset the dataset for the chart (<code>null</code> permitted).
974      * @param orientation the chart orientation (horizontal or vertical)
975      * (<code>null</code> not permitted).
976      * @param legend a flag specifying whether or not a legend is required.
977      * @param tooltips configure chart to generate tool tips?
978      * @param urls configure chart to generate URLs?
979      *
980      * @return A line chart.
981      */

982     public static JFreeChart createLineChart(String JavaDoc title,
983                                              String JavaDoc categoryAxisLabel,
984                                              String JavaDoc valueAxisLabel,
985                                              CategoryDataset dataset,
986                                              PlotOrientation orientation,
987                                              boolean legend,
988                                              boolean tooltips,
989                                              boolean urls) {
990
991         if (orientation == null) {
992             throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
993         }
994         CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
995         ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
996
997         LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
998         if (tooltips) {
999             renderer.setBaseToolTipGenerator(
1000                new StandardCategoryToolTipGenerator()
1001            );
1002        }
1003        if (urls) {
1004            renderer.setBaseItemURLGenerator(
1005                new StandardCategoryURLGenerator()
1006            );
1007        }
1008        CategoryPlot plot = new CategoryPlot(
1009            dataset, categoryAxis, valueAxis, renderer
1010        );
1011        plot.setOrientation(orientation);
1012        JFreeChart chart = new JFreeChart(
1013            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1014        );
1015
1016        return chart;
1017
1018    }
1019
1020    /**
1021     * Creates a line chart with default settings. The chart object returned by
1022     * this method uses a {@link CategoryPlot} instance as the plot, with a
1023     * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
1024     * the range axis, and a {@link LineRenderer3D} as the renderer.
1025     *
1026     * @param title the chart title (<code>null</code> permitted).
1027     * @param categoryAxisLabel the label for the category axis
1028     * (<code>null</code> permitted).
1029     * @param valueAxisLabel the label for the value axis (<code>null</code>
1030     * permitted).
1031     * @param dataset the dataset for the chart (<code>null</code> permitted).
1032     * @param orientation the chart orientation (horizontal or vertical)
1033     * (<code>null</code> not permitted).
1034     * @param legend a flag specifying whether or not a legend is required.
1035     * @param tooltips configure chart to generate tool tips?
1036     * @param urls configure chart to generate URLs?
1037     *
1038     * @return A line chart.
1039     */

1040    public static JFreeChart createLineChart3D(String JavaDoc title,
1041                                               String JavaDoc categoryAxisLabel,
1042                                               String JavaDoc valueAxisLabel,
1043                                               CategoryDataset dataset,
1044                                               PlotOrientation orientation,
1045                                               boolean legend,
1046                                               boolean tooltips,
1047                                               boolean urls) {
1048
1049        if (orientation == null) {
1050            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1051        }
1052        CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
1053        ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
1054
1055        LineRenderer3D renderer = new LineRenderer3D();
1056        if (tooltips) {
1057            renderer.setBaseToolTipGenerator(
1058                new StandardCategoryToolTipGenerator()
1059            );
1060        }
1061        if (urls) {
1062            renderer.setBaseItemURLGenerator(
1063                new StandardCategoryURLGenerator()
1064            );
1065        }
1066        CategoryPlot plot = new CategoryPlot(
1067            dataset, categoryAxis, valueAxis, renderer
1068        );
1069        plot.setOrientation(orientation);
1070        JFreeChart chart = new JFreeChart(
1071            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1072        );
1073
1074        return chart;
1075
1076    }
1077
1078    /**
1079     * Creates a Gantt chart using the supplied attributes plus default values
1080     * where required. The chart object returned by this method uses a
1081     * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
1082     * for the domain axis, a {@link DateAxis} as the range axis, and a
1083     * {@link GanttRenderer} as the renderer.
1084     *
1085     * @param title the chart title (<code>null</code> permitted).
1086     * @param categoryAxisLabel the label for the category axis
1087     * (<code>null</code> permitted).
1088     * @param dateAxisLabel the label for the date axis
1089     * (<code>null</code> permitted).
1090     * @param dataset the dataset for the chart (<code>null</code> permitted).
1091     * @param legend a flag specifying whether or not a legend is required.
1092     * @param tooltips configure chart to generate tool tips?
1093     * @param urls configure chart to generate URLs?
1094     *
1095     * @return A Gantt chart.
1096     */

1097    public static JFreeChart createGanttChart(String JavaDoc title,
1098                                              String JavaDoc categoryAxisLabel,
1099                                              String JavaDoc dateAxisLabel,
1100                                              IntervalCategoryDataset dataset,
1101                                              boolean legend,
1102                                              boolean tooltips,
1103                                              boolean urls) {
1104
1105        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1106        DateAxis dateAxis = new DateAxis(dateAxisLabel);
1107
1108        CategoryItemRenderer renderer = new GanttRenderer();
1109        if (tooltips) {
1110            renderer.setBaseToolTipGenerator(
1111                new IntervalCategoryToolTipGenerator(
1112                    "{3} - {4}", DateFormat.getDateInstance()
1113                )
1114            );
1115        }
1116        if (urls) {
1117            renderer.setBaseItemURLGenerator(
1118                new StandardCategoryURLGenerator()
1119            );
1120        }
1121
1122        CategoryPlot plot = new CategoryPlot(
1123            dataset, categoryAxis, dateAxis, renderer
1124        );
1125        plot.setOrientation(PlotOrientation.HORIZONTAL);
1126        JFreeChart chart = new JFreeChart(
1127            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1128        );
1129
1130        return chart;
1131
1132    }
1133
1134    /**
1135     * Creates a waterfall chart. The chart object returned by this method
1136     * uses a {@link CategoryPlot} instance as the plot, with a
1137     * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
1138     * range axis, and a {@link WaterfallBarRenderer} as the renderer.
1139     *
1140     * @param title the chart title (<code>null</code> permitted).
1141     * @param categoryAxisLabel the label for the category axis
1142     * (<code>null</code> permitted).
1143     * @param valueAxisLabel the label for the value axis (<code>null</code>
1144     * permitted).
1145     * @param dataset the dataset for the chart (<code>null</code> permitted).
1146     * @param orientation the plot orientation (horizontal or vertical)
1147     * (<code>null</code> NOT permitted).
1148     * @param legend a flag specifying whether or not a legend is required.
1149     * @param tooltips configure chart to generate tool tips?
1150     * @param urls configure chart to generate URLs?
1151     *
1152     * @return A waterfall chart.
1153     */

1154    public static JFreeChart createWaterfallChart(String JavaDoc title,
1155                                                  String JavaDoc categoryAxisLabel,
1156                                                  String JavaDoc valueAxisLabel,
1157                                                  CategoryDataset dataset,
1158                                                  PlotOrientation orientation,
1159                                                  boolean legend,
1160                                                  boolean tooltips,
1161                                                  boolean urls) {
1162
1163        if (orientation == null) {
1164            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1165        }
1166        CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1167        categoryAxis.setCategoryMargin(0.0);
1168
1169        ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1170
1171        WaterfallBarRenderer renderer = new WaterfallBarRenderer();
1172        if (orientation == PlotOrientation.HORIZONTAL) {
1173            ItemLabelPosition position = new ItemLabelPosition(
1174                ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1175                TextAnchor.CENTER, Math.PI / 2.0
1176            );
1177            renderer.setPositiveItemLabelPosition(position);
1178            renderer.setNegativeItemLabelPosition(position);
1179         }
1180        else if (orientation == PlotOrientation.VERTICAL) {
1181            ItemLabelPosition position = new ItemLabelPosition(
1182                ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1183                TextAnchor.CENTER, 0.0
1184            );
1185            renderer.setPositiveItemLabelPosition(position);
1186            renderer.setNegativeItemLabelPosition(position);
1187        }
1188        if (tooltips) {
1189            StandardCategoryToolTipGenerator generator
1190                = new StandardCategoryToolTipGenerator();
1191            renderer.setBaseToolTipGenerator(generator);
1192        }
1193        if (urls) {
1194            renderer.setBaseItemURLGenerator(
1195                new StandardCategoryURLGenerator()
1196            );
1197        }
1198
1199        CategoryPlot plot = new CategoryPlot(
1200            dataset, categoryAxis, valueAxis, renderer
1201        );
1202        plot.clearRangeMarkers();
1203        Marker baseline = new ValueMarker(0.0);
1204        baseline.setPaint(Color.black);
1205        plot.addRangeMarker(baseline, Layer.FOREGROUND);
1206        plot.setOrientation(orientation);
1207        JFreeChart chart = new JFreeChart(
1208            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1209        );
1210
1211        return chart;
1212
1213    }
1214
1215    /**
1216     * Creates a polar plot for the specified dataset (x-values interpreted as
1217     * angles in degrees). The chart object returned by this method uses a
1218     * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for
1219     * the radial axis.
1220     *
1221     * @param title the chart title (<code>null</code> permitted).
1222     * @param dataset the dataset (<code>null</code> permitted).
1223     * @param legend legend required?
1224     * @param tooltips tooltips required?
1225     * @param urls URLs required?
1226     *
1227     * @return A chart.
1228     */

1229    public static JFreeChart createPolarChart(String JavaDoc title,
1230                                              XYDataset dataset,
1231                                              boolean legend,
1232                                              boolean tooltips,
1233                                              boolean urls) {
1234
1235        PolarPlot plot = new PolarPlot();
1236        plot.setDataset(dataset);
1237        NumberAxis rangeAxis = new NumberAxis();
1238        rangeAxis.setAxisLineVisible(false);
1239        rangeAxis.setTickMarksVisible(false);
1240        rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
1241        plot.setAxis(rangeAxis);
1242        plot.setRenderer(new DefaultPolarItemRenderer());
1243        JFreeChart chart = new JFreeChart(
1244            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1245        );
1246        return chart;
1247
1248    }
1249
1250    /**
1251     * Creates a scatter plot with default settings.
1252     * <P>
1253     * The chart object returned by this method uses an {@link XYPlot} instance
1254     * as the plot, with a {@link NumberAxis} for the domain axis, a
1255     * {@link NumberAxis} as the range axis, and a
1256     * {@link StandardXYItemRenderer} as the renderer.
1257     *
1258     * @param title the chart title (<code>null</code> permitted).
1259     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1260     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1261     * @param dataset the dataset for the chart (<code>null</code> permitted).
1262     * @param orientation the plot orientation (horizontal or vertical)
1263     * (<code>null</code> NOT permitted).
1264     * @param legend a flag specifying whether or not a legend is required.
1265     * @param tooltips configure chart to generate tool tips?
1266     * @param urls configure chart to generate URLs?
1267     *
1268     * @return A scatter plot.
1269     */

1270    public static JFreeChart createScatterPlot(String JavaDoc title,
1271                                               String JavaDoc xAxisLabel,
1272                                               String JavaDoc yAxisLabel,
1273                                               XYDataset dataset,
1274                                               PlotOrientation orientation,
1275                                               boolean legend,
1276                                               boolean tooltips,
1277                                               boolean urls) {
1278
1279        if (orientation == null) {
1280            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1281        }
1282        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1283        xAxis.setAutoRangeIncludesZero(false);
1284        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1285        yAxis.setAutoRangeIncludesZero(false);
1286
1287        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1288
1289        XYToolTipGenerator toolTipGenerator = null;
1290        if (tooltips) {
1291            toolTipGenerator = new StandardXYToolTipGenerator();
1292        }
1293
1294        XYURLGenerator urlGenerator = null;
1295        if (urls) {
1296            urlGenerator = new StandardXYURLGenerator();
1297        }
1298        XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);
1299        renderer.setBaseToolTipGenerator(toolTipGenerator);
1300        renderer.setURLGenerator(urlGenerator);
1301        plot.setRenderer(renderer);
1302        plot.setOrientation(orientation);
1303
1304        JFreeChart chart = new JFreeChart(
1305            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1306        );
1307
1308        return chart;
1309
1310    }
1311
1312    /**
1313     * Creates and returns a default instance of an XY bar chart.
1314     * <P>
1315     * The chart object returned by this method uses an {@link XYPlot} instance
1316     * as the plot, with a {@link DateAxis} for the domain axis, a
1317     * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the
1318     * renderer.
1319     *
1320     * @param title the chart title (<code>null</code> permitted).
1321     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1322     * @param dateAxis make the domain axis display dates?
1323     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1324     * @param dataset the dataset for the chart (<code>null</code> permitted).
1325     * @param orientation the orientation (horizontal or vertical)
1326     * (<code>null</code> NOT permitted).
1327     * @param legend a flag specifying whether or not a legend is required.
1328     * @param tooltips configure chart to generate tool tips?
1329     * @param urls configure chart to generate URLs?
1330     *
1331     * @return An XY bar chart.
1332     */

1333    public static JFreeChart createXYBarChart(String JavaDoc title,
1334                                              String JavaDoc xAxisLabel,
1335                                              boolean dateAxis,
1336                                              String JavaDoc yAxisLabel,
1337                                              IntervalXYDataset dataset,
1338                                              PlotOrientation orientation,
1339                                              boolean legend,
1340                                              boolean tooltips,
1341                                              boolean urls) {
1342
1343        if (orientation == null) {
1344            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1345        }
1346        ValueAxis domainAxis = null;
1347        if (dateAxis) {
1348            domainAxis = new DateAxis(xAxisLabel);
1349        }
1350        else {
1351            NumberAxis axis = new NumberAxis(xAxisLabel);
1352            axis.setAutoRangeIncludesZero(false);
1353            domainAxis = axis;
1354        }
1355        ValueAxis valueAxis = new NumberAxis(yAxisLabel);
1356
1357        XYBarRenderer renderer = new XYBarRenderer();
1358        if (tooltips) {
1359            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1360        }
1361        if (urls) {
1362            renderer.setURLGenerator(new StandardXYURLGenerator());
1363        }
1364
1365        XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer);
1366        plot.setOrientation(orientation);
1367
1368        JFreeChart chart = new JFreeChart(
1369            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1370        );
1371
1372        return chart;
1373
1374    }
1375
1376    /**
1377     * Creates an area chart using an {@link XYDataset}.
1378     * <P>
1379     * The chart object returned by this method uses an {@link XYPlot} instance
1380     * as the plot, with a {@link NumberAxis} for the domain axis, a
1381     * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as
1382     * the renderer.
1383     *
1384     * @param title the chart title (<code>null</code> permitted).
1385     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1386     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1387     * @param dataset the dataset for the chart (<code>null</code> permitted).
1388     * @param orientation the plot orientation (horizontal or vertical)
1389     * (<code>null</code> NOT permitted).
1390     * @param legend a flag specifying whether or not a legend is required.
1391     * @param tooltips configure chart to generate tool tips?
1392     * @param urls configure chart to generate URLs?
1393     *
1394     * @return An XY area chart.
1395     */

1396    public static JFreeChart createXYAreaChart(String JavaDoc title,
1397                                               String JavaDoc xAxisLabel,
1398                                               String JavaDoc yAxisLabel,
1399                                               XYDataset dataset,
1400                                               PlotOrientation orientation,
1401                                               boolean legend,
1402                                               boolean tooltips,
1403                                               boolean urls) {
1404
1405        if (orientation == null) {
1406            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1407        }
1408        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1409        xAxis.setAutoRangeIncludesZero(false);
1410        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1411        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1412        plot.setOrientation(orientation);
1413        plot.setForegroundAlpha(0.5f);
1414
1415        XYToolTipGenerator tipGenerator = null;
1416        if (tooltips) {
1417            tipGenerator = new StandardXYToolTipGenerator();
1418        }
1419
1420        XYURLGenerator urlGenerator = null;
1421        if (urls) {
1422            urlGenerator = new StandardXYURLGenerator();
1423        }
1424
1425        plot.setRenderer(
1426            new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator)
1427        );
1428        JFreeChart chart = new JFreeChart(
1429            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1430        );
1431
1432        return chart;
1433
1434    }
1435
1436    /**
1437     * Creates a stacked XY area plot. The chart object returned by this
1438     * method uses an {@link XYPlot} instance as the plot, with a
1439     * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the
1440     * range axis, and a {@link StackedXYAreaRenderer} as the renderer.
1441     *
1442     * @param title the chart title (<code>null</code> permitted).
1443     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1444     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1445     * @param dataset the dataset for the chart (<code>null</code> permitted).
1446     * @param orientation the plot orientation (horizontal or vertical)
1447     * (<code>null</code> NOT permitted).
1448     * @param legend a flag specifying whether or not a legend is required.
1449     * @param tooltips configure chart to generate tool tips?
1450     * @param urls configure chart to generate URLs?
1451     *
1452     * @return A stacked XY area chart.
1453     */

1454    public static JFreeChart createStackedXYAreaChart(String JavaDoc title,
1455                                                    String JavaDoc xAxisLabel,
1456                                                    String JavaDoc yAxisLabel,
1457                                                    TableXYDataset dataset,
1458                                                    PlotOrientation orientation,
1459                                                    boolean legend,
1460                                                    boolean tooltips,
1461                                                    boolean urls) {
1462
1463        if (orientation == null) {
1464            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1465        }
1466        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1467        xAxis.setAutoRangeIncludesZero(false);
1468        xAxis.setLowerMargin(0.0);
1469        xAxis.setUpperMargin(0.0);
1470        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1471        XYToolTipGenerator toolTipGenerator = null;
1472        if (tooltips) {
1473            toolTipGenerator = new StandardXYToolTipGenerator();
1474        }
1475
1476        XYURLGenerator urlGenerator = null;
1477        if (urls) {
1478            urlGenerator = new StandardXYURLGenerator();
1479        }
1480        StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(
1481            XYAreaRenderer.AREA, toolTipGenerator, urlGenerator
1482        );
1483        renderer.setOutline(true);
1484        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1485        plot.setOrientation(orientation);
1486
1487        plot.setRangeAxis(yAxis); // forces recalculation of the axis range
1488

1489        JFreeChart chart = new JFreeChart(
1490            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1491        );
1492        return chart;
1493
1494    }
1495
1496    /**
1497     * Creates a line chart (based on an {@link XYDataset}) with default
1498     * settings.
1499     *
1500     * @param title the chart title (<code>null</code> permitted).
1501     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1502     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1503     * @param dataset the dataset for the chart (<code>null</code> permitted).
1504     * @param orientation the plot orientation (horizontal or vertical)
1505     * (<code>null</code> NOT permitted).
1506     * @param legend a flag specifying whether or not a legend is required.
1507     * @param tooltips configure chart to generate tool tips?
1508     * @param urls configure chart to generate URLs?
1509     *
1510     * @return The chart.
1511     */

1512    public static JFreeChart createXYLineChart(String JavaDoc title,
1513                                               String JavaDoc xAxisLabel,
1514                                               String JavaDoc yAxisLabel,
1515                                               XYDataset dataset,
1516                                               PlotOrientation orientation,
1517                                               boolean legend,
1518                                               boolean tooltips,
1519                                               boolean urls) {
1520
1521        if (orientation == null) {
1522            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1523        }
1524        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1525        xAxis.setAutoRangeIncludesZero(false);
1526        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1527        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
1528        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1529        plot.setOrientation(orientation);
1530        if (tooltips) {
1531            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1532        }
1533        if (urls) {
1534            renderer.setURLGenerator(new StandardXYURLGenerator());
1535        }
1536
1537        JFreeChart chart = new JFreeChart(
1538            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1539        );
1540
1541        return chart;
1542
1543    }
1544
1545    /**
1546     * Creates a stepped XY plot with default settings.
1547     *
1548     * @param title the chart title (<code>null</code> permitted).
1549     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1550     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1551     * @param dataset the dataset for the chart (<code>null</code> permitted).
1552     * @param orientation the plot orientation (horizontal or vertical)
1553     * (<code>null</code> NOT permitted).
1554     * @param legend a flag specifying whether or not a legend is required.
1555     * @param tooltips configure chart to generate tool tips?
1556     * @param urls configure chart to generate URLs?
1557     *
1558     * @return A chart.
1559     */

1560    public static JFreeChart createXYStepChart(String JavaDoc title,
1561                                               String JavaDoc xAxisLabel,
1562                                               String JavaDoc yAxisLabel,
1563                                               XYDataset dataset,
1564                                               PlotOrientation orientation,
1565                                               boolean legend,
1566                                               boolean tooltips,
1567                                               boolean urls) {
1568
1569        if (orientation == null) {
1570            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1571        }
1572        DateAxis xAxis = new DateAxis(xAxisLabel);
1573        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1574        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
1575
1576        XYToolTipGenerator toolTipGenerator = null;
1577        if (tooltips) {
1578            toolTipGenerator = new StandardXYToolTipGenerator();
1579        }
1580
1581        XYURLGenerator urlGenerator = null;
1582        if (urls) {
1583            urlGenerator = new StandardXYURLGenerator();
1584        }
1585        XYItemRenderer renderer
1586            = new XYStepRenderer(toolTipGenerator, urlGenerator);
1587
1588        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1589        plot.setRenderer(renderer);
1590        plot.setOrientation(orientation);
1591        plot.setDomainCrosshairVisible(false);
1592        plot.setRangeCrosshairVisible(false);
1593        JFreeChart chart = new JFreeChart(
1594            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1595        );
1596        return chart;
1597
1598    }
1599
1600    /**
1601     * Creates a filled stepped XY plot with default settings.
1602     *
1603     * @param title the chart title (<code>null</code> permitted).
1604     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1605     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1606     * @param dataset the dataset for the chart (<code>null</code> permitted).
1607     * @param orientation the plot orientation (horizontal or vertical)
1608     * (<code>null</code> NOT permitted).
1609     * @param legend a flag specifying whether or not a legend is required.
1610     * @param tooltips configure chart to generate tool tips?
1611     * @param urls configure chart to generate URLs?
1612     *
1613     * @return A chart.
1614     */

1615    public static JFreeChart createXYStepAreaChart(String JavaDoc title,
1616                                                   String JavaDoc xAxisLabel,
1617                                                   String JavaDoc yAxisLabel,
1618                                                   XYDataset dataset,
1619                                                   PlotOrientation orientation,
1620                                                   boolean legend,
1621                                                   boolean tooltips,
1622                                                   boolean urls) {
1623
1624        if (orientation == null) {
1625            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1626        }
1627        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1628        xAxis.setAutoRangeIncludesZero(false);
1629        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1630
1631        XYToolTipGenerator toolTipGenerator = null;
1632        if (tooltips) {
1633            toolTipGenerator = new StandardXYToolTipGenerator();
1634        }
1635
1636        XYURLGenerator urlGenerator = null;
1637        if (urls) {
1638            urlGenerator = new StandardXYURLGenerator();
1639        }
1640        XYItemRenderer renderer = new XYStepAreaRenderer(
1641            XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, urlGenerator
1642        );
1643
1644        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1645        plot.setRenderer(renderer);
1646        plot.setOrientation(orientation);
1647        plot.setDomainCrosshairVisible(false);
1648        plot.setRangeCrosshairVisible(false);
1649        JFreeChart chart = new JFreeChart(
1650            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1651        );
1652        return chart;
1653    }
1654
1655    /**
1656     * Creates and returns a time series chart. A time series chart is an
1657     * {@link XYPlot} with a {@link DateAxis} for the x-axis and a
1658     * {@link NumberAxis} for the y-axis. The default renderer is an
1659     * {@link XYLineAndShapeRenderer}.
1660     * <P>
1661     * A convenient dataset to use with this chart is a
1662     * {@link org.jfree.data.time.TimeSeriesCollection}.
1663     *
1664     * @param title the chart title (<code>null</code> permitted).
1665     * @param timeAxisLabel a label for the time axis (<code>null</code>
1666     * permitted).
1667     * @param valueAxisLabel a label for the value axis (<code>null</code>
1668     * permitted).
1669     * @param dataset the dataset for the chart (<code>null</code> permitted).
1670     * @param legend a flag specifying whether or not a legend is required.
1671     * @param tooltips configure chart to generate tool tips?
1672     * @param urls configure chart to generate URLs?
1673     *
1674     * @return A time series chart.
1675     */

1676    public static JFreeChart createTimeSeriesChart(String JavaDoc title,
1677                                                   String JavaDoc timeAxisLabel,
1678                                                   String JavaDoc valueAxisLabel,
1679                                                   XYDataset dataset,
1680                                                   boolean legend,
1681                                                   boolean tooltips,
1682                                                   boolean urls) {
1683
1684        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1685        timeAxis.setLowerMargin(0.02); // reduce the default margins
1686
timeAxis.setUpperMargin(0.02);
1687        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1688        valueAxis.setAutoRangeIncludesZero(false); // override default
1689
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1690
1691        XYToolTipGenerator toolTipGenerator = null;
1692        if (tooltips) {
1693            toolTipGenerator
1694                = StandardXYToolTipGenerator.getTimeSeriesInstance();
1695        }
1696
1697        XYURLGenerator urlGenerator = null;
1698        if (urls) {
1699            urlGenerator = new StandardXYURLGenerator();
1700        }
1701
1702        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
1703        renderer.setDefaultLinesVisible(true);
1704        renderer.setDefaultShapesVisible(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 JavaDoc title,
1730                                                    String JavaDoc timeAxisLabel,
1731                                                    String JavaDoc 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 JavaDoc title,
1760                                                String JavaDoc timeAxisLabel,
1761                                                String JavaDoc 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 JavaDoc title,
1796                                                String JavaDoc timeAxisLabel,
1797                                                String JavaDoc 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 and returns a default instance of a signal chart.
1817     *
1818     * @param title the chart title (<code>null</code> permitted).
1819     * @param timeAxisLabel a label for the time axis (<code>null</code>
1820     * permitted).
1821     * @param valueAxisLabel a label for the value axis (<code>null</code>
1822     * permitted).
1823     * @param dataset the dataset for the chart (<code>null</code> permitted).
1824     * @param legend a flag specifying whether or not a legend is required.
1825     *
1826     * @return A signal chart.
1827     */

1828    public static JFreeChart createSignalChart(String JavaDoc title,
1829                                               String JavaDoc timeAxisLabel,
1830                                               String JavaDoc valueAxisLabel,
1831                                               SignalsDataset dataset,
1832                                               boolean legend) {
1833
1834        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1835        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1836        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1837        plot.setRenderer(new SignalRenderer());
1838        JFreeChart chart = new JFreeChart(
1839            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1840        );
1841        return chart;
1842
1843    }
1844
1845    /**
1846     * Creates a bubble chart with default settings. The chart is composed of
1847     * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
1848     * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
1849     * to draw the data items.
1850     *
1851     * @param title the chart title (<code>null</code> permitted).
1852     * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
1853     * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
1854     * @param dataset the dataset for the chart (<code>null</code> permitted).
1855     * @param orientation the orientation (horizontal or vertical)
1856     * (<code>null</code> NOT permitted).
1857     * @param legend a flag specifying whether or not a legend is required.
1858     * @param tooltips configure chart to generate tool tips?
1859     * @param urls configure chart to generate URLs?
1860     *
1861     * @return A bubble chart.
1862     */

1863    public static JFreeChart createBubbleChart(String JavaDoc title,
1864                                               String JavaDoc xAxisLabel,
1865                                               String JavaDoc yAxisLabel,
1866                                               XYZDataset dataset,
1867                                               PlotOrientation orientation,
1868                                               boolean legend,
1869                                               boolean tooltips,
1870                                               boolean urls) {
1871
1872        if (orientation == null) {
1873            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1874        }
1875        NumberAxis xAxis = new NumberAxis(xAxisLabel);
1876        xAxis.setAutoRangeIncludesZero(false);
1877        NumberAxis yAxis = new NumberAxis(yAxisLabel);
1878        yAxis.setAutoRangeIncludesZero(false);
1879
1880        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1881
1882        XYItemRenderer renderer = new XYBubbleRenderer(
1883            XYBubbleRenderer.SCALE_ON_RANGE_AXIS
1884        );
1885        if (tooltips) {
1886            renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
1887        }
1888        if (urls) {
1889            renderer.setURLGenerator(new StandardXYZURLGenerator());
1890        }
1891        plot.setRenderer(renderer);
1892        plot.setOrientation(orientation);
1893
1894        JFreeChart chart = new JFreeChart(
1895            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1896        );
1897
1898        return chart;
1899
1900    }
1901
1902    /**
1903     * Creates a histogram chart. This chart is constructed with an
1904     * {@link XYPlot} using an {@link XYBarRenderer}. The domain and range
1905     * axes are {@link NumberAxis} instances.
1906     *
1907     * @param title the chart title (<code>null</code> permitted).
1908     * @param xAxisLabel the x axis label (<code>null</code> permitted).
1909     * @param yAxisLabel the y axis label (<code>null</code> permitted).
1910     * @param dataset the dataset (<code>null</code> permitted).
1911     * @param orientation the orientation (horizontal or vertical)
1912     * (<code>null</code> NOT permitted).
1913     * @param legend create a legend?
1914     * @param tooltips display tooltips?
1915     * @param urls generate URLs?
1916     *
1917     * @return The chart.
1918     */

1919    public static JFreeChart createHistogram(String JavaDoc title,
1920                                             String JavaDoc xAxisLabel,
1921                                             String JavaDoc yAxisLabel,
1922                                             IntervalXYDataset dataset,
1923                                             PlotOrientation orientation,
1924                                             boolean legend,
1925                                             boolean tooltips,
1926                                             boolean urls) {
1927
1928        if (orientation == null) {
1929            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
1930        }
1931        ValueAxis xAxis = new NumberAxis(xAxisLabel);
1932        ValueAxis yAxis = new NumberAxis(yAxisLabel);
1933
1934        XYItemRenderer renderer = new XYBarRenderer();
1935        if (tooltips) {
1936            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1937        }
1938        if (urls) {
1939            renderer.setURLGenerator(new StandardXYURLGenerator());
1940        }
1941
1942        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1943        plot.setOrientation(orientation);
1944        JFreeChart chart = new JFreeChart(
1945            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1946        );
1947        return chart;
1948
1949    }
1950
1951    /**
1952     * Creates and returns a default instance of a box and whisker chart.
1953     *
1954     * @param title the chart title (<code>null</code> permitted).
1955     * @param timeAxisLabel a label for the time axis (<code>null</code>
1956     * permitted).
1957     * @param valueAxisLabel a label for the value axis (<code>null</code>
1958     * permitted).
1959     * @param dataset the dataset for the chart (<code>null</code> permitted).
1960     * @param legend a flag specifying whether or not a legend is required.
1961     *
1962     * @return A box and whisker chart.
1963     */

1964    public static JFreeChart createBoxAndWhiskerChart(String JavaDoc title,
1965                                                 String JavaDoc timeAxisLabel,
1966                                                 String JavaDoc valueAxisLabel,
1967                                                 BoxAndWhiskerXYDataset dataset,
1968                                                 boolean legend) {
1969
1970        ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1971        NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1972        valueAxis.setAutoRangeIncludesZero(false);
1973        XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
1974        XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1975        return new JFreeChart(
1976            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
1977        );
1978
1979    }
1980
1981    /**
1982     * Creates a wind plot with default settings.
1983     *
1984     * @param title the chart title (<code>null</code> permitted).
1985     * @param xAxisLabel a label for the x-axis (<code>null</code> permitted).
1986     * @param yAxisLabel a label for the y-axis (<code>null</code> permitted).
1987     * @param dataset the dataset for the chart (<code>null</code> permitted).
1988     * @param legend a flag that controls whether or not a legend is created.
1989     * @param tooltips configure chart to generate tool tips?
1990     * @param urls configure chart to generate URLs?
1991     *
1992     * @return A wind plot.
1993     *
1994     */

1995    public static JFreeChart createWindPlot(String JavaDoc title,
1996                                            String JavaDoc xAxisLabel,
1997                                            String JavaDoc yAxisLabel,
1998                                            WindDataset dataset,
1999                                            boolean legend,
2000                                            boolean tooltips,
2001                                            boolean urls) {
2002
2003        ValueAxis xAxis = new DateAxis(xAxisLabel);
2004        ValueAxis yAxis = new NumberAxis(yAxisLabel);
2005        yAxis.setRange(-12.0, 12.0);
2006
2007        WindItemRenderer renderer = new WindItemRenderer();
2008        if (tooltips) {
2009            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2010        }
2011        if (urls) {
2012            renderer.setURLGenerator(new StandardXYURLGenerator());
2013        }
2014        XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2015        JFreeChart chart = new JFreeChart(
2016            title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend
2017        );
2018
2019        return chart;
2020
2021    }
2022
2023    /**
2024     * Creates a wafer map chart.
2025     *
2026     * @param title the chart title (<code>null</code> permitted).
2027     * @param dataset the dataset (<code>null</code> permitted).
2028     * @param orientation the plot orientation (horizontal or vertical)
2029     * (<code>null</code> NOT permitted.
2030     * @param legend display a legend?
2031     * @param tooltips generate tooltips?
2032     * @param urls generate URLs?
2033     *
2034     * @return A wafer map chart.
2035     */

2036    public static JFreeChart createWaferMapChart(String JavaDoc title,
2037                                                 WaferMapDataset dataset,
2038                                                 PlotOrientation orientation,
2039                                                 boolean legend,
2040                                                 boolean tooltips,
2041                                                 boolean urls) {
2042
2043        if (orientation == null) {
2044            throw new IllegalArgumentException JavaDoc("Null 'orientation' argument.");
2045        }
2046        WaferMapPlot plot = new WaferMapPlot(dataset);
2047        WaferMapRenderer renderer = new WaferMapRenderer();
2048        plot.setRenderer(renderer);
2049
2050        JFreeChart chart = new JFreeChart(
2051            title,
2052            JFreeChart.DEFAULT_TITLE_FONT,
2053            plot,
2054            legend
2055        );
2056
2057        return chart;
2058    }
2059
2060}
2061
Popular Tags