Methods Summary |
---|
public int | calcularPosicionRaton(int x, int y)
FontMetrics fn = getFontMetrics(JHexEditor.font);
x = x / (fn.stringWidth(" ") + 1);
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("JHexEditorASCII ==> " + s);
|
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) + (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)
|
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);
//datos ascii
int ini = he.getInicio() * 16;
long fin = ini + (he.getNumberOfVisibleLines() * 16);
if (fin > he.buff.limit()) fin = he.buff.limit();
int x = 0;
int y = 0;
he.buff.position(ini);
for (int n = ini; n < fin; n++) {
if (n == he.cursor) {
g.setColor(Color.blue);
if (hasFocus()) he.filledCursor(g, x, y, 1);
else he.cuadro(g, x, y, 1);
if (hasFocus()) g.setColor(Color.white);
else g.setColor(Color.black);
} else {
g.setColor(Color.black);
}
String s = Iso8859_1.convert(new byte[]{he.buff.get()});
// if ((he.buff[n] < 20) || (he.buff[n] > 126)) s = "" + (char) 16;
he.printString(g, s, (x++), y);
if (x == 16) {
x = 0;
y++;
}
}
|