List of usage examples for org.jfree.chart.title TextTitle TextTitle
public TextTitle(String text)
From source file:unalcol.termites.boxplots.MessagesSent1.java
/** * Creates a new demo./* ww w .j a v a 2 s.c o m*/ * * @param title the frame title. * @param pf */ public MessagesSent1(final String title, ArrayList<Double> pf) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Messages Sent"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("Dialog", Font.PLAIN, 16); xAxis.setTickLabelFont(font); yAxis.setTickLabelFont(font); yAxis.setLabelFont(font); final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf), new Font("SansSerif", Font.BOLD, 18), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); setContentPane(chartPanel); TextTitle legendText = null; if (pf.size() == 1) { legendText = new TextTitle("Population Size"); } else { legendText = new TextTitle("Population Size - Probability of Failure"); } legendText.setFont(font); legendText.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); chart.getLegend().setItemFont(font); FileOutputStream output; try { output = new FileOutputStream("messagesnumber1" + pf + mazeMode + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null); } catch (FileNotFoundException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MessagesSent1.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.jfree.experimental.chart.annotations.junit.XYTitleAnnotationTests.java
/** * Two objects that are equal are required to return the same hashCode. *///from ww w.java 2s.c om public void testHashCode() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
From source file:org.jfree.chart.demo.YieldCurveDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield", xydataset, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15); xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime())); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }/*from w w w . jav a 2s. co m*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); jfreechart.addSubtitle(new TextTitle("November 2005")); TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm"); texttitle.setFont(new Font("Dialog", 0, 9)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:binky.reportrunner.ui.actions.admin.GetAuditChartAction.java
@Override @PreAuthorize("hasRole('ROLE_ADMIN')") public String execute() throws Exception { // do some stuff and get a chart going // DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); TimeSeriesCollection dataSet = new TimeSeriesCollection(); List<RunnerHistoryEvent> events = auditService.getSuccessEvents(module, new Date(fromDate), new Date(toDate)); Map<String, TimeSeries> serieses = new HashMap<String, TimeSeries>(); for (RunnerHistoryEvent e : events) { TimeSeries s = serieses.get(e.getMethod()); if (s == null) { s = new TimeSeries(e.getMethod()); serieses.put(e.getMethod(), s); }//w ww.ja v a2s. co m s.addOrUpdate(new Millisecond(e.getTimeStamp()), e.getRunTime()); } for (TimeSeries s : serieses.values()) { dataSet.addSeries(s); } chart = ChartFactory.createTimeSeriesChart(module, "", "run time (ms)", dataSet, true, false, false); // .createLineChart("","","Run Time (ms)",dataSet,PlotOrientation.VERTICAL, // true,false,false); XYPlot linePlot = (XYPlot) chart.getPlot(); linePlot.setDomainGridlinesVisible(true); linePlot.setRangeGridlinesVisible(true); linePlot.setRangeGridlinePaint(Color.black); linePlot.setDomainGridlinePaint(Color.black); TextTitle subTitle = new TextTitle("Successful Executions"); subTitle.setFont(new Font("Arial", Font.ITALIC, 10)); chart.addSubtitle(subTitle); chart.getTitle().setFont(new Font("Arial", Font.BOLD, 12)); DateAxis axis = (DateAxis) linePlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss dd-MM-yyyy")); XYItemRenderer r = linePlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } chart.setAntiAlias(true); chart.setTextAntiAlias(true); return SUCCESS; }
From source file:org.jfree.chart.demo.MultipleAxisDemo1.java
/** * Creates the demo chart.// w w w . ja v a2s . com * * @return The chart. */ private JFreeChart createChart() { final XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Time of Day", "Primary Range Axis", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); chart.addSubtitle(new TextTitle("Four datasets and four range axes.")); final XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPaint(Color.black); // AXIS 2 final NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); final XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 final NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); plot.setRangeAxis(2, axis3); final XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 final NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); final XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
From source file:com.itemanalysis.jmetrik.graph.scatterplot.ScatterplotPanel.java
public void setGraph() { DefaultXYDataset dataset = new DefaultXYDataset(); PlotOrientation orientation = PlotOrientation.VERTICAL; try {//from w ww. j a va 2s.c o m chart = ChartFactory.createScatterPlot(title, // chart title xlabel, // x axis label ylabel, // y axis label dataset, // data orientation, showLegend, // include legend true, // tooltips false // urls ); if (subtitle != null && !"".equals(subtitle)) { TextTitle subtitle1 = new TextTitle(subtitle); chart.addSubtitle(subtitle1); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainZeroBaselineVisible(false); plot.setRangeZeroBaselineVisible(false); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(this, panel.getPopupMenu()); panel.setPreferredSize(new Dimension(width, height)); chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); this.setBackground(Color.WHITE); this.add(panel); } catch (IllegalArgumentException ex) { logger.fatal(ex.getMessage(), ex); this.firePropertyChange("error", "", "Error - Check log for details."); } }
From source file:org.jfree.chart.demo.YieldCurveDemo.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield", xydataset, false, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15); xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime())); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }/* w w w .j av a 2s .c o m*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); jfreechart.addSubtitle(new TextTitle("November 2005")); TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm"); texttitle.setFont(new Font("Dialog", 0, 9)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle); return jfreechart; }
From source file:com.swordlord.gozer.components.fop.graph.GFopStackedBarChart.java
public GFopStackedBarChart(IGozerFrameExtension gfe, GStackedBarChart chart) { super(gfe);/* w w w .j a v a2 s . c o m*/ DataBindingMember dbMemberRowKey = chart.getDataBindingMemberRowKey(); DataBindingMember dbMemberColKey = chart.getDataBindingMemberColKey(); DataBindingMember dbMemberValue = chart.getDataBindingMemberValue(); DataBindingManager dbManager = chart.getDataBindingManager(); DefaultCategoryDataset dcd = new DefaultCategoryDataset(); List<DataRowBase> rowTests = dbManager.getRows(dbMemberValue); for (int j = 0; j < rowTests.size(); j++) { DataRowBase row = rowTests.get(j); String strKey = row.getPropertyAsStringForce(dbMemberRowKey.getRelativePathWithField()); dcd.setValue(row.getPropertyAsInt(dbMemberValue.getRelativePathWithField()), strKey, row.getPropertyAsStringForce(dbMemberColKey.getRelativePathWithField())); } JFreeChart fc = ChartFactory.createStackedBarChart(chart.getTitle(), chart.getCategoryAxisLabel(), chart.getValueAxisLabel(), dcd, chart.getOrientation(), chart.getLegend(), false, false); // Do this in a more static way! StackedBarRenderer.setDefaultBarPainter(new StandardBarPainter()); //chart.setBackgroundPaint(Color.white); if (chart.getSubTitle() != null) { fc.addSubtitle(new TextTitle(chart.getSubTitle())); } CategoryPlot plot = fc.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDrawingSupplier(chart.getDrawingSupplier()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(chart.getCategoryAxisVisible()); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setVisible(chart.getValueAxisVisible()); /* //CategoryItemRenderer renderer = (CategoryItemRenderer) plot.getRenderer(); for (int j = 0; j < rowKey.length; j++) { renderer.setSeriesItemLabelGenerator(j, new LabelGenerator(j, rowKey[j])); renderer.setSeriesItemLabelsVisible(j, true); } */ StackedBarRenderer renderer = new StackedBarRenderer(); for (int j = 0; j < dcd.getRowCount(); j++) { renderer.setSeriesItemLabelGenerator(j, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelsVisible(j, true); } //renderer.setLegendItemLabelGenerator(new LabelGenerator()); renderer.setShadowVisible(false); plot.setRenderer(renderer); _image = new ChartImage("chart", fc, chart.getWidth(800), chart.getHeight(800)); }
From source file:unalcol.termites.boxplots.ECALMessages.java
/** * Creates a new demo./* w w w . j a va2 s . c om*/ * * @param title the frame title. * @param pf */ public ECALMessages(final String title, ArrayList<Double> pf) { super(title); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Messages Sent"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("Dialog", Font.PLAIN, 13); xAxis.setTickLabelFont(font); yAxis.setTickLabelFont(font); yAxis.setLabelFont(font); final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf), new Font("SansSerif", Font.BOLD, 18), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); setContentPane(chartPanel); TextTitle legendText = null; if (pf.size() == 1) { legendText = new TextTitle("Population Size"); } else { legendText = new TextTitle("Population Size - Probability of Failure"); } legendText.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); LegendTitle legend = chart.getLegend(); legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0)); FileOutputStream output; try { output = new FileOutputStream("messagesECAL" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null); } catch (FileNotFoundException ex) { Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:unalcol.termites.boxplots.MessagesSent2.java
/** * Creates a new demo.//from w w w . j a v a2s. c om * * @param title the frame title. * @param pf */ public MessagesSent2(final String title, ArrayList<Double> pf) { super(title); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Messages Sent"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("Dialog", Font.PLAIN, 13); xAxis.setTickLabelFont(font); yAxis.setTickLabelFont(font); yAxis.setLabelFont(font); final JFreeChart chart = new JFreeChart("Messages Sent " + getTitle(pf), new Font("SansSerif", Font.BOLD, 18), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); setContentPane(chartPanel); TextTitle legendText = null; if (pf.size() == 1) { legendText = new TextTitle("Population Size"); } else { legendText = new TextTitle("Population Size - Probability of Failure"); } legendText.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); LegendTitle legend = chart.getLegend(); legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0)); FileOutputStream output; try { output = new FileOutputStream("messagesnumber2" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null); } catch (FileNotFoundException ex) { Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex); } }