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


Java PInputEvent.getDeltaRelativeTo方法代码示例

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


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

示例1: handleMouseDragEvent

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
/**
 * Handle and event indicating that the user has dragged the mouse,
 * intending to move the marker.  This updates the position of the
 * marker and the values displayed.
 *
 * @param event
 */
private void handleMouseDragEvent( PInputEvent event ) {
    PNode draggedNode = event.getPickedNode();
    PDimension d = event.getDeltaRelativeTo( draggedNode );
    draggedNode.localToParent( d );
    double newXPos = _readoutRect.getOffset().getX() + d.width;
    double newCenterXPos = newXPos + ( _readoutRect.getFullBoundsReference().width / 2 );
    if ( newCenterXPos < _chart.getGraphOriginPos().getX() ) {
        // Limit the position from going too far to the left.
        newXPos = _chart.getGraphOriginPos().getX() - ( _readoutRect.getFullBoundsReference().width / 2 );
    }
    else if ( newCenterXPos > _chart.getGraphMaxX() ) {
        // Limit the position from going too far to the right.
        newXPos = _chart.getGraphMaxX() - ( _readoutRect.getFullBoundsReference().width / 2 );
    }
    _readoutRect.setOffset( newXPos, _readoutRect.getOffset().getY() );
    updateReadoutText();
    _indicatorHandle.setOffset( newXPos + _readoutRect.getWidth() / 2 - _indicatorHandle.getWidth() / 2,
                                _indicatorHandle.getOffset().getY() );
    _indicatorLine.setOffset( newXPos + _readoutRect.getWidth() / 2 - _indicatorLine.getWidth() / 2,
                              _readoutRect.getOffset().getY() + _readoutRect.getHeight() );

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:NuclearDecayProportionChart.java

示例2: handleMouseDragEvent

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void handleMouseDragEvent( PInputEvent event ) {

        // Only allow the user to move unbonded atoms.
        if ( m_model.getBondingState() != DualAtomModel.BONDING_STATE_UNBONDED ) {
            // Need to release the bond before we can move the atom.
            m_model.releaseBond();
        }

        // Determine the amount of motion indicated by the drag event.
        PNode draggedNode = event.getPickedNode();
        PDimension d = event.getDeltaRelativeTo( draggedNode );
        draggedNode.localToParent( d );

        // Make sure we don't exceed the positional limits.
        double newPosX = m_particle.getX() + d.width;
        if ( newPosX > m_maxX ) {
            newPosX = m_maxX;
        }
        else if ( newPosX < m_minX ) {
            newPosX = m_minX;
        }

        // Move the particle based on the amount of mouse movement.
        m_particle.setPosition( newPosX, m_particle.getY() );

    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:GrabbableParticleNode.java

示例3: handleMouseDragged

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void handleMouseDragged( PInputEvent event ) {
    PDimension pt = event.getDeltaRelativeTo( ProbeNode.this.getParent() );
    boolean movementAllowed = true;
    Rectangle2D boundaryRect = localToGlobal( _dragBounds.getFullBounds() );
    Rectangle2D probeRect = localToGlobal( _imageNode.getFullBounds() );

    // Only allow the probe to be moved if it is within the bounding
    // rectangle.  This prevents the probe from being dragged off the
    // canvas where the user can't recover it.
    if ( pt.width > 0 && probeRect.getMaxX() >= boundaryRect.getMaxX() ) {
        movementAllowed = false;
    }
    else if ( pt.width < 0 && probeRect.getMinX() <= boundaryRect.getMinX() ) {
        movementAllowed = false;
    }
    if ( pt.height > 0 && probeRect.getMaxY() >= boundaryRect.getMaxY() ) {
        movementAllowed = false;
    }
    else if ( pt.height < 0 && probeRect.getMinY() <= boundaryRect.getMinY() ) {
        movementAllowed = false;
    }
    if ( movementAllowed ) {
        // Move the probe in the model based on the user's dragging.
        _probeModel.translate( _mvt.viewToModelDifferentialX( pt.width ),
                               _mvt.viewToModelDifferentialY( pt.height ) );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:RadiometricDatingMeterNode.java

示例4: handleMouseDragEvent

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void handleMouseDragEvent(PInputEvent event){
	// Move the node as indicated by the drag event.
    PNode draggedNode = event.getPickedNode();
    PDimension d = event.getDeltaRelativeTo(draggedNode);
    draggedNode.localToParent(d);
    AtomicNucleus nucleus = getNucleusRef();
    double newPosX = nucleus.getPositionReference().getX() + d.getWidth();
    double newPosY = nucleus.getPositionReference().getY() + d.getHeight();
    nucleus.setPosition(newPosX, newPosY);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:GrabbableNucleusImageNode.java

示例5: mouseDragged

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
public void mouseDragged( PInputEvent event ) {
    super.mouseDragged( event );
    PDimension viewDelta = event.getDeltaRelativeTo( node.getParent() );
    Vector2D modelDelta = mvt.viewToModelDelta( new Vector2D( viewDelta ) );
    mass.translate( modelDelta );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:MassDragHandler.java

示例6: handleMouseDragEvent

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void handleMouseDragEvent( PInputEvent event ) {

        PNode draggedNode = event.getPickedNode();
        PDimension d = event.getDeltaRelativeTo( draggedNode );
        draggedNode.localToParent( d );
        m_mouseMovementAmount += d.getHeight();

        // Resize the container based on the amount that the node has moved.
        m_model.setTargetParticleContainerHeight( m_containerSizeAtDragStart - m_mouseMovementAmount );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:PointingHandNode.java

示例7: drag

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void drag(final PInputEvent event) {
    super.drag(event);
    final PDimension aDelta = event.getDeltaRelativeTo(PSWTHandle.this);
    if (aDelta.getWidth() != 0 || aDelta.getHeight() != 0) {
        dragHandle(aDelta, event);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PSWTHandle.java

示例8: drag

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
protected void drag(final PInputEvent event) {
    super.drag(event);
    final PDimension aDelta = event.getDeltaRelativeTo(PHandle.this);
    if (aDelta.getWidth() != 0 || aDelta.getHeight() != 0) {
        dragHandle(aDelta, event);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:PHandle.java

示例9: mouseDragged

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
public void mouseDragged( PInputEvent event ) {
    PDimension viewDelta = event.getDeltaRelativeTo( pNode.getParent() );
    Vector2D modelDelta = mvt.viewToModelDelta( new Vector2D( viewDelta ) );
    biomolecule.translate( modelDelta );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:BiomoleculeDragHandler.java

示例10: drag

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
@Override
protected void drag( final PInputEvent event ) {
    final PDimension d = event.getDeltaRelativeTo( dragNode );
    dragNode.localToParent( d );
    dragNode.setOffset( dragNode.getXOffset() + d.getWidth(), dragNode.getYOffset() + d.getHeight() );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:TestDetectorWire.java

示例11: handleSliderKnobDragEvent

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void handleSliderKnobDragEvent( PInputEvent event ) {

        PNode draggedNode = event.getPickedNode();
        PDimension d = event.getDeltaRelativeTo( draggedNode );
        draggedNode.localToParent( d );
        double movementAmount = d.getHeight();

        double knobMovementRange = zoomOutButton.getFullBoundsReference().getMinY()
                                   - zoomInButton.getFullBoundsReference().getMaxY();

        double zoomDelta = -movementAmount / knobMovementRange * ( maxZoom - minZoom );

        double newZoomValue = zoomable.getZoomFactor() + zoomDelta;

        newZoomValue = MathUtil.clamp( minZoom, newZoomValue, maxZoom );

        zoomable.setZoomFactor( newZoomValue );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:ZoomControl.java

示例12: getDelta

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private Dimension2D getDelta( PInputEvent event ) {
    Dimension2D dx = event.getDeltaRelativeTo( this );
    return dx;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:5,代码来源:MeasuringTape.java

示例13: EpsilonControlInteractionPotentialDiagram

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param sigma
 * @param epsilon
 * @param wide    - True if the widescreen version of the graph is needed, false if not.
 */
public EpsilonControlInteractionPotentialDiagram( double sigma, double epsilon, boolean wide,
                                                  final MultipleParticleModel model ) {

    super( sigma, epsilon, wide, true );

    this.m_model = model;
    model.addListener( new MultipleParticleModel.Adapter() {
        public void interactionStrengthChanged() {
            setLjPotentialParameters( m_model.getSigma(), m_model.getEpsilon() );
        }

        public void moleculeTypeChanged() {
            updateInteractivityState();
            drawPotentialCurve();
        }
    } );

    // Create the handler for events that indicate that the user is
    // changing the value of epsilon.
    PBasicInputEventHandler epsilonChangeHandler = new PBasicInputEventHandler() {
        public void mouseDragged( PInputEvent event ) {
            PNode draggedNode = event.getPickedNode();
            PDimension d = event.getDeltaRelativeTo( draggedNode );
            draggedNode.localToParent( d );
            double scaleFactor = StatesOfMatterConstants.MAX_EPSILON / ( getGraphHeight() / 2 );
            m_model.setEpsilon( m_model.getEpsilon() + d.getHeight() * scaleFactor );
        }
    };

    // Add the line that will indicate the value of epsilon.
    double epsilonLineLength = EPSILON_HANDLE_OFFSET_PROPORTION * m_width * 2.2;
    m_epsilonLine = new PPath( new Line2D.Double( -epsilonLineLength / 3, 0, epsilonLineLength / 2, 0 ) );
    m_epsilonLine.setStroke( EPSILON_LINE_STROKE );
    m_epsilonLine.setStrokePaint( EPSILON_LINE_COLOR );
    m_epsilonLine.addInputEventListener( new CursorHandler( Cursor.N_RESIZE_CURSOR ) );
    m_epsilonLine.addInputEventListener( epsilonChangeHandler );
    m_ljPotentialGraph.addChild( m_epsilonLine );

    // Add the arrow node that will allow the user to control the value of
    // the epsilon parameter.
    m_epsilonResizeHandle = new ResizeArrowNode( RESIZE_HANDLE_SIZE_PROPORTION * m_width, Math.PI / 2,
                                                 RESIZE_HANDLE_NORMAL_COLOR, RESIZE_HANDLE_HIGHLIGHTED_COLOR );
    m_ljPotentialGraph.addChild( m_epsilonResizeHandle );
    m_epsilonResizeHandle.addInputEventListener( epsilonChangeHandler );

    // Update interactivity state.
    updateInteractivityState();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:56,代码来源:EpsilonControlInteractionPotentialDiagram.java

示例14: mouseDragged

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
public void mouseDragged( PInputEvent event ) {
    PDimension delta = event.getDeltaRelativeTo( _node.getParent() );
    Point2D p = _modelElement.getPosition();
    Point2D pNew = new Point2D.Double( p.getX() + delta.getWidth(), p.getY() + delta.getHeight() );
    _modelElement.setPosition( pNew );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:BConnectionsManager.java

示例15: dragSpline

import edu.umd.cs.piccolo.event.PInputEvent; //导入方法依赖的package包/类
private void dragSpline( PInputEvent event ) {
    Point2D.Double tx = new Point2D.Double( event.getDeltaRelativeTo( this ).width, event.getDeltaRelativeTo( this ).height );
    dragSpline( event, tx );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:5,代码来源:SplineNode.java


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