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" 
   89     private static final long serialVersionUID = 1L;
 
   91     private static final Font DEFAULT_FONT = 
new JLabel().getFont();
 
   97     private static final double NEAR_ZERO = Math.ulp(1d);
 
   98     private static final Color NO_DATA_COLOR = Color.WHITE;
 
   99     private static final double DEFAULT_CHART_PADDING = .1;
 
  101     private static final Font DEFAULT_HEADER_FONT = 
new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5));
 
  102     private static final PieSectionLabelGenerator DEFAULT_LABEL_GENERATOR
 
  103             = 
new StandardPieSectionLabelGenerator(
 
  104                     "{0}: {1} ({2})", 
new DecimalFormat(
"#,###"), 
new DecimalFormat(
"0.0%"));
 
  106     private final ChartMessageOverlay overlay = 
new ChartMessageOverlay();
 
  107     private final DefaultPieDataset dataset = 
new DefaultPieDataset();
 
  125         this.chart = ChartFactory.createPieChart(
 
  132         chart.setBackgroundPaint(null);
 
  133         chart.getTitle().setFont(DEFAULT_HEADER_FONT);
 
  135         this.plot = ((PiePlot) chart.getPlot());
 
  136         plot.setInteriorGap(DEFAULT_CHART_PADDING);
 
  137         plot.setLabelGenerator(DEFAULT_LABEL_GENERATOR);
 
  138         plot.setLabelFont(DEFAULT_FONT);
 
  139         plot.setBackgroundPaint(null);
 
  140         plot.setOutlinePaint(null);
 
  143         ChartPanel panel = 
new ChartPanel(chart);
 
  144         panel.addOverlay(overlay);
 
  145         panel.setPopupMenu(null);
 
  147         this.setLayout(
new BorderLayout());
 
  148         this.add(panel, BorderLayout.CENTER);
 
  155         return (this.chart == null || this.chart.getTitle() == null)
 
  157                 : this.chart.getTitle().getText();
 
  168         this.chart.
getTitle().setText(title);
 
  174         this.overlay.setVisible(visible);
 
  175         this.overlay.setMessage(message);
 
  179     protected void setResults(List<PieChartPanel.PieChartItem> data) {
 
  180         this.dataset.clear();
 
  181         this.plot.clearSectionPaints(
false);
 
  183         if (data != null && !data.isEmpty()) {
 
  185                 this.dataset.setValue(slice.getLabel(), slice.getValue());
 
  186                 if (slice.getColor() != null) {
 
  187                     this.plot.setSectionPaint(slice.getLabel(), slice.getColor());
 
  194             this.dataset.setValue(Bundle.PieChartPanel_noDataLabel(), NEAR_ZERO);
 
  195             this.plot.setSectionPaint(Bundle.PieChartPanel_noDataLabel(), NO_DATA_COLOR);
 
  207         setMessage(
true, message);
 
PieChartPanel setTitle(String title)
 
synchronized void showDataWithMessage(List< PieChartPanel.PieChartItem > data, String message)
 
PieChartPanel(String title)
 
PieChartItem(String label, double value, Color color)
 
void setResults(List< PieChartPanel.PieChartItem > data)
 
void setMessage(boolean visible, String message)