Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes
com.google.scrollview.events.SVEventHandler Class Reference

Inherits PBasicInputEventHandler, ActionListener, KeyListener, and WindowListener.

List of all members.

## Public Member Functions
| SVEventHandler (SVWindow wdw)
void | mouseClicked (PInputEvent e)
void | mousePressed (PInputEvent e)
void | mouseDragged (PInputEvent e)
void | mouseReleased (PInputEvent e)
void | mouseWheelRotated (PInputEvent e)
void | mouseMoved (PInputEvent e)
void | mouseEntered (PInputEvent e)
void | mouseExited (PInputEvent e)
void | actionPerformed (ActionEvent e)
void | keyPressed (KeyEvent e)
void | windowClosing (WindowEvent e)
void | keyReleased (KeyEvent e)
void | keyTyped (KeyEvent e)
void | windowActivated (WindowEvent e)
void | windowClosed (WindowEvent e)
void | windowDeactivated (WindowEvent e)
void | windowDeiconified (WindowEvent e)
void | windowIconified (WindowEvent e)
void | windowOpened (WindowEvent e)

## Public Attributes
Timer | timer

## Detailed Description

The ScrollViewEventHandler takes care of any events which might happen on the canvas and converts them to an according SVEvent, which is (using the processEvent method) then added to a message queue. All events from the message queue get sent gradually

Author:
  wanke.nosp@m.@goo.nosp@m.gle.c.nosp@m.om

Definition at line 42 of file SVEventHandler.java.

## Constructor & Destructor Documentation

com.google.scrollview.events.SVEventHandler.SVEventHandler | ( | SVWindow | wdw | ) |
| inline

Setup the timer.

Definition at line 75 of file SVEventHandler.java.

{
timer = new Timer(1000, this);
svWindow = wdw;
}

## Member Function Documentation

void com.google.scrollview.events.SVEventHandler.actionPerformed | ( | ActionEvent | e | ) |
| inline

The only associated object with this is the timer, so we use it to send a SVET_HOVER event.

Definition at line 226 of file SVEventHandler.java.

{
processEvent(new SVEvent(SVEventType.SVET_HOVER, svWindow, lastXMove,
lastYMove, 0, 0, null));
}

void com.google.scrollview.events.SVEventHandler.keyPressed | ( | KeyEvent | e | ) |
| inline

A key was pressed - create an SVET_INPUT event.

NOTE: Might be useful to specify hotkeys.

Implementation note: The keyListener provided by Piccolo seems to be broken, so we use the AWT listener directly. There are never any keyTyped events received either so we are stuck with physical keys, which is very ugly.

Definition at line 241 of file SVEventHandler.java.

{
char keyCh = e.getKeyChar();
if (keyCh == '\r' || keyCh == '\n' || keyCh == '\0' || keyCh == '?') {
processEvent(new SVEvent(SVEventType.SVET_INPUT, svWindow, lastXMove,
lastYMove, 0, 0, keyStr));
// Send newline characters as '!' as '!' can never be a keypressed
// and the client eats all newline characters.
keyStr = "!";
} else {
processEvent(new SVEvent(SVEventType.SVET_INPUT, svWindow, lastXMove,
lastYMove, 0, 0, String.valueOf(keyCh)));
keyStr += keyCh;
}
}

void com.google.scrollview.events.SVEventHandler.keyReleased | ( | KeyEvent | e | ) |
| inline

These are all events we do not care about and throw away

Definition at line 273 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.keyTyped | ( | KeyEvent | e | ) |
| inline

Definition at line 276 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.mouseClicked | ( | PInputEvent | e | ) |
| inline

The mouse is clicked - create an SVET_CLICK event.

Definition at line 104 of file SVEventHandler.java.

{
if (e.isPopupTrigger()) {
showPopup(e);
} else {
processEvent(new SVEvent(SVEventType.SVET_CLICK, svWindow, (int) e
.getPosition().getX(), (int) e.getPosition().getY(), 0, 0, null));
}
}

void com.google.scrollview.events.SVEventHandler.mouseDragged | ( | PInputEvent | e | ) |
| inline

The mouse is getting dragged - create an SVET_MOUSE event.

Definition at line 132 of file SVEventHandler.java.

{
processEvent(new SVEvent(SVEventType.SVET_MOUSE, svWindow, (int) e
.getPosition().getX(), (int) e.getPosition().getY(), (int) e
.getPosition().getX()
- lastX, (int) e.getPosition().getY() - lastY, null));
// Paint a selection rectangle.
if (selection == null) {
startX = (int) e.getPosition().getX();
startY = (int) e.getPosition().getY();
selection = PPath.createRectangle(startX, startY, 1, 1);
selection.setTransparency(rubberBandTransparency);
svWindow.canvas.getLayer().addChild(selection);
} else {
int right = Math.max(startX, (int) e.getPosition().getX());
int left = Math.min(startX, (int) e.getPosition().getX());
int bottom = Math.max(startY, (int) e.getPosition().getY());
int top = Math.min(startY, (int) e.getPosition().getY());
svWindow.canvas.getLayer().removeChild(selection);
selection = PPath.createRectangle(left, top, right - left, bottom - top);
selection.setPaint(Color.YELLOW);
selection.setTransparency(rubberBandTransparency);
svWindow.canvas.getLayer().addChild(selection);
}
}

void com.google.scrollview.events.SVEventHandler.mouseEntered | ( | PInputEvent | e | ) |
| inline

The mouse entered the window. Start the timer, which will then emit SVET_HOVER events every X ms.

Definition at line 210 of file SVEventHandler.java.

{
timer.restart();
}

void com.google.scrollview.events.SVEventHandler.mouseExited | ( | PInputEvent | e | ) |
| inline

The mouse exited the window Stop the timer, so no more SVET_HOVER events will emit.

Definition at line 218 of file SVEventHandler.java.

{
timer.stop();
}

void com.google.scrollview.events.SVEventHandler.mouseMoved | ( | PInputEvent | e | ) |
| inline

The mouse was moved - create an SVET_MOTION event. NOTE: This obviously creates a lot of traffic and, depending on the type of application, could quite possibly be disabled.

Definition at line 201 of file SVEventHandler.java.

{
processEvent(new SVEvent(SVEventType.SVET_MOTION, svWindow, (int) e
.getPosition().getX(), (int) e.getPosition().getY(), 0, 0, null));
}

void com.google.scrollview.events.SVEventHandler.mousePressed | ( | PInputEvent | e | ) |
| inline

The mouse key is pressed (and keeps getting pressed). Depending on the OS, show a popup menu (if the button pressed is associated with popup menus, like the RMB under windows&linux) or otherwise save the position (in case it is a selection).

Definition at line 120 of file SVEventHandler.java.

{
if (e.isPopupTrigger()) {
showPopup(e);
} else {
lastX = (int) e.getPosition().getX();
lastY = (int) e.getPosition().getY();
timer.restart();
}
}

void com.google.scrollview.events.SVEventHandler.mouseReleased | ( | PInputEvent | e | ) |
| inline

The mouse was released. Depending on the OS, show a popup menu (if the button pressed is associated with popup menus, like the RMB under windows&linux) or otherwise create an SVET_SELECTION event.

Definition at line 165 of file SVEventHandler.java.

{
if (e.isPopupTrigger()) {
showPopup(e);
} else {
processEvent(new SVEvent(SVEventType.SVET_SELECTION, svWindow, (int) e
.getPosition().getX(), (int) e.getPosition().getY(), (int) e
.getPosition().getX()
- lastX, (int) e.getPosition().getY() - lastY, null));
}
if (selection != null) {
svWindow.canvas.getLayer().removeChild(selection);
}
}

void com.google.scrollview.events.SVEventHandler.mouseWheelRotated | ( | PInputEvent | e | ) |
| inline

The mouse wheel is used to zoom in and out of the viewport and center on the (x,y) position the mouse is currently on.

Definition at line 184 of file SVEventHandler.java.

{
PCamera lc = svWindow.canvas.getCamera();
double sf = SVWindow.SCALING_FACTOR;
if (e.getWheelRotation() < 0) {
sf = 1 / sf;
}
lc.scaleViewAboutPoint(lc.getScale() / sf, e.getPosition().getX(), e
.getPosition().getY());
}

void com.google.scrollview.events.SVEventHandler.windowActivated | ( | WindowEvent | e | ) |
| inline

Definition at line 279 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.windowClosed | ( | WindowEvent | e | ) |
| inline

Definition at line 282 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.windowClosing | ( | WindowEvent | e | ) |
| inline

A window is closed (by the 'x') - create an SVET_DESTROY event. If it was the last open Window, also send an SVET_EXIT event (but do not exit unless the client says so).

Definition at line 261 of file SVEventHandler.java.

{
processEvent(new SVEvent(SVEventType.SVET_DESTROY, svWindow, lastXMove,
lastYMove, 0, 0, null));
e.getWindow().dispose();
SVWindow.nrWindows--;
if (SVWindow.nrWindows == 0) {
processEvent(new SVEvent(SVEventType.SVET_EXIT, svWindow, lastXMove,
lastYMove, 0, 0, null));
}
}

void com.google.scrollview.events.SVEventHandler.windowDeactivated | ( | WindowEvent | e | ) |
| inline

Definition at line 285 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.windowDeiconified | ( | WindowEvent | e | ) |
| inline

Definition at line 288 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.windowIconified | ( | WindowEvent | e | ) |
| inline

Definition at line 291 of file SVEventHandler.java.

{
}

void com.google.scrollview.events.SVEventHandler.windowOpened | ( | WindowEvent | e | ) |
| inline

Definition at line 294 of file SVEventHandler.java.

{
}

## Member Data Documentation

Timer com.google.scrollview.events.SVEventHandler.timer

Necessary to wait for a defined period of time (for SVET_HOVER).

Definition at line 46 of file SVEventHandler.java.

The documentation for this class was generated from the following file:

- /mnt/data/src/tesseract-ocr/java/com/google/scrollview/events/SVEventHandler.java