List of usage examples for org.jfree.chart JFreeChart addSubtitle
public void addSubtitle(Title subtitle)
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.SchichtenBarChart.java
protected JFreeChart createSpiderChart(Object dataset) { SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) dataset); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); JFreeChart chart = new JFreeChart(Messages.SchichtenBarChart_3, TextTitle.DEFAULT_FONT, plot, false); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); return chart; }
From source file:com.greenpepper.confluence.macros.historic.AbstractChartBuilder.java
protected void addSubTitle(JFreeChart chart, String subTitle, Font font) { if (StringUtils.isNotEmpty(subTitle)) { TextTitle chartSubTitle = new TextTitle(subTitle); customizeTitle(chartSubTitle, font); chart.addSubtitle(chartSubTitle); }//from w w w .java 2s . c om }
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizeChart(JFreeChart jfchart, ChartParams params) { // title/*from w w w. j a v a 2 s. c o m*/ if (params.get(ChartParams.TITLE_PREFIX + ChartParams.TITLE_SUFFIX) != null) { TextTitle title = new TextTitle(params.getString(ChartParams.TITLE_PREFIX + ChartParams.TITLE_SUFFIX)); customizeTitle(title, params, ChartParams.TITLE_PREFIX); jfchart.setTitle(title); } // subtitle if (params.get(ChartParams.SUBTITLE_PREFIX + ChartParams.TITLE_SUFFIX) != null) { TextTitle subtitle = new TextTitle( params.getString(ChartParams.SUBTITLE_PREFIX + ChartParams.TITLE_SUFFIX)); customizeTitle(subtitle, params, ChartParams.SUBTITLE_PREFIX); jfchart.addSubtitle(subtitle); } // legend LegendTitle legend = jfchart.getLegend(); customizeLegend(legend, params); // anti-alias if (params.get(ChartParams.ANTI_ALIAS) != null) { jfchart.setAntiAlias(params.getBoolean(ChartParams.ANTI_ALIAS).booleanValue()); } // background color if (params.get(ChartParams.BACKGROUND_COLOR) != null) { jfchart.setBackgroundPaint(params.getColor(ChartParams.BACKGROUND_COLOR)); } // border if (params.get(ChartParams.BORDER_VISIBLE) != null && params.getBoolean(ChartParams.BORDER_VISIBLE).booleanValue()) { jfchart.setBorderVisible(true); if (params.get(ChartParams.BORDER_COLOR) != null) { jfchart.setBorderPaint(params.getColor(ChartParams.BORDER_COLOR)); } if (params.get(ChartParams.BORDER_STROKE) != null) { jfchart.setBorderStroke(params.getStroke(ChartParams.BORDER_STROKE)); } } }
From source file:org.perfrepo.web.controller.reports.testgroup.TestGroupChartBean.java
public void drawChart(OutputStream out, Object data) throws IOException { if (data instanceof ChartData) { ChartData chartData = (ChartData) data; JFreeChart chart = ChartFactory.createBarChart(chartData.getTitle(), "Test", "%", processDataSet(chartData), PlotOrientation.HORIZONTAL, false, true, false); chart.addSubtitle(new TextTitle("Comparison", new Font("Dialog", Font.ITALIC, 10))); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CustomRenderer renderer = new CustomRenderer(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}%", NumberFormat.getInstance())); renderer.setBaseItemLabelsVisible(true); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(1d / (chartData.getTests().length + 4.0)); plot.setRenderer(renderer);/* w w w . j a v a 2 s.c om*/ CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setCategoryMargin(0.1); categoryAxis.setUpperMargin(0.1); categoryAxis.setLowerMargin(0.1); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); BufferedImage buffImg = chart.createBufferedImage(640, chartData.getTests().length * 100 + 100); ImageIO.write(buffImg, "gif", out); } }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.MaturitySpiderChart.java
protected JFreeChart createSpiderChart(Object dataset) { SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) dataset); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setSeriesPaint(0, new Color(0.0f, 1f, 0f, 1f)); // green plot.setSeriesPaint(1, new Color(1f, 1f, 0f, 1f)); // yellow plot.setSeriesPaint(2, new Color(1f, 0f, 0f, 1f)); // red plot.setSeriesPaint(3, new Color(0f, 0f, 0f, 1f)); // grey plot.setWebFilled(true);/*from w w w .j a v a 2s . co m*/ JFreeChart chart = new JFreeChart(Messages.MaturitySpiderChart_0, TextTitle.DEFAULT_FONT, plot, false); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); return chart; }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.ISRSpiderChart.java
protected JFreeChart createSpiderChart(Object dataset) { SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) dataset); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setSeriesPaint(0, new Color(0.0f, 1f, 0f, 1f)); // green plot.setSeriesPaint(1, new Color(1f, 1f, 0f, 1f)); // yellow plot.setSeriesPaint(2, new Color(1f, 0f, 0f, 1f)); // red plot.setSeriesPaint(3, new Color(0f, 0f, 0f, 1f)); // grey plot.setWebFilled(true);//from ww w . ja va 2s. co m JFreeChart chart = new JFreeChart(Messages.ISRSpiderChart_0, TextTitle.DEFAULT_FONT, plot, false); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); return chart; }
From source file:org.jfree.chart.demo.LegendWrapperDemo1.java
private static JFreeChart createChart(PieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart("Legend Wrapper Demo 1", piedataset, false, true, false);// www. j a v a 2s. com PiePlot pieplot = (PiePlot) jfreechart.getPlot(); pieplot.setLabelFont(new Font("SansSerif", 0, 12)); pieplot.setNoDataMessage("No data available"); pieplot.setCircular(true); pieplot.setLabelGap(0.02D); LegendTitle legendtitle = new LegendTitle(jfreechart.getPlot()); BlockContainer blockcontainer = new BlockContainer(new BorderArrangement()); blockcontainer.setFrame(new BlockBorder(1.0D, 1.0D, 1.0D, 1.0D)); LabelBlock labelblock = new LabelBlock("Legend Items:", new Font("SansSerif", 1, 12)); labelblock.setPadding(5D, 5D, 5D, 5D); blockcontainer.add(labelblock, RectangleEdge.TOP); LabelBlock labelblock1 = new LabelBlock("Source: http://www.jfree.org"); labelblock1.setPadding(8D, 20D, 2D, 5D); blockcontainer.add(labelblock1, RectangleEdge.BOTTOM); BlockContainer blockcontainer1 = legendtitle.getItemContainer(); blockcontainer1.setPadding(2D, 10D, 5D, 2D); blockcontainer.add(blockcontainer1); legendtitle.setWrapper(blockcontainer); legendtitle.setPosition(RectangleEdge.RIGHT); legendtitle.setHorizontalAlignment(HorizontalAlignment.LEFT); jfreechart.addSubtitle(legendtitle); return jfreechart; }
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); }// www. j a v a 2 s . 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); return jfreechart; }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.HierarchicalBarChart.java
private void buildFinalChart(String title, String subTitle, String xAxisLabel, String yAxisLabel, int height, int width, String filename, Chart.Scale scaleMode, Chart.LegendFormat legendFormatMode, int alpha) { @SuppressWarnings("unchecked") Vector<Counter>[] vec = new Vector[this.timers.length]; boolean exist; // create the dataset... for (int i = 0; i < this.timers.length; i++) { vec[i] = new Vector<Counter>(); @SuppressWarnings("unchecked") Iterator<Element> it = this.timers[i].getDescendants(); while (it.hasNext()) { try { Element elt = (Element) it.next(); String name = elt.getAttributeValue("name"); double value = Double.valueOf(elt.getAttributeValue("avg")); exist = false;//from w w w . ja v a2 s .co m for (int j = 0; j < vec[i].size(); j++) { if (((Counter) vec[i].get(j)).getName().equals(name)) { ((Counter) vec[i].get(j)).addValue(value); exist = true; break; } } if (!exist) { vec[i].add(new Counter(name, value)); } } catch (ClassCastException e) { continue; } } } CategoryDataset dataset = null; try { dataset = DatasetUtilities.createCategoryDataset(toSeries(vec[0]), this.categories, toDataset(vec)); } catch (IllegalArgumentException e) { e.printStackTrace(); throw new IllegalArgumentException( "Benchmark names must have different names. Be sure that your filter contains correct timers names"); } // create the chart... final CategoryAxis categoryAxis = new CategoryAxis(xAxisLabel); final ValueAxis valueAxis = new NumberAxis(yAxisLabel); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new HierarchicalBarRenderer()); plot.setOrientation(PlotOrientation.VERTICAL); final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.addSubtitle(new TextTitle(subTitle)); // set the background color for the chart... chart.setBackgroundPaint(Color.white); final HierarchicalBarRenderer renderer = (HierarchicalBarRenderer) plot.getRenderer(); renderer.setItemMargin(0.01); renderer.setDatasetTree(this.timers); renderer.setSeries(toSeries(vec[0])); renderer.setAlpha(alpha); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(HierarchicalBarChart.CATEGORY_MARGIN); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); try { if ((filename == null) || "".equals(filename)) { throw new RuntimeException( "The output filename for the HierarchicalBarChart cannot be null or empty !"); } ChartUtilities.saveChartAsPNG(XMLHelper.createFileWithDirs(filename + ".png"), chart, width, height); Utilities.saveChartAsSVG(chart, new Rectangle(width, height), XMLHelper.createFileWithDirs(filename + ".svg")); } catch (java.io.IOException e) { System.err.println("Error writing chart image to file"); e.printStackTrace(); } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.SimpleBox.java
public JFreeChart createChart(DatasetMap datasetMap) { BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) datasetMap.getDatasets().get("1"); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(name, categoryLabel, valueLabel, dataset, false); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title);/*from w w w. ja v a2 s.com*/ if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } CategoryPlot plot = (CategoryPlot) chart.getPlot(); BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer(); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue())); plot.setDomainGridlinePaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); renderer.setFillBox(true); renderer.setArtifactPaint(Color.BLACK); renderer.setSeriesPaint(0, new Color(Integer.decode("#0000FF").intValue())); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(min, max); return chart; }