Nicolas Vervelle wrote:
Let's try to work on how to make it useable for both Java and JavaScript.
First, I think we should concentrate on defining the kind of data
structure the getProperty() mechanism should be able to return.
I am putting a first draft in this mail.
My understanding is:
- The getProperty() method could return an "Object" or an ordered array
of "Object".
- An "Object" itself is simply an unordered collection of "Property".
- A "Property" is the combination of a "Property Name" and a "Property
Value".
- A "Property Name" is a string.
- A "Property Value" can be of several kinds: string, integer, floating
point, boolean, (are there others ?), "Object" or even an ordered array
of one of the previous types.
and that's all.
That's what I see. I'd conceptualize it as:
1. The getProperty() method could return an associative array
consisting of a single "property name" key associated with a single
"property value". (This is what it does now, in JSON.)
2. A "property value" consists of one of:
(a) a text string
(b) a numeric value of some type, including boolean
(c) an ordered array of (a) - (d)
(d) an associative array of (a) - (d)
That pretty much takes care of it. Depth will go a few levels, I
think, not more. You have, for example:
an ordered array of atoms, each of which is an associative array of a
mixture of string and numeric values. Something like:
JSON:
{"atomInfo":[{"ipt":0,"number":1,"sym":"H","atno":1
,"x":-3.380413,"y":-1.1272367,"z":0.5733036
,"name":"H","model":0,"info":"H 1 #1"},{...
JavaScript:
atomInfo=new Array()
atomInfo[0]=new Array()
atomInfo[0].ipt=0
atomInfo[0].number=1
atomInfo[0].sym="H"
atomInfo[0].atno=1
atomInfo[0].x=-3.380413
atomInfo[0].y=-1.1272367
atomInfo[0].z=0.5733036
atomInfo[0].name="H"
atomInfo[0].model=0
atomInfo[0].info="H 1 #1"
atomInfo[1]=new Array() ...
a transform matrix is an ordered array of ordered arrays of numerics.
Java: transformInfo = [ [1.0 0.0 0.0] [0.0 1.0 0.0] [0.0 0.0 1.0] ]
JSON: {"transformInfo": [
[1.0,0.0,0.0],[0.0,1.0,0.0],[0.0,0.0,1.0] ]}
JavaScript:
transformInfo=new Array()
transformInfo[0]=new Array()
transformInfo[0][0]=1
transformInfo[0][1]=0
transformInfo[0][2]=0
transformInfo[1]=new Array()
transformInfo[1][0]=0
transformInfo[1][1]=1
transformInfo[1][2]=0
transformInfo[2]=new Array()
transformInfo[2][0]=0
transformInfo[2][1]=0
transformInfo[2][2]=1
A boundbox data structure is just an associative array of ordered
arrays of numerics.
JSON:
{"boundboxInfo": {"center":[-0.23140144, 0.61279976,
0.071704745],"edge":[3.1490116, 3.4308553, 2.4460702]}}
etc.
Now, if pointers to Java objects (with methods and private properties
and such are also possible, that COULD be a big glitch for
JavaScript/applet communication, I don't know. Maybe not if a JSON
string can be made from any such object.
Bob
--
Robert M. Hanson, [EMAIL PROTECTED], 507-646-3107
Professor of Chemistry, St. Olaf College
1520 St. Olaf Ave., Northfield, MN 55057
mailto:[EMAIL PROTECTED]
http://www.stolaf.edu/people/hansonr
"Imagination is more important than knowledge." - Albert Einstein
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers