Skip to content

Commit eb16e5e

Browse files
committed
#11 DEX format - add icons
1 parent 3d4c8b7 commit eb16e5e

Some content is hidden

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

41 files changed

+179
-76
lines changed

BinaryInternalsViewer/src/main/java/org/freeinternals/biv/JSplitPaneFile.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ private void createAndShowGUI() {
7979
0,
8080
this.file.fileByteArray.length,
8181
this.file.fileName,
82+
this.file.getIcon(),
8283
this.file.filePath));
8384
this.file.generateTreeNode(root);
8485
final JTree tree = new JTree(new DefaultTreeModel(root));

CommonLib/src/main/java/org/freeinternals/commonlib/core/BytesTool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static byte[] readFileAsBytes(final File file) {
176176
* @param zipFile The {@code jar} or {@code zip} file
177177
* @param zipEntry The entry to be read
178178
* @return Byte array of the class file, or {@code null} if error happened.
179-
* @throws java.io.IOException Error happened when reading the zip file
179+
* @throws IOException Error happened when reading the zip file
180180
*/
181181
public static byte[] readZipEntryAsBytes(final ZipFile zipFile, final ZipEntry zipEntry) throws IOException {
182182
if (zipFile == null) {

CommonLib/src/main/java/org/freeinternals/commonlib/core/DataInputEx.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,31 @@ public interface DataInputEx {
8888
* <code>long</code> value.
8989
*
9090
* @return the <code>long</code> value read.
91-
* @throws java.io.IOException I/O Error
91+
* @throws IOException I/O Error
9292
*/
9393
long readUnsignedIntInLittleEndian() throws IOException;
9494

9595
/**
9696
* Reads eight input bytes and returns a {@code long} value.
9797
*
9898
* @return the <code>long</code> value read.
99-
* @throws java.io.IOException I/O Error
99+
* @throws IOException I/O Error
100100
*/
101101
long readLongInLittleEndian() throws IOException;
102102

103103
/**
104104
* Reads eight input bytes and returns a {@code unsigned long} value.
105105
*
106106
* @return the <code>unsigned long</code> value read
107-
* @throws java.io.IOException I/O Error
107+
* @throws IOException I/O Error
108108
*/
109109
BigInteger readUnsignedLong() throws IOException;
110110

111111
/**
112112
* Reads eight input bytes and returns a {@code unsigned long} value.
113113
*
114114
* @return the <code>unsigned long</code> value read
115-
* @throws java.io.IOException I/O Error
115+
* @throws IOException I/O Error
116116
*/
117117
BigInteger readUnsignedLongInLittleEndian() throws IOException;
118118

@@ -147,14 +147,14 @@ public interface DataInputEx {
147147
* Read until a null terminator, or the end of the buffer as binary.
148148
*
149149
* @return
150-
* @throws java.io.IOException I/O Error
150+
* @throws IOException I/O Error
151151
*/
152152
byte[] readBinary() throws IOException;
153153

154154
/**
155155
* Skip to the end of the buffer.
156156
*
157-
* @throws java.io.IOException I/O Error
157+
* @throws IOException I/O Error
158158
*/
159159
void skipToEnd() throws IOException;
160160

CommonLib/src/main/java/org/freeinternals/commonlib/core/FileFormat.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.Collections;
1414
import java.util.SortedMap;
1515
import java.util.TreeMap;
16+
import javax.swing.Icon;
1617
import javax.swing.JScrollPane;
1718
import javax.swing.JTabbedPane;
1819
import javax.swing.JTextPane;
@@ -47,8 +48,8 @@ public abstract class FileFormat {
4748
* Parse the content from a {@link File} object.
4849
*
4950
* @param file {@link File} object
50-
* @throws java.io.IOException Failed to Read file
51-
* @throws org.freeinternals.commonlib.core.FileFormatException The file is empty
51+
* @throws IOException Failed to Read file
52+
* @throws FileFormatException The file is empty
5253
*/
5354
protected FileFormat(final File file) throws IOException, FileFormatException {
5455
this.fileName = file.getName();
@@ -129,6 +130,16 @@ public Collection<FileComponent> getFileComponents() {
129130
return Collections.unmodifiableCollection(this.components.values());
130131
}
131132

133+
/**
134+
* The child class may choose to provide an icon for the file format. This
135+
* method should be change to abstract if all children has provided an icon.
136+
*
137+
* @return <code>null</code> to use default icon, else use supplied icon
138+
*/
139+
public Icon getIcon() {
140+
return null;
141+
}
142+
132143
/**
133144
* Response to the tree node selection change event. Example: when choosing
134145
* method code node, the JVM Class file want to add a tab to display decoded

CommonLib/src/main/java/org/freeinternals/commonlib/core/PosDataInputStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public String readASCII() throws IOException {
376376
* <code>end</code>.
377377
*
378378
* @param end
379-
* @throws java.io.IOException
379+
* @throws IOException
380380
*
381381
* <pre>
382382
* java:S135 - Loops should not contain more than a single "break" or "continue" statement --- We need it in this method
@@ -409,7 +409,7 @@ public String readASCIIUntil(final byte end) throws IOException {
409409
*
410410
* @param end End value for the ASCII string
411411
* @return ASCII as string
412-
* @throws java.io.IOException Read failed
412+
* @throws IOException Read failed
413413
*
414414
* <pre>
415415
* java:S135 - Loops should not contain more than a single "break" or "continue" statement --- We need it in this method
@@ -444,7 +444,7 @@ public String readASCIIUntil(byte... end) throws IOException {
444444
* {@link #NEWLINE_LF} flag found.
445445
*
446446
* @return
447-
* @throws java.io.IOException
447+
* @throws IOException
448448
*/
449449
public ASCIILine readASCIILine() throws IOException {
450450
int nlLen = 1;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public JTreeNodeFileComponent(final int nodeStartPos, final int nodeLength, fina
9393
*/
9494
public JTreeNodeFileComponent(final int nodeStartPos, final int nodeLength, final String nodeText, final Icon nodeIcon, final String desc) {
9595
this(nodeStartPos, nodeLength, nodeText);
96+
this.setIcon(nodeIcon);
9697
this.description = desc;
97-
this.icon = nodeIcon;
9898
}
9999

100100
@Override
@@ -155,7 +155,9 @@ public Icon getIcon() {
155155
* @param icon value for {@link #icon}
156156
*/
157157
public void setIcon(Icon icon) {
158-
this.icon = icon;
158+
if (icon != null) {
159+
this.icon = icon;
160+
}
159161
}
160162

161163
/**

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

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import java.awt.BorderLayout;
1010
import javax.swing.Icon;
11+
import javax.swing.ImageIcon;
1112
import javax.swing.JDialog;
1213
import javax.swing.JFrame;
1314
import javax.swing.JPanel;
@@ -58,12 +59,65 @@ public static void generateTreeNodeDiff(
5859
}
5960

6061
/**
61-
* Get Java system default icon for shortcut.
62+
* Icon for counter.
6263
*
63-
* @return Shortcut icon in Java
64+
* @return Icon for counter
65+
* @see <a href="https://icons8.com/icon/2U6ROkjIrXIA/abacus">Abacus</a> icon by <a href="https://icons8.com">Icons8</a>
6466
*/
65-
public static Icon getShortcutIcon() {
66-
return UIManager.getIcon("InternalFrame.maximizeIcon");
67+
public static Icon icon4Counter() {
68+
return new ImageIcon(UITool.class.getResource("/image/icons8-abacus-16.png"));
69+
}
70+
71+
/**
72+
* Icon for DEX file.
73+
*
74+
* @return Icon for dex file
75+
* @see <a href="https://icons8.com/icon/38933/apk">APK</a> icon by <a href="https://icons8.com">Icons8</a>
76+
*/
77+
public static Icon icon4Dex() {
78+
return new ImageIcon(UITool.class.getResource("/image/icons8-apk-20.png"));
79+
}
80+
81+
/**
82+
* Icon for Java.
83+
*
84+
* @return Icon for Java
85+
*/
86+
public static Icon icon4Java() {
87+
return new ImageIcon(UITool.class.getResource("/image/icons8-java-20.png"));
88+
}
89+
90+
/**
91+
* Icon for magic number.
92+
*
93+
* @return Icon for magic number
94+
* @see <a href="https://icons8.com/icon/q8t3iE9rg6YF/magic-wand">Magic Wand</a> icon by <a href="https://icons8.com">Icons8</a>
95+
*/
96+
public static Icon icon4Magic() {
97+
return new ImageIcon(UITool.class.getResource("/image/icons8-magic-wand-16.png"));
98+
}
99+
100+
/**
101+
* Icon for shortcut.
102+
*
103+
* @return Shortcut icon
104+
*
105+
* @see <a href="https://icons8.com/icon/78265/shortcut">Shortcut</a> icon
106+
* by <a href="https://icons8.com">Icons8</a>
107+
*/
108+
public static Icon icon4Shortcut() {
109+
return new ImageIcon(UITool.class.getResource("/image/icons8-shortcut-16.png"));
110+
}
111+
112+
/**
113+
* Icon for version.
114+
*
115+
* @return Icon for versions
116+
* @see <a href="https://icons8.com/icon/21933/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
117+
* @see <a href="https://icons8.com/icon/59954/versions">Versions</a> icon by <a href="https://icons8.com">Icons8</a>
118+
*/
119+
public static Icon icon4Versions() {
120+
return new ImageIcon(UITool.class.getResource("/image/icons8-versions-16.png"));
67121
}
68122

69123
/**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Icons from [Icons8](https://icons8.com/)
2+
3+
* Free version is avaible if [linking](https://icons8.com/pricing) is added
Loading
Loading

0 commit comments

Comments
 (0)