Browse Source

Fixed Layereditor

Max Nuding 13 years ago
parent
commit
c54cbd4385
3 changed files with 72 additions and 17 deletions
  1. 1
    0
      Cube Control/cubeWorker.java
  2. 19
    5
      Cube Control/frame.java
  3. 52
    12
      Cube Control/layerEditFrame.java

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

417
   }
417
   }
418
 
418
 
419
   byte[] getData() {
419
   byte[] getData() {
420
+    data[0] = 3;
420
     return data;
421
     return data;
421
   }
422
   }
422
 
423
 

+ 19
- 5
Cube Control/frame.java View File

74
   private JButton download = new JButton();
74
   private JButton download = new JButton();
75
   private JLabel jLabel4 = new JLabel();
75
   private JLabel jLabel4 = new JLabel();
76
   private JTextField frameRemaining = new JTextField();
76
   private JTextField frameRemaining = new JTextField();
77
+  private JLabel frmLngthLbl = new JLabel();
78
+  private JTextField frmLngthTxt = new JTextField();
77
   // Ende Attribute
79
   // Ende Attribute
78
 
80
 
79
   private cubeWorker worker = new cubeWorker();
81
   private cubeWorker worker = new cubeWorker();
262
     frameList.setModel(frameListModel);
264
     frameList.setModel(frameListModel);
263
     //frameListModel.addElement();
265
     //frameListModel.addElement();
264
     cp.add(frameListScrollPane);
266
     cp.add(frameListScrollPane);
265
-    frameUp.setBounds(544, 8, 107, 33);
267
+
268
+    frameUp.setBounds(544, 8, 107, 28);
266
     frameUp.setText("Move up");
269
     frameUp.setText("Move up");
267
     frameUp.setFont(new Font("Dialog", Font.PLAIN, 13));
270
     frameUp.setFont(new Font("Dialog", Font.PLAIN, 13));
268
     cp.add(frameUp);
271
     cp.add(frameUp);
272
       }
275
       }
273
     });
276
     });
274
 
277
 
275
-    frameDown.setBounds(544, 152, 107, 33);
278
+    frameDown.setBounds(544, 122, 107, 28);
276
     frameDown.setText("Move down");
279
     frameDown.setText("Move down");
277
     frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
280
     frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
278
     cp.add(frameDown);
281
     cp.add(frameDown);
282
       }
285
       }
283
     });
286
     });
284
 
287
 
285
-    frameAdd.setBounds(544, 56, 107, 33);
288
+    frameAdd.setBounds(544, 46, 107, 28);
286
     frameAdd.setText("Add");
289
     frameAdd.setText("Add");
287
     frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
290
     frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
288
     cp.add(frameAdd);
291
     cp.add(frameAdd);
292
       }
295
       }
293
     });
296
     });
294
 
297
 
295
-    frameRemove.setBounds(544, 104, 107, 33);
298
+    frameRemove.setBounds(544, 84, 107, 28);
296
     frameRemove.setText("Remove");
299
     frameRemove.setText("Remove");
297
     frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
300
     frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
298
     cp.add(frameRemove);
301
     cp.add(frameRemove);
301
         frameRemove_ActionPerformed(evt);
304
         frameRemove_ActionPerformed(evt);
302
       }
305
       }
303
     });
306
     });
307
+    
308
+    frmLngthLbl.setBounds(536, 160, 113, 24);
309
+    frmLngthLbl.setText("Length of a frame");
310
+    frmLngthLbl.setFont(new Font("Dialog", Font.PLAIN, 13));
311
+    cp.add(frmLngthLbl);
312
+    
313
+    frmLngthTxt.setBounds(536, 184, 113, 24);
314
+    frmLngthTxt.setText("0");
315
+    frmLngthTxt.setFont(new Font("Dialog", Font.PLAIN, 13));
316
+    cp.add(frmLngthTxt);
304
 
317
 
305
     animScrollPane.setBounds(8, 264, 209, 121);
318
     animScrollPane.setBounds(8, 264, 209, 121);
306
     animList.setModel(animModel);
319
     animList.setModel(animModel);
425
 
438
 
426
   // Anfang Ereignisprozeduren
439
   // Anfang Ereignisprozeduren
427
   public void editA_ActionPerformed(ActionEvent evt) {
440
   public void editA_ActionPerformed(ActionEvent evt) {
428
-     // layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(0));
441
+
442
+     layerEditFrame layerFrame1 = new layerEditFrame(worker.getFrame(animList.getSelectedIndex(), frameList.getSelectedIndex()), 0);
429
   }
443
   }
430
 
444
 
431
   public void editB_ActionPerformed(ActionEvent evt) {
445
   public void editB_ActionPerformed(ActionEvent evt) {

+ 52
- 12
Cube Control/layerEditFrame.java View File

17
   JButton[][] ledPanels = new JButton[8][8];
17
   JButton[][] ledPanels = new JButton[8][8];
18
   ImageIcon on = new ImageIcon(getClass().getResource("LEDon.png"));
18
   ImageIcon on = new ImageIcon(getClass().getResource("LEDon.png"));
19
   ImageIcon off = new ImageIcon(getClass().getResource("LEDoff.png"));
19
   ImageIcon off = new ImageIcon(getClass().getResource("LEDoff.png"));
20
+  byte[][] ledStatus = new byte[8][8];
20
   boolean changedStateSinceSave = false;
21
   boolean changedStateSinceSave = false;
21
   byte[] frame;
22
   byte[] frame;
23
+  int li;
22
 
24
 
23
   // Ende Attribute
25
   // Ende Attribute
24
 
26
 
25
-  public layerEditFrame(byte[] f) {
27
+  public layerEditFrame(byte[] f, int layerIndex) {
26
     // Frame-Initialisierung
28
     // Frame-Initialisierung
27
     super("Layer Edit");
29
     super("Layer Edit");
28
     frame = f;
30
     frame = f;
31
+    li = layerIndex;
29
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
32
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
30
     int frameWidth = 180;
33
     int frameWidth = 180;
31
     int frameHeight = 230;
34
     int frameHeight = 230;
93
 
96
 
94
     // Ende Komponenten
97
     // Ende Komponenten
95
   private void loadData(){
98
   private void loadData(){
96
-    byte[][] frameArray = new byte[8][8];
97
-    //Load the data from the bytearray 'frame' and write it into frameArray.length A 0 means off, everything else means on
98
-    for(int i = 0; i < frameArray.length; i++){            //
99
-      for(int j = 0; j < frameArray[i].length; j++){       //This ist just that we have a starting point....
100
-        frameArray[i][j] = 0;                              //
99
+
100
+    for(int i = 0; i < 8; i++){
101
+      int div = frame[li + i];
102
+      int[] rest = new int[8];
103
+      int ctr = 0;
104
+      while(div != 0){
105
+        rest[ctr] = div%2;
106
+        div = div/2;
107
+        ctr++;
101
       }
108
       }
102
-    }
103
-    for(int i = 0; i < frameArray.length; i++){            //
104
-      for(int j = 0; j < frameArray[i].length; j++){       //Set the LED-Buttons
105
-        if(frameArray[i][j] == 0){
106
-           ledPanels[i][j].setIcon(off);
109
+
110
+      for(int j = 0; j < 8; j++){
111
+        if(rest[j] == 0){
112
+         ledPanels[li + j][i].setIcon(off);
107
         } else {
113
         } else {
108
-           ledPanels[i][j].setIcon(on);
114
+         ledPanels[li + j][i].setIcon(on);
109
         }
115
         }
116
+        ledStatus[li + j][i] = (byte) rest[j];
110
       }
117
       }
118
+
111
     }
119
     }
120
+
112
   }
121
   }
113
 
122
 
123
+   byte[] getFinalFrame(){
124
+      return frame;
125
+   }
126
+
114
   public void btnClicked(int i, int j){
127
   public void btnClicked(int i, int j){
115
     changedStateSinceSave = true;
128
     changedStateSinceSave = true;
116
     if (ledPanels[i][j].getIcon() == on){
129
     if (ledPanels[i][j].getIcon() == on){
117
       ledPanels[i][j].setIcon(off);
130
       ledPanels[i][j].setIcon(off);
131
+       ledStatus[i][j] = 0;
118
     } else {
132
     } else {
119
       ledPanels[i][j].setIcon(on);
133
       ledPanels[i][j].setIcon(on);
134
+       ledStatus[i][j] = 1;
120
     }
135
     }
136
+
121
   }
137
   }
122
 
138
 
123
   public void cancel(){
139
   public void cancel(){
126
 
142
 
127
   
143
   
128
   public void save(){
144
   public void save(){
145
+    int ctr = 0;
146
+    byte[] tmpFrame = new byte[64];
129
     changedStateSinceSave = false;
147
     changedStateSinceSave = false;
148
+    int reihe = 0;
149
+    for(int j = 0; j < 8; j++){
150
+      for(int i = 0; i < 8; i++){
151
+        reihe += ((int) Math.pow(2, i)) * ledStatus[i][j];
152
+        System.out.println("LED-Status: " + ledStatus[i][j]);
153
+        System.out.println("Reihe: " + i);
154
+        System.out.println("Spalte: " + j);
155
+        System.out.println("Wertigkeit: " + ((int) Math.pow(2, i)));
156
+        System.out.println("Zusammen: " + ((int) Math.pow(2, j)) * ledStatus[i][j]);
157
+        System.out.println("Reihe nacher: " + reihe);
158
+        System.out.println();
159
+        ctr++;
160
+      }
161
+      tmpFrame[j] = (byte)reihe;
162
+      reihe = 0;
163
+      System.out.println("----");
164
+      System.out.println("Frame-Array, Position " + j + " = " + tmpFrame[j]);
165
+      System.out.println("----");
166
+    }
167
+      frame = tmpFrame;
168
+
169
+
130
   }
170
   }
131
 
171
 
132
   private int saveExitDialog() {
172
   private int saveExitDialog() {

Loading…
Cancel
Save