Miguel,
I now have a simple Jmol "plugin" for my distributed presentation
system as well as an only *very*slightly* modified JmolApplet, that
*always* includes a text field for script command entry and that
knows how to send off script commands to its remote peers,
or to execute script commands sent to it by remote peers.
As I see it now, I am going to limit my attempts at synchronziation
of Jmol models to this type of distributed execution of Jmol-script
commands - until I can *read* the current state of a Jmol model
more directly. So *interactive* modifications of the Jmol model
are not currently handled at all....
To prove that the whole remoting bit, in the case of the modified
JmolApplet, is acutally quite simple, let me show the relevant code
snippets here. Text field entry is caught, as usual, by an ActionListener:
// Action listener (JTextField)
public void actionPerformed(ActionEvent evt) {
String text = _textField.getText();
doScriptCmd(false, text);
}
doScriptCnd(...) comment sends the script to its remote peers and executes
it locally as well like this:
private void doScriptCmd(boolean remote, String cmds) {
if (!remote && _messageOut != null) {
// send locally entered script command to all peers
try {
_messageOut.writeInt(SCRIPTCMD);
_messageOut.writeUTF(cmds);
_messageOut.send();
}
catch (IOException exc) {
exc.printStackTrace();
}
}
if (remote)
_textField.setText(cmds); // insert command into our text field as
well
// actually execute script command (remote and local case)
script(cmds);
_textField.selectAll(); // so it's easier to to overwrite the command
just executed
}
If a remote peer sends us script command this way, the following function,
receive(), gets invoked:
public void receive (DataInputStream messageIn) {
try {
while (messageIn.available () > 0) {
switch (messageIn.readInt()) {
case SCRIPTCMD:
doScriptCmd(true, messageIn.readUTF());
break;
default:
complain("receive() -- unhandled command "+cmd);
}
}
}
catch (IOException exc) {
exc.printStackTrace();
}
}
That's it. Easy, isn't it? - Of course, even though this works, up
to a point, being able to read the relevant state from the Jmol
model itself would allow me to improve the level of remote
synchronization that can be done *very*significantly*....
So I will always be eager to hear good news from you in this
regard ;-)
Regards,
Christian
----- Original Message -----
From: "Miguel Howard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, December 14, 2003 8:13 PM
Subject: Re: [Jmol-users] Synchronizing distributed molecular models
<snip/>
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Jmol-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jmol-users