Skip to content

Commit 3267f70

Browse files
committed
#11 DEX format - parse items
1 parent eb16e5e commit 3267f70

File tree

73 files changed

+804
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+804
-152
lines changed

BinaryInternalsViewer/src/main/java/org/freeinternals/biv/plugin/DefaultFileFormat.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import org.freeinternals.commonlib.core.FileFormat;
1010
import java.io.File;
1111
import java.io.IOException;
12+
import javax.swing.Icon;
1213
import javax.swing.tree.DefaultMutableTreeNode;
1314
import org.freeinternals.commonlib.core.FileFormatException;
15+
import org.freeinternals.commonlib.ui.UITool;
1416

1517
/**
1618
*
@@ -23,13 +25,18 @@ public DefaultFileFormat(final File file) throws IOException, FileFormatExceptio
2325
super(file);
2426
}
2527

28+
29+
@Override
30+
@SuppressWarnings("java:S1186") // Methods should not be empty --- Ignore this rule
31+
public void generateTreeNode(DefaultMutableTreeNode parentNode) {
32+
}
2633
@Override
2734
public String getContentTabName() {
2835
return "Binary Data";
2936
}
3037

3138
@Override
32-
@SuppressWarnings("java:S1186") // Methods should not be empty --- Ignore this rule
33-
public void generateTreeNode(DefaultMutableTreeNode parentNode) {
39+
public Icon getIcon() {
40+
return UITool.icon4BinaryFile();
3441
}
3542
}

CommonLib/src/main/java/org/freeinternals/commonlib/ui/UITool.java

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
package org.freeinternals.commonlib.ui;
88

99
import java.awt.BorderLayout;
10+
import java.util.HashMap;
11+
import java.util.Map;
1012
import javax.swing.Icon;
1113
import javax.swing.ImageIcon;
1214
import javax.swing.JDialog;
1315
import javax.swing.JFrame;
1416
import javax.swing.JPanel;
15-
import javax.swing.UIManager;
1617
import javax.swing.tree.DefaultMutableTreeNode;
1718
import org.freeinternals.commonlib.core.BytesTool;
1819

@@ -58,14 +59,49 @@ public static void generateTreeNodeDiff(
5859
diffStr)));
5960
}
6061

62+
private static final Map<String, Icon> iconCache = new HashMap<>();
63+
private static Icon icon(String url) {
64+
return iconCache.computeIfAbsent(url, k -> new ImageIcon(UITool.class.getResource(url)));
65+
}
66+
67+
/**
68+
* Icon for binary file.
69+
*
70+
* @return Icon for binary file
71+
* @see <a href="https://icons8.com/icon/38992/binary-file">Binary File</a> icon by <a href="https://icons8.com">Icons8</a>
72+
*/
73+
public static Icon icon4BinaryFile() {
74+
return icon("/image/icons8-binary-file-20.png");
75+
}
76+
77+
/**
78+
* Icon for bytes.
79+
*
80+
* @return Icon for bytes
81+
* @see <a href="https://icons8.com/icon/62371/scart">Scart</a> icon by <a href="https://icons8.com">Icons8</a>
82+
*/
83+
public static Icon icon4Bytes() {
84+
return icon("/image/icons8-scart-16.png");
85+
}
86+
87+
/**
88+
* Icon for checksum.
89+
*
90+
* @return Icon for checksum
91+
* @see <a href="https://icons8.com/icon/sz8cPVwzLrMP/check-mark">Check Mark</a> icon by <a href="https://icons8.com">Icons8</a>
92+
*/
93+
public static Icon icon4Checksum() {
94+
return icon("/image/icons8-check-mark-16.png");
95+
}
96+
6197
/**
6298
* Icon for counter.
6399
*
64100
* @return Icon for counter
65101
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a> icon by <a href="https://icons8.com">Icons8</a>
66102
*/
67103
public static Icon icon4Counter() {
68-
return new ImageIcon(UITool.class.getResource("/image/icons8-abacus-16.png"));
104+
return icon("/image/icons8-abacus-16.png");
69105
}
70106

71107
/**
@@ -75,7 +111,27 @@ public static Icon icon4Counter() {
75111
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by <a href="https://icons8.com">Icons8</a>
76112
*/
77113
public static Icon icon4Dex() {
78-
return new ImageIcon(UITool.class.getResource("/image/icons8-apk-20.png"));
114+
return icon("/image/icons8-apk-20.png");
115+
}
116+
117+
/**
118+
* Icon for endian.
119+
*
120+
* @return Icon for endian
121+
* @see <a href="https://icons8.com/icon/Xf1Gx1HbxVsm/up-down-arrow">Up Down Arrow</a> icon by <a href="https://icons8.com">Icons8</a>
122+
*/
123+
public static Icon icon4Endian() {
124+
return icon("/image/icons8-up-down-arrow-16.png");
125+
}
126+
127+
/**
128+
* Icon for length.
129+
*
130+
* @return Icon for length
131+
* @see <a href="https://icons8.com/icon/44699/length">Length</a> icon by <a href="https://icons8.com">Icons8</a>
132+
*/
133+
public static Icon icon4Length() {
134+
return icon("/image/icons8-length-16.png");
79135
}
80136

81137
/**
@@ -84,7 +140,17 @@ public static Icon icon4Dex() {
84140
* @return Icon for Java
85141
*/
86142
public static Icon icon4Java() {
87-
return new ImageIcon(UITool.class.getResource("/image/icons8-java-20.png"));
143+
return icon("/image/icons8-java-20.png");
144+
}
145+
146+
/**
147+
* Icon for Offset / Location / Index.
148+
*
149+
* @return Icon for Offset
150+
* @see <a href="https://icons8.com/icon/2gsR2g07AQvu/map-pin">Map Pin</a> icon by <a href="https://icons8.com">Icons8</a>
151+
*/
152+
public static Icon icon4Offset() {
153+
return icon("/image/icons8-map-pin-16.png");
88154
}
89155

90156
/**
@@ -94,7 +160,7 @@ public static Icon icon4Java() {
94160
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic Wand</a> icon by <a href="https://icons8.com">Icons8</a>
95161
*/
96162
public static Icon icon4Magic() {
97-
return new ImageIcon(UITool.class.getResource("/image/icons8-magic-wand-16.png"));
163+
return icon("/image/icons8-magic-wand-16.png");
98164
}
99165

100166
/**
@@ -106,7 +172,38 @@ public static Icon icon4Magic() {
106172
* by <a href="https://icons8.com">Icons8</a>
107173
*/
108174
public static Icon icon4Shortcut() {
109-
return new ImageIcon(UITool.class.getResource("/image/icons8-shortcut-16.png"));
175+
return icon("/image/icons8-shortcut-16.png");
176+
}
177+
178+
/**
179+
* Icon for signature.
180+
*
181+
* @return Icon for signature
182+
* @see <a href="https://icons8.com/icon/bmicUxC0XDNt/signature">Signature</a> icon by <a href="https://icons8.com">Icons8</a>
183+
*/
184+
public static Icon icon4Signature() {
185+
return icon("/image/icons8-signature-16.png");
186+
}
187+
188+
/**
189+
* Icon for Size.
190+
*
191+
* @return Shortcut icon
192+
* @see <a href="https://icons8.com/icon/d8VomliGByyY/page-size">Page Size</a> icon by <a href="https://icons8.com">Icons8</a>
193+
*/
194+
public static Icon icon4Size() {
195+
return icon("/image/icons8-page-size-16.png");
196+
}
197+
198+
199+
/**
200+
* Icon for tag.
201+
*
202+
* @return tag icon
203+
* @see <a href="https://icons8.com/icon/pmzH4rF8Lrv9/tag">Tag</a> icon by <a href="https://icons8.com">Icons8</a>
204+
*/
205+
public static Icon icon4Tag() {
206+
return icon("/image/icons8-tag-16.png");
110207
}
111208

112209
/**
@@ -117,7 +214,7 @@ public static Icon icon4Shortcut() {
117214
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
118215
*/
119216
public static Icon icon4Versions() {
120-
return new ImageIcon(UITool.class.getResource("/image/icons8-versions-16.png"));
217+
return icon("/image/icons8-versions-16.png");
121218
}
122219

123220
/**
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)