Reputation: 409
I am trying to rotate a Rectangle2D object by a particular theta. But I cannot do this because the method transform(AffineTransform) is undefined for Rectangle2D. Any thoughts on how to do this? Thanks.
Rectangle2D.Double currentVehic = new Rectangle2D.Double(bottomLeft[0], bottomLeft[1],vehicWidth, vehicHeight);
// Rotate the vehicle perimeter about its center
AffineTransform rotate = new AffineTransform();
//Rectangle2D rotatedVehic = AffineTransform.getRotateInstance(theta,x,y);
rotate.setToRotation(theta, x, y);
currentVehic.transform(rotate);
return currentVehic;
Upvotes: 1
Views: 2504
Reputation: 205785
Because a Rectangle2D
is a Shape
, you may be looking for the AffineTransform
method createTransformedShape()
. A complete example is examined here, and another is cited here.
Upvotes: 6