本文整理汇总了Java中edu.umd.cs.piccolo.event.PInputEvent.getPositionRelativeTo方法的典型用法代码示例。如果您正苦于以下问题:Java PInputEvent.getPositionRelativeTo方法的具体用法?Java PInputEvent.getPositionRelativeTo怎么用?Java PInputEvent.getPositionRelativeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.event.PInputEvent
的用法示例。
在下文中一共展示了PInputEvent.getPositionRelativeTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override protected void drag( final PInputEvent event ) {
super.drag( event );
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
final double viewX = pMouse.getX() - clickXOffset;
final double viewY = pMouse.getY() - clickYOffset;
Vector2D pView = constrainToBounds( viewX, viewY );
point.set( mvt.viewToModel( pView ) );
Vector2D pModel = mvt.viewToModel( pView );
if ( graph.contains( point.get() ) ) {
// snap to the grid
point.set( new Vector2D( MathUtil.roundHalfUp( pModel.getX() ), MathUtil.roundHalfUp( pModel.getY() ) ) );
}
else {
point.set( pModel );
}
}
示例2: drag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override protected void drag( final PInputEvent event ) {
super.drag( event );
boolean wasInSolution = paper.isInSolution();
// adjust location
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
double x = pMouse.getX() - clickXOffset;
double y = pMouse.getY() - clickYOffset;
paper.setLocation( x, y );
// send a sim-sharing event when the paper transitions between in/out of solution.
if ( wasInSolution != paper.isInSolution() ) {
SimSharingManager.sendUserMessage( userComponent, UserComponentTypes.sprite, UserActions.drag, ParameterSet.parameterSet( ParameterKeys.isInSolution, paper.isInSolution() ) );
}
}
示例3: mouseDragged
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mouseDragged( PInputEvent event ) {
//Make sure we started the drag already
if ( relativeGrabPoint == null ) {
updateGrabPoint( event );
}
//Compute the targeted model point for the drag
final Point2D newDragPosition = event.getPositionRelativeTo( node.getParent() );
Point2D modelPt = transform.viewToModel( newDragPosition.getX() - relativeGrabPoint.getX(),
newDragPosition.getY() - relativeGrabPoint.getY() );
//Find the constrained point for the targeted model point and apply it
Point2D constrained = constraint.apply( modelPt );
sendMessage( constrained );
setModelPosition( constrained );
}
示例4: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void startDrag( PInputEvent event ) {
super.startDrag( event );
// note the offset between the mouse click and the knob's origin
Point2D pMouseLocal = event.getPositionRelativeTo( GraphNode.this );
Point2D pMouseGlobal = GraphNode.this.localToGlobal( pMouseLocal );
Point2D pKnobGlobal = GraphNode.this.localToGlobal( event.getPickedNode().getOffset() );
_globalClickYOffset = pMouseGlobal.getY() - pKnobGlobal.getY();
}
示例5: mousePressed
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mousePressed( PInputEvent event ) {
mousePressed = true;
if ( launcher.isEnabled() ) {
temperatureBeingAdjusted = true;
originalAngle = launcher.getTheta();
originalR = launcher.getExtension();
this.startPoint = event.getPositionRelativeTo( LauncherGraphic.this.getParent() );
}
}
示例6: drag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
protected void drag( final PInputEvent event ) {
super.drag( event );
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
double yView = pMouse.getY() - clickYOffset;
double yModel = MathUtil.clamp( 2 * mvt.viewToModelDelta( 0, -yView ).getY(), valueRange );
capacitor.setPlateSeparation( yModel );
}
示例7: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override protected void startDrag( PInputEvent event ) {
super.startDrag( event );
// note the offset between the mouse click and the knob's origin
Point2D pMouseLocal = event.getPositionRelativeTo( relativeNode );
Point2D pMouseGlobal = relativeNode.localToGlobal( pMouseLocal );
Point2D pKnobGlobal = relativeNode.localToGlobal( thumbNode.getOffset() );
globalClickXOffset = pMouseGlobal.getX() - pKnobGlobal.getX() + trackNode.getXOffset();
globalClickYOffset = pMouseGlobal.getY() - pKnobGlobal.getY() + trackNode.getYOffset();
}
示例8: drag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
protected void drag( final PInputEvent event ) {
super.drag( event );
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
double xView = pMouse.getX() - clickXOffset;
double yView = pMouse.getY() - clickYOffset;
locationProperty.set( mvt.viewToModel( xView, yView ) );
}
示例9: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void startDrag( PInputEvent event ) {
if ( sliderNode.isEnabled() ) {
super.startDrag( event );
// note the offset between the mouse click and the knob's origin
Point2D pMouseLocal = event.getPositionRelativeTo( sliderNode );
Point2D pMouseGlobal = sliderNode.localToGlobal( pMouseLocal );
Point2D pThumbGlobal = sliderNode.localToGlobal( sliderNode.getThumbNode().getOffset() );
_globalClickXOffset = pMouseGlobal.getX() - pThumbGlobal.getX();
}
}
示例10: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
protected void startDrag( PInputEvent event ) {
super.startDrag( event );
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
Point2D pOrigin = mvt.modelToViewDelta( -capacitor.getPlateWidth() / 2, 0, -capacitor.getPlateWidth() / 2 );
clickXOffset = pMouse.getX() - pOrigin.getX();
}
示例11: drag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
protected void drag( PInputEvent event ) {
super.drag( event );
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
double plateWidth = getPlateWidth( pMouse );
capacitor.setPlateWidth( plateWidth );
}
示例12: changeZeroPoint
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void changeZeroPoint( PInputEvent pEvent ) {
// pEvent.getca
// Point pt = rampWorld.convertToWorld( pEvent.getPosition() );
Point2D pt = pEvent.getPositionRelativeTo( rampWorld );
double zeroPointY = rampPanel.getRampGraphic().getScreenTransform().viewToModelY( pt.getY() );
rampPhysicalModel.setZeroPointY( zeroPointY );
}
示例13: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override protected void startDrag( PInputEvent event ) {
super.startDrag( event );
// Note the mouse-click offset when dragging starts.
Point2D pMouse = event.getPositionRelativeTo( dragNode.getParent() );
clickXOffset = pMouse.getX() - mvt.modelToViewX( point.get().getX() );
clickYOffset = pMouse.getY() - mvt.modelToViewY( point.get().getY() );
// Move the tool that we're dragging to the foreground.
dragNode.moveToFront();
}
示例14: drag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override protected void drag( PInputEvent event ) {
super.drag( event );
Point2D pMouse = event.getPositionRelativeTo( manipulatorNode.getParent() );
// constrain to range, snap to grid
double y1 = MathUtil.roundHalfUp( MathUtil.clamp( mvt.viewToModelDeltaY( pMouse.getY() - clickYOffset ), y1Range.get() ) );
// Keep slope constant, change y1.
line.set( Line.createSlopeIntercept( line.get().rise, line.get().run, y1, line.get().color ) );
}
示例15: updateGrabPoint
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void updateGrabPoint( PInputEvent event ) {
Point2D viewStartingPoint = event.getPositionRelativeTo( node.getParent() );
Vector2D viewCoordinateOfObject = transform.modelToView( modelLocation.get() );
relativeGrabPoint = new Point2D.Double( viewStartingPoint.getX() - viewCoordinateOfObject.getX(), viewStartingPoint.getY() - viewCoordinateOfObject.getY() );
}