Browse Source

Revert "ArrayList now LinkedList"

This reverts commit 1c43cd2399.
Thomas Buck 12 years ago
parent
commit
97c65ec834

+ 2
- 4
CubeControl/Animation.java View File

21
  * along with LED-Cube.  If not, see <http://www.gnu.org/licenses/>.
21
  * along with LED-Cube.  If not, see <http://www.gnu.org/licenses/>.
22
  */
22
  */
23
 
23
 
24
-import java.util.LinkedList;
24
+import java.util.ArrayList;
25
 
25
 
26
 /**
26
 /**
27
  * A collection of frames that represent an entire animation.
27
  * A collection of frames that represent an entire animation.
32
  */
32
  */
33
 
33
 
34
 public class Animation {
34
 public class Animation {
35
-  public LinkedList<AFrame> frames = new LinkedList<AFrame>();
36
-  // Public so moveFrame can access it
37
-  
35
+  ArrayList<AFrame> frames = new ArrayList<AFrame>();
38
   private int lastFrameIndex = 0;
36
   private int lastFrameIndex = 0;
39
   private String name = "Animation";
37
   private String name = "Animation";
40
 
38
 

+ 9
- 9
CubeControl/AnimationUtility.java View File

25
 import java.io.File;
25
 import java.io.File;
26
 import java.util.Scanner;
26
 import java.util.Scanner;
27
 import java.io.IOException;
27
 import java.io.IOException;
28
-import java.util.LinkedList;
28
+import java.util.ArrayList;
29
 
29
 
30
 /**
30
 /**
31
  * A helper class that loads animations from a file or saves them to one.
31
  * A helper class that loads animations from a file or saves them to one.
39
   private static String lastError = null;
39
   private static String lastError = null;
40
 
40
 
41
   /**
41
   /**
42
-   * Read a file, return LinkedList with all animations in the file.
42
+   * Read a file, return ArrayList with all animations in the file.
43
    * @param path Path of file
43
    * @param path Path of file
44
-   * @return Populated LinkedList
44
+   * @return Populated ArrayList
45
    * @throws Excpetion When something goes wrong with the Scanner...
45
    * @throws Excpetion When something goes wrong with the Scanner...
46
    */
46
    */
47
-  public static LinkedList<Animation> readFile(String path) throws Exception {
47
+  public static ArrayList<Animation> readFile(String path) throws Exception {
48
     Scanner sc = new Scanner(new File(path));
48
     Scanner sc = new Scanner(new File(path));
49
-  LinkedList<Animation> animations = new LinkedList<Animation>();
49
+  ArrayList<Animation> animations = new ArrayList<Animation>();
50
 
50
 
51
   do {
51
   do {
52
   Animation tmp = readAnimation(sc);
52
   Animation tmp = readAnimation(sc);
63
   }
63
   }
64
 
64
 
65
   /**
65
   /**
66
-   * Write a file with all Animations of an LinkedList
66
+   * Write a file with all Animations of an ArrayList
67
    * @param path Path to write to
67
    * @param path Path to write to
68
-   * @param animations LinkedList with all animations to be saved
68
+   * @param animations ArrayList with all animations to be saved
69
    * @see AnimationUtility#getLastError() getLastError()
69
    * @see AnimationUtility#getLastError() getLastError()
70
    */
70
    */
71
-  public static void writeFile(String path, LinkedList<Animation> animations) {
71
+  public static void writeFile(String path, ArrayList<Animation> animations) {
72
     File f = new File(path);
72
     File f = new File(path);
73
     if (f.exists()) {
73
     if (f.exists()) {
74
       try {
74
       try {
102
   /**
102
   /**
103
    * Get the last error that occured while writing
103
    * Get the last error that occured while writing
104
    * @return Text of the exception that occured
104
    * @return Text of the exception that occured
105
-   * @see AnimationUtility#writeFile(String, LinkedList) writeFile()
105
+   * @see AnimationUtility#writeFile(String, ArrayList) writeFile()
106
    */
106
    */
107
   public static String getLastError() {
107
   public static String getLastError() {
108
     String tmp = lastError;
108
     String tmp = lastError;

+ 9
- 8
CubeControl/Frame.java View File

103
   public void valueChanged(ListSelectionEvent evt) {
103
   public void valueChanged(ListSelectionEvent evt) {
104
   if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
104
   if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
105
     // If animList or framsList is the source, we act...
105
     // If animList or framsList is the source, we act...
106
-	if ((evt.getSource() == animList) && (animList.getSelectedIndex() != -1)) {
107
-      // animList selection changed, update frameList
108
-      frameListModel.clear();
109
-      for (int i = 0; i < worker.numOfFrames(animList.getSelectedIndex()); i++) {
110
-        frameListModel.addElement(worker.getFrameName(animList.getSelectedIndex(), i));
111
-      }
112
-      frameList.setModel(frameListModel);
113
-    }
114
 
106
 
115
     // If both selections are valid, update Frame duration and set 3D data
107
     // If both selections are valid, update Frame duration and set 3D data
116
     if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
108
     if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
120
       // clear Frame duration
112
       // clear Frame duration
121
       frameLengthText.setText("");
113
       frameLengthText.setText("");
122
     }
114
     }
115
+
116
+    if ((evt.getSource() == animList) && (animList.getSelectedIndex() != -1)) {
117
+      // animList selection changed, update frameList
118
+      frameListModel.clear();
119
+      for (int i = 0; i < worker.numOfFrames(animList.getSelectedIndex()); i++) {
120
+        frameListModel.addElement(worker.getFrameName(animList.getSelectedIndex(), i));
121
+      }
122
+      frameList.setModel(frameListModel);
123
+    }
123
   }
124
   }
124
   }
125
   }
125
 
126
 

+ 3
- 3
CubeControl/cubeWorker.java View File

25
  * This class handles one animation file. This file can contain
25
  * This class handles one animation file. This file can contain
26
  * many animations, but has to be only 1Mbit in size (128*1024 Byte).
26
  * many animations, but has to be only 1Mbit in size (128*1024 Byte).
27
  */
27
  */
28
-import java.util.LinkedList;
28
+import java.util.ArrayList;
29
 import java.util.Collections;
29
 import java.util.Collections;
30
 import java.util.StringTokenizer;
30
 import java.util.StringTokenizer;
31
 
31
 
50
 // Fields
50
 // Fields
51
 // --------------------
51
 // --------------------
52
 
52
 
53
-  private LinkedList<Animation> animations = new LinkedList<Animation>();
53
+  private ArrayList<Animation> animations = new ArrayList<Animation>();
54
   private int framesRemaining = 2016; // (128 * 1024) / 65 = 2016,...
54
   private int framesRemaining = 2016; // (128 * 1024) / 65 = 2016,...
55
   private boolean changedState = false;
55
   private boolean changedState = false;
56
 
56
 
71
    * Creates a worker from the given animation list
71
    * Creates a worker from the given animation list
72
    * @param anims List of animations
72
    * @param anims List of animations
73
    */
73
    */
74
-  cubeWorker(LinkedList<Animation> anims) {
74
+  cubeWorker(ArrayList<Animation> anims) {
75
     animations = anims;
75
     animations = anims;
76
   }
76
   }
77
 
77
 

Loading…
Cancel
Save