Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ZoomParams.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.zooming;
20 
21 import java.util.Collections;
22 import java.util.EnumSet;
23 import java.util.Objects;
24 import java.util.Set;
25 import org.joda.time.Interval;
26 import org.openide.util.NbBundle;
28 
33 public class ZoomParams {
34 
35  private final Interval timeRange;
36 
38 
39  private final Filter filter;
40 
41  private final DescriptionLOD descrLOD;
42 
43  private final Set<Field> changedFields;
44 
45  public Set<Field> getChangedFields() {
46  return Collections.unmodifiableSet(changedFields);
47  }
48 
49  public enum Field {
50 
51  TIME, EVENT_TYPE_ZOOM, FILTER, DESCRIPTION_LOD;
52  }
53 
54  public Interval getTimeRange() {
55  return timeRange;
56  }
57 
59  return typeZoomLevel;
60  }
61 
62  public Filter getFilter() {
63  return filter;
64  }
65 
67  return descrLOD;
68  }
69 
70  public ZoomParams(Interval timeRange, EventTypeZoomLevel zoomLevel, Filter filter, DescriptionLOD descrLOD) {
71  this.timeRange = timeRange;
72  this.typeZoomLevel = zoomLevel;
73  this.filter = filter;
74  this.descrLOD = descrLOD;
75  changedFields = EnumSet.allOf(Field.class);
76  }
77 
78  public ZoomParams(Interval timeRange, EventTypeZoomLevel zoomLevel, Filter filter, DescriptionLOD descrLOD, EnumSet<Field> changed) {
79  this.timeRange = timeRange;
80  this.typeZoomLevel = zoomLevel;
81  this.filter = filter;
82  this.descrLOD = descrLOD;
83  changedFields = changed;
84  }
85 
86  public ZoomParams withTimeAndType(Interval timeRange, EventTypeZoomLevel zoomLevel) {
87  return new ZoomParams(timeRange, zoomLevel, filter, descrLOD, EnumSet.of(Field.TIME, Field.EVENT_TYPE_ZOOM));
88  }
89 
91  return new ZoomParams(timeRange, zoomLevel, filter, descrLOD, EnumSet.of(Field.EVENT_TYPE_ZOOM));
92  }
93 
94  public ZoomParams withTimeRange(Interval timeRange) {
95  return new ZoomParams(timeRange, typeZoomLevel, filter, descrLOD, EnumSet.of(Field.TIME));
96  }
97 
99  return new ZoomParams(timeRange, typeZoomLevel, filter, descrLOD, EnumSet.of(Field.DESCRIPTION_LOD));
100  }
101 
102  public ZoomParams withFilter(Filter filter) {
103  return new ZoomParams(timeRange, typeZoomLevel, filter, descrLOD, EnumSet.of(Field.FILTER));
104  }
105 
106  public boolean hasFilter(Filter filterSet) {
107  return this.filter.equals(filterSet);
108  }
109 
110  public boolean hasTypeZoomLevel(EventTypeZoomLevel typeZoom) {
111  return this.typeZoomLevel.equals(typeZoom);
112  }
113 
114  public boolean hasTimeRange(Interval timeRange) {
115  return this.timeRange == null ? false : this.timeRange.equals(timeRange);
116  }
117 
118  public boolean hasDescrLOD(DescriptionLOD newLOD) {
119  return this.descrLOD.equals(newLOD);
120  }
121 
122  @Override
123  public int hashCode() {
124  int hash = 3;
125  hash = 97 * hash + Objects.hashCode(this.timeRange.getStartMillis());
126  hash = 97 * hash + Objects.hashCode(this.timeRange.getEndMillis());
127  hash = 97 * hash + Objects.hashCode(this.typeZoomLevel);
128  hash = 97 * hash + Objects.hashCode(this.filter.isActive());
129  hash = 97 * hash + Objects.hashCode(this.descrLOD);
130 
131  return hash;
132  }
133 
134  @Override
135  public boolean equals(Object obj) {
136  if (obj == null) {
137  return false;
138  }
139  if (getClass() != obj.getClass()) {
140  return false;
141  }
142  final ZoomParams other = (ZoomParams) obj;
143  if (!Objects.equals(this.timeRange, other.timeRange)) {
144  return false;
145  }
146  if (this.typeZoomLevel != other.typeZoomLevel) {
147  return false;
148  }
149  if (this.filter.equals(other.filter) == false) {
150  return false;
151  }
152  if (this.descrLOD != other.descrLOD) {
153  return false;
154  }
155 
156  return true;
157  }
158 
159  @Override
160  public String toString() {
161  return NbBundle.getMessage(this.getClass(), "ZoomParams.toString", getTimeRange().toString());
162  }
163 
164 }
ZoomParams withTypeZoomLevel(EventTypeZoomLevel zoomLevel)
Definition: ZoomParams.java:90
boolean hasTypeZoomLevel(EventTypeZoomLevel typeZoom)
ZoomParams withDescrLOD(DescriptionLOD descrLOD)
Definition: ZoomParams.java:98
ZoomParams withTimeRange(Interval timeRange)
Definition: ZoomParams.java:94
ZoomParams withTimeAndType(Interval timeRange, EventTypeZoomLevel zoomLevel)
Definition: ZoomParams.java:86
boolean hasDescrLOD(DescriptionLOD newLOD)
ZoomParams(Interval timeRange, EventTypeZoomLevel zoomLevel, Filter filter, DescriptionLOD descrLOD, EnumSet< Field > changed)
Definition: ZoomParams.java:78
ZoomParams(Interval timeRange, EventTypeZoomLevel zoomLevel, Filter filter, DescriptionLOD descrLOD)
Definition: ZoomParams.java:70

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