//scriptlet.java import java.awt.Color; import java.awt.Font; import net.sf.jasperreports.engine.JRDefaultScriptlet; import net.sf.jasperreports.engine.JRScriptletException; import net.sf.jasperreports.renderers.JCommonDrawableRenderer; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.title.TextTitle; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.HorizontalAlignment; import org.jfree.ui.RectangleEdge; public class retail_cvr_by_loc3Scriptlet extends it.businesslogic.ireport.IReportScriptlet { /** Creates a new instance of JRIreportDefaultScriptlet */ public retail_cvr_by_loc3Scriptlet() { } /** Begin EVENT_AFTER_COLUMN_INIT This line is generated by iReport. Don't modify or move please! */ public void afterColumnInit() throws JRScriptletException { super.beforeColumnInit(); } /** End EVENT_AFTER_COLUMN_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_AFTER_DETAIL_EVAL This line is generated by iReport. Don't modify or move please! */ public void afterDetailEval() throws JRScriptletException { super.afterDetailEval(); } /** End EVENT_AFTER_DETAIL_EVAL This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_AFTER_GROUP_INIT This line is generated by iReport. Don't modify or move please! */ public void afterGroupInit(String groupName) throws JRScriptletException { //super.afterGroupInit(groupName); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue((java.math.BigDecimal)getFieldValue("TRAFFIC"), "Traffic", (java.lang.String)getFieldValue("GRAPH_X_AXIS")); // create the chart... JFreeChart chart = ChartFactory.createLineChart( "Java Standard Class Library", // chart title (java.lang.String)getParameterValue("p_period"), // domain axis label "Traffic", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.addSubtitle(new TextTitle("Number of Classes By Release")); TextTitle source = new TextTitle("Source: Java In A Nutshell (4th Edition) by David Flanagan (O’Reilly)"); source.setFont(new Font("SansSerif", Font.PLAIN, 10)); //source.setPosition(RectangleEdge.BOTTOM); //source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis axis2 = new NumberAxis("Conversion"); axis2.setRange(5, 500); plot.setRangeAxis(1, axis2); //plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.white); this.setVariableValue("Chart", new JCommonDrawableRenderer(chart)); } /** End EVENT_AFTER_GROUP_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_AFTER_PAGE_INIT This line is generated by iReport. Don't modify or move please! */ public void afterPageInit() throws JRScriptletException { super.afterPageInit(); } /** End EVENT_AFTER_PAGE_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_AFTER_REPORT_INIT This line is generated by iReport. Don't modify or move please! */ public void afterReportInit() throws JRScriptletException { } /** End EVENT_AFTER_REPORT_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_BEFORE_COLUMN_INIT This line is generated by iReport. Don't modify or move please! */ public void beforeColumnInit() throws JRScriptletException { } /** End EVENT_BEFORE_COLUMN_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_BEFORE_DETAIL_EVAL This line is generated by iReport. Don't modify or move please! */ public void beforeDetailEval() throws JRScriptletException { } /** end EVENT_BEFORE_DETAIL_EVAL Please don't touch or move this comment*/ /** End EVENT_BEFORE_DETAIL_EVAL This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_BEFORE_GROUP_INIT This line is generated by iReport. Don't modify or move please! */ public void beforeGroupInit(String groupName) throws JRScriptletException { } /** End EVENT_BEFORE_GROUP_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_BEFORE_PAGE_INIT This line is generated by iReport. Don't modify or move please! */ public void beforePageInit() throws JRScriptletException { } /** End EVENT_BEFORE_PAGE_INIT This line is generated by iReport. Don't modify or move please! */ /** Begin EVENT_BEFORE_REPORT_INIT This line is generated by iReport. Don't modify or move please! */ public void beforeReportInit() throws JRScriptletException { } /** End EVENT_BEFORE_REPORT_INIT This line is generated by iReport. Don't modify or move please! */ }