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


Java PNode.globalToLocal方法代码示例

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


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

示例1: cameraToLocal

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Transforms the given point from camera coordinates to the node's local
 * system.
 * 
 * @param camera camera from which coordinates are measured
 * @param pt point to transform (will be modified)
 * @param node node from which local coordinates are measured
 */
private void cameraToLocal(final PCamera camera, final Point2D pt, final PNode node) {
    if (node != null) {
        if (descendsFromLayer(node)) {
            final AffineTransform inverse = invertTransform(camera.getViewTransform());
            inverse.transform(pt, pt);
        }

        node.globalToLocal(pt);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:PSwingEventHandler.java

示例2: accept

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Returns true if the node is an acceptable selection.
 * 
 * @param node node being tested
 * @return true if node is an acceptable selection
 */
public boolean accept(final PNode node) {
    localBounds.setRect(bounds);
    node.globalToLocal(localBounds);

    final boolean boundsIntersects = node.intersects(localBounds);
    final boolean isMarquee = node == marquee;
    return node.getPickable() && boundsIntersects && !isMarquee && !selectableParents.contains(node)
            && !isCameraLayer(node);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:PSelectionEventHandler.java

示例3: PHScaleCanvas

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public PHScaleCanvas( PHScaleModel model, Resettable resettable ) {
    super();
    setWorldTransformStrategy( new RenderingSizeStrategy( this, RENDERING_SIZE ) );
    setBackground( PHScaleConstants.CANVAS_BACKGROUND );

    Liquid liquid = model.getLiquid();

    // Root of our scene graph
    _rootNode = new PNode();
    addWorldChild( _rootNode );

    // Nodes
    _beakerControlNode = new BeakerControlNode( liquid, this );
    _pHControlNode = new PHControlNode( liquid, PHScaleConstants.LOG_TICKS_Y_SPACING );
    _graphControlNode = new GraphControlNode( liquid, PHScaleConstants.LOG_TICKS_Y_SPACING );
    _resetAllButton = new PHScaleResetAllButton( resettable, this );
    PSwing resetAllButtonWrapper = new PSwing( _resetAllButton );

    // Rendering order
    _rootNode.addChild( _beakerControlNode );
    _rootNode.addChild( _pHControlNode );
    _rootNode.addChild( _graphControlNode );
    _rootNode.addChild( resetAllButtonWrapper );

    // Layout
    // beaker at left
    _beakerControlNode.setOffset( 25, 15 );
    // pH control to right of beaker
    double x = _beakerControlNode.getFullBoundsReference().getMaxX() + 15;
    double y = _beakerControlNode.getFullBoundsReference().getY() + 56;
    _pHControlNode.setOffset( x, y );
    // Reset All button centered below pH control
    x = _pHControlNode.getFullBoundsReference().getX() + ( ( _pHControlNode.getFullBoundsReference().getWidth() - resetAllButtonWrapper.getFullBoundsReference().getWidth() ) / 2 );
    y = _pHControlNode.getFullBoundsReference().getMaxY() + 70;
    resetAllButtonWrapper.setOffset( x, y );
    // bar graph to right of pH control
    x = _pHControlNode.getFullBoundsReference().getMaxX() + 120;
    y = 10;
    _graphControlNode.setOffset( x, y );

    // Tweak the layout to align the pH slider ticks and bar graph log ticks
    Point2D sliderOffset = _rootNode.globalToLocal( _pHControlNode.getTickAlignmentGlobalOffset() );
    Point2D graphOffset = _rootNode.globalToLocal( _graphControlNode.getTickAlignmentGlobalOffset() );
    _pHControlNode.setOffset( _pHControlNode.getXOffset(), _pHControlNode.getYOffset() + ( graphOffset.getY() - sliderOffset.getY() ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:PHScaleCanvas.java

示例4: dragHandle

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Is invoked when the handle is being dragged.
 * 
 * @param aLocalDimension dimension representing the magnitude of the handle
 *            drag
 * @param aEvent event responsible for the call
 */
public void dragHandle(final PDimension aLocalDimension, final PInputEvent aEvent) {
    final PBoundsLocator l = (PBoundsLocator) getLocator();

    final PNode n = l.getNode();
    final PBounds b = n.getBounds();

    final PNode parent = getParent();
    if (parent != n && parent instanceof PCamera) {
        ((PCamera) parent).localToView(aLocalDimension);
    }

    localToGlobal(aLocalDimension);
    n.globalToLocal(aLocalDimension);

    final double dx = aLocalDimension.getWidth();
    final double dy = aLocalDimension.getHeight();

    switch (l.getSide()) {
        case SwingConstants.NORTH:
            b.setRect(b.x, b.y + dy, b.width, b.height - dy);
            break;

        case SwingConstants.SOUTH:
            b.setRect(b.x, b.y, b.width, b.height + dy);
            break;

        case SwingConstants.EAST:
            b.setRect(b.x, b.y, b.width + dx, b.height);
            break;

        case SwingConstants.WEST:
            b.setRect(b.x + dx, b.y, b.width - dx, b.height);
            break;

        case SwingConstants.NORTH_WEST:
            b.setRect(b.x + dx, b.y + dy, b.width - dx, b.height - dy);
            break;

        case SwingConstants.SOUTH_WEST:
            b.setRect(b.x + dx, b.y, b.width - dx, b.height + dy);
            break;

        case SwingConstants.NORTH_EAST:
            b.setRect(b.x, b.y + dy, b.width + dx, b.height - dy);
            break;

        case SwingConstants.SOUTH_EAST:
            b.setRect(b.x, b.y, b.width + dx, b.height + dy);
            break;
        default:
            throw new RuntimeException("Invalid side returned from PBoundsLocator");
    }

    boolean flipX = false;
    boolean flipY = false;

    if (b.width < 0) {
        flipX = true;
        b.width = -b.width;
        b.x -= b.width;
    }

    if (b.height < 0) {
        flipY = true;
        b.height = -b.height;
        b.y -= b.height;
    }

    if (flipX || flipY) {
        flipSiblingBoundsHandles(flipX, flipY);
    }

    n.setBounds(b);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:82,代码来源:PBoundsHandle.java


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