Helper class used to implement all Mouse/Key Java listener and convert them into the vtkInteractor proper event. @authors Sebastien Jourdain - sebastien.jourdain@kitware.com, Kitware Inc 2012 Joachim Pouderoux - joachim.pouderoux@kitware.com, Kitware SAS 2012 @thanks This work was s
| 26 | * 15 avenue des Sablieres, CS 60001, 33116 Le Barp, France. |
| 27 | */ |
| 28 | public class vtkInteractorForwarder implements MouseListener, MouseMotionListener, MouseWheelListener, KeyListener { |
| 29 | final public static int MOUSE_BUTTON_1 = 1; |
| 30 | final public static int MOUSE_BUTTON_2 = 2; |
| 31 | final public static int MOUSE_BUTTON_3 = 4; |
| 32 | final public static int MOUSE_MODIFIER_SHIFT = 1; |
| 33 | final public static int MOUSE_MODIFIER_CTRL = 2; |
| 34 | final public static int MOUSE_MODIFIER_ALT = 4; |
| 35 | |
| 36 | private int lastX; |
| 37 | private int lastY; |
| 38 | private int ctrlPressed; |
| 39 | private int shiftPressed; |
| 40 | private vtkComponent<?> component; |
| 41 | private double updateRate, updateRateRelease; |
| 42 | private double scaleFactor = 1; |
| 43 | private ScheduledExecutorService scheduler; |
| 44 | private Runnable eventTick; |
| 45 | private vtkEventInterceptor eventInterceptor; |
| 46 | |
| 47 | public vtkInteractorForwarder(vtkComponent<?> component) { |
| 48 | this.component = component; |
| 49 | this.lastX = this.lastY = this.ctrlPressed = 0; |
| 50 | this.updateRate = 5.0; |
| 51 | this.updateRateRelease = 0.01; |
| 52 | this.scaleFactor = vtkInteractorForwarder.getDisplayScale(); |
| 53 | |
| 54 | this.eventTick = new Runnable() { |
| 55 | |
| 56 | public void run() { |
| 57 | vtkInteractorForwarder.this.component.getVTKLock().lock(); |
| 58 | vtkInteractorForwarder.this.component.getRenderWindowInteractor().TimerEvent(); |
| 59 | vtkInteractorForwarder.this.component.getVTKLock().unlock(); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | // Schedule time events |
| 64 | this.scheduler = Executors.newSingleThreadScheduledExecutor(); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Provide a custom event interceptor |
| 69 | * |
| 70 | * @param eventInterceptor |
| 71 | */ |
| 72 | public void setEventInterceptor(vtkEventInterceptor eventInterceptor) { |
| 73 | this.eventInterceptor = eventInterceptor; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @return the custom event interceptor if any otherwise return null |
| 78 | */ |
| 79 | public vtkEventInterceptor getEventInterceptor() { |
| 80 | return eventInterceptor; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Method called by VTK to start a timer |
| 85 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected