Browse Source

Fixed frame bugs...

Thomas Buck 12 years ago
parent
commit
dbfd6d87ef
3 changed files with 48 additions and 30 deletions
  1. 4
    1
      Cube Control/cubeWorker.java
  2. 40
    25
      Cube Control/frame.java
  3. 4
    4
      Cube Control/makefile

+ 4
- 1
Cube Control/cubeWorker.java View File

@@ -55,6 +55,9 @@ public class cubeWorker {
55 55
   cubeWorker() {
56 56
   animations.add(new Animation());
57 57
   animations.get(0).setName("Animation 1");
58
+  animations.get(0).add(0);
59
+  animations.get(0).get(0).setName("Frame 1");
60
+  framesRemaining--;
58 61
   }
59 62
 
60 63
   cubeWorker(ArrayList<Animation> anims) {
@@ -158,7 +161,7 @@ public class cubeWorker {
158 161
     framesRemaining--;
159 162
     int s = animations.get(anim).size();
160 163
     animations.get(anim).add(s);
161
-  animations.get(anim).get(s).setName("Frame " + (2016 - framesRemaining));
164
+  animations.get(anim).get(s).setName("Frame " + animations.get(anim).size());
162 165
     return s;
163 166
     }
164 167
 

+ 40
- 25
Cube Control/frame.java View File

@@ -57,6 +57,7 @@ public class frame extends JFrame implements ListSelectionListener {
57 57
   private JButton frameDown = new JButton();
58 58
   private JButton frameAdd = new JButton();
59 59
   private JButton frameRemove = new JButton();
60
+  private JButton frameRename = new JButton();
60 61
   private JButton frame = new JButton();
61 62
   private JList animList = new JList();
62 63
   private DefaultListModel animModel = new DefaultListModel();
@@ -91,37 +92,40 @@ public class frame extends JFrame implements ListSelectionListener {
91 92
     }
92 93
   }
93 94
 
95
+  private String askString(String title, String text) {
96
+	  return JOptionPane.showInputDialog(null, title, text, JOptionPane.QUESTION_MESSAGE);
97
+  }
98
+
94 99
   private void errorMessage(String s) {
95 100
   String[] Optionen = {"OK"};
96 101
   JOptionPane.showOptionDialog(this, s, "Error!", JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE, null, Optionen, Optionen[0]);
97 102
   }
98 103
 
99 104
   public void valueChanged(ListSelectionEvent evt) {
100
-    if ((!evt.getValueIsAdjusting()) && (evt.getSource() != animList) && (evt.getSource() != frameList)) {
101
-     DefaultListModel model = (DefaultListModel)((JList)evt.getSource()).getModel();
105
+    if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
102 106
      int anim = animList.getSelectedIndex();
103 107
      int max;
104
-     if(evt.getSource() == animList){
108
+	 if (anim == -1){
109
+        anim = 0;
110
+     }
111
+     if(evt.getSource() == frameList){
105 112
        max = worker.numOfAnimations();
106
-       System.out.println(max);
107
-
113
+	   animModel.clear();
108 114
      } else {
109
-       max = worker.numOfFrames(animList.getSelectedIndex());
110
-
115
+       max = worker.numOfFrames(anim);
116
+	   frameListModel.clear();
111 117
      }
112 118
 
113
-     if (anim == -1){
114
-        anim = 0;
115
-     }
116
-     model.clear();
117
-     for (int i = 0; i < max; i++) {
119
+	 // if value changed in anim, rebuild frame, else other way round
120
+	 for (int i = 0; i < max; i++) {
118 121
        if(evt.getSource() == animList){
119
-          model.add(i, worker.getAnimationName(i));
122
+			frameListModel.addElement(worker.getFrameName(anim, i));
123
+			frameList.setModel(frameListModel);
120 124
        } else {
121
-         model.add(i, worker.getFrameName(anim, i));
125
+			animModel.addElement(worker.getAnimationName(i));
126
+			animList.setModel(animModel);
122 127
        }
123
-    }
124
-    frameList.setModel(model);
128
+	 }
125 129
     }
126 130
   }
127 131
 
@@ -272,7 +276,7 @@ public class frame extends JFrame implements ListSelectionListener {
272 276
       }
273 277
     });
274 278
 
275
-    frameDown.setBounds(544, 152, 107, 33);
279
+    frameDown.setBounds(544, 122, 107, 33);
276 280
     frameDown.setText("Move down");
277 281
     frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
278 282
     cp.add(frameDown);
@@ -282,7 +286,19 @@ public class frame extends JFrame implements ListSelectionListener {
282 286
       }
283 287
     });
284 288
 
285
-    frameAdd.setBounds(544, 56, 107, 33);
289
+	frameRename.setBounds(544, 160, 107, 33);
290
+	frameRename.setText("Rename");
291
+	frameRename.setFont(new Font("Dialog", Font.PLAIN, 13));
292
+	cp.add(frameRename);
293
+	frameRename.addActionListener(new ActionListener() {
294
+		public void actionPerformed(ActionEvent evt) {
295
+			worker.setFrameName(askString("Rename", "Rename " + frameList.getSelectedValue()), animList.getSelectedIndex(), frameList.getSelectedIndex());
296
+			frameListModel.set(frameList.getSelectedIndex(), worker.getFrameName(animList.getSelectedIndex(), frameList.getSelectedIndex()));
297
+			frameList.setModel(frameListModel);
298
+		}
299
+	});
300
+
301
+    frameAdd.setBounds(544, 46, 107, 33);
286 302
     frameAdd.setText("Add");
287 303
     frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
288 304
     cp.add(frameAdd);
@@ -292,7 +308,7 @@ public class frame extends JFrame implements ListSelectionListener {
292 308
       }
293 309
     });
294 310
 
295
-    frameRemove.setBounds(544, 104, 107, 33);
311
+    frameRemove.setBounds(544, 84, 107, 33);
296 312
     frameRemove.setText("Remove");
297 313
     frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
298 314
     cp.add(frameRemove);
@@ -410,7 +426,7 @@ public class frame extends JFrame implements ListSelectionListener {
410 426
     cp.add(jLabel4);
411 427
     frameRemaining.setBounds(536, 232, 113, 24);
412 428
     frameRemaining.setEditable(false);
413
-    frameRemaining.setText("2048");
429
+    frameRemaining.setText(String.valueOf(worker.framesRemaining()));
414 430
     frameRemaining.setFont(new Font("Dialog", Font.PLAIN, 13));
415 431
     cp.add(frameRemaining);
416 432
     animList.setFont(new Font("Dialog", Font.PLAIN, 13));
@@ -528,13 +544,12 @@ public class frame extends JFrame implements ListSelectionListener {
528 544
       errorMessage("Could not add animation!");
529 545
     } else {
530 546
     int n = worker.numOfAnimations() - 1;
531
-    if (n < 0) {
547
+    // would have 0 anims after successfully adding one...
548
+	/*if (n < 0) {
532 549
       n = 0;
533
-    }
550
+    }*/
534 551
     animModel.clear();
535
-    System.out.println(n);
536
-    //animModel.addElement(worker.getAnimationName(n));
537
-    for (int i = 0; i < n; i++) {
552
+    for (int i = 0; i < (n + 1); i++) {
538 553
         animModel.add(i, worker.getAnimationName(i));
539 554
     }
540 555
     animList.setModel(animModel);

+ 4
- 4
Cube Control/makefile View File

@@ -1,14 +1,14 @@
1 1
 JAVAC = javac
2 2
 CC = gcc
3
-#TARGET = unix
4
-TARGET = win
3
+TARGET = unix
4
+#TARGET = win
5 5
 
6 6
 JAVAFILES = cubeWorker.java layerEditFrame.java frame.java
7 7
 
8 8
 ifeq ($(TARGET),win)
9
-CLASSES = cubeWorker.class layerEditFrame.class layerEditFrame$$1.class layerEditFrame$$2.class layerEditFrame$$3.class layerEditFrame$$4.class frame.class frame$$1.class frame$$2.class frame$$3.class frame$$4.class frame$$5.class frame$$6.class frame$$7.class frame$$8.class frame$$9.class frame$$10.class frame$$11.class frame$$12.class frame$$13.class frame$$14.class frame$$15.class frame$$16.class frame$$17.class frame$$18.class frame$$19.class frame$$20.class frame$$21.class frame$$22.class AFrame.class Animation.class AnimationUtility.class LEDoff.png LEDon.png
9
+CLASSES = cubeWorker.class layerEditFrame.class layerEditFrame$$1.class layerEditFrame$$2.class layerEditFrame$$3.class layerEditFrame$$4.class frame.class frame$$1.class frame$$2.class frame$$3.class frame$$4.class frame$$5.class frame$$6.class frame$$7.class frame$$8.class frame$$9.class frame$$10.class frame$$11.class frame$$12.class frame$$13.class frame$$14.class frame$$15.class frame$$16.class frame$$17.class frame$$18.class frame$$19.class frame$$20.class frame$$21.class frame$$22.class frame$$23.class AFrame.class Animation.class AnimationUtility.class LEDoff.png LEDon.png
10 10
 else
11
-CLASSES = 'cubeWorker.class' 'layerEditFrame.class' 'layerEditFrame$$1.class' 'layerEditFrame$$2.class' 'layerEditFrame$$3.class' 'layerEditFrame$$4.class' 'frame.class' 'frame$$1.class' 'frame$$2.class' 'frame$$3.class' 'frame$$4.class' 'frame$$5.class' 'frame$$6.class' 'frame$$7.class' 'frame$$8.class' 'frame$$9.class' 'frame$$10.class' 'frame$$11.class' 'frame$$12.class' 'frame$$13.class' 'frame$$14.class' 'frame$$15.class' 'frame$$16.class' 'frame$$17.class' 'frame$$18.class' 'frame$$19.class' 'frame$$20.class' 'frame$$21.class' 'frame$$22.class' 'AFrame.class' 'Animation.class' 'AnimationUtility.class' 'LEDoff.png' 'LEDon.png'
11
+CLASSES = 'cubeWorker.class' 'layerEditFrame.class' 'layerEditFrame$$1.class' 'layerEditFrame$$2.class' 'layerEditFrame$$3.class' 'layerEditFrame$$4.class' 'frame.class' 'frame$$1.class' 'frame$$2.class' 'frame$$3.class' 'frame$$4.class' 'frame$$5.class' 'frame$$6.class' 'frame$$7.class' 'frame$$8.class' 'frame$$9.class' 'frame$$10.class' 'frame$$11.class' 'frame$$12.class' 'frame$$13.class' 'frame$$14.class' 'frame$$15.class' 'frame$$16.class' 'frame$$17.class' 'frame$$18.class' 'frame$$19.class' 'frame$$20.class' 'frame$$21.class' 'frame$$22.class' 'frame$$23.class' 'AFrame.class' 'Animation.class' 'AnimationUtility.class' 'LEDoff.png' 'LEDon.png'
12 12
 endif
13 13
 
14 14
 all: build clean

Loading…
Cancel
Save