1 43 44 package org.jfree.chart.demo; 45 46 import java.awt.Color ; 47 import java.awt.Font ; 48 import java.awt.GradientPaint ; 49 import java.lang.reflect.Method ; 50 import java.util.Calendar ; 51 import java.util.Date ; 52 import java.util.ResourceBundle ; 53 54 import org.jfree.chart.ChartFactory; 55 import org.jfree.chart.JFreeChart; 56 import org.jfree.chart.Legend; 57 import org.jfree.chart.Spacer; 58 import org.jfree.chart.TextTitle; 59 import org.jfree.chart.axis.DateAxis; 60 import org.jfree.chart.axis.LogarithmicAxis; 61 import org.jfree.chart.axis.NumberAxis; 62 import org.jfree.chart.axis.ValueAxis; 63 import org.jfree.chart.labels.HighLowToolTipGenerator; 64 import org.jfree.chart.labels.TimeSeriesToolTipGenerator; 65 import org.jfree.chart.plot.CategoryPlot; 66 import org.jfree.chart.plot.CombinedDomainXYPlot; 67 import org.jfree.chart.plot.CombinedRangeXYPlot; 68 import org.jfree.chart.plot.CompassPlot; 69 import org.jfree.chart.plot.DialShape; 70 import org.jfree.chart.plot.MeterPlot; 71 import org.jfree.chart.plot.PiePlot; 72 import org.jfree.chart.plot.Plot; 73 import org.jfree.chart.plot.PlotOrientation; 74 import org.jfree.chart.plot.ThermometerPlot; 75 import org.jfree.chart.plot.XYPlot; 76 import org.jfree.chart.renderer.HighLowRenderer; 77 import org.jfree.chart.renderer.StandardXYItemRenderer; 78 import org.jfree.chart.renderer.XYBarRenderer; 79 import org.jfree.chart.renderer.XYItemRenderer; 80 import org.jfree.data.CategoryDataset; 81 import org.jfree.data.CombinedDataset; 82 import org.jfree.data.DatasetUtilities; 83 import org.jfree.data.DefaultValueDataset; 84 import org.jfree.data.HighLowDataset; 85 import org.jfree.data.IntervalCategoryDataset; 86 import org.jfree.data.MovingAverage; 87 import org.jfree.data.PieDataset; 88 import org.jfree.data.SignalsDataset; 89 import org.jfree.data.SubSeriesDataset; 90 import org.jfree.data.WindDataset; 91 import org.jfree.data.XYDataset; 92 import org.jfree.data.gantt.Task; 93 import org.jfree.data.gantt.TaskSeries; 94 import org.jfree.data.gantt.TaskSeriesCollection; 95 import org.jfree.data.time.SimpleTimePeriod; 96 import org.jfree.data.time.TimeSeries; 97 import org.jfree.data.time.TimeSeriesCollection; 98 99 108 public class JFreeChartDemoBase { 109 110 120 public static final String [][] CHART_COMMANDS = { 121 {"HORIZONTAL_BAR_CHART", "createHorizontalBarChart", "chart1"}, 122 {"HORIZONTAL_STACKED_BAR_CHART", "createStackedHorizontalBarChart", "chart2"}, 123 {"VERTICAL_BAR_CHART", "createVerticalBarChart", "chart3"}, 124 {"VERTICAL_3D_BAR_CHART", "createVertical3DBarChart", "chart4"}, 125 {"VERTICAL_STACKED_BAR_CHART", "createVerticalStackedBarChart", "chart5"}, 126 {"VERTICAL_STACKED_3D_BAR_CHART", "createVerticalStacked3DBarChart", "chart6"}, 127 {"PIE_CHART_1", "createPieChartOne", "chart7"}, 128 {"PIE_CHART_2", "createPieChartTwo", "chart8"}, 129 {"XY_PLOT", "createXYPlot", "chart9"}, 130 {"TIME_SERIES_1_CHART", "createTimeSeries1Chart", "chart10"}, 131 {"TIME_SERIES_2_CHART", "createTimeSeries2Chart", "chart11"}, 132 {"TIME_SERIES_WITH_MA_CHART", "createTimeSeriesWithMAChart", "chart12"}, 133 {"HIGH_LOW_CHART", "createHighLowChart", "chart13"}, 134 {"CANDLESTICK_CHART", "createCandlestickChart", "chart14"}, 135 {"SIGNAL_CHART", "createSignalChart", "chart15"}, 136 {"WIND_PLOT", "createWindPlot", "chart16"}, 137 {"SCATTER_PLOT", "createScatterPlot", "chart17"}, 138 {"LINE_CHART", "createLineChart", "chart18"}, 139 {"VERTICAL_XY_BAR_CHART", "createVerticalXYBarChart", "chart19"}, 140 {"XY_PLOT_NULL", "createNullXYPlot", "chart20"}, 141 {"XY_PLOT_ZERO", "createXYPlotZeroData", "chart21"}, 142 {"TIME_SERIES_CHART_SCROLL", "createTimeSeriesChartInScrollPane", "chart22"}, 143 {"SINGLE_SERIES_BAR_CHART", "createSingleSeriesBarChart", "chart23"}, 144 {"DYNAMIC_CHART", "createDynamicXYChart", "chart24"}, 145 {"OVERLAID_CHART", "createOverlaidChart", "chart25"}, 146 {"HORIZONTALLY_COMBINED_CHART", "createHorizontallyCombinedChart", "chart26"}, 147 {"VERTICALLY_COMBINED_CHART", "createVerticallyCombinedChart", "chart27"}, 148 {"COMBINED_OVERLAID_CHART", "createCombinedAndOverlaidChart1", "chart28"}, 149 {"COMBINED_OVERLAID_DYNAMIC_CHART", "createCombinedAndOverlaidDynamicXYChart", "chart29"}, 150 {"THERMOMETER_CHART", "createThermometerChart", "chart30"}, 151 {"METER_CHART", "createMeterChartCircle", "chart31"}, 152 {"GANTT_CHART", "createGanttChart", "chart32"}, 153 {"METER_CHART2", "createMeterChartPie", "chart33"}, 154 {"METER_CHART3", "createMeterChartChord", "chart34"}, 155 {"COMPASS_CHART", "createCompassChart", "chart35"}, 156 }; 157 158 159 public static final String BASE_RESOURCE_CLASS 160 = "org.jfree.chart.demo.resources.DemoResources"; 161 162 163 private ResourceBundle resources; 164 165 166 private JFreeChart[] charts = new JFreeChart[CHART_COMMANDS.length]; 167 168 171 public JFreeChartDemoBase() { 172 this.resources = ResourceBundle.getBundle(BASE_RESOURCE_CLASS); 173 } 174 175 182 public JFreeChart getChart(int i) { 183 184 if ((i < 0) && (i >= charts.length)) { 185 i = 0; 186 } 187 188 if (charts[i] == null) { 189 try { 191 Method method = getClass().getDeclaredMethod(CHART_COMMANDS[i][1], null); 192 charts[i] = (JFreeChart) method.invoke(this, null); 193 } 194 catch (Exception ex) { 195 ex.printStackTrace(); 196 } 197 } 198 return charts[i]; 199 } 200 201 206 public ResourceBundle getResources() { 207 return this.resources; 208 } 209 210 215 public JFreeChart createHorizontalBarChart() { 216 217 String title = resources.getString("bar.horizontal.title"); 219 String domain = resources.getString("bar.horizontal.domain"); 220 String range = resources.getString("bar.horizontal.range"); 221 222 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 223 JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data, 224 PlotOrientation.HORIZONTAL, 225 true, 226 true, 227 false); 228 229 chart.getLegend().setAnchor(Legend.EAST); 231 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.orange)); 232 CategoryPlot plot = chart.getCategoryPlot(); 233 plot.setRangeCrosshairVisible(false); 234 NumberAxis axis = (NumberAxis) plot.getRangeAxis(); 235 axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 236 axis.setInverted(true); 237 238 return chart; 239 240 } 241 242 247 public JFreeChart createStackedHorizontalBarChart() { 248 249 String title = resources.getString("bar.horizontal-stacked.title"); 251 String domain = resources.getString("bar.horizontal-stacked.domain"); 252 String range = resources.getString("bar.horizontal-stacked.range"); 253 254 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 255 JFreeChart chart = ChartFactory.createStackedBarChart(title, domain, range, 256 data, 257 PlotOrientation.HORIZONTAL, 258 true, 259 true, 260 false); 261 262 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.blue)); 264 return chart; 265 266 } 267 268 273 public JFreeChart createVerticalBarChart() { 274 275 String title = resources.getString("bar.vertical.title"); 276 String domain = resources.getString("bar.vertical.domain"); 277 String range = resources.getString("bar.vertical.range"); 278 279 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 280 JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data, 281 PlotOrientation.VERTICAL, 282 true, 283 true, 284 false); 285 286 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.red)); 288 CategoryPlot plot = (CategoryPlot) chart.getPlot(); 289 plot.setForegroundAlpha(0.9f); 290 NumberAxis verticalAxis = (NumberAxis) plot.getRangeAxis(); 291 verticalAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 292 return chart; 293 } 294 295 300 public JFreeChart createVertical3DBarChart() { 301 302 String title = resources.getString("bar.vertical3D.title"); 304 String domain = resources.getString("bar.vertical3D.domain"); 305 String range = resources.getString("bar.vertical3D.range"); 306 307 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 308 JFreeChart chart = ChartFactory.createBarChart3D( 309 title, 310 domain, 311 range, data, 312 PlotOrientation.VERTICAL, 313 true, 314 true, 315 false 316 ); 317 318 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.blue)); 320 CategoryPlot plot = (CategoryPlot) chart.getPlot(); 321 plot.setForegroundAlpha(0.75f); 322 return chart; 323 324 } 325 326 331 public JFreeChart createVerticalStackedBarChart() { 332 333 String title = resources.getString("bar.vertical-stacked.title"); 335 String domain = resources.getString("bar.vertical-stacked.domain"); 336 String range = resources.getString("bar.vertical-stacked.range"); 337 338 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 339 JFreeChart chart 340 = ChartFactory.createStackedBarChart(title, domain, range, data, 341 PlotOrientation.VERTICAL, 342 true, 343 true, 344 false); 345 346 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.red)); 348 return chart; 349 350 } 351 352 357 public JFreeChart createVerticalStacked3DBarChart() { 358 359 String title = resources.getString("bar.vertical-stacked3D.title"); 361 String domain = resources.getString("bar.vertical-stacked3D.domain"); 362 String range = resources.getString("bar.vertical-stacked3D.range"); 363 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 364 JFreeChart chart = ChartFactory.createStackedBarChart3D(title, domain, range, data, 365 PlotOrientation.VERTICAL, 366 true, true, false); 367 368 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.red)); 370 return chart; 371 372 } 373 374 379 public JFreeChart createPieChartOne() { 380 381 String title = resources.getString("pie.pie1.title"); 383 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 384 PieDataset extracted = DatasetUtilities.createPieDatasetForRow(data, 0); 385 JFreeChart chart = ChartFactory.createPieChart(title, extracted, true, true, false); 386 387 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.orange)); 389 PiePlot plot = (PiePlot) chart.getPlot(); 390 plot.setCircular(false); 391 plot.setRadius(0.60); 393 plot.setExplodePercent(1, 1.00); 394 return chart; 395 396 } 397 398 403 public JFreeChart createPieChartTwo() { 404 405 String title = resources.getString("pie.pie2.title"); 407 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 408 Comparable category = (Comparable ) data.getColumnKeys().get(1); 409 PieDataset extracted = DatasetUtilities.createPieDatasetForColumn(data, category); 410 JFreeChart chart = ChartFactory.createPieChart(title, extracted, true, true, false); 411 412 chart.setBackgroundPaint(Color.lightGray); 414 PiePlot pie = (PiePlot) chart.getPlot(); 415 pie.setSectionLabelType(PiePlot.NAME_AND_PERCENT_LABELS); 416 pie.setBackgroundImage(JFreeChart.INFO.getLogo()); 417 pie.setBackgroundPaint(Color.white); 418 pie.setBackgroundAlpha(0.6f); 419 pie.setForegroundAlpha(0.75f); 420 return chart; 421 422 } 423 424 429 public JFreeChart createXYPlot() { 430 431 String title = resources.getString("xyplot.sample1.title"); 433 String domain = resources.getString("xyplot.sample1.domain"); 434 String range = resources.getString("xyplot.sample1.range"); 435 XYDataset data = DemoDatasetFactory.createSampleXYDataset(); 436 JFreeChart chart = ChartFactory.createXYLineChart( 437 title, 438 domain, range, data, 439 PlotOrientation.VERTICAL, 440 true, 441 true, 442 false 443 ); 444 445 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.green)); 447 return chart; 448 449 } 450 451 456 public JFreeChart createTimeSeries1Chart() { 457 458 String title = resources.getString("timeseries.sample1.title"); 460 String subtitle = resources.getString("timeseries.sample1.subtitle"); 461 String domain = resources.getString("timeseries.sample1.domain"); 462 String range = resources.getString("timeseries.sample1.range"); 463 String copyrightStr = resources.getString("timeseries.sample1.copyright"); 464 XYDataset data = DemoDatasetFactory.createTimeSeriesCollection3(); 465 JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, 466 true, 467 true, 468 false); 469 470 TextTitle title2 = new TextTitle(subtitle, new Font ("SansSerif", Font.PLAIN, 12)); 472 title2.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.0)); 473 chart.addSubtitle(title2); 474 475 TextTitle copyright = new TextTitle(copyrightStr, new Font ("SansSerif", Font.PLAIN, 9)); 476 copyright.setPosition(TextTitle.BOTTOM); 477 copyright.setHorizontalAlignment(TextTitle.RIGHT); 478 chart.addSubtitle(copyright); 479 480 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 481 XYPlot plot = chart.getXYPlot(); 482 DateAxis axis = (DateAxis) plot.getDomainAxis(); 483 axis.setVerticalTickLabels(true); 484 return chart; 485 486 } 487 488 493 public JFreeChart createTimeSeries2Chart() { 494 495 String title = resources.getString("timeseries.sample2.title"); 497 String subtitleStr = resources.getString("timeseries.sample2.subtitle"); 498 String domain = resources.getString("timeseries.sample2.domain"); 499 String range = resources.getString("timeseries.sample2.range"); 500 XYDataset data = DemoDatasetFactory.createTimeSeriesCollection4(); 501 JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, 502 true, true, false); 503 504 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 506 chart.addSubtitle(subtitle); 507 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 508 XYPlot plot = chart.getXYPlot(); 509 LogarithmicAxis rangeAxis = new LogarithmicAxis(range); 510 plot.setRangeAxis(rangeAxis); 511 return chart; 512 513 } 514 515 520 public JFreeChart createTimeSeriesWithMAChart() { 521 522 String title = resources.getString("timeseries.sample3.title"); 524 String domain = resources.getString("timeseries.sample3.domain"); 525 String range = resources.getString("timeseries.sample3.range"); 526 String subtitleStr = resources.getString("timeseries.sample3.subtitle"); 527 TimeSeries jpy = DemoDatasetFactory.createJPYTimeSeries(); 528 TimeSeries mav = MovingAverage.createMovingAverage(jpy, "30 Day Moving Average", 30, 30); 529 TimeSeriesCollection dataset = new TimeSeriesCollection(); 530 dataset.addSeries(jpy); 531 dataset.addSeries(mav); 532 JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, dataset, 533 true, 534 true, 535 false); 536 537 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 539 chart.addSubtitle(subtitle); 540 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 541 return chart; 542 543 } 544 545 550 public JFreeChart createHighLowChart() { 551 552 String title = resources.getString("timeseries.highlow.title"); 554 String domain = resources.getString("timeseries.highlow.domain"); 555 String range = resources.getString("timeseries.highlow.range"); 556 String subtitleStr = resources.getString("timeseries.highlow.subtitle"); 557 HighLowDataset data = DemoDatasetFactory.createHighLowDataset(); 558 JFreeChart chart = ChartFactory.createHighLowChart(title, domain, range, data, true); 559 560 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 562 chart.addSubtitle(subtitle); 563 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.magenta)); 564 return chart; 565 566 } 567 568 573 public JFreeChart createCandlestickChart() { 574 575 String title = resources.getString("timeseries.candlestick.title"); 577 String domain = resources.getString("timeseries.candlestick.domain"); 578 String range = resources.getString("timeseries.candlestick.range"); 579 String subtitleStr = resources.getString("timeseries.candlestick.subtitle"); 580 HighLowDataset data = DemoDatasetFactory.createHighLowDataset(); 581 JFreeChart chart = ChartFactory.createCandlestickChart(title, domain, range, data, false); 582 583 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 585 chart.addSubtitle(subtitle); 586 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.green)); 587 return chart; 588 589 } 590 591 596 public JFreeChart createSignalChart() { 597 598 String title = resources.getString("timeseries.signal.title"); 600 String domain = resources.getString("timeseries.signal.domain"); 601 String range = resources.getString("timeseries.signal.range"); 602 String subtitleStr = resources.getString("timeseries.signal.subtitle"); 603 SignalsDataset data = DemoDatasetFactory.createSampleSignalDataset(); 604 JFreeChart chart = ChartFactory.createSignalChart(title, domain, range, data, true); 605 606 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 608 chart.addSubtitle(subtitle); 609 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 610 return chart; 611 612 } 613 614 619 public JFreeChart createThermometerChart() { 620 621 String title = resources.getString("meter.thermo.title"); 623 String subtitleStr = resources.getString("meter.thermo.subtitle"); 624 String units = resources.getString("meter.thermo.units"); 625 626 DefaultValueDataset data = new DefaultValueDataset(new Double (34.0)); 627 ThermometerPlot plot = new ThermometerPlot(data); 628 plot.setUnits(units); 629 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); 630 631 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 633 chart.addSubtitle(subtitle); 634 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 635 return chart; 636 637 } 638 639 644 public JFreeChart createMeterChartCircle() { 645 646 String title = resources.getString("meter.meter.title"); 648 String subtitleStr = resources.getString("meter.meter.subtitle"); 649 DefaultValueDataset data = new DefaultValueDataset(50.0); 652 MeterPlot plot = new MeterPlot(data); 654 plot.setMeterAngle(270); 655 plot.setDialShape(DialShape.CIRCLE); 656 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, 657 plot, false); 658 659 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 661 chart.addSubtitle(subtitle); 662 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 663 return chart; 664 } 665 666 671 public JFreeChart createMeterChartPie() { 672 673 String title = resources.getString("meter.meter.title"); 675 String subtitleStr = resources.getString("meter.meter.subtitle"); 676 DefaultValueDataset data = new DefaultValueDataset(50.0); 679 MeterPlot plot = new MeterPlot(data); 681 plot.setMeterAngle(270); 682 plot.setDialShape(DialShape.PIE); 683 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); 684 685 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 687 chart.addSubtitle(subtitle); 688 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 689 return chart; 690 } 691 692 697 public JFreeChart createMeterChartChord() { 698 699 String title = resources.getString("meter.meter.title"); 701 String subtitleStr = resources.getString("meter.meter.subtitle"); 702 DefaultValueDataset data = new DefaultValueDataset(45.0); 705 MeterPlot plot = new MeterPlot(data); 707 plot.setMeterAngle(270); 708 plot.setDialShape(DialShape.CHORD); 709 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false); 710 711 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 713 chart.addSubtitle(subtitle); 714 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 715 return chart; 716 } 717 718 723 public JFreeChart createCompassChart() { 724 725 String title = resources.getString("meter.compass.title"); 727 String subtitleStr = resources.getString("meter.compass.subtitle"); 728 DefaultValueDataset data = new DefaultValueDataset(new Double (45.0)); 729 730 Plot plot = new CompassPlot(data); 731 JFreeChart chart = new JFreeChart( 732 title, 733 JFreeChart.DEFAULT_TITLE_FONT, 734 plot, 735 false 736 ); 737 738 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 740 chart.addSubtitle(subtitle); 741 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 742 return chart; 743 } 744 745 750 public JFreeChart createWindPlot() { 751 752 String title = resources.getString("other.wind.title"); 754 String domain = resources.getString("other.wind.domain"); 755 String range = resources.getString("other.wind.range"); 756 WindDataset data = DemoDatasetFactory.createWindDataset1(); 757 JFreeChart chart = ChartFactory.createWindPlot(title, domain, range, data, 758 true, 759 false, 760 false); 761 762 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.green)); 764 return chart; 765 766 } 767 768 773 public JFreeChart createScatterPlot() { 774 775 String title = resources.getString("other.scatter.title"); 777 String domain = resources.getString("other.scatter.domain"); 778 String range = resources.getString("other.scatter.range"); 779 XYDataset data = new SampleXYDataset2(); 780 JFreeChart chart = ChartFactory.createScatterPlot( 781 title, 782 domain, 783 range, 784 data, 785 PlotOrientation.VERTICAL, 786 true, 787 true, false ); 790 791 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.green)); 793 794 XYPlot plot = chart.getXYPlot(); 795 plot.setDomainCrosshairVisible(true); 796 plot.setRangeCrosshairVisible(true); 797 NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); 798 rangeAxis.setAutoRangeIncludesZero(false); 799 return chart; 800 801 } 802 803 808 public JFreeChart createLineChart() { 809 810 String title = resources.getString("other.line.title"); 812 String domain = resources.getString("other.line.domain"); 813 String range = resources.getString("other.line.range"); 814 CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); 815 JFreeChart chart = ChartFactory.createLineChart(title, domain, range, data, 816 PlotOrientation.VERTICAL, 817 true, 818 true, 819 false); 820 821 chart.setBackgroundImage(JFreeChart.INFO.getLogo()); 823 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.green)); 824 825 CategoryPlot plot = (CategoryPlot) chart.getPlot(); 826 plot.setBackgroundAlpha(0.65f); 827 return chart; 828 } 829 830 835 public JFreeChart createVerticalXYBarChart() { 836 837 String title = resources.getString("other.xybar.title"); 839 String domain = resources.getString("other.xybar.domain"); 840 String range = resources.getString("other.xybar.range"); 841 TimeSeriesCollection data = DemoDatasetFactory.createTimeSeriesCollection1(); 842 data.setDomainIsPointsInTime(false); 843 JFreeChart chart = ChartFactory.createXYBarChart( 844 title, 845 domain, 846 range, 847 data, 848 PlotOrientation.VERTICAL, 849 true, 850 false, 851 false 852 ); 853 854 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.blue)); 856 857 XYItemRenderer renderer = chart.getXYPlot().getRenderer(); 858 renderer.setToolTipGenerator(new TimeSeriesToolTipGenerator()); 859 return chart; 860 } 861 862 867 public JFreeChart createNullXYPlot() { 868 869 String title = resources.getString("test.null.title"); 871 String domain = resources.getString("test.null.domain"); 872 String range = resources.getString("test.null.range"); 873 XYDataset data = null; 874 JFreeChart chart = ChartFactory.createXYLineChart( 875 title, domain, range, data, 876 PlotOrientation.VERTICAL, 877 true, 878 true, 879 false 880 ); 881 882 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.red)); 884 return chart; 885 886 } 887 888 893 public JFreeChart createXYPlotZeroData() { 894 895 String title = resources.getString("test.zero.title"); 897 String domain = resources.getString("test.zero.domain"); 898 String range = resources.getString("test.zero.range"); 899 XYDataset data = new EmptyXYDataset(); 900 JFreeChart chart = ChartFactory.createXYLineChart( 901 title, domain, range, data, 902 PlotOrientation.VERTICAL, 903 true, 904 true, 905 false 906 ); 907 908 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.red)); 910 return chart; 911 } 912 913 918 public JFreeChart createTimeSeriesChartInScrollPane() { 919 920 String title = resources.getString("test.scroll.title"); 922 String domain = resources.getString("test.scroll.domain"); 923 String range = resources.getString("test.scroll.range"); 924 String subtitleStr = resources.getString("test.scroll.subtitle"); 925 XYDataset data = DemoDatasetFactory.createTimeSeriesCollection2(); 926 JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, 927 true, 928 true, 929 false); 930 931 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 933 chart.addSubtitle(subtitle); 934 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.gray)); 935 return chart; 936 937 } 938 939 944 public JFreeChart createSingleSeriesBarChart() { 945 946 String title = resources.getString("test.single.title"); 948 String domain = resources.getString("test.single.domain"); 949 String range = resources.getString("test.single.range"); 950 String subtitle1Str = resources.getString("test.single.subtitle1"); 951 String subtitle2Str = resources.getString("test.single.subtitle2"); 952 953 CategoryDataset data = DemoDatasetFactory.createSingleSeriesCategoryDataset(); 954 955 JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data, 956 PlotOrientation.HORIZONTAL, 957 true, 958 true, 959 false); 960 chart.addSubtitle(new TextTitle(subtitle1Str)); 961 chart.addSubtitle(new TextTitle(subtitle2Str)); 962 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.red)); 963 return chart; 964 965 } 966 967 973 public JFreeChart createDynamicXYChart() { 974 975 String title = resources.getString("test.dynamic.title"); 976 String domain = resources.getString("test.dynamic.domain"); 977 String range = resources.getString("test.dynamic.range"); 978 979 SampleXYDataset data = new SampleXYDataset(); 980 JFreeChart chart = ChartFactory.createXYLineChart( 981 title, domain, range, data, 982 PlotOrientation.VERTICAL, 983 true, 984 true, 985 false 986 ); 987 SampleXYDatasetThread update = new SampleXYDatasetThread(data); 988 989 Thread thread = new Thread (update); 990 thread.start(); 991 992 return chart; 993 994 } 995 996 1005 public JFreeChart createOverlaidChart() { 1006 1007 String title = this.resources.getString("combined.overlaid.title"); 1009 String subtitleStr = this.resources.getString("combined.overlaid.subtitle"); 1010 String domainAxisLabel = this.resources.getString("combined.overlaid.domain"); 1011 String rangeAxisLabel = this.resources.getString("combined.overlaid.range"); 1012 1013 HighLowDataset highLowData = DemoDatasetFactory.createHighLowDataset(); 1015 1016 ValueAxis domainAxis = new DateAxis(domainAxisLabel); 1018 NumberAxis rangeAxis = new NumberAxis(rangeAxisLabel); 1019 rangeAxis.setAutoRangeIncludesZero(false); 1020 XYItemRenderer renderer1 = new HighLowRenderer(); 1021 renderer1.setToolTipGenerator(new HighLowToolTipGenerator()); 1022 1023 XYPlot plot = new XYPlot(highLowData, domainAxis, rangeAxis, renderer1); 1024 1025 XYDataset maData = MovingAverage.createMovingAverage( 1027 highLowData, 1028 " (Moving Average)", 1029 5 * 24 * 60 * 60 * 1000L, 1030 5 * 24 * 60 * 60 * 1000L 1031 ); 1032 plot.setSecondaryDataset(0, maData); 1033 XYItemRenderer renderer2 = new StandardXYItemRenderer(); 1034 renderer2.setToolTipGenerator(new TimeSeriesToolTipGenerator("d-MMM-yyyy", "0.00")); 1035 plot.setSecondaryRenderer(0, renderer2); 1036 1037 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); 1039 1040 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 1042 chart.addSubtitle(subtitle); 1043 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 1044 1045 return chart; 1046 1047 } 1048 1049 1054 public JFreeChart createHorizontallyCombinedChart() { 1055 1056 String title = this.resources.getString("combined.horizontal.title"); 1058 String subtitleStr = this.resources.getString("combined.horizontal.subtitle"); 1059 String [] domains = this.resources.getStringArray("combined.horizontal.domains"); 1060 String rangeAxisLabel = this.resources.getString("combined.horizontal.range"); 1061 1062 TimeSeriesCollection dataset0 = new TimeSeriesCollection(); 1063 TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); 1064 dataset0.addSeries(eur); 1065 1066 TimeSeriesCollection dataset1 = new TimeSeriesCollection(); 1067 TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); 1068 dataset1.addSeries(eur); 1069 dataset1.addSeries(mav); 1070 1071 TimeSeriesCollection dataset2 = new TimeSeriesCollection(); 1072 dataset2.addSeries(eur); 1073 1074 NumberAxis valueAxis = new NumberAxis(rangeAxisLabel); 1076 valueAxis.setAutoRangeIncludesZero(false); CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); 1078 parent.setRenderer(new StandardXYItemRenderer()); 1079 1080 int[] weight = {1, 1, 1}; 1083 XYPlot subplot1 = new XYPlot(dataset0, new DateAxis(domains[0]), null, 1085 new StandardXYItemRenderer()); 1086 parent.add(subplot1, weight[0]); 1087 1088 XYPlot subplot2 = new XYPlot(dataset1, new DateAxis(domains[1]), null, 1090 new StandardXYItemRenderer()); 1091 parent.add(subplot2, weight[1]); 1092 1093 XYPlot subplot3 = new XYPlot(dataset2, new DateAxis(domains[2]), 1095 null, new XYBarRenderer(0.20)); 1096 parent.add(subplot3, weight[2]); 1097 1098 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, parent, true); 1100 1101 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 1103 chart.addSubtitle(subtitle); 1104 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 1105 return chart; 1106 1107 } 1108 1109 1114 public JFreeChart createVerticallyCombinedChart() { 1115 1116 String title = this.resources.getString("combined.vertical.title"); 1118 String subtitleStr = this.resources.getString("combined.vertical.subtitle"); 1119 String domain = this.resources.getString("combined.vertical.domain"); 1120 String [] ranges = this.resources.getStringArray("combined.vertical.ranges"); 1121 1122 1123 TimeSeriesCollection dataset0 = new TimeSeriesCollection(); 1124 TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); 1125 dataset0.addSeries(eur); 1126 1127 TimeSeriesCollection dataset1 = new TimeSeriesCollection(); 1128 TimeSeries jpy = DemoDatasetFactory.createJPYTimeSeries(); 1129 TimeSeries mav = MovingAverage.createMovingAverage(jpy, "JPY/GBP (30 Day MA)", 30, 30); 1130 dataset1.addSeries(jpy); 1131 dataset1.addSeries(mav); 1132 1133 XYDataset dataset2 = DemoDatasetFactory.createHighLowDataset(); 1134 1135 TimeSeriesCollection dataset3 = new TimeSeriesCollection(); 1136 dataset3.addSeries(eur); 1137 1138 ValueAxis timeAxis = new DateAxis(domain); 1140 1141 CombinedDomainXYPlot multiPlot = new CombinedDomainXYPlot(timeAxis); 1143 1144 int[] weight = {1, 1, 1, 1}; 1146 XYPlot subplot1 = new XYPlot(dataset0, null, new NumberAxis(ranges[0]), 1148 new StandardXYItemRenderer()); 1149 NumberAxis range1 = (NumberAxis) subplot1.getRangeAxis(); 1150 range1.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1151 range1.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1152 range1.setAutoRangeIncludesZero(false); 1153 multiPlot.add(subplot1, weight[0]); 1154 1155 XYPlot subplot2 = new XYPlot(dataset1, null, new NumberAxis(ranges[1]), 1157 new StandardXYItemRenderer()); 1158 NumberAxis range2 = (NumberAxis) subplot2.getRangeAxis(); 1159 range2.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1160 range2.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1161 range2.setAutoRangeIncludesZero(false); 1162 multiPlot.add(subplot2, weight[1]); 1163 1164 XYPlot subplot3 = new XYPlot(dataset2, null, new NumberAxis(ranges[2]), null); 1166 XYItemRenderer renderer3 = new HighLowRenderer(); 1167 subplot3.setRenderer(renderer3); 1168 NumberAxis range3 = (NumberAxis) subplot3.getRangeAxis(); 1169 range3.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1170 range3.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1171 range3.setAutoRangeIncludesZero(false); 1172 multiPlot.add(subplot3, weight[2]); 1173 1174 XYPlot subplot4 = new XYPlot(dataset3, null, new NumberAxis(ranges[3]), null); 1176 XYItemRenderer renderer4 = new XYBarRenderer(); 1177 subplot4.setRenderer(renderer4); 1178 NumberAxis range4 = (NumberAxis) subplot4.getRangeAxis(); 1179 range4.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1180 range4.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1181 range4.setAutoRangeIncludesZero(false); 1182 multiPlot.add(subplot4, weight[3]); 1183 1184 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, multiPlot, true); 1186 1187 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 1189 chart.addSubtitle(subtitle); 1190 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 1191 return chart; 1192 1193 } 1194 1195 1203 public JFreeChart createCombinedAndOverlaidChart1() { 1204 1205 String title = this.resources.getString("combined.combined-overlaid.title"); 1207 String subtitleStr = this.resources.getString("combined.combined-overlaid.subtitle"); 1208 String domain = this.resources.getString("combined.combined-overlaid.domain"); 1209 String [] ranges = this.resources.getStringArray("combined.combined-overlaid.ranges"); 1210 1211 TimeSeries jpy = DemoDatasetFactory.createJPYTimeSeries(); 1212 TimeSeries mav = MovingAverage.createMovingAverage(jpy, "30 Day Moving Average", 30, 30); 1213 1214 TimeSeriesCollection dataset0 = new TimeSeriesCollection(); 1215 dataset0.addSeries(jpy); 1216 1217 TimeSeriesCollection dataset1 = new TimeSeriesCollection(); 1218 dataset1.addSeries(jpy); 1219 dataset1.addSeries(mav); 1220 1221 HighLowDataset highLowDataset = DemoDatasetFactory.createHighLowDataset(); 1222 XYDataset highLowDatasetMA = MovingAverage.createMovingAverage( 1223 highLowDataset, 1224 " (MA)", 1225 5 * 24 * 60 * 60 * 1000L, 1226 5 * 24 * 60 * 60 * 1000L 1227 ); 1228 1229 NumberAxis[] valueAxis = new NumberAxis[3]; 1231 for (int i = 0; i < valueAxis.length; i++) { 1232 valueAxis[i] = new NumberAxis(ranges[i]); 1233 if (i <= 1) { 1234 valueAxis[i].setAutoRangeIncludesZero(false); } 1236 } 1237 1238 CombinedDomainXYPlot parent = new CombinedDomainXYPlot(new DateAxis(domain)); 1240 1241 int[] weight = {1, 2, 2}; 1242 1243 XYItemRenderer renderer1 = new StandardXYItemRenderer(); 1245 XYPlot subplot1 = new XYPlot(dataset0, null, new NumberAxis(ranges[0]), renderer1); 1246 NumberAxis axis1 = (NumberAxis) subplot1.getRangeAxis(); 1247 axis1.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1248 axis1.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1249 axis1.setAutoRangeIncludesZero(false); 1250 parent.add(subplot1, weight[0]); 1251 1252 XYPlot subplot2 = new XYPlot(dataset0, null, new NumberAxis(ranges[1]), 1254 new StandardXYItemRenderer()); 1255 NumberAxis axis2 = (NumberAxis) subplot2.getRangeAxis(); 1256 axis2.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1257 axis2.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1258 axis2.setAutoRangeIncludesZero(false); 1259 subplot2.setSecondaryDataset(0, dataset1); 1260 subplot2.setSecondaryRenderer(0, new StandardXYItemRenderer()); 1261 1262 parent.add(subplot2, weight[1]); 1263 1264 XYItemRenderer renderer3 = new HighLowRenderer(); 1266 XYPlot subplot3 = new XYPlot(highLowDataset, null, new NumberAxis(ranges[2]), renderer3); 1267 NumberAxis axis3 = (NumberAxis) subplot3.getRangeAxis(); 1268 axis3.setTickLabelFont(new Font ("Monospaced", Font.PLAIN, 7)); 1269 axis3.setLabelFont(new Font ("SansSerif", Font.PLAIN, 8)); 1270 axis3.setAutoRangeIncludesZero(false); 1271 subplot3.setSecondaryDataset(0, highLowDatasetMA); 1272 subplot3.setSecondaryRenderer(0, new StandardXYItemRenderer()); 1273 1274 parent.add(subplot3, weight[2]); 1275 1276 JFreeChart chart = new JFreeChart( 1278 title, 1279 new Font ("SansSerif", Font.BOLD, 12), 1280 parent, 1281 true 1282 ); 1283 1284 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 10)); 1286 chart.addSubtitle(subtitle); 1287 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.blue)); 1288 return chart; 1289 1290 } 1291 1292 1298 public JFreeChart createCombinedAndOverlaidDynamicXYChart() { 1299 1300 String title = this.resources.getString("combined.dynamic.title"); 1302 String subtitleStr = this.resources.getString("combined.dynamic.subtitle"); 1303 String domainAxisLabel = this.resources.getString("combined.dynamic.domain"); 1304 String [] ranges = this.resources.getStringArray("combined.dynamic.ranges"); 1305 1306 SampleXYDataset data = new SampleXYDataset(); 1308 1309 XYDataset series0 = new SubSeriesDataset(data, 0); 1311 XYDataset series1 = new SubSeriesDataset(data, 1); 1312 1313 CombinedDataset combinedData = new CombinedDataset(); 1314 combinedData.add(series0); 1315 combinedData.add(series1); 1316 1317 NumberAxis timeAxis = new NumberAxis(domainAxisLabel); 1319 timeAxis.setTickMarksVisible(true); 1320 timeAxis.setAutoRangeIncludesZero(false); 1321 1322 NumberAxis[] valueAxis = new NumberAxis[4]; 1324 for (int i = 0; i < valueAxis.length; i++) { 1325 valueAxis[i] = new NumberAxis(ranges[i]); 1326 valueAxis[i].setAutoRangeIncludesZero(false); 1327 } 1328 1329 CombinedDomainXYPlot plot = new CombinedDomainXYPlot(timeAxis); 1330 1331 XYItemRenderer renderer0 = new StandardXYItemRenderer(); 1333 XYPlot subplot0 = new XYPlot(series0, null, valueAxis[0], renderer0); 1334 plot.add(subplot0, 1); 1335 1336 XYItemRenderer renderer1 = new StandardXYItemRenderer(); 1338 XYPlot subplot1 = new XYPlot(series1, null, valueAxis[1], renderer1); 1339 plot.add(subplot1, 1); 1340 1341 XYPlot subplot2 = new XYPlot(series0, null, valueAxis[2], new StandardXYItemRenderer()); 1343 subplot2.setSecondaryDataset(0, series1); 1344 subplot2.setSecondaryRenderer(0, new StandardXYItemRenderer()); 1345 plot.add(subplot2, 1); 1346 1347 XYItemRenderer renderer3 = new StandardXYItemRenderer(); 1349 XYPlot subplot3 = new XYPlot(data, null, valueAxis[3], renderer3); 1350 plot.add(subplot3, 1); 1351 1352 JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); 1353 1354 TextTitle subtitle = new TextTitle(subtitleStr, new Font ("SansSerif", Font.BOLD, 12)); 1356 chart.addSubtitle(subtitle); 1357 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 0, 1000, Color.cyan)); 1358 1359 SampleXYDatasetThread update = new SampleXYDatasetThread(data); 1361 Thread thread = new Thread (update); 1362 thread.start(); 1363 1364 return chart; 1365 1366 } 1367 1368 1373 public JFreeChart createGanttChart() { 1374 1375 String title = resources.getString("gantt.task.title"); 1376 String domain = resources.getString("gantt.task.domain"); 1377 String range = resources.getString("gantt.task.range"); 1378 1379 IntervalCategoryDataset data = createGanttDataset1(); 1380 1381 JFreeChart chart = ChartFactory.createGanttChart( 1382 title, domain, range, data, 1383 true, 1384 true, 1385 false 1386 ); 1387 1388 chart.setBackgroundPaint(new GradientPaint (0, 0, Color.white, 1000, 0, Color.blue)); 1390 return chart; 1391 1392 } 1393 1394 1401 private static IntervalCategoryDataset createGanttDataset1() { 1402 1403 TaskSeries s1 = new TaskSeries("Scheduled"); 1404 s1.add(new Task("Write Proposal", 1405 new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), 1406 date(5, Calendar.APRIL, 2001)))); 1407 s1.add(new Task("Obtain Approval", 1408 new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), 1409 date(9, Calendar.APRIL, 2001)))); 1410 s1.add(new Task("Requirements Analysis", 1411 new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), 1412 date(5, Calendar.MAY, 2001)))); 1413 s1.add(new Task("Design Phase", 1414 new SimpleTimePeriod(date(6, Calendar.MAY, 2001), 1415 date(30, Calendar.MAY, 2001)))); 1416 s1.add(new Task("Design Signoff", 1417 new SimpleTimePeriod(date(2, Calendar.JUNE, 2001), 1418 date(2, Calendar.JUNE, 2001)))); 1419 s1.add(new Task("Alpha Implementation", 1420 new SimpleTimePeriod(date(3, Calendar.JUNE, 2001), 1421 date(31, Calendar.JULY, 2001)))); 1422 s1.add(new Task("Design Review", 1423 new SimpleTimePeriod(date(1, Calendar.AUGUST, 2001), 1424 date(8, Calendar.AUGUST, 2001)))); 1425 s1.add(new Task("Revised Design Signoff", 1426 new SimpleTimePeriod(date(10, Calendar.AUGUST, 2001), 1427 date(10, Calendar.AUGUST, 2001)))); 1428 s1.add(new Task("Beta Implementation", 1429 new SimpleTimePeriod(date(12, Calendar.AUGUST, 2001), 1430 date(12, Calendar.SEPTEMBER, 2001)))); 1431 s1.add(new Task("Testing", 1432 new SimpleTimePeriod(date(13, Calendar.SEPTEMBER, 2001), 1433 date(31, Calendar.OCTOBER, 2001)))); 1434 s1.add(new Task("Final Implementation", 1435 new SimpleTimePeriod(date(1, Calendar.NOVEMBER, 2001), 1436 date(15, Calendar.NOVEMBER, 2001)))); 1437 s1.add(new Task("Signoff", 1438 new SimpleTimePeriod(date(28, Calendar.NOVEMBER, 2001), 1439 date(30, Calendar.NOVEMBER, 2001)))); 1440 1441 TaskSeries s2 = new TaskSeries("Actual"); 1442 s2.add(new Task("Write Proposal", 1443 new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), 1444 date(5, Calendar.APRIL, 2001)))); 1445 s2.add(new Task("Obtain Approval", 1446 new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), 1447 date(9, Calendar.APRIL, 2001)))); 1448 s2.add(new Task("Requirements Analysis", 1449 new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), 1450 date(15, Calendar.MAY, 2001)))); 1451 s2.add(new Task("Design Phase", 1452 new SimpleTimePeriod(date(15, Calendar.MAY, 2001), 1453 date(17, Calendar.JUNE, 2001)))); 1454 s2.add(new Task("Design Signoff", 1455 new SimpleTimePeriod(date(30, Calendar.JUNE, 2001), 1456 date(30, Calendar.JUNE, 2001)))); 1457 s2.add(new Task("Alpha Implementation", 1458 new SimpleTimePeriod(date(1, Calendar.JULY, 2001), 1459 date(12, Calendar.SEPTEMBER, 2001)))); 1460 s2.add(new Task("Design Review", 1461 new SimpleTimePeriod(date(12, Calendar.SEPTEMBER, 2001), 1462 date(22, Calendar.SEPTEMBER, 2001)))); 1463 s2.add(new Task("Revised Design Signoff", 1464 new SimpleTimePeriod(date(25, Calendar.SEPTEMBER, 2001), 1465 date(27, Calendar.SEPTEMBER, 2001)))); 1466 s2.add(new Task("Beta Implementation", 1467 new SimpleTimePeriod(date(27, Calendar.SEPTEMBER, 2001), 1468 date(30, Calendar.OCTOBER, 2001)))); 1469 s2.add(new Task("Testing", 1470 new SimpleTimePeriod(date(31, Calendar.OCTOBER, 2001), 1471 date(17, Calendar.NOVEMBER, 2001)))); 1472 s2.add(new Task("Final Implementation", 1473 new SimpleTimePeriod(date(18, Calendar.NOVEMBER, 2001), 1474 date(5, Calendar.DECEMBER, 2001)))); 1475 s2.add(new Task("Signoff", 1476 new SimpleTimePeriod(date(10, Calendar.DECEMBER, 2001), 1477 date(11, Calendar.DECEMBER, 2001)))); 1478 1479 TaskSeriesCollection collection = new TaskSeriesCollection(); 1480 collection.add(s1); 1481 collection.add(s2); 1482 1483 return collection; 1484 } 1485 1486 1495 private static Date date(int day, int month, int year) { 1496 1497 Calendar calendar = Calendar.getInstance(); 1498 calendar.set(year, month, day); 1499 Date result = calendar.getTime(); 1500 return result; 1501 1502 } 1503 1504} 1505 | Popular Tags |