|
@@ -83,6 +83,7 @@ public class Frame extends JFrame implements ListSelectionListener {
|
83
|
83
|
|
84
|
84
|
public cubeWorker worker = new cubeWorker(this);
|
85
|
85
|
private boolean fileSelected = false;
|
|
86
|
+ private Frame thisFrame;
|
86
|
87
|
|
87
|
88
|
// Ende Variablen
|
88
|
89
|
|
|
@@ -125,25 +126,22 @@ public class Frame extends JFrame implements ListSelectionListener {
|
125
|
126
|
&& (animList.getSelectedIndex() != -1)) {
|
126
|
127
|
// animList selection changed, update frameList
|
127
|
128
|
frameListModel.clear();
|
128
|
|
- for (int i = 0; i < worker.numOfFrames(animList
|
129
|
|
- .getSelectedIndex()); i++) {
|
130
|
|
- // Offending statement:
|
131
|
|
- // worker.numOfFrames(animList.getSelectedIndex())
|
132
|
|
- frameListModel.addElement(worker.getFrameName(
|
133
|
|
- animList.getSelectedIndex(), i));
|
|
129
|
+
|
|
130
|
+ // System.out.println("Selected Animation: " + animList.getSelectedIndex());
|
|
131
|
+ int max = worker.getAnimation(animList.getSelectedIndex()).size();
|
|
132
|
+
|
|
133
|
+ for (int i = 0; i < max; i++) {
|
|
134
|
+ frameListModel.addElement(worker.getAnimation(
|
|
135
|
+ animList.getSelectedIndex()).getFrame(i).getName());
|
134
|
136
|
}
|
135
|
137
|
frameList.setModel(frameListModel);
|
136
|
138
|
}
|
137
|
139
|
|
138
|
140
|
// If both selections are valid, update Frame duration and set 3D
|
139
|
141
|
// data
|
140
|
|
- if ((animList.getSelectedIndex() != -1)
|
141
|
|
- && (frameList.getSelectedIndex() != -1)) {
|
142
|
|
- ledView.setData(worker.getFrame(animList.getSelectedIndex(),
|
143
|
|
- frameList.getSelectedIndex()));
|
144
|
|
- frameLengthText.setText(Integer.toString(worker.getFrameTime(
|
145
|
|
- animList.getSelectedIndex(),
|
146
|
|
- frameList.getSelectedIndex())));
|
|
142
|
+ if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
|
|
143
|
+ ledView.setData(worker.getAnimation(animList.getSelectedIndex()).getFrame(frameList.getSelectedIndex()).getData());
|
|
144
|
+ frameLengthText.setText(Integer.toString(worker.getAnimation(animList.getSelectedIndex()).getFrame(frameList.getSelectedIndex()).getTime()));
|
147
|
145
|
} else {
|
148
|
146
|
// clear Frame duration
|
149
|
147
|
frameLengthText.setText("");
|
|
@@ -169,15 +167,16 @@ public class Frame extends JFrame implements ListSelectionListener {
|
169
|
167
|
public Frame(String title) {
|
170
|
168
|
// Frame-Initialisierung
|
171
|
169
|
super(title);
|
|
170
|
+ thisFrame = this;
|
172
|
171
|
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
173
|
172
|
|
174
|
|
- String[] sPorts = worker.getSerialPorts();
|
|
173
|
+ String[] sPorts = HelperUtility.getPorts();
|
175
|
174
|
for (int i = 0; i < sPorts.length; i++) {
|
176
|
175
|
jComboBox1.addItem(sPorts[i]);
|
177
|
176
|
}
|
178
|
177
|
|
179
|
|
- for (int i = 0; i < worker.numOfAnimations(); i++) {
|
180
|
|
- animModel.addElement(worker.getAnimationName(i));
|
|
178
|
+ for (int i = 0; i < worker.size(); i++) {
|
|
179
|
+ animModel.addElement(worker.getAnimation(i).getName());
|
181
|
180
|
}
|
182
|
181
|
|
183
|
182
|
addWindowListener(new WindowAdapter() {
|
|
@@ -216,7 +215,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
216
|
215
|
cp.add(editA);
|
217
|
216
|
editA.addActionListener(new ActionListener() {
|
218
|
217
|
public void actionPerformed(ActionEvent evt) {
|
219
|
|
- editA_ActionPerformed(evt);
|
|
218
|
+ if (animList.getSelectedIndex() == -1) {
|
|
219
|
+ errorMessage("Please select an animation.");
|
|
220
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
221
|
+ errorMessage("Please select a Frame.");
|
|
222
|
+ } else {
|
|
223
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 0, worker, thisFrame);
|
|
224
|
+ }
|
220
|
225
|
}
|
221
|
226
|
});
|
222
|
227
|
|
|
@@ -226,7 +231,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
226
|
231
|
cp.add(editB);
|
227
|
232
|
editB.addActionListener(new ActionListener() {
|
228
|
233
|
public void actionPerformed(ActionEvent evt) {
|
229
|
|
- editB_ActionPerformed(evt);
|
|
234
|
+ if (animList.getSelectedIndex() == -1) {
|
|
235
|
+ errorMessage("Please select an animation.");
|
|
236
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
237
|
+ errorMessage("Please select a Frame.");
|
|
238
|
+ } else {
|
|
239
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 1, worker, thisFrame);
|
|
240
|
+ }
|
230
|
241
|
}
|
231
|
242
|
});
|
232
|
243
|
|
|
@@ -236,7 +247,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
236
|
247
|
cp.add(editC);
|
237
|
248
|
editC.addActionListener(new ActionListener() {
|
238
|
249
|
public void actionPerformed(ActionEvent evt) {
|
239
|
|
- editC_ActionPerformed(evt);
|
|
250
|
+ if (animList.getSelectedIndex() == -1) {
|
|
251
|
+ errorMessage("Please select an animation.");
|
|
252
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
253
|
+ errorMessage("Please select a Frame.");
|
|
254
|
+ } else {
|
|
255
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 2, worker, thisFrame);
|
|
256
|
+ }
|
240
|
257
|
}
|
241
|
258
|
});
|
242
|
259
|
|
|
@@ -246,7 +263,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
246
|
263
|
cp.add(editD);
|
247
|
264
|
editD.addActionListener(new ActionListener() {
|
248
|
265
|
public void actionPerformed(ActionEvent evt) {
|
249
|
|
- editD_ActionPerformed(evt);
|
|
266
|
+ if (animList.getSelectedIndex() == -1) {
|
|
267
|
+ errorMessage("Please select an animation.");
|
|
268
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
269
|
+ errorMessage("Please select a Frame.");
|
|
270
|
+ } else {
|
|
271
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 3, worker, thisFrame);
|
|
272
|
+ }
|
250
|
273
|
}
|
251
|
274
|
});
|
252
|
275
|
|
|
@@ -256,7 +279,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
256
|
279
|
cp.add(editE);
|
257
|
280
|
editE.addActionListener(new ActionListener() {
|
258
|
281
|
public void actionPerformed(ActionEvent evt) {
|
259
|
|
- editE_ActionPerformed(evt);
|
|
282
|
+ if (animList.getSelectedIndex() == -1) {
|
|
283
|
+ errorMessage("Please select an animation.");
|
|
284
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
285
|
+ errorMessage("Please select a Frame.");
|
|
286
|
+ } else {
|
|
287
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 4, worker, thisFrame);
|
|
288
|
+ }
|
260
|
289
|
}
|
261
|
290
|
});
|
262
|
291
|
|
|
@@ -266,7 +295,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
266
|
295
|
cp.add(editF);
|
267
|
296
|
editF.addActionListener(new ActionListener() {
|
268
|
297
|
public void actionPerformed(ActionEvent evt) {
|
269
|
|
- editF_ActionPerformed(evt);
|
|
298
|
+ if (animList.getSelectedIndex() == -1) {
|
|
299
|
+ errorMessage("Please select an animation.");
|
|
300
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
301
|
+ errorMessage("Please select a Frame.");
|
|
302
|
+ } else {
|
|
303
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 5, worker, thisFrame);
|
|
304
|
+ }
|
270
|
305
|
}
|
271
|
306
|
});
|
272
|
307
|
|
|
@@ -276,7 +311,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
276
|
311
|
cp.add(editG);
|
277
|
312
|
editG.addActionListener(new ActionListener() {
|
278
|
313
|
public void actionPerformed(ActionEvent evt) {
|
279
|
|
- editG_ActionPerformed(evt);
|
|
314
|
+ if (animList.getSelectedIndex() == -1) {
|
|
315
|
+ errorMessage("Please select an animation.");
|
|
316
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
317
|
+ errorMessage("Please select a Frame.");
|
|
318
|
+ } else {
|
|
319
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 6, worker, thisFrame);
|
|
320
|
+ }
|
280
|
321
|
}
|
281
|
322
|
});
|
282
|
323
|
|
|
@@ -286,7 +327,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
286
|
327
|
cp.add(editH);
|
287
|
328
|
editH.addActionListener(new ActionListener() {
|
288
|
329
|
public void actionPerformed(ActionEvent evt) {
|
289
|
|
- editH_ActionPerformed(evt);
|
|
330
|
+ if (animList.getSelectedIndex() == -1) {
|
|
331
|
+ errorMessage("Please select an animation.");
|
|
332
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
333
|
+ errorMessage("Please select a Frame.");
|
|
334
|
+ } else {
|
|
335
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 7, worker, thisFrame);
|
|
336
|
+ }
|
290
|
337
|
}
|
291
|
338
|
});
|
292
|
339
|
|
|
@@ -300,7 +347,14 @@ public class Frame extends JFrame implements ListSelectionListener {
|
300
|
347
|
cp.add(frameUp);
|
301
|
348
|
frameUp.addActionListener(new ActionListener() {
|
302
|
349
|
public void actionPerformed(ActionEvent evt) {
|
303
|
|
- frameUp_ActionPerformed(evt);
|
|
350
|
+ int i = frameList.getSelectedIndex();
|
|
351
|
+ if ((i > 0) && (frameListModel.getSize() >= 2)) {
|
|
352
|
+ Object tmp = frameListModel.get(i);
|
|
353
|
+ frameListModel.set(i, frameListModel.get(i - 1));
|
|
354
|
+ frameListModel.set(i - 1, tmp);
|
|
355
|
+ frameList.setSelectedIndex(i - 1);
|
|
356
|
+ worker.getAnimation(animList.getSelectedIndex()).moveFrameUp(frameList.getSelectedIndex());
|
|
357
|
+ }
|
304
|
358
|
}
|
305
|
359
|
});
|
306
|
360
|
|
|
@@ -310,7 +364,16 @@ public class Frame extends JFrame implements ListSelectionListener {
|
310
|
364
|
cp.add(frameAdd);
|
311
|
365
|
frameAdd.addActionListener(new ActionListener() {
|
312
|
366
|
public void actionPerformed(ActionEvent evt) {
|
313
|
|
- frameAdd_ActionPerformed(evt);
|
|
367
|
+ if (animList.getSelectedIndex() == -1) {
|
|
368
|
+ errorMessage("Please select an animation!");
|
|
369
|
+ } else {
|
|
370
|
+ int n = worker.getAnimation(animList.getSelectedIndex()).size();
|
|
371
|
+ worker.getAnimation(animList.getSelectedIndex()).addFrame();
|
|
372
|
+ // Not reaching past this comment if frame list empty
|
|
373
|
+ frameRemaining.setText(Integer.toString(worker.memoryRemaining()));
|
|
374
|
+ frameListModel.add(n, worker.getAnimation(animList.getSelectedIndex()).getFrame(n).getName());
|
|
375
|
+ frameList.setModel(frameListModel);
|
|
376
|
+ }
|
314
|
377
|
}
|
315
|
378
|
});
|
316
|
379
|
|
|
@@ -320,7 +383,16 @@ public class Frame extends JFrame implements ListSelectionListener {
|
320
|
383
|
cp.add(frameRemove);
|
321
|
384
|
frameRemove.addActionListener(new ActionListener() {
|
322
|
385
|
public void actionPerformed(ActionEvent evt) {
|
323
|
|
- frameRemove_ActionPerformed(evt);
|
|
386
|
+ if (animList.getSelectedIndex() == -1) {
|
|
387
|
+ errorMessage("Select an animation.");
|
|
388
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
389
|
+ errorMessage("Select a Frame.");
|
|
390
|
+ } else {
|
|
391
|
+ worker.getAnimation(animList.getSelectedIndex()).removeFrame(frameList.getSelectedIndex());
|
|
392
|
+ frameRemaining.setText(Integer.toString(worker.memoryRemaining()));
|
|
393
|
+ frameListModel.removeElementAt(frameList.getSelectedIndex());
|
|
394
|
+ frameList.setModel(frameListModel);
|
|
395
|
+ }
|
324
|
396
|
}
|
325
|
397
|
});
|
326
|
398
|
|
|
@@ -340,11 +412,8 @@ public class Frame extends JFrame implements ListSelectionListener {
|
340
|
412
|
errorMessage("Select a Frame!");
|
341
|
413
|
return;
|
342
|
414
|
}
|
343
|
|
- worker.setFrameName(
|
344
|
|
- askString("Rename",
|
345
|
|
- "Rename " + frameList.getSelectedValue() + "?"),
|
346
|
|
- a, f);
|
347
|
|
- frameListModel.set(f, worker.getFrameName(a, f));
|
|
415
|
+ worker.getAnimation(a).getFrame(f).setName(askString("Rename", "Rename " + frameList.getSelectedValue() + "?"));
|
|
416
|
+ frameListModel.set(f, worker.getAnimation(a).getFrame(f).getName());
|
348
|
417
|
frameList.setModel(frameListModel);
|
349
|
418
|
}
|
350
|
419
|
});
|
|
@@ -355,7 +424,14 @@ public class Frame extends JFrame implements ListSelectionListener {
|
355
|
424
|
cp.add(frameDown);
|
356
|
425
|
frameDown.addActionListener(new ActionListener() {
|
357
|
426
|
public void actionPerformed(ActionEvent evt) {
|
358
|
|
- frameDown_ActionPerformed(evt);
|
|
427
|
+ int i = frameList.getSelectedIndex();
|
|
428
|
+ if ((i >= 0) && (frameListModel.getSize() >= 2) && (i < (frameListModel.getSize() - 1))) {
|
|
429
|
+ Object tmp = frameListModel.get(i);
|
|
430
|
+ frameListModel.set(i, frameListModel.get(i + 1));
|
|
431
|
+ frameListModel.set(i + 1, tmp);
|
|
432
|
+ frameList.setSelectedIndex(i + 1);
|
|
433
|
+ worker.getAnimation(animList.getSelectedIndex()).moveFrameDown(frameList.getSelectedIndex());
|
|
434
|
+ }
|
359
|
435
|
}
|
360
|
436
|
});
|
361
|
437
|
|
|
@@ -375,7 +451,14 @@ public class Frame extends JFrame implements ListSelectionListener {
|
375
|
451
|
cp.add(fullScreenButton);
|
376
|
452
|
fullScreenButton.addActionListener(new ActionListener() {
|
377
|
453
|
public void actionPerformed(ActionEvent evt) {
|
378
|
|
- enterFullscreen(evt);
|
|
454
|
+ ledView.enterFullscreen();
|
|
455
|
+ setLocation(0,0);
|
|
456
|
+ setSize(700, 700);
|
|
457
|
+ int w = Toolkit.getDefaultToolkit().getScreenSize().width;
|
|
458
|
+ int h = Toolkit.getDefaultToolkit().getScreenSize().height;
|
|
459
|
+ setSize(w - 5, h - 30);
|
|
460
|
+ playAnimationFullscreen.setVisible(true);
|
|
461
|
+ cubeCanvas.setBounds(0, 0, w - 5, h - 80);
|
379
|
462
|
}
|
380
|
463
|
});
|
381
|
464
|
|
|
@@ -384,18 +467,40 @@ public class Frame extends JFrame implements ListSelectionListener {
|
384
|
467
|
cp.add(exitButton);
|
385
|
468
|
exitButton.addActionListener(new ActionListener() {
|
386
|
469
|
public void actionPerformed(ActionEvent evt) {
|
387
|
|
- exitFullscreen();
|
|
470
|
+ playAnimationFullscreen.setVisible(false);
|
|
471
|
+ setLocation(0,0);
|
|
472
|
+ setSize(661, 440);
|
|
473
|
+ ledView.leaveFullscreen();
|
|
474
|
+ cubeCanvas.setBounds(8,8, 250,250);
|
|
475
|
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
|
476
|
+ int x = (d.width - getSize().width) / 2;
|
|
477
|
+ int y = (d.height - getSize().height) / 2;
|
|
478
|
+ setLocation(x, y);
|
388
|
479
|
}
|
389
|
480
|
});
|
390
|
481
|
|
391
|
|
-
|
392
|
482
|
playAnimation.setText("Play");
|
393
|
483
|
playAnimation.setBounds(344, 390, 147, 25);
|
394
|
484
|
playAnimation.setFont(new Font("Dialog", Font.PLAIN, 13));
|
395
|
485
|
cp.add(playAnimation);
|
396
|
486
|
playAnimation.addActionListener(new ActionListener() {
|
397
|
487
|
public void actionPerformed(ActionEvent evt){
|
398
|
|
- playAnimation(evt);
|
|
488
|
+ if (animList.getSelectedIndex() == -1) {
|
|
489
|
+ errorMessage("Please select an animation.");
|
|
490
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
491
|
+ errorMessage("Please select a Frame.");
|
|
492
|
+ } else {
|
|
493
|
+ for(int i = 0; i < frameList.getModel().getSize(); i++){
|
|
494
|
+ frameList.setSelectedIndex(i);
|
|
495
|
+ short time1 = worker.getAnimation(animList.getSelectedIndex()).getFrame(frameList.getSelectedIndex()).getTime();
|
|
496
|
+ long time = (long) (((time1+1) * 1/24) * 1000);
|
|
497
|
+ try {
|
|
498
|
+ Thread.sleep(time);
|
|
499
|
+ } catch(Exception e) {
|
|
500
|
+ System.out.println(e);
|
|
501
|
+ }
|
|
502
|
+ }
|
|
503
|
+ }
|
399
|
504
|
}
|
400
|
505
|
});
|
401
|
506
|
|
|
@@ -406,11 +511,25 @@ public class Frame extends JFrame implements ListSelectionListener {
|
406
|
511
|
cp.add(playAnimationFullscreen);
|
407
|
512
|
playAnimationFullscreen.addActionListener(new ActionListener() {
|
408
|
513
|
public void actionPerformed(ActionEvent evt){
|
409
|
|
- playAnimation(evt);
|
|
514
|
+ if (animList.getSelectedIndex() == -1) {
|
|
515
|
+ errorMessage("Please select an animation.");
|
|
516
|
+ } else if (frameList.getSelectedIndex() == -1) {
|
|
517
|
+ errorMessage("Please select a Frame.");
|
|
518
|
+ } else {
|
|
519
|
+ for(int i = 0; i < frameList.getModel().getSize(); i++){
|
|
520
|
+ frameList.setSelectedIndex(i);
|
|
521
|
+ short time1 = worker.getAnimation(animList.getSelectedIndex()).getFrame(frameList.getSelectedIndex()).getTime();
|
|
522
|
+ long time = (long) (((time1+1) * 1/24) * 1000);
|
|
523
|
+ try {
|
|
524
|
+ Thread.sleep(time);
|
|
525
|
+ } catch(Exception e) {
|
|
526
|
+ System.out.println(e);
|
|
527
|
+ }
|
|
528
|
+ }
|
|
529
|
+ }
|
410
|
530
|
}
|
411
|
531
|
});
|
412
|
532
|
|
413
|
|
-
|
414
|
533
|
frameDuration.setBounds(590, 184, 60, 24);
|
415
|
534
|
frameDuration.setText("OK");
|
416
|
535
|
frameDuration.setFont(new Font("Dialog", Font.PLAIN, 13));
|
|
@@ -433,10 +552,7 @@ public class Frame extends JFrame implements ListSelectionListener {
|
433
|
552
|
errorMessage("Please select a Frame!");
|
434
|
553
|
return;
|
435
|
554
|
}
|
436
|
|
- worker.setFrameTime(
|
437
|
|
- (byte) (Integer.parseInt(frameLengthText.getText()) - 1),
|
438
|
|
- animList.getSelectedIndex(),
|
439
|
|
- frameList.getSelectedIndex());
|
|
555
|
+ worker.getAnimation(animList.getSelectedIndex()).getFrame(frameList.getSelectedIndex()).setTime((byte)(Integer.parseInt(frameLengthText.getText()) - 1));
|
440
|
556
|
}
|
441
|
557
|
}
|
442
|
558
|
});
|
|
@@ -452,7 +568,14 @@ public class Frame extends JFrame implements ListSelectionListener {
|
452
|
568
|
cp.add(animUp);
|
453
|
569
|
animUp.addActionListener(new ActionListener() {
|
454
|
570
|
public void actionPerformed(ActionEvent evt) {
|
455
|
|
- animUp_ActionPerformed(evt);
|
|
571
|
+ int i = animList.getSelectedIndex();
|
|
572
|
+ if ((i > 0) && (animModel.getSize() >= 2)) {
|
|
573
|
+ Object tmp = animModel.get(i);
|
|
574
|
+ animModel.set(i, animModel.get(i - 1));
|
|
575
|
+ animModel.set(i - 1, tmp);
|
|
576
|
+ animList.setSelectedIndex(i - 1);
|
|
577
|
+ worker.moveAnimationUp(animList.getSelectedIndex());
|
|
578
|
+ }
|
456
|
579
|
}
|
457
|
580
|
});
|
458
|
581
|
|
|
@@ -462,7 +585,14 @@ public class Frame extends JFrame implements ListSelectionListener {
|
462
|
585
|
cp.add(animDown);
|
463
|
586
|
animDown.addActionListener(new ActionListener() {
|
464
|
587
|
public void actionPerformed(ActionEvent evt) {
|
465
|
|
- animDown_ActionPerformed(evt);
|
|
588
|
+ int i = animList.getSelectedIndex();
|
|
589
|
+ if ((i >= 0) && (animModel.getSize() >= 2) && (i < (animModel.getSize() - 1))) {
|
|
590
|
+ Object tmp = animModel.get(i);
|
|
591
|
+ animModel.set(i, animModel.get(i + 1));
|
|
592
|
+ animModel.set(i + 1, tmp);
|
|
593
|
+ animList.setSelectedIndex(i + 1);
|
|
594
|
+ worker.moveAnimationDown(animList.getSelectedIndex());
|
|
595
|
+ }
|
466
|
596
|
}
|
467
|
597
|
});
|
468
|
598
|
|
|
@@ -477,11 +607,8 @@ public class Frame extends JFrame implements ListSelectionListener {
|
477
|
607
|
errorMessage("Select an animation!");
|
478
|
608
|
return;
|
479
|
609
|
}
|
480
|
|
- worker.setAnimationName(
|
481
|
|
- askString("Rename",
|
482
|
|
- "Rename " + animList.getSelectedValue() + "?"),
|
483
|
|
- a);
|
484
|
|
- animModel.set(a, worker.getAnimationName(a));
|
|
610
|
+ worker.getAnimation(a).setName(askString("Rename", "Rename " + animList.getSelectedValue() + "?"));
|
|
611
|
+ animModel.set(a, worker.getAnimation(a).getName());
|
485
|
612
|
animList.setModel(animModel);
|
486
|
613
|
}
|
487
|
614
|
});
|
|
@@ -492,7 +619,15 @@ public class Frame extends JFrame implements ListSelectionListener {
|
492
|
619
|
cp.add(animAdd);
|
493
|
620
|
animAdd.addActionListener(new ActionListener() {
|
494
|
621
|
public void actionPerformed(ActionEvent evt) {
|
495
|
|
- animAdd_ActionPerformed(evt);
|
|
622
|
+ if (worker.addAnimation() == -1) {
|
|
623
|
+ errorMessage("Could not add animation!");
|
|
624
|
+ } else {
|
|
625
|
+ animModel.clear();
|
|
626
|
+ for (int i = 0; i < worker.size(); i++) {
|
|
627
|
+ animModel.add(i, worker.getAnimation(i).getName());
|
|
628
|
+ }
|
|
629
|
+ animList.setModel(animModel);
|
|
630
|
+ }
|
496
|
631
|
}
|
497
|
632
|
});
|
498
|
633
|
|
|
@@ -502,7 +637,13 @@ public class Frame extends JFrame implements ListSelectionListener {
|
502
|
637
|
cp.add(animRemove);
|
503
|
638
|
animRemove.addActionListener(new ActionListener() {
|
504
|
639
|
public void actionPerformed(ActionEvent evt) {
|
505
|
|
- animRemove_ActionPerformed(evt);
|
|
640
|
+ if (animList.getSelectedIndex() == -1) {
|
|
641
|
+ errorMessage("Select an animation.");
|
|
642
|
+ } else {
|
|
643
|
+ worker.removeAnimation(animList.getSelectedIndex());
|
|
644
|
+ animModel.removeElementAt(animList.getSelectedIndex());
|
|
645
|
+ animList.setModel(animModel);
|
|
646
|
+ }
|
506
|
647
|
}
|
507
|
648
|
});
|
508
|
649
|
|
|
@@ -517,7 +658,24 @@ public class Frame extends JFrame implements ListSelectionListener {
|
517
|
658
|
cp.add(load);
|
518
|
659
|
load.addActionListener(new ActionListener() {
|
519
|
660
|
public void actionPerformed(ActionEvent evt) {
|
520
|
|
- load_ActionPerformed(evt);
|
|
661
|
+ JFileChooser fc = new JFileChooser();
|
|
662
|
+ int ret = fc.showOpenDialog(thisFrame);
|
|
663
|
+ if (ret == JFileChooser.APPROVE_OPTION) {
|
|
664
|
+ File file = fc.getSelectedFile();
|
|
665
|
+ if (fileSelected == false) {
|
|
666
|
+ fileSelected = true;
|
|
667
|
+ }
|
|
668
|
+ animPath.setText(file.getPath());
|
|
669
|
+ worker.loadState(animPath.getText());
|
|
670
|
+ animModel.clear();
|
|
671
|
+ for (int i = 0; i < worker.size(); i++) {
|
|
672
|
+ animModel.addElement(worker.getAnimation(i).getName());
|
|
673
|
+ }
|
|
674
|
+ animList.setModel(animModel);
|
|
675
|
+
|
|
676
|
+ frameListModel.clear();
|
|
677
|
+ frameList.setModel(frameListModel);
|
|
678
|
+ }
|
521
|
679
|
}
|
522
|
680
|
});
|
523
|
681
|
|
|
@@ -527,7 +685,18 @@ public class Frame extends JFrame implements ListSelectionListener {
|
527
|
685
|
cp.add(save);
|
528
|
686
|
save.addActionListener(new ActionListener() {
|
529
|
687
|
public void actionPerformed(ActionEvent evt) {
|
530
|
|
- save_ActionPerformed(evt);
|
|
688
|
+ if (fileSelected == false) {
|
|
689
|
+ JFileChooser fc = new JFileChooser();
|
|
690
|
+ int ret = fc.showSaveDialog(thisFrame);
|
|
691
|
+ if (ret == JFileChooser.APPROVE_OPTION) {
|
|
692
|
+ File file = fc.getSelectedFile();
|
|
693
|
+ fileSelected = true;
|
|
694
|
+ animPath.setText(file.getPath());
|
|
695
|
+ worker.saveState(animPath.getText());
|
|
696
|
+ }
|
|
697
|
+ } else {
|
|
698
|
+ worker.saveState(animPath.getText());
|
|
699
|
+ }
|
531
|
700
|
}
|
532
|
701
|
});
|
533
|
702
|
|
|
@@ -537,7 +706,21 @@ public class Frame extends JFrame implements ListSelectionListener {
|
537
|
706
|
cp.add(saveAs);
|
538
|
707
|
saveAs.addActionListener(new ActionListener() {
|
539
|
708
|
public void actionPerformed(ActionEvent evt) {
|
540
|
|
- saveAs_ActionPerformed(evt);
|
|
709
|
+ JFileChooser fc;
|
|
710
|
+ if (fileSelected == true) {
|
|
711
|
+ fc = new JFileChooser(new File(animPath.getText()).getParentFile());
|
|
712
|
+ } else {
|
|
713
|
+ fc = new JFileChooser();
|
|
714
|
+ }
|
|
715
|
+ int ret = fc.showSaveDialog(thisFrame);
|
|
716
|
+ if (ret == JFileChooser.APPROVE_OPTION) {
|
|
717
|
+ File file = fc.getSelectedFile();
|
|
718
|
+ if (fileSelected == false) {
|
|
719
|
+ fileSelected = true;
|
|
720
|
+ }
|
|
721
|
+ animPath.setText(file.getPath());
|
|
722
|
+ worker.saveState(animPath.getText());
|
|
723
|
+ }
|
541
|
724
|
}
|
542
|
725
|
});
|
543
|
726
|
|
|
@@ -550,7 +733,17 @@ public class Frame extends JFrame implements ListSelectionListener {
|
550
|
733
|
cp.add(upload);
|
551
|
734
|
upload.addActionListener(new ActionListener() {
|
552
|
735
|
public void actionPerformed(ActionEvent evt) {
|
553
|
|
- upload_ActionPerformed(evt);
|
|
736
|
+ if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
|
|
737
|
+ // errorMessage("No serial port selected...");
|
|
738
|
+ } else {
|
|
739
|
+ if (worker.cubeProbeConnected((String) jComboBox1.getSelectedItem())) {
|
|
740
|
+ if (worker.cubeSendState((String) jComboBox1.getSelectedItem()) != 0) {
|
|
741
|
+ // errorMessage("Could not upload data!");
|
|
742
|
+ }
|
|
743
|
+ } else {
|
|
744
|
+ // errorMessage("Cube does not respond...");
|
|
745
|
+ }
|
|
746
|
+ }
|
554
|
747
|
}
|
555
|
748
|
});
|
556
|
749
|
|
|
@@ -560,7 +753,17 @@ public class Frame extends JFrame implements ListSelectionListener {
|
560
|
753
|
cp.add(download);
|
561
|
754
|
download.addActionListener(new ActionListener() {
|
562
|
755
|
public void actionPerformed(ActionEvent evt) {
|
563
|
|
- download_ActionPerformed(evt);
|
|
756
|
+ if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
|
|
757
|
+ // errorMessage("No serial port selected...");
|
|
758
|
+ } else {
|
|
759
|
+ if (worker.cubeProbeConnected((String) jComboBox1.getSelectedItem())) {
|
|
760
|
+ if (worker.cubeGetState((String) jComboBox1.getSelectedItem()) != 0) {
|
|
761
|
+ // errorMessage("Could not download data!");
|
|
762
|
+ }
|
|
763
|
+ } else {
|
|
764
|
+ // errorMessage("Cube does not respond...");
|
|
765
|
+ }
|
|
766
|
+ }
|
564
|
767
|
}
|
565
|
768
|
});
|
566
|
769
|
|
|
@@ -570,7 +773,7 @@ public class Frame extends JFrame implements ListSelectionListener {
|
570
|
773
|
cp.add(jLabel4);
|
571
|
774
|
frameRemaining.setBounds(536, 232, 113, 24);
|
572
|
775
|
frameRemaining.setEditable(false);
|
573
|
|
- frameRemaining.setText(String.valueOf(worker.framesRemaining()));
|
|
776
|
+ frameRemaining.setText(String.valueOf(worker.memoryRemaining()));
|
574
|
777
|
frameRemaining.setFont(new Font("Dialog", Font.PLAIN, 13));
|
575
|
778
|
cp.add(frameRemaining);
|
576
|
779
|
animList.setFont(new Font("Dialog", Font.PLAIN, 13));
|
|
@@ -582,348 +785,6 @@ public class Frame extends JFrame implements ListSelectionListener {
|
582
|
785
|
setVisible(true);
|
583
|
786
|
}
|
584
|
787
|
|
585
|
|
- // Anfang Methoden
|
586
|
|
-
|
587
|
|
- // Anfang Ereignisprozeduren
|
588
|
|
-
|
589
|
|
- public void playAnimation(ActionEvent evt){
|
590
|
|
- if (animList.getSelectedIndex() == -1) {
|
591
|
|
- errorMessage("Please select an animation.");
|
592
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
593
|
|
- errorMessage("Please select a Frame.");
|
594
|
|
- } else {
|
595
|
|
- for(int i = 0; i < frameList.getModel().getSize(); i++){
|
596
|
|
- frameList.setSelectedIndex(i);
|
597
|
|
- short time1 = worker.getFrameTime(animList.getSelectedIndex(), frameList.getSelectedIndex());
|
598
|
|
- long time = (long) (((time1+1) * 1/24) * 1000);
|
599
|
|
- try{
|
600
|
|
- Thread.sleep(time);
|
601
|
|
- }catch(Exception e){
|
602
|
|
- System.out.println(e);
|
603
|
|
- }
|
604
|
|
- }
|
605
|
|
- }
|
606
|
|
-
|
607
|
|
- }
|
608
|
|
-
|
609
|
|
- public void enterFullscreen(ActionEvent evt) {
|
610
|
|
- ledView.enterFullscreen();
|
611
|
|
- //FullscreenWindow fw = new FullscreenWindow(worker, cubeCanvas, ledView, this);
|
612
|
|
- setLocation(0,0);
|
613
|
|
- setSize(700, 700);
|
614
|
|
- int w = Toolkit.getDefaultToolkit().getScreenSize().width;
|
615
|
|
- int h = Toolkit.getDefaultToolkit().getScreenSize().height;
|
616
|
|
- System.out.println(w);
|
617
|
|
- System.out.println(h);
|
618
|
|
- setSize(w-5, h-30);
|
619
|
|
-
|
620
|
|
- playAnimationFullscreen.setVisible(true);
|
621
|
|
- //setSize(Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height);
|
622
|
|
- //Y U NO WORK????
|
623
|
|
- cubeCanvas.setBounds(0,0,Toolkit.getDefaultToolkit().getScreenSize().width-5, Toolkit.getDefaultToolkit().getScreenSize().height-80);
|
624
|
|
-
|
625
|
|
- }
|
626
|
|
- public void exitFullscreen(){
|
627
|
|
- //661, 440
|
628
|
|
- playAnimationFullscreen.setVisible(false);
|
629
|
|
- setLocation(0,0);
|
630
|
|
- setSize(661, 440);
|
631
|
|
- ledView.leaveFullscreen();
|
632
|
|
- cubeCanvas.setBounds(8,8, 250,250);
|
633
|
|
- Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
|
634
|
|
- int x = (d.width - getSize().width) / 2;
|
635
|
|
- int y = (d.height - getSize().height) / 2;
|
636
|
|
- setLocation(x, y);
|
637
|
|
- }
|
638
|
|
-
|
639
|
|
- public void editA_ActionPerformed(ActionEvent evt) {
|
640
|
|
-
|
641
|
|
- if (animList.getSelectedIndex() == -1) {
|
642
|
|
- errorMessage("Please select an animation.");
|
643
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
644
|
|
- errorMessage("Please select a Frame.");
|
645
|
|
- } else {
|
646
|
|
- @SuppressWarnings("unused")
|
647
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
648
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
649
|
|
- 0, worker, this);
|
650
|
|
-
|
651
|
|
- }
|
652
|
|
- }
|
653
|
|
-
|
654
|
|
- public void editB_ActionPerformed(ActionEvent evt) {
|
655
|
|
- if (animList.getSelectedIndex() == -1) {
|
656
|
|
- errorMessage("Please select an animation.");
|
657
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
658
|
|
- errorMessage("Please select a Frame.");
|
659
|
|
- } else {
|
660
|
|
- @SuppressWarnings("unused")
|
661
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
662
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
663
|
|
- 1, worker, this);
|
664
|
|
- }
|
665
|
|
- }
|
666
|
|
-
|
667
|
|
- public void editC_ActionPerformed(ActionEvent evt) {
|
668
|
|
- if (animList.getSelectedIndex() == -1) {
|
669
|
|
- errorMessage("Please select an animation.");
|
670
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
671
|
|
- errorMessage("Please select a Frame.");
|
672
|
|
- } else {
|
673
|
|
- @SuppressWarnings("unused")
|
674
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
675
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
676
|
|
- 2, worker, this);
|
677
|
|
- }
|
678
|
|
- }
|
679
|
|
-
|
680
|
|
- public void editD_ActionPerformed(ActionEvent evt) {
|
681
|
|
- if (animList.getSelectedIndex() == -1) {
|
682
|
|
- errorMessage("Please select an animation.");
|
683
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
684
|
|
- errorMessage("Please select a Frame.");
|
685
|
|
- } else {
|
686
|
|
- @SuppressWarnings("unused")
|
687
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
688
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
689
|
|
- 3, worker, this);
|
690
|
|
- }
|
691
|
|
- }
|
692
|
|
-
|
693
|
|
- public void editE_ActionPerformed(ActionEvent evt) {
|
694
|
|
- if (animList.getSelectedIndex() == -1) {
|
695
|
|
- errorMessage("Please select an animation.");
|
696
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
697
|
|
- errorMessage("Please select a Frame.");
|
698
|
|
- } else {
|
699
|
|
- @SuppressWarnings("unused")
|
700
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
701
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
702
|
|
- 4, worker, this);
|
703
|
|
- }
|
704
|
|
- }
|
705
|
|
-
|
706
|
|
- public void editF_ActionPerformed(ActionEvent evt) {
|
707
|
|
- if (animList.getSelectedIndex() == -1) {
|
708
|
|
- errorMessage("Please select an animation.");
|
709
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
710
|
|
- errorMessage("Please select a Frame.");
|
711
|
|
- } else {
|
712
|
|
- @SuppressWarnings("unused")
|
713
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
714
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
715
|
|
- 5, worker, this);
|
716
|
|
- }
|
717
|
|
- }
|
718
|
|
-
|
719
|
|
- public void editG_ActionPerformed(ActionEvent evt) {
|
720
|
|
- if (animList.getSelectedIndex() == -1) {
|
721
|
|
- errorMessage("Please select an animation.");
|
722
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
723
|
|
- errorMessage("Please select a Frame.");
|
724
|
|
- } else {
|
725
|
|
- @SuppressWarnings("unused")
|
726
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
727
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
728
|
|
- 6, worker, this);
|
729
|
|
- }
|
730
|
|
- }
|
731
|
|
-
|
732
|
|
- public void editH_ActionPerformed(ActionEvent evt) {
|
733
|
|
- if (animList.getSelectedIndex() == -1) {
|
734
|
|
- errorMessage("Please select an animation.");
|
735
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
736
|
|
- errorMessage("Please select a Frame.");
|
737
|
|
- } else {
|
738
|
|
- @SuppressWarnings("unused")
|
739
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(
|
740
|
|
- animList.getSelectedIndex(), frameList.getSelectedIndex(),
|
741
|
|
- 7, worker, this);
|
742
|
|
- }
|
743
|
|
- }
|
744
|
|
-
|
745
|
|
- public void frameUp_ActionPerformed(ActionEvent evt) {
|
746
|
|
- int i = frameList.getSelectedIndex();
|
747
|
|
- if ((i > 0) && (frameListModel.getSize() >= 2)) {
|
748
|
|
- Object tmp = frameListModel.get(i);
|
749
|
|
- frameListModel.set(i, frameListModel.get(i - 1));
|
750
|
|
- frameListModel.set(i - 1, tmp);
|
751
|
|
- frameList.setSelectedIndex(i - 1);
|
752
|
|
- worker.moveFrame(worker.UP, animList.getSelectedIndex(),
|
753
|
|
- frameList.getSelectedIndex());
|
754
|
|
- }
|
755
|
|
- }
|
756
|
|
-
|
757
|
|
- public void frameDown_ActionPerformed(ActionEvent evt) {
|
758
|
|
- int i = frameList.getSelectedIndex();
|
759
|
|
- if ((i >= 0) && (frameListModel.getSize() >= 2)
|
760
|
|
- && (i < (frameListModel.getSize() - 1))) {
|
761
|
|
- Object tmp = frameListModel.get(i);
|
762
|
|
- frameListModel.set(i, frameListModel.get(i + 1));
|
763
|
|
- frameListModel.set(i + 1, tmp);
|
764
|
|
- frameList.setSelectedIndex(i + 1);
|
765
|
|
- worker.moveFrame(worker.DOWN, animList.getSelectedIndex(),
|
766
|
|
- frameList.getSelectedIndex());
|
767
|
|
- }
|
768
|
|
- }
|
769
|
|
-
|
770
|
|
- public void frameAdd_ActionPerformed(ActionEvent evt) {
|
771
|
|
- if (animList.getSelectedIndex() == -1) {
|
772
|
|
- errorMessage("Please select an animation!");
|
773
|
|
- } else {
|
774
|
|
- int n = worker.numOfFrames(animList.getSelectedIndex());
|
775
|
|
- worker.addFrame(animList.getSelectedIndex());
|
776
|
|
- // Not reaching past this comment if frame list empty
|
777
|
|
- frameRemaining.setText(Integer.toString(worker.framesRemaining()));
|
778
|
|
- frameListModel.add(n,
|
779
|
|
- worker.getFrameName(animList.getSelectedIndex(), n));
|
780
|
|
- frameList.setModel(frameListModel);
|
781
|
|
- }
|
782
|
|
- }
|
783
|
|
-
|
784
|
|
- public void frameRemove_ActionPerformed(ActionEvent evt) {
|
785
|
|
- if (animList.getSelectedIndex() == -1) {
|
786
|
|
- errorMessage("Select an animation.");
|
787
|
|
- } else if (frameList.getSelectedIndex() == -1) {
|
788
|
|
- errorMessage("Select a Frame.");
|
789
|
|
- } else {
|
790
|
|
- worker.removeFrame(animList.getSelectedIndex(),
|
791
|
|
- frameList.getSelectedIndex());
|
792
|
|
- frameRemaining.setText(Integer.toString(worker.framesRemaining()));
|
793
|
|
- frameListModel.removeElementAt(frameList.getSelectedIndex());
|
794
|
|
- frameList.setModel(frameListModel);
|
795
|
|
- }
|
796
|
|
- }
|
797
|
|
-
|
798
|
|
- public void animUp_ActionPerformed(ActionEvent evt) {
|
799
|
|
- int i = animList.getSelectedIndex();
|
800
|
|
- if ((i > 0) && (animModel.getSize() >= 2)) {
|
801
|
|
- Object tmp = animModel.get(i);
|
802
|
|
- animModel.set(i, animModel.get(i - 1));
|
803
|
|
- animModel.set(i - 1, tmp);
|
804
|
|
- animList.setSelectedIndex(i - 1);
|
805
|
|
- worker.moveAnimation(worker.UP, animList.getSelectedIndex());
|
806
|
|
- }
|
807
|
|
- }
|
808
|
|
-
|
809
|
|
- public void animDown_ActionPerformed(ActionEvent evt) {
|
810
|
|
- int i = animList.getSelectedIndex();
|
811
|
|
- if ((i >= 0) && (animModel.getSize() >= 2)
|
812
|
|
- && (i < (animModel.getSize() - 1))) {
|
813
|
|
- Object tmp = animModel.get(i);
|
814
|
|
- animModel.set(i, animModel.get(i + 1));
|
815
|
|
- animModel.set(i + 1, tmp);
|
816
|
|
- animList.setSelectedIndex(i + 1);
|
817
|
|
- worker.moveAnimation(worker.DOWN, animList.getSelectedIndex());
|
818
|
|
- }
|
819
|
|
- }
|
820
|
|
-
|
821
|
|
- public void animAdd_ActionPerformed(ActionEvent evt) {
|
822
|
|
- if (worker.addAnimation() == -1) {
|
823
|
|
- errorMessage("Could not add animation!");
|
824
|
|
- } else {
|
825
|
|
- animModel.clear();
|
826
|
|
- for (int i = 0; i < worker.numOfAnimations(); i++) {
|
827
|
|
- animModel.add(i, worker.getAnimationName(i));
|
828
|
|
- }
|
829
|
|
- animList.setModel(animModel);
|
830
|
|
- }
|
831
|
|
-
|
832
|
|
- }
|
833
|
|
-
|
834
|
|
- public void animRemove_ActionPerformed(ActionEvent evt) {
|
835
|
|
- if (animList.getSelectedIndex() == -1) {
|
836
|
|
- errorMessage("Select an animation.");
|
837
|
|
- } else {
|
838
|
|
- worker.removeAnimation(animList.getSelectedIndex());
|
839
|
|
- animModel.removeElementAt(animList.getSelectedIndex());
|
840
|
|
- animList.setModel(animModel);
|
841
|
|
- }
|
842
|
|
- }
|
843
|
|
-
|
844
|
|
- public void load_ActionPerformed(ActionEvent evt) {
|
845
|
|
- JFileChooser fc = new JFileChooser();
|
846
|
|
- int ret = fc.showOpenDialog(this);
|
847
|
|
- if (ret == JFileChooser.APPROVE_OPTION) {
|
848
|
|
- File file = fc.getSelectedFile();
|
849
|
|
- if (fileSelected == false) {
|
850
|
|
- fileSelected = true;
|
851
|
|
- }
|
852
|
|
- animPath.setText(file.getPath());
|
853
|
|
- worker.loadState(animPath.getText());
|
854
|
|
- animModel.clear();
|
855
|
|
- for (int i = 0; i < worker.numOfAnimations(); i++) {
|
856
|
|
- animModel.addElement(worker.getAnimationName(i));
|
857
|
|
- }
|
858
|
|
- animList.setModel(animModel);
|
859
|
|
-
|
860
|
|
- frameListModel.clear();
|
861
|
|
- frameList.setModel(frameListModel);
|
862
|
|
- }
|
863
|
|
- }
|
864
|
|
-
|
865
|
|
- public void save_ActionPerformed(ActionEvent evt) {
|
866
|
|
- if (fileSelected == false) {
|
867
|
|
- JFileChooser fc = new JFileChooser();
|
868
|
|
- int ret = fc.showSaveDialog(this);
|
869
|
|
- if (ret == JFileChooser.APPROVE_OPTION) {
|
870
|
|
- File file = fc.getSelectedFile();
|
871
|
|
- fileSelected = true;
|
872
|
|
- animPath.setText(file.getPath());
|
873
|
|
- worker.saveState(animPath.getText());
|
874
|
|
- }
|
875
|
|
- } else {
|
876
|
|
- worker.saveState(animPath.getText());
|
877
|
|
- }
|
878
|
|
- }
|
879
|
|
-
|
880
|
|
- public void saveAs_ActionPerformed(ActionEvent evt) {
|
881
|
|
- JFileChooser fc;
|
882
|
|
- if (fileSelected == true) {
|
883
|
|
- fc = new JFileChooser(new File(animPath.getText()).getParentFile());
|
884
|
|
- } else {
|
885
|
|
- fc = new JFileChooser();
|
886
|
|
- }
|
887
|
|
- int ret = fc.showSaveDialog(this);
|
888
|
|
- if (ret == JFileChooser.APPROVE_OPTION) {
|
889
|
|
- File file = fc.getSelectedFile();
|
890
|
|
- if (fileSelected == false) {
|
891
|
|
- fileSelected = true;
|
892
|
|
- }
|
893
|
|
- animPath.setText(file.getPath());
|
894
|
|
- worker.saveState(animPath.getText());
|
895
|
|
- }
|
896
|
|
- }
|
897
|
|
-
|
898
|
|
- // We get detailed error messages from the SerialHelper...
|
899
|
|
- public void upload_ActionPerformed(ActionEvent evt) {
|
900
|
|
- if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
|
901
|
|
- // errorMessage("No serial port selected...");
|
902
|
|
- } else {
|
903
|
|
- if (worker.probeCubeConnected((String) jComboBox1.getSelectedItem())) {
|
904
|
|
- if (worker.uploadState((String) jComboBox1.getSelectedItem()) != 0) {
|
905
|
|
- // errorMessage("Could not upload data!");
|
906
|
|
- }
|
907
|
|
- } else {
|
908
|
|
- // errorMessage("Cube does not respond...");
|
909
|
|
- }
|
910
|
|
- }
|
911
|
|
- }
|
912
|
|
-
|
913
|
|
- public void download_ActionPerformed(ActionEvent evt) {
|
914
|
|
- if (jComboBox1.getSelectedItem().equals("Select serial port...")) {
|
915
|
|
- // errorMessage("No serial port selected...");
|
916
|
|
- } else {
|
917
|
|
- if (worker.probeCubeConnected((String) jComboBox1.getSelectedItem())) {
|
918
|
|
- if (worker.downloadState((String) jComboBox1.getSelectedItem()) != 0) {
|
919
|
|
- // errorMessage("Could not download data!");
|
920
|
|
- }
|
921
|
|
- } else {
|
922
|
|
- // errorMessage("Cube does not respond...");
|
923
|
|
- }
|
924
|
|
- }
|
925
|
|
- }
|
926
|
|
-
|
927
|
788
|
public Led3D get3D() {
|
928
|
789
|
return ledView;
|
929
|
790
|
}
|
|
@@ -1003,26 +864,26 @@ public class Frame extends JFrame implements ListSelectionListener {
|
1003
|
864
|
|
1004
|
865
|
if (s.startsWith("frames ")) {
|
1005
|
866
|
int anim = Integer.parseInt(s.substring(7));
|
1006
|
|
- if (anim >= f.worker.numOfAnimations()) {
|
1007
|
|
- System.out.println("Animation does not exist! Max: " + (f.worker.numOfAnimations() - 1));
|
|
867
|
+ if (anim >= f.worker.size()) {
|
|
868
|
+ System.out.println("Animation does not exist! Max: " + (f.worker.size() - 1));
|
1008
|
869
|
} else {
|
1009
|
|
- System.out.println("Animation: " + f.worker.getAnimationName(anim));
|
1010
|
|
- for (int i = 0; i < f.worker.numOfFrames(anim); i++) {
|
1011
|
|
- AFrame frame = f.worker.getAnimationList().get(anim).get(i);
|
1012
|
|
- System.out.println("\tFrame " + frame.getOrder() + " (" + frame.getTime() + "): " + frame.getName());
|
|
870
|
+ System.out.println("Animation: " + f.worker.getAnimation(anim).getName());
|
|
871
|
+ for (int i = 0; i < f.worker.getAnimation(anim).size(); i++) {
|
|
872
|
+ AFrame frame = f.worker.getAnimation(anim).getFrame(i);
|
|
873
|
+ System.out.println("\tFrame (" + frame.getTime() + "): " + frame.getName());
|
1013
|
874
|
}
|
1014
|
875
|
}
|
1015
|
876
|
}
|
1016
|
877
|
|
1017
|
878
|
if (s.equals("a") || s.equals("anims")) {
|
1018
|
|
- for (int i = 0; i < f.worker.numOfAnimations(); i++) {
|
1019
|
|
- Animation anim = f.worker.getAnimationList().get(i);
|
1020
|
|
- System.out.println("\tAnimation " + anim.getOrder() + ": " + anim.getName());
|
|
879
|
+ for (int i = 0; i < f.worker.size(); i++) {
|
|
880
|
+ Animation anim = f.worker.getAnimation(i);
|
|
881
|
+ System.out.println("\tAnimation: " + anim.getName());
|
1021
|
882
|
}
|
1022
|
883
|
}
|
1023
|
884
|
|
1024
|
885
|
if (s.equals("s") || s.equals("scan")) {
|
1025
|
|
- String[] sPorts = f.worker.getSerialPorts();
|
|
886
|
+ String[] sPorts = HelperUtility.getPorts();
|
1026
|
887
|
f.jComboBox1.removeAllItems();
|
1027
|
888
|
for (int i = 0; i < sPorts.length; i++) {
|
1028
|
889
|
f.jComboBox1.addItem(sPorts[i]);
|