Top Fields Constructors Methods
org.apache.pdfbox.debugger.hexviewer

pack-priv Class HexPane

extends JPanel
implements KeyListener, MouseListener, MouseMotionListener, HexModelChangeListener
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.debugger.hexviewer.HexModelChangeListener, java.awt.event.MouseMotionListener, java.util.EventListener, java.awt.event.MouseListener, java.awt.event.KeyListener
Annotations
@SuppressWarnings:squid:S1948
Imports
java.awt.Color, .Dimension, .Graphics, .Graphics2D, .Point, .Rectangle, java.awt.event.KeyEvent, .KeyListener, .MouseEvent, .MouseListener, .MouseMotionListener, java.awt.font.TextAttribute, java.text.AttributedString, java.util.ArrayList, .List, javax.swing.JPanel

Author
Khyrul Bashar HexPane shows the byte in a Grid table where every row has 16 bytes. It only draws bytes those are only visible at a given time.

Field Summary

Modifier and TypeField and Description
private static final byte
private final List<HexChangeListener>
private final HexModel
private static final byte
private static final byte
private int
private int
private final List<SelectionChangeListener>
private byte

Constructor Summary

AccessConstructor and Description
pack-priv
HexPane(HexModel
HexModel instance.
model
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
public void
private void
fireHexValueChanged(byte value, int index)

private void
private byte
getByte(char[] chars)

private char[]
getChars(byte b)

private int

Returns:

index.
getIndexForPoint
(Point
Point instance.
point
)

Returns the index for a given point If there is any byte in there.

private Point

Returns:

Point instance.
getPointForIndex
(int
int.
index
)

Returns the starting point in the view for any index.

private AttributedString
public void
private static boolean
isHexChar(char c)

public void
keyPressed(KeyEvent
the event to be processed
keyEvent
)

Implements java.awt.event.KeyListener.keyPressed.

Invoked when a key has been pressed.

public void
keyReleased(KeyEvent
the event to be processed
keyEvent
)

Implements java.awt.event.KeyListener.keyReleased.

Invoked when a key has been released.

public void
keyTyped(KeyEvent
the event to be processed
keyEvent
)

Implements java.awt.event.KeyListener.keyTyped.

Invoked when a key has been typed.

public void
mouseClicked(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseListener.mouseClicked.

Invoked when the mouse button has been clicked (pressed and released) on a component.

public void
mouseDragged(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseMotionListener.mouseDragged.

Invoked when a mouse button is pressed on a component and then dragged.

public void
mouseEntered(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseListener.mouseEntered.

Invoked when the mouse enters a component.

public void
mouseExited(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseListener.mouseExited.

Invoked when the mouse exits a component.

public void
mouseMoved(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseMotionListener.mouseMoved.

Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.

public void
mousePressed(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseListener.mousePressed.

Invoked when a mouse button has been pressed on a component.

public void
mouseReleased(MouseEvent
the event to be processed
mouseEvent
)

Implements java.awt.event.MouseListener.mouseReleased.

Invoked when a mouse button has been released on a component.

protected void
paintComponent(Graphics
the Graphics object to protect
g
)

Overrides javax.swing.JComponent.paintComponent.

Calls the UI delegate's paint method, if the UI delegate is non-null.

private void
paintInEdit(Graphics g, byte content, int x, int y)

private void
putInSelected(int index)

Puts an index in selected state or in other word it selects the byte of the index.

private void
public void
setSelected(int index)

Inherited from javax.swing.JPanel:
getAccessibleContextgetUIgetUIClassIDparamStringsetUIupdateUI

Field Detail

EDITback to summary
private static final byte EDIT
hexChangeListenersback to summary
private final List<HexChangeListener> hexChangeListeners
modelback to summary
private final HexModel model
NORMALback to summary
private static final byte NORMAL
SELECTEDback to summary
private static final byte SELECTED
selectedCharback to summary
private int selectedChar
selectedIndexback to summary
private int selectedIndex
selectionChangeListenersback to summary
private final List<SelectionChangeListener> selectionChangeListeners
stateback to summary
private byte state

Constructor Detail

HexPaneback to summary
pack-priv HexPane(HexModel model)

Constructor.

Parameters
model:HexModel

HexModel instance.

Method Detail

addHexChangeListenersback to summary
public void addHexChangeListeners(HexChangeListener listener)
addSelectionChangeListenerback to summary
public void addSelectionChangeListener(SelectionChangeListener listener)
fireHexValueChangedback to summary
private void fireHexValueChanged(byte value, int index)
fireSelectionChangedback to summary
private void fireSelectionChanged(SelectEvent event)
getByteback to summary
private byte getByte(char[] chars)
getCharsback to summary
private char[] getChars(byte b)
getIndexForPointback to summary
private int getIndexForPoint(Point point)

Returns the index for a given point If there is any byte in there.

Parameters
point:Point

Point instance.

Returns:int

index.

getPointForIndexback to summary
private Point getPointForIndex(int index)

Returns the starting point in the view for any index.

Parameters
index:int

int.

Returns:Point

Point instance.

getSelectedStringback to summary
private AttributedString getSelectedString(String str)
hexModelChangedback to summary
public void hexModelChanged(HexModelChangedEvent event)

Implements org.apache.pdfbox.debugger.hexviewer.HexModelChangeListener.hexModelChanged.

Annotations
@Override
isHexCharback to summary
private static boolean isHexChar(char c)
keyPressedback to summary
public void keyPressed(KeyEvent keyEvent)

Implements java.awt.event.KeyListener.keyPressed.

Doc from java.awt.event.KeyListener.keyPressed.

Invoked when a key has been pressed. See the class description for KeyEvent for a definition of a key pressed event.

Parameters
keyEvent:KeyEvent

the event to be processed

Annotations
@Override
keyReleasedback to summary
public void keyReleased(KeyEvent keyEvent)

Implements java.awt.event.KeyListener.keyReleased.

Doc from java.awt.event.KeyListener.keyReleased.

Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.

Parameters
keyEvent:KeyEvent

the event to be processed

Annotations
@Override
keyTypedback to summary
public void keyTyped(KeyEvent keyEvent)

Implements java.awt.event.KeyListener.keyTyped.

Doc from java.awt.event.KeyListener.keyTyped.

Invoked when a key has been typed. See the class description for KeyEvent for a definition of a key typed event.

Parameters
keyEvent:KeyEvent

the event to be processed

Annotations
@Override
mouseClickedback to summary
public void mouseClicked(MouseEvent mouseEvent)

Implements java.awt.event.MouseListener.mouseClicked.

Doc from java.awt.event.MouseListener.mouseClicked.

Invoked when the mouse button has been clicked (pressed and released) on a component.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
mouseDraggedback to summary
public void mouseDragged(MouseEvent mouseEvent)

Implements java.awt.event.MouseMotionListener.mouseDragged.

Doc from java.awt.event.MouseMotionListener.mouseDragged.

Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
mouseEnteredback to summary
public void mouseEntered(MouseEvent mouseEvent)

Implements java.awt.event.MouseListener.mouseEntered.

Doc from java.awt.event.MouseListener.mouseEntered.

Invoked when the mouse enters a component.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
mouseExitedback to summary
public void mouseExited(MouseEvent mouseEvent)

Implements java.awt.event.MouseListener.mouseExited.

Doc from java.awt.event.MouseListener.mouseExited.

Invoked when the mouse exits a component.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
mouseMovedback to summary
public void mouseMoved(MouseEvent mouseEvent)

Implements java.awt.event.MouseMotionListener.mouseMoved.

Doc from java.awt.event.MouseMotionListener.mouseMoved.

Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
mousePressedback to summary
public void mousePressed(MouseEvent mouseEvent)

Implements java.awt.event.MouseListener.mousePressed.

Doc from java.awt.event.MouseListener.mousePressed.

Invoked when a mouse button has been pressed on a component.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
mouseReleasedback to summary
public void mouseReleased(MouseEvent mouseEvent)

Implements java.awt.event.MouseListener.mouseReleased.

Doc from java.awt.event.MouseListener.mouseReleased.

Invoked when a mouse button has been released on a component.

Parameters
mouseEvent:MouseEvent

the event to be processed

Annotations
@Override
paintComponentback to summary
protected void paintComponent(Graphics g)

Overrides javax.swing.JComponent.paintComponent.

Doc from javax.swing.JComponent.paintComponent.

Calls the UI delegate's paint method, if the UI delegate is non-null. We pass the delegate a copy of the Graphics object to protect the rest of the paint code from irrevocable changes (for example, Graphics.translate).

If you override this in a subclass you should not make permanent changes to the passed in Graphics. For example, you should not alter the clip Rectangle or modify the transform. If you need to do these operations you may find it easier to create a new Graphics from the passed in Graphics and manipulate it. Further, if you do not invoke super's implementation you must honor the opaque property, that is if this component is opaque, you must completely fill in the background in an opaque color. If you do not honor the opaque property you will likely see visual artifacts.

The passed in Graphics object might have a transform other than the identify transform installed on it. In this case, you might get unexpected results if you cumulatively apply another transform.

Parameters
g:Graphics

the Graphics object to protect

Annotations
@Override
paintInEditback to summary
private void paintInEdit(Graphics g, byte content, int x, int y)
putInSelectedback to summary
private void putInSelected(int index)

Puts an index in selected state or in other word it selects the byte of the index.

setDefaultback to summary
private void setDefault(Graphics g)
setSelectedback to summary
public void setSelected(int index)