@@ -0,0 +1,3400 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage org.sleuthkit.autopsy.casemodule.datasourcesummary;%0A%0Aimport java.awt.BorderLayout;%0Aimport javax.swing.JPanel;%0Aimport org.sleuthkit.datamodel.DataSource;%0A%0Aimport org.jfree.chart.ChartFactory;%0Aimport org.jfree.chart.ChartPanel;%0Aimport org.jfree.chart.JFreeChart;%0Aimport org.jfree.chart.labels.PieSectionLabelGenerator;%0Aimport org.jfree.chart.labels.StandardPieSectionLabelGenerator;%0Aimport org.jfree.chart.plot.PiePlot;%0Aimport org.jfree.data.general.DefaultPieDataset;%0A%0Aimport java.text.DecimalFormat;%0Aimport org.openide.util.NbBundle;%0Aimport org.sleuthkit.autopsy.coreutils.FileTypeUtils;%0A%0A/**%0A *%0A * @author gregd%0A */%0Apublic class FileTypePieChart extends JPanel %7B%0A%0A    private DataSource dataSource;%0A    private DefaultPieDataset dataset = new DefaultPieDataset();%0A%0A    public FileTypePieChart() %7B%0A        // Create chart%0A        JFreeChart chart = ChartFactory.createPieChart(%0A                NbBundle.getMessage(DataSourceSummaryCountsPanel.class, %22DataSourceSummaryCountsPanel.byMimeTypeLabel.text%22),%0A                dataset,%0A                true,%0A                true,%0A                false);%0A%0A        //Format Label%0A        PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator(%0A                %22%7B0%7D: %7B1%7D (%7B2%7D)%22, new DecimalFormat(%220%22), new DecimalFormat(%220.0%25%22));%0A        ((PiePlot) chart.getPlot()).setLabelGenerator(labelGenerator);%0A%0A        // Create Panel%0A        ChartPanel panel = new ChartPanel(chart);%0A        this.setLayout(new BorderLayout());%0A        this.add(panel, BorderLayout.CENTER);%0A    %7D%0A%0A    DataSource getDataSource() %7B%0A        return this.dataSource;%0A    %7D%0A%0A    void setDataSource(DataSource dataSource) %7B%0A        this.dataSource = dataSource;%0A        this.dataset.clear();%0A%0A        if (dataSource != null) %7B%0A            this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_images_row(),%0A                    getCount(dataSource, FileTypeUtils.FileTypeCategory.IMAGE));%0A            this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(),%0A                    getCount(dataSource, FileTypeUtils.FileTypeCategory.VIDEO));%0A            this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_audio_row(),%0A                    getCount(dataSource, FileTypeUtils.FileTypeCategory.AUDIO));%0A            this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_documents_row(),%0A                    getCount(dataSource, FileTypeUtils.FileTypeCategory.DOCUMENTS));%0A            this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_executables_row(),%0A                    getCount(dataSource, FileTypeUtils.FileTypeCategory.EXECUTABLE));%0A        %7D%0A    %7D%0A%0A    /**%0A     * Retrieves the counts of files of a particular mime type for a particular%0A     * DataSource.%0A     *%0A     * @param dataSource The DataSource.%0A     * @param category   The mime type category.%0A     *%0A     * @return The count.%0A     */%0A    private static Long getCount(DataSource dataSource, FileTypeUtils.FileTypeCategory category) %7B%0A        return DataSourceInfoUtilities.getCountOfFilesForMimeTypes(dataSource, category.getMediaTypes());%0A    %7D%0A%7D%0A

use of jfreechart for files by mime type pie chart