本文整理汇总了Java中org.piccolo2d.util.PAffineTransform类的典型用法代码示例。如果您正苦于以下问题:Java PAffineTransform类的具体用法?Java PAffineTransform怎么用?Java PAffineTransform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PAffineTransform类属于org.piccolo2d.util包,在下文中一共展示了PAffineTransform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocalToGlobalTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
/**
* Return the transform that converts local coordinates at this node to the
* global coordinate system.
*
* @param dest PAffineTransform to transform to global coordinates
* @return The concatenation of transforms from the top node down to this
* node.
*/
public PAffineTransform getLocalToGlobalTransform(final PAffineTransform dest) {
PAffineTransform result = dest;
if (parent != null) {
result = parent.getLocalToGlobalTransform(result);
if (transform != null) {
result.concatenate(transform);
}
}
else if (dest == null) {
result = getTransform();
}
else if (transform != null) {
result.setTransform(transform);
}
else {
result.setToIdentity();
}
return result;
}
示例2: testAnimateToPositionScaleRotationHasProperSetup
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testAnimateToPositionScaleRotationHasProperSetup() {
node.setBounds(0, 0, 100, 100);
final PTransformActivity activity = node.animateToPositionScaleRotation(50, 50, 0.5, Math.PI, 50);
assertEquals(50, activity.getDuration());
assertEquals(PUtil.DEFAULT_ACTIVITY_STEP_RATE, activity.getStepRate());
assertTrue(activity.getFirstLoop());
assertFalse(activity.isStepping());
final double[] resultTransform = activity.getDestinationTransform();
final PAffineTransform expected = new PAffineTransform();
expected.translate(50, 50);
expected.scale(0.5, 0.5);
expected.rotate(Math.PI);
assertEquals(-0.5, resultTransform[0], 0.001);
assertEquals(0, resultTransform[1], 0.001);
assertEquals(0, resultTransform[2], 0.001);
assertEquals(-0.5, resultTransform[3], 0.001);
assertEquals(50.0, resultTransform[4], 0.001);
assertEquals(50.0, resultTransform[5], 0.001);
}
示例3: testAnimateToRelativePositionResultsInProperTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testAnimateToRelativePositionResultsInProperTransform() {
final PCanvas canvas = new PCanvas();
final PNode A = new PNode();
A.setBounds(0, 0, 50, 50);
canvas.getLayer().addChild(A);
final PNode B = new PNode();
B.setBounds(0, 0, 100, 100);
B.setOffset(100, 100);
canvas.getLayer().addChild(B);
final Point2D srcPt = new Point2D.Double(1.0, 0.0);
final Point2D destPt = new Point2D.Double(0.0, 0.0);
A.animateToRelativePosition(srcPt, destPt, B.getGlobalBounds(), 0);
final PAffineTransform expectedTransform = new PAffineTransform();
expectedTransform.translate(50, 100);
assertEquals(expectedTransform, A.getTransform());
}
示例4: invertTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
/**
* Returns the inverse transform for the provided transform. Throws
* exception if transform is non invertible.
*
* @param transform transform to invert
* @return inverted transform
*/
private AffineTransform invertTransform(final PAffineTransform transform) {
try {
return transform.createInverse();
}
catch (final NoninvertibleTransformException e) {
throw new PAffineTransformException(e, transform);
}
}
示例5: PCamera
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
/**
* Create a new camera with an empy list of layers.
*/
public PCamera() {
super();
viewTransform = new PAffineTransform();
layers = new ArrayList/*<PLayer>*/();
viewConstraint = VIEW_CONSTRAINT_NONE;
}
示例6: computeGlobalTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
private PAffineTransform computeGlobalTransform(final PNode node) {
if (node == null) {
return new PAffineTransform();
}
final PAffineTransform parentGlobalTransform = computeGlobalTransform(node.parent);
if (node.transform != null) {
parentGlobalTransform.concatenate(node.transform);
}
return parentGlobalTransform;
}
示例7: getGlobalToLocalTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
/**
* Return the transform that converts global coordinates to local
* coordinates of this node.
*
* @param dest PAffineTransform to transform from global to local
*
* @return The inverse of the concatenation of transforms from the root down
* to this node.
*/
public PAffineTransform getGlobalToLocalTransform(final PAffineTransform dest) {
PAffineTransform result = getLocalToGlobalTransform(dest);
try {
result.setTransform(result.createInverse());
}
catch (final NoninvertibleTransformException e) {
throw new PAffineTransformException(e, result);
}
return result;
}
示例8: getTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
/**
* Return a copy of the transform associated with this node.
*
* @return copy of this node's transform
*/
public PAffineTransform getTransform() {
if (transform == null) {
return new PAffineTransform();
}
else {
return (PAffineTransform) transform.clone();
}
}
示例9: getInverseTransform
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
/**
* Return an inverted copy of the transform associated with this node.
*
* @return inverted copy of this node's transform
*/
public PAffineTransform getInverseTransform() {
if (transform == null) {
return new PAffineTransform();
}
try {
return new PAffineTransform(transform.createInverse());
}
catch (final NoninvertibleTransformException e) {
throw new PAffineTransformException(e, transform);
}
}
示例10: testLocalToGlobal
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testLocalToGlobal() {
final PNode aParent = new PNode();
final PNode aChild = new PNode();
aParent.addChild(aChild);
aChild.scale(0.5);
// bounds
final PBounds bnds = new PBounds(0, 0, 50, 50);
aChild.localToGlobal(bnds);
assertEquals(0, bnds.x, 0);
assertEquals(0, bnds.y, 0);
assertEquals(25, bnds.width, 0);
assertEquals(25, bnds.height, 0);
aChild.globalToLocal(bnds);
assertEquals(0, bnds.x, 0);
assertEquals(0, bnds.y, 0);
assertEquals(50, bnds.width, 0);
assertEquals(50, bnds.height, 0);
aChild.getGlobalToLocalTransform(new PAffineTransform());
aChild.getLocalToGlobalTransform(new PAffineTransform()).createTransformedShape(aChild.getBounds());
// dimensions
final PDimension dim = new PDimension(50, 50);
aChild.localToGlobal(dim);
assertEquals(25, dim.getHeight(), 0);
assertEquals(25, dim.getWidth(), 0);
aChild.globalToLocal(dim);
assertEquals(50, dim.getHeight(), 0);
assertEquals(50, dim.getWidth(), 0);
}
示例11: testAnimateTransformToBoundsWithDuration0IsImmediate
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testAnimateTransformToBoundsWithDuration0IsImmediate() {
node.setBounds(0, 0, 100, 100);
final PActivity activity = node.animateTransformToBounds(0, 0, 10, 10, 0);
assertNull(activity);
final PAffineTransform transform = node.getTransform();
assertEquals(0.1, transform.getScale(), 0.0001);
}
示例12: testAnimateToPositionScaleRotationWithDuration0IsImmediate
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testAnimateToPositionScaleRotationWithDuration0IsImmediate() {
node.setBounds(0, 0, 100, 100);
final PActivity activity = node.animateToPositionScaleRotation(50, 50, 0.5, Math.PI, 0);
assertNull(activity);
final PAffineTransform resultTransform = node.getTransform();
final PAffineTransform expected = new PAffineTransform();
expected.translate(50, 50);
expected.scale(0.5, 0.5);
expected.rotate(Math.PI);
assertEquals(expected, resultTransform);
}
示例13: testRotateAboutPointVersion1AffectsTransformAsItShould
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testRotateAboutPointVersion1AffectsTransformAsItShould() {
node.setBounds(25, 25, 50, 50);
node.rotateAboutPoint(Math.PI, 50, 0); // It's top center point
final PAffineTransform expectedTransform = new PAffineTransform();
expectedTransform.translate(100, 0);
expectedTransform.rotate(Math.PI);
assertEquals(expectedTransform, node.getTransform());
}
示例14: testRotateAboutPointVersion2AffectsTransformAsItShould
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testRotateAboutPointVersion2AffectsTransformAsItShould() {
node.setBounds(25, 25, 50, 50);
node.rotateAboutPoint(Math.PI, new Point2D.Double(50, 0)); // It's top
// center
// point
final PAffineTransform expectedTransform = new PAffineTransform();
expectedTransform.translate(100, 0);
expectedTransform.rotate(Math.PI);
assertEquals(expectedTransform, node.getTransform());
}
示例15: testScaleAboutPointWorksAsExpected
import org.piccolo2d.util.PAffineTransform; //导入依赖的package包/类
public void testScaleAboutPointWorksAsExpected() {
node.setBounds(0, 0, 100, 100);
node.scaleAboutPoint(2, new Point2D.Double(50, 50));
final PAffineTransform expectedTransform = new PAffineTransform();
expectedTransform.translate(-50, -50);
expectedTransform.scale(2, 2);
assertEquals(expectedTransform, node.getTransform());
}