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

Copyright © 2012-2016 Basis Technology. Generated on: Mon Jun 18 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.