List of usage examples for org.jfree.chart.ui RectangleEdge BOTTOM
RectangleEdge BOTTOM
To view the source code for org.jfree.chart.ui RectangleEdge BOTTOM.
Click Source Link
From source file:org.jfree.graphics2d.demo.SVGPieChartDemo1.java
/** * Creates a chart./*w w w . ja va 2 s .co m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title dataset); chart.removeLegend(); // set a custom background for the chart chart.setBackgroundPainter(new GradientPainter(new Color(20, 20, 20), RectangleAnchor.TOP_LEFT, Color.DARK_GRAY, RectangleAnchor.BOTTOM_RIGHT)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPainter(null); plot.setInteriorGap(0.04); plot.setBorderPainter(null); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java
private void addNotice(JFreeChart chart) { TextTitle notice = new TextTitle(); String msg = i18n.get("msg.io.chart.notice"); if (msg != null && !msg.isEmpty()) { notice.setText(msg);//from w w w .j a va 2 s. c o m notice.setPaint(Color.BLACK); notice.setFont(LabelConstants.FONT_LABEL_SMALL); notice.setPosition(RectangleEdge.BOTTOM); notice.setHorizontalAlignment(HorizontalAlignment.RIGHT); notice.setVerticalAlignment(VerticalAlignment.BOTTOM); notice.setPadding(new RectangleInsets(0, 0, 20, 20)); chart.addSubtitle(notice); } }
From source file:org.jfree.chart.ChartFactory.java
/** * Creates a chart that displays multiple pie plots. The chart object * returned by this method uses a {@link MultiplePiePlot} instance as the * plot./*from ww w . ja v a 2s .c om*/ * * @param title the chart title ({@code null} permitted). * @param dataset the dataset ({@code null} permitted). * @param order the order that the data is extracted (by row or by column) * ({@code null} not permitted). * * @return A chart. */ public static JFreeChart createMultiplePieChart3D(String title, CategoryDataset dataset, TableOrder order) { ParamChecks.nullNotPermitted(order, "order"); MultiplePiePlot plot = new MultiplePiePlot(dataset); plot.setDataExtractOrder(order); plot.setBackgroundPainter(null); plot.setBorderPainter(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPainter(null); plot.setPieChart(pieChart); PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }