1:
115:
116: package ;
117:
118: import ;
119: import ;
120: import ;
121: import ;
122: import ;
123: import ;
124:
125: import ;
126: import ;
127: import ;
128: import ;
129: import ;
130: import ;
131: import ;
132: import ;
133: import ;
134: import ;
135: import ;
136: import ;
137: import ;
138: import ;
139: import ;
140: import ;
141: import ;
142: import ;
143: import ;
144: import ;
145: import ;
146: import ;
147: import ;
148: import ;
149: import ;
150: import ;
151: import ;
152: import ;
153: import ;
154: import ;
155: import ;
156: import ;
157: import ;
158: import ;
159: import ;
160: import ;
161: import ;
162: import ;
163: import ;
164: import ;
165: import ;
166: import ;
167: import ;
168: import ;
169: import ;
170: import ;
171: import ;
172: import ;
173: import ;
174: import ;
175: import ;
176: import ;
177: import ;
178: import ;
179: import ;
180: import ;
181: import ;
182: import ;
183: import ;
184: import ;
185: import ;
186: import ;
187: import ;
188: import ;
189: import ;
190: import ;
191: import ;
192: import ;
193: import ;
194: import ;
195: import ;
196: import ;
197: import ;
198: import ;
199: import ;
200: import ;
201: import ;
202: import ;
203: import ;
204:
205:
209: public abstract class ChartFactory {
210:
211:
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:
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:
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:
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:
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:
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:
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:
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:
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:
729:
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:
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:
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:
790: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
791: renderer);
792: plot.setOrientation(orientation);
793: if (orientation == PlotOrientation.HORIZONTAL) {
794:
795:
796: plot.setColumnRenderingOrder(SortOrder.DESCENDING);
797: }
798:
799:
800: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
801: plot, legend);
802:
803: return chart;
804:
805: }
806:
807:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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);
1416:
1417: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1418: plot, legend);
1419: return chart;
1420:
1421: }
1422:
1423:
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:
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:
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:
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);
1610: timeAxis.setUpperMargin(0.02);
1611: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1612: valueAxis.setAutoRangeIncludesZero(false);
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:
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:
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:
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:
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:
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:
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:
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:
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: }