本文整理汇总了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;
}
示例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);
}