Преглед на файлове

now ready to load the frame-info into the layereditor.

Max Nuding преди 12 години
родител
ревизия
e351d4339f
променени са 3 файла, в които са добавени 70 реда и са изтрити 41 реда
  1. 39
    32
      Cube Control/cubeWorker.java
  2. 8
    8
      Cube Control/frame.java
  3. 23
    1
      Cube Control/layerEditFrame.java

+ 39
- 32
Cube Control/cubeWorker.java Целия файл

32
 // Definitions
32
 // Definitions
33
 // --------------------
33
 // --------------------
34
 
34
 
35
-	final int UP = 0;
35
+  final int UP = 0;
36
     final int DOWN = 1;
36
     final int DOWN = 1;
37
 
37
 
38
 // --------------------
38
 // --------------------
41
 
41
 
42
 // --------------------
42
 // --------------------
43
 
43
 
44
-	cubeWorker() {
44
+  cubeWorker() {
45
 
45
 
46
     }
46
     }
47
 
47
 
49
 // Misc. Methods
49
 // Misc. Methods
50
 // --------------------
50
 // --------------------
51
 
51
 
52
-	// Returns how many animations are defined
52
+  // Returns how many animations are defined
53
     public int numOfAnimations() {
53
     public int numOfAnimations() {
54
 
54
 
55
            return 3;
55
            return 3;
61
            return 3;
61
            return 3;
62
     }
62
     }
63
 
63
 
64
-	// Tells how many Frames you can add until you reached 1 Mbit...
64
+  // Tells how many Frames you can add until you reached 1 Mbit...
65
     public int framesRemaining() {
65
     public int framesRemaining() {
66
 
66
 
67
            return 0;
67
            return 0;
72
 // Animation Specific
72
 // Animation Specific
73
 // --------------------
73
 // --------------------
74
 
74
 
75
-	// Selects an animation on wich the animation specific functions operate
75
+  // Selects an animation on wich the animation specific functions operate
76
     // Returns -1 if it does not exist, else its index
76
     // Returns -1 if it does not exist, else its index
77
     public int selectAnimation(int index) {
77
     public int selectAnimation(int index) {
78
            System.out.println("Animation " + index + " selected.");
78
            System.out.println("Animation " + index + " selected.");
79
            
79
            
80
-		   return index;
80
+       return index;
81
     }
81
     }
82
 
82
 
83
-	// Adds a new Animation
83
+  // Adds a new Animation
84
     // Returns id if ok, -1 if error or not enough space for
84
     // Returns id if ok, -1 if error or not enough space for
85
     // another animation
85
     // another animation
86
     public int addAnimation() {
86
     public int addAnimation() {
93
 
93
 
94
     }
94
     }
95
     
95
     
96
-	public String getAnimationName() {
96
+  public String getAnimationName() {
97
 
97
 
98
            return "TestAnim";
98
            return "TestAnim";
99
     }
99
     }
100
 
100
 
101
-	public void setAnimationName(String s) {
101
+  public void setAnimationName(String s) {
102
 
102
 
103
     }
103
     }
104
 
104
 
105
-	public void moveAnimation(int dir) {
106
-		if (dir == UP){
107
-    		//animation moved up
108
-		
109
-		} else if (dir == DOWN){
110
-			//animation moved down
105
+  public void moveAnimation(int dir) {
106
+    if (dir == UP){
107
+        //animation moved up
108
+    
109
+    } else if (dir == DOWN){
110
+      //animation moved down
111
 
111
 
112
-		}
113
-	}
112
+    }
113
+  }
114
 
114
 
115
 // --------------------
115
 // --------------------
116
 // Frame Specific
116
 // Frame Specific
117
 // --------------------
117
 // --------------------
118
-	
119
-	// Selects an animation on wich the frame specific functions operate
118
+  
119
+  // Selects an animation on wich the frame specific functions operate
120
     // Returns -1 if it does not exist, else its index
120
     // Returns -1 if it does not exist, else its index
121
-	public int selectFrame(int index) {
122
-		System.out.println("Frame " + index + " selected.");
121
+  public int selectFrame(int index) {
122
+    System.out.println("Frame " + index + " selected.");
123
 
123
 
124
-		return index;
125
-	}
124
+    return index;
125
+  }
126
 
126
 
127
-	public String getFrameName() {
127
+  public String getFrameName() {
128
 
128
 
129
            return "Test";
129
            return "Test";
130
     }
130
     }
155
 
155
 
156
     }
156
     }
157
 
157
 
158
-	public void moveFrame(int dir){
159
-		if (dir == UP){
160
-    		// frame moved up
158
+  public void moveFrame(int dir){
159
+    if (dir == UP){
160
+        // frame moved up
161
       
161
       
162
-		} else if (dir == DOWN){
163
-			// frame moved down
162
+    } else if (dir == DOWN){
163
+      // frame moved down
164
 
164
 
165
-		}
166
-	}
165
+    }
166
+  }
167
 
167
 
168
 // --------------------
168
 // --------------------
169
 // File Specific
169
 // File Specific
181
            return 0;
181
            return 0;
182
     }
182
     }
183
 
183
 
184
-	// Returns true if last saved state != current state
184
+  // Returns true if last saved state != current state
185
     public boolean changedStateSinceSave() {
185
     public boolean changedStateSinceSave() {
186
 
186
 
187
            return true;
187
            return true;
188
     }
188
     }
189
+// --------------------
190
+// File Specific
191
+// --------------------
192
+
193
+   public byte[] getLayer(int index){
194
+          return null;
195
+   }
189
 
196
 
190
 // --------------------
197
 // --------------------
191
 // Serial Port Specific
198
 // Serial Port Specific

+ 8
- 8
Cube Control/frame.java Целия файл

359
 
359
 
360
   // Anfang Ereignisprozeduren
360
   // Anfang Ereignisprozeduren
361
   public void editA_ActionPerformed(ActionEvent evt) {
361
   public void editA_ActionPerformed(ActionEvent evt) {
362
-     layerEditFrame layerFrame1 = new layerEditFrame();
362
+     layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(0));
363
   }
363
   }
364
 
364
 
365
   public void editB_ActionPerformed(ActionEvent evt) {
365
   public void editB_ActionPerformed(ActionEvent evt) {
366
-     layerEditFrame layerFrame1 = new layerEditFrame();
366
+     layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(1));
367
   }
367
   }
368
 
368
 
369
   public void editC_ActionPerformed(ActionEvent evt) {
369
   public void editC_ActionPerformed(ActionEvent evt) {
370
-    layerEditFrame layerFrame1 = new layerEditFrame();
370
+    layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(2));
371
   }
371
   }
372
 
372
 
373
   public void editD_ActionPerformed(ActionEvent evt) {
373
   public void editD_ActionPerformed(ActionEvent evt) {
374
-    layerEditFrame layerFrame1 = new layerEditFrame();
374
+    layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(3));
375
   }
375
   }
376
 
376
 
377
   public void editE_ActionPerformed(ActionEvent evt) {
377
   public void editE_ActionPerformed(ActionEvent evt) {
378
-    layerEditFrame layerFrame1 = new layerEditFrame();
378
+    layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(4));
379
   }
379
   }
380
 
380
 
381
   public void editF_ActionPerformed(ActionEvent evt) {
381
   public void editF_ActionPerformed(ActionEvent evt) {
382
-    layerEditFrame layerFrame1 = new layerEditFrame();
382
+    layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(5));
383
   }
383
   }
384
 
384
 
385
   public void editG_ActionPerformed(ActionEvent evt) {
385
   public void editG_ActionPerformed(ActionEvent evt) {
386
-    layerEditFrame layerFrame1 = new layerEditFrame();
386
+    layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(6));
387
   }
387
   }
388
 
388
 
389
   public void editH_ActionPerformed(ActionEvent evt) {
389
   public void editH_ActionPerformed(ActionEvent evt) {
390
-    layerEditFrame layerFrame1 = new layerEditFrame();
390
+    layerEditFrame layerFrame1 = new layerEditFrame(worker.getLayer(7));
391
   }
391
   }
392
 
392
 
393
   public void frameUp_ActionPerformed(ActionEvent evt) {
393
   public void frameUp_ActionPerformed(ActionEvent evt) {

+ 23
- 1
Cube Control/layerEditFrame.java Целия файл

18
   static ImageIcon on = new ImageIcon("LEDon.png");
18
   static ImageIcon on = new ImageIcon("LEDon.png");
19
   static ImageIcon off = new ImageIcon("LEDoff.png");
19
   static ImageIcon off = new ImageIcon("LEDoff.png");
20
   boolean changedStateSinceSave = false;
20
   boolean changedStateSinceSave = false;
21
+  byte[] frame;
21
 
22
 
22
   // Ende Attribute
23
   // Ende Attribute
23
 
24
 
24
-  public layerEditFrame() {
25
+  public layerEditFrame(byte[] f) {
25
     // Frame-Initialisierung
26
     // Frame-Initialisierung
26
     super("Layer Edit");
27
     super("Layer Edit");
28
+    frame = f;
27
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
29
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
28
     int frameWidth = 180;
30
     int frameWidth = 180;
29
     int frameHeight = 230;
31
     int frameHeight = 230;
51
          cp.add(ledPanels[i][j]);
53
          cp.add(ledPanels[i][j]);
52
       }
54
       }
53
     }
55
     }
56
+    loadData();
54
     JButton saveBtn = new JButton("Save");
57
     JButton saveBtn = new JButton("Save");
55
     JButton cancelBtn = new JButton("Cancel");
58
     JButton cancelBtn = new JButton("Cancel");
56
     
59
     
89
     // Anfang Komponenten
92
     // Anfang Komponenten
90
 
93
 
91
     // Ende Komponenten
94
     // Ende Komponenten
95
+  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;                              //
101
+      }
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);
107
+        } else {
108
+           ledPanels[i][j].setIcon(on);
109
+        }
110
+      }
111
+    }
112
+  }
113
+
92
   public void btnClicked(int i, int j){
114
   public void btnClicked(int i, int j){
93
     changedStateSinceSave = true;
115
     changedStateSinceSave = true;
94
     if (ledPanels[i][j].getIcon() == on){
116
     if (ledPanels[i][j].getIcon() == on){

Loading…
Отказ
Запис