List of usage examples for org.jfree.chart.labels StandardPieToolTipGenerator StandardPieToolTipGenerator
public StandardPieToolTipGenerator()
From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java
/** * /*from www. j ava2 s . co m*/ * * @param title * @param titleFont * @param data ?? * @param order * @param legend * @param tooltips ???? * @param urls ??URL * @param urlGenerator * * @return */ public static JFreeChart createPieChart(String title, java.awt.Font titleFont, CategoryDataset data, TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) { MultiplePiePlot plot = new MultiplePiePlot(data); plot.setDataExtractOrder(order); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); // pp.setInsets(new Insets(0, 5, 5, 5)); pp.setBackgroundPaint(null); pp.setOutlineStroke(null); // plot.setOutlineStroke(null); PieToolTipGenerator tooltipGenerator = null; if (tooltips) { tooltipGenerator = new StandardPieToolTipGenerator(); } // PieURLGenerator urlGenerator = null; if (!urls) { urlGenerator = null; } pp.setToolTipGenerator(tooltipGenerator); pp.setLabelGenerator(null); pp.setURLGenerator(urlGenerator); JFreeChart chart = new JFreeChart(title, titleFont, plot, legend); return chart; }
From source file:com.tonbeller.jpivot.chart.ChartFactory.java
/** * Creates a chart containing multiple pie charts, from a TableDataset. * * @param title the chart title.//from w w w. j a v a 2s.c o m * @param data the dataset for the chart. * @param extractType <code>PER_ROW</code> or <code>PER_COLUMN</code> (defined in * {@link PiePlot}). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return a pie chart. */ public static JFreeChart createPieChart(String title, java.awt.Font titleFont, CategoryDataset data, TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) { MultiplePiePlot plot = new MultiplePiePlot(data); plot.setDataExtractOrder(order); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); //pp.setInsets(new Insets(0, 5, 5, 5)); pp.setBackgroundPaint(null); // no outline around each piechart pp.setOutlineStroke(null); //plot.setOutlineStroke(null); PieToolTipGenerator tooltipGenerator = null; if (tooltips) { tooltipGenerator = new StandardPieToolTipGenerator(); } //PieURLGenerator urlGenerator = null; if (!urls) { urlGenerator = null; } pp.setToolTipGenerator(tooltipGenerator); pp.setLabelGenerator(null); pp.setURLGenerator(urlGenerator); JFreeChart chart = new JFreeChart(title, titleFont, plot, legend); return chart; }
From source file:org.operamasks.faces.render.graph.PieChartRenderer.java
protected JFreeChart createChart(UIChart comp) { Dataset dataset = createDataset(comp); JFreeChart chart = null;//from ww w.ja va 2 s.com PiePlot pieplot = null; boolean ring = Coercion.coerceToBoolean(comp.getAttributes().get("ring")); if (dataset instanceof CategoryDataset) { CategoryDataset catset = (CategoryDataset) dataset; if (catset.getRowCount() == 1) { PieDataset pieset = new CategoryToPieDataset(catset, TableOrder.BY_ROW, 0); if (ring) { chart = ChartFactory.createRingChart(null, pieset, false, false, false); } else if (comp.isEffect3D()) { chart = ChartFactory.createPieChart3D(null, pieset, false, false, false); } else { chart = ChartFactory.createPieChart(null, pieset, false, false, false); } pieplot = (PiePlot) chart.getPlot(); } else { if (comp.isEffect3D()) { chart = ChartFactory.createMultiplePieChart3D(null, catset, TableOrder.BY_ROW, false, false, false); } else { chart = ChartFactory.createMultiplePieChart(null, catset, TableOrder.BY_ROW, false, false, false); } pieplot = (PiePlot) ((MultiplePiePlot) chart.getPlot()).getPieChart().getPlot(); } } if (pieplot != null) { if (!comp.isDrawItemLabel()) { pieplot.setLabelGenerator(null); } if (comp.isShowItemTips()) { pieplot.setToolTipGenerator(new StandardPieToolTipGenerator()); } Object startAngle = comp.getAttributes().get("startAngle"); if (startAngle != null) { pieplot.setStartAngle(Coercion.coerceToDouble(startAngle)); } } return chart; }
From source file:nextapp.echo.chart.testapp.testscreen.PieChartTest.java
public PieChartTest() { super(SplitPane.ORIENTATION_HORIZONTAL, new Extent(250, Extent.PX)); setStyleName("DefaultResizable"); ButtonColumn controlsColumn = new ButtonColumn(); controlsColumn.setStyleName("TestControlsColumn"); add(controlsColumn);//from w w w . j a v a 2s .com DefaultKeyedValues values = new DefaultKeyedValues(); values.addValue("Widgets", 500.2); values.addValue("Cubits", 216.0); values.addValue("Zonkits", 125.9); final DefaultPieDataset pieDataset = new DefaultPieDataset(new DefaultPieDataset(values)); PiePlot piePlot = new PiePlot(pieDataset); piePlot.setToolTipGenerator(new StandardPieToolTipGenerator()); final ChartDisplay chartDisplay = new ChartDisplay(piePlot); add(chartDisplay); chartDisplay.setActionCommands(new String[] { "Widgets", "Cubits", "Zonkits" }); chartDisplay.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { WindowPane window = new WindowPane("Chart series clicked", new Extent(300), new Extent(200)); window.add(new Label("You clicked on " + arg0.getActionCommand())); Component contentPane = getParent(); while (!(contentPane instanceof ContentPane)) { contentPane = contentPane.getParent(); } contentPane.add(window); } }); ChartPanel chartPanel = new ChartPanel(new JFreeChart(piePlot)); chartPanel.setRefreshBuffer(true); ChartEntity entity = chartPanel.getEntityForPoint(50, 50); System.out.println("Entity: " + entity); controlsColumn.addButton("Set Width = 800px", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setWidth(new Extent(800)); } } }); controlsColumn.addButton("Set Width = null", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setWidth(null); } } }); controlsColumn.addButton("Set Height = 600px", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setHeight(new Extent(600)); } } }); controlsColumn.addButton("Set Height = null", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setHeight(null); } } }); controlsColumn.addButton("Update a Value", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { pieDataset.setValue("Cubits", Math.random() * 500); } } }); }
From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java
/** * 3D//from w w w. j a v a2 s. co m * * @param title * @param titleFont * @param data ?? * @param order * @param legend * @param tooltips ???? * @param urls ??URL * @param urlGenerator * * @return */ public static JFreeChart create3DPieChart(String title, java.awt.Font titleFont, CategoryDataset data, TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) { MultiplePiePlot plot = new MultiplePiePlot(data); plot.setDataExtractOrder(order); // plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot(); pp.setBackgroundPaint(null); // pp.setInsets(new Insets(0, 5, 5, 5)); pp.setOutlineStroke(null); PieToolTipGenerator tooltipGenerator = null; if (tooltips) { tooltipGenerator = new StandardPieToolTipGenerator(); } if (!urls) { urlGenerator = null; } pp.setToolTipGenerator(tooltipGenerator); pp.setLabelGenerator(null); pp.setURLGenerator(urlGenerator); JFreeChart chart = new JFreeChart(title, titleFont, plot, legend); return chart; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); }/*from w w w . j a v a 2 s . c o m*/ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart("Pie Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:com.tonbeller.jpivot.chart.ChartFactory.java
/** * Creates a sample dataset for the demo. * // ww w . jav a 2s . co m * @return A sample dataset. */ public static JFreeChart create3DPieChart(String title, java.awt.Font titleFont, CategoryDataset data, TableOrder order, boolean legend, boolean tooltips, boolean urls, PieURLGenerator urlGenerator) { MultiplePiePlot plot = new MultiplePiePlot(data); plot.setDataExtractOrder(order); //plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot(); pp.setBackgroundPaint(null); //pp.setInsets(new Insets(0, 5, 5, 5)); // no outline around each piechart pp.setOutlineStroke(null); PieToolTipGenerator tooltipGenerator = null; if (tooltips) { tooltipGenerator = new StandardPieToolTipGenerator(); } if (!urls) { urlGenerator = null; } pp.setToolTipGenerator(tooltipGenerator); pp.setLabelGenerator(null); pp.setURLGenerator(urlGenerator); JFreeChart chart = new JFreeChart(title, titleFont, plot, legend); return chart; }
From source file:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**//from w w 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:net.sourceforge.processdash.ui.lib.chart.DiscPlot.java
public DiscPlot(PieDataset dataset) { super();//ww w .j a va 2s . co m this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this); } this.interiorGap = DEFAULT_INTERIOR_GAP; this.discDistributor = new StandardDiscItemDistributor(dataset); this.discRenderer = new StandardDiscItemRenderer(); this.labelGenerator = new StandardPieSectionLabelGenerator(); this.labelFont = DEFAULT_LABEL_FONT; this.labelPaint = DEFAULT_LABEL_PAINT; this.toolTipGenerator = new StandardPieToolTipGenerator(); this.urlGenerator = null; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset, PieDataset previousDataset) { final boolean greenForIncrease = true; final boolean subTitle = true; final boolean showDifference = true; int percentDiffForMaxScale = 20; PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); }/*from w w w . j av a 2 s. co m*/ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } @SuppressWarnings({ "rawtypes", "unchecked" }) List<Comparable> keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (@SuppressWarnings("rawtypes") Comparable key : keys) { Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue( key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart("Pie Chart Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } plot.setNoDataMessage("No data available"); return chart; }