19 package org.sleuthkit.autopsy.datasourcesummary.uiutils;
 
   21 import java.awt.BorderLayout;
 
   23 import java.awt.Graphics2D;
 
   24 import java.text.DecimalFormat;
 
   25 import java.util.List;
 
   26 import javax.swing.JLabel;
 
   27 import org.jfree.chart.ChartFactory;
 
   28 import org.jfree.chart.ChartPanel;
 
   29 import org.jfree.chart.JFreeChart;
 
   30 import org.jfree.chart.labels.PieSectionLabelGenerator;
 
   31 import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
 
   32 import org.jfree.chart.panel.AbstractOverlay;
 
   33 import org.jfree.chart.panel.Overlay;
 
   34 import org.jfree.chart.plot.PiePlot;
 
   35 import org.jfree.data.general.DefaultPieDataset;
 
   36 import org.openide.util.NbBundle.Messages;
 
   42     "PieChartPanel_noDataLabel=No Data" 
   84     private static class MessageOverlay extends AbstractOverlay implements Overlay {
 
   86         private static final long serialVersionUID = 1L;
 
   95         void setVisible(
boolean visible) {
 
  104         void setMessage(String message) {
 
  110             overlay.
paintOverlay(gd, cp.getWidth(), cp.getHeight());
 
  115     private static final long serialVersionUID = 1L;
 
  117     private static final Font DEFAULT_FONT = 
new JLabel().getFont();
 
  123     private static final double NEAR_ZERO = Math.ulp(1d);
 
  125     private static final Font DEFAULT_HEADER_FONT = 
new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5));
 
  126     private static final PieSectionLabelGenerator DEFAULT_LABEL_GENERATOR
 
  127             = 
new StandardPieSectionLabelGenerator(
 
  128                     "{0}: {1} ({2})", 
new DecimalFormat(
"#,###"), 
new DecimalFormat(
"0.0%"));
 
  131     private final DefaultPieDataset dataset = 
new DefaultPieDataset();
 
  148         this.chart = ChartFactory.createPieChart(
 
  155         chart.setBackgroundPaint(null);
 
  156         chart.getLegend().setItemFont(DEFAULT_FONT);
 
  157         chart.getTitle().setFont(DEFAULT_HEADER_FONT);
 
  160         chart.removeLegend();
 
  162         PiePlot plot = ((PiePlot) chart.getPlot());
 
  164         plot.setLabelGenerator(DEFAULT_LABEL_GENERATOR);
 
  165         plot.setLabelFont(DEFAULT_FONT);
 
  166         plot.setBackgroundPaint(null);
 
  167         plot.setOutlinePaint(null);
 
  170         ChartPanel panel = 
new ChartPanel(chart);
 
  171         panel.addOverlay(overlay);
 
  172         this.setLayout(
new BorderLayout());
 
  173         this.add(panel, BorderLayout.CENTER);
 
  180         return (this.chart == null || this.chart.getTitle() == null)
 
  182                 : this.chart.getTitle().getText();
 
  193         this.chart.
getTitle().setText(title);
 
  199         this.overlay.setVisible(visible);
 
  200         this.overlay.setMessage(message);
 
  204     protected void setResults(List<PieChartPanel.PieChartItem> data) {
 
  205         this.dataset.clear();
 
  206         if (data != null && !data.isEmpty()) {
 
  208                 this.dataset.setValue(slice.getLabel(), slice.getValue());
 
  214             this.dataset.setValue(Bundle.PieChartPanel_noDataLabel(), NEAR_ZERO);
 
  226         setMessage(
true, message);
 
PieChartPanel setTitle(String title)
 
synchronized void showDataWithMessage(List< PieChartPanel.PieChartItem > data, String message)
 
void paintOverlay(Graphics2D gd, ChartPanel cp)
 
void paintOverlay(Graphics g, int width, int height)
 
PieChartPanel(String title)
 
void setMessage(String message)
 
PieChartItem(String label, double value)
 
void setResults(List< PieChartPanel.PieChartItem > data)
 
void setVisible(boolean visible)
 
void setMessage(boolean visible, String message)