Changing Font Size On Hex Viewer
This commit is contained in:
parent
4e57bd03e4
commit
612f89cd1c
5 changed files with 19 additions and 8 deletions
|
@ -794,6 +794,11 @@ public class MainViewerGUI extends JFrame
|
|||
deleteForeignOutdatedLibs.setSelected(Configuration.deleteForeignLibraries);
|
||||
}
|
||||
|
||||
public int getFontSize()
|
||||
{
|
||||
return (int) fontSpinner.getValue();
|
||||
}
|
||||
|
||||
public synchronized void clearBusyStatus()
|
||||
{
|
||||
SwingUtilities.invokeLater(()->
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package the.bytecode.club.bytecodeviewer.gui.hexviewer;
|
||||
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
@ -28,7 +30,7 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
|
|||
|
||||
byte[] buff;
|
||||
public int cursor;
|
||||
protected static Font font = new Font("Monospaced", Font.PLAIN, 12);
|
||||
public Font font;
|
||||
protected int border = 2;
|
||||
public boolean DEBUG = false;
|
||||
private final JScrollBar sb;
|
||||
|
@ -40,7 +42,10 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
|
|||
public JHexEditor(byte[] buff)
|
||||
{
|
||||
super();
|
||||
|
||||
this.buff = buff;
|
||||
this.font = new Font("Monospaced", Font.PLAIN, BytecodeViewer.viewer.getFontSize());
|
||||
|
||||
checkSize();
|
||||
|
||||
this.addMouseWheelListener(this);
|
||||
|
@ -85,6 +90,7 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe
|
|||
checkSize();
|
||||
|
||||
FontMetrics fn = getFontMetrics(font);
|
||||
|
||||
Rectangle rec = this.getBounds();
|
||||
lineas = (rec.height / fn.getHeight()) - 1;
|
||||
int n = (buff.length / textLength) - 1;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis
|
|||
debug("getMinimumSize()");
|
||||
|
||||
Dimension d = new Dimension();
|
||||
FontMetrics fn = getFontMetrics(JHexEditor.font);
|
||||
FontMetrics fn = getFontMetrics(he.font);
|
||||
int w = fn.stringWidth(" ");
|
||||
int h = fn.getHeight();
|
||||
int nl = he.getLineas();
|
||||
|
@ -69,7 +69,7 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis
|
|||
g.fillRect(0, 0, d.width, d.height);
|
||||
g.setColor(Color.black);
|
||||
|
||||
g.setFont(JHexEditor.font);
|
||||
g.setFont(he.font);
|
||||
|
||||
// datos ascii
|
||||
int ini = he.getInicio() * he.textLength;
|
||||
|
@ -113,7 +113,7 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis
|
|||
|
||||
// calcular la posicion del raton
|
||||
public int calcularPosicionRaton(int x, int y) {
|
||||
FontMetrics fn = getFontMetrics(JHexEditor.font);
|
||||
FontMetrics fn = getFontMetrics(he.font);
|
||||
x = x / (fn.stringWidth(" ") + 1);
|
||||
y = y / fn.getHeight();
|
||||
debug("x=" + x + " ,y=" + y);
|
||||
|
|
|
@ -54,7 +54,7 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
|
|||
g.setColor(Color.white);
|
||||
}
|
||||
|
||||
g.setFont(JHexEditor.font);
|
||||
g.setFont(he.font);
|
||||
|
||||
int ini = he.getInicio() * he.textLength;
|
||||
int fin = ini + (he.getLineas() * he.textLength);
|
||||
|
@ -102,7 +102,7 @@ public class JHexEditorHEX extends JComponent implements MouseListener, KeyListe
|
|||
|
||||
// calcular la posicion del raton
|
||||
public int calcularPosicionRaton(int x, int y) {
|
||||
FontMetrics fn = getFontMetrics(JHexEditor.font);
|
||||
FontMetrics fn = getFontMetrics(he.font);
|
||||
x = x / ((fn.stringWidth(" ") + 1) * 3);
|
||||
y = y / fn.getHeight();
|
||||
debug("x=" + x + " ,y=" + y);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class BytecodeViewPanelUpdater implements Runnable
|
|||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
final JHexEditor hex = new JHexEditor(cw.toByteArray());
|
||||
hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
||||
hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, BytecodeViewer.viewer.getFontSize()));
|
||||
|
||||
bytecodeViewPanel.add(hex);
|
||||
});
|
||||
|
@ -374,6 +374,6 @@ public class BytecodeViewPanelUpdater implements Runnable
|
|||
|
||||
String editable = isPanelEditable ? " - " + EDITABLE : "";
|
||||
bytecodeViewPanel.textArea.getTitleHeader().setText(decompiler.getDecompilerName() + editable);
|
||||
bytecodeViewPanel.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
||||
bytecodeViewPanel.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, BytecodeViewer.viewer.getFontSize()));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue