diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/DhsImageCategory.java b/Core/src/org/sleuthkit/autopsy/datamodel/DhsImageCategory.java index a736c59881..50974519c7 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/DhsImageCategory.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/DhsImageCategory.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013-16 Basis Technology Corp. + * Copyright 2013-18 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,30 +19,20 @@ package org.sleuthkit.autopsy.datamodel; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; +import java.util.Arrays; import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javafx.geometry.Insets; import javafx.scene.Node; -import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.Background; -import javafx.scene.layout.BackgroundFill; -import javafx.scene.layout.Border; -import javafx.scene.layout.BorderStroke; -import javafx.scene.layout.BorderStrokeStyle; -import javafx.scene.layout.BorderWidths; -import javafx.scene.layout.CornerRadii; -import javafx.scene.layout.Region; import javafx.scene.paint.Color; import org.openide.util.NbBundle; /** * Enum to represent the six categories in the DHS image categorization scheme. */ -@NbBundle.Messages({"Category.one=CAT-1: Child Exploitation (Illegal)", +@NbBundle.Messages({ + "Category.one=CAT-1: Child Exploitation (Illegal)", "Category.two=CAT-2: Child Exploitation (Non-Illegal/Age Difficult)", "Category.three=CAT-3: CGI/Animation (Child Exploitive)", "Category.four=CAT-4: Exemplar/Comparison (Internal Use Only)", @@ -55,29 +45,32 @@ public enum DhsImageCategory { * preserves the fact that lower category numbers are first/most sever, * except 0 which is last */ - ONE(Color.RED, 1, Bundle.Category_one()), - TWO(Color.ORANGE, 2, Bundle.Category_two()), - THREE(Color.YELLOW, 3, Bundle.Category_three()), - FOUR(Color.BISQUE, 4, Bundle.Category_four()), - FIVE(Color.GREEN, 5, Bundle.Category_five()), - ZERO(Color.LIGHTGREY, 0, Bundle.Category_zero()); + ONE(Color.RED, 1, Bundle.Category_one(), "cat1.png"), + TWO(Color.ORANGE, 2, Bundle.Category_two(), "cat2.png"), + THREE(Color.YELLOW, 3, Bundle.Category_three(), "cat3.png"), + FOUR(Color.BISQUE, 4, Bundle.Category_four(), "cat4.png"), + FIVE(Color.GREEN, 5, Bundle.Category_five(), "cat5.png"), + ZERO(Color.LIGHTGREY, 0, Bundle.Category_zero(), "cat0.png"); - private static final BorderWidths BORDER_WIDTHS_2 = new BorderWidths(2); - private static final CornerRadii CORNER_RADII_4 = new CornerRadii(4); + /** Map from displayName to enum value */ + private static final Map nameMap + = Maps.uniqueIndex(Arrays.asList(values()), DhsImageCategory::getDisplayName); - public static ImmutableList getNonZeroCategories() { - return nonZeroCategories; + private final Color color; + private final String displayName; + private final int id; + private final Image icon; + + private DhsImageCategory(Color color, int id, String name, String filename) { + this.color = color; + this.displayName = name; + this.id = id; + this.icon = new Image(getClass().getResourceAsStream("/org/sleuthkit/autopsy/images/" + filename)); } - private static final ImmutableList nonZeroCategories = - ImmutableList.of(DhsImageCategory.FIVE, DhsImageCategory.FOUR, DhsImageCategory.THREE, DhsImageCategory.TWO, DhsImageCategory.ONE); - - /** - * map from displayName to enum value - */ - private static final Map nameMap = - Stream.of(values()).collect(Collectors.toMap(DhsImageCategory::getDisplayName, - Function.identity())); + public static ImmutableList getNonZeroCategories() { + return ImmutableList.of(FIVE, FOUR, THREE, TWO, ONE); + } public static DhsImageCategory fromDisplayName(String displayName) { return nameMap.get(displayName); @@ -91,19 +84,6 @@ public enum DhsImageCategory { return nameMap.containsKey(tName) == false; } - private final Color color; - - private final String displayName; - - private final int id; - private Image snapshot; - - private DhsImageCategory(Color color, int id, String name) { - this.color = color; - this.displayName = name; - this.id = id; - } - public int getCategoryNumber() { return id; } @@ -121,15 +101,7 @@ public enum DhsImageCategory { return displayName; } - synchronized public Node getGraphic() { - if (snapshot == null) { - Region region = new Region(); - region.setBackground(new Background(new BackgroundFill(getColor(), CORNER_RADII_4, Insets.EMPTY))); - region.setPrefSize(16, 16); - region.setBorder(new Border(new BorderStroke(getColor().darker(), BorderStrokeStyle.SOLID, CORNER_RADII_4, BORDER_WIDTHS_2))); - Scene scene = new Scene(region, 16, 16, Color.TRANSPARENT); - snapshot = region.snapshot(null, null); - } - return new ImageView(snapshot); + public Node getGraphic() { + return new ImageView(icon); } } diff --git a/Core/src/org/sleuthkit/autopsy/images/cat0.png b/Core/src/org/sleuthkit/autopsy/images/cat0.png new file mode 100644 index 0000000000..142cc111b7 Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/images/cat0.png differ diff --git a/Core/src/org/sleuthkit/autopsy/images/cat1.png b/Core/src/org/sleuthkit/autopsy/images/cat1.png new file mode 100644 index 0000000000..2ad7fdd04a Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/images/cat1.png differ diff --git a/Core/src/org/sleuthkit/autopsy/images/cat2.png b/Core/src/org/sleuthkit/autopsy/images/cat2.png new file mode 100644 index 0000000000..a85c0142c4 Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/images/cat2.png differ diff --git a/Core/src/org/sleuthkit/autopsy/images/cat3.png b/Core/src/org/sleuthkit/autopsy/images/cat3.png new file mode 100644 index 0000000000..53ab5432ff Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/images/cat3.png differ diff --git a/Core/src/org/sleuthkit/autopsy/images/cat4.png b/Core/src/org/sleuthkit/autopsy/images/cat4.png new file mode 100644 index 0000000000..f96aade080 Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/images/cat4.png differ diff --git a/Core/src/org/sleuthkit/autopsy/images/cat5.png b/Core/src/org/sleuthkit/autopsy/images/cat5.png new file mode 100644 index 0000000000..7cb2868d66 Binary files /dev/null and b/Core/src/org/sleuthkit/autopsy/images/cat5.png differ diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/GuiUtils.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/GuiUtils.java index 91b55e5bf1..8288ee4abf 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/GuiUtils.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/GuiUtils.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2015 Basis Technology Corp. + * Copyright 2015-2018 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,6 +27,7 @@ import javafx.scene.control.MenuItem; import javafx.scene.image.Image; import javafx.stage.Stage; import org.controlsfx.control.action.Action; +import org.controlsfx.control.action.ActionUtils; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.ThreadConfined; @@ -64,12 +65,11 @@ public final class GuiUtils { * @return */ public static MenuItem createAutoAssigningMenuItem(ButtonBase button, Action action) { - - MenuItem menuItem = new MenuItem(action.getText(), action.getGraphic()); + MenuItem menuItem = ActionUtils.createMenuItem(action); menuItem.setOnAction(actionEvent -> { action.handle(actionEvent); button.setText(action.getText()); - button.setGraphic(action.getGraphic()); + button.setGraphic(menuItem.getGraphic()); button.setOnAction(action); }); return menuItem;