19 package org.sleuthkit.autopsy.datasourcesummary.uiutils;
21 import java.awt.BorderLayout;
23 import java.util.List;
24 import javax.swing.JLabel;
25 import org.apache.commons.collections4.CollectionUtils;
26 import org.jfree.chart.ChartFactory;
27 import org.jfree.chart.ChartPanel;
28 import org.jfree.chart.JFreeChart;
29 import org.jfree.chart.axis.ValueAxis;
30 import org.jfree.chart.plot.CategoryPlot;
31 import org.jfree.chart.plot.PlotOrientation;
32 import org.jfree.chart.renderer.category.BarRenderer;
33 import org.jfree.chart.renderer.category.StandardBarPainter;
34 import org.jfree.data.category.DefaultCategoryDataset;
47 public static class OrderedKey implements Comparable<OrderedKey> {
67 Object getKeyValue() {
86 return Integer.compare(this.getKeyIndex(), o.getKeyIndex());
103 if (getClass() != obj.getClass()) {
107 if (this.keyIndex != other.
keyIndex) {
116 return this.getKeyValue() == null ? null : this.getKeyValue().toString();
123 private static final Font
DEFAULT_HEADER_FONT =
new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5));
125 private final ChartMessageOverlay
overlay =
new ChartMessageOverlay();
126 private final DefaultCategoryDataset
dataset =
new DefaultCategoryDataset();
128 private final CategoryPlot
plot;
134 this(null, null, null);
144 public BarChartPanel(String title, String categoryLabel, String valueLabel) {
145 this.chart = ChartFactory.createStackedBarChart(
150 PlotOrientation.VERTICAL,
154 chart.setBackgroundPaint(null);
155 chart.getTitle().setFont(DEFAULT_HEADER_FONT);
157 this.plot = ((CategoryPlot) chart.getPlot());
158 this.plot.getRenderer().setBaseItemLabelFont(DEFAULT_FONT);
159 plot.setBackgroundPaint(null);
160 plot.setOutlinePaint(null);
163 ValueAxis range = plot.getRangeAxis();
164 range.setVisible(
false);
167 plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10);
169 ((BarRenderer) plot.getRenderer()).setBarPainter(
new StandardBarPainter());
172 ChartPanel panel =
new ChartPanel(chart);
173 panel.addOverlay(overlay);
174 panel.setPopupMenu(null);
176 this.setLayout(
new BorderLayout());
177 this.add(panel, BorderLayout.CENTER);
184 return (this.chart == null || this.chart.getTitle() == null)
186 : this.chart.getTitle().getText();
197 this.chart.
getTitle().setText(title);
203 this.overlay.setVisible(visible);
204 this.overlay.setMessage(message);
209 this.dataset.clear();
211 if (CollectionUtils.isNotEmpty(data)) {
212 for (
int s = 0; s < data.size(); s++) {
214 if (series != null && CollectionUtils.isNotEmpty(series.
getItems())) {
216 this.plot.getRenderer().setSeriesPaint(s, series.
getColor());
219 for (
int i = 0; i < series.
getItems().size(); i++) {
final DefaultCategoryDataset dataset
int compareTo(OrderedKey o)
static final Font DEFAULT_FONT
OrderedKey(Object keyValue, int keyIndex)
void setResults(List< BarChartSeries > data)
final ChartMessageOverlay overlay
void setMessage(boolean visible, String message)
static final long serialVersionUID
List< BarChartItem > getItems()
BarChartPanel setTitle(String title)
static final Font DEFAULT_HEADER_FONT
boolean equals(Object obj)
BarChartPanel(String title, String categoryLabel, String valueLabel)