当前位置: 首页>>代码示例>>Java>>正文


Java MouseEvent类代码示例

本文整理汇总了Java中com.jogamp.newt.event.MouseEvent的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent类的具体用法?Java MouseEvent怎么用?Java MouseEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MouseEvent类属于com.jogamp.newt.event包,在下文中一共展示了MouseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseReleased

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@Override
public void mouseReleased(MouseEvent e) {
    // called when a mouse button is waiting for release and was released

    // set the mouse state to released for the button
    int code = e.getButton();
    MouseButton mb = this.buttons.get(code);
    // check if the mouse event is in the map
    if (mb == null) {
        // if not, then add it
        mb = new MouseButton(code);
        this.buttons.put(code, mb);
    }
    mb.setPressed(false);
    mb.setWasReleased(true);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:17,代码来源:Mouse.java

示例2: mouseDragged

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
    // called when a mouse button is waiting for release and the mouse is moving

    // set the mouse location
    this.moved = true;
    this.location = new Point(e.getX(), e.getY());
    // set the mouse button pressed flag
    int code = e.getButton();
    MouseButton mb = this.buttons.get(code);
    // check if the mouse event is in the map
    if (mb == null) {
        // if not, then add it
        mb = new MouseButton(code);
        this.buttons.put(code, mb);
    }
    mb.setPressed(true);
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:19,代码来源:Mouse.java

示例3: mouseWheelMoved

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@Override
public void mouseWheelMoved(MouseEvent e) {
    Vec2d screenAnchor = new Vec2d(e.getX() / (double) view.getSize().x, e.getY() / (double) view.getSize().y);
    Vec2d worldAnchor = Rect2d.project(new Rect2d(1, 0, 0, 1), view.getViewportBounds(), screenAnchor);

    // set zoom
    double zoom = view.getZoomLevel();
    zoom += e.getRotation()[0] * e.getRotationScale() * zoomFactor;
    zoom += e.getRotation()[1] * e.getRotationScale() * zoomFactor;
    view.setZoomLevel(zoom);

    // update position
    Vec2d worldAtAnchorNow = Rect2d.project(new Rect2d(1, 0, 0, 1), view.getViewportBounds(), screenAnchor);
    Vec2d delta = Vec2d.sub(worldAtAnchorNow, worldAnchor);

    Vec3d vpos = view.getPosition();
    view.setPosition(vpos.x + delta.x, vpos.y + delta.y);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:19,代码来源:OrthoInputController.java

示例4: resolve

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
/**
 * Resolves the given event by distributing it to the overlays and the top-level controller. The
 * distribution-process stops as soon as any overlay fully consumes the event (i.e. the callback of this event
 * returns {@code true}) and thus blocks subsequent overlays from receiving this event.
 *
 * @param e        the event to resolveKeyEvent.
 * @param fn       the function to be executed for each overlay.
 * @param toplevel the top-level receiver of the event.
 */
private void resolve(MouseEvent e, MouseListenerFunction fn, Consumer<MouseEvent> toplevel) {
    ArrayList<MouseListener> listeners = getAllOverlays().stream()
            .filter(Overlay::isEnabled)
            .map(Overlay::getMouseListener)
            .filter(Objects::nonNull)
            .collect(Collectors.toCollection(ArrayList::new));

    for (int i = listeners.size() - 1; i >= 0; i--) {
        fn.call(listeners.get(i), e);
        if (e.isConsumed())
            return;
    }

    toplevel.accept(e);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:25,代码来源:TileBasedVisualization.java

示例5: mouseClicked

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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();
  }

}
 
开发者ID:ClearVolume,项目名称:ClearVolume,代码行数:24,代码来源:MouseControl.java

示例6: mouseDragged

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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();

}
 
开发者ID:ClearVolume,项目名称:ClearVolume,代码行数:22,代码来源:MouseControl.java

示例7: mouseWheelMoved

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
/**
 * 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();

}
 
开发者ID:ClearVolume,项目名称:ClearVolume,代码行数:31,代码来源:MouseControl.java

示例8: mousePressed

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@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();

}
 
开发者ID:ClearVolume,项目名称:ClearVolume,代码行数:23,代码来源:MouseControl.java

示例9: mouseDragged

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@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]);
        }
    }
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:25,代码来源:GPUUISceneGLListener0A.java

示例10: mouseWheelMoved

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@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 );
        }
    }
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:24,代码来源:GPUUISceneGLListener0A.java

示例11: gestureDetected

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@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);
                } } );
        }
    }
}
 
开发者ID:java-opengl-labs,项目名称:jogl-samples,代码行数:20,代码来源:SceneUIController.java

示例12: mouseReleased

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
public void mouseReleased(MouseEvent event) {
	lockEvents();
	GUIMouseEvent guiMouseEvent = mouseEventsPool.allocate();
	guiMouseEvent.setTime(System.currentTimeMillis());
	guiMouseEvent.setType(Type.MOUSE_RELEASED);
	guiMouseEvent.setX(event.getX());
	guiMouseEvent.setY(event.getY());
	guiMouseEvent.setButton(event.getButton());
	guiMouseEvent.setWheelX(event.getRotation()[0] * event.getRotationScale());
	guiMouseEvent.setWheelY(event.getRotation()[1] * event.getRotationScale());
	guiMouseEvent.setWheelZ(event.getRotation()[2] * event.getRotationScale());
	guiMouseEvent.setProcessed(false);
	mouseEvents.add(guiMouseEvent);
	unlockEvents();

	// add additional mouse moved event
	mouseMoved(event);
}
 
开发者ID:andreasdr,项目名称:tdme,代码行数:19,代码来源:GUI.java

示例13: mousePressed

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@Override
public void mousePressed(MouseEvent me) 
{        
    if (me.isButtonDown(MouseButtonCode.Left.ToAWTMouseButtonIndex()))
        m_LeftButtonStateRaw = MouseButtonState.JustPressed;
    
    if (me.isButtonDown(MouseButtonCode.Middle.ToAWTMouseButtonIndex()))
        m_MiddleButtonStateRaw = MouseButtonState.JustPressed;
    
    if (me.isButtonDown(MouseButtonCode.Right.ToAWTMouseButtonIndex()))
        m_RightButtonStateRaw = MouseButtonState.JustPressed;

}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:14,代码来源:MouseHandler.java

示例14: mouseReleased

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@Override
public void mouseReleased(MouseEvent me) 
{
    if (me.isButtonDown(MouseButtonCode.Left.ToAWTMouseButtonIndex()))
        m_LeftButtonStateRaw = MouseButtonState.JustReleased;
    
    if (me.isButtonDown(MouseButtonCode.Middle.ToAWTMouseButtonIndex()))
        m_MiddleButtonStateRaw = MouseButtonState.JustReleased;
    
    if (me.isButtonDown(MouseButtonCode.Right.ToAWTMouseButtonIndex()))
        m_RightButtonStateRaw = MouseButtonState.JustReleased;
 
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:14,代码来源:MouseHandler.java

示例15: mouseClicked

import com.jogamp.newt.event.MouseEvent; //导入依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    int code = e.getButton();
    MouseButton mb = this.buttons.get(code);
    // check if the mouse event is in the map
    if (mb == null) {
        // if not, then add it
        mb = new MouseButton(code);
        this.buttons.put(code, mb);
    }
    // set the value directly (since this can be a single/double/triple etc click)
    mb.setValue(e.getClickCount());
}
 
开发者ID:dmitrykolesnikovich,项目名称:featurea,代码行数:14,代码来源:Mouse.java


注:本文中的com.jogamp.newt.event.MouseEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。