Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Utils.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017 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.communications;
20 
21 import java.awt.Component;
22 import java.time.ZoneId;
23 import java.time.ZoneOffset;
24 import java.util.TimeZone;
25 import javax.swing.table.TableCellRenderer;
26 import org.netbeans.swing.outline.Outline;
29 import org.sleuthkit.datamodel.Account;
30 
34 public final class Utils {
35 
36  private Utils() {
37  }
38 
39  static public ZoneId getUserPreferredZoneId() {
41  ZoneOffset.systemDefault() : TimeZone.getTimeZone(UserPreferences.getTimeZoneForDisplays()).toZoneId();
42  return zone;
43  }
44 
50  static public final String getIconFilePath(Account.Type type) {
51  return Accounts.getIconFilePath(type);
52  }
53 
54  static public void setColumnWidths(Outline outline) {
55  int margin = 4;
56  int padding = 8;
57 
58  final int rows = Math.min(100, outline.getRowCount());
59 
60  for (int column = 0; column < outline.getColumnCount(); column++) {
61  int columnWidthLimit = 500;
62  int columnWidth = 0;
63 
64  // find the maximum width needed to fit the values for the first 100 rows, at most
65  for (int row = 0; row < rows; row++) {
66  TableCellRenderer renderer = outline.getCellRenderer(row, column);
67  Component comp = outline.prepareRenderer(renderer, row, column);
68  columnWidth = Math.max(comp.getPreferredSize().width, columnWidth);
69  }
70 
71  columnWidth += 2 * margin + padding; // add margin and regular padding
72  columnWidth = Math.min(columnWidth, columnWidthLimit);
73 
74  outline.getColumnModel().getColumn(column).setPreferredWidth(columnWidth);
75  }
76  }
77 
78 }
static void setColumnWidths(Outline outline)
Definition: Utils.java:54
static String getIconFilePath(Account.Type type)
Definition: Accounts.java:2001
static final String getIconFilePath(Account.Type type)
Definition: Utils.java:50

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.