Java Code Examples for com.jogamp.newt.event.MouseEvent#getAttachment()
The following examples show how to use
com.jogamp.newt.event.MouseEvent#getAttachment() .
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: GPUUISceneGLListener0A.java From jogl-samples with MIT License | 6 votes |
@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 2
Source File: GPUUISceneGLListener0A.java From jogl-samples with MIT License | 6 votes |
@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 ); } } }