1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-09-03 14:30:01 +00:00

Merge pull request #4174 from millmanorama/1062-not_on_jfx_thread

1062 not on jfx thread
This commit is contained in:
Richard Cordovano
2018-10-04 10:08:48 -04:00
committed by GitHub
8 changed files with 33 additions and 61 deletions

View File

@@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013-16 Basis Technology Corp.
* Copyright 2013-18 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> 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<String, DhsImageCategory> nameMap
= Maps.uniqueIndex(Arrays.asList(values()), DhsImageCategory::getDisplayName);
public static ImmutableList<DhsImageCategory> 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<DhsImageCategory> nonZeroCategories =
ImmutableList.of(DhsImageCategory.FIVE, DhsImageCategory.FOUR, DhsImageCategory.THREE, DhsImageCategory.TWO, DhsImageCategory.ONE);
/**
* map from displayName to enum value
*/
private static final Map<String, DhsImageCategory> nameMap =
Stream.of(values()).collect(Collectors.toMap(DhsImageCategory::getDisplayName,
Function.identity()));
public static ImmutableList<DhsImageCategory> 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);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

View File

@@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2015 Basis Technology Corp.
* Copyright 2015-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> 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;