1 108 109 package org.jfree.chart; 110 111 import java.awt.Color ; 112 import java.awt.Font ; 113 import java.text.DateFormat ; 114 import java.text.NumberFormat ; 115 import java.util.Iterator ; 116 import java.util.List ; 117 118 import org.jfree.chart.axis.CategoryAxis; 119 import org.jfree.chart.axis.CategoryAxis3D; 120 import org.jfree.chart.axis.DateAxis; 121 import org.jfree.chart.axis.NumberAxis; 122 import org.jfree.chart.axis.NumberAxis3D; 123 import org.jfree.chart.axis.Timeline; 124 import org.jfree.chart.axis.ValueAxis; 125 import org.jfree.chart.labels.HighLowItemLabelGenerator; 126 import org.jfree.chart.labels.IntervalCategoryToolTipGenerator; 127 import org.jfree.chart.labels.ItemLabelAnchor; 128 import org.jfree.chart.labels.ItemLabelPosition; 129 import org.jfree.chart.labels.PieToolTipGenerator; 130 import org.jfree.chart.labels.StandardCategoryToolTipGenerator; 131 import org.jfree.chart.labels.StandardPieItemLabelGenerator; 132 import org.jfree.chart.labels.StandardXYToolTipGenerator; 133 import org.jfree.chart.labels.StandardXYZToolTipGenerator; 134 import org.jfree.chart.labels.XYToolTipGenerator; 135 import org.jfree.chart.plot.CategoryPlot; 136 import org.jfree.chart.plot.Marker; 137 import org.jfree.chart.plot.MultiplePiePlot; 138 import org.jfree.chart.plot.PiePlot; 139 import org.jfree.chart.plot.PiePlot3D; 140 import org.jfree.chart.plot.PlotOrientation; 141 import org.jfree.chart.plot.PolarPlot; 142 import org.jfree.chart.plot.RingPlot; 143 import org.jfree.chart.plot.ValueMarker; 144 import org.jfree.chart.plot.WaferMapPlot; 145 import org.jfree.chart.plot.XYPlot; 146 import org.jfree.chart.renderer.DefaultPolarItemRenderer; 147 import org.jfree.chart.renderer.WaferMapRenderer; 148 import org.jfree.chart.renderer.category.AreaRenderer; 149 import org.jfree.chart.renderer.category.BarRenderer; 150 import org.jfree.chart.renderer.category.BarRenderer3D; 151 import org.jfree.chart.renderer.category.CategoryItemRenderer; 152 import org.jfree.chart.renderer.category.GanttRenderer; 153 import org.jfree.chart.renderer.category.LineAndShapeRenderer; 154 import org.jfree.chart.renderer.category.LineRenderer3D; 155 import org.jfree.chart.renderer.category.StackedAreaRenderer; 156 import org.jfree.chart.renderer.category.StackedBarRenderer; 157 import org.jfree.chart.renderer.category.StackedBarRenderer3D; 158 import org.jfree.chart.renderer.category.WaterfallBarRenderer; 159 import org.jfree.chart.renderer.xy.CandlestickRenderer; 160 import org.jfree.chart.renderer.xy.HighLowRenderer; 161 import org.jfree.chart.renderer.xy.SignalRenderer; 162 import org.jfree.chart.renderer.xy.StackedXYAreaRenderer; 163 import org.jfree.chart.renderer.xy.StandardXYItemRenderer; 164 import org.jfree.chart.renderer.xy.WindItemRenderer; 165 import org.jfree.chart.renderer.xy.XYAreaRenderer; 166 import org.jfree.chart.renderer.xy.XYBarRenderer; 167 import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer; 168 import org.jfree.chart.renderer.xy.XYBubbleRenderer; 169 import org.jfree.chart.renderer.xy.XYItemRenderer; 170 import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; 171 import org.jfree.chart.renderer.xy.XYStepAreaRenderer; 172 import org.jfree.chart.renderer.xy.XYStepRenderer; 173 import org.jfree.chart.title.TextTitle; 174 import org.jfree.chart.urls.PieURLGenerator; 175 import org.jfree.chart.urls.StandardCategoryURLGenerator; 176 import org.jfree.chart.urls.StandardPieURLGenerator; 177 import org.jfree.chart.urls.StandardXYURLGenerator; 178 import org.jfree.chart.urls.StandardXYZURLGenerator; 179 import org.jfree.chart.urls.XYURLGenerator; 180 import org.jfree.data.category.CategoryDataset; 181 import org.jfree.data.category.IntervalCategoryDataset; 182 import org.jfree.data.general.DefaultPieDataset; 183 import org.jfree.data.general.PieDataset; 184 import org.jfree.data.general.WaferMapDataset; 185 import org.jfree.data.statistics.BoxAndWhiskerXYDataset; 186 import org.jfree.data.xy.IntervalXYDataset; 187 import org.jfree.data.xy.OHLCDataset; 188 import org.jfree.data.xy.SignalsDataset; 189 import org.jfree.data.xy.TableXYDataset; 190 import org.jfree.data.xy.WindDataset; 191 import org.jfree.data.xy.XYDataset; 192 import org.jfree.data.xy.XYZDataset; 193 import org.jfree.ui.Layer; 194 import org.jfree.ui.RectangleEdge; 195 import org.jfree.ui.RectangleInsets; 196 import org.jfree.ui.TextAnchor; 197 import org.jfree.util.SortOrder; 198 import org.jfree.util.TableOrder; 199 200 204 public abstract class ChartFactory { 205 206 220 public static JFreeChart createPieChart(String title, 221 PieDataset dataset, 222 boolean legend, 223 boolean tooltips, 224 boolean urls) { 225 226 PiePlot plot = new PiePlot(dataset); 227 plot.setLabelGenerator(new StandardPieItemLabelGenerator()); 228 plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); 229 if (tooltips) { 230 plot.setToolTipGenerator( 231 new StandardPieItemLabelGenerator( 232 StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT 233 ) 234 ); 235 } 236 if (urls) { 237 plot.setURLGenerator(new StandardPieURLGenerator()); 238 } 239 return new JFreeChart( 240 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 241 ); 242 243 } 244 245 283 public static JFreeChart createPieChart(String title, 284 PieDataset dataset, 285 PieDataset previousDataset, 286 int percentDiffForMaxScale, 287 boolean greenForIncrease, 288 boolean legend, 289 boolean tooltips, 290 boolean urls, 291 boolean subTitle, 292 boolean showDifference) { 293 294 PiePlot plot = new PiePlot(dataset); 295 plot.setLabelGenerator(new StandardPieItemLabelGenerator()); 296 plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); 297 298 if (tooltips) { 299 plot.setToolTipGenerator( 300 new StandardPieItemLabelGenerator( 301 StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT 302 ) 303 ); 304 } 305 if (urls) { 306 plot.setURLGenerator(new StandardPieURLGenerator()); 307 } 308 309 List keys = dataset.getKeys(); 310 DefaultPieDataset series = null; 311 if (showDifference) { 312 series = new DefaultPieDataset(); 313 } 314 315 double colorPerPercent = 255.0 / percentDiffForMaxScale; 316 for (Iterator it = keys.iterator(); it.hasNext();) { 317 Comparable key = (Comparable ) it.next(); 318 Number newValue = dataset.getValue(key); 319 Number oldValue = previousDataset.getValue(key); 320 int section = dataset.getIndex(key); 321 322 if (oldValue == null) { 323 if (greenForIncrease) { 324 plot.setSectionPaint(section, Color.green); 325 } 326 else { 327 plot.setSectionPaint(section, Color.red); 328 } 329 if (showDifference) { 330 series.setValue(key + " (+100%)", newValue); 331 } 332 } 333 else { 334 double percentChange = (newValue.doubleValue() 335 / oldValue.doubleValue() - 1.0) * 100.0; 336 double shade 337 = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 338 : Math.abs(percentChange) * colorPerPercent); 339 if (greenForIncrease 340 && newValue.doubleValue() > oldValue.doubleValue() 341 || !greenForIncrease && newValue.doubleValue() 342 < oldValue.doubleValue()) { 343 plot.setSectionPaint(section, new Color (0, (int) shade, 0)); 344 } 345 else { 346 plot.setSectionPaint(section, new Color ((int) shade, 0, 0)); 347 } 348 if (showDifference) { 349 series.setValue( 350 key + " (" + (percentChange >= 0 ? "+" : "") 351 + NumberFormat.getPercentInstance().format( 352 percentChange / 100.0) + ")", newValue 353 ); 354 } 355 } 356 } 357 358 if (showDifference) { 359 plot.setDataset(series); 360 } 361 362 JFreeChart chart = new JFreeChart( 363 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 364 ); 365 366 if (subTitle) { 367 TextTitle subtitle = null; 368 subtitle = new TextTitle( 369 "Bright " + (greenForIncrease ? "red" : "green") 370 + "=change >=-" + percentDiffForMaxScale + "%, Bright " 371 + (!greenForIncrease ? "red" : "green") + "=change >=+" 372 + percentDiffForMaxScale + "%", 373 new Font ("SansSerif", Font.PLAIN, 10) 374 ); 375 chart.addSubtitle(subtitle); 376 } 377 378 return chart; 379 } 380 381 395 public static JFreeChart createRingChart(String title, 396 PieDataset dataset, 397 boolean legend, 398 boolean tooltips, 399 boolean urls) { 400 401 RingPlot plot = new RingPlot(dataset); 402 plot.setLabelGenerator(new StandardPieItemLabelGenerator()); 403 plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); 404 if (tooltips) { 405 plot.setToolTipGenerator( 406 new StandardPieItemLabelGenerator( 407 StandardPieItemLabelGenerator.DEFAULT_SECTION_LABEL_FORMAT 408 ) 409 ); 410 } 411 if (urls) { 412 plot.setURLGenerator(new StandardPieURLGenerator()); 413 } 414 return new JFreeChart( 415 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 416 ); 417 418 } 419 420 435 public static JFreeChart createMultiplePieChart(String title, 436 CategoryDataset dataset, 437 TableOrder order, 438 boolean legend, 439 boolean tooltips, 440 boolean urls) { 441 442 if (order == null) { 443 throw new IllegalArgumentException ("Null 'order' argument."); 444 } 445 MultiplePiePlot plot = new MultiplePiePlot(dataset); 446 plot.setDataExtractOrder(order); 447 plot.setBackgroundPaint(null); 448 plot.setOutlineStroke(null); 449 450 if (tooltips) { 451 PieToolTipGenerator tooltipGenerator 452 = new StandardPieItemLabelGenerator(); 453 PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); 454 pp.setToolTipGenerator(tooltipGenerator); 455 } 456 457 if (urls) { 458 PieURLGenerator urlGenerator = new StandardPieURLGenerator(); 459 PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); 460 pp.setURLGenerator(urlGenerator); 461 } 462 463 JFreeChart chart = new JFreeChart( 464 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 465 ); 466 467 return chart; 468 469 } 470 471 484 public static JFreeChart createPieChart3D(String title, 485 PieDataset dataset, 486 boolean legend, 487 boolean tooltips, 488 boolean urls) { 489 490 PiePlot3D plot = new PiePlot3D(dataset); 491 plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); 492 if (tooltips) { 493 plot.setToolTipGenerator(new StandardPieItemLabelGenerator()); 494 } 495 if (urls) { 496 plot.setURLGenerator(new StandardPieURLGenerator()); 497 } 498 return new JFreeChart( 499 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 500 ); 501 502 } 503 504 519 public static JFreeChart createMultiplePieChart3D(String title, 520 CategoryDataset dataset, 521 TableOrder order, 522 boolean legend, 523 boolean tooltips, 524 boolean urls) { 525 526 if (order == null) { 527 throw new IllegalArgumentException ("Null 'order' argument."); 528 } 529 MultiplePiePlot plot = new MultiplePiePlot(dataset); 530 plot.setDataExtractOrder(order); 531 plot.setBackgroundPaint(null); 532 plot.setOutlineStroke(null); 533 534 JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); 535 TextTitle seriesTitle = new TextTitle( 536 "Series Title", new Font ("SansSerif", Font.BOLD, 12) 537 ); 538 seriesTitle.setPosition(RectangleEdge.BOTTOM); 539 pieChart.setTitle(seriesTitle); 540 pieChart.removeLegend(); 541 pieChart.setBackgroundPaint(null); 542 plot.setPieChart(pieChart); 543 544 if (tooltips) { 545 PieToolTipGenerator tooltipGenerator 546 = new StandardPieItemLabelGenerator(); 547 PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); 548 pp.setToolTipGenerator(tooltipGenerator); 549 } 550 551 if (urls) { 552 PieURLGenerator urlGenerator = new StandardPieURLGenerator(); 553 PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); 554 pp.setURLGenerator(urlGenerator); 555 } 556 557 JFreeChart chart = new JFreeChart( 558 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 559 ); 560 561 return chart; 562 563 } 564 565 585 public static JFreeChart createBarChart(String title, 586 String categoryAxisLabel, 587 String valueAxisLabel, 588 CategoryDataset dataset, 589 PlotOrientation orientation, 590 boolean legend, 591 boolean tooltips, 592 boolean urls) { 593 594 if (orientation == null) { 595 throw new IllegalArgumentException ("Null 'orientation' argument."); 596 } 597 CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); 598 ValueAxis valueAxis = new NumberAxis(valueAxisLabel); 599 600 BarRenderer renderer = new BarRenderer(); 601 if (orientation == PlotOrientation.HORIZONTAL) { 602 ItemLabelPosition position1 = new ItemLabelPosition( 603 ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT 604 ); 605 renderer.setPositiveItemLabelPosition(position1); 606 ItemLabelPosition position2 = new ItemLabelPosition( 607 ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT 608 ); 609 renderer.setNegativeItemLabelPosition(position2); 610 } 611 else if (orientation == PlotOrientation.VERTICAL) { 612 ItemLabelPosition position1 = new ItemLabelPosition( 613 ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER 614 ); 615 renderer.setPositiveItemLabelPosition(position1); 616 ItemLabelPosition position2 = new ItemLabelPosition( 617 ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER 618 ); 619 renderer.setNegativeItemLabelPosition(position2); 620 } 621 if (tooltips) { 622 renderer.setBaseToolTipGenerator( 623 new StandardCategoryToolTipGenerator() 624 ); 625 } 626 if (urls) { 627 renderer.setBaseItemURLGenerator( 628 new StandardCategoryURLGenerator() 629 ); 630 } 631 632 CategoryPlot plot = new CategoryPlot( 633 dataset, categoryAxis, valueAxis, renderer 634 ); 635 plot.setOrientation(orientation); 636 JFreeChart chart = new JFreeChart( 637 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 638 ); 639 640 return chart; 641 642 } 643 644 665 public static JFreeChart createStackedBarChart(String title, 666 String domainAxisLabel, 667 String rangeAxisLabel, 668 CategoryDataset dataset, 669 PlotOrientation orientation, 670 boolean legend, 671 boolean tooltips, 672 boolean urls) { 673 674 if (orientation == null) { 675 throw new IllegalArgumentException ("Null 'orientation' argument."); 676 } 677 678 CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel); 679 ValueAxis valueAxis = new NumberAxis(rangeAxisLabel); 680 681 StackedBarRenderer renderer = new StackedBarRenderer(); 682 if (tooltips) { 683 renderer.setBaseToolTipGenerator( 684 new StandardCategoryToolTipGenerator() 685 ); 686 } 687 if (urls) { 688 renderer.setBaseItemURLGenerator( 689 new StandardCategoryURLGenerator() 690 ); 691 } 692 693 CategoryPlot plot = new CategoryPlot( 694 dataset, categoryAxis, valueAxis, renderer 695 ); 696 plot.setOrientation(orientation); 697 JFreeChart chart = new JFreeChart( 698 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 699 ); 700 701 return chart; 702 703 } 704 705 725 public static JFreeChart createBarChart3D(String title, 726 String categoryAxisLabel, 727 String valueAxisLabel, 728 CategoryDataset dataset, 729 PlotOrientation orientation, 730 boolean legend, 731 boolean tooltips, 732 boolean urls) { 733 734 if (orientation == null) { 735 throw new IllegalArgumentException ("Null 'orientation' argument."); 736 } 737 CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); 738 ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); 739 740 BarRenderer3D renderer = new BarRenderer3D(); 741 if (tooltips) { 742 renderer.setBaseToolTipGenerator( 743 new StandardCategoryToolTipGenerator() 744 ); 745 } 746 if (urls) { 747 renderer.setBaseItemURLGenerator( 748 new StandardCategoryURLGenerator() 749 ); 750 } 751 752 CategoryPlot plot = new CategoryPlot( 753 dataset, categoryAxis, valueAxis, renderer 754 ); 755 plot.setOrientation(orientation); 756 if (orientation == PlotOrientation.HORIZONTAL) { 757 plot.setRowRenderingOrder(SortOrder.DESCENDING); 760 plot.setColumnRenderingOrder(SortOrder.DESCENDING); 761 } 762 plot.setForegroundAlpha(0.75f); 763 764 JFreeChart chart = new JFreeChart( 765 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 766 ); 767 768 return chart; 769 770 } 771 772 793 public static JFreeChart createStackedBarChart3D(String title, 794 String categoryAxisLabel, 795 String valueAxisLabel, 796 CategoryDataset dataset, 797 PlotOrientation orientation, 798 boolean legend, 799 boolean tooltips, 800 boolean urls) { 801 802 if (orientation == null) { 803 throw new IllegalArgumentException ("Null 'orientation' argument."); 804 } 805 CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); 806 ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); 807 808 CategoryItemRenderer renderer = new StackedBarRenderer3D(); 810 if (tooltips) { 811 renderer.setBaseToolTipGenerator( 812 new StandardCategoryToolTipGenerator() 813 ); 814 } 815 if (urls) { 816 renderer.setBaseItemURLGenerator( 817 new StandardCategoryURLGenerator() 818 ); 819 } 820 821 CategoryPlot plot = new CategoryPlot( 823 dataset, categoryAxis, valueAxis, renderer 824 ); 825 plot.setOrientation(orientation); 826 if (orientation == PlotOrientation.HORIZONTAL) { 827 plot.setColumnRenderingOrder(SortOrder.DESCENDING); 830 } 831 832 JFreeChart chart = new JFreeChart( 834 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 835 ); 836 837 return chart; 838 839 } 840 841 861 public static JFreeChart createAreaChart(String title, 862 String categoryAxisLabel, 863 String valueAxisLabel, 864 CategoryDataset dataset, 865 PlotOrientation orientation, 866 boolean legend, 867 boolean tooltips, 868 boolean urls) { 869 870 if (orientation == null) { 871 throw new IllegalArgumentException ("Null 'orientation' argument."); 872 } 873 CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); 874 categoryAxis.setCategoryMargin(0.0); 875 876 ValueAxis valueAxis = new NumberAxis(valueAxisLabel); 877 878 AreaRenderer renderer = new AreaRenderer(); 879 if (tooltips) { 880 renderer.setBaseToolTipGenerator( 881 new StandardCategoryToolTipGenerator() 882 ); 883 } 884 if (urls) { 885 renderer.setBaseItemURLGenerator( 886 new StandardCategoryURLGenerator() 887 ); 888 } 889 890 CategoryPlot plot = new CategoryPlot( 891 dataset, categoryAxis, valueAxis, renderer 892 ); 893 plot.setOrientation(orientation); 894 JFreeChart chart = new JFreeChart( 895 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 896 ); 897 898 return chart; 899 900 } 901 902 923 public static JFreeChart createStackedAreaChart(String title, 924 String categoryAxisLabel, 925 String valueAxisLabel, 926 CategoryDataset dataset, 927 PlotOrientation orientation, 928 boolean legend, 929 boolean tooltips, 930 boolean urls) { 931 932 if (orientation == null) { 933 throw new IllegalArgumentException ("Null 'orientation' argument."); 934 } 935 CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); 936 ValueAxis valueAxis = new NumberAxis(valueAxisLabel); 937 938 StackedAreaRenderer renderer = new StackedAreaRenderer(); 939 if (tooltips) { 940 renderer.setBaseToolTipGenerator( 941 new StandardCategoryToolTipGenerator() 942 ); 943 } 944 if (urls) { 945 renderer.setBaseItemURLGenerator( 946 new StandardCategoryURLGenerator() 947 ); 948 } 949 950 CategoryPlot plot = new CategoryPlot( 951 dataset, categoryAxis, valueAxis, renderer 952 ); 953 plot.setOrientation(orientation); 954 JFreeChart chart = new JFreeChart( 955 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 956 ); 957 958 return chart; 959 960 } 961 962 982 public static JFreeChart createLineChart(String title, 983 String categoryAxisLabel, 984 String valueAxisLabel, 985 CategoryDataset dataset, 986 PlotOrientation orientation, 987 boolean legend, 988 boolean tooltips, 989 boolean urls) { 990 991 if (orientation == null) { 992 throw new IllegalArgumentException ("Null 'orientation' argument."); 993 } 994 CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); 995 ValueAxis valueAxis = new NumberAxis(valueAxisLabel); 996 997 LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false); 998 if (tooltips) { 999 renderer.setBaseToolTipGenerator( 1000 new StandardCategoryToolTipGenerator() 1001 ); 1002 } 1003 if (urls) { 1004 renderer.setBaseItemURLGenerator( 1005 new StandardCategoryURLGenerator() 1006 ); 1007 } 1008 CategoryPlot plot = new CategoryPlot( 1009 dataset, categoryAxis, valueAxis, renderer 1010 ); 1011 plot.setOrientation(orientation); 1012 JFreeChart chart = new JFreeChart( 1013 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1014 ); 1015 1016 return chart; 1017 1018 } 1019 1020 1040 public static JFreeChart createLineChart3D(String title, 1041 String categoryAxisLabel, 1042 String valueAxisLabel, 1043 CategoryDataset dataset, 1044 PlotOrientation orientation, 1045 boolean legend, 1046 boolean tooltips, 1047 boolean urls) { 1048 1049 if (orientation == null) { 1050 throw new IllegalArgumentException ("Null 'orientation' argument."); 1051 } 1052 CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); 1053 ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); 1054 1055 LineRenderer3D renderer = new LineRenderer3D(); 1056 if (tooltips) { 1057 renderer.setBaseToolTipGenerator( 1058 new StandardCategoryToolTipGenerator() 1059 ); 1060 } 1061 if (urls) { 1062 renderer.setBaseItemURLGenerator( 1063 new StandardCategoryURLGenerator() 1064 ); 1065 } 1066 CategoryPlot plot = new CategoryPlot( 1067 dataset, categoryAxis, valueAxis, renderer 1068 ); 1069 plot.setOrientation(orientation); 1070 JFreeChart chart = new JFreeChart( 1071 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1072 ); 1073 1074 return chart; 1075 1076 } 1077 1078 1097 public static JFreeChart createGanttChart(String title, 1098 String categoryAxisLabel, 1099 String dateAxisLabel, 1100 IntervalCategoryDataset dataset, 1101 boolean legend, 1102 boolean tooltips, 1103 boolean urls) { 1104 1105 CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); 1106 DateAxis dateAxis = new DateAxis(dateAxisLabel); 1107 1108 CategoryItemRenderer renderer = new GanttRenderer(); 1109 if (tooltips) { 1110 renderer.setBaseToolTipGenerator( 1111 new IntervalCategoryToolTipGenerator( 1112 "{3} - {4}", DateFormat.getDateInstance() 1113 ) 1114 ); 1115 } 1116 if (urls) { 1117 renderer.setBaseItemURLGenerator( 1118 new StandardCategoryURLGenerator() 1119 ); 1120 } 1121 1122 CategoryPlot plot = new CategoryPlot( 1123 dataset, categoryAxis, dateAxis, renderer 1124 ); 1125 plot.setOrientation(PlotOrientation.HORIZONTAL); 1126 JFreeChart chart = new JFreeChart( 1127 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1128 ); 1129 1130 return chart; 1131 1132 } 1133 1134 1154 public static JFreeChart createWaterfallChart(String title, 1155 String categoryAxisLabel, 1156 String valueAxisLabel, 1157 CategoryDataset dataset, 1158 PlotOrientation orientation, 1159 boolean legend, 1160 boolean tooltips, 1161 boolean urls) { 1162 1163 if (orientation == null) { 1164 throw new IllegalArgumentException ("Null 'orientation' argument."); 1165 } 1166 CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); 1167 categoryAxis.setCategoryMargin(0.0); 1168 1169 ValueAxis valueAxis = new NumberAxis(valueAxisLabel); 1170 1171 WaterfallBarRenderer renderer = new WaterfallBarRenderer(); 1172 if (orientation == PlotOrientation.HORIZONTAL) { 1173 ItemLabelPosition position = new ItemLabelPosition( 1174 ItemLabelAnchor.CENTER, TextAnchor.CENTER, 1175 TextAnchor.CENTER, Math.PI / 2.0 1176 ); 1177 renderer.setPositiveItemLabelPosition(position); 1178 renderer.setNegativeItemLabelPosition(position); 1179 } 1180 else if (orientation == PlotOrientation.VERTICAL) { 1181 ItemLabelPosition position = new ItemLabelPosition( 1182 ItemLabelAnchor.CENTER, TextAnchor.CENTER, 1183 TextAnchor.CENTER, 0.0 1184 ); 1185 renderer.setPositiveItemLabelPosition(position); 1186 renderer.setNegativeItemLabelPosition(position); 1187 } 1188 if (tooltips) { 1189 StandardCategoryToolTipGenerator generator 1190 = new StandardCategoryToolTipGenerator(); 1191 renderer.setBaseToolTipGenerator(generator); 1192 } 1193 if (urls) { 1194 renderer.setBaseItemURLGenerator( 1195 new StandardCategoryURLGenerator() 1196 ); 1197 } 1198 1199 CategoryPlot plot = new CategoryPlot( 1200 dataset, categoryAxis, valueAxis, renderer 1201 ); 1202 plot.clearRangeMarkers(); 1203 Marker baseline = new ValueMarker(0.0); 1204 baseline.setPaint(Color.black); 1205 plot.addRangeMarker(baseline, Layer.FOREGROUND); 1206 plot.setOrientation(orientation); 1207 JFreeChart chart = new JFreeChart( 1208 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1209 ); 1210 1211 return chart; 1212 1213 } 1214 1215 1229 public static JFreeChart createPolarChart(String title, 1230 XYDataset dataset, 1231 boolean legend, 1232 boolean tooltips, 1233 boolean urls) { 1234 1235 PolarPlot plot = new PolarPlot(); 1236 plot.setDataset(dataset); 1237 NumberAxis rangeAxis = new NumberAxis(); 1238 rangeAxis.setAxisLineVisible(false); 1239 rangeAxis.setTickMarksVisible(false); 1240 rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); 1241 plot.setAxis(rangeAxis); 1242 plot.setRenderer(new DefaultPolarItemRenderer()); 1243 JFreeChart chart = new JFreeChart( 1244 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1245 ); 1246 return chart; 1247 1248 } 1249 1250 1270 public static JFreeChart createScatterPlot(String title, 1271 String xAxisLabel, 1272 String yAxisLabel, 1273 XYDataset dataset, 1274 PlotOrientation orientation, 1275 boolean legend, 1276 boolean tooltips, 1277 boolean urls) { 1278 1279 if (orientation == null) { 1280 throw new IllegalArgumentException ("Null 'orientation' argument."); 1281 } 1282 NumberAxis xAxis = new NumberAxis(xAxisLabel); 1283 xAxis.setAutoRangeIncludesZero(false); 1284 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1285 yAxis.setAutoRangeIncludesZero(false); 1286 1287 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); 1288 1289 XYToolTipGenerator toolTipGenerator = null; 1290 if (tooltips) { 1291 toolTipGenerator = new StandardXYToolTipGenerator(); 1292 } 1293 1294 XYURLGenerator urlGenerator = null; 1295 if (urls) { 1296 urlGenerator = new StandardXYURLGenerator(); 1297 } 1298 XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); 1299 renderer.setBaseToolTipGenerator(toolTipGenerator); 1300 renderer.setURLGenerator(urlGenerator); 1301 plot.setRenderer(renderer); 1302 plot.setOrientation(orientation); 1303 1304 JFreeChart chart = new JFreeChart( 1305 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1306 ); 1307 1308 return chart; 1309 1310 } 1311 1312 1333 public static JFreeChart createXYBarChart(String title, 1334 String xAxisLabel, 1335 boolean dateAxis, 1336 String yAxisLabel, 1337 IntervalXYDataset dataset, 1338 PlotOrientation orientation, 1339 boolean legend, 1340 boolean tooltips, 1341 boolean urls) { 1342 1343 if (orientation == null) { 1344 throw new IllegalArgumentException ("Null 'orientation' argument."); 1345 } 1346 ValueAxis domainAxis = null; 1347 if (dateAxis) { 1348 domainAxis = new DateAxis(xAxisLabel); 1349 } 1350 else { 1351 NumberAxis axis = new NumberAxis(xAxisLabel); 1352 axis.setAutoRangeIncludesZero(false); 1353 domainAxis = axis; 1354 } 1355 ValueAxis valueAxis = new NumberAxis(yAxisLabel); 1356 1357 XYBarRenderer renderer = new XYBarRenderer(); 1358 if (tooltips) { 1359 renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); 1360 } 1361 if (urls) { 1362 renderer.setURLGenerator(new StandardXYURLGenerator()); 1363 } 1364 1365 XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer); 1366 plot.setOrientation(orientation); 1367 1368 JFreeChart chart = new JFreeChart( 1369 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1370 ); 1371 1372 return chart; 1373 1374 } 1375 1376 1396 public static JFreeChart createXYAreaChart(String title, 1397 String xAxisLabel, 1398 String yAxisLabel, 1399 XYDataset dataset, 1400 PlotOrientation orientation, 1401 boolean legend, 1402 boolean tooltips, 1403 boolean urls) { 1404 1405 if (orientation == null) { 1406 throw new IllegalArgumentException ("Null 'orientation' argument."); 1407 } 1408 NumberAxis xAxis = new NumberAxis(xAxisLabel); 1409 xAxis.setAutoRangeIncludesZero(false); 1410 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1411 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); 1412 plot.setOrientation(orientation); 1413 plot.setForegroundAlpha(0.5f); 1414 1415 XYToolTipGenerator tipGenerator = null; 1416 if (tooltips) { 1417 tipGenerator = new StandardXYToolTipGenerator(); 1418 } 1419 1420 XYURLGenerator urlGenerator = null; 1421 if (urls) { 1422 urlGenerator = new StandardXYURLGenerator(); 1423 } 1424 1425 plot.setRenderer( 1426 new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator) 1427 ); 1428 JFreeChart chart = new JFreeChart( 1429 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1430 ); 1431 1432 return chart; 1433 1434 } 1435 1436 1454 public static JFreeChart createStackedXYAreaChart(String title, 1455 String xAxisLabel, 1456 String yAxisLabel, 1457 TableXYDataset dataset, 1458 PlotOrientation orientation, 1459 boolean legend, 1460 boolean tooltips, 1461 boolean urls) { 1462 1463 if (orientation == null) { 1464 throw new IllegalArgumentException ("Null 'orientation' argument."); 1465 } 1466 NumberAxis xAxis = new NumberAxis(xAxisLabel); 1467 xAxis.setAutoRangeIncludesZero(false); 1468 xAxis.setLowerMargin(0.0); 1469 xAxis.setUpperMargin(0.0); 1470 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1471 XYToolTipGenerator toolTipGenerator = null; 1472 if (tooltips) { 1473 toolTipGenerator = new StandardXYToolTipGenerator(); 1474 } 1475 1476 XYURLGenerator urlGenerator = null; 1477 if (urls) { 1478 urlGenerator = new StandardXYURLGenerator(); 1479 } 1480 StackedXYAreaRenderer renderer = new StackedXYAreaRenderer( 1481 XYAreaRenderer.AREA, toolTipGenerator, urlGenerator 1482 ); 1483 renderer.setOutline(true); 1484 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); 1485 plot.setOrientation(orientation); 1486 1487 plot.setRangeAxis(yAxis); 1489 JFreeChart chart = new JFreeChart( 1490 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1491 ); 1492 return chart; 1493 1494 } 1495 1496 1512 public static JFreeChart createXYLineChart(String title, 1513 String xAxisLabel, 1514 String yAxisLabel, 1515 XYDataset dataset, 1516 PlotOrientation orientation, 1517 boolean legend, 1518 boolean tooltips, 1519 boolean urls) { 1520 1521 if (orientation == null) { 1522 throw new IllegalArgumentException ("Null 'orientation' argument."); 1523 } 1524 NumberAxis xAxis = new NumberAxis(xAxisLabel); 1525 xAxis.setAutoRangeIncludesZero(false); 1526 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1527 XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); 1528 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); 1529 plot.setOrientation(orientation); 1530 if (tooltips) { 1531 renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); 1532 } 1533 if (urls) { 1534 renderer.setURLGenerator(new StandardXYURLGenerator()); 1535 } 1536 1537 JFreeChart chart = new JFreeChart( 1538 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1539 ); 1540 1541 return chart; 1542 1543 } 1544 1545 1560 public static JFreeChart createXYStepChart(String title, 1561 String xAxisLabel, 1562 String yAxisLabel, 1563 XYDataset dataset, 1564 PlotOrientation orientation, 1565 boolean legend, 1566 boolean tooltips, 1567 boolean urls) { 1568 1569 if (orientation == null) { 1570 throw new IllegalArgumentException ("Null 'orientation' argument."); 1571 } 1572 DateAxis xAxis = new DateAxis(xAxisLabel); 1573 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1574 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 1575 1576 XYToolTipGenerator toolTipGenerator = null; 1577 if (tooltips) { 1578 toolTipGenerator = new StandardXYToolTipGenerator(); 1579 } 1580 1581 XYURLGenerator urlGenerator = null; 1582 if (urls) { 1583 urlGenerator = new StandardXYURLGenerator(); 1584 } 1585 XYItemRenderer renderer 1586 = new XYStepRenderer(toolTipGenerator, urlGenerator); 1587 1588 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); 1589 plot.setRenderer(renderer); 1590 plot.setOrientation(orientation); 1591 plot.setDomainCrosshairVisible(false); 1592 plot.setRangeCrosshairVisible(false); 1593 JFreeChart chart = new JFreeChart( 1594 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1595 ); 1596 return chart; 1597 1598 } 1599 1600 1615 public static JFreeChart createXYStepAreaChart(String title, 1616 String xAxisLabel, 1617 String yAxisLabel, 1618 XYDataset dataset, 1619 PlotOrientation orientation, 1620 boolean legend, 1621 boolean tooltips, 1622 boolean urls) { 1623 1624 if (orientation == null) { 1625 throw new IllegalArgumentException ("Null 'orientation' argument."); 1626 } 1627 NumberAxis xAxis = new NumberAxis(xAxisLabel); 1628 xAxis.setAutoRangeIncludesZero(false); 1629 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1630 1631 XYToolTipGenerator toolTipGenerator = null; 1632 if (tooltips) { 1633 toolTipGenerator = new StandardXYToolTipGenerator(); 1634 } 1635 1636 XYURLGenerator urlGenerator = null; 1637 if (urls) { 1638 urlGenerator = new StandardXYURLGenerator(); 1639 } 1640 XYItemRenderer renderer = new XYStepAreaRenderer( 1641 XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, urlGenerator 1642 ); 1643 1644 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); 1645 plot.setRenderer(renderer); 1646 plot.setOrientation(orientation); 1647 plot.setDomainCrosshairVisible(false); 1648 plot.setRangeCrosshairVisible(false); 1649 JFreeChart chart = new JFreeChart( 1650 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1651 ); 1652 return chart; 1653 } 1654 1655 1676 public static JFreeChart createTimeSeriesChart(String title, 1677 String timeAxisLabel, 1678 String valueAxisLabel, 1679 XYDataset dataset, 1680 boolean legend, 1681 boolean tooltips, 1682 boolean urls) { 1683 1684 ValueAxis timeAxis = new DateAxis(timeAxisLabel); 1685 timeAxis.setLowerMargin(0.02); timeAxis.setUpperMargin(0.02); 1687 NumberAxis valueAxis = new NumberAxis(valueAxisLabel); 1688 valueAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); 1690 1691 XYToolTipGenerator toolTipGenerator = null; 1692 if (tooltips) { 1693 toolTipGenerator 1694 = StandardXYToolTipGenerator.getTimeSeriesInstance(); 1695 } 1696 1697 XYURLGenerator urlGenerator = null; 1698 if (urls) { 1699 urlGenerator = new StandardXYURLGenerator(); 1700 } 1701 1702 XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); 1703 renderer.setDefaultLinesVisible(true); 1704 renderer.setDefaultShapesVisible(false); 1705 renderer.setBaseToolTipGenerator(toolTipGenerator); 1706 renderer.setURLGenerator(urlGenerator); 1707 plot.setRenderer(renderer); 1708 1709 JFreeChart chart = new JFreeChart( 1710 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1711 ); 1712 return chart; 1713 1714 } 1715 1716 1729 public static JFreeChart createCandlestickChart(String title, 1730 String timeAxisLabel, 1731 String valueAxisLabel, 1732 OHLCDataset dataset, 1733 boolean legend) { 1734 1735 ValueAxis timeAxis = new DateAxis(timeAxisLabel); 1736 NumberAxis valueAxis = new NumberAxis(valueAxisLabel); 1737 XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); 1738 plot.setRenderer(new CandlestickRenderer()); 1739 JFreeChart chart = new JFreeChart( 1740 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1741 ); 1742 return chart; 1743 1744 } 1745 1746 1759 public static JFreeChart createHighLowChart(String title, 1760 String timeAxisLabel, 1761 String valueAxisLabel, 1762 OHLCDataset dataset, 1763 boolean legend) { 1764 1765 ValueAxis timeAxis = new DateAxis(timeAxisLabel); 1766 NumberAxis valueAxis = new NumberAxis(valueAxisLabel); 1767 HighLowRenderer renderer = new HighLowRenderer(); 1768 renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); 1769 XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); 1770 JFreeChart chart = new JFreeChart( 1771 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1772 ); 1773 return chart; 1774 1775 } 1776 1777 1795 public static JFreeChart createHighLowChart(String title, 1796 String timeAxisLabel, 1797 String valueAxisLabel, 1798 OHLCDataset dataset, 1799 Timeline timeline, 1800 boolean legend) { 1801 1802 DateAxis timeAxis = new DateAxis(timeAxisLabel); 1803 timeAxis.setTimeline(timeline); 1804 NumberAxis valueAxis = new NumberAxis(valueAxisLabel); 1805 HighLowRenderer renderer = new HighLowRenderer(); 1806 renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); 1807 XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); 1808 JFreeChart chart = new JFreeChart( 1809 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1810 ); 1811 return chart; 1812 1813 } 1814 1815 1828 public static JFreeChart createSignalChart(String title, 1829 String timeAxisLabel, 1830 String valueAxisLabel, 1831 SignalsDataset dataset, 1832 boolean legend) { 1833 1834 ValueAxis timeAxis = new DateAxis(timeAxisLabel); 1835 NumberAxis valueAxis = new NumberAxis(valueAxisLabel); 1836 XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); 1837 plot.setRenderer(new SignalRenderer()); 1838 JFreeChart chart = new JFreeChart( 1839 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1840 ); 1841 return chart; 1842 1843 } 1844 1845 1863 public static JFreeChart createBubbleChart(String title, 1864 String xAxisLabel, 1865 String yAxisLabel, 1866 XYZDataset dataset, 1867 PlotOrientation orientation, 1868 boolean legend, 1869 boolean tooltips, 1870 boolean urls) { 1871 1872 if (orientation == null) { 1873 throw new IllegalArgumentException ("Null 'orientation' argument."); 1874 } 1875 NumberAxis xAxis = new NumberAxis(xAxisLabel); 1876 xAxis.setAutoRangeIncludesZero(false); 1877 NumberAxis yAxis = new NumberAxis(yAxisLabel); 1878 yAxis.setAutoRangeIncludesZero(false); 1879 1880 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); 1881 1882 XYItemRenderer renderer = new XYBubbleRenderer( 1883 XYBubbleRenderer.SCALE_ON_RANGE_AXIS 1884 ); 1885 if (tooltips) { 1886 renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); 1887 } 1888 if (urls) { 1889 renderer.setURLGenerator(new StandardXYZURLGenerator()); 1890 } 1891 plot.setRenderer(renderer); 1892 plot.setOrientation(orientation); 1893 1894 JFreeChart chart = new JFreeChart( 1895 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1896 ); 1897 1898 return chart; 1899 1900 } 1901 1902 1919 public static JFreeChart createHistogram(String title, 1920 String xAxisLabel, 1921 String yAxisLabel, 1922 IntervalXYDataset dataset, 1923 PlotOrientation orientation, 1924 boolean legend, 1925 boolean tooltips, 1926 boolean urls) { 1927 1928 if (orientation == null) { 1929 throw new IllegalArgumentException ("Null 'orientation' argument."); 1930 } 1931 ValueAxis xAxis = new NumberAxis(xAxisLabel); 1932 ValueAxis yAxis = new NumberAxis(yAxisLabel); 1933 1934 XYItemRenderer renderer = new XYBarRenderer(); 1935 if (tooltips) { 1936 renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); 1937 } 1938 if (urls) { 1939 renderer.setURLGenerator(new StandardXYURLGenerator()); 1940 } 1941 1942 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); 1943 plot.setOrientation(orientation); 1944 JFreeChart chart = new JFreeChart( 1945 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1946 ); 1947 return chart; 1948 1949 } 1950 1951 1964 public static JFreeChart createBoxAndWhiskerChart(String title, 1965 String timeAxisLabel, 1966 String valueAxisLabel, 1967 BoxAndWhiskerXYDataset dataset, 1968 boolean legend) { 1969 1970 ValueAxis timeAxis = new DateAxis(timeAxisLabel); 1971 NumberAxis valueAxis = new NumberAxis(valueAxisLabel); 1972 valueAxis.setAutoRangeIncludesZero(false); 1973 XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); 1974 XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); 1975 return new JFreeChart( 1976 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 1977 ); 1978 1979 } 1980 1981 1995 public static JFreeChart createWindPlot(String title, 1996 String xAxisLabel, 1997 String yAxisLabel, 1998 WindDataset dataset, 1999 boolean legend, 2000 boolean tooltips, 2001 boolean urls) { 2002 2003 ValueAxis xAxis = new DateAxis(xAxisLabel); 2004 ValueAxis yAxis = new NumberAxis(yAxisLabel); 2005 yAxis.setRange(-12.0, 12.0); 2006 2007 WindItemRenderer renderer = new WindItemRenderer(); 2008 if (tooltips) { 2009 renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); 2010 } 2011 if (urls) { 2012 renderer.setURLGenerator(new StandardXYURLGenerator()); 2013 } 2014 XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); 2015 JFreeChart chart = new JFreeChart( 2016 title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend 2017 ); 2018 2019 return chart; 2020 2021 } 2022 2023 2036 public static JFreeChart createWaferMapChart(String title, 2037 WaferMapDataset dataset, 2038 PlotOrientation orientation, 2039 boolean legend, 2040 boolean tooltips, 2041 boolean urls) { 2042 2043 if (orientation == null) { 2044 throw new IllegalArgumentException ("Null 'orientation' argument."); 2045 } 2046 WaferMapPlot plot = new WaferMapPlot(dataset); 2047 WaferMapRenderer renderer = new WaferMapRenderer(); 2048 plot.setRenderer(renderer); 2049 2050 JFreeChart chart = new JFreeChart( 2051 title, 2052 JFreeChart.DEFAULT_TITLE_FONT, 2053 plot, 2054 legend 2055 ); 2056 2057 return chart; 2058 } 2059 2060} 2061 | Popular Tags |