From 40e26c27f8f1d4d06a8abd1d78fd2c922183ecc4 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Mon, 25 Apr 2022 17:53:06 +0200 Subject: [PATCH] Replace usage of IconImage with Icon This allows us to use icons other than ImageIcons. --- .../ResourceListIconRenderer.java | 7 ++- .../resources/IconResources.java | 44 +++++++++---------- .../resources/ResourceType.java | 8 ++-- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java index bc5a1dac..49b9feae 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListIconRenderer.java @@ -5,8 +5,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.swing.ImageIcon; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeNode; import org.apache.commons.io.FilenameUtils; @@ -21,7 +20,7 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceType; public class ResourceListIconRenderer extends DefaultTreeCellRenderer { //TODO the icon cache needs to be cleared on treenode removal - public static Map iconCache = new HashMap<>(); + public static Map iconCache = new HashMap<>(); //called every time there is a pane update @Override @@ -134,7 +133,7 @@ public class ResourceListIconRenderer extends DefaultTreeCellRenderer return ret; } - public void cacheNodeIcon(ResourceTreeNode node, ImageIcon icon) + public void cacheNodeIcon(ResourceTreeNode node, Icon icon) { iconCache.put(node, icon); setIcon(icon); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java index ef571150..9ee03bff 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/IconResources.java @@ -49,28 +49,28 @@ public class IconResources static protected final int HALF_SIZE = 4; static protected final int SIZE = 9; - public static List iconList; - public static BufferedImage icon; - public static ImageIcon nextIcon; - public static ImageIcon prevIcon; - public static ImageIcon busyIcon; - public static ImageIcon busyB64Icon; - public static ImageIcon batIcon; - public static ImageIcon shIcon; - public static ImageIcon csharpIcon; - public static ImageIcon cplusplusIcon; - public static ImageIcon configIcon; - public static ImageIcon jarIcon; - public static ImageIcon zipIcon; - public static ImageIcon packagesIcon; - public static ImageIcon folderIcon; - public static ImageIcon androidIcon; - public static ImageIcon unknownFileIcon; - public static ImageIcon textIcon; - public static ImageIcon classIcon; - public static ImageIcon imageIcon; - public static ImageIcon decodedIcon; - public static ImageIcon javaIcon; + public static final List iconList; + public static final BufferedImage icon; + public static final Icon nextIcon; + public static final Icon prevIcon; + public static final Icon busyIcon; + public static final Icon busyB64Icon; + public static final Icon batIcon; + public static final Icon shIcon; + public static final Icon csharpIcon; + public static final Icon cplusplusIcon; + public static final Icon configIcon; + public static final Icon jarIcon; + public static final Icon zipIcon; + public static final Icon packagesIcon; + public static final Icon folderIcon; + public static final Icon androidIcon; + public static final Icon unknownFileIcon; + public static final Icon textIcon; + public static final Icon classIcon; + public static final Icon imageIcon; + public static final Icon decodedIcon; + public static final Icon javaIcon; static { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java index 6613bc2d..dd02c3b4 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java @@ -2,7 +2,7 @@ package the.bytecode.club.bytecodeviewer.resources; import java.util.HashMap; import java.util.Map; -import javax.swing.ImageIcon; +import javax.swing.*; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -53,7 +53,7 @@ public enum ResourceType public static final Map imageExtensionMap = new HashMap<>(); public static final Map supportedBCVExtensionMap = new HashMap<>(); - private final ImageIcon icon; + private final Icon icon; private final String[] extensions; //private final byte[][] headerMagicNumber; @@ -79,13 +79,13 @@ public enum ResourceType supportedBCVExtensionMap.put(extension, ANDROID_ARCHIVE); } - ResourceType(ImageIcon icon, String... extensions) + ResourceType(Icon icon, String... extensions) { this.icon = icon; this.extensions = extensions; } - public ImageIcon getIcon() + public Icon getIcon() { return icon; }