com.nutiteq.ui
Class ThreadDrivenPanning

java.lang.Object
  extended by java.lang.Thread
      extended by com.nutiteq.ui.ThreadDrivenPanning
All Implemented Interfaces:
PanningStrategy, java.lang.Runnable

public class ThreadDrivenPanning
extends java.lang.Thread
implements PanningStrategy

Thread driven panning implementation, that will pan map at 35 ms intervals. Based on panning time, the panning speed will increase. At the beginning map will be moved by one pixel, the by two pixels and at the end by four pixels. This implementation has additional checks using keyRepeated events to check, if panning is still active. If no keyRepeat events have been received for two seconds, then panning is considered abandoned and is stopped. Current panning action will be stopped, not the thread. Abandoned panning actions can be created, when key is pressed for moving and then some system interruption (incoming call, etc.) happens. Then the key released event is never received by MapComponent and panning is never stopped. NOTE - for this implementation to work correctly, MapComponent needs to receive keyRepeated events.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ThreadDrivenPanning()
           
 
Method Summary
 boolean isPanning()
          Is panning implementation still running
 void keyRepeated(int keyCode)
          Notify panning 'thread' about key repeated events
 void quit()
          Quit panning 'thread'
 void run()
           
 void setMapComponent(com.nutiteq.ui.Pannable mapComponent)
          Will be called from library, after strategy has been entered into MapComponent or MapItem
 void startPanning(int directionX, int directionY, boolean panningWithKeys)
          Start panning with directions information.
 void stopPanning()
          Stop current pan action.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.nutiteq.ui.PanningStrategy
start
 

Constructor Detail

ThreadDrivenPanning

public ThreadDrivenPanning()
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

startPanning

public void startPanning(int directionX,
                         int directionY,
                         boolean panningWithKeys)
Description copied from interface: PanningStrategy
Start panning with directions information. Also notify if panning was started by key controls or some other event (for example on screen controls with stylus)

Specified by:
startPanning in interface PanningStrategy
Parameters:
directionX - change on x axis
directionY - change on y axis
panningWithKeys - has panning been started by key events

isPanning

public boolean isPanning()
Description copied from interface: PanningStrategy
Is panning implementation still running

Specified by:
isPanning in interface PanningStrategy
Returns:
if panning 'thread' is still working

stopPanning

public void stopPanning()
Description copied from interface: PanningStrategy
Stop current pan action.

Specified by:
stopPanning in interface PanningStrategy

quit

public void quit()
Description copied from interface: PanningStrategy
Quit panning 'thread'

Specified by:
quit in interface PanningStrategy

keyRepeated

public void keyRepeated(int keyCode)
Description copied from interface: PanningStrategy
Notify panning 'thread' about key repeated events

Specified by:
keyRepeated in interface PanningStrategy
Parameters:
keyCode - code for key repeated

setMapComponent

public void setMapComponent(com.nutiteq.ui.Pannable mapComponent)
Description copied from interface: PanningStrategy
Will be called from library, after strategy has been entered into MapComponent or MapItem

Specified by:
setMapComponent in interface PanningStrategy
Parameters:
mapComponent - map object on which to perform panning actions