mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 16:40:46 +00:00
better binary data display
This commit is contained in:
@@ -35,15 +35,14 @@ public final class BinaryPanel extends JPanel implements ActionListener, Compone
|
||||
|
||||
public BinaryPanel() {
|
||||
super(new BorderLayout());
|
||||
setOpaque(true);
|
||||
setBackground(View.DEFAULT_BACKGROUND_COLOR);
|
||||
// todo: set textArea size, to hide horizontal scrollbar
|
||||
|
||||
add(new JScrollPane(hexEditor), BorderLayout.CENTER);
|
||||
|
||||
JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||
JPanel buttonsPanel = new JPanel(new FlowLayout());
|
||||
bottomPanel.add(buttonsPanel, BorderLayout.EAST);
|
||||
add(bottomPanel, BorderLayout.SOUTH);
|
||||
addComponentListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,13 +51,17 @@ public final class BinaryPanel extends JPanel implements ActionListener, Compone
|
||||
|
||||
public void setBinaryData(byte[] data) {
|
||||
this.data = data;
|
||||
setBackground(View.swfBackgroundColor);
|
||||
int widthInChars = getWidth() / 7 -3; // -3: scrollbar
|
||||
int blockCount = widthInChars / 34;
|
||||
hexEditor.setEditable(false);
|
||||
hexEditor.setText(Helper.byteArrayToHex(data, blockCount * 8));
|
||||
hexEditor.setFont(new Font("Monospaced", Font.PLAIN, hexEditor.getFont().getSize()));
|
||||
//hexEditor.setContentType("text/plain"); //throws exception. why?
|
||||
if (data != null) {
|
||||
int widthInChars = getWidth() / 7 - 3; // -3: scrollbar
|
||||
int blockCount = widthInChars / 34;
|
||||
hexEditor.setFont(new Font("Monospaced", Font.PLAIN, hexEditor.getFont().getSize()));
|
||||
hexEditor.setContentType("text/plain");
|
||||
hexEditor.setText(Helper.byteArrayToHex(data, blockCount * 8));
|
||||
hexEditor.setCaretPosition(0);
|
||||
} else {
|
||||
hexEditor.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -598,13 +598,19 @@ public class Helper {
|
||||
|
||||
for (int i = 0; i < bytesPerRow; i++) {
|
||||
int idx = row * bytesPerRow + i;
|
||||
if (data.length == idx) {
|
||||
break;
|
||||
if (data.length > idx) {
|
||||
if (i> 0 && i % groupSize == 0) {
|
||||
writer.appendNoHilight(" ");
|
||||
}
|
||||
writer.appendNoHilight(String.format("%02x ", data[idx]));
|
||||
} else {
|
||||
if (addChars) {
|
||||
if (i> 0 && i % groupSize == 0) {
|
||||
writer.appendNoHilight(" ");
|
||||
}
|
||||
writer.appendNoHilight(" ");
|
||||
}
|
||||
}
|
||||
if (i> 0 && i % groupSize == 0) {
|
||||
writer.appendNoHilight(" ");
|
||||
}
|
||||
writer.appendNoHilight(String.format("%02x ", data[idx]));
|
||||
}
|
||||
|
||||
if (addChars) {
|
||||
|
||||
Reference in New Issue
Block a user