Inheritance diagram for OutputElement::

Public Methods | |
| OutputElement () | |
| void | componentAdded (ContainerEvent e) |
| void | componentRemoved (ContainerEvent e) |
| void | paint (Graphics g) |
| void | mouseClicked (MouseEvent e) |
| void | mouseEntered (MouseEvent e) |
| void | mouseExited (MouseEvent e) |
| void | mousePressed (MouseEvent e) |
| void | mouseReleased (MouseEvent e) |
| HxCorba.ImageRep | computeResult () |
| void | keyPressed () |
| void | animationStep () |
| boolean | continueAnimation () |
| void | run () |
| void | lostOwnership (Clipboard clipboard, Transferable contents) |
Protected Methods | |
| void | doInit () |
|
|
00025 {
00026 int marginLF = 0;
00027 int marginUP = 0;
00028 int marginRG = KeyComponent.componentSize().width / 2;
00029 int marginDW = 0;
00030 int machineW = 68;
00031 int machineH = 97;
00032
00033 setSize(marginLF+machineW+marginRG, marginUP+machineH+marginDW);
00034 setMachineImage(Images.transport, marginLF, marginUP, machineW, machineH);
00035
00036 _props = new OutProperties();
00037 _props.destination = "World";
00038
00039 _inout = createOutputSocket(marginLF+15, marginUP + 32);
00040 setLayer(_inout, PROP_LAYER.intValue()); //on top of machineImage
00041
00042 _destination = createPropertyComponent(_props, marginLF+5, marginUP + 74, 60);
00043 _key = createKeyComponent(marginLF+machineW-marginRG-2, marginUP);
00044
00045 _direction = createPropertyComponent("", marginLF+10, marginUP+10, 48);
00046 _direction.addMouseListener(this);
00047 _direction.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
00048
00049 _mode = MODE_RECEIVE;
00050 _direction.setText("Receive");
00051
00052 _conMgr = new ConnectorManager(this, _inout);
00053 _conMgr.setColor(Color.green.darker());
00054
00055 _appMgr = null;
00056 _inout.setVisible(false);
00057 _key.setVisible(false);
00058 _direction.setVisible(false);
00059 _destination.setVisible(false);
00060 }
|
|
|
00062 {}
|
|
|
00065 {
00066 if(e.getChild() == this) _conMgr.freeConnector();
00067 }
|
|
|
00070 {
00071 super.paint(g);
00072
00073 java.util.Random rand = new java.util.Random();
00074 g.setColor(Color.green);
00075
00076 for(int i=0; i<_nStars; i++) {
00077 int x = 6 + rand.nextInt(55);
00078 int y = 28 + rand.nextInt(45);
00079 g.drawLine(x-2,y,x+2,y);
00080 g.drawLine(x,y-2,x,y+2);
00081 }
00082 }
|
|
|
00085 {
00086 do {
00087 _mode = (_mode + 1) % 5;
00088 }while(!modeAllowed(_mode));
00089
00090 _inout.isInput((_mode == MODE_SEND) || (_mode == MODE_COPY));
00091 String [] modeStr = {"Receive", "Paste", "Connect", " Send", "Copy" };
00092 _direction.setText(modeStr[_mode]);
00093 repaint();
00094 }
|
|
|
00096 {}
|
|
|
00097 {}
|
|
|
00098 {}
|
|
|
00099 {}
|
|
|
Reimplemented from ConnectorMachine.
00104 {
00105 if((_mode != MODE_RECEIVE) && ((_mode != MODE_PASTE))) return null;
00106
00107 if(_mode == MODE_PASTE) {
00108 _working = true;
00109 _nStars = 0;
00110 _starsUp = false;
00111 new Thread(this).start();
00112 }
00113 else {
00114 _working = false;
00115 _nStars = 0;
00116 _starsUp = true;
00117 }
00118
00119 _key.startAnimation();
00120 _key.joinAnimation();
00121
00122 if(_inout.empty()) return null;
00123
00124 HxCorba.ImageRep result = _inout.getImageRep();
00125 _inout.removeElement();
00126
00127 return result;
00128 }
|
|
|
Reimplemented from AnimatedMachine.
00132 {
00133 if((_nStars > 0) || (_starsUp)) return; //already pressed
00134
00135 if(_key.isTurned()) { //there is a connector
00136 _conMgr.freeConnector();
00137 _key.turnKey();
00138 return;
00139 }
00140
00141 if(!_inout.empty() && (_mode == MODE_RECEIVE)) return;
00142 if(!_inout.empty() && (_mode == MODE_PASTE)) return;
00143 if(_inout.empty() && (_mode == MODE_SEND)) return;
00144 if(_inout.empty() && (_mode == MODE_COPY)) return;
00145
00146 if(_inout.empty() && (_mode == MODE_CONNECT)) {
00147 _conMgr.createConnector("Output result");
00148 _key.turnKey();
00149 return;
00150 }
00151
00152 if((_mode == MODE_COPY) || (_mode == MODE_PASTE)) {
00153 _working = true;
00154 _nStars = 0;
00155 _starsUp = false;
00156 new Thread(this).start();
00157 }
00158 else {
00159 _working = false;
00160 _nStars = 0;
00161 _starsUp = true;
00162 }
00163
00164 _key.startAnimation();
00165 }
|
|
|
Reimplemented from AnimatedMachine.
00169 {
00170 if(_starsUp) {
00171 _nStars += 5;
00172 if(_nStars >= 15) {
00173 _working = true;
00174 _starsUp = false;
00175 new Thread(this).start();
00176 }
00177 }
00178 else
00179 if(!_working) _nStars -= 5;
00180
00181 repaint();
00182 }
|
|
|
Reimplemented from AnimatedMachine.
00186 {
00187 return (_working || (_nStars > 0));
00188 }
|
|
|
00191 {
00192 try {
00193 if(_mode == MODE_COPY) doCopy();
00194 else if(_mode == MODE_PASTE) doPaste();
00195 else if(_mode == MODE_SEND) doSend();
00196 else if(_mode == MODE_RECEIVE) doReceive();
00197
00198 }catch(Exception err){
00199 ErrorStreamArea.println("Error! "+err+"\n");
00200 err.printStackTrace();
00201 }
00202
00203 _working = false;
00204 }
|
|
||||||||||||
|
00207 {}
|
|
|
Reimplemented from MachineElement.
00216 {
00217 _appMgr = ApplicationsManager.defaultAppMgr();
00218 if(_appMgr != null)
00219 _destination.setVisible(true);
00220 else {
00221 _mode = MODE_PASTE; // only Copy&Paste allowed
00222 _direction.setText("Paste");
00223 //turnOff("NameService can not be found");
00224 }
00225
00226 _inout.setVisible(true);
00227 _key.setVisible(true);
00228 _direction.setVisible(true);
00229 repaint();
00230 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001