Thomas Buck 13 years ago
parent
commit
b677e78c12
2 changed files with 101 additions and 94 deletions
  1. 90
    89
      Cube Control/frame.java
  2. 11
    5
      Cube Control/layerEditFrame.java

+ 90
- 89
Cube Control/frame.java View File

4
 *
4
 *
5
 * Copyright 2011 Thomas Buck <xythobuz@me.com>
5
 * Copyright 2011 Thomas Buck <xythobuz@me.com>
6
 * Copyright 2011 Max Nuding <max.nuding@gmail.com>
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
 * This file is part of LED-Cube.
9
 * This file is part of LED-Cube.
10
 *
10
 *
47
   private JButton editG = new JButton();
47
   private JButton editG = new JButton();
48
   private JButton editH = new JButton();
48
   private JButton editH = new JButton();
49
   private DefaultListModel frameListModel = new DefaultListModel();
49
   private DefaultListModel frameListModel = new DefaultListModel();
50
-  private JList frameList = new JList();
50
+  public JList frameList = new JList();
51
   private JScrollPane frameListScrollPane = new JScrollPane(frameList);
51
   private JScrollPane frameListScrollPane = new JScrollPane(frameList);
52
   private JButton frameUp = new JButton();
52
   private JButton frameUp = new JButton();
53
   private JButton frameDown = new JButton();
53
   private JButton frameDown = new JButton();
101
   }
101
   }
102
 
102
 
103
   public void valueChanged(ListSelectionEvent evt) {
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
   private void save() {
127
   private void save() {
175
     cp.setLayout(null);
175
     cp.setLayout(null);
176
     // Anfang Komponenten
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
     //----- 3D-----
185
     //----- 3D-----
186
     //-------------
186
     //-------------
504
     frameList.setFont(new Font("Dialog", Font.PLAIN, 13));
504
     frameList.setFont(new Font("Dialog", Font.PLAIN, 13));
505
     // Ende Komponenten
505
     // Ende Komponenten
506
     animList.addListSelectionListener(this);
506
     animList.addListSelectionListener(this);
507
-	frameList.addListSelectionListener(this);
507
+  frameList.addListSelectionListener(this);
508
     setResizable(false);
508
     setResizable(false);
509
     setVisible(true);
509
     setVisible(true);
510
   }
510
   }
519
      } else if(frameList.getSelectedIndex() == -1){
519
      } else if(frameList.getSelectedIndex() == -1){
520
        errorMessage("Please select a frame.");
520
        errorMessage("Please select a frame.");
521
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
530
      } else if(frameList.getSelectedIndex() == -1){
530
        errorMessage("Please select a frame.");
531
        errorMessage("Please select a frame.");
531
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
540
      } else if(frameList.getSelectedIndex() == -1){
540
        errorMessage("Please select a frame.");
541
        errorMessage("Please select a frame.");
541
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
550
      } else if(frameList.getSelectedIndex() == -1){
550
        errorMessage("Please select a frame.");
551
        errorMessage("Please select a frame.");
551
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
560
      } else if(frameList.getSelectedIndex() == -1){
560
        errorMessage("Please select a frame.");
561
        errorMessage("Please select a frame.");
561
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
570
      } else if(frameList.getSelectedIndex() == -1){
570
        errorMessage("Please select a frame.");
571
        errorMessage("Please select a frame.");
571
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
580
      } else if(frameList.getSelectedIndex() == -1){
580
        errorMessage("Please select a frame.");
581
        errorMessage("Please select a frame.");
581
      } else {
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
      } else if(frameList.getSelectedIndex() == -1){
590
      } else if(frameList.getSelectedIndex() == -1){
590
        errorMessage("Please select a frame.");
591
        errorMessage("Please select a frame.");
591
      } else {
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
   }
762
   }
762
 
763
 
763
   public Led3D get3D() {
764
   public Led3D get3D() {
764
-	  return ledView;
765
+    return ledView;
765
   }
766
   }
766
 
767
 
767
   public static void main(String[] args) {
768
   public static void main(String[] args) {
768
     frame f = new frame("Cube Control");
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
+}

+ 11
- 5
Cube Control/layerEditFrame.java View File

4
 *
4
 *
5
 * Copyright 2011 Thomas Buck <xythobuz@me.com>
5
 * Copyright 2011 Thomas Buck <xythobuz@me.com>
6
 * Copyright 2011 Max Nuding <max.nuding@gmail.com>
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
 * This file is part of LED-Cube.
9
 * This file is part of LED-Cube.
10
 *
10
 *
42
   cubeWorker worker = null;
42
   cubeWorker worker = null;
43
   int animI;
43
   int animI;
44
   int frameI;
44
   int frameI;
45
+  frame LedFrame;
45
 
46
 
46
   // Ende Attribute
47
   // Ende Attribute
47
 
48
 
48
-  public layerEditFrame(int animIndex, int frameIndex, int layerIndex, cubeWorker work) {
49
+  public layerEditFrame(int animIndex, int frameIndex, int layerIndex, cubeWorker work, frame LEDframe) {
49
     // Frame-Initialisierung
50
     // Frame-Initialisierung
50
     super("Layer Edit");
51
     super("Layer Edit");
51
     worker = work;
52
     worker = work;
53
+    LedFrame = LEDframe;
52
     animI = animIndex;
54
     animI = animIndex;
53
     frameI = frameIndex;
55
     frameI = frameIndex;
54
     //frame =  byteToShortArray(worker.getFrame(animIndex, frameIndex));
56
     //frame =  byteToShortArray(worker.getFrame(animIndex, frameIndex));
144
     }
146
     }
145
 
147
 
146
   }
148
   }
149
+  
150
+   public boolean isFinished(){
151
+     return finish;
152
+   }
147
 
153
 
148
-   short[] getFinalFrame(){
154
+   public short[] getFinalFrame(){
149
       if (finish == false) {
155
       if (finish == false) {
150
         return null;
156
         return null;
151
       }
157
       }
184
       reihe = 0;
190
       reihe = 0;
185
     }
191
     }
186
       frame = tmpFrame;
192
       frame = tmpFrame;
187
-      //worker.setFrame(shortToByteArray(frame), animI, frameI);
188
       worker.setFrame(frame, animI, frameI);
193
       worker.setFrame(frame, animI, frameI);
194
+      ListSelectionEvent layerChanged = new ListSelectionEvent(LedFrame.frameList, LedFrame.frameList.getSelectedIndex(), LedFrame.frameList.getSelectedIndex(), false);
195
+      LedFrame.valueChanged(layerChanged);
189
       dispose();
196
       dispose();
190
   }
197
   }
191
   
198
   
219
 }
226
 }
220
 
227
 
221
 
228
 
222
-

Loading…
Cancel
Save