本文整理汇总了Java中edu.umd.cs.piccolo.event.PInputEvent.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java PInputEvent.getPosition方法的具体用法?Java PInputEvent.getPosition怎么用?Java PInputEvent.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.event.PInputEvent
的用法示例。
在下文中一共展示了PInputEvent.getPosition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseDragged
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mouseDragged( PInputEvent e ) {
if( startLocation == null ) {
mousePressed( e );
}
else {
Point2D fin = e.getPosition();
Point2D.Double rel = new Point2D.Double( fin.getX() - startLocation.x, fin.getY() - startLocation.y );
double dx = rel.x;
double dy = rel.y;
int modelDX = (int)( dx / getColorGrid().getCellWidth() );
int modelDY = (int)( dy / getColorGrid().getCellHeight() );
int newWidth = origDim.width + modelDX;
int newHeight = origDim.height + modelDY;
newWidth = Math.max( newWidth, 0 );
newHeight = Math.max( newHeight, 0 );
rectangularObject.setSize( newWidth, newHeight );
}
}
示例2: mouseMoved
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mouseMoved( PInputEvent e ) {
super.mouseMoved( e );
Point2D mousePosition = e.getPosition();
if ( !_dragging && isInLens( mousePosition ) ) {
hiliteEigenstate( mousePosition );
}
}
示例3: mouseReleased
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mouseReleased( PInputEvent e ) {
super.mouseReleased( e );
if ( !_dragging ) {
Point2D mousePosition = e.getPosition();
if ( isInLens( mousePosition ) ) {
selectEigenstate( mousePosition );
}
}
_dragging = false;
}
示例4: setToolTipLocation
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void setToolTipLocation( ToolTipNode toolTipNode, PNode associatedNode, PInputEvent event ) {
Point2D pGlobal = event.getPosition();
Point2D pLocal = toolTipNode.getParent().globalToLocal( pGlobal );
double xOffset = pLocal.getX() - ( toolTipNode.getFullBoundsReference().getWidth() / 2 );
double yOffset = pLocal.getY() - toolTipNode.getFullBoundsReference().getHeight();
toolTipNode.setOffset( xOffset, yOffset );
}
示例5: mousePressed
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mousePressed( PInputEvent event ) {
_isDragging = true;
Point2D mousePosition = event.getPosition();
PNode node = event.getPickedNode();
Rectangle2D nodeBounds = getNodeBounds( node );
// Determine where we pressed relative to the node's upper left corner.
double x = mousePosition.getX() - nodeBounds.getX();
double y = mousePosition.getY() - nodeBounds.getY();
_pressedOffset.setLocation( x, y );
event.setHandled( _markAsHandled );
}
示例6: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void startDrag(final PInputEvent e) {
super.startDrag(e);
final Point2D p = e.getPosition();
// Create a new squiggle and add it to the canvas.
squiggle = new PPath();
squiggle.moveTo((float) p.getX(), (float) p.getY());
squiggle.setStroke(new BasicStroke((float) (1 / e.getCamera().getViewScale())));
canvas.getLayer().addChild(squiggle);
// Reset the keydboard focus.
e.getInputManager().setKeyboardFocus(null);
}
示例7: 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;
}
}
示例8: startDrag
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void startDrag( PInputEvent event ) {
super.startDrag( event );
origPosition = event.getPosition();
origOscLoc = new Point( oscillator.getCenterX(), oscillator.getCenterY() );
}
示例9: dragConstrainPoint
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void dragConstrainPoint( PInputEvent event ) {
Point2D mousePosition = event.getPosition();
PNode node = event.getPickedNode();
Rectangle2D nodeBounds = getNodeBounds( node );
/*
* Adjust the mouse location to account for where we clicked
* relative to the node's center point. We want the center
* of the node to remain in the bounds.
*/
double x = mousePosition.getX() - _pressedOffset.getX() + _nodeCenter.getX();
double y = mousePosition.getY() - _pressedOffset.getY() + _nodeCenter.getY();
_adjustedMousePosition.setLocation( x, y );
// Calculate dx
double dx = 0;
if ( _horizontalLockEnabled ) {
dx = 0;
}
else if ( _adjustedMousePosition.getX() < _dragBounds.getX() ) {
// move to far left
dx = _dragBounds.getX() - nodeBounds.getX() - _nodeCenter.getX();
}
else if ( _adjustedMousePosition.getX() > _dragBounds.getX() + _dragBounds.getWidth() ) {
// move to far right
dx = ( _dragBounds.getX() + _dragBounds.getWidth() ) - nodeBounds.getX() - _nodeCenter.getX();
}
else {
// follow mouse
dx = mousePosition.getX() - nodeBounds.getX() - _pressedOffset.getX();
}
// Calculate dy
double dy = 0;
if ( _verticalLockEnabled ) {
dy = 0;
}
else if ( _adjustedMousePosition.getY() < _dragBounds.getY() ) {
// move to top
dy = _dragBounds.getY() - nodeBounds.getY() - _nodeCenter.getY();
}
else if ( _adjustedMousePosition.getY() > _dragBounds.getY() + _dragBounds.getHeight() ) {
// move to bottom
dy = ( _dragBounds.getY() + _dragBounds.getHeight() ) - nodeBounds.getY() - _nodeCenter.getY();
}
else {
// follow mouse
dy = mousePosition.getY() - nodeBounds.getY() - _pressedOffset.getY();
}
// Perform the drag
if ( dx != 0 || dy != 0 ) {
node.translate( dx, dy );
}
}
示例10: dragConstrainBounds
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void dragConstrainBounds( PInputEvent event ) {
Point2D mousePosition = event.getPosition();
PNode node = event.getPickedNode();
Rectangle2D nodeBounds = getNodeBounds( node );
/*
* Adjust the mouse location to account for where we clicked
* relative to the node's upper left corner.
*/
double x = mousePosition.getX() - _pressedOffset.getX();
double y = mousePosition.getY() - _pressedOffset.getY();
_adjustedMousePosition.setLocation( x, y );
// Calculate dx
double dx = 0;
if ( _horizontalLockEnabled ) {
dx = 0;
}
else if ( _adjustedMousePosition.getX() < _dragBounds.getX() ) {
// move to far left
dx = _dragBounds.getX() - nodeBounds.getX();
}
else if ( _adjustedMousePosition.getX() + nodeBounds.getWidth() > _dragBounds.getX() + _dragBounds.getWidth() ) {
// move to far right
dx = ( _dragBounds.getX() + _dragBounds.getWidth() - nodeBounds.getWidth() ) - nodeBounds.getX();
}
else {
// follow mouse
dx = mousePosition.getX() - nodeBounds.getX() - _pressedOffset.getX();
}
// Calculate dy
double dy = 0;
if ( _verticalLockEnabled ) {
dy = 0;
}
else if ( _adjustedMousePosition.getY() < _dragBounds.getY() ) {
// move to top
dy = _dragBounds.getY() - nodeBounds.getY();
}
else if ( _adjustedMousePosition.getY() + nodeBounds.getHeight() > _dragBounds.getY() + _dragBounds.getHeight() ) {
// move to bottom
dy = ( _dragBounds.getY() + _dragBounds.getHeight() - nodeBounds.getHeight() ) - nodeBounds.getY();
}
else {
// follow mouse
dy = mousePosition.getY() - nodeBounds.getY() - _pressedOffset.getY();
}
// Perform the drag
if ( dx != 0 || dy != 0 ) {
node.translate( dx, dy );
}
}
示例11: updateSquiggle
import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void updateSquiggle(final PInputEvent aEvent) {
// Add a new segment to the squiggle from the last mouse position
// to the current mouse position.
final Point2D p = aEvent.getPosition();
squiggle.lineTo((float) p.getX(), (float) p.getY());
}
示例12: 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();
}