com.jogamp.newt.event.MouseEvent Java Examples

The following examples show how to use com.jogamp.newt.event.MouseEvent. 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: SceneUIController.java    From jogl-samples with MIT License 6 votes vote down vote up
@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 #2
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Interface method implementation
 * 
 * @see com.jogamp.newt.event.MouseAdapter#mouseWheelMoved(com.jogamp.newt.event.MouseEvent)
 */
@Override
public void mouseWheelMoved(final MouseEvent pMouseEvent)
{
  if (mRenderer.notifyEyeRayListeners(mRenderer, pMouseEvent))
    return;

  final float[] lWheelRotation = pMouseEvent.getRotation();

  double lZoomWheelFactor = 0.0125f * mMouseWheelFactor;

  if (pMouseEvent.isMetaDown())
  {
    mRenderer.addFOV(lWheelRotation[1] * lZoomWheelFactor);
  }
  else
  {
    lZoomWheelFactor /= mRenderer.getFOV();
    mRenderer.addTranslationZ(lWheelRotation[1] * lZoomWheelFactor);
  }

  setSavedMousePosition(pMouseEvent);

  mRenderer.notifyChangeOfVolumeRenderingParameters();

}
 
Example #3
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Interface method implementation
 * 
 * @see com.jogamp.newt.event.MouseAdapter#mouseDragged(com.jogamp.newt.event.MouseEvent)
 */
@Override
public void mouseDragged(final MouseEvent pMouseEvent)
{
  if (mRenderer.notifyEyeRayListeners(mRenderer, pMouseEvent))
    return;

  handleArcBall(pMouseEvent);

  handleMoveLight(pMouseEvent);

  handleTranslation(pMouseEvent);
  handleGammaMinMax(pMouseEvent);
  handleAlphaBlending(pMouseEvent);
  mRenderer.notifyChangeOfVolumeRenderingParameters();

}
 
Example #5
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Interface method implementation
 * 
 * @see com.jogamp.newt.event.MouseAdapter#mouseClicked(com.jogamp.newt.event.MouseEvent)
 */
@Override
public void mouseClicked(final MouseEvent pMouseEvent)
{
  if (mRenderer.notifyEyeRayListeners(mRenderer, pMouseEvent))
    return;

  if (pMouseEvent.getClickCount() == 1)
  {
    handleGammaMinMax(pMouseEvent);

  }
  else if (pMouseEvent.getClickCount() == 2)
  {
    mRenderer.toggleFullScreen();
    mRenderer.notifyChangeOfVolumeRenderingParameters();
  }

}
 
Example #6
Source File: GPUUISceneGLListener0A.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
public void mouseDragged(final MouseEvent e) {
    final Object attachment = e.getAttachment();
    if( attachment instanceof UIShape.PointerEventInfo ) {
        final UIShape.PointerEventInfo shapeEvent = (UIShape.PointerEventInfo)attachment;
        if( e.getPointerCount() == 1 ) {
            // 1 pointer drag
            if(dragFirst) {
                dragFirstX = shapeEvent.objPos[0]; // e.getX();
                dragFirstY = shapeEvent.objPos[1]; // e.getY();
                dragFirst=false;
                return;
            }
            final float nx = shapeEvent.objPos[0]; // e.getX();
            final float ny = shapeEvent.objPos[1]; // e.getY();
            final float dx = nx - dragFirstX;
            final float dy = ny - dragFirstY;
            // final float dy = -(ny - dragLastY);
            shapeEvent.shape.translate(dx, dy, 0f);
            final float[] tx = shapeEvent.shape.getTranslate();
            actionText = String.format("Pos %6.2f / %6.2f / %6.2f", tx[0], tx[1], tx[2]);
        }
    }
}
 
Example #7
Source File: GPUUISceneGLListener0A.java    From jogl-samples with MIT License 6 votes vote down vote up
@Override
public void mouseWheelMoved(final MouseEvent e) {
    final Object attachment = e.getAttachment();
    if( attachment instanceof UIShape.PointerEventInfo ) {
        final UIShape.PointerEventInfo shapeEvent = (UIShape.PointerEventInfo)attachment;
        final boolean isOnscreen = PointerClass.Onscreen == e.getPointerType(0).getPointerClass();
        if( 0 == ( ~InputEvent.BUTTONALL_MASK & e.getModifiers() ) && !isOnscreen ) {
            // offscreen vertical mouse wheel zoom
            final float tz = 8f*e.getRotation()[1]; // vertical: wheel
            System.err.println("Rotate.Zoom.W: "+tz);
            shapeEvent.shape.translate(0f, 0f, tz);
        } else if( isOnscreen || e.isControlDown() ) {
            final float[] rot =  VectorUtil.scaleVec3(e.getRotation(), e.getRotation(), FloatUtil.PI / 180.0f);
            if( isOnscreen ) {
                System.err.println("XXX: "+e);
                // swap axis for onscreen rotation matching natural feel
                final float tmp = rot[0]; rot[0] = rot[1]; rot[1] = tmp;
                VectorUtil.scaleVec3(rot, rot, 2f);
            }
            shapeEvent.shape.getRotation().rotateByEuler( rot );
        }
    }
}
 
Example #8
Source File: CubeSample2.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
	switch(e.getButton()) {
	case MouseEvent.BUTTON1:
		animator.resume();
		System.out.println("button 1, left click");
		break;
	case MouseEvent.BUTTON2:
		System.out.println("button 2");
		break;
	case MouseEvent.BUTTON3:
		System.out.println("button 3, right click");
		willAnimatorPause  = true;
		animator.resume();
		break;
	}
}
 
Example #9
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
final void dispatchMouseEventPickShape(final MouseEvent e, final int glWinX, final int glWinY, final boolean setActive) {
    final float[] objPos = new float[3];
    final UIShape[] shape = { null };
    pickShape(glWinX, glWinY, objPos, shape, new Runnable() {
       public void run() {
           if( setActive ) {
               setActiveShape(shape[0]);
           }
           shape[0].dispatchMouseEvent(e, glWinX, glWinY, objPos);
       } } );
}
 
Example #10
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
final void dispatchMouseEventForShape(final UIShape shape, final MouseEvent e, final int glWinX, final int glWinY) {
    final float[] objPos = new float[3];
    windowToShapeCoords(shape, glWinX, glWinY, objPos, new Runnable() {
        public void run() {
            shape.dispatchMouseEvent(e, glWinX, glWinY, objPos);
        } } );
}
 
Example #11
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@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 #12
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the transfer function range.
 * 
 * @param pMouseEvent
 *          mouse event
 */
public void handleAlphaBlending(final MouseEvent pMouseEvent)
{
  if (mRenderer.getRenderAlgorithm(mRenderer.getCurrentRenderLayerIndex()) == RenderAlgorithm.MaxProjection
      && !pMouseEvent.isMetaDown()
      && !pMouseEvent.isShiftDown()
      && !pMouseEvent.isControlDown()
      && pMouseEvent.isAltDown()
      && !pMouseEvent.isAltGraphDown()
      && pMouseEvent.isButtonDown(1))
  {
    final double lWidth = mRenderer.getViewportWidth();
    final double nx = (pMouseEvent.getX()) / lWidth;

    final double lAlpha = 16 * pow(nx,2);

    mRenderer.setAlphaBlending(mRenderer.getCurrentRenderLayerIndex(),
                               lAlpha);
    // System.out.println(lAlpha);
  }

  /*
  System.out.println("_____________________________________");
  System.out.println("isAltDown=" + pMouseEvent.isAltDown());
  System.out.println("isAltGraphDown="
                     + pMouseEvent.isAltGraphDown());
  System.out.println("isControlDown="
                     + pMouseEvent.isControlDown());
  System.out.println("isMetaDown=" + pMouseEvent.isMetaDown());
  System.out.println("isShiftDown=" + pMouseEvent.isShiftDown());
  /**/

}
 
Example #13
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #14
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #15
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void mouseReleased(MouseEvent pMouseEvent)
{
  if (mRenderer.notifyEyeRayListeners(mRenderer, pMouseEvent))
    return;

  mRenderer.getAdaptiveLODController().notifyUserInteractionEnded();
  super.mouseReleased(pMouseEvent);

}
 
Example #16
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
final void dispatchMouseEvent(final MouseEvent e, final int glWinX, final int glWinY) {
    if( null == activeShape ) {
        dispatchMouseEventPickShape(e, glWinX, glWinY, true);
    } else {
        dispatchMouseEventForShape(activeShape, e, glWinX, glWinY);
    }
}
 
Example #17
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #18
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Interface method implementation
 * 
 * @see com.jogamp.newt.event.MouseAdapter#mouseMoved(com.jogamp.newt.event.MouseEvent)
 */
@Override
public void mouseMoved(final MouseEvent pMouseEvent)
{
  if (mRenderer.notifyEyeRayListeners(mRenderer, pMouseEvent))
    return;

  if (mMoveLightMode) // &&
    // mRenderer.getAdaptiveLODController().getNumberOfPasses()
    // == 1
    moveLight(pMouseEvent);

  setSavedMousePosition(pMouseEvent);
}
 
Example #19
Source File: MouseControl.java    From clearvolume with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void handleMoveLight(final MouseEvent pMouseEvent)
{

  if (!mMoveLightMode
      && mRenderer.getRenderAlgorithm(mRenderer.getCurrentRenderLayerIndex()) == RenderAlgorithm.IsoSurface
      && !pMouseEvent.isMetaDown()
      && !pMouseEvent.isShiftDown()
      && !pMouseEvent.isControlDown()
      && pMouseEvent.isAltDown()
      && !pMouseEvent.isAltGraphDown()
      && !pMouseEvent.isButtonDown(1))
  {
    moveLight(pMouseEvent);
  }
}
 
Example #20
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@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 #21
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@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 #22
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@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 #23
Source File: MouseHandler.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@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 #24
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@Override
public void mouseWheelMoved(final MouseEvent e) {
    // flip to GL window coordinates
    final int glWinX = lx;
    final int glWinY = viewport[3] - ly - 1;
    dispatchMouseEventPickShape(e, glWinX, glWinY, true);
}
 
Example #25
Source File: MouseHandler.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseMoved(MouseEvent e) {
	_lastX = e.getX();
	_lastY = e.getY();

	_window.setMouseX(_lastX);
	_window.setMouseY(_lastY);

	_listener.mouseMoved(_windowID, _lastX, _lastY);
}
 
Example #26
Source File: MouseHandler.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
@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 #27
Source File: SceneUIController.java    From jogl-samples with MIT License 5 votes vote down vote up
@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 #28
Source File: SceneUIController.java    From jogl-samples with MIT License 4 votes vote down vote up
@Override
public void mouseExited(final MouseEvent e) {
    release();
    clear();
}
 
Example #29
Source File: CameraControl.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
@Override
public void rawMouseEvent(MouseEvent me) {
}
 
Example #30
Source File: UIListenerBase01.java    From jogl-samples with MIT License 4 votes vote down vote up
public void mouseEntered(final MouseEvent e) {
}