and tags,
and ignore all the other information and tags in the CML. */
private static function loadCML(cml: XML, g: Graph): void {
var gid: String = cml.@id;
var item: Item;
// look for elements that have no namespace
for each (var node: XML in cml..atom) {
item = new Item(gid + node.@id);
item.data = node;
g.add(item);
}
// look for elements in the standard CML namespace
for each (node in cml..cmlns::atom) {
item = new Item(gid + node.@id);
item.data = node;
g.add(item);
}
// look for elements that have no namespace
for each (var bond: XML in cml..bond) {
loadBond(bond, g, gid);
}
// look for elements in the standard CML namespace
for each (bond in cml..cmlns::bond) {
loadBond(bond, g, gid);
}
}
/** load a bond into a graph. A bond looks like this
*
* a6
* a7
* 1
*
*/
private static function loadBond(bond: XML, g: Graph, gid: String): void {
var fromID: String;
var toID: String;
var orderString: String;
try {
// try finding the info without using a namespace
fromID = bond.string[0].toString();
toID = bond.string[1].toString();
orderString = bond.string.(@builtin == "order");
} catch (e: Error) {
// that failed. try again using a namespace.
fromID = bond.cmlns::string[0].toString();
toID = bond.cmlns::string[1].toString();
orderString = bond.cmlns::string[2].toString(); //.(@builtin == "order");
}
// find the 2 atoms, based on their id's
var fromItem: Item = g.find(gid + fromID);
var toItem: Item = g.find(gid + toID);
if((fromItem != null) && (toItem != null)) {
// get the 'order' of the bond. Make sure it's a sensible number.
var order: int = int(orderString.toString());
if(order < 0) order = 0;
if(order > 10) order = 10;
// create the data object that is associated with this edge.
// this object must specify various visual parameters for the line
// that represents the bond. (note: its ok to omit this, in
// which case the edge will be drawn using default settings).
var data: Object = {settings: {alpha: 0.5, color: 0, thickness: (order * 3) - 2}};
// add the bond (a.k.a. link) to the graph
g.link(fromItem, toItem, data);
}
// todo: the bind information sometimes has a 'stereo' value with values like H and W. do something with this.
}
/** pops up the about box */
private function doAbout(): void {
var aboutWindow: IFlexDisplayObject = new springgraph_sample_MoleculeViewer_AboutWindow();
PopUpManager.addPopUp(aboutWindow, this, true);
PopUpManager.centerPopUp(aboutWindow);
}
]]>
accholine
adenosine
adrenalin
aminopval
baclofen
bicuculli
bufotenin
carotine
choline
clozapine
diazepam
dopamine
glutamate
histamine
indoleace
kainate
naloxone
nicotine
riboflavin
serotonin
tyrosine