/Users/lyon/j4p/src/net/rmi/rmiimage/CPUArrayFrame.java

1    package net.rmi.rmiimage; 
2     
3    import ip.gui.frames.ClosableFrame; 
4     
5    import java.awt.*; 
6    import java.awt.event.ComponentEvent; 
7    import java.awt.event.ComponentListener; 
8     
9    public class CPUArrayFrame extends 
10           ClosableFrame implements 
11       ComponentListener { 
12     public void componentShown( 
13         ComponentEvent e) { 
14     } 
15    
16     public void componentMoved( 
17         ComponentEvent e) { 
18     } 
19    
20     public void componentHidden( 
21         ComponentEvent e) { 
22     } 
23    
24     public void componentResized( 
25         ComponentEvent e) { 
26       pack(); 
27     } 
28    
29     public CpuPanel[] addCpus(int N) { 
30       setLayout(new 
31           GridLayout(2, 1)); 
32       setBackground(Color.white); 
33       PapPanel pap = 
34           new PapPanel(N); 
35       add(pap); 
36       add(new BCP(this)); 
37       pack(); 
38       return pap.cpuPanels; 
39    
40     } 
41    
42     public void incrementCpus() { 
43       int statearr[] = new int[cpus.length]; 
44       for (int i = 0; i < cpus.length; i++) 
45         statearr[i] = -1; 
46    
47       for (int i = 0; i < cpus.length; i++) { 
48         if (cpus[i].getstate()) 
49           statearr[i] = 1; 
50       } 
51       Client mc = new Client(statearr); 
52       for (int i = 0; i < cpus.length; i++) { 
53   //      cpus[i].setSpeed(cpus[i].getSpeed()+1); 
54   //      cpus[i].setLightOn(true); 
55         if (cpus[i].getstate()) { 
56           System.out.println("From CPUArrayframe!"); 
57           cpus[i].setLightOn(true); 
58           mc.Start(i, cpus[i]); 
59         } 
60       } 
61     } 
62    
63     public void terminateCpus() { 
64       for (int i = 0; i < cpus.length; i++) { 
65         cpus[i].setSpeed(0); 
66         cpus[i].setLightOn(false); 
67       } 
68     } 
69    
70     CpuPanel cpus[]; 
71    
72     public void init() { 
73       cpus = addCpus(20); 
74       for (int i = 0; i < cpus.length; i++) 
75         cpus[i].setSpeed(0); 
76       setVisible(true); 
77       addComponentListener(this); 
78     } 
79    
80     public static void main(String args[]) { 
81       CPUArrayFrame d = new CPUArrayFrame(); 
82       d.init(); 
83     } 
84   } 
85