19package org.sleuthkit.autopsy.datasourcesummary.uiutils;
21import java.awt.BorderLayout;
24import java.text.DecimalFormat;
26import javax.swing.JLabel;
27import org.jfree.chart.ChartFactory;
28import org.jfree.chart.ChartPanel;
29import org.jfree.chart.JFreeChart;
30import org.jfree.chart.labels.PieSectionLabelGenerator;
31import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
32import org.jfree.chart.plot.PiePlot;
33import org.jfree.data.general.DefaultPieDataset;
34import org.openide.util.NbBundle.Messages;
40 "PieChartPanel_noDataLabel=No Data"
52 private static final double NEAR_ZERO = Math.ulp(1d);
58 =
new StandardPieSectionLabelGenerator(
59 "{0}: {1} ({2})",
new DecimalFormat(
"#,###"),
new DecimalFormat(
"0.0%"));
61 private final ChartMessageOverlay
overlay =
new ChartMessageOverlay();
62 private final DefaultPieDataset<String>
dataset =
new DefaultPieDataset<>();
64 private final PiePlot<String>
plot;
66 @SuppressWarnings(
"unchecked")
68 return ((PiePlot<String>)
chart.getPlot());
86 this.chart = ChartFactory.createPieChart(
93 chart.setBackgroundPaint(
null);
99 plot.setBackgroundPaint(
null);
100 plot.setOutlinePaint(
null);
103 ChartPanel panel =
new ChartPanel(
chart);
105 panel.setPopupMenu(
null);
107 this.setLayout(
new BorderLayout());
108 this.add(panel, BorderLayout.CENTER);
115 return (this.chart ==
null || this.chart.getTitle() ==
null)
117 : this.chart.getTitle().getText();
128 this.chart.
getTitle().setText(title);
134 this.overlay.setVisible(visible);
135 this.overlay.setMessage(message);
140 this.dataset.clear();
141 this.plot.clearSectionPaints(
false);
143 if (data !=
null && !data.isEmpty()) {
145 this.dataset.setValue(slice.getLabel(), slice.getValue());
146 if (slice.getColor() !=
null) {
147 this.plot.setSectionPaint(slice.getLabel(), slice.getColor());
154 this.dataset.setValue(Bundle.PieChartPanel_noDataLabel(),
NEAR_ZERO);
155 this.plot.setSectionPaint(Bundle.PieChartPanel_noDataLabel(),
NO_DATA_COLOR);
final DefaultPieDataset< String > dataset
synchronized void showDataWithMessage(List< PieChartItem > data, String message)
static final Font DEFAULT_HEADER_FONT
static final Font DEFAULT_FONT
void setResults(List< PieChartItem > data)
final PiePlot< String > plot
void setMessage(boolean visible, String message)
static PiePlot< String > getTypedPlot(JFreeChart chart)
static final PieSectionLabelGenerator DEFAULT_LABEL_GENERATOR
static final double NEAR_ZERO
PieChartPanel(String title)
static final Color NO_DATA_COLOR
static final double DEFAULT_CHART_PADDING
final ChartMessageOverlay overlay
PieChartPanel setTitle(String title)
static final long serialVersionUID