Browse Source

ArrayList now LinkedList

Thomas Buck 13 years ago
parent
commit
1c43cd2399

+ 4
- 2
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.ArrayList;
24
+import java.util.LinkedList;
25 25
 
26 26
 /**
27 27
  * A collection of frames that represent an entire animation.
@@ -32,7 +32,9 @@ import java.util.ArrayList;
32 32
  */
33 33
 
34 34
 public class Animation {
35
-  ArrayList<AFrame> frames = new ArrayList<AFrame>();
35
+  public LinkedList<AFrame> frames = new LinkedList<AFrame>();
36
+  // Public so moveFrame can access it
37
+  
36 38
   private int lastFrameIndex = 0;
37 39
   private String name = "Animation";
38 40
 

+ 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.ArrayList;
28
+import java.util.LinkedList;
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 ArrayList with all animations in the file.
42
+   * Read a file, return LinkedList with all animations in the file.
43 43
    * @param path Path of file
44
-   * @return Populated ArrayList
44
+   * @return Populated LinkedList
45 45
    * @throws Excpetion When something goes wrong with the Scanner...
46 46
    */
47
-  public static ArrayList<Animation> readFile(String path) throws Exception {
47
+  public static LinkedList<Animation> readFile(String path) throws Exception {
48 48
     Scanner sc = new Scanner(new File(path));
49
-  ArrayList<Animation> animations = new ArrayList<Animation>();
49
+  LinkedList<Animation> animations = new LinkedList<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 ArrayList
66
+   * Write a file with all Animations of an LinkedList
67 67
    * @param path Path to write to
68
-   * @param animations ArrayList with all animations to be saved
68
+   * @param animations LinkedList with all animations to be saved
69 69
    * @see AnimationUtility#getLastError() getLastError()
70 70
    */
71
-  public static void writeFile(String path, ArrayList<Animation> animations) {
71
+  public static void writeFile(String path, LinkedList<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, ArrayList) writeFile()
105
+   * @see AnimationUtility#writeFile(String, LinkedList) writeFile()
106 106
    */
107 107
   public static String getLastError() {
108 108
     String tmp = lastError;

+ 8
- 9
CubeControl/Frame.java View File

@@ -103,6 +103,14 @@ 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
+    }
106 114
 
107 115
     // If both selections are valid, update Frame duration and set 3D data
108 116
     if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
@@ -112,15 +120,6 @@ public class Frame extends JFrame implements ListSelectionListener {
112 120
       // clear Frame duration
113 121
       frameLengthText.setText("");
114 122
     }
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
-    }
124 123
   }
125 124
   }
126 125
 

+ 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.ArrayList;
28
+import java.util.LinkedList;
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 ArrayList<Animation> animations = new ArrayList<Animation>();
53
+  private LinkedList<Animation> animations = new LinkedList<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(ArrayList<Animation> anims) {
74
+  cubeWorker(LinkedList<Animation> anims) {
75 75
     animations = anims;
76 76
   }
77 77
 

Loading…
Cancel
Save