19 package org.sleuthkit.autopsy.corecomponents;
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import org.openide.nodes.AbstractNode;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Node;
27 import org.openide.util.lookup.Lookups;
42 class ThumbnailViewChildren
extends Children.Keys<Integer> {
44 static final int IMAGES_PER_PAGE = 200;
46 private final HashMap<Integer, List<Node>> pages =
new HashMap<Integer, List<Node>>();
47 private int totalImages = 0;
48 private int totalPages = 0;
49 private int iconSize = ImageUtils.ICON_SIZE_MEDIUM;
50 private static final Logger logger = Logger.getLogger(ThumbnailViewChildren.class.getName());
55 ThumbnailViewChildren(Node arg,
int iconSize) {
59 this.iconSize = iconSize;
68 protected void addNotify() {
78 int getTotalImages() {
82 private void setupKeys() {
88 final List<Node> suppContent =
new ArrayList<Node>();
89 for (Node child : parent.getChildren().getNodes()) {
90 if (isSupported(child)) {
94 suppContent.add(child);
98 if (totalImages == 0) {
103 if (totalImages < IMAGES_PER_PAGE) {
106 totalPages = totalImages / IMAGES_PER_PAGE;
107 if (totalPages % totalImages != 0) {
113 for (
int page = 1; page <= totalPages; ++page) {
114 int toAdd = Math.min(IMAGES_PER_PAGE, totalImages - prevImages);
115 List<Node> pageContent = suppContent.subList(prevImages, prevImages + toAdd);
116 pages.put(page, pageContent);
120 Integer[] pageNums =
new Integer[totalPages];
121 for (
int i = 0; i < totalPages; ++i) {
130 protected void removeNotify() {
131 super.removeNotify();
137 protected Node[] createNodes(Integer pageNum) {
138 final ThumbnailPageNode pageNode =
new ThumbnailPageNode(pageNum);
139 return new Node[]{pageNode};
142 public static boolean isSupported(Node node) {
144 Content content = node.getLookup().lookup(Content.class);
145 if (content != null) {
146 return ImageUtils.thumbnailSupported(content);
152 public void setIconSize(
int iconSize) {
153 this.iconSize = iconSize;
164 setName(Integer.toString(pageNum));
165 int from = 1 + ((pageNum - 1) * IMAGES_PER_PAGE);
166 int showImages = Math.min(IMAGES_PER_PAGE, totalImages - (from - 1));
167 int to = from + showImages - 1;
168 setDisplayName(from +
"-" + to);
170 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/Folder-icon.png");
191 setKeys(contentImages);
196 super.removeNotify();
198 setKeys(
new ArrayList<Node>());
203 if (wrapped != null) {
204 final ThumbnailViewNode thumb =
new ThumbnailViewNode(wrapped, iconSize);
205 return new Node[]{thumb};
Node[] createNodes(Node wrapped)
List< Node > contentImages