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<>();
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;
63 protected void addNotify() {
73 int getTotalImages() {
77 private void setupKeys() {
83 final List<Node> suppContent =
new ArrayList<>();
84 for (Node child : parent.getChildren().getNodes()) {
85 if (isSupported(child)) {
89 suppContent.add(child);
93 if (totalImages == 0) {
98 if (totalImages < IMAGES_PER_PAGE) {
101 totalPages = totalImages / IMAGES_PER_PAGE;
102 if (totalPages % totalImages != 0) {
108 for (
int page = 1; page <= totalPages; ++page) {
109 int toAdd = Math.min(IMAGES_PER_PAGE, totalImages - prevImages);
110 List<Node> pageContent = suppContent.subList(prevImages, prevImages + toAdd);
111 pages.put(page, pageContent);
115 Integer[] pageNums =
new Integer[totalPages];
116 for (
int i = 0; i < totalPages; ++i) {
123 protected void removeNotify() {
124 super.removeNotify();
130 protected Node[] createNodes(Integer pageNum) {
131 final ThumbnailPageNode pageNode =
new ThumbnailPageNode(pageNum);
132 return new Node[]{pageNode};
135 static boolean isSupported(Node node) {
137 Content content = node.getLookup().lookup(Content.class);
138 if (content != null) {
139 return ImageUtils.thumbnailSupported(content);
145 public void setIconSize(
int iconSize) {
146 this.iconSize = iconSize;
157 setName(Integer.toString(pageNum));
158 int from = 1 + ((pageNum - 1) * IMAGES_PER_PAGE);
159 int showImages = Math.min(IMAGES_PER_PAGE, totalImages - (from - 1));
160 int to = from + showImages - 1;
161 setDisplayName(from +
"-" + to);
163 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/Folder-icon.png");
184 setKeys(contentImages);
189 super.removeNotify();
191 setKeys(
new ArrayList<Node>());
196 if (wrapped != null) {
197 final ThumbnailViewNode thumb =
new ThumbnailViewNode(wrapped, iconSize);
198 return new Node[]{thumb};
Node[] createNodes(Node wrapped)
List< Node > contentImages