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,7 +21,7 @@
21 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 27
  * A collection of frames that represent an entire animation.
@@ -32,9 +32,7 @@ import java.util.LinkedList;
32 32
  */
33 33
 
34 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 36
   private int lastFrameIndex = 0;
39 37
   private String name = "Animation";
40 38
 

+ 9
- 9
CubeControl/AnimationUtility.java View File

@@ -25,7 +25,7 @@ import java.io.FileWriter;
25 25
 import java.io.File;
26 26
 import java.util.Scanner;
27 27
 import java.io.IOException;
28
-import java.util.LinkedList;
28
+import java.util.ArrayList;
29 29
 
30 30
 /**
31 31
  * A helper class that loads animations from a file or saves them to one.
@@ -39,14 +39,14 @@ public class AnimationUtility {
39 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 43
    * @param path Path of file
44
-   * @return Populated LinkedList
44
+   * @return Populated ArrayList
45 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 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 51
   do {
52 52
   Animation tmp = readAnimation(sc);
@@ -63,12 +63,12 @@ public class AnimationUtility {
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 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 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 72
     File f = new File(path);
73 73
     if (f.exists()) {
74 74
       try {
@@ -102,7 +102,7 @@ public class AnimationUtility {
102 102
   /**
103 103
    * Get the last error that occured while writing
104 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 107
   public static String getLastError() {
108 108
     String tmp = lastError;

+ 9
- 8
CubeControl/Frame.java View File

@@ -103,14 +103,6 @@ public class Frame extends JFrame implements ListSelectionListener {
103 103
   public void valueChanged(ListSelectionEvent evt) {
104 104
   if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
105 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 107
     // If both selections are valid, update Frame duration and set 3D data
116 108
     if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
@@ -120,6 +112,15 @@ public class Frame extends JFrame implements ListSelectionListener {
120 112
       // clear Frame duration
121 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,7 +25,7 @@
25 25
  * This class handles one animation file. This file can contain
26 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 29
 import java.util.Collections;
30 30
 import java.util.StringTokenizer;
31 31
 
@@ -50,7 +50,7 @@ public class cubeWorker {
50 50
 // Fields
51 51
 // --------------------
52 52
 
53
-  private LinkedList<Animation> animations = new LinkedList<Animation>();
53
+  private ArrayList<Animation> animations = new ArrayList<Animation>();
54 54
   private int framesRemaining = 2016; // (128 * 1024) / 65 = 2016,...
55 55
   private boolean changedState = false;
56 56
 
@@ -71,7 +71,7 @@ public class cubeWorker {
71 71
    * Creates a worker from the given animation list
72 72
    * @param anims List of animations
73 73
    */
74
-  cubeWorker(LinkedList<Animation> anims) {
74
+  cubeWorker(ArrayList<Animation> anims) {
75 75
     animations = anims;
76 76
   }
77 77
 

Loading…
Cancel
Save