1:
120:
121: package ;
122:
123: import ;
124: import ;
125: import ;
126: import ;
127: import ;
128: import ;
129: import ;
130:
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: import ;
205: import ;
206: import ;
207: import ;
208: import ;
209: import ;
210: import ;
211: import ;
212: import ;
213:
214:
218: public abstract class ChartFactory {
219:
220:
236: public static JFreeChart createPieChart(String title, PieDataset dataset,
237: boolean legend, boolean tooltips, Locale locale) {
238:
239: PiePlot plot = new PiePlot(dataset);
240: plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
241: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
242: if (tooltips) {
243: plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
244: }
245: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
246: legend);
247:
248: }
249:
250:
264: public static JFreeChart createPieChart(String title,
265: PieDataset dataset,
266: boolean legend,
267: boolean tooltips,
268: boolean urls) {
269:
270: PiePlot plot = new PiePlot(dataset);
271: plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
272: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
273: if (tooltips) {
274: plot.setToolTipGenerator(new StandardPieToolTipGenerator());
275: }
276: if (urls) {
277: plot.setURLGenerator(new StandardPieURLGenerator());
278: }
279: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
280: legend);
281:
282: }
283:
284:
324: public static JFreeChart createPieChart(String title, PieDataset dataset,
325: PieDataset previousDataset, int percentDiffForMaxScale,
326: boolean greenForIncrease, boolean legend, boolean tooltips,
327: Locale locale, boolean subTitle, boolean showDifference) {
328:
329: PiePlot plot = new PiePlot(dataset);
330: plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
331: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
332:
333: if (tooltips) {
334: plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
335: }
336:
337: List keys = dataset.getKeys();
338: DefaultPieDataset series = null;
339: if (showDifference) {
340: series = new DefaultPieDataset();
341: }
342:
343: double colorPerPercent = 255.0 / percentDiffForMaxScale;
344: for (Iterator it = keys.iterator(); it.hasNext();) {
345: Comparable key = (Comparable) it.next();
346: Number newValue = dataset.getValue(key);
347: Number oldValue = previousDataset.getValue(key);
348:
349: if (oldValue == null) {
350: if (greenForIncrease) {
351: plot.setSectionPaint(key, Color.green);
352: }
353: else {
354: plot.setSectionPaint(key, Color.red);
355: }
356: if (showDifference) {
357: series.setValue(key + " (+100%)", newValue);
358: }
359: }
360: else {
361: double percentChange = (newValue.doubleValue()
362: / oldValue.doubleValue() - 1.0) * 100.0;
363: double shade
364: = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
365: : Math.abs(percentChange) * colorPerPercent);
366: if (greenForIncrease
367: && newValue.doubleValue() > oldValue.doubleValue()
368: || !greenForIncrease && newValue.doubleValue()
369: < oldValue.doubleValue()) {
370: plot.setSectionPaint(key, new Color(0, (int) shade, 0));
371: }
372: else {
373: plot.setSectionPaint(key, new Color((int) shade, 0, 0));
374: }
375: if (showDifference) {
376: series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")
377: + NumberFormat.getPercentInstance().format(
378: percentChange / 100.0) + ")", newValue);
379: }
380: }
381: }
382:
383: if (showDifference) {
384: plot.setDataset(series);
385: }
386:
387: JFreeChart chart = new JFreeChart(title,
388: JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
389:
390: if (subTitle) {
391: TextTitle subtitle = null;
392: subtitle = new TextTitle("Bright " + (greenForIncrease ? "red"
393: : "green") + "=change >=-" + percentDiffForMaxScale
394: + "%, Bright " + (!greenForIncrease ? "red" : "green")
395: + "=change >=+" + percentDiffForMaxScale + "%",
396: new Font("SansSerif", Font.PLAIN, 10));
397: chart.addSubtitle(subtitle);
398: }
399:
400: return chart;
401: }
402:
403:
441: public static JFreeChart createPieChart(String title,
442: PieDataset dataset,
443: PieDataset previousDataset,
444: int percentDiffForMaxScale,
445: boolean greenForIncrease,
446: boolean legend,
447: boolean tooltips,
448: boolean urls,
449: boolean subTitle,
450: boolean showDifference) {
451:
452: PiePlot plot = new PiePlot(dataset);
453: plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
454: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
455:
456: if (tooltips) {
457: plot.setToolTipGenerator(new StandardPieToolTipGenerator());
458: }
459: if (urls) {
460: plot.setURLGenerator(new StandardPieURLGenerator());
461: }
462:
463: List keys = dataset.getKeys();
464: DefaultPieDataset series = null;
465: if (showDifference) {
466: series = new DefaultPieDataset();
467: }
468:
469: double colorPerPercent = 255.0 / percentDiffForMaxScale;
470: for (Iterator it = keys.iterator(); it.hasNext();) {
471: Comparable key = (Comparable) it.next();
472: Number newValue = dataset.getValue(key);
473: Number oldValue = previousDataset.getValue(key);
474:
475: if (oldValue == null) {
476: if (greenForIncrease) {
477: plot.setSectionPaint(key, Color.green);
478: }
479: else {
480: plot.setSectionPaint(key, Color.red);
481: }
482: if (showDifference) {
483: series.setValue(key + " (+100%)", newValue);
484: }
485: }
486: else {
487: double percentChange = (newValue.doubleValue()
488: / oldValue.doubleValue() - 1.0) * 100.0;
489: double shade
490: = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
491: : Math.abs(percentChange) * colorPerPercent);
492: if (greenForIncrease
493: && newValue.doubleValue() > oldValue.doubleValue()
494: || !greenForIncrease && newValue.doubleValue()
495: < oldValue.doubleValue()) {
496: plot.setSectionPaint(key, new Color(0, (int) shade, 0));
497: }
498: else {
499: plot.setSectionPaint(key, new Color((int) shade, 0, 0));
500: }
501: if (showDifference) {
502: series.setValue(key + " (" + (percentChange >= 0 ? "+" : "")
503: + NumberFormat.getPercentInstance().format(
504: percentChange / 100.0) + ")", newValue);
505: }
506: }
507: }
508:
509: if (showDifference) {
510: plot.setDataset(series);
511: }
512:
513: JFreeChart chart = new JFreeChart(title,
514: JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
515:
516: if (subTitle) {
517: TextTitle subtitle = null;
518: subtitle = new TextTitle("Bright " + (greenForIncrease ? "red"
519: : "green") + "=change >=-" + percentDiffForMaxScale
520: + "%, Bright " + (!greenForIncrease ? "red" : "green")
521: + "=change >=+" + percentDiffForMaxScale + "%",
522: new Font("SansSerif", Font.PLAIN, 10));
523: chart.addSubtitle(subtitle);
524: }
525:
526: return chart;
527: }
528:
529:
545: public static JFreeChart createRingChart(String title, PieDataset dataset,
546: boolean legend, boolean tooltips, Locale locale) {
547:
548: RingPlot plot = new RingPlot(dataset);
549: plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
550: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
551: if (tooltips) {
552: plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
553: }
554: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
555: legend);
556:
557: }
558:
559:
573: public static JFreeChart createRingChart(String title,
574: PieDataset dataset,
575: boolean legend,
576: boolean tooltips,
577: boolean urls) {
578:
579: RingPlot plot = new RingPlot(dataset);
580: plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
581: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
582: if (tooltips) {
583: plot.setToolTipGenerator(new StandardPieToolTipGenerator());
584: }
585: if (urls) {
586: plot.setURLGenerator(new StandardPieURLGenerator());
587: }
588: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
589: legend);
590:
591: }
592:
593:
608: public static JFreeChart createMultiplePieChart(String title,
609: CategoryDataset dataset,
610: TableOrder order,
611: boolean legend,
612: boolean tooltips,
613: boolean urls) {
614:
615: if (order == null) {
616: throw new IllegalArgumentException("Null 'order' argument.");
617: }
618: MultiplePiePlot plot = new MultiplePiePlot(dataset);
619: plot.setDataExtractOrder(order);
620: plot.setBackgroundPaint(null);
621: plot.setOutlineStroke(null);
622:
623: if (tooltips) {
624: PieToolTipGenerator tooltipGenerator
625: = new StandardPieToolTipGenerator();
626: PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
627: pp.setToolTipGenerator(tooltipGenerator);
628: }
629:
630: if (urls) {
631: PieURLGenerator urlGenerator = new StandardPieURLGenerator();
632: PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
633: pp.setURLGenerator(urlGenerator);
634: }
635:
636: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
637: plot, legend);
638:
639: return chart;
640:
641: }
642:
643:
658: public static JFreeChart createPieChart3D(String title, PieDataset dataset,
659: boolean legend, boolean tooltips, Locale locale) {
660:
661: PiePlot3D plot = new PiePlot3D(dataset);
662: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
663: if (tooltips) {
664: plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
665: }
666: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
667: legend);
668:
669: }
670:
671:
684: public static JFreeChart createPieChart3D(String title,
685: PieDataset dataset,
686: boolean legend,
687: boolean tooltips,
688: boolean urls) {
689:
690: PiePlot3D plot = new PiePlot3D(dataset);
691: plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
692: if (tooltips) {
693: plot.setToolTipGenerator(new StandardPieToolTipGenerator());
694: }
695: if (urls) {
696: plot.setURLGenerator(new StandardPieURLGenerator());
697: }
698: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
699: legend);
700:
701: }
702:
703:
718: public static JFreeChart createMultiplePieChart3D(String title,
719: CategoryDataset dataset,
720: TableOrder order,
721: boolean legend,
722: boolean tooltips,
723: boolean urls) {
724:
725: if (order == null) {
726: throw new IllegalArgumentException("Null 'order' argument.");
727: }
728: MultiplePiePlot plot = new MultiplePiePlot(dataset);
729: plot.setDataExtractOrder(order);
730: plot.setBackgroundPaint(null);
731: plot.setOutlineStroke(null);
732:
733: JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
734: TextTitle seriesTitle = new TextTitle("Series Title",
735: new Font("SansSerif", Font.BOLD, 12));
736: seriesTitle.setPosition(RectangleEdge.BOTTOM);
737: pieChart.setTitle(seriesTitle);
738: pieChart.removeLegend();
739: pieChart.setBackgroundPaint(null);
740: plot.setPieChart(pieChart);
741:
742: if (tooltips) {
743: PieToolTipGenerator tooltipGenerator
744: = new StandardPieToolTipGenerator();
745: PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
746: pp.setToolTipGenerator(tooltipGenerator);
747: }
748:
749: if (urls) {
750: PieURLGenerator urlGenerator = new StandardPieURLGenerator();
751: PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
752: pp.setURLGenerator(urlGenerator);
753: }
754:
755: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
756: plot, legend);
757:
758: return chart;
759:
760: }
761:
762:
782: public static JFreeChart createBarChart(String title,
783: String categoryAxisLabel,
784: String valueAxisLabel,
785: CategoryDataset dataset,
786: PlotOrientation orientation,
787: boolean legend,
788: boolean tooltips,
789: boolean urls) {
790:
791: if (orientation == null) {
792: throw new IllegalArgumentException("Null 'orientation' argument.");
793: }
794: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
795: ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
796:
797: BarRenderer renderer = new BarRenderer();
798: if (orientation == PlotOrientation.HORIZONTAL) {
799: ItemLabelPosition position1 = new ItemLabelPosition(
800: ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
801: renderer.setBasePositiveItemLabelPosition(position1);
802: ItemLabelPosition position2 = new ItemLabelPosition(
803: ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
804: renderer.setBaseNegativeItemLabelPosition(position2);
805: }
806: else if (orientation == PlotOrientation.VERTICAL) {
807: ItemLabelPosition position1 = new ItemLabelPosition(
808: ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
809: renderer.setBasePositiveItemLabelPosition(position1);
810: ItemLabelPosition position2 = new ItemLabelPosition(
811: ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
812: renderer.setBaseNegativeItemLabelPosition(position2);
813: }
814: if (tooltips) {
815: renderer.setBaseToolTipGenerator(
816: new StandardCategoryToolTipGenerator());
817: }
818: if (urls) {
819: renderer.setBaseItemURLGenerator(
820: new StandardCategoryURLGenerator());
821: }
822:
823: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
824: renderer);
825: plot.setOrientation(orientation);
826: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
827: plot, legend);
828:
829: return chart;
830:
831: }
832:
833:
854: public static JFreeChart createStackedBarChart(String title,
855: String domainAxisLabel,
856: String rangeAxisLabel,
857: CategoryDataset dataset,
858: PlotOrientation orientation,
859: boolean legend,
860: boolean tooltips,
861: boolean urls) {
862:
863: if (orientation == null) {
864: throw new IllegalArgumentException("Null 'orientation' argument.");
865: }
866:
867: CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
868: ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);
869:
870: StackedBarRenderer renderer = new StackedBarRenderer();
871: if (tooltips) {
872: renderer.setBaseToolTipGenerator(
873: new StandardCategoryToolTipGenerator());
874: }
875: if (urls) {
876: renderer.setBaseItemURLGenerator(
877: new StandardCategoryURLGenerator());
878: }
879:
880: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
881: renderer);
882: plot.setOrientation(orientation);
883: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
884: plot, legend);
885:
886: return chart;
887:
888: }
889:
890:
910: public static JFreeChart createBarChart3D(String title,
911: String categoryAxisLabel,
912: String valueAxisLabel,
913: CategoryDataset dataset,
914: PlotOrientation orientation,
915: boolean legend,
916: boolean tooltips,
917: boolean urls) {
918:
919: if (orientation == null) {
920: throw new IllegalArgumentException("Null 'orientation' argument.");
921: }
922: CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
923: ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
924:
925: BarRenderer3D renderer = new BarRenderer3D();
926: if (tooltips) {
927: renderer.setBaseToolTipGenerator(
928: new StandardCategoryToolTipGenerator());
929: }
930: if (urls) {
931: renderer.setBaseItemURLGenerator(
932: new StandardCategoryURLGenerator());
933: }
934:
935: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
936: renderer);
937: plot.setOrientation(orientation);
938: if (orientation == PlotOrientation.HORIZONTAL) {
939:
940:
941: plot.setRowRenderingOrder(SortOrder.DESCENDING);
942: plot.setColumnRenderingOrder(SortOrder.DESCENDING);
943: }
944: plot.setForegroundAlpha(0.75f);
945:
946: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
947: plot, legend);
948:
949: return chart;
950:
951: }
952:
953:
974: public static JFreeChart createStackedBarChart3D(String title,
975: String categoryAxisLabel,
976: String valueAxisLabel,
977: CategoryDataset dataset,
978: PlotOrientation orientation,
979: boolean legend,
980: boolean tooltips,
981: boolean urls) {
982:
983: if (orientation == null) {
984: throw new IllegalArgumentException("Null 'orientation' argument.");
985: }
986: CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
987: ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
988:
989:
990: CategoryItemRenderer renderer = new StackedBarRenderer3D();
991: if (tooltips) {
992: renderer.setBaseToolTipGenerator(
993: new StandardCategoryToolTipGenerator());
994: }
995: if (urls) {
996: renderer.setBaseItemURLGenerator(
997: new StandardCategoryURLGenerator());
998: }
999:
1000:
1001: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1002: renderer);
1003: plot.setOrientation(orientation);
1004: if (orientation == PlotOrientation.HORIZONTAL) {
1005:
1006:
1007: plot.setColumnRenderingOrder(SortOrder.DESCENDING);
1008: }
1009:
1010:
1011: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1012: plot, legend);
1013:
1014: return chart;
1015:
1016: }
1017:
1018:
1038: public static JFreeChart createAreaChart(String title,
1039: String categoryAxisLabel,
1040: String valueAxisLabel,
1041: CategoryDataset dataset,
1042: PlotOrientation orientation,
1043: boolean legend,
1044: boolean tooltips,
1045: boolean urls) {
1046:
1047: if (orientation == null) {
1048: throw new IllegalArgumentException("Null 'orientation' argument.");
1049: }
1050: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1051: categoryAxis.setCategoryMargin(0.0);
1052:
1053: ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1054:
1055: AreaRenderer renderer = new AreaRenderer();
1056: if (tooltips) {
1057: renderer.setBaseToolTipGenerator(
1058: new StandardCategoryToolTipGenerator());
1059: }
1060: if (urls) {
1061: renderer.setBaseItemURLGenerator(
1062: new StandardCategoryURLGenerator());
1063: }
1064:
1065: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1066: renderer);
1067: plot.setOrientation(orientation);
1068: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1069: plot, legend);
1070:
1071: return chart;
1072:
1073: }
1074:
1075:
1096: public static JFreeChart createStackedAreaChart(String title,
1097: String categoryAxisLabel,
1098: String valueAxisLabel,
1099: CategoryDataset dataset,
1100: PlotOrientation orientation,
1101: boolean legend,
1102: boolean tooltips,
1103: boolean urls) {
1104:
1105: if (orientation == null) {
1106: throw new IllegalArgumentException("Null 'orientation' argument.");
1107: }
1108: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1109: ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1110:
1111: StackedAreaRenderer renderer = new StackedAreaRenderer();
1112: if (tooltips) {
1113: renderer.setBaseToolTipGenerator(
1114: new StandardCategoryToolTipGenerator());
1115: }
1116: if (urls) {
1117: renderer.setBaseItemURLGenerator(
1118: new StandardCategoryURLGenerator());
1119: }
1120:
1121: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1122: renderer);
1123: plot.setOrientation(orientation);
1124: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1125: plot, legend);
1126:
1127: return chart;
1128:
1129: }
1130:
1131:
1151: public static JFreeChart createLineChart(String title,
1152: String categoryAxisLabel,
1153: String valueAxisLabel,
1154: CategoryDataset dataset,
1155: PlotOrientation orientation,
1156: boolean legend,
1157: boolean tooltips,
1158: boolean urls) {
1159:
1160: if (orientation == null) {
1161: throw new IllegalArgumentException("Null 'orientation' argument.");
1162: }
1163: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1164: ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1165:
1166: LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
1167: if (tooltips) {
1168: renderer.setBaseToolTipGenerator(
1169: new StandardCategoryToolTipGenerator());
1170: }
1171: if (urls) {
1172: renderer.setBaseItemURLGenerator(
1173: new StandardCategoryURLGenerator());
1174: }
1175: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1176: renderer);
1177: plot.setOrientation(orientation);
1178: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1179: plot, legend);
1180:
1181: return chart;
1182:
1183: }
1184:
1185:
1205: public static JFreeChart createLineChart3D(String title,
1206: String categoryAxisLabel,
1207: String valueAxisLabel,
1208: CategoryDataset dataset,
1209: PlotOrientation orientation,
1210: boolean legend,
1211: boolean tooltips,
1212: boolean urls) {
1213:
1214: if (orientation == null) {
1215: throw new IllegalArgumentException("Null 'orientation' argument.");
1216: }
1217: CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
1218: ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
1219:
1220: LineRenderer3D renderer = new LineRenderer3D();
1221: if (tooltips) {
1222: renderer.setBaseToolTipGenerator(
1223: new StandardCategoryToolTipGenerator());
1224: }
1225: if (urls) {
1226: renderer.setBaseItemURLGenerator(
1227: new StandardCategoryURLGenerator());
1228: }
1229: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1230: renderer);
1231: plot.setOrientation(orientation);
1232: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1233: plot, legend);
1234:
1235: return chart;
1236:
1237: }
1238:
1239:
1258: public static JFreeChart createGanttChart(String title,
1259: String categoryAxisLabel,
1260: String dateAxisLabel,
1261: IntervalCategoryDataset dataset,
1262: boolean legend,
1263: boolean tooltips,
1264: boolean urls) {
1265:
1266: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1267: DateAxis dateAxis = new DateAxis(dateAxisLabel);
1268:
1269: CategoryItemRenderer renderer = new GanttRenderer();
1270: if (tooltips) {
1271: renderer.setBaseToolTipGenerator(
1272: new IntervalCategoryToolTipGenerator(
1273: "{3} - {4}", DateFormat.getDateInstance()));
1274: }
1275: if (urls) {
1276: renderer.setBaseItemURLGenerator(
1277: new StandardCategoryURLGenerator());
1278: }
1279:
1280: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis,
1281: renderer);
1282: plot.setOrientation(PlotOrientation.HORIZONTAL);
1283: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1284: plot, legend);
1285:
1286: return chart;
1287:
1288: }
1289:
1290:
1310: public static JFreeChart createWaterfallChart(String title,
1311: String categoryAxisLabel,
1312: String valueAxisLabel,
1313: CategoryDataset dataset,
1314: PlotOrientation orientation,
1315: boolean legend,
1316: boolean tooltips,
1317: boolean urls) {
1318:
1319: if (orientation == null) {
1320: throw new IllegalArgumentException("Null 'orientation' argument.");
1321: }
1322: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
1323: categoryAxis.setCategoryMargin(0.0);
1324:
1325: ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
1326:
1327: WaterfallBarRenderer renderer = new WaterfallBarRenderer();
1328: if (orientation == PlotOrientation.HORIZONTAL) {
1329: ItemLabelPosition position = new ItemLabelPosition(
1330: ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1331: TextAnchor.CENTER, Math.PI / 2.0);
1332: renderer.setBasePositiveItemLabelPosition(position);
1333: renderer.setBaseNegativeItemLabelPosition(position);
1334: }
1335: else if (orientation == PlotOrientation.VERTICAL) {
1336: ItemLabelPosition position = new ItemLabelPosition(
1337: ItemLabelAnchor.CENTER, TextAnchor.CENTER,
1338: TextAnchor.CENTER, 0.0);
1339: renderer.setBasePositiveItemLabelPosition(position);
1340: renderer.setBaseNegativeItemLabelPosition(position);
1341: }
1342: if (tooltips) {
1343: StandardCategoryToolTipGenerator generator
1344: = new StandardCategoryToolTipGenerator();
1345: renderer.setBaseToolTipGenerator(generator);
1346: }
1347: if (urls) {
1348: renderer.setBaseItemURLGenerator(
1349: new StandardCategoryURLGenerator());
1350: }
1351:
1352: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
1353: renderer);
1354: plot.clearRangeMarkers();
1355: Marker baseline = new ValueMarker(0.0);
1356: baseline.setPaint(Color.black);
1357: plot.addRangeMarker(baseline, Layer.FOREGROUND);
1358: plot.setOrientation(orientation);
1359: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1360: plot, legend);
1361:
1362: return chart;
1363:
1364: }
1365:
1366:
1380: public static JFreeChart createPolarChart(String title,
1381: XYDataset dataset,
1382: boolean legend,
1383: boolean tooltips,
1384: boolean urls) {
1385:
1386: PolarPlot plot = new PolarPlot();
1387: plot.setDataset(dataset);
1388: NumberAxis rangeAxis = new NumberAxis();
1389: rangeAxis.setAxisLineVisible(false);
1390: rangeAxis.setTickMarksVisible(false);
1391: rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
1392: plot.setAxis(rangeAxis);
1393: plot.setRenderer(new DefaultPolarItemRenderer());
1394: JFreeChart chart = new JFreeChart(
1395: title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
1396: return chart;
1397:
1398: }
1399:
1400:
1419: public static JFreeChart createScatterPlot(String title, String xAxisLabel,
1420: String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
1421: boolean legend, boolean tooltips, boolean urls) {
1422:
1423: if (orientation == null) {
1424: throw new IllegalArgumentException("Null 'orientation' argument.");
1425: }
1426: NumberAxis xAxis = new NumberAxis(xAxisLabel);
1427: xAxis.setAutoRangeIncludesZero(false);
1428: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1429: yAxis.setAutoRangeIncludesZero(false);
1430:
1431: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1432:
1433: XYToolTipGenerator toolTipGenerator = null;
1434: if (tooltips) {
1435: toolTipGenerator = new StandardXYToolTipGenerator();
1436: }
1437:
1438: XYURLGenerator urlGenerator = null;
1439: if (urls) {
1440: urlGenerator = new StandardXYURLGenerator();
1441: }
1442: XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);
1443: renderer.setBaseToolTipGenerator(toolTipGenerator);
1444: renderer.setURLGenerator(urlGenerator);
1445: plot.setRenderer(renderer);
1446: plot.setOrientation(orientation);
1447:
1448: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1449: plot, legend);
1450: return chart;
1451:
1452: }
1453:
1454:
1475: public static JFreeChart createXYBarChart(String title,
1476: String xAxisLabel,
1477: boolean dateAxis,
1478: String yAxisLabel,
1479: IntervalXYDataset dataset,
1480: PlotOrientation orientation,
1481: boolean legend,
1482: boolean tooltips,
1483: boolean urls) {
1484:
1485: if (orientation == null) {
1486: throw new IllegalArgumentException("Null 'orientation' argument.");
1487: }
1488: ValueAxis domainAxis = null;
1489: if (dateAxis) {
1490: domainAxis = new DateAxis(xAxisLabel);
1491: }
1492: else {
1493: NumberAxis axis = new NumberAxis(xAxisLabel);
1494: axis.setAutoRangeIncludesZero(false);
1495: domainAxis = axis;
1496: }
1497: ValueAxis valueAxis = new NumberAxis(yAxisLabel);
1498:
1499: XYBarRenderer renderer = new XYBarRenderer();
1500: if (tooltips) {
1501: XYToolTipGenerator tt;
1502: if (dateAxis) {
1503: tt = StandardXYToolTipGenerator.getTimeSeriesInstance();
1504: }
1505: else {
1506: tt = new StandardXYToolTipGenerator();
1507: }
1508: renderer.setBaseToolTipGenerator(tt);
1509: }
1510: if (urls) {
1511: renderer.setURLGenerator(new StandardXYURLGenerator());
1512: }
1513:
1514: XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer);
1515: plot.setOrientation(orientation);
1516:
1517: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1518: plot, legend);
1519:
1520: return chart;
1521:
1522: }
1523:
1524:
1544: public static JFreeChart createXYAreaChart(String title,
1545: String xAxisLabel,
1546: String yAxisLabel,
1547: XYDataset dataset,
1548: PlotOrientation orientation,
1549: boolean legend,
1550: boolean tooltips,
1551: boolean urls) {
1552:
1553: if (orientation == null) {
1554: throw new IllegalArgumentException("Null 'orientation' argument.");
1555: }
1556: NumberAxis xAxis = new NumberAxis(xAxisLabel);
1557: xAxis.setAutoRangeIncludesZero(false);
1558: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1559: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1560: plot.setOrientation(orientation);
1561: plot.setForegroundAlpha(0.5f);
1562:
1563: XYToolTipGenerator tipGenerator = null;
1564: if (tooltips) {
1565: tipGenerator = new StandardXYToolTipGenerator();
1566: }
1567:
1568: XYURLGenerator urlGenerator = null;
1569: if (urls) {
1570: urlGenerator = new StandardXYURLGenerator();
1571: }
1572:
1573: plot.setRenderer(
1574: new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator)
1575: );
1576: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1577: plot, legend);
1578:
1579: return chart;
1580:
1581: }
1582:
1583:
1601: public static JFreeChart createStackedXYAreaChart(String title,
1602: String xAxisLabel,
1603: String yAxisLabel,
1604: TableXYDataset dataset,
1605: PlotOrientation orientation,
1606: boolean legend,
1607: boolean tooltips,
1608: boolean urls) {
1609:
1610: if (orientation == null) {
1611: throw new IllegalArgumentException("Null 'orientation' argument.");
1612: }
1613: NumberAxis xAxis = new NumberAxis(xAxisLabel);
1614: xAxis.setAutoRangeIncludesZero(false);
1615: xAxis.setLowerMargin(0.0);
1616: xAxis.setUpperMargin(0.0);
1617: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1618: XYToolTipGenerator toolTipGenerator = null;
1619: if (tooltips) {
1620: toolTipGenerator = new StandardXYToolTipGenerator();
1621: }
1622:
1623: XYURLGenerator urlGenerator = null;
1624: if (urls) {
1625: urlGenerator = new StandardXYURLGenerator();
1626: }
1627: StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(
1628: toolTipGenerator, urlGenerator);
1629: renderer.setOutline(true);
1630: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1631: plot.setOrientation(orientation);
1632:
1633: plot.setRangeAxis(yAxis);
1634:
1635: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1636: plot, legend);
1637: return chart;
1638:
1639: }
1640:
1641:
1657: public static JFreeChart createXYLineChart(String title,
1658: String xAxisLabel,
1659: String yAxisLabel,
1660: XYDataset dataset,
1661: PlotOrientation orientation,
1662: boolean legend,
1663: boolean tooltips,
1664: boolean urls) {
1665:
1666: if (orientation == null) {
1667: throw new IllegalArgumentException("Null 'orientation' argument.");
1668: }
1669: NumberAxis xAxis = new NumberAxis(xAxisLabel);
1670: xAxis.setAutoRangeIncludesZero(false);
1671: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1672: XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
1673: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
1674: plot.setOrientation(orientation);
1675: if (tooltips) {
1676: renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
1677: }
1678: if (urls) {
1679: renderer.setURLGenerator(new StandardXYURLGenerator());
1680: }
1681:
1682: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1683: plot, legend);
1684:
1685: return chart;
1686:
1687: }
1688:
1689:
1704: public static JFreeChart createXYStepChart(String title,
1705: String xAxisLabel,
1706: String yAxisLabel,
1707: XYDataset dataset,
1708: PlotOrientation orientation,
1709: boolean legend,
1710: boolean tooltips,
1711: boolean urls) {
1712:
1713: if (orientation == null) {
1714: throw new IllegalArgumentException("Null 'orientation' argument.");
1715: }
1716: DateAxis xAxis = new DateAxis(xAxisLabel);
1717: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1718: yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
1719:
1720: XYToolTipGenerator toolTipGenerator = null;
1721: if (tooltips) {
1722: toolTipGenerator = new StandardXYToolTipGenerator();
1723: }
1724:
1725: XYURLGenerator urlGenerator = null;
1726: if (urls) {
1727: urlGenerator = new StandardXYURLGenerator();
1728: }
1729: XYItemRenderer renderer
1730: = new XYStepRenderer(toolTipGenerator, urlGenerator);
1731:
1732: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1733: plot.setRenderer(renderer);
1734: plot.setOrientation(orientation);
1735: plot.setDomainCrosshairVisible(false);
1736: plot.setRangeCrosshairVisible(false);
1737: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1738: plot, legend);
1739: return chart;
1740:
1741: }
1742:
1743:
1758: public static JFreeChart createXYStepAreaChart(String title,
1759: String xAxisLabel,
1760: String yAxisLabel,
1761: XYDataset dataset,
1762: PlotOrientation orientation,
1763: boolean legend,
1764: boolean tooltips,
1765: boolean urls) {
1766:
1767: if (orientation == null) {
1768: throw new IllegalArgumentException("Null 'orientation' argument.");
1769: }
1770: NumberAxis xAxis = new NumberAxis(xAxisLabel);
1771: xAxis.setAutoRangeIncludesZero(false);
1772: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1773:
1774: XYToolTipGenerator toolTipGenerator = null;
1775: if (tooltips) {
1776: toolTipGenerator = new StandardXYToolTipGenerator();
1777: }
1778:
1779: XYURLGenerator urlGenerator = null;
1780: if (urls) {
1781: urlGenerator = new StandardXYURLGenerator();
1782: }
1783: XYItemRenderer renderer = new XYStepAreaRenderer(
1784: XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator,
1785: urlGenerator);
1786:
1787: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1788: plot.setRenderer(renderer);
1789: plot.setOrientation(orientation);
1790: plot.setDomainCrosshairVisible(false);
1791: plot.setRangeCrosshairVisible(false);
1792: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1793: plot, legend);
1794: return chart;
1795: }
1796:
1797:
1818: public static JFreeChart createTimeSeriesChart(String title,
1819: String timeAxisLabel,
1820: String valueAxisLabel,
1821: XYDataset dataset,
1822: boolean legend,
1823: boolean tooltips,
1824: boolean urls) {
1825:
1826: ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1827: timeAxis.setLowerMargin(0.02);
1828: timeAxis.setUpperMargin(0.02);
1829: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1830: valueAxis.setAutoRangeIncludesZero(false);
1831: XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1832:
1833: XYToolTipGenerator toolTipGenerator = null;
1834: if (tooltips) {
1835: toolTipGenerator
1836: = StandardXYToolTipGenerator.getTimeSeriesInstance();
1837: }
1838:
1839: XYURLGenerator urlGenerator = null;
1840: if (urls) {
1841: urlGenerator = new StandardXYURLGenerator();
1842: }
1843:
1844: XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,
1845: false);
1846: renderer.setBaseToolTipGenerator(toolTipGenerator);
1847: renderer.setURLGenerator(urlGenerator);
1848: plot.setRenderer(renderer);
1849:
1850: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1851: plot, legend);
1852: return chart;
1853:
1854: }
1855:
1856:
1869: public static JFreeChart createCandlestickChart(String title,
1870: String timeAxisLabel,
1871: String valueAxisLabel,
1872: OHLCDataset dataset,
1873: boolean legend) {
1874:
1875: ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1876: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1877: XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
1878: plot.setRenderer(new CandlestickRenderer());
1879: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1880: plot, legend);
1881: return chart;
1882:
1883: }
1884:
1885:
1898: public static JFreeChart createHighLowChart(String title,
1899: String timeAxisLabel,
1900: String valueAxisLabel,
1901: OHLCDataset dataset,
1902: boolean legend) {
1903:
1904: ValueAxis timeAxis = new DateAxis(timeAxisLabel);
1905: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1906: HighLowRenderer renderer = new HighLowRenderer();
1907: renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
1908: XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1909: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1910: plot, legend);
1911: return chart;
1912:
1913: }
1914:
1915:
1933: public static JFreeChart createHighLowChart(String title,
1934: String timeAxisLabel,
1935: String valueAxisLabel,
1936: OHLCDataset dataset,
1937: Timeline timeline,
1938: boolean legend) {
1939:
1940: DateAxis timeAxis = new DateAxis(timeAxisLabel);
1941: timeAxis.setTimeline(timeline);
1942: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
1943: HighLowRenderer renderer = new HighLowRenderer();
1944: renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
1945: XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
1946: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
1947: plot, legend);
1948: return chart;
1949:
1950: }
1951:
1952:
1970: public static JFreeChart createBubbleChart(String title,
1971: String xAxisLabel,
1972: String yAxisLabel,
1973: XYZDataset dataset,
1974: PlotOrientation orientation,
1975: boolean legend,
1976: boolean tooltips,
1977: boolean urls) {
1978:
1979: if (orientation == null) {
1980: throw new IllegalArgumentException("Null 'orientation' argument.");
1981: }
1982: NumberAxis xAxis = new NumberAxis(xAxisLabel);
1983: xAxis.setAutoRangeIncludesZero(false);
1984: NumberAxis yAxis = new NumberAxis(yAxisLabel);
1985: yAxis.setAutoRangeIncludesZero(false);
1986:
1987: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
1988:
1989: XYItemRenderer renderer = new XYBubbleRenderer(
1990: XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
1991: if (tooltips) {
1992: renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
1993: }
1994: if (urls) {
1995: renderer.setURLGenerator(new StandardXYZURLGenerator());
1996: }
1997: plot.setRenderer(renderer);
1998: plot.setOrientation(orientation);
1999:
2000: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2001: plot, legend);
2002:
2003: return chart;
2004:
2005: }
2006:
2007:
2024: public static JFreeChart createHistogram(String title,
2025: String xAxisLabel,
2026: String yAxisLabel,
2027: IntervalXYDataset dataset,
2028: PlotOrientation orientation,
2029: boolean legend,
2030: boolean tooltips,
2031: boolean urls) {
2032:
2033: if (orientation == null) {
2034: throw new IllegalArgumentException("Null 'orientation' argument.");
2035: }
2036: NumberAxis xAxis = new NumberAxis(xAxisLabel);
2037: xAxis.setAutoRangeIncludesZero(false);
2038: ValueAxis yAxis = new NumberAxis(yAxisLabel);
2039:
2040: XYItemRenderer renderer = new XYBarRenderer();
2041: if (tooltips) {
2042: renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2043: }
2044: if (urls) {
2045: renderer.setURLGenerator(new StandardXYURLGenerator());
2046: }
2047:
2048: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2049: plot.setOrientation(orientation);
2050: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2051: plot, legend);
2052: return chart;
2053:
2054: }
2055:
2056:
2072: public static JFreeChart createBoxAndWhiskerChart(String title,
2073: String categoryAxisLabel, String valueAxisLabel,
2074: BoxAndWhiskerCategoryDataset dataset, boolean legend) {
2075:
2076: CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
2077: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2078: valueAxis.setAutoRangeIncludesZero(false);
2079:
2080: BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
2081: renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
2082:
2083: CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
2084: renderer);
2085: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
2086: legend);
2087: }
2088:
2089:
2102: public static JFreeChart createBoxAndWhiskerChart(String title,
2103: String timeAxisLabel,
2104: String valueAxisLabel,
2105: BoxAndWhiskerXYDataset dataset,
2106: boolean legend) {
2107:
2108: ValueAxis timeAxis = new DateAxis(timeAxisLabel);
2109: NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
2110: valueAxis.setAutoRangeIncludesZero(false);
2111: XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
2112: XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
2113: return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
2114: legend);
2115:
2116: }
2117:
2118:
2132: public static JFreeChart createWindPlot(String title,
2133: String xAxisLabel,
2134: String yAxisLabel,
2135: WindDataset dataset,
2136: boolean legend,
2137: boolean tooltips,
2138: boolean urls) {
2139:
2140: ValueAxis xAxis = new DateAxis(xAxisLabel);
2141: ValueAxis yAxis = new NumberAxis(yAxisLabel);
2142: yAxis.setRange(-12.0, 12.0);
2143:
2144: WindItemRenderer renderer = new WindItemRenderer();
2145: if (tooltips) {
2146: renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
2147: }
2148: if (urls) {
2149: renderer.setURLGenerator(new StandardXYURLGenerator());
2150: }
2151: XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
2152: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2153: plot, legend);
2154:
2155: return chart;
2156:
2157: }
2158:
2159:
2172: public static JFreeChart createWaferMapChart(String title,
2173: WaferMapDataset dataset,
2174: PlotOrientation orientation,
2175: boolean legend,
2176: boolean tooltips,
2177: boolean urls) {
2178:
2179: if (orientation == null) {
2180: throw new IllegalArgumentException("Null 'orientation' argument.");
2181: }
2182: WaferMapPlot plot = new WaferMapPlot(dataset);
2183: WaferMapRenderer renderer = new WaferMapRenderer();
2184: plot.setRenderer(renderer);
2185:
2186: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
2187: plot, legend);
2188:
2189: return chart;
2190: }
2191:
2192: }