Browse Source

Fixed duration setting

Thomas Buck 12 years ago
parent
commit
5819b4c099
1 changed files with 70 additions and 46 deletions
  1. 70
    46
      Cube Control/frame.java

+ 70
- 46
Cube Control/frame.java View File

@@ -78,6 +78,7 @@ public class frame extends JFrame implements ListSelectionListener {
78 78
   private JTextField frameRemaining = new JTextField();
79 79
   private JLabel frmLngthLbl = new JLabel();
80 80
   private JTextField frmLngthTxt = new JTextField();
81
+  private JButton frameDuration = new JButton();
81 82
   // Ende Attribute
82 83
 
83 84
   private cubeWorker worker = new cubeWorker();
@@ -107,15 +108,18 @@ public class frame extends JFrame implements ListSelectionListener {
107 108
     if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
108 109
      int anim = animList.getSelectedIndex();
109 110
      int max;
110
-   if (anim == -1){
111
+     if (anim == -1){
111 112
         anim = 0;
112 113
      }
114
+	 if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
115
+	   	   frmLngthTxt.setText(Integer.toString(worker.getFrameTime(animList.getSelectedIndex(), frameList.getSelectedIndex())));
116
+	 }
113 117
      if(evt.getSource() == frameList){
114 118
        max = worker.numOfAnimations();
115
-     animModel.clear();
119
+	   animModel.clear();
116 120
      } else {
117 121
        max = worker.numOfFrames(anim);
118
-     frameListModel.clear();
122
+       frameListModel.clear();
119 123
      }
120 124
 
121 125
    // if value changed in anim, rebuild frame, else other way round
@@ -285,7 +289,6 @@ public class frame extends JFrame implements ListSelectionListener {
285 289
 
286 290
     frameListScrollPane.setBounds(384, 8, 145, 249);
287 291
     frameList.setModel(frameListModel);
288
-    //frameListModel.addElement();
289 292
     cp.add(frameListScrollPane);
290 293
 
291 294
     frameUp.setBounds(544, 8, 107, 28);
@@ -298,22 +301,31 @@ public class frame extends JFrame implements ListSelectionListener {
298 301
       }
299 302
     });
300 303
 
301
-    frameDown.setBounds(544, 122, 107, 28);
302
-
303
-    frameDown.setText("Move down");
304
-    frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
305
-    cp.add(frameDown);
306
-    frameDown.addActionListener(new ActionListener() {
304
+	frameAdd.setBounds(544, 39, 107, 28);
305
+    frameAdd.setText("Add");
306
+    frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
307
+    cp.add(frameAdd);
308
+    frameAdd.addActionListener(new ActionListener() {
307 309
       public void actionPerformed(ActionEvent evt) {
308
-        frameDown_ActionPerformed(evt);
310
+        frameAdd_ActionPerformed(evt);
309 311
       }
310 312
     });
311 313
 
312
-    frameAdd.setBounds(544, 46, 107, 28);
313
-  frameRename.setText("Rename");
314
-  frameRename.setFont(new Font("Dialog", Font.PLAIN, 13));
315
-  cp.add(frameRename);
316
-  frameRename.addActionListener(new ActionListener() {
314
+	frameRemove.setBounds(544, 70, 107, 28);
315
+    frameRemove.setText("Remove");
316
+    frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
317
+    cp.add(frameRemove);
318
+    frameRemove.addActionListener(new ActionListener() {
319
+      public void actionPerformed(ActionEvent evt) {
320
+        frameRemove_ActionPerformed(evt);
321
+      }
322
+    });
323
+	
324
+	frameRename.setBounds(544, 101, 107, 28);
325
+	frameRename.setText("Rename");
326
+  	frameRename.setFont(new Font("Dialog", Font.PLAIN, 13));
327
+  	cp.add(frameRename);
328
+  	frameRename.addActionListener(new ActionListener() {
317 329
     public void actionPerformed(ActionEvent evt) {
318 330
       int a = animList.getSelectedIndex();
319 331
       if (a < 0) {
@@ -331,43 +343,55 @@ public class frame extends JFrame implements ListSelectionListener {
331 343
     }
332 344
   });
333 345
 
334
-
335
-    frameAdd.setText("Add");
336
-    frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
337
-    cp.add(frameAdd);
338
-    frameAdd.addActionListener(new ActionListener() {
339
-      public void actionPerformed(ActionEvent evt) {
340
-        frameAdd_ActionPerformed(evt);
341
-      }
342
-    });
343
-
344
-
345
-    frameRemove.setBounds(544, 84, 107, 28);
346
-
347
-    frameRemove.setBounds(544, 84, 107, 33);
348
-
349
-    frameRemove.setText("Remove");
350
-    frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
351
-    cp.add(frameRemove);
352
-    frameRemove.addActionListener(new ActionListener() {
346
+    frameDown.setBounds(544, 132, 107, 28);
347
+    frameDown.setText("Move down");
348
+    frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
349
+    cp.add(frameDown);
350
+    frameDown.addActionListener(new ActionListener() {
353 351
       public void actionPerformed(ActionEvent evt) {
354
-        frameRemove_ActionPerformed(evt);
352
+        frameDown_ActionPerformed(evt);
355 353
       }
356 354
     });
357 355
 
358 356
     frmLngthLbl.setBounds(536, 160, 113, 24);
359
-    frmLngthLbl.setText("Length of a frame");
357
+    frmLngthLbl.setText("Time (1/24 sec)");
360 358
     frmLngthLbl.setFont(new Font("Dialog", Font.PLAIN, 13));
361 359
     cp.add(frmLngthLbl);
362 360
 
363
-    frmLngthTxt.setBounds(536, 184, 113, 24);
364
-    frmLngthTxt.setText("0");
361
+    frmLngthTxt.setBounds(536, 184, 50, 24);
362
+    frmLngthTxt.setText("");
365 363
     frmLngthTxt.setFont(new Font("Dialog", Font.PLAIN, 13));
366 364
     cp.add(frmLngthTxt);
367 365
 
366
+	frameDuration.setBounds(590, 184, 50, 24);
367
+	frameDuration.setText("OK");
368
+	frameDuration.setFont(new Font("Dialog", Font.PLAIN, 13));
369
+	cp.add(frameDuration);
370
+	frameDuration.addActionListener(new ActionListener() {
371
+		public void actionPerformed(ActionEvent evt) {
372
+			if (frmLngthTxt.getText().equals("0")) {
373
+				errorMessage("0 is not a valid value!");
374
+				frmLngthTxt.setText("1");
375
+			} else if (Integer.parseInt(frmLngthTxt.getText()) > 256) {
376
+				errorMessage("Value too high. Max: 256");
377
+				frmLngthTxt.setText("256");
378
+				return;
379
+			} else {
380
+				if (animList.getSelectedIndex() == -1) {
381
+					errorMessage("Please select an animation!");
382
+					return;
383
+				}
384
+				if (frameList.getSelectedIndex() == -1) {
385
+					errorMessage("Please select a frame!");
386
+					return;
387
+				}
388
+				worker.setFrameTime((byte)(Integer.parseInt(frmLngthTxt.getText()) - 1), animList.getSelectedIndex(), frameList.getSelectedIndex());
389
+			}
390
+		}
391
+	});
392
+
368 393
     animScrollPane.setBounds(8, 264, 209, 121);
369 394
     animList.setModel(animModel);
370
-    //jList2Model.addElement("");
371 395
     cp.add(animScrollPane);
372 396
 
373 397
     animUp.setBounds(224, 264, 99, 25);
@@ -380,7 +404,7 @@ public class frame extends JFrame implements ListSelectionListener {
380 404
       }
381 405
     });
382 406
 
383
-    animDown.setBounds(224, 342, 99, 25);
407
+  	animDown.setBounds(224, 368, 99, 25);
384 408
     animDown.setText("Move down");
385 409
     animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
386 410
     cp.add(animDown);
@@ -390,11 +414,11 @@ public class frame extends JFrame implements ListSelectionListener {
390 414
       }
391 415
     });
392 416
 
393
-  animRename.setBounds(224, 368, 99, 25);
394
-  animRename.setText("Rename");
395
-  animRename.setFont(new Font("Dialog", Font.PLAIN, 13));
396
-  cp.add(animRename);
397
-  animRename.addActionListener(new ActionListener() {
417
+    animRename.setBounds(224, 342, 99, 25);
418
+  	animRename.setText("Rename");
419
+  	animRename.setFont(new Font("Dialog", Font.PLAIN, 13));
420
+  	cp.add(animRename);
421
+  	animRename.addActionListener(new ActionListener() {
398 422
     public void actionPerformed(ActionEvent evt) {
399 423
       int a = animList.getSelectedIndex();
400 424
       if (a < 0) {

Loading…
Cancel
Save