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 IndefiniteRotationTask extends AnimationTask { 22 23 24 private final VisualObject target; 25 26 27 private double rate = 0; 28 29 37 public IndefiniteRotationTask(final VisualObject target) { 38 super(-1); 39 this.target = target; 40 } 41 42 48 public void setRate(final double rate) { 49 this.rate = rate; 50 } 51 52 59 @Override 60 protected void update(final double progress) { 61 62 synchronized (target) { 63 Point2D rotationPoint = target.getRotationPoint(); 64 AffineTransform transform = target.getTransform(); 65 double thetaToRotate = rate * (progress / 1000); 66 transform.rotate(thetaToRotate, rotationPoint.getX(), rotationPoint.getY()); 67 target.setTransform(transform); 68 } 69 } 70 71 } 72 | Popular Tags |