123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
-
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Collections;
-
-
-
- public class Animation {
- AFrame frames[] = new AFrame[1];
- private String name = "Animation";
- private static int lastIndex = 1;
-
-
-
- public Animation() {
- frames[0] = new AFrame();
- name = "Animation " + lastIndex++;
- }
-
-
-
- public AFrame getFrame(int i) {
- if (i >= frames.length) {
- return null;
- } else {
- return frames[i];
- }
- }
-
-
-
- public void moveFrameUp(int i) {
- if (i > 0) {
- AFrame tmp = frames[i];
- frames[i] = frames[i - 1];
- frames[i - 1] = tmp;
- }
- }
-
-
-
- public void moveFrameDown(int i) {
- if (i < (frames.length - 1)) {
- AFrame tmp = frames[i];
- frames[i] = frames[i + 1];
- frames[i + 1] = tmp;
- }
- }
-
-
-
- public void setFrame(AFrame f, int i) {
- if (i < frames.length) {
- frames[i] = f;
- } else {
- addFrame(f);
- }
- }
-
-
-
- public void addFrame() {
- extendArray();
- frames[frames.length - 1] = new AFrame();
- }
-
-
-
- public void addFrame(AFrame f) {
- addFrame();
- frames[frames.length - 1] = f;
- }
-
-
-
- public int size() {
- return frames.length;
- }
-
-
-
- public void removeFrame(int i) {
- shiftOver(i);
- shrinkArray();
- }
-
-
-
- public String getName() {
- return name;
- }
-
-
-
- public void setName(String s) {
- name = s;
- }
-
- private void extendArray() {
- AFrame newArray[] = new AFrame[frames.length + 1];
- for (int i = 0; i < frames.length; i++) {
- newArray[i] = frames[i];
- }
- frames = newArray;
- }
-
- private void shrinkArray() {
- AFrame newArray[] = new AFrame[frames.length - 1];
- for (int i = 0; i < newArray.length; i++) {
- newArray[i] = frames[i];
- }
- frames = newArray;
- }
-
- private void shiftOver(int toForget) {
- for (int i = (toForget + 1); i < frames.length; i++) {
- frames[i - 1] = frames[i];
- }
- }
- }
|