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

PlayElement Class Reference

Inheritance diagram for PlayElement::

MachineElement AnimatedMachine ConnectorMachine List of all members.

Public Methods

 PlayElement ()
HxCorba.ImageRep computeResult ()
void componentAdded (ContainerEvent e)
void componentRemoved (ContainerEvent e)
void keyPressed ()
void animationStep ()
boolean continueAnimation ()

Constructor & Destructor Documentation

PlayElement::PlayElement   [inline]
 

00023 {
00024     int marginLF = 0;
00025     int marginUP = 0;
00026     int marginRG = KeyComponent.componentSize().width  / 2 - 10;
00027     int marginDW = ImageElement.componentSize().height / 2;
00028     int machineW = 114;
00029     int machineH = 90;
00030 
00031     setSize(marginLF+machineW+marginRG, marginUP+machineH+marginDW);
00032     setMachineImage(Images.player, marginLF, marginUP, machineW, machineH);
00033 
00034     _props = new PlayProperties();
00035     _props.length = 0;
00036     _props.pos = -1;
00037 
00038     _output = createOutputSocket(0, 5);
00039     _input = createInputSocket(marginLF+22, marginUP + machineH - marginDW - 2);
00040     _propComp = createPropertyComponent(_props, marginLF+58, marginUP + 62, 35);
00041     _key = createKeyComponent(marginLF+machineW-marginRG-27, marginUP + 5);
00042     _display = createDisplayComponent(marginLF+22, marginUP+4, 70, 47);
00043 
00044     _conMgr = new ConnectorManager(this, _output);
00045     _conMgr.setColor(Color.orange);
00046     _conMgr.createConnector("Player frame");
00047 
00048     _input.addContainerListener(this);
00049 }


Member Function Documentation

HxCorba.ImageRep PlayElement::computeResult   [inline, virtual]
 

Reimplemented from ConnectorMachine.

00053 {
00054     if(_input == null) return null;
00055     return _input.getImageRep();
00056 }

void PlayElement::componentAdded ContainerEvent    e [inline]
 

00059 {
00060     if(e.getContainer() != _input) return;
00061 
00062     ImageElement elem = (ImageElement)e.getChild();
00063 
00064     if(elem instanceof VideoElement) {
00065         _velem = (VideoElement)elem;
00066         _props.pos = _velem.getFrameNumber();
00067         _props.length = _velem.getVideo().nrFrames();
00068     }else if(elem instanceof ConnectorElement) {
00069         _props.pos = -1;
00070         _props.length = 0;
00071     }else if(elem.getImageRep() != null) {
00072         _props.pos = 0;
00073         _props.length = 1;
00074     }else {
00075         _props.pos = -1;
00076         _props.length = 0;
00077     }
00078 
00079     _propComp.repaint();
00080     if(_props.pos != -1)
00081         _display.showImage(elem.getImageRep());
00082 }

void PlayElement::componentRemoved ContainerEvent    e [inline]
 

00085 {
00086     if(e.getChild() == this) _conMgr.freeConnector();
00087 
00088     if(e.getContainer() != _input) return;
00089 
00090     _props.pos = -1;
00091     _props.length = 0;
00092     _video = null;
00093     _velem = null;
00094     _working = false;
00095     _display.clear();
00096 }

void PlayElement::keyPressed   [inline, virtual]
 

Reimplemented from AnimatedMachine.

00100 {
00101     if(_velem == null) return;
00102 
00103     _working = !_working;
00104 
00105     if(_working) {
00106         //machine started
00107         _video = _velem.getVideo();
00108         _key.startAnimation(20);
00109     } else
00110         //stopped
00111         _velem.setFrame(_props.pos);
00112 }

void PlayElement::animationStep   [inline, virtual]
 

Reimplemented from AnimatedMachine.

00116 {
00117     if(_velem == null) return;
00118 
00119     _props.pos++;
00120     if(_props.pos >= _video.nrFrames()) {
00121         _props.pos = _video.nrFrames()-1;
00122         _velem.setFrame(_props.pos);
00123         _working = false;
00124     }
00125     else {
00126         _display.showImage(_video.getFrame(_props.pos));
00127     }
00128     _propComp.repaint();
00129 }

boolean PlayElement::continueAnimation   [inline, virtual]
 

Reimplemented from AnimatedMachine.

00133 {
00134     return (_working && (_velem != null));
00135 }


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