7
7
package org .freeinternals .commonlib .ui ;
8
8
9
9
import java .awt .BorderLayout ;
10
+ import java .util .HashMap ;
11
+ import java .util .Map ;
10
12
import javax .swing .Icon ;
11
13
import javax .swing .ImageIcon ;
12
14
import javax .swing .JDialog ;
13
15
import javax .swing .JFrame ;
14
16
import javax .swing .JPanel ;
15
- import javax .swing .UIManager ;
16
17
import javax .swing .tree .DefaultMutableTreeNode ;
17
18
import org .freeinternals .commonlib .core .BytesTool ;
18
19
@@ -58,14 +59,49 @@ public static void generateTreeNodeDiff(
58
59
diffStr )));
59
60
}
60
61
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
+
61
97
/**
62
98
* Icon for counter.
63
99
*
64
100
* @return Icon for counter
65
101
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a> icon by <a href="https://icons8.com">Icons8</a>
66
102
*/
67
103
public static Icon icon4Counter () {
68
- return new ImageIcon ( UITool . class . getResource ( "/image/icons8-abacus-16.png" ) );
104
+ return icon ( "/image/icons8-abacus-16.png" );
69
105
}
70
106
71
107
/**
@@ -75,7 +111,27 @@ public static Icon icon4Counter() {
75
111
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by <a href="https://icons8.com">Icons8</a>
76
112
*/
77
113
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" );
79
135
}
80
136
81
137
/**
@@ -84,7 +140,17 @@ public static Icon icon4Dex() {
84
140
* @return Icon for Java
85
141
*/
86
142
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" );
88
154
}
89
155
90
156
/**
@@ -94,7 +160,7 @@ public static Icon icon4Java() {
94
160
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic Wand</a> icon by <a href="https://icons8.com">Icons8</a>
95
161
*/
96
162
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" );
98
164
}
99
165
100
166
/**
@@ -106,7 +172,38 @@ public static Icon icon4Magic() {
106
172
* by <a href="https://icons8.com">Icons8</a>
107
173
*/
108
174
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" );
110
207
}
111
208
112
209
/**
@@ -117,7 +214,7 @@ public static Icon icon4Shortcut() {
117
214
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
118
215
*/
119
216
public static Icon icon4Versions () {
120
- return new ImageIcon ( UITool . class . getResource ( "/image/icons8-versions-16.png" ) );
217
+ return icon ( "/image/icons8-versions-16.png" );
121
218
}
122
219
123
220
/**
0 commit comments