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


Java PInputEvent.getCanvasPosition方法代码示例

本文整理汇总了Java中edu.umd.cs.piccolo.event.PInputEvent.getCanvasPosition方法的典型用法代码示例。如果您正苦于以下问题:Java PInputEvent.getCanvasPosition方法的具体用法?Java PInputEvent.getCanvasPosition怎么用?Java PInputEvent.getCanvasPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.piccolo.event.PInputEvent的用法示例。


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

示例1: mouseDragged

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mouseDragged( PInputEvent e ) {
        if ( System.currentTimeMillis() - lastDragTime >= thresholdMillis ) {//you waited too long, now have to start dragging again.
            resetDragging();
        }
        if ( lastPressLocation == null ) {
            lastPressLocation = e.getCanvasPosition();
        }
        double dx = Math.abs( lastPressLocation.getX() - e.getCanvasPosition().getX() );
        double dy = Math.abs( lastPressLocation.getY() - e.getCanvasPosition().getY() );
        if ( dx >= thresholdX && dy >= thresholdY ) {
            isDragging = true;
        }
        if ( isDragging ) {
//            System.out.println( "mouse dragged" + e );
            target.mouseDragged( e );
        }
        lastDragTime = System.currentTimeMillis();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:ThresholdedPDragAdapter.java

示例2: mouseDragged

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void mouseDragged( PInputEvent pInputEvent ) {
        Point2D pt = pInputEvent.getCanvasPosition();
//        Point2D o=getViewOrigin();
        Point2D o = getViewOrigin();
        localToGlobal( o );
        rampPanel.getCamera().globalToLocal( o );
//        Point2D pt = pInputEvent.getPositionRelativeTo( this );
////        localToGlobal( pt );
//        Point2D o = ramp.getOrigin();
////        localToGlobal( o );
////        pt = getRampWorld().convertToWorld( pt );
//        System.out.println( "o = " + o );
//        System.out.println( "pt = " + pt );
        MutableVector2D vec = new MutableVector2D( o, pt );

        System.out.println( "vec = " + vec );
        double angle = -vec.getAngle();
        System.out.println( "angle = " + angle );
        angle = MathUtil.clamp( 0, angle, Math.PI / 2.0 );
        ramp.setAngle( angle );
        rampPanel.getRampModule().record();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:SurfaceGraphic.java

示例3: drag

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void drag( PInputEvent event ) {
    Point2D pos = event.getCanvasPosition();
    double latticeDX = latticeScreenCoordinates.toLatticeCoordinatesDifferentialX( pos.getX() - dragStartPt.getX() );
    double latticeDY = latticeScreenCoordinates.toLatticeCoordinatesDifferentialY( pos.getY() - dragStartPt.getY() );
    if ( changeStart ) {
        wallPotential.setSrcPoint( new Point( origStart.x + (int) latticeDX, origStart.y + (int) latticeDY ) );
    }
    if ( changeEnd ) {
        wallPotential.setDstPoint( new Point( origEnd.x + (int) latticeDX, origEnd.y + (int) latticeDY ) );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:WallPotentialGraphic.java

示例4: initializeSelection

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
/**
 * Starts a selection based on the provided event.
 * 
 * @param pie event used to populate the selection
 */
protected void initializeSelection(final PInputEvent pie) {
    canvasPressPt = pie.getCanvasPosition();
    presspt = pie.getPosition();
    pressNode = pie.getPath().getPickedNode();
    if (pressNode instanceof PCamera) {
        pressNode = null;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:PSelectionEventHandler.java

示例5: mousePressed

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mousePressed( PInputEvent e ) {
    lastPressLocation = e.getCanvasPosition();
    target.mousePressed( e );
    lastDragTime = System.currentTimeMillis();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:ThresholdedPDragAdapter.java

示例6: startDrag

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void startDrag( PInputEvent event ) {
    super.startDrag( event );
    this.dragStartPt = event.getCanvasPosition();
    origStart = wallPotential.getSource();
    origEnd = wallPotential.getDestination();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:WallPotentialGraphic.java

示例7: getPosition

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private static Point2D getPosition( PInputEvent event ) {
    return event.getCanvasPosition();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:SimSharingDragHandler.java

示例8: initializeSelection

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void initializeSelection(final PInputEvent pie) {
    super.initializeSelection(pie);
    pressPt = pie.getPosition();
    canvasPressPt = pie.getCanvasPosition();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:PSWTSelectionEventHandler.java


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