Source for org.jfree.chart.ChartFactory

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