Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
EventType.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2014 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.timeline.datamodel.eventtype;
20 
21 import java.util.ArrayList;
22 import java.util.Comparator;
23 import java.util.List;
24 import javafx.scene.image.Image;
25 import javafx.scene.paint.Color;
27 
33 public interface EventType {
34 
35  final static List<? extends EventType> allTypes = RootEventType.getInstance().getSubTypesRecusive();
36 
37  static Comparator<EventType> getComparator() {
38  return Comparator.comparing(EventType.allTypes::indexOf);
39 
40  }
41 
42  default BaseTypes getBaseType() {
43  if (this instanceof BaseTypes) {
44  return (BaseTypes) this;
45  } else {
46  return getSuperType().getBaseType();
47  }
48  }
49 
50  default List<? extends EventType> getSubTypesRecusive() {
51  ArrayList<EventType> flatList = new ArrayList<>();
52 
53  for (EventType et : getSubTypes()) {
54  flatList.add(et);
55  flatList.addAll(et.getSubTypesRecusive());
56  }
57  return flatList;
58  }
59 
63  default Color getColor() {
64 
65  Color baseColor = this.getSuperType().getColor();
66  int siblings = getSuperType().getSiblingTypes().stream().max((
67  EventType t, EventType t1)
68  -> Integer.compare(t.getSubTypes().size(), t1.getSubTypes().size()))
69  .get().getSubTypes().size() + 1;
70  int superSiblings = this.getSuperType().getSiblingTypes().size();
71 
72  double offset = (360.0 / superSiblings) / siblings;
73  final Color deriveColor = baseColor.deriveColor(ordinal() * offset, 1, 1, 1);
74 
75  return Color.hsb(deriveColor.getHue(), deriveColor.getSaturation(), deriveColor.getBrightness());
76 
77  }
78 
79  default List<? extends EventType> getSiblingTypes() {
80  return this.getSuperType().getSubTypes();
81  }
82 
86  public EventType getSuperType();
87 
89 
94  public List<? extends EventType> getSubTypes();
95 
96  /*
97  * return the name of the icon file for this type, it will be resolved in
98  * the org/sleuthkit/autopsy/timeline/images
99  */
100  public String getIconBase();
101 
102  public String getDisplayName();
103 
104  public EventType getSubType(String string);
105 
106  public Image getFXImage();
107 
108  public int ordinal();
109 
110 }
default List<?extends EventType > getSubTypesRecusive()
Definition: EventType.java:50
static final List<?extends EventType > allTypes
Definition: EventType.java:35
default List<?extends EventType > getSiblingTypes()
Definition: EventType.java:79

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.