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


Java PCamera.setViewTransform方法代码示例

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


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

示例1: animateCameraViewTransformTo

import org.piccolo2d.PCamera; //导入方法依赖的package包/类
/**
 * Animates the camera's view transform into the provided one over the
 * duration provided.
 * 
 * @param camera camera being animated
 * @param targetTransform the transform to which the camera's transform will
 *            be animated
 * @param duration the number of milliseconds the animation should last
 * 
 * @return an activity object that represents the animation
 */
protected PActivity animateCameraViewTransformTo(final PCamera camera, final AffineTransform targetTransform,
        final int duration) {
    boolean wasOldAnimation = false;

    // first stop any old animations.
    if (navigationActivity != null) {
        navigationActivity.terminate();
        wasOldAnimation = true;
    }

    if (duration == 0) {
        camera.setViewTransform(targetTransform);
        return null;
    }

    final AffineTransform source = camera.getViewTransformReference();

    if (source.equals(targetTransform)) {
        return null;
    }

    navigationActivity = camera.animateViewToTransform(targetTransform, duration);
    navigationActivity.setSlowInSlowOut(!wasOldAnimation);
    return navigationActivity;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:37,代码来源:PNavigationEventHandler.java

示例2: directCameraViewToFocus

import org.piccolo2d.PCamera; //导入方法依赖的package包/类
/**
 * Animates the Camera's view so that it contains the new focus node.
 * 
 * @param camera The camera to be animated
 * @param newFocus the node that will gain focus
 * @param duration number of milliseconds that animation should last for
 * 
 * @return an activity object representing the scheduled animation
 */
public PActivity directCameraViewToFocus(final PCamera camera, final PNode newFocus, final int duration) {
    focusNode = newFocus;
    final AffineTransform originalViewTransform = camera.getViewTransform();

    final PDimension d = new PDimension(1, 0);
    focusNode.globalToLocal(d);

    final double scaleFactor = d.getWidth() / camera.getViewScale();
    final Point2D scalePoint = focusNode.getGlobalFullBounds().getCenter2D();
    if (Math.abs(1f - scaleFactor) < SCALING_THRESHOLD) {
        camera.scaleViewAboutPoint(scaleFactor, scalePoint.getX(), scalePoint.getY());
    }

    // Pan the canvas to include the view bounds with minimal canvas
    // movement.
    camera.animateViewToPanToBounds(focusNode.getGlobalFullBounds(), 0);

    // Get rid of any white space. The canvas may be panned and
    // zoomed in to do this. But make sure not stay constrained by max
    // magnification.
    // fillViewWhiteSpace(aCamera);

    final AffineTransform resultingTransform = camera.getViewTransform();
    camera.setViewTransform(originalViewTransform);

    // Animate the canvas so that it ends up with the given
    // view transform.
    return animateCameraViewTransformTo(camera, resultingTransform, duration);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:39,代码来源:PNavigationEventHandler.java


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