19 package org.sleuthkit.autopsy.datasourcesummary.uiutils;
 
   21 import java.awt.BorderLayout;
 
   22 import java.awt.Color;
 
   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.plot.PiePlot;
 
   33 import org.jfree.data.general.DefaultPieDataset;
 
   34 import org.openide.util.NbBundle.Messages;
 
   40     "PieChartPanel_noDataLabel=No Data" 
   44     private static final long serialVersionUID = 1L;
 
   46     private static final Font DEFAULT_FONT = 
new JLabel().getFont();
 
   52     private static final double NEAR_ZERO = Math.ulp(1d);
 
   53     private static final Color NO_DATA_COLOR = Color.WHITE;
 
   54     private static final double DEFAULT_CHART_PADDING = .1;
 
   56     private static final Font DEFAULT_HEADER_FONT = 
new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5));
 
   57     private static final PieSectionLabelGenerator DEFAULT_LABEL_GENERATOR
 
   58             = 
new StandardPieSectionLabelGenerator(
 
   59                     "{0}: {1} ({2})", 
new DecimalFormat(
"#,###"), 
new DecimalFormat(
"0.0%"));
 
   61     private final ChartMessageOverlay overlay = 
new ChartMessageOverlay();
 
   62     private final DefaultPieDataset dataset = 
new DefaultPieDataset();
 
   64     private final PiePlot 
plot;
 
   80         this.chart = ChartFactory.createPieChart(
 
   87         chart.setBackgroundPaint(null);
 
   88         chart.getTitle().setFont(DEFAULT_HEADER_FONT);
 
   90         this.plot = ((PiePlot) chart.getPlot());
 
   91         plot.setInteriorGap(DEFAULT_CHART_PADDING);
 
   92         plot.setLabelGenerator(DEFAULT_LABEL_GENERATOR);
 
   93         plot.setLabelFont(DEFAULT_FONT);
 
   94         plot.setBackgroundPaint(null);
 
   95         plot.setOutlinePaint(null);
 
   98         ChartPanel panel = 
new ChartPanel(chart);
 
   99         panel.addOverlay(overlay);
 
  100         panel.setPopupMenu(null);
 
  102         this.setLayout(
new BorderLayout());
 
  103         this.add(panel, BorderLayout.CENTER);
 
  110         return (this.chart == null || this.chart.getTitle() == null)
 
  112                 : this.chart.getTitle().getText();
 
  123         this.chart.
getTitle().setText(title);
 
  129         this.overlay.setVisible(visible);
 
  130         this.overlay.setMessage(message);
 
  135         this.dataset.clear();
 
  136         this.plot.clearSectionPaints(
false);
 
  138         if (data != null && !data.isEmpty()) {
 
  140                 this.dataset.setValue(slice.getLabel(), slice.getValue());
 
  141                 if (slice.getColor() != null) {
 
  142                     this.plot.setSectionPaint(slice.getLabel(), slice.getColor());
 
  149             this.dataset.setValue(Bundle.PieChartPanel_noDataLabel(), NEAR_ZERO);
 
  150             this.plot.setSectionPaint(Bundle.PieChartPanel_noDataLabel(), NO_DATA_COLOR);
 
  162         setMessage(
true, message);
 
PieChartPanel setTitle(String title)
void setResults(List< PieChartItem > data)
PieChartPanel(String title)
synchronized void showDataWithMessage(List< PieChartItem > data, String message)
void setMessage(boolean visible, String message)