|
@@ -29,6 +29,7 @@
|
29
|
29
|
import java.util.ArrayList;
|
30
|
30
|
import java.util.Arrays;
|
31
|
31
|
import java.util.Scanner;
|
|
32
|
+import java.util.Collections;
|
32
|
33
|
import java.io.FileWriter;
|
33
|
34
|
import java.io.File;
|
34
|
35
|
import java.io.IOException;
|
|
@@ -125,17 +126,13 @@ public class cubeWorker {
|
125
|
126
|
if (dir == UP){
|
126
|
127
|
//animation moved up
|
127
|
128
|
if (selectedAnimation > 0) {
|
128
|
|
- Animation tmp = animations.get(selectedAnimation);
|
129
|
|
- animations.set(selectedAnimation, animations.get(selectedAnimation - 1));
|
130
|
|
- animations.set(selectedAnimation - 1, tmp);
|
|
129
|
+ Collections.swap(animations, selectedAnimation, selectedAnimation - 1);
|
131
|
130
|
}
|
132
|
131
|
} else if (dir == DOWN){
|
133
|
132
|
//animation moved down
|
134
|
133
|
if (selectedAnimation < (animations.size() - 1)) {
|
135
|
|
- Animation tmp = animations.get(selectedAnimation);
|
136
|
|
- animations.set(selectedAnimation, animations.get(selectedAnimation + 1));
|
137
|
|
- animations.set(selectedAnimation + 1, tmp);
|
138
|
|
- }
|
|
134
|
+ Collections.swap(animations, selectedAnimation, selectedAnimation + 1);
|
|
135
|
+ }
|
139
|
136
|
}
|
140
|
137
|
}
|
141
|
138
|
|
|
@@ -197,16 +194,12 @@ public class cubeWorker {
|
197
|
194
|
if (dir == UP){
|
198
|
195
|
// frame moved up
|
199
|
196
|
if (frame > 0) {
|
200
|
|
- AFrame tmp = animations.get(anim).get(frame);
|
201
|
|
- animations.get(anim).set(animations.get(anim).get(frame - 1), frame);
|
202
|
|
- animations.get(anim).set(tmp, frame - 1);
|
|
197
|
+ Collections.swap(animations.get(anim).frames, frame, frame - 1);
|
203
|
198
|
}
|
204
|
199
|
} else if (dir == DOWN){
|
205
|
200
|
// frame moved down
|
206
|
201
|
if (frame < (animations.get(anim).size() - 1)) {
|
207
|
|
- AFrame tmp = animations.get(anim).get(frame);
|
208
|
|
- animations.get(anim).set(animations.get(anim).get(frame + 1), frame);
|
209
|
|
- animations.get(anim).set(tmp, frame + 1);
|
|
202
|
+ Collections.swap(animations.get(anim).frames, frame, frame + 1);
|
210
|
203
|
}
|
211
|
204
|
}
|
212
|
205
|
}
|
|
@@ -449,7 +442,7 @@ class AFrame {
|
449
|
442
|
}
|
450
|
443
|
|
451
|
444
|
class Animation {
|
452
|
|
- private ArrayList<AFrame> frames = new ArrayList<AFrame>();
|
|
445
|
+ ArrayList<AFrame> frames = new ArrayList<AFrame>();
|
453
|
446
|
private int lastFrameIndex = 0;
|
454
|
447
|
private String name = "Animation";
|
455
|
448
|
|