| 1 6 7 package com.thoughtriver.open.vectorvisuals.task; 8 9 import java.awt.geom.*; 10 11 import com.thoughtriver.open.vectorvisuals.*; 12 13 21 public class RotationTask extends AnimationTask { 22 23 24 private VisualObject target = null; 25 26 27 private double angle = 0; 28 29 30 private double lastProgress = 0; 31 32 43 public RotationTask(final VisualObject target, final double angle, final int duration) { 44 super(duration); 45 this.target = target; 46 this.angle = angle; 47 lastProgress = 0; 48 } 49 50 58 @Override  59 protected void update(final double progress) { 60 61 synchronized (target) { 62 Point2D rotationPoint = target.getRotationPoint(); 63 AffineTransform transform = target.getTransform(); 64 65 double thetaToRotate = (progress - lastProgress) * angle; 66 lastProgress = progress; 67 68 transform.rotate(thetaToRotate, rotationPoint.getX(), rotationPoint.getY()); 69 target.setTransform(transform); 70 } 71 } 72 73 } 74 | Popular Tags |