Horus Doc || Java GUI Reference || Doxygen's quick Index  

LoadElement Class Reference

Inheritance diagram for LoadElement::

MachineElement AnimatedMachine List of all members.

Public Methods

 LoadElement ()
void keyPressed ()
void animationStep ()
boolean continueAnimation ()
void run ()

Protected Methods

void doInit ()

Constructor & Destructor Documentation

LoadElement::LoadElement   [inline]
 

00026 {
00027     int marginLF = 0;
00028     int marginUP = 0;
00029     int marginRG = Math.max(KeyComponent.componentSize().width / 2,
00030                             ImageElement.componentSize().width / 2);
00031     int marginDW = 0;
00032     int machineW = 101;
00033     int machineH = 122;
00034 
00035     setSize(marginLF+machineW+marginRG, marginUP+machineH+marginDW);
00036     setMachineImage(Images.loader, marginLF, marginUP, machineW, machineH);
00037 
00038     _output = createOutputSocket(
00039                 marginLF+machineW-ImageElement.componentSize().width/2,
00040                 marginUP + 66);
00041     _key = createKeyComponent(
00042                 marginLF+machineW-KeyComponent.componentSize().width/2 - 2,
00043                 marginUP + 8);
00044 
00045     _key.setVisible(false);
00046 }


Member Function Documentation

void LoadElement::keyPressed   [inline, virtual]
 

Reimplemented from AnimatedMachine.

00050 {
00051     if(_working) return;
00052 
00053     if(!_output.empty()) return;
00054 
00055     LoadProperties dlg = new LoadProperties();
00056     dlg.show();
00057     if(dlg.name != null) {
00058         //_imageMgr = getManager(dlg.server);
00059          _imageName = dlg.name;
00060 
00061          _working = true;
00062          _key.startAnimation();
00063          new Thread(this).start();
00064     }
00065 }

void LoadElement::animationStep   [inline, virtual]
 

Reimplemented from AnimatedMachine.

00069 {
00070 }

boolean LoadElement::continueAnimation   [inline, virtual]
 

Reimplemented from AnimatedMachine.

00074 {
00075     return _working;
00076 }

void LoadElement::run   [inline]
 

00079 {
00080     try {
00081         ImageElement result = null;
00082         if(_imageName.startsWith("http://")) {
00083             URL url = new URL(_imageName);
00084             HxCorba.ImageRep img = _imageMgr.loadWebImage(url);
00085             String name = new File(url.getFile()).getName();
00086             result = new ImageElement(img, name);
00087         }else {
00088             HxCorba.ImageRep img = _imageMgr.loadServerImage(_imageName);
00089             result = new ImageElement(img, _imageName);
00090         }
00091         if(result != null) _output.setElement(result);
00092 
00093     }catch(MalformedURLException e) {
00094         ErrorStreamArea.println("Malformed URL");
00095     }catch(org.omg.CORBA.OBJECT_NOT_EXIST e) {
00096         ErrorStreamArea.println("Image "+_imageName+" is sold out");
00097     }catch(Exception e) {
00098         ErrorStreamArea.println(""+e);
00099         e.printStackTrace();
00100     }
00101     _working = false;
00102 }

void LoadElement::doInit   [inline, protected]
 

Reimplemented from MachineElement.

00111 {
00112     _imageMgr = ImageManager.defaultImageMgr();
00113     if(_imageMgr != null)
00114         _key.setVisible(true);
00115     else
00116         turnOff("No servers available");
00117 
00118     repaint();
00119 }


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:22 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001