mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
formatting
This commit is contained in:
parent
690a799059
commit
3dd03d1683
@ -32,7 +32,6 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
import org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory;
|
import org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -153,30 +152,57 @@ class TypesPanel extends BaseDataSourceSummaryPanel {
|
|||||||
return usefulContent;
|
return usefulContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information concerning a particular category in the file types pie chart.
|
||||||
|
*/
|
||||||
private static class TypesPieCategory {
|
private static class TypesPieCategory {
|
||||||
|
|
||||||
private final String label;
|
private final String label;
|
||||||
private final Set<String> mimeTypes;
|
private final Set<String> mimeTypes;
|
||||||
private final Color color;
|
private final Color color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main constructor.
|
||||||
|
*
|
||||||
|
* @param label The label for this slice.
|
||||||
|
* @param mimeTypes The mime types associated with this slice.
|
||||||
|
* @param color The color associated with this slice.
|
||||||
|
*/
|
||||||
TypesPieCategory(String label, Set<String> mimeTypes, Color color) {
|
TypesPieCategory(String label, Set<String> mimeTypes, Color color) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.mimeTypes = mimeTypes;
|
this.mimeTypes = mimeTypes;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor that accepts FileTypeCategory.
|
||||||
|
*
|
||||||
|
* @param label The label for this slice.
|
||||||
|
* @param mimeTypes The mime types associated with this slice.
|
||||||
|
* @param color The color associated with this slice.
|
||||||
|
*/
|
||||||
TypesPieCategory(String label, FileTypeCategory fileCategory, Color color) {
|
TypesPieCategory(String label, FileTypeCategory fileCategory, Color color) {
|
||||||
this(label, fileCategory.getMediaTypes(), color);
|
this(label, fileCategory.getMediaTypes(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The label for this category.
|
||||||
|
*/
|
||||||
String getLabel() {
|
String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The mime types associated with this category.
|
||||||
|
*/
|
||||||
Set<String> getMimeTypes() {
|
Set<String> getMimeTypes() {
|
||||||
return mimeTypes;
|
return mimeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The color associated with this category.
|
||||||
|
*/
|
||||||
Color getColor() {
|
Color getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
@ -188,14 +214,14 @@ class TypesPanel extends BaseDataSourceSummaryPanel {
|
|||||||
private static final String FILE_TYPE_FACTORY = FileTypeIdModuleFactory.class.getCanonicalName();
|
private static final String FILE_TYPE_FACTORY = FileTypeIdModuleFactory.class.getCanonicalName();
|
||||||
private static final String FILE_TYPE_MODULE_NAME = FileTypeIdModuleFactory.getModuleName();
|
private static final String FILE_TYPE_MODULE_NAME = FileTypeIdModuleFactory.getModuleName();
|
||||||
private static final Logger logger = Logger.getLogger(TypesPanel.class.getName());
|
private static final Logger logger = Logger.getLogger(TypesPanel.class.getName());
|
||||||
|
|
||||||
private static final Color IMAGES_COLOR = new Color(156, 39, 176);
|
private static final Color IMAGES_COLOR = new Color(156, 39, 176);
|
||||||
private static final Color VIDEOS_COLOR = Color.YELLOW;
|
private static final Color VIDEOS_COLOR = Color.YELLOW;
|
||||||
private static final Color AUDIO_COLOR = Color.BLUE;
|
private static final Color AUDIO_COLOR = Color.BLUE;
|
||||||
private static final Color DOCUMENTS_COLOR = Color.GREEN;
|
private static final Color DOCUMENTS_COLOR = Color.GREEN;
|
||||||
private static final Color EXECUTABLES_COLOR = new Color(0,188,212);
|
private static final Color EXECUTABLES_COLOR = new Color(0, 188, 212);
|
||||||
private static final Color UNKNOWN_COLOR = Color.ORANGE;
|
private static final Color UNKNOWN_COLOR = Color.ORANGE;
|
||||||
private static final Color OTHER_COLOR = new Color(78,52,46);
|
private static final Color OTHER_COLOR = new Color(78, 52, 46);
|
||||||
private static final Color NOT_ANALYZED_COLOR = Color.WHITE;
|
private static final Color NOT_ANALYZED_COLOR = Color.WHITE;
|
||||||
|
|
||||||
// All file type categories.
|
// All file type categories.
|
||||||
@ -331,7 +357,8 @@ class TypesPanel extends BaseDataSourceSummaryPanel {
|
|||||||
/**
|
/**
|
||||||
* Gets all the data for the file type pie chart.
|
* Gets all the data for the file type pie chart.
|
||||||
*
|
*
|
||||||
* @param dataSource The datasource.
|
* @param mimeTypeData The means of acquiring data.
|
||||||
|
* @param dataSource The datasource.
|
||||||
*
|
*
|
||||||
* @return The pie chart items.
|
* @return The pie chart items.
|
||||||
*/
|
*/
|
||||||
@ -345,13 +372,13 @@ class TypesPanel extends BaseDataSourceSummaryPanel {
|
|||||||
// for each category of file types, get the counts of files
|
// for each category of file types, get the counts of files
|
||||||
List<PieChartItem> fileCategoryItems = new ArrayList<>();
|
List<PieChartItem> fileCategoryItems = new ArrayList<>();
|
||||||
long categoryTotalCount = 0;
|
long categoryTotalCount = 0;
|
||||||
|
|
||||||
for (TypesPieCategory cat : FILE_MIME_TYPE_CATEGORIES) {
|
for (TypesPieCategory cat : FILE_MIME_TYPE_CATEGORIES) {
|
||||||
long thisValue = getLongOrZero(mimeTypeData.getCountOfFilesForMimeTypes(dataSource, cat.getMimeTypes()));
|
long thisValue = getLongOrZero(mimeTypeData.getCountOfFilesForMimeTypes(dataSource, cat.getMimeTypes()));
|
||||||
categoryTotalCount += thisValue;
|
categoryTotalCount += thisValue;
|
||||||
|
|
||||||
fileCategoryItems.add(new PieChartItem(
|
fileCategoryItems.add(new PieChartItem(
|
||||||
cat.getLabel(),
|
cat.getLabel(),
|
||||||
thisValue,
|
thisValue,
|
||||||
cat.getColor()));
|
cat.getColor()));
|
||||||
}
|
}
|
||||||
@ -364,19 +391,21 @@ class TypesPanel extends BaseDataSourceSummaryPanel {
|
|||||||
|
|
||||||
// create entry for mime types in other category
|
// create entry for mime types in other category
|
||||||
long otherCount = allRegularFiles - (categoryTotalCount + noMimeTypeCount);
|
long otherCount = allRegularFiles - (categoryTotalCount + noMimeTypeCount);
|
||||||
PieChartItem otherPieItem = new PieChartItem(Bundle.TypesPanel_fileMimeTypesChart_other_title(),
|
PieChartItem otherPieItem = new PieChartItem(Bundle.TypesPanel_fileMimeTypesChart_other_title(),
|
||||||
otherCount, OTHER_COLOR);
|
otherCount, OTHER_COLOR);
|
||||||
|
|
||||||
// check at this point to see if these are all 0; if so, we don't have useful content.
|
// check at this point to see if these are all 0; if so, we don't have useful content.
|
||||||
boolean usefulContent = categoryTotalCount > 0 || otherCount > 0;
|
boolean usefulContent = categoryTotalCount > 0 || otherCount > 0;
|
||||||
|
|
||||||
// create entry for not analyzed mime types category
|
// create entry for not analyzed mime types category
|
||||||
PieChartItem notAnalyzedItem = new PieChartItem(Bundle.TypesPanel_fileMimeTypesChart_notAnalyzed_title(),
|
PieChartItem notAnalyzedItem = new PieChartItem(Bundle.TypesPanel_fileMimeTypesChart_notAnalyzed_title(),
|
||||||
noMimeTypeCount, NOT_ANALYZED_COLOR);
|
noMimeTypeCount, NOT_ANALYZED_COLOR);
|
||||||
|
|
||||||
|
// combine categories with 'other' and 'not analyzed'
|
||||||
List<PieChartItem> items = Stream.concat(
|
List<PieChartItem> items = Stream.concat(
|
||||||
fileCategoryItems.stream(),
|
fileCategoryItems.stream(),
|
||||||
Stream.of(otherPieItem, notAnalyzedItem))
|
Stream.of(otherPieItem, notAnalyzedItem))
|
||||||
|
// remove items that have no value
|
||||||
.filter(slice -> slice.getValue() > 0)
|
.filter(slice -> slice.getValue() > 0)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public class BaseMessageOverlay {
|
|||||||
g.translate(leftPad, 0);
|
g.translate(leftPad, 0);
|
||||||
label.setBounds(0, 0, labelWidth, parentHeight);
|
label.setBounds(0, 0, labelWidth, parentHeight);
|
||||||
g.translate(0, 0);
|
g.translate(0, 0);
|
||||||
|
|
||||||
label.paint(g);
|
label.paint(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class PieChartPanel extends AbstractLoadableComponent<List<PieChartPanel.
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final BaseMessageOverlay overlay = new BaseMessageOverlay();
|
private final BaseMessageOverlay overlay = new BaseMessageOverlay();
|
||||||
|
|
||||||
// multiply this value by the smaller dimension (height or width) of the component
|
// multiply this value by the smaller dimension (height or width) of the component
|
||||||
// to determine width of text to be displayed.
|
// to determine width of text to be displayed.
|
||||||
private static final double MESSAGE_WIDTH_FACTOR = .6;
|
private static final double MESSAGE_WIDTH_FACTOR = .6;
|
||||||
@ -174,7 +174,7 @@ public class PieChartPanel extends AbstractLoadableComponent<List<PieChartPanel.
|
|||||||
|
|
||||||
chart.setBackgroundPaint(null);
|
chart.setBackgroundPaint(null);
|
||||||
chart.getTitle().setFont(DEFAULT_HEADER_FONT);
|
chart.getTitle().setFont(DEFAULT_HEADER_FONT);
|
||||||
|
|
||||||
this.plot = ((PiePlot) chart.getPlot());
|
this.plot = ((PiePlot) chart.getPlot());
|
||||||
plot.setInteriorGap(DEFAULT_CHART_PADDING);
|
plot.setInteriorGap(DEFAULT_CHART_PADDING);
|
||||||
plot.setLabelGenerator(DEFAULT_LABEL_GENERATOR);
|
plot.setLabelGenerator(DEFAULT_LABEL_GENERATOR);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user