|
@@ -4,7 +4,7 @@
|
4
|
4
|
*
|
5
|
5
|
* Copyright 2011 Thomas Buck <xythobuz@me.com>
|
6
|
6
|
* Copyright 2011 Max Nuding <max.nuding@gmail.com>
|
7
|
|
-* Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
|
|
7
|
+* Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
|
8
|
8
|
*
|
9
|
9
|
* This file is part of LED-Cube.
|
10
|
10
|
*
|
|
@@ -47,7 +47,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
47
|
47
|
private JButton editG = new JButton();
|
48
|
48
|
private JButton editH = new JButton();
|
49
|
49
|
private DefaultListModel frameListModel = new DefaultListModel();
|
50
|
|
- private JList frameList = new JList();
|
|
50
|
+ public JList frameList = new JList();
|
51
|
51
|
private JScrollPane frameListScrollPane = new JScrollPane(frameList);
|
52
|
52
|
private JButton frameUp = new JButton();
|
53
|
53
|
private JButton frameDown = new JButton();
|
|
@@ -101,27 +101,27 @@ public class frame extends JFrame implements ListSelectionListener {
|
101
|
101
|
}
|
102
|
102
|
|
103
|
103
|
public void valueChanged(ListSelectionEvent evt) {
|
104
|
|
- if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
|
105
|
|
- // If animList or framsList is the source, we act...
|
106
|
|
-
|
107
|
|
- // If both selections are valid, update frame duration and set 3D data
|
108
|
|
- if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
|
109
|
|
- ledView.setData(worker.getFrame(animList.getSelectedIndex(), frameList.getSelectedIndex()));
|
110
|
|
- frmLngthTxt.setText(Integer.toString(worker.getFrameTime(animList.getSelectedIndex(), frameList.getSelectedIndex())));
|
111
|
|
- } else {
|
112
|
|
- // clear frame duration
|
113
|
|
- frmLngthTxt.setText("");
|
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
|
|
- }
|
124
|
|
- }
|
|
104
|
+ if ((!evt.getValueIsAdjusting()) && ((evt.getSource() == animList) || (evt.getSource() == frameList))) {
|
|
105
|
+ // If animList or framsList is the source, we act...
|
|
106
|
+
|
|
107
|
+ // If both selections are valid, update frame duration and set 3D data
|
|
108
|
+ if ((animList.getSelectedIndex() != -1) && (frameList.getSelectedIndex() != -1)) {
|
|
109
|
+ ledView.setData(worker.getFrame(animList.getSelectedIndex(), frameList.getSelectedIndex()));
|
|
110
|
+ frmLngthTxt.setText(Integer.toString(worker.getFrameTime(animList.getSelectedIndex(), frameList.getSelectedIndex())));
|
|
111
|
+ } else {
|
|
112
|
+ // clear frame duration
|
|
113
|
+ frmLngthTxt.setText("");
|
|
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
|
+ }
|
|
124
|
+ }
|
125
|
125
|
}
|
126
|
126
|
|
127
|
127
|
private void save() {
|
|
@@ -175,12 +175,12 @@ public class frame extends JFrame implements ListSelectionListener {
|
175
|
175
|
cp.setLayout(null);
|
176
|
176
|
// Anfang Komponenten
|
177
|
177
|
|
178
|
|
- // ledView init
|
179
|
|
- short[] dat = new short[64];
|
180
|
|
- for (int i = 0; i < dat.length; i++) {
|
181
|
|
- dat[i] = 0xFF;
|
182
|
|
- }
|
183
|
|
- ledView.setData(dat);
|
|
178
|
+ // ledView init
|
|
179
|
+ short[] dat = new short[64];
|
|
180
|
+ for (int i = 0; i < dat.length; i++) {
|
|
181
|
+ dat[i] = 0xFF;
|
|
182
|
+ }
|
|
183
|
+ ledView.setData(dat);
|
184
|
184
|
|
185
|
185
|
//----- 3D-----
|
186
|
186
|
//-------------
|
|
@@ -504,7 +504,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
504
|
504
|
frameList.setFont(new Font("Dialog", Font.PLAIN, 13));
|
505
|
505
|
// Ende Komponenten
|
506
|
506
|
animList.addListSelectionListener(this);
|
507
|
|
- frameList.addListSelectionListener(this);
|
|
507
|
+ frameList.addListSelectionListener(this);
|
508
|
508
|
setResizable(false);
|
509
|
509
|
setVisible(true);
|
510
|
510
|
}
|
|
@@ -519,7 +519,8 @@ public class frame extends JFrame implements ListSelectionListener {
|
519
|
519
|
} else if(frameList.getSelectedIndex() == -1){
|
520
|
520
|
errorMessage("Please select a frame.");
|
521
|
521
|
} else {
|
522
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 0, worker);
|
|
522
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 0, worker, this);
|
|
523
|
+
|
523
|
524
|
}
|
524
|
525
|
}
|
525
|
526
|
|
|
@@ -529,7 +530,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
529
|
530
|
} else if(frameList.getSelectedIndex() == -1){
|
530
|
531
|
errorMessage("Please select a frame.");
|
531
|
532
|
} else {
|
532
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 1, worker);
|
|
533
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 1, worker, this);
|
533
|
534
|
}
|
534
|
535
|
}
|
535
|
536
|
|
|
@@ -539,7 +540,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
539
|
540
|
} else if(frameList.getSelectedIndex() == -1){
|
540
|
541
|
errorMessage("Please select a frame.");
|
541
|
542
|
} else {
|
542
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 2, worker);
|
|
543
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 2, worker, this);
|
543
|
544
|
}
|
544
|
545
|
}
|
545
|
546
|
|
|
@@ -549,7 +550,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
549
|
550
|
} else if(frameList.getSelectedIndex() == -1){
|
550
|
551
|
errorMessage("Please select a frame.");
|
551
|
552
|
} else {
|
552
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 3, worker);
|
|
553
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 3, worker, this);
|
553
|
554
|
}
|
554
|
555
|
}
|
555
|
556
|
|
|
@@ -559,7 +560,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
559
|
560
|
} else if(frameList.getSelectedIndex() == -1){
|
560
|
561
|
errorMessage("Please select a frame.");
|
561
|
562
|
} else {
|
562
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 4, worker);
|
|
563
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 4, worker, this);
|
563
|
564
|
}
|
564
|
565
|
}
|
565
|
566
|
|
|
@@ -569,7 +570,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
569
|
570
|
} else if(frameList.getSelectedIndex() == -1){
|
570
|
571
|
errorMessage("Please select a frame.");
|
571
|
572
|
} else {
|
572
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 5, worker);
|
|
573
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 5, worker, this);
|
573
|
574
|
}
|
574
|
575
|
}
|
575
|
576
|
|
|
@@ -579,7 +580,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
579
|
580
|
} else if(frameList.getSelectedIndex() == -1){
|
580
|
581
|
errorMessage("Please select a frame.");
|
581
|
582
|
} else {
|
582
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 6, worker);
|
|
583
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 6, worker, this);
|
583
|
584
|
}
|
584
|
585
|
}
|
585
|
586
|
|
|
@@ -589,7 +590,7 @@ public class frame extends JFrame implements ListSelectionListener {
|
589
|
590
|
} else if(frameList.getSelectedIndex() == -1){
|
590
|
591
|
errorMessage("Please select a frame.");
|
591
|
592
|
} else {
|
592
|
|
- layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 7, worker);
|
|
593
|
+ layerEditFrame layerFrame1 = new layerEditFrame(animList.getSelectedIndex(), frameList.getSelectedIndex(), 7, worker, this);
|
593
|
594
|
}
|
594
|
595
|
}
|
595
|
596
|
|
|
@@ -761,58 +762,58 @@ public class frame extends JFrame implements ListSelectionListener {
|
761
|
762
|
}
|
762
|
763
|
|
763
|
764
|
public Led3D get3D() {
|
764
|
|
- return ledView;
|
|
765
|
+ return ledView;
|
765
|
766
|
}
|
766
|
767
|
|
767
|
768
|
public static void main(String[] args) {
|
768
|
769
|
frame f = new frame("Cube Control");
|
769
|
|
- Led3D l = f.get3D();
|
770
|
|
- java.util.Scanner sc = new java.util.Scanner(System.in);
|
771
|
|
-
|
772
|
|
- System.out.println("## Cube Control Debug Console ##");
|
773
|
|
- System.out.println("Enter a Command ('h' for help)\n");
|
774
|
|
-
|
775
|
|
- System.out.print("$> ");
|
776
|
|
-
|
777
|
|
- do {
|
778
|
|
- if (sc.hasNext()) {
|
779
|
|
- String s = sc.next();
|
780
|
|
-
|
781
|
|
- if (s.equals("p") || (s.equals("print")))
|
782
|
|
- l.printTranslationData();
|
783
|
|
-
|
784
|
|
- if (s.equals("q") || s.equals("quit"))
|
785
|
|
- System.exit(0);
|
786
|
|
-
|
787
|
|
- if (s.equals("on") || s.equals("1")) {
|
788
|
|
- short[] d = new short[64];
|
789
|
|
- for (int i = 0; i < d.length; i++) {
|
790
|
|
- d[i] = 0xFF;
|
791
|
|
- }
|
792
|
|
- l.setData(d);
|
793
|
|
- System.out.println("All LEDs on now...");
|
794
|
|
- }
|
795
|
|
-
|
796
|
|
- if (s.equals("off") || s.equals("0")) {
|
797
|
|
- short[] d = new short[64];
|
798
|
|
- for (int i = 0; i < d.length; i++) {
|
799
|
|
- d[i] = 0x00;
|
800
|
|
- }
|
801
|
|
- l.setData(d);
|
802
|
|
- System.out.println("All LEDs off now...");
|
803
|
|
- }
|
804
|
|
-
|
805
|
|
- if (s.equals("h") || (s.equals("help"))) {
|
806
|
|
- System.out.println("Commands:");
|
807
|
|
- System.out.println("\t'on' / '1'\t:\tToggle all LEDs on");
|
808
|
|
- System.out.println("\t'off' / '0'\t:\tToggle all LEDs off");
|
809
|
|
- System.out.println("\t'print' / 'p'\t:\tPrint 3D Translation Matrix Data");
|
810
|
|
- System.out.println("\t'help' / 'h'\t:\tShow this message");
|
811
|
|
- System.out.println("\t'quit' / 'q'\t:\tExit Cube Control");
|
812
|
|
- }
|
813
|
|
-
|
814
|
|
- System.out.print("$> ");
|
815
|
|
- }
|
816
|
|
- } while (true);
|
817
|
|
- }
|
818
|
|
-}
|
|
770
|
+ Led3D l = f.get3D();
|
|
771
|
+ java.util.Scanner sc = new java.util.Scanner(System.in);
|
|
772
|
+
|
|
773
|
+ System.out.println("## Cube Control Debug Console ##");
|
|
774
|
+ System.out.println("Enter a Command ('h' for help)\n");
|
|
775
|
+
|
|
776
|
+ System.out.print("$> ");
|
|
777
|
+
|
|
778
|
+ do {
|
|
779
|
+ if (sc.hasNext()) {
|
|
780
|
+ String s = sc.next();
|
|
781
|
+
|
|
782
|
+ if (s.equals("p") || (s.equals("print")))
|
|
783
|
+ l.printTranslationData();
|
|
784
|
+
|
|
785
|
+ if (s.equals("q") || s.equals("quit"))
|
|
786
|
+ System.exit(0);
|
|
787
|
+
|
|
788
|
+ if (s.equals("on") || s.equals("1")) {
|
|
789
|
+ short[] d = new short[64];
|
|
790
|
+ for (int i = 0; i < d.length; i++) {
|
|
791
|
+ d[i] = 0xFF;
|
|
792
|
+ }
|
|
793
|
+ l.setData(d);
|
|
794
|
+ System.out.println("All LEDs on now...");
|
|
795
|
+ }
|
|
796
|
+
|
|
797
|
+ if (s.equals("off") || s.equals("0")) {
|
|
798
|
+ short[] d = new short[64];
|
|
799
|
+ for (int i = 0; i < d.length; i++) {
|
|
800
|
+ d[i] = 0x00;
|
|
801
|
+ }
|
|
802
|
+ l.setData(d);
|
|
803
|
+ System.out.println("All LEDs off now...");
|
|
804
|
+ }
|
|
805
|
+
|
|
806
|
+ if (s.equals("h") || (s.equals("help"))) {
|
|
807
|
+ System.out.println("Commands:");
|
|
808
|
+ System.out.println("\t'on' / '1'\t:\tToggle all LEDs on");
|
|
809
|
+ System.out.println("\t'off' / '0'\t:\tToggle all LEDs off");
|
|
810
|
+ System.out.println("\t'print' / 'p'\t:\tPrint 3D Translation Matrix Data");
|
|
811
|
+ System.out.println("\t'help' / 'h'\t:\tShow this message");
|
|
812
|
+ System.out.println("\t'quit' / 'q'\t:\tExit Cube Control");
|
|
813
|
+ }
|
|
814
|
+
|
|
815
|
+ System.out.print("$> ");
|
|
816
|
+ }
|
|
817
|
+ } while (true);
|
|
818
|
+ }
|
|
819
|
+}
|