mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 06:40:47 +00:00
small dumpview UI changes
This commit is contained in:
@@ -48,8 +48,7 @@ public class HexView extends JTable {
|
||||
private final Color[] highlightColors;
|
||||
private final Color bgColor = Color.decode("#F7F7F7");
|
||||
private final Color bgColorAlternate = Color.decode("#EDEDED");
|
||||
private int itsRow = 0;
|
||||
private int itsColumn = 0;
|
||||
private int mouseOverIdx = -1;
|
||||
private HexViewListener listener;
|
||||
|
||||
private class HighlightCellRenderer extends DefaultTableCellRenderer {
|
||||
@@ -61,8 +60,8 @@ public class HexView extends JTable {
|
||||
|
||||
JLabel l = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
int level = -1;
|
||||
if (col > 0 && highlightStarts != null && col != bytesInRow + 1) {
|
||||
int idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1));
|
||||
int idx = getIdxByColAndRow(row, col);
|
||||
if (highlightStarts != null) {
|
||||
byteIndex = idx;
|
||||
for (int i = 0; i < highlightStarts.length; i++) {
|
||||
if (highlightStarts[i] <= idx && highlightEnds[i] >= idx) {
|
||||
@@ -83,13 +82,12 @@ public class HexView extends JTable {
|
||||
background = row % 2 == 0 ? bgColor : bgColorAlternate;
|
||||
}
|
||||
|
||||
if (col == itsColumn && row == itsRow) {
|
||||
if (idx != -1 && idx == mouseOverIdx) {
|
||||
foreground = new Color(255 - foreground.getRed(), 255 - foreground.getGreen(), 255 - foreground.getBlue());
|
||||
background = new Color(255 - background.getRed(), 255 - background.getGreen(), 255 - background.getBlue());
|
||||
}
|
||||
l.setForeground(foreground);
|
||||
l.setBackground(background);
|
||||
|
||||
|
||||
return l;
|
||||
}
|
||||
@@ -109,22 +107,26 @@ public class HexView extends JTable {
|
||||
int col = table.getSelectedColumn();
|
||||
int row = table.getSelectedRow();
|
||||
|
||||
if (col > 0 && highlightStarts != null && col != bytesInRow + 1) {
|
||||
int idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1));
|
||||
byte[] data = getModel().getData();
|
||||
if (idx < data.length) {
|
||||
if (listener != null) {
|
||||
listener.byteValueChanged(idx, data[idx]);
|
||||
}
|
||||
}
|
||||
int idx = getIdxByColAndRow(row, col);
|
||||
if (listener != null) {
|
||||
listener.byteValueChanged(idx, idx == -1 ? 0 : getModel().getData()[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class HexViewMouseAdapter extends MouseAdapter {
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
public void mouseExited(MouseEvent e) {
|
||||
HexView table = (HexView) e.getSource();
|
||||
Point point = e.getPoint();
|
||||
int col = table.columnAtPoint(point);
|
||||
int row = table.rowAtPoint(point);
|
||||
mouseOverIdx = -1;
|
||||
getModel().fireTableCellUpdated(row, col);
|
||||
if (listener != null) {
|
||||
listener.byteMouseMoved(-1, (byte) 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,13 +138,12 @@ public class HexView extends JTable {
|
||||
Point point = e.getPoint();
|
||||
int col = table.columnAtPoint(point);
|
||||
int row = table.rowAtPoint(point);
|
||||
itsColumn = col;
|
||||
itsRow = row;
|
||||
int idx = getIdxByColAndRow(row, col);
|
||||
mouseOverIdx = idx;
|
||||
getModel().fireTableCellUpdated(row, col);
|
||||
|
||||
if (listener != null) {
|
||||
int idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1));
|
||||
listener.byteMouseMoved(idx, getModel().getData()[idx]);
|
||||
listener.byteMouseMoved(idx, idx == -1 ? 0 : getModel().getData()[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,6 +213,10 @@ public class HexView extends JTable {
|
||||
this.highlightEnds = highlightEnds;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return getModel().getData();
|
||||
}
|
||||
|
||||
public void scrollToByte(long byteNum) {
|
||||
|
||||
int row = (int) (byteNum / bytesInRow);
|
||||
@@ -221,6 +226,26 @@ public class HexView extends JTable {
|
||||
scrollRectToVisible(new Rectangle(getCellRect(row, 0, true)));
|
||||
}
|
||||
|
||||
private int getIdxByColAndRow(int row, int col) {
|
||||
int idx = -1;
|
||||
if (col > 0 && col != bytesInRow + 1) {
|
||||
idx = row * bytesInRow + ((col > bytesInRow + 1) ? (col - bytesInRow - 2) : (col - 1));
|
||||
}
|
||||
byte[] data = getModel().getData();
|
||||
if (idx >= data.length) {
|
||||
idx = -1;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
public int getFocusedByteIdx() {
|
||||
int col = getSelectedColumn();
|
||||
int row = getSelectedRow();
|
||||
|
||||
int idx = getIdxByColAndRow(row, col);
|
||||
return idx;
|
||||
}
|
||||
|
||||
public void scrollToByte(long[] byteNumStarts, long[] byteNumEnds) {
|
||||
for (int i = 0; i < byteNumStarts.length; i++) {
|
||||
scrollToByte(byteNumStarts[i]);
|
||||
|
||||
Reference in New Issue
Block a user