Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
BarChartSeries.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2021 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 */
19package org.sleuthkit.autopsy.datasourcesummary.uiutils;
20
21import java.awt.Color;
22import java.util.Collections;
23import java.util.List;
24
28public class BarChartSeries {
29
33 public static class BarChartItem {
34
35 private final Comparable<?> key;
36 private final double value;
37
44 public BarChartItem(Comparable<?> key, double value) {
45 this.key = key;
46 this.value = value;
47 }
48
52 public Comparable<?> getKey() {
53 return key;
54 }
55
59 public double getValue() {
60 return value;
61 }
62 }
63 private final Comparable<?> key;
64 private final Color color;
65 private final List<BarChartItem> items;
66
74 public BarChartSeries(Comparable<?> key, Color color, List<BarChartItem> items) {
75 this.key = key;
76 this.color = color;
77 this.items = (items == null) ? Collections.emptyList() : Collections.unmodifiableList(items);
78 }
79
83 public Color getColor() {
84 return color;
85 }
86
90 public List<BarChartItem> getItems() {
91 return items;
92 }
93
97 public Comparable<?> getKey() {
98 return key;
99 }
100
106 public static class OrderedKey implements Comparable<OrderedKey> {
107
108 private final Object keyValue;
109 private final int keyIndex;
110
118 public OrderedKey(Object keyValue, int keyIndex) {
119 this.keyValue = keyValue;
120 this.keyIndex = keyIndex;
121 }
122
126 Object getKeyValue() {
127 return keyValue;
128 }
129
133 int getKeyIndex() {
134 return keyIndex;
135 }
136
137 @Override
138 public int compareTo(OrderedKey o) {
139 // this will have a higher value than null.
140 if (o == null) {
141 return 1;
142 }
143
144 // compare by index
145 return Integer.compare(this.getKeyIndex(), o.getKeyIndex());
146 }
147
148 @Override
149 public int hashCode() {
150 int hash = 3;
151 return hash;
152 }
153
154 @Override
155 public boolean equals(Object obj) {
156 if (this == obj) {
157 return true;
158 }
159 if (obj == null) {
160 return false;
161 }
162 if (getClass() != obj.getClass()) {
163 return false;
164 }
165 final OrderedKey other = (OrderedKey) obj;
166 if (this.keyIndex != other.keyIndex) {
167 return false;
168 }
169 return true;
170 }
171
172 @Override
173 public String toString() {
174 // use toString on the key.
175 return this.getKeyValue() == null ? null : this.getKeyValue().toString();
176 }
177 }
178
179}
BarChartSeries(Comparable<?> key, Color color, List< BarChartItem > items)

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.