Autopsy  4.19.3
Graphical digital forensics platform for The Sleuth Kit and other tools.
DhsImageCategory.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-18 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
21 import com.google.common.collect.ImmutableList;
22 import com.google.common.collect.Maps;
23 import java.util.Arrays;
24 import java.util.Map;
25 import javafx.scene.Node;
26 import javafx.scene.image.Image;
27 import javafx.scene.image.ImageView;
28 import javafx.scene.paint.Color;
29 import org.openide.util.NbBundle;
30 
35 @NbBundle.Messages({
36  "Category.one=CAT-1: Child Exploitation (Illegal)",
37  "Category.two=CAT-2: Child Exploitation (Non-Illegal/Age Difficult)",
38  "Category.three=CAT-3: CGI/Animation (Child Exploitive)",
39  "Category.four=CAT-4: Exemplar/Comparison (Internal Use Only)",
40  "Category.five=CAT-5: Non-pertinent",
41  "Category.zero=CAT-0: Uncategorized"})
42 public enum DhsImageCategory {
43 
44  /*
45  * This order of declaration is required so that Enum's compareTo method
46  * preserves the fact that lower category numbers are first/most sever,
47  * except 0 which is last
48  */
49  ONE(Color.RED, 1, Bundle.Category_one(), "cat1.png"),
50  TWO(Color.ORANGE, 2, Bundle.Category_two(), "cat2.png"),
51  THREE(Color.YELLOW, 3, Bundle.Category_three(), "cat3.png"),
52  FOUR(Color.BISQUE, 4, Bundle.Category_four(), "cat4.png"),
53  FIVE(Color.GREEN, 5, Bundle.Category_five(), "cat5.png"),
54  ZERO(Color.LIGHTGREY, 0, Bundle.Category_zero(), "cat0.png");
55 
57  private static final Map<String, DhsImageCategory> nameMap
58  = Maps.uniqueIndex(Arrays.asList(values()), DhsImageCategory::getDisplayName);
59 
60  private final Color color;
61  private final String displayName;
62  private final int id;
63  private final Image icon;
64 
65  private DhsImageCategory(Color color, int id, String name, String filename) {
66  this.color = color;
67  this.displayName = name;
68  this.id = id;
69  this.icon = new Image(getClass().getResourceAsStream("/org/sleuthkit/autopsy/images/" + filename));
70  }
71 
72  public static ImmutableList<DhsImageCategory> getNonZeroCategories() {
73  return ImmutableList.of(FIVE, FOUR, THREE, TWO, ONE);
74  }
75 
76  public static DhsImageCategory fromDisplayName(String displayName) {
77  return nameMap.get(displayName);
78  }
79 
80  public static boolean isCategoryName(String tName) {
81  return nameMap.containsKey(tName);
82  }
83 
84  public static boolean isNotCategoryName(String tName) {
85  return nameMap.containsKey(tName) == false;
86  }
87 
88  public int getCategoryNumber() {
89  return id;
90  }
91 
92  public Color getColor() {
93  return color;
94  }
95 
96  public String getDisplayName() {
97  return displayName;
98  }
99 
100  @Override
101  public String toString() {
102  return displayName;
103  }
104 
105  public Node getGraphic() {
106  return new ImageView(icon);
107  }
108 }
DhsImageCategory(Color color, int id, String name, String filename)
static ImmutableList< DhsImageCategory > getNonZeroCategories()
static DhsImageCategory fromDisplayName(String displayName)

Copyright © 2012-2022 Basis Technology. Generated on: Tue Jun 27 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.