本文整理汇总了Java中com.jogamp.newt.event.MouseEvent.getX方法的典型用法代码示例。如果您正苦于以下问题:Java MouseEvent.getX方法的具体用法?Java MouseEvent.getX怎么用?Java MouseEvent.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.newt.event.MouseEvent
的用法示例。
在下文中一共展示了MouseEvent.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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();
}
示例4: 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);
} } );
}
}
}
示例5: mouseDragged
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
int x = e.getX();
int y = e.getY();
double scale = view.getScale();
double diffX = (x - prevX) * (1.0 / scale);
double diffY = (y - prevY) * (1.0 / scale);
Vec3d pos = view.getPosition();
view.setPosition(pos.x - diffX, pos.y + diffY);
prevX = x;
prevY = y;
}
示例6: mouseDragged
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
int x = e.getX() - lastX;
int y = e.getY() - lastY;
lastX = e.getX();
lastY = e.getY();
Vec2 pan = camera.getCurrentTranslation();
double m = 2. * camera.getWidth() / Displayer.getActiveViewport().height;
camera.setCurrentTranslation(pan.x + x * m, pan.y - y * m);
Displayer.render(0.5);
}
示例7: mouseMoved
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
if (Displayer.getUpdateViewpoint() == UpdateViewpoint.equatorial) {
mouseX = e.getX();
mouseY = e.getY();
Camera camera = Displayer.getCamera();
Vec3 v = CameraHelper.getVectorFromPlane(camera, Displayer.getActiveViewport(), mouseX, mouseY, Quat.ZERO, true);
if (v == null)
return;
double width = camera.getWidth(), minDist = 10;
String name = null;
for (Map.Entry<LoadPosition, Position.L> entry : UpdateViewpoint.equatorial.getPositions()) {
Position.L p = entry.getValue();
double deltaX = Math.abs(p.rad * Math.cos(p.lon) - v.x);
double deltaY = Math.abs(p.rad * Math.sin(p.lon) - v.y);
double dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY) / width;
if (dist < minDist) {
minDist = dist;
name = entry.getKey().getTarget().toString();
}
}
if (!text.isEmpty()) {
text.clear();
Displayer.display();
}
if (minDist < 0.01) {
text.add(name);
Displayer.display();
}
}
}
示例8: handleArcBall
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
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));
}
}
示例9: moveLight
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
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);
}
示例10: handleTranslation
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
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);
}
示例11: handleAlphaBlending
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
/**
* 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());
/**/
}
示例12: mousePressed
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@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);
}
示例13: mouseReleased
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@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();
}
}
示例14: mouseClicked
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@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();
}
示例15: mouseDragged
import com.jogamp.newt.event.MouseEvent; //导入方法依赖的package包/类
@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);
}
}