Autopsy  4.8.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-16 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 java.util.Map;
23 import java.util.function.Function;
24 import java.util.stream.Collectors;
25 import java.util.stream.Stream;
26 import javafx.geometry.Insets;
27 import javafx.scene.Node;
28 import javafx.scene.Scene;
29 import javafx.scene.image.Image;
30 import javafx.scene.image.ImageView;
31 import javafx.scene.layout.Background;
32 import javafx.scene.layout.BackgroundFill;
33 import javafx.scene.layout.Border;
34 import javafx.scene.layout.BorderStroke;
35 import javafx.scene.layout.BorderStrokeStyle;
36 import javafx.scene.layout.BorderWidths;
37 import javafx.scene.layout.CornerRadii;
38 import javafx.scene.layout.Region;
39 import javafx.scene.paint.Color;
40 import org.openide.util.NbBundle;
41 
45 @NbBundle.Messages({"Category.one=CAT-1: Child Exploitation (Illegal)",
46  "Category.two=CAT-2: Child Exploitation (Non-Illegal/Age Difficult)",
47  "Category.three=CAT-3: CGI/Animation (Child Exploitive)",
48  "Category.four=CAT-4: Exemplar/Comparison (Internal Use Only)",
49  "Category.five=CAT-5: Non-pertinent",
50  "Category.zero=CAT-0: Uncategorized"})
51 public enum DhsImageCategory {
52 
53  /*
54  * This order of declaration is required so that Enum's compareTo method
55  * preserves the fact that lower category numbers are first/most sever,
56  * except 0 which is last
57  */
58  ONE(Color.RED, 1, Bundle.Category_one()),
59  TWO(Color.ORANGE, 2, Bundle.Category_two()),
60  THREE(Color.YELLOW, 3, Bundle.Category_three()),
61  FOUR(Color.BISQUE, 4, Bundle.Category_four()),
62  FIVE(Color.GREEN, 5, Bundle.Category_five()),
63  ZERO(Color.LIGHTGREY, 0, Bundle.Category_zero());
64 
65  private static final BorderWidths BORDER_WIDTHS_2 = new BorderWidths(2);
66  private static final CornerRadii CORNER_RADII_4 = new CornerRadii(4);
67 
68  public static ImmutableList<DhsImageCategory> getNonZeroCategories() {
69  return nonZeroCategories;
70  }
71 
72  private static final ImmutableList<DhsImageCategory> nonZeroCategories =
74 
78  private static final Map<String, DhsImageCategory> nameMap =
79  Stream.of(values()).collect(Collectors.toMap(DhsImageCategory::getDisplayName,
80  Function.identity()));
81 
82  public static DhsImageCategory fromDisplayName(String displayName) {
83  return nameMap.get(displayName);
84  }
85 
86  public static boolean isCategoryName(String tName) {
87  return nameMap.containsKey(tName);
88  }
89 
90  public static boolean isNotCategoryName(String tName) {
91  return nameMap.containsKey(tName) == false;
92  }
93 
94  private final Color color;
95 
96  private final String displayName;
97 
98  private final int id;
99  private Image snapshot;
100 
101  private DhsImageCategory(Color color, int id, String name) {
102  this.color = color;
103  this.displayName = name;
104  this.id = id;
105  }
106 
107  public int getCategoryNumber() {
108  return id;
109  }
110 
111  public Color getColor() {
112  return color;
113  }
114 
115  public String getDisplayName() {
116  return displayName;
117  }
118 
119  @Override
120  public String toString() {
121  return displayName;
122  }
123 
124  synchronized public Node getGraphic() {
125  if (snapshot == null) {
126  Region region = new Region();
127  region.setBackground(new Background(new BackgroundFill(getColor(), CORNER_RADII_4, Insets.EMPTY)));
128  region.setPrefSize(16, 16);
129  region.setBorder(new Border(new BorderStroke(getColor().darker(), BorderStrokeStyle.SOLID, CORNER_RADII_4, BORDER_WIDTHS_2)));
130  Scene scene = new Scene(region, 16, 16, Color.TRANSPARENT);
131  snapshot = region.snapshot(null, null);
132  }
133  return new ImageView(snapshot);
134  }
135 }
DhsImageCategory(Color color, int id, String name)
static ImmutableList< DhsImageCategory > getNonZeroCategories()
static DhsImageCategory fromDisplayName(String displayName)

Copyright © 2012-2018 Basis Technology. Generated on: Thu Oct 4 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.