Autopsy  4.16.0
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 
34 @NbBundle.Messages({
35  "Category.one=CAT-1: Child Exploitation (Illegal)",
36  "Category.two=CAT-2: Child Exploitation (Non-Illegal/Age Difficult)",
37  "Category.three=CAT-3: CGI/Animation (Child Exploitive)",
38  "Category.four=CAT-4: Exemplar/Comparison (Internal Use Only)",
39  "Category.five=CAT-5: Non-pertinent",
40  "Category.zero=CAT-0: Uncategorized"})
41 public enum DhsImageCategory {
42 
43  /*
44  * This order of declaration is required so that Enum's compareTo method
45  * preserves the fact that lower category numbers are first/most sever,
46  * except 0 which is last
47  */
48  ONE(Color.RED, 1, Bundle.Category_one(), "cat1.png"),
49  TWO(Color.ORANGE, 2, Bundle.Category_two(), "cat2.png"),
50  THREE(Color.YELLOW, 3, Bundle.Category_three(), "cat3.png"),
51  FOUR(Color.BISQUE, 4, Bundle.Category_four(), "cat4.png"),
52  FIVE(Color.GREEN, 5, Bundle.Category_five(), "cat5.png"),
53  ZERO(Color.LIGHTGREY, 0, Bundle.Category_zero(), "cat0.png");
54 
56  private static final Map<String, DhsImageCategory> nameMap
57  = Maps.uniqueIndex(Arrays.asList(values()), DhsImageCategory::getDisplayName);
58 
59  private final Color color;
60  private final String displayName;
61  private final int id;
62  private final Image icon;
63 
64  private DhsImageCategory(Color color, int id, String name, String filename) {
65  this.color = color;
66  this.displayName = name;
67  this.id = id;
68  this.icon = new Image(getClass().getResourceAsStream("/org/sleuthkit/autopsy/images/" + filename));
69  }
70 
71  public static ImmutableList<DhsImageCategory> getNonZeroCategories() {
72  return ImmutableList.of(FIVE, FOUR, THREE, TWO, ONE);
73  }
74 
75  public static DhsImageCategory fromDisplayName(String displayName) {
76  return nameMap.get(displayName);
77  }
78 
79  public static boolean isCategoryName(String tName) {
80  return nameMap.containsKey(tName);
81  }
82 
83  public static boolean isNotCategoryName(String tName) {
84  return nameMap.containsKey(tName) == false;
85  }
86 
87  public int getCategoryNumber() {
88  return id;
89  }
90 
91  public Color getColor() {
92  return color;
93  }
94 
95  public String getDisplayName() {
96  return displayName;
97  }
98 
99  @Override
100  public String toString() {
101  return displayName;
102  }
103 
104  public Node getGraphic() {
105  return new ImageView(icon);
106  }
107 }
DhsImageCategory(Color color, int id, String name, String filename)
static ImmutableList< DhsImageCategory > getNonZeroCategories()
static DhsImageCategory fromDisplayName(String displayName)

Copyright © 2012-2020 Basis Technology. Generated on: Tue Sep 22 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.