Ver código fonte

Fixed Layereditor

Max Nuding 13 anos atrás
pai
commit
c54cbd4385

+ 1
- 0
Cube Control/cubeWorker.java Ver arquivo

@@ -417,6 +417,7 @@ class AFrame {
417 417
   }
418 418
 
419 419
   byte[] getData() {
420
+    data[0] = 3;
420 421
     return data;
421 422
   }
422 423
 

+ 19
- 5
Cube Control/frame.java Ver arquivo

@@ -74,6 +74,8 @@ public class frame extends JFrame implements ListSelectionListener {
74 74
   private JButton download = new JButton();
75 75
   private JLabel jLabel4 = new JLabel();
76 76
   private JTextField frameRemaining = new JTextField();
77
+  private JLabel frmLngthLbl = new JLabel();
78
+  private JTextField frmLngthTxt = new JTextField();
77 79
   // Ende Attribute
78 80
 
79 81
   private cubeWorker worker = new cubeWorker();
@@ -262,7 +264,8 @@ public class frame extends JFrame implements ListSelectionListener {
262 264
     frameList.setModel(frameListModel);
263 265
     //frameListModel.addElement();
264 266
     cp.add(frameListScrollPane);
265
-    frameUp.setBounds(544, 8, 107, 33);
267
+
268
+    frameUp.setBounds(544, 8, 107, 28);
266 269
     frameUp.setText("Move up");
267 270
     frameUp.setFont(new Font("Dialog", Font.PLAIN, 13));
268 271
     cp.add(frameUp);
@@ -272,7 +275,7 @@ public class frame extends JFrame implements ListSelectionListener {
272 275
       }
273 276
     });
274 277
 
275
-    frameDown.setBounds(544, 152, 107, 33);
278
+    frameDown.setBounds(544, 122, 107, 28);
276 279
     frameDown.setText("Move down");
277 280
     frameDown.setFont(new Font("Dialog", Font.PLAIN, 13));
278 281
     cp.add(frameDown);
@@ -282,7 +285,7 @@ public class frame extends JFrame implements ListSelectionListener {
282 285
       }
283 286
     });
284 287
 
285
-    frameAdd.setBounds(544, 56, 107, 33);
288
+    frameAdd.setBounds(544, 46, 107, 28);
286 289
     frameAdd.setText("Add");
287 290
     frameAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
288 291
     cp.add(frameAdd);
@@ -292,7 +295,7 @@ public class frame extends JFrame implements ListSelectionListener {
292 295
       }
293 296
     });
294 297
 
295
-    frameRemove.setBounds(544, 104, 107, 33);
298
+    frameRemove.setBounds(544, 84, 107, 28);
296 299
     frameRemove.setText("Remove");
297 300
     frameRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
298 301
     cp.add(frameRemove);
@@ -301,6 +304,16 @@ public class frame extends JFrame implements ListSelectionListener {
301 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 318
     animScrollPane.setBounds(8, 264, 209, 121);
306 319
     animList.setModel(animModel);
@@ -425,7 +438,8 @@ public class frame extends JFrame implements ListSelectionListener {
425 438
 
426 439
   // Anfang Ereignisprozeduren
427 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 445
   public void editB_ActionPerformed(ActionEvent evt) {

+ 52
- 12
Cube Control/layerEditFrame.java Ver arquivo

@@ -17,15 +17,18 @@ public class layerEditFrame extends JFrame {
17 17
   JButton[][] ledPanels = new JButton[8][8];
18 18
   ImageIcon on = new ImageIcon(getClass().getResource("LEDon.png"));
19 19
   ImageIcon off = new ImageIcon(getClass().getResource("LEDoff.png"));
20
+  byte[][] ledStatus = new byte[8][8];
20 21
   boolean changedStateSinceSave = false;
21 22
   byte[] frame;
23
+  int li;
22 24
 
23 25
   // Ende Attribute
24 26
 
25
-  public layerEditFrame(byte[] f) {
27
+  public layerEditFrame(byte[] f, int layerIndex) {
26 28
     // Frame-Initialisierung
27 29
     super("Layer Edit");
28 30
     frame = f;
31
+    li = layerIndex;
29 32
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
30 33
     int frameWidth = 180;
31 34
     int frameHeight = 230;
@@ -93,31 +96,44 @@ public class layerEditFrame extends JFrame {
93 96
 
94 97
     // Ende Komponenten
95 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 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 127
   public void btnClicked(int i, int j){
115 128
     changedStateSinceSave = true;
116 129
     if (ledPanels[i][j].getIcon() == on){
117 130
       ledPanels[i][j].setIcon(off);
131
+       ledStatus[i][j] = 0;
118 132
     } else {
119 133
       ledPanels[i][j].setIcon(on);
134
+       ledStatus[i][j] = 1;
120 135
     }
136
+
121 137
   }
122 138
 
123 139
   public void cancel(){
@@ -126,7 +142,31 @@ public class layerEditFrame extends JFrame {
126 142
 
127 143
   
128 144
   public void save(){
145
+    int ctr = 0;
146
+    byte[] tmpFrame = new byte[64];
129 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 172
   private int saveExitDialog() {

Carregando…
Cancelar
Salvar