()
| 95 | } |
| 96 | |
| 97 | void startAnimation() { |
| 98 | int first=firstFrame, last=lastFrame; |
| 99 | if (first<1 || first>nSlices || last<1 || last>nSlices) |
| 100 | {first=1; last=nSlices;} |
| 101 | if (swin.getAnimate()) |
| 102 | {stopAnimation(); return;} |
| 103 | swin.setAnimate(true); |
| 104 | long time, nextTime=System.currentTimeMillis(); |
| 105 | Thread.currentThread().setPriority(Thread.MIN_PRIORITY); |
| 106 | int sliceIncrement = 1; |
| 107 | Calibration cal = imp.getCalibration(); |
| 108 | if (cal.fps!=0.0) |
| 109 | animationRate = cal.fps; |
| 110 | if (animationRate<0.1) { |
| 111 | animationRate = 1.0; |
| 112 | cal.fps = animationRate; |
| 113 | } |
| 114 | int frames = imp.getNFrames(); |
| 115 | int slices = imp.getNSlices(); |
| 116 | |
| 117 | if (imp.isDisplayedHyperStack() && frames>1) { |
| 118 | int frame = imp.getFrame(); |
| 119 | first = 1; |
| 120 | last = frames; |
| 121 | while (swin.getAnimate()) { |
| 122 | time = System.currentTimeMillis(); |
| 123 | if (time<nextTime) |
| 124 | IJ.wait((int)(nextTime-time)); |
| 125 | else |
| 126 | Thread.yield(); |
| 127 | nextTime += (long)(1000.0/animationRate); |
| 128 | frame += sliceIncrement; |
| 129 | if (frame<first) { |
| 130 | frame = first+1; |
| 131 | sliceIncrement = 1; |
| 132 | } |
| 133 | if (frame>last) { |
| 134 | if (cal.loop) { |
| 135 | frame = last-1; |
| 136 | sliceIncrement = -1; |
| 137 | } else { |
| 138 | frame = first; |
| 139 | sliceIncrement = 1; |
| 140 | } |
| 141 | } |
| 142 | if (imp.isLocked()) return; |
| 143 | imp.setPosition(imp.getChannel(), imp.getSlice(), frame); |
| 144 | imp.updateStatusbarValue(); |
| 145 | } |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | if (imp.isDisplayedHyperStack() && slices>1) { |
| 150 | slice = imp.getSlice(); |
| 151 | first = 1; |
| 152 | last = slices; |
| 153 | while (swin.getAnimate()) { |
| 154 | time = System.currentTimeMillis(); |
no test coverage detected