KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > examples > c3d > C3DUser


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.examples.c3d;
32
33 import java.awt.Button JavaDoc;
34 import java.awt.Canvas JavaDoc;
35 import java.awt.Color JavaDoc;
36 import java.awt.Dialog JavaDoc;
37 import java.awt.Dimension JavaDoc;
38 import java.awt.Font JavaDoc;
39 import java.awt.Frame JavaDoc;
40 import java.awt.Graphics JavaDoc;
41 import java.awt.GridBagConstraints JavaDoc;
42 import java.awt.GridBagLayout JavaDoc;
43 import java.awt.GridLayout JavaDoc;
44 import java.awt.Image JavaDoc;
45 import java.awt.Insets JavaDoc;
46 import java.awt.Label JavaDoc;
47 import java.awt.List JavaDoc;
48 import java.awt.Menu JavaDoc;
49 import java.awt.MenuBar JavaDoc;
50 import java.awt.MenuItem JavaDoc;
51 import java.awt.Panel JavaDoc;
52 import java.awt.TextArea JavaDoc;
53 import java.awt.TextField JavaDoc;
54 import java.awt.event.ActionEvent JavaDoc;
55 import java.awt.event.ActionListener JavaDoc;
56 import java.awt.event.ItemEvent JavaDoc;
57 import java.awt.event.ItemListener JavaDoc;
58 import java.awt.event.MouseEvent JavaDoc;
59 import java.awt.event.MouseListener JavaDoc;
60 import java.awt.event.WindowAdapter JavaDoc;
61 import java.awt.event.WindowEvent JavaDoc;
62 import java.awt.image.MemoryImageSource JavaDoc;
63 import java.net.InetAddress JavaDoc;
64 import java.net.UnknownHostException JavaDoc;
65 import java.util.Hashtable JavaDoc;
66
67 import org.apache.log4j.Logger;
68 import org.objectweb.proactive.ProActive;
69 import org.objectweb.proactive.core.config.ProActiveConfiguration;
70 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor;
71 import org.objectweb.proactive.core.descriptor.data.VirtualNode;
72 import org.objectweb.proactive.core.node.Node;
73 import org.objectweb.proactive.core.node.NodeException;
74 import org.objectweb.proactive.examples.c3d.geom.Vec;
75 import org.objectweb.proactive.examples.c3d.prim.Light;
76 import org.objectweb.proactive.examples.c3d.prim.Primitive;
77 import org.objectweb.proactive.examples.c3d.prim.Sphere;
78 import org.objectweb.proactive.ext.migration.MigrationStrategyManagerImpl;
79
80 public class C3DUser implements org.objectweb.proactive.RunActive, java.io.Serializable JavaDoc {
81     
82     static Logger logger = Logger.getLogger(C3DUser.class.getName());
83     
84     private MigrationStrategyManagerImpl myStrategyManager;
85     private boolean onMigration;
86     private String JavaDoc dispatcher_host;
87     
88     protected VirtualNode vnDispatcher;
89   /**
90    * Uses active objects if set to true
91    */

92   private final boolean ACTIVE = true;
93   private C3DUser me;
94   /**
95    * The about box
96    */

97   private MyDialog about;
98   /**
99    * Status log, displays messages from other users concerning action
100    * requests
101    */

102    TextArea JavaDoc ta_log;
103   /**
104    * SpyEvent log
105    */

106    TextArea JavaDoc ta_mess;
107   /**
108    * Name (number) of this user
109    */

110    Label JavaDoc l_user;
111   /**
112    * OS String of the C3Ddispatcher
113    */

114    Label JavaDoc l_c3ddispatcher;
115   /**
116    * Height of the <code>Image</code> to be rendered
117    */

118   final int i_height = 270;
119   /**
120    * Width of the <code>Image</code> to be rendered
121    */

122   final int i_width = 270;
123   /**
124    * <code>MemoryImagesource</code> as pixel source for the
125    * <code>Image</code> to be rendered
126    */

127    transient MemoryImageSource JavaDoc mis;
128   /**
129    * Destination array for the calculated pixels of the <code>Image</code>
130    */

131   transient int pix[];
132   /**
133    * <code>C3DDispatcher</code>, decouples the m user frames and the
134    * n rendering engines. There is always exactly one C3DDispatcher object
135    * in the Java// rendering system.
136    */

137   C3DDispatcher c3ddispatcher;
138   /**
139    * Number of this user in the set of users registered at the
140    * <code>C3DDispatcher</Code>, used to distinguish the action requests of
141    * several users
142    */

143
144   //@@ADDON Florian 13/8/98
145
/**
146    * Hashtable containing the name and ID of each user<br>
147    * Used for direct messaging
148    */

149   private Hashtable JavaDoc h_users = new Hashtable JavaDoc();
150   /**
151    * An AWT list allowing the User to select its locutors [??]
152    */

153   private transient List JavaDoc li_users;
154   /**
155    * The ID# of the selected locutor [-1=broadcast]
156    */

157   private int talkId = -1;
158   /**
159    * The array of random colors
160    */

161   private static Vec color[] = {
162     // new Vec(0,0,0), // Black
163
new Vec(1, 1, 1), // White
164
new Vec(0, 0, 0.5), // Navy
165
new Vec(0, 0.5, 0), // darkgreen
166
new Vec(0.5, 0, 0), // dark red
167
new Vec(1, 0.6, 0), // Orange
168
new Vec(1, 0.7, 0.8),// Pink
169
new Vec(0.8, 0.8, 1)// Lavender
170
};
171
172   
173   //@@END_ADDON Florian 13/8/98
174

175   /**
176    * The number of rotations so far
177    */

178   public int nRotate = 0;
179   public transient UserFrame userframe;
180   boolean b_isApplet;
181   boolean b_isBot;
182   String JavaDoc botUrl;
183   String JavaDoc s_username;
184   int i_user;
185
186
187   public C3DUser() {
188   }
189
190
191   public C3DUser(Boolean JavaDoc b_isApplet, Boolean JavaDoc b_isBot, String JavaDoc url) {
192     this.b_isApplet = b_isApplet.booleanValue();
193     this.b_isBot = b_isBot.booleanValue();
194     this.botUrl = url;
195     this.onMigration = false;
196   }
197
198
199   public void go(ProActiveDescriptor pad) {
200     
201             
202     me = (C3DUser)org.objectweb.proactive.ProActive.getStubOnThis();
203     
204     // Creates the user Frame
205
vnDispatcher = pad.getVirtualNode("Dispatcher");
206     userframe = new UserFrame(me);
207     userframe.createWelcomePanel();
208     
209     setOnMigration(true);
210   }
211
212     public void rebuild(){
213         me = (C3DUser)org.objectweb.proactive.ProActive.getStubOnThis();
214         userframe = new UserFrame(me);
215         userframe.createPanelAfterMigration(dispatcher_host,s_username);
216     }
217     
218     public void clean(){
219         if (userframe != null){
220             userframe.dispose();
221             userframe = null;
222         }
223     }
224     
225     public void setOnMigration(boolean value){
226         this.onMigration = value;
227     }
228     
229     public boolean getOnMigration(){
230         return this.onMigration;
231     }
232     
233   public void runActivity(org.objectweb.proactive.Body body) {
234    logger.info("Starting custom live in C3DUser");
235     //System.out.println("migration "+getOnMigration());
236
org.objectweb.proactive.Service service = new org.objectweb.proactive.Service(body);
237     myStrategyManager = new MigrationStrategyManagerImpl((org.objectweb.proactive.core.body.migration.Migratable) body);
238     myStrategyManager.onDeparture("clean");
239     if(getOnMigration()) {
240         //System.out.println("on migration");
241
//System.out.println("width "+i_width);
242
//System.out.println("height "+i_height);
243
rebuild();
244         
245       }
246         
247     
248 // while (body.isActive()) {
249
// service.blockingServeOldest();
250
// }
251
service.fifoServing();
252         
253     
254     if(getOnMigration()) clean();
255     //if the activity is restarted it is a migration
256
//to be improved
257

258   }
259
260     
261
262   /**
263    * Entry point of the program
264    */

265   public static void main(String JavaDoc argv[]) throws NodeException{
266     
267     ProActiveDescriptor proActiveDescriptor = null;
268     
269     ProActiveConfiguration.load();
270         try
271         {
272             proActiveDescriptor =
273                 ProActive.getProactiveDescriptor(
274                     "file:"+argv[0]);
275             proActiveDescriptor.activateMappings();
276             
277         }
278         catch (Exception JavaDoc e)
279         {
280             e.printStackTrace();
281             logger.fatal("Pb in main");
282         }
283  
284     VirtualNode user =
285             proActiveDescriptor.getVirtualNode("User");
286             
287         Node node = user.getNode();
288     Object JavaDoc params[] = { new Boolean JavaDoc(false),new Boolean JavaDoc(false), ""};
289     try {
290         
291       C3DUser c3duser = (C3DUser)org.objectweb.proactive.ProActive.newActive("org.objectweb.proactive.examples.c3d.C3DUser", params, node.getNodeInformation().getURL());
292       
293       c3duser.go(proActiveDescriptor);
294     } catch (Exception JavaDoc e) {
295       e.printStackTrace();
296     }
297   }
298
299
300   public void log(String JavaDoc s_message) {
301     ta_log.append(s_message + "\n");
302   }
303
304
305   public void message(String JavaDoc s_message) {
306     ta_mess.append(s_message + "\n");
307   }
308
309
310   public UserFrame getUserFrame() {
311     return userframe;
312   }
313
314   
315   //@@ADDON Florian 13/8/98
316
/**
317    * Informs the user that a new user has joined the party!!
318    * @param nUser The new user's ID
319    * @param sNAme The new user's name
320    * @version ADDON 13/8/98
321    * @author Florian DOYON
322    */

323   public void informNewUser(int nUser, String JavaDoc sName) {
324     li_users.add(sName);
325     h_users.put(sName, new Integer JavaDoc(nUser));
326   }
327
328
329   /**
330    * Informs the user that another user left
331    * @param nUser The id of the old user
332    * @version ADDON 16/8/98
333    * @author Florian DOYON
334    */

335   public void informUserLeft(String JavaDoc sName) {
336
337     // remove the user from the users list
338
try {
339       li_users.remove(sName);
340     } catch (Exception JavaDoc e) {
341         e.printStackTrace();
342     }
343
344     // Remove the user from the hash table
345
h_users.remove(sName);
346
347     if (h_users.isEmpty()) {
348       talkId = -1;
349       li_users.select(0);
350     }
351   }
352   //@@END_ADDON Florian 13/8/98
353

354   /**
355    * The pinging function called by <code>C3DDispatcher</code>
356    * to get the avg. pinging time
357    */

358   public int ping() {
359     return 0;
360   }
361
362
363   /**
364    * Create and initialize the scene for the rendering picture.
365    * @return The scene just created
366    */

367   private Scene createScene() {
368     int x = 0;
369     int y = 0;
370
371     Scene scene = new Scene();
372     
373     /* Creates three objects (spheres) */
374     Primitive p = new Sphere(new Vec(10, -5.77, 0), 7);
375     p.setColor(1.0, 0.0, 0.0);
376     p.surf.shine = 14.0;
377     p.surf.kd = 0.7;
378     p.surf.ks = 0.3;
379     p.surf.ior = 0.3;
380     scene.addObject(p);
381
382     p = new Sphere(new Vec(0, 11.55, 0), 7);
383     p.setColor(0.0, 1.0, 0.0);
384     p.surf.shine = 14.0;
385     p.surf.kd = 0.7;
386     p.surf.ks = 0.3;
387     scene.addObject(p);
388
389     p = new Sphere(new Vec(-10, -5.77, 0), 7);
390     p.setColor(0.0, 0.0, 1.0);
391     p.surf.shine = 14.0;
392     p.surf.kd = 0.7;
393     p.surf.ks = 0.3;
394     scene.addObject(p);
395
396     /*
397         p = new Sphere(new Vec(0,0,0), 3);
398         p.setColor(1.0,1.0,1.0);
399         p.surf.shine = 15.0;
400         p.surf.ks = 0.5;
401         p.surf.kt=0.5;
402         scene.addObject(p);
403  
404         p = new Sphere(new Vec(-10,5.77,0), 4);
405         p.setColor(0.0,1.0,1.0);
406         p.surf.shine = 14.0;
407         p.surf.kd = 0.7;
408         p.surf.ks = 0.3;
409         scene.addObject(p);
410
411         p = new Sphere(new Vec(10,5.77,0), 4);
412         p.setColor(1.0,1.0,0.0);
413         p.surf.shine = 14.0;
414         p.surf.kd = 0.7;
415         p.surf.ks = 0.3;
416         scene.addObject(p);
417  
418         p = new Sphere(new Vec(0,-11.55,0), 4);
419         p.setColor(1.0,0.0,1.0);
420         p.surf.shine = 14.0;
421         p.surf.kd = 0.7;
422         p.surf.ks = 0.3;
423         scene.addObject(p);
424
425         p = new Sphere(new Vec(0,0,14), 8);
426         p.setColor(0.0,0.0,0.0);
427         p.surf.shine = 14.0;
428         p.surf.kd = 0.7;
429         p.surf.ks = 0.3;
430         scene.addObject(p);
431
432     */

433     /* Creates five lights for the scene */
434     scene.addLight(new Light(100, 100, -50, 1.0));
435     scene.addLight(new Light(-100, 100, -50, 1.0));
436     scene.addLight(new Light(100, -100, -50, 1.0));
437     // scene.addLight(new Light(-100,-100,-50, 1.0));
438
// scene.addLight(new Light(200, 200, 0, 1.0));
439
// scene.addLight(new Light(0,0, 0, 1.0));
440

441     /* Creates a View (viewing point) for the rendering scene */
442     View v = new View();
443     // v.from = new Vec(x, y, -40);
444
v.from = new Vec(x, y, -30);
445     // v.from = new Vec(x, y, -5);
446
v.at = new Vec(x, y, -15);
447     v.up = new Vec(0, 1, 0);
448     v.angle = 35.0 * 3.14159265 / 180.0;
449     v.aspect = 1.0; /* 4.0/3.0; */
450     v.dist = 1.0;
451     scene.addView(v);
452
453     return scene;
454   }
455
456
457   /**
458    * Display an interval of newly calculated pixels
459    * @param newpix The pixels as int array
460    * @param interval The interval
461    */

462   public void setPixels(int[] newpix, Interval interval) {
463     int from = interval.width * interval.yfrom;
464     
465     /* Copy new pixels among the old ones */
466     System.arraycopy(newpix, 0, pix, from, newpix.length);
467     
468     /* Inform the image observers of the update */
469     mis.newPixels(0, interval.yfrom, interval.width, interval.yto);
470
471     /* Refresh the image displayed on the frame */
472     userframe.repaint();
473   }
474
475
476   /**
477    * Displays a message from the <code>C3DDispatcher</code> in the status log
478    *
479    * @param message message to be displayed
480    */

481   public void showMessage(String JavaDoc message) {
482     ta_log.append(message + "\n");
483     if (b_isBot) {
484       // if all the intervals are rendered
485
if (message.substring(0, 3).compareTo("All") == 0) {
486         // 16 renderings
487
if (nRotate < 15) {
488           nRotate++;
489           c3ddispatcher.rotateLeft(i_user);
490         } else {
491           c3ddispatcher.doBenchmarks();
492           exit();
493         }
494       }
495     }
496   }
497
498
499   public void showUserMessage(String JavaDoc message) {
500     ta_mess.append(message + '\n');
501   }
502
503
504   public void dialogMessage(String JavaDoc title, String JavaDoc content) {
505     MsgDialog md = new MsgDialog(userframe, title, content);
506     md.setVisible(true);
507   }
508
509
510   /**
511    * OOP encapsulation method for 'int width'
512    * @return width of the applet window, i.e. width of the rendering image
513    */

514
515   public Integer JavaDoc getWidth() {
516     //System.out.println("Dispatcher asks for width ");
517
return new Integer JavaDoc(i_width);
518   }
519
520
521   /**
522    * OOP encapsulation method for 'int height'
523    * @return height of the applet window, i.e. height of the rendering image
524    */

525   public Integer JavaDoc getHeight() {
526     return new Integer JavaDoc(i_height);
527   }
528
529
530   /**
531    * Exit the application
532    */

533
534   void exit() {
535     try {
536       c3ddispatcher.unregisterConsumer(i_user);
537       userframe.setVisible(false);
538       userframe.dispose();
539       userframe = null;
540       me.terminate();
541      
542     } catch (NullPointerException JavaDoc ex) {
543         ex.printStackTrace();
544     }
545 // if (!b_isApplet) {
546
//
547
// System.exit(0);
548
// }
549
}
550
551
552   private void trace(String JavaDoc s_message) {
553     logger.info("C3DUser: " + s_message);
554   }
555
556
557     public void terminate(){
558         org.objectweb.proactive.ProActive.getBodyOnThis().terminate();
559     }
560
561   public class UserFrame extends Frame JavaDoc implements ActionListener JavaDoc, ItemListener JavaDoc {
562
563     /**
564      * Button UP
565      */

566     
567     private Button JavaDoc b_up = new EqualButton("Up");
568     /**
569      * Button UP
570      */

571     private Button JavaDoc b_down = new EqualButton("Down");
572     /**
573      * Button to request the 'rotate left' action
574      */

575     private Button JavaDoc b_left = new EqualButton("Left");
576     /**
577      * Button to request the 'rotate right' action
578      */

579     private Button JavaDoc b_right = new EqualButton("Right");
580     /**
581      * Button to request the spin clock action
582      */

583     private Button JavaDoc b_clock = new EqualButton("Spin right");
584     /**
585      * Button to request the spin unclock action
586      */

587     private Button JavaDoc b_unclock = new EqualButton("Spin left");
588     /**
589      * Button to exit the application
590      */

591     private Button JavaDoc b_exit = new EqualButton("Exit");
592     /***
593      * Button to add a Sphere
594      */

595     private Button JavaDoc b_addSphere = new Button JavaDoc("Add random sphere");
596     /**
597      * Button to conenct to the dispatcher
598      */

599     private Button JavaDoc b_connect = new EqualButton("Connect");
600     /**
601      * Button to reset the scene
602      */

603     private Button JavaDoc b_reset = new EqualButton("Reset");
604     /**
605      * Button used for sending messages
606      */

607     private Button JavaDoc b_send = new Button JavaDoc("Send");
608     private TextField JavaDoc tf_mess, tf_name, tf_host;
609     private GridBagLayout JavaDoc gridbag = new GridBagLayout JavaDoc();;
610     private GridBagConstraints JavaDoc c = new GridBagConstraints JavaDoc();
611     private String JavaDoc s_localhost;
612     private C3DUser c3duser;
613     private MenuItem JavaDoc mi_exit, mi_clear, mi_list,mi_about;
614     private Font JavaDoc f_standard = new Font JavaDoc("SansSerif", Font.PLAIN, 12);
615     private int i_top;
616     private MenuBar JavaDoc mb;
617
618
619     /**
620      * One and only constructor for <code>UserFrame</code>. Creates and
621      * displays this frame and the GUI objects, creates the image object
622      * to take the rendered picture.
623      */

624     public UserFrame(C3DUser c3d) {
625       super("Collaborative 3D Environment - User Window");
626       setBackground(Color.lightGray);
627       setLayout(gridbag);
628       setFont(f_standard);
629       addWindowListener(new MyWindowListener());
630       c3duser = c3d;
631
632       s_localhost = "";
633       try {
634         s_localhost = InetAddress.getLocalHost().getCanonicalHostName();
635       } catch (UnknownHostException JavaDoc e) {
636         s_localhost = "unknown!";
637       }
638     }
639
640         public UserFrame(C3DUser c3d, boolean value) {
641             super("Collaborative 3D Environment - User Window");
642       setBackground(Color.lightGray);
643       setLayout(gridbag);
644       setFont(f_standard);
645       addWindowListener(new MyWindowListener());
646       c3duser = c3d;
647       s_localhost = "";
648       try {
649         s_localhost = InetAddress.getLocalHost().getCanonicalHostName();
650       } catch (UnknownHostException JavaDoc e) {
651         s_localhost = "unknown!";
652       }
653     
654         }
655         
656     public Button JavaDoc getB_up() {
657       return b_up;
658     }
659
660
661     public Button JavaDoc getB_down() {
662       return b_down;
663     }
664
665
666     public Button JavaDoc getB_left() {
667       return b_left;
668     }
669
670
671     public Button JavaDoc getB_right() {
672       return b_right;
673     }
674
675
676     public Button JavaDoc getB_clock() {
677       return b_clock;
678     }
679
680
681     public Button JavaDoc getB_unclock() {
682       return b_unclock;
683     }
684
685
686     /**
687      * Creates the display for a benchmarking bot
688      */

689     public void createBot(String JavaDoc url) {
690       s_username = "Benchmarking bot";
691       //createFinalPanel(url, s_username);
692
}
693
694
695     private void createWelcomePanel() {
696       Label JavaDoc l1 = new Label JavaDoc("Welcome to the Collaborative 3D Environment -", Label.CENTER);
697       c.insets = new Insets JavaDoc(5, 5, 0, 5);
698       c.gridwidth = GridBagConstraints.REMAINDER;
699       c.weightx = 1.0;
700       gridbag.setConstraints(l1, c);
701       add(l1);
702
703       Label JavaDoc l2 = new Label JavaDoc("a Java// test application", Label.CENTER);
704       c.insets = new Insets JavaDoc(0, 5, 0, 5);
705       gridbag.setConstraints(l2, c);
706       add(l2);
707
708       Label JavaDoc l3 = new Label JavaDoc("Please enter your name and the host of the C3DDispatcher.", Label.CENTER);
709       c.insets = new Insets JavaDoc(15, 5, 10, 5);
710       gridbag.setConstraints(l3, c);
711       add(l3);
712
713       Label JavaDoc l4 = new Label JavaDoc("Name:", Label.RIGHT);
714       Label JavaDoc l5 = new Label JavaDoc("Host:", Label.RIGHT);
715       c.insets = new Insets JavaDoc(5, 5, 5, 0);
716       c.gridwidth = 1;
717       c.anchor = GridBagConstraints.EAST;
718       gridbag.setConstraints(l4, c);
719       gridbag.setConstraints(l5, c);
720
721       tf_name = new TextField JavaDoc(20);
722       tf_name.addActionListener(this);
723
724       tf_host = new TextField JavaDoc(s_localhost, 20);
725       tf_host.addActionListener(this);
726       c.insets = new Insets JavaDoc(5, 0, 5, 5);
727       c.anchor = GridBagConstraints.CENTER;
728       c.gridwidth = GridBagConstraints.REMAINDER;
729       gridbag.setConstraints(tf_name, c);
730       gridbag.setConstraints(tf_host, c);
731
732       add(l4);
733       add(tf_name);
734       add(l5);
735       add(tf_host);
736
737       c.gridwidth = GridBagConstraints.RELATIVE;
738       c.insets = new Insets JavaDoc(15, 5, 10, 5);
739       c.anchor = GridBagConstraints.EAST;
740       gridbag.setConstraints(b_connect, c);
741       b_connect.addActionListener(this);
742       add(b_connect);
743       c.gridwidth = GridBagConstraints.REMAINDER;
744       c.anchor = GridBagConstraints.CENTER;
745       gridbag.setConstraints(b_exit, c);
746       b_exit.addActionListener(this);
747       add(b_exit);
748
749       pack();
750       setVisible(true);
751       toFront();
752     }
753
754         public void createPanel(String JavaDoc s_host,String JavaDoc s_name){
755             setVisible(false);
756       removeAll();
757
758       mb = new MenuBar JavaDoc();
759       Menu JavaDoc m_file = new Menu JavaDoc("File", false);
760       m_file.setFont(f_standard);
761       mi_exit = new MenuItem JavaDoc("Exit");
762       mi_clear = new MenuItem JavaDoc("Clear log");
763       mi_list = new MenuItem JavaDoc("List users");
764       mi_clear.setFont(f_standard);
765       mi_exit.setFont(f_standard);
766       mi_list.setFont(f_standard);
767       mi_exit.addActionListener(this);
768       mi_clear.addActionListener(this);
769       mi_list.addActionListener(this);
770       m_file.add(mi_list);
771       m_file.add(mi_clear);
772       m_file.addSeparator();
773       m_file.add(mi_exit);
774       mb.add(m_file);
775
776       Menu JavaDoc m_c3d = new Menu JavaDoc("C3D ProActive PDC", false);
777       mi_about = new MenuItem JavaDoc("About ProActive PDC");
778       mi_about.setFont(f_standard);
779       mi_about.addActionListener(this);
780       m_c3d.add(mi_about);
781
782       mb.setHelpMenu(m_c3d);
783       setMenuBar(mb);
784
785       /* Instanciates the destination pixel array */
786       pix = new int[i_width * i_height];
787    
788       /* Creates a MemoryImageSource as a pixel source for the image */
789       mis = new MemoryImageSource JavaDoc(i_width, i_height, pix, 0, i_width);
790
791       /* Accomodates the changing nature (rotation) of the image */
792       mis.setAnimated(true);
793
794       /* Creates an image component from the image from the
795        * MemoryImageSource; avoids drawing issues in the user frame
796        * and places it in a panel
797        */

798       Panel JavaDoc p_image = new Panel JavaDoc(new GridLayout JavaDoc(1, 1));
799       //System.out.println("p image "+p_image.getSize().width);
800

801       // PANEL CONSTRAINTS
802
c.insets = new Insets JavaDoc(5, 5, 0, 5);
803       
804       // position
805
c.gridx = 0;
806       c.gridy = 0;
807       c.weightx = 1;
808       c.weighty = 1;
809       
810       // size;
811
c.gridwidth = 1;
812       c.gridheight = 1;
813
814       //fill
815
c.fill = GridBagConstraints.BOTH; // components will fill their whole area
816

817       gridbag.setConstraints(p_image, c);
818       //System.out.println("p image "+p_image.getSize().width);
819
p_image.add(new MyImageContainer(createImage(mis), i_width, i_height, p_image));
820       add(p_image);
821
822       /**
823        * The log and buttons area
824        */

825       
826       // Creates the panel and places it in the main frame
827
Panel JavaDoc p_log = new Panel JavaDoc();
828       
829       // adds the panel
830
c.gridx = 1;
831       gridbag.setConstraints(p_log, c);
832       add(p_log);
833       
834       // Creates the panel's layout manager
835
GridBagLayout JavaDoc gb_panel = new GridBagLayout JavaDoc();
836       p_log.setLayout(gb_panel);
837       
838       // Label displaying the username
839
l_user = new Label JavaDoc("User " + s_name, Label.CENTER);
840       l_user.setFont(new Font JavaDoc("SansSerif", Font.ITALIC + Font.BOLD, 18));
841
842       GridBagConstraints JavaDoc pc = new GridBagConstraints JavaDoc();
843
844       pc.fill = GridBagConstraints.BOTH;
845       pc.insets = new Insets JavaDoc(5, 5, 0, 5);
846       pc.gridx = 0;
847       pc.gridy = 0;
848       pc.weightx = 1;
849       pc.weighty = 1;
850       pc.gridwidth = GridBagConstraints.REMAINDER;
851       gb_panel.setConstraints(l_user, pc);
852       p_log.add(l_user);
853       
854       // Label displaying local machine informations
855
Label JavaDoc l_machine = new Label JavaDoc("Local host: " + s_localhost + " (" + System.getProperty("os.name") + " " + System.getProperty("os.version") + ")");
856
857       // Adds the label in the panel
858
pc.gridy = 1;
859       gb_panel.setConstraints(l_machine, pc);
860       p_log.add(l_machine);
861       
862       
863       // Label displaying C3DDispatcher informations
864
l_c3ddispatcher = new Label JavaDoc("C3DDispatcher host: " + s_host);
865       pc.gridy = 2;
866       gb_panel.setConstraints(l_c3ddispatcher, pc);
867       p_