All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
com.google.scrollview.events.SVEventHandler Class Reference
Inheritance diagram for com.google.scrollview.events.SVEventHandler:

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.

75  {
76  timer = new Timer(1000, this);
77  svWindow = wdw;
78  }

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 227 of file SVEventHandler.java.

227  {
228  processEvent(new SVEvent(SVEventType.SVET_HOVER, svWindow, lastXMove,
229  lastYMove, 0, 0, null));
230  }
SVEventType
Definition: scrollview.h:45
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 242 of file SVEventHandler.java.

242  {
243  char keyCh = e.getKeyChar();
244  if (keyCh == '\r' || keyCh == '\n' || keyCh == '\0' || keyCh == '?') {
245  processEvent(new SVEvent(SVEventType.SVET_INPUT, svWindow, lastXMove,
246  lastYMove, 0, 0, keyStr));
247  // Send newline characters as '!' as '!' can never be a keypressed
248  // and the client eats all newline characters.
249  keyStr = "!";
250  } else {
251  processEvent(new SVEvent(SVEventType.SVET_INPUT, svWindow, lastXMove,
252  lastYMove, 0, 0, String.valueOf(keyCh)));
253  keyStr += keyCh;
254  }
255  }
SVEventType
Definition: scrollview.h:45
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 274 of file SVEventHandler.java.

274  {
275  }
void com.google.scrollview.events.SVEventHandler.keyTyped ( KeyEvent  e)
inline

Definition at line 277 of file SVEventHandler.java.

277  {
278  }
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.

104  {
105  if (e.isPopupTrigger()) {
106  showPopup(e);
107  } else {
108  processEvent(new SVEvent(SVEventType.SVET_CLICK, svWindow, (int) e
109  .getPosition().getX(), (int) e.getPosition().getY(), 0, 0, null));
110  }
111  }
SVEventType
Definition: scrollview.h:45
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.

132  {
133  processEvent(new SVEvent(SVEventType.SVET_MOUSE, svWindow, (int) e
134  .getPosition().getX(), (int) e.getPosition().getY(), (int) e
135  .getPosition().getX()
136  - lastX, (int) e.getPosition().getY() - lastY, null));
137 
138  // Paint a selection rectangle.
139  if (selection == null) {
140  startX = (int) e.getPosition().getX();
141  startY = (int) e.getPosition().getY();
142  selection = PPath.createRectangle(startX, startY, 1, 1);
143  selection.setTransparency(rubberBandTransparency);
144  svWindow.canvas.getLayer().addChild(selection);
145  } else {
146  int right = Math.max(startX, (int) e.getPosition().getX());
147  int left = Math.min(startX, (int) e.getPosition().getX());
148  int bottom = Math.max(startY, (int) e.getPosition().getY());
149  int top = Math.min(startY, (int) e.getPosition().getY());
150  svWindow.canvas.getLayer().removeChild(selection);
151  selection = PPath.createRectangle(left, top, right - left, bottom - top);
152  selection.setPaint(Color.YELLOW);
153  selection.setTransparency(rubberBandTransparency);
154  svWindow.canvas.getLayer().addChild(selection);
155  }
156  }
SVEventType
Definition: scrollview.h:45
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 211 of file SVEventHandler.java.

211  {
212  timer.restart();
213  }
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 219 of file SVEventHandler.java.

219  {
220  timer.stop();
221  }
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 202 of file SVEventHandler.java.

202  {
203  processEvent(new SVEvent(SVEventType.SVET_MOTION, svWindow, (int) e
204  .getPosition().getX(), (int) e.getPosition().getY(), 0, 0, null));
205  }
SVEventType
Definition: scrollview.h:45
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.

120  {
121  if (e.isPopupTrigger()) {
122  showPopup(e);
123  } else {
124  lastX = (int) e.getPosition().getX();
125  lastY = (int) e.getPosition().getY();
126  timer.restart();
127  }
128  }
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.

165  {
166  if (e.isPopupTrigger()) {
167  showPopup(e);
168  } else {
169  processEvent(new SVEvent(SVEventType.SVET_SELECTION, svWindow, (int) e
170  .getPosition().getX(), (int) e.getPosition().getY(), (int) e
171  .getPosition().getX()
172  - lastX, (int) e.getPosition().getY() - lastY, null));
173  }
174  if (selection != null) {
175  svWindow.canvas.getLayer().removeChild(selection);
176  selection = null;
177  }
178  }
SVEventType
Definition: scrollview.h:45
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 185 of file SVEventHandler.java.

185  {
186  PCamera lc = svWindow.canvas.getCamera();
187  double sf = SVWindow.SCALING_FACTOR;
188 
189  if (e.getWheelRotation() < 0) {
190  sf = 1 / sf;
191  }
192  lc.scaleViewAboutPoint(lc.getScale() / sf, e.getPosition().getX(), e
193  .getPosition().getY());
194  }
void com.google.scrollview.events.SVEventHandler.windowActivated ( WindowEvent  e)
inline

Definition at line 280 of file SVEventHandler.java.

280  {
281  }
void com.google.scrollview.events.SVEventHandler.windowClosed ( WindowEvent  e)
inline

Definition at line 283 of file SVEventHandler.java.

283  {
284  }
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 262 of file SVEventHandler.java.

262  {
263  processEvent(new SVEvent(SVEventType.SVET_DESTROY, svWindow, lastXMove,
264  lastYMove, 0, 0, null));
265  e.getWindow().dispose();
266  SVWindow.nrWindows--;
267  if (SVWindow.nrWindows == 0) {
268  processEvent(new SVEvent(SVEventType.SVET_EXIT, svWindow, lastXMove,
269  lastYMove, 0, 0, null));
270  }
271  }
SVEventType
Definition: scrollview.h:45
void com.google.scrollview.events.SVEventHandler.windowDeactivated ( WindowEvent  e)
inline

Definition at line 286 of file SVEventHandler.java.

286  {
287  }
void com.google.scrollview.events.SVEventHandler.windowDeiconified ( WindowEvent  e)
inline

Definition at line 289 of file SVEventHandler.java.

289  {
290  }
void com.google.scrollview.events.SVEventHandler.windowIconified ( WindowEvent  e)
inline

Definition at line 292 of file SVEventHandler.java.

292  {
293  }
void com.google.scrollview.events.SVEventHandler.windowOpened ( WindowEvent  e)
inline

Definition at line 295 of file SVEventHandler.java.

295  {
296  }

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: