List of usage examples for org.jfree.chart.title TextTitle TextTitle
public TextTitle(String text, Font font)
From source file:icaro.aplicaciones.recursos.recursoEstadistica.jFreeChart.demo.PieChartDemo1.java
/** * Creates a chart./*from w ww.j av a 2 s.c o 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, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // 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.setBackgroundPaint(null); plot.setInteriorGap(0.04); // plot.setOutlineVisible(false); // 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:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java
/** * Sets data to display on the graph. This method is used to add aggregates * data to the graph./*from w ww. java 2 s.c o m*/ * * @param serie Aggregrated serie of data * @param lower Aggregated serie of data lowered by the standard deviation * @param upper Aggregated serie of data increased by the standard deviation */ public void setData(TsData serie, TsData lower, TsData upper) { XYPlot plot = chartPanel.getChart().getXYPlot(); chartPanel.getChart().setTitle(new TextTitle("Aggregated Data", new Font("SansSerif", Font.PLAIN, 12))); plot.setDataset(SMOOTH_INDEX, TsXYDatasets.from("series", serie)); plot.setDataset(DIFF_INDEX, TsXYDatasets.builder().add("lower", lower).add("upper", upper).build()); onDataFormatChange(); onColorSchemeChange(); }
From source file:com.xilinx.kintex7.ThermoPlot.java
public void createPlot() { dset = new DefaultValueDataset(50); plot = new ThermometerPlot(dset); plot.setRange(0, 125);// w w w . j av a2s . c om //plot.setFollowDataInSubranges(true); //plot.setUseSubrangePaint(false); plot.setThermometerStroke(new BasicStroke(2.0f)); plot.setSubrange(ThermometerPlot.NORMAL, 0, 60); plot.setSubrange(ThermometerPlot.WARNING, 60, 85); plot.setSubrange(ThermometerPlot.CRITICAL, 86, 125); plot.setThermometerPaint(Color.BLACK); plot.setOutlineVisible(false); plot.setBackgroundAlpha(0); plot.setMercuryPaint(Color.ORANGE); plot.setUnits(ThermometerPlot.UNITS_NONE); chart = new JFreeChart("", plot); TextTitle ttitle = new TextTitle("Temperature (\u2103)", new Font("Temperature (\u2103)", Font.BOLD, 15)); ttitle.setPaint(Color.WHITE); chart.setTitle(ttitle); chart.setBackgroundPaint(new Color(133, 133, 133)); //chart.setTitle(""); }
From source file:com.xilinx.kintex7.PowerChart.java
private void makeChart() { dataset = new DefaultCategoryDataset(); chart = ChartFactory.createBarChart("", "Time Interval", "", dataset, PlotOrientation.HORIZONTAL, true, true, false);/*w ww . j a va 2 s. co m*/ TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15)); ttitle.setPaint(Color.WHITE); chart.setTitle(ttitle); chart.setBackgroundPaint(bg); CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); ValueAxis axis = plot.getRangeAxis(); axis.setUpperBound(6.0); axis.setLowerBound(0.0); axis.setTickLabelPaint(new Color(185, 185, 185)); CategoryAxis caxis = plot.getDomainAxis(); caxis.setTickLabelPaint(new Color(185, 185, 185)); caxis.setLabelPaint(new Color(185, 185, 185)); renderer.setItemMargin(0); renderer.setSeriesPaint(0, new Color(0x17, 0x7b, 0x7c)); renderer.setSeriesPaint(1, new Color(0xa2, 0x45, 0x73)); renderer.setSeriesPaint(2, new Color(0xff, 0x80, 0x40)); renderer.setSeriesPaint(3, new Color(0x6f, 0x2c, 0x85)); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000"))); addDummy(); }
From source file:com.xilinx.kintex7.DMABarChart.java
private void makeChart() { dataset = new DefaultCategoryDataset(); chart = ChartFactory.createBarChart("", "Time Interval", "Throughput (Gbps)", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(bg);//from w w w . j a v a 2 s. co m TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15)); ttitle.setPaint(Color.WHITE); chart.setTitle(ttitle); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); ValueAxis axis = plot.getRangeAxis(); axis.setUpperBound(30.0); axis.setLowerBound(0.0); axis.setTickLabelPaint(new Color(185, 185, 185)); axis.setLabelPaint(new Color(185, 185, 185)); CategoryAxis caxis = plot.getDomainAxis(); caxis.setTickLabelPaint(new Color(185, 185, 185)); caxis.setLabelPaint(new Color(185, 185, 185)); renderer.setItemMargin(0); renderer.setSeriesPaint(0, new Color(0, 0, 0x80)); renderer.setSeriesPaint(1, new Color(0, 0x80, 0xff)); renderer.setSeriesPaint(2, new Color(0xa2, 0x45, 0x73)); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000"))); //renderer.setMaximumBarWidth(0.05); addDummy(); }
From source file:com.xilinx.virtex7.DMABarChart.java
private void makeChart() { dataset = new DefaultCategoryDataset(); chart = ChartFactory.createBarChart("", "Time Interval", "Throughput (Gbps)", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(bg);//w ww .ja v a2s . c o m TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15)); ttitle.setPaint(Color.WHITE); chart.setTitle(ttitle); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); ValueAxis axis = plot.getRangeAxis(); axis.setUpperBound(64.0); axis.setLowerBound(0.0); axis.setTickLabelPaint(new Color(185, 185, 185)); axis.setLabelPaint(new Color(185, 185, 185)); CategoryAxis caxis = plot.getDomainAxis(); caxis.setTickLabelPaint(new Color(185, 185, 185)); caxis.setLabelPaint(new Color(185, 185, 185)); renderer.setItemMargin(0); renderer.setSeriesPaint(0, new Color(0, 0, 0x80)); renderer.setSeriesPaint(1, new Color(0, 0x80, 0xff)); renderer.setSeriesPaint(2, new Color(0xa2, 0x45, 0x73)); renderer.setSeriesPaint(3, new Color(0x40, 0xa1, 0xff)); renderer.setSeriesPaint(4, new Color(0xa1, 0x60, 0x98)); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000"))); //renderer.setMaximumBarWidth(0.05); addDummy(); }
From source file:com.xilinx.virtex7.PowerChart.java
private void makeChart() { dataset = new DefaultCategoryDataset(); chart = ChartFactory.createBarChart("", "Time Interval", "", dataset, PlotOrientation.HORIZONTAL, true, true, false);/* w ww . j a v a 2 s .com*/ TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15)); ttitle.setPaint(Color.WHITE); chart.setTitle(ttitle); chart.setBackgroundPaint(bg); CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); ValueAxis axis = plot.getRangeAxis(); axis.setUpperBound(10.0); TickUnits tickUnits = new TickUnits(); tickUnits.add(new NumberTickUnit(2)); axis.setStandardTickUnits(tickUnits); axis.setLowerBound(0.0); axis.setTickLabelPaint(new Color(185, 185, 185)); CategoryAxis caxis = plot.getDomainAxis(); caxis.setTickLabelPaint(new Color(185, 185, 185)); caxis.setLabelPaint(new Color(185, 185, 185)); renderer.setItemMargin(0); renderer.setSeriesPaint(0, new Color(0x17, 0x7b, 0x7c)); renderer.setSeriesPaint(1, new Color(0xa2, 0x45, 0x73)); renderer.setSeriesPaint(2, new Color(0xff, 0x80, 0x40)); renderer.setSeriesPaint(3, new Color(0x6f, 0x2c, 0x85)); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000"))); addDummy(); }
From source file:charts.PieChart3D.java
/** * Creates a chart./*from w ww .ja v a 2 s. com*/ * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset, PieChartModel model) { JFreeChart chart = ChartFactory.createPieChart(model.getTitle(), // chart // title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // 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.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("FCA", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("FCH", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("FCS", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("FCG", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setSectionPaint("FCJ", createGradientPaint(new Color(200, 255, 200), Color.BLACK)); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {1} ({2}) ")); 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(model.getSubTitle(), 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:RMOS.PieChart.java
/** * Creates a chart./* w w w . j a va 2 s .c om*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Eco Systems Statistics", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // 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.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); plot.setSectionPaint(f1.getStationInGroup().get(1), Color.blue); plot.setSectionPaint(f1.getStationInGroup().get(1), Color.GREEN); // 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: Eco Recycle Station", 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.jfree.chart.demo.CombinedXYPlotDemo5.java
/** * Creates a combined XYPlot chart./* w w w. ja v a 2s. c o m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create a default chart based on some sample data... final TimeSeriesCollection dataset0 = new TimeSeriesCollection(); final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries(); dataset0.addSeries(eur); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(); final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30); dataset1.addSeries(eur); dataset1.addSeries(mav); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(); dataset2.addSeries(eur); JFreeChart chart = null; // make a common vertical axis for all the sub-plots final NumberAxis valueAxis = new NumberAxis("Value"); valueAxis.setAutoRangeIncludesZero(false); // override default // make a horizontally combined plot final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis); // add subplot 1... final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis("Date 1"), null, new StandardXYItemRenderer()); subplot1.setDomainCrosshairVisible(true); subplot1.setRangeCrosshairVisible(true); parent.add(subplot1, 1); // add subplot 2... final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis("Date 2"), null, new StandardXYItemRenderer()); subplot2.setDomainCrosshairVisible(true); subplot2.setRangeCrosshairVisible(true); parent.add(subplot2, 1); // add subplot 3... final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis("Date 3"), null, new XYBarRenderer(0.20)); subplot3.setDomainCrosshairVisible(true); subplot3.setRangeCrosshairVisible(true); parent.add(subplot3, 1); // now make the top level JFreeChart chart = new JFreeChart("Demo Chart", JFreeChart.DEFAULT_TITLE_FONT, parent, true); // then customise it a little... final TextTitle subtitle = new TextTitle("This is a subtitle", new Font("SansSerif", Font.BOLD, 12)); chart.addSubtitle(subtitle); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); return chart; }