Java Code Examples for com.jogamp.newt.event.MouseEvent#getY()
The following examples show how to use
com.jogamp.newt.event.MouseEvent#getY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MouseControl.java From clearvolume with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void mousePressed(MouseEvent pMouseEvent) { if (mRenderer.notifyEyeRayListeners(mRenderer, pMouseEvent)) return; if (!pMouseEvent.isMetaDown() && !pMouseEvent.isShiftDown() && !pMouseEvent.isControlDown() && pMouseEvent.isButtonDown(1)) { final float lMouseX = pMouseEvent.getX(); final float lMouseY = pMouseEvent.getY(); mArcBall.setBounds(mRenderer.getViewportWidth(), mRenderer.getViewportHeight()); mArcBall.setCurrent(mRenderer.getQuaternion()); mArcBall.click(lMouseX, lMouseY); } mRenderer.getAdaptiveLODController() .notifyUserInteractionInProgress(); }
Example 2
Source File: SceneUIController.java From jogl-samples with MIT License | 6 votes |
@Override public void gestureDetected(final GestureEvent gh) { if( null != activeShape ) { // gesture .. delegate to active shape! final InputEvent orig = gh.getTrigger(); if( orig instanceof MouseEvent ) { final MouseEvent e = (MouseEvent) orig; // flip to GL window coordinates final int glWinX = e.getX(); final int glWinY = viewport[3] - e.getY() - 1; final float[] objPos = new float[3]; final UIShape shape = activeShape; windowToShapeCoords(shape, glWinX, glWinY, objPos, new Runnable() { public void run() { shape.dispatchGestureEvent(gh, glWinX, glWinY, objPos); } } ); } } }
Example 3
Source File: MouseControl.java From clearvolume with GNU Lesser General Public License v3.0 | 5 votes |
protected void handleArcBall(final MouseEvent pMouseEvent) { if (!pMouseEvent.isMetaDown() && !pMouseEvent.isShiftDown() && !pMouseEvent.isAltDown() && !pMouseEvent.isControlDown() && pMouseEvent.isButtonDown(1)) { final float lMouseX = pMouseEvent.getX(); final float lMouseY = pMouseEvent.getY(); mArcBall.setBounds(mRenderer.getViewportWidth(), mRenderer.getViewportHeight()); mRenderer.setQuaternion(mArcBall.drag(lMouseX, lMouseY)); } }
Example 4
Source File: MouseControl.java From clearvolume with GNU Lesser General Public License v3.0 | 5 votes |
private void moveLight(final MouseEvent pMouseEvent) { final float lMouseX = pMouseEvent.getX(); final float lMouseY = pMouseEvent.getY(); final float light[] = new float[3]; mArcBall.mapToSphere(lMouseX, lMouseY, light); mRenderer.setLightVector(light); }
Example 5
Source File: MouseControl.java From clearvolume with GNU Lesser General Public License v3.0 | 5 votes |
private void handleTranslation(final MouseEvent pMouseEvent) { final int dx = pMouseEvent.getX() - mSavedMouseX; final int dy = pMouseEvent.getY() - mSavedMouseY; // If the right button is held down, translate the object if (!pMouseEvent.isMetaDown() && !pMouseEvent.isControlDown() && (pMouseEvent.isButtonDown(3))) { mRenderer.addTranslationX(dx / 100.0f); mRenderer.addTranslationY(-dy / 100.0f); } setSavedMousePosition(pMouseEvent); }
Example 6
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
@Override public void mousePressed(final MouseEvent e) { if( -1 == lId || e.getPointerId(0) == lId ) { lx = e.getX(); ly = e.getY(); lId = e.getPointerId(0); } // flip to GL window coordinates final int glWinX = e.getX(); final int glWinY = viewport[3] - e.getY() - 1; dispatchMouseEvent(e, glWinX, glWinY); }
Example 7
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
@Override public void mouseReleased(final MouseEvent e) { // flip to GL window coordinates final int glWinX = e.getX(); final int glWinY = viewport[3] - e.getY() - 1; dispatchMouseEvent(e, glWinX, glWinY); if( 1 == e.getPointerCount() ) { // Release active shape: last pointer has been lifted! release(); clear(); } }
Example 8
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
@Override public void mouseClicked(final MouseEvent e) { // flip to GL window coordinates final int glWinX = e.getX(); final int glWinY = viewport[3] - e.getY() - 1; // activeId should have been released by mouseRelease() already! dispatchMouseEventPickShape(e, glWinX, glWinY, false); // Release active shape: last pointer has been lifted! release(); clear(); }
Example 9
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
@Override public void mouseDragged(final MouseEvent e) { // drag activeShape, if no gesture-activity, only on 1st pointer if( null != activeShape && !pinchToZoomGesture.isWithinGesture() && e.getPointerId(0) == lId ) { lx = e.getX(); ly = e.getY(); // dragged .. delegate to active shape! // flip to GL window coordinates final int glWinX = lx; final int glWinY = viewport[3] - ly - 1; dispatchMouseEventForShape(activeShape, e, glWinX, glWinY); } }
Example 10
Source File: SceneUIController.java From jogl-samples with MIT License | 5 votes |
@Override public void mouseMoved(final MouseEvent e) { if( -1 == lId || e.getPointerId(0) == lId ) { lx = e.getX(); ly = e.getY(); lId = e.getPointerId(0); } }
Example 11
Source File: MouseHandler.java From jaamsim with Apache License 2.0 | 5 votes |
@Override public void mousePressed(MouseEvent e) { _isDown[e.getButton()] = true; _startX = e.getX(); _startY = e.getY(); _lastX = e.getX(); _lastY = e.getY(); _listener.mouseButtonDown(_windowID, _lastX, _lastY, e.getButton(), true, modsFromEvent(e)); }
Example 12
Source File: MouseHandler.java From jaamsim with Apache License 2.0 | 5 votes |
@Override public void mouseMoved(MouseEvent e) { _lastX = e.getX(); _lastY = e.getY(); _window.setMouseX(_lastX); _window.setMouseY(_lastY); _listener.mouseMoved(_windowID, _lastX, _lastY); }
Example 13
Source File: MouseHandler.java From jaamsim with Apache License 2.0 | 5 votes |
@Override public void mouseDragged(MouseEvent e) { if (!_isDown[e.getButton()]) { return; // This should probably not happen, but just in case... } int deltaX = e.getX() - _lastX; int deltaY = e.getY() - _lastY; _lastX = e.getX(); _lastY = e.getY(); _window.setMouseX(_lastX); _window.setMouseY(_lastY); WindowInteractionListener.DragInfo dragInfo = new WindowInteractionListener.DragInfo(); dragInfo.windowID = _windowID; dragInfo.x = _lastX; dragInfo.y = _lastY; dragInfo.dx = deltaX; dragInfo.dy = deltaY; dragInfo.startX = _startX; dragInfo.startY = _startY; dragInfo.button = e.getButton(); dragInfo.modFlags = modsFromEvent(e); _listener.mouseDragged(dragInfo); }
Example 14
Source File: CursorOverlay.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean notifyEyeRay(ClearGLVolumeRenderer pRenderer, MouseEvent pMouseEvent, EyeRay pEyeRay) { if (!mMovable) return false; // System.out.println(pMouseEvent); final boolean lCorrectModifier = true; // pMouseEvent.isShiftDown(); final boolean lCorrectMouseButton = pMouseEvent.getButton() == 1; final boolean lCorrectMouseEvent = (pMouseEvent.getEventType() == MouseEvent.EVENT_MOUSE_CLICKED || pMouseEvent.getEventType() == MouseEvent.EVENT_MOUSE_DRAGGED); if (!(lCorrectMouseButton && lCorrectMouseEvent && lCorrectModifier)) return false; final float[] lX = new float[] { x, y, z }; final float[] lO2X = GLMatrix.clone(lX); GLMatrix.sub(lO2X, pEyeRay.org); final float lProjectionLength = GLMatrix.dot( lO2X, pEyeRay.dir); final float[] lClosestPoint = GLMatrix.clone(pEyeRay.dir); GLMatrix.mult(lClosestPoint, lProjectionLength); GLMatrix.add(lClosestPoint, pEyeRay.org); final float mx = pMouseEvent.getX(); final float my = pMouseEvent.getY(); // System.out.format("MX=%g MY=%g \n", mx, my); final double lDistance = sqrt((mx - px) * (mx - px) + (my - py) * (my - py)); // final float[] lCP2X = GLMatrix.clone(lX); // GLMatrix.distance(lCP2X, lClosestPoint); // final float lDistanceToClosestPoint = GLMatrix.norm(lCP2X); /*System.out.println(pEyeRay); System.out.println(Arrays.toString(lClosestPoint)); System.out.println("lDistanceToClosestPoint=" + lDistanceToClosestPoint); /**/ if (lDistance < getDistanceThreshold()) { x = clamp(lClosestPoint[0]); y = clamp(lClosestPoint[1]); z = clamp(lClosestPoint[2]); mHasChanged = true; return true; } return false; }
Example 15
Source File: ClearGLVolumeRenderer.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
/** * Notifies eye ray listeners. * * @param pRenderer * renderer that calls listeners * @param pMouseEvent * associated mouse event. * @return true if event captured */ public boolean notifyEyeRayListeners(ClearGLVolumeRenderer pRenderer, MouseEvent pMouseEvent) { if (mEyeRayListenerList.isEmpty()) return false; final int lX = pMouseEvent.getX(); final int lY = pMouseEvent.getY(); final GLMatrix lInverseModelViewMatrix = getModelViewMatrix().clone() .invert(); final GLMatrix lInverseProjectionMatrix = getClearGLWindow().getProjectionMatrix() .clone() .invert(); final GLMatrix lAspectRatioCorrectedProjectionMatrix = getAspectRatioCorrectedProjectionMatrix().invert(); // lInverseModelViewMatrix.transpose(); // lInverseProjectionMatrix.invert(); // lInverseProjectionMatrix.transpose(); final EyeRay lEyeRay = ScreenToEyeRay.convert(getViewportWidth(), getViewportHeight(), lX, lY, lInverseModelViewMatrix, lAspectRatioCorrectedProjectionMatrix); boolean lPreventOtherDisplayChanges = false; for (final EyeRayListener lEyeRayListener : mEyeRayListenerList) { lPreventOtherDisplayChanges |= lEyeRayListener.notifyEyeRay(pRenderer, pMouseEvent, lEyeRay); if (lPreventOtherDisplayChanges) break; } return lPreventOtherDisplayChanges; }
Example 16
Source File: MouseControl.java From clearvolume with GNU Lesser General Public License v3.0 | 4 votes |
private void setSavedMousePosition(final MouseEvent pMouseEvent) { mSavedMouseX = pMouseEvent.getX(); mSavedMouseY = pMouseEvent.getY(); }