List of usage examples for org.jfree.chart.title TextTitle TextTitle
public TextTitle(String text, Font font)
From source file:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**// ww w .j a va 2s.c o m * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //?? //createPieChart 2D; createPieChart3D 3D JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false); //,? chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22))); //? LegendTitle legend = chart.getLegend(0); //,ture,? legend.setItemFont(new Font("", Font.BOLD, 20)); //?(??) PiePlot plot = (PiePlot) chart.getPlot(); //?==? plot.setLabelFont(new Font("", Font.BOLD, 22)); // plot.setBaseSectionOutlinePaint(Color.BLUE); // plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f)); //?,??,?? plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE //() plot.setStartAngle(70); //??? //plot.setExplodePercent(1, 0.5D); //plot.setExplodePercent("One", 0.5D); //,3D? plot.setExplodePercent(dataset.getKey(0), 0.1d); // plot.setLabelLinkPaint(Color.BLUE); // plot.setLabelOutlinePaint(Color.black); // plot.setLabelShadowPaint(Color.RED); // plot.setSectionPaint(1, Color.BLACK); // :,{0},{1},{2}?,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}")); //:(true),(false) plot.setCircular(true); //? plot.setNoDataMessage("??..."); //??? plot.setToolTipGenerator(new StandardPieToolTipGenerator()); // //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp")); return chart; }
From source file:com.orsonpdf.demo.PDFTimeSeriesChartDemo1.java
/** * Creates a chart.//from w w w .jav a 2 s.c om * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset, true, false, false); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.red); plot.setDomainGridlinePaint(Color.red); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:org.jfree.graphics2d.demo.SVGTimeSeriesChartDemo1.java
/** * Creates a chart./* w ww.j a va2 s . co m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:com.ouc.cpss.view.ChartProBuilder.java
private static JFreeChart createJFreeChart(CategoryDataset dataset) { /**// w ww .jav a2 s . co m * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //? // ? JFreeChart jfreeChart = null; if (choice == 1) { jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); /** * JFreeChart */ jfreeChart.setTitle(new TextTitle("? -- ?TOP10", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); } else { jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); jfreeChart.setTitle(new TextTitle("? -- ?TOP10", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); } return jfreeChart; }
From source file:jmbench.plots.SummaryWhiskerPlot.java
public JFreeChart createChart() { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, "Matrix Libraries", "Relative Performance", dataSet, true);/*from w ww .java 2s . c o m*/ CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinesVisible(true); plot.setBackgroundPaint(new Color(230, 230, 230)); plot.setDomainGridlinePaint(new Color(50, 50, 50, 50)); plot.setDomainGridlineStroke(new BasicStroke(78f)); chart.getTitle().setFont(new Font("Times New Roman", Font.BOLD, 24)); String foo = "( Higher is Better )"; if (subtitle != null) foo += " ( " + subtitle + " )"; chart.addSubtitle(new TextTitle(foo, new Font("SansSerif", Font.ITALIC, 12))); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.openfaces.component.chart.impl.plots.MultiplePiePlotAdapter.java
private TextTitle getSeriesTitle(Chart chart) { StyleObjectModel cssChartViewModel = chart.getChartView().getStyleObjectModel(); TextTitle seriesTitle;/*from w ww . j ava 2s. com*/ Font f = CSSUtil.getFont(cssChartViewModel); if (f != null) { seriesTitle = new TextTitle("Series Title", f); } else { seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); } if (cssChartViewModel.getColor() != null) { seriesTitle.setPaint(cssChartViewModel.getColor()); } seriesTitle.setPosition(RectangleEdge.BOTTOM); return seriesTitle; }
From source file:jmbench.plots.OperationsVersusSizePlot.java
public void setSubTitle(String title) { chart.addSubtitle(new TextTitle(title, new Font("SansSerif", Font.ITALIC, 12))); }
From source file:net.sf.statcvs.output.xml.chart.AbstractChart.java
/** * create chart with titles and credit information *///from w w w . ja va 2 s . c o m public void placeTitle() { Font font = new Font("SansSerif", Font.PLAIN, 12); Font creditInformationFont = new Font("SansSerif", Font.PLAIN, 9); TextTitle title = new TextTitle(this.title, font); title.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.0)); chart.addSubtitle(title); if (Settings.getShowCreditInformation()) { TextTitle copyright = new TextTitle("generated by statcvs-xml", creditInformationFont); copyright.setPosition(RectangleEdge.BOTTOM); copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(copyright); } chart.setBackgroundPaint(Color.white); }
From source file:agentlogfileanalyzer.gui.ComparisonFrame.java
/** * Creates a chart frame for comparing a selected classifier to a set of * other classifiers./*from w ww . jav a 2 s . c o m*/ * * @param firstTitle * the first line of the chart title * @param secondTitle * the second line of the chart title * @param compDataForColumns * the data the will be displayed in the chart */ public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) { super("Classifier comparison"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < compDataForColumns.size(); i++) { ComparisonDataSet mms = compDataForColumns.get(i); dataset.addValue(mms.getMax(), "max", mms.getColumnName()); dataset.addValue(mms.getMin(), "min", mms.getColumnName()); dataset.addValue(mms.getSelected(), "selected", mms.getColumnName()); } JFreeChart jfreechart = ChartFactory.createBarChart("", // title "", // x-axis title "", // y-axis title dataset, PlotOrientation.VERTICAL, true, true, false); TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12)); TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12)); jfreechart.addSubtitle(0, subtitle1); jfreechart.addSubtitle(1, subtitle2); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer(); categoryplot.setRenderer(minmaxcategoryrenderer); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); }
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);/* www . jav a 2s. 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); } }