/** * Add the correct event button types to the set according to the mouse event. * * @param event the mouse event * @param types the set of types * @throws NullPointerException if event or types is null */ public static void addButtonTypes(final ProxyMouseEvent event, final Set<CameraEventType> types) { // process the button number switch (event.getButton()) { case WHEEL: if (event.getWheelRotation() < 0) { types.add(CameraEventType.WHEEL_UP); } else if (event.getWheelRotation() > 0) { types.add(CameraEventType.WHEEL_DOWN); } else { types.add(CameraEventType.NONE); } break; case BUTTON1: types.add(CameraEventType.LEFT); break; case BUTTON2: types.add(CameraEventType.MIDDLE); break; case BUTTON3: types.add(CameraEventType.RIGHT); break; default: types.add(CameraEventType.NONE); break; } }
/** * Create a new camera event. * * @param camera camera that generated the event * @param event the mouse event * @return the new camera event * @throws NullPointerException if event is null */ public static CameraEvent newCameraEvent(final Camera camera, final ProxyMouseEvent event) { final Set<CameraEventType> types = EnumSet.noneOf(CameraEventType.class); ProxyCameraUtils.addButtonTypes(event, types); ProxyCameraUtils.addModifierTypes(event, types); final CameraEvent pickEvent = new CameraEvent( camera, event.getX(), event.getY(), Math.max(event.getClickCount(), Math.abs(event.getWheelRotation())), types); return pickEvent; }