Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ThumbnailViewNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 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.corecomponents;
20 
21 import java.awt.Image;
22 import java.lang.ref.SoftReference;
23 import org.openide.nodes.FilterNode;
24 import org.openide.nodes.Node;
27 
32 class ThumbnailViewNode extends FilterNode {
33 
34  private SoftReference<Image> iconCache = null;
35  private int iconSize = ImageUtils.ICON_SIZE_MEDIUM;
36  //private final BufferedImage defaultIconBI;
37 
41  ThumbnailViewNode(Node arg, int iconSize) {
42  super(arg, Children.LEAF);
43  this.iconSize = iconSize;
44  }
45 
46  @Override
47  public String getDisplayName() {
48  if (super.getDisplayName().length() > 15) {
49  return super.getDisplayName().substring(0, 15).concat("...");
50  } else {
51  return super.getDisplayName();
52  }
53  }
54 
55  @Override
56  public Image getIcon(int type) {
57  Image icon = null;
58 
59  if (iconCache != null) {
60  icon = iconCache.get();
61  }
62 
63  if (icon == null) {
64  Content content = this.getLookup().lookup(Content.class);
65 
66  if (content != null) {
67  icon = ImageUtils.getIcon(content, iconSize);
68  } else {
69  icon = ImageUtils.getDefaultIcon();
70  }
71 
72  iconCache = new SoftReference<>(icon);
73  }
74 
75  return icon;
76  }
77 
78  public void setIconSize(int iconSize) {
79  this.iconSize = iconSize;
80  iconCache = null;
81  }
82 
83 }

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.