跨境电商官方网站建设,网站空间多大,html5 网站源码,成都三网合一网站建设我将假设您了解如何旋转图像一次.如果你不这样做,你可以通过快速谷歌搜索找到它.您需要的是一个为您旋转它的后台进程.它的工作原理如下#xff1a;/*** Warning - this class is UNSYNCHRONIZED!*/public class RotatableImage {Image image;float currentDegrees;public Rot…我将假设您了解如何旋转图像一次.如果你不这样做,你可以通过快速谷歌搜索找到它.您需要的是一个为您旋转它的后台进程.它的工作原理如下/*** Warning - this class is UNSYNCHRONIZED!*/public class RotatableImage {Image image;float currentDegrees;public RotateableImage(Image image) {this.image image;this.currentDegrees 0.0f;this.remainingDegrees 0.0f;}public void paintOn(Graphics g) {//put your code to rotate the image once in here, using current degrees as your rotation}public void spin(float additionalDegrees) {setSpin(currentDegrees additionalDegrees);}public void setSpin(float newDegrees) {currentDegrees additionalDegrees;while(currentDegrees 0f) currentDegrees 360f;while(currentDegrees 360f) currentDegrees - 360f;}}public class ImageSpinner implements Runnable {RotateableImage image;final float totalDegrees;float degrees;float speed; // in degrees per secondpublic ImageSpinner(RotatableImage image, float degrees, float speed) {this.image image;this.degrees degrees;this.totalDegrees degrees;this.speed speed;}public void run() {// assume about 40 frames per second, and that the it doesnt matter if it isnt exactint fps 40;while(Math.abs(degrees) Math.abs(speed / fps)) { // how close is the degrees to 0?float degreesToRotate speed / fps;image.spin(degreesToRotate);degrees - degreesToRotate;/* sleep will always wait at least 1000 / fps before recalcingbut you have no guarantee that it wont take forever! If you absolutelyrequire better timing, this isnt the solution for you */try { Thread.sleep(1000 / fps); } catch(InterruptedException e) { /* swallow */ }}image.setSpin(totalDegrees); // this might need to be 360 - totalDegrees, not sure}}