Methods Summary |
---|
public int | calcularPosicionRaton(int x, int y)
FontMetrics fn = getFontMetrics(JHexEditor.font);
x = x / ((fn.stringWidth(" ") + 1) * 3);
y = y / fn.getHeight();
debug("x=" + x + " ,y=" + y);
return x + ((y + he.getInicio()) * 16);
|
private void | debug(java.lang.String s)
if (he.DEBUG) System.out.println("JHexEditorHEX ==> " + s);
|
public java.awt.Dimension | getMaximumSize()
debug("getMaximumSize()");
return getMinimumSize();
|
public java.awt.Dimension | getMinimumSize()
debug("getMinimumSize()");
Dimension d = new Dimension();
FontMetrics fn = getFontMetrics(JHexEditor.font);
int h = fn.getHeight();
int nl = he.getNumberOfVisibleLines();
d.setSize(((fn.stringWidth(" ") + 1) * +((16 * 3) - 1)) + (he.border * 2) + 1, h * nl + (he.border * 2) + 1);
return d;
|
public java.awt.Dimension | getPreferredSize()
debug("getPreferredSize()");
return getMinimumSize();
|
public boolean | isFocusable()
return true;
|
public void | keyPressed(java.awt.event.KeyEvent e)
debug("keyPressed(" + e + ")");
he.keyPressed(e);
|
public void | keyReleased(java.awt.event.KeyEvent e)
debug("keyReleased(" + e + ")");
|
public void | keyTyped(java.awt.event.KeyEvent e)
|
public void | mouseClicked(java.awt.event.MouseEvent e)
debug("mouseClicked(" + e + ")");
he.cursor = calcularPosicionRaton(e.getX(), e.getY());
this.requestFocus();
he.repaint();
|
public void | mouseEntered(java.awt.event.MouseEvent e)
|
public void | mouseExited(java.awt.event.MouseEvent e)
|
public void | mousePressed(java.awt.event.MouseEvent e)
|
public void | mouseReleased(java.awt.event.MouseEvent e)
|
public void | paint(java.awt.Graphics g)
debug("paint(" + g + ")");
debug("cursor=" + he.cursor + " buff.length=" + he.buff.limit());
Dimension d = getMinimumSize();
g.setColor(Color.white);
g.fillRect(0, 0, d.width, d.height);
g.setColor(Color.black);
g.setFont(JHexEditor.font);
int ini = he.getInicio() * 16;
long fin = ini + (he.getNumberOfVisibleLines() * 16);
if (fin > he.buff.limit()) fin = he.buff.limit();
//datos hex
int x = 0;
int y = 0;
he.buff.position(ini);
for (int n = ini; n < fin; n++) {
if (n == he.cursor) {
if (hasFocus()) {
g.setColor(Color.black);
he.filledCursor(g, (x * 3), y, 2);
g.setColor(Color.blue);
he.filledCursor(g, (x * 3) + cursor, y, 1);
} else {
g.setColor(Color.blue);
he.cuadro(g, (x * 3), y, 2);
}
if (hasFocus()) g.setColor(Color.white);
else g.setColor(Color.black);
} else {
g.setColor(Color.black);
}
String s = ("0" + Integer.toHexString(he.buff.get()));
s = s.substring(s.length() - 2);
he.printString(g, s, ((x++) * 3), y);
if (x == 16) {
x = 0;
y++;
}
}
|