var TEST_MODE = 0; if (TEST_MODE == 1) { var root_object_id = 11; var root_object_class = "bizPC"; var root_relation = "neighboors"; var xml_document_url = "http://localhost:81/pages/xml.navigator.php"; var details_url = "http://localhost:81/pages/UI.php?operation=details"; } else { var root_object_id = obj_id; // 11; var root_object_class = obj_class; // "bizPC"; var root_relation = relation; // "neighboors"; var xml_document_url = unescape(xmlUrl); // "http://localhost:81/pages/xml.navigator.php"; var details_url = unescape(drillUrl); // "http://localhost:81/pages/UI.php?operation=details"; } if (pWidth == undefined) { pWidth = 800; } if (pHeight == undefined) { pHeight = 800; } var K = 0; //0.02; // elasticity coeff var Q = 0; // Normally each element may have a specific "charge" var deltaT = 1; // delta time var solidFriction = 10; var radius = 25; if (customRadius != undefined) { radius = customRadius; } if (displayController != 'true') { _level0.Controller._x = -1000; // Make it invisible } var M = 1; // Mass of the object var frictionCoeff = 0.9; // Friction coefficient var bDrawForces = false; var aXPos = new Array; var aYPos = new Array; var aClips = new Array; var aLinks = new Array; var aWeights = new Array; var oItemsContextMenu = new ContextMenu(); oItemsContextMenu.hideBuiltInItems(); var menuItem = new ContextMenuItem ("Details...", DisplayObjectDetails); var menuItem2 = new ContextMenuItem ("Expand", Expand); var menuItem3 = new ContextMenuItem ("Drill down", DrillDown); function DisplayObjectDetails(oSelectedObject) { // Called by the context menu var fullUrl:String = details_url; if (fullUrl.indexOf("?",0) > 0) { fullUrl = fullUrl+"&class="+oSelectedObject.obj_class+"&id="+oSelectedObject.id; } else { fullUrl = fullUrl+"?class="+oSelectedObject.obj_class+"&id="+oSelectedObject.id; } getURL(fullUrl, "_top"); } function DrillDown(oSelectedObject) { DoReload(oSelectedObject.id, oSelectedObject.obj_class, root_relation); } function Expand(oSelectedObject) { DoLoad(oSelectedObject.id, oSelectedObject.obj_class, root_relation); } oItemsContextMenu.customItems.push(menuItem, menuItem2, menuItem3); function DrawLinks() { oLinksMovie = _root.links; oLinksMovie.clear(); oLinksMovie.lineStyle (5, 0xcccccc, 100); for(i=0; i 1) // if less than 1 pixel, don't draw it { // Draw the arrow: main line oForcesMovie.lineTo(aClips[i]._x + Fx, aClips[i]._y + Fy); // Head of the arrow oForcesMovie.lineTo(aClips[i]._x + Fx + 5*(Fy-Fx)/strengh, aClips[i]._y + Fy - 5*(Fx+Fy)/strengh); oForcesMovie.moveTo(aClips[i]._x + Fx, aClips[i]._y + Fy); // Head of the arrow oForcesMovie.lineTo(aClips[i]._x + Fx - 5*(Fx+Fy)/strengh, aClips[i]._y + Fy - 5*(Fy-Fx)/strengh); } } } } function DrawItems() { aForces = ComputeForces(); DrawLinks(true); DrawForces(aForces); } function DoStartDrag() { this.bInDrag = true; if (this.iTimeout != 0) { clearTimeout(this.iTimeout); this.iTimeout = 0; } this.startDrag() } function DoReleaseDrag() { this.stopDrag(); this.bInDrag = false; if (this.lastclick - (this.lastclick=getTimer()) + 250 > 0) { //do doubleclick action trace("double"); DoReload(this.id, this.obj_class); } else { //do singleclick action trace("single"); } } function DoRollOver() { trace("Roll Over: "+this.name); var iTimeOut:Number; iTimeout = setTimeout(ShowTooltip, 500, this); this.iTimeout = iTimeout; } function DoRollOut() { trace("Roll Out"); if (this.iTimeout != 0) { clearTimeout(this.iTimeout); this.iTimeout = 0; } HideTooltip(); } function UpdatePositions() { var MIN_MOVE_LIMIT = 0.3; // Whatever moves of less than 0.3 px per cycle, remains frozen to spare some CPU for(var i=0; i MIN_MOVE_LIMIT) || (Math.abs(aClips[i].Vy * deltaT) > MIN_MOVE_LIMIT) ) { aClips[i]._x += aClips[i].Vx * deltaT; aClips[i]._y += aClips[i].Vy * deltaT; } } } } function CreateItem(id, obj_class, icon, name, x, y, parentId, oNodeDetails) { trace("CreateItem(id:"+id+" , parentId:"+parentId+")"); var i = aClips.length; // Add new elements at the end of the array var sMovieName; switch (icon) { case "application": sMovieName = "Item_application"; break; case "business_process": sMovieName = "Item_business_process"; break; case "chemicals": sMovieName = "Item_chemicals"; break; case "contact": sMovieName = "Item_contact"; break; case "contract": sMovieName = "Item_contract"; break; case "change": sMovieName = "Item_change"; break; case "database": sMovieName = "Item_database"; break; case "db_instance": sMovieName = "Item_db_instance"; break; case "desktop": sMovieName = "Item_dekstop"; break; case "incident": sMovieName = "Item_incident"; break; case "interface": sMovieName = "Item_interface"; break; case "laptop": sMovieName = "Item_laptop"; break; case "network_device": sMovieName = "Item_nw_device"; break; case "printer": sMovieName = "Item_printer"; break; case "server": sMovieName = "Item_server"; break; case "wireless_device": sMovieName = "Item_wireless_device"; break; default: sMovieName = "Item"; } aClips[i]= _root.links.attachMovie(sMovieName, "r"+i, i+10); aClips[i]._x= x; aClips[i]._y= y; aClips[i].parentId = parentId; aClips[i].details = oNodeDetails; aClips[i]._xscale = radius; aClips[i]._yscale = radius; aClips[i].onPress = DoStartDrag; aClips[i].onRelease = DoReleaseDrag; aClips[i].onRollOver = DoRollOver; aClips[i].onRollOut = DoRollOut; aClips[i].Vx = 0; // No inital speed aClips[i].Vy = 0; // No inital speed aClips[i].bInDrag = false; aClips[i].id = id; aClips[i].icon = icon; aClips[i].name = name; aClips[i].obj_class = obj_class; aClips[i].menu = oItemsContextMenu; aWeights[i] = 1; trace("Element added: index="+i+", id="+id+", obj_class="+id+", obj_class="+name+", icon="+icon+newline+"details: "+aClips[i].details.values); return i; } function GetParentAngle(oClip:MovieClip) { var angle:Number = 0; trace("GetParentAngle oClip.parentId: "+oClip.parentId); if (oClip.parentId != undefined) { oParentClip = aClips[oClip.parentId]; dx = oClip._x - oParentClip._x; dy = oClip._y - oParentClip._y; trace("GetParentAngle dx: "+dx+", dy:"+dy); if ((dx == 0) && (dy == 0)) { angle = 0; } else { angle = Math.atan2(dy, dx); } } trace("GetParentAngle returned: "+((angle*360)/(2*Math.PI))); return angle; } function FindItemByIdAndClass(id, obj_class) { var result = -1; var i = 0; while ( (i < aClips.length) && (result == -1)) { if ((aClips[i].id == id) && (aClips[i].obj_class == obj_class)) { result = i; } i++; } return result; } function AddLink(sourceIndex, destinationIndex, bArrow) { trace("Adding link between srcIndex:"+sourceIndex+" and destIndex:"+destinationIndex+" (arrow:"+bArrow+" )"); aLinks[aLinks.length] = { start: sourceIndex, end: destinationIndex, bArrow: bArrow }; } oLinksMovie = _root.createEmptyMovieClip ("links", -1); oForcesMovie = _root.createEmptyMovieClip ("forces", 9999); oLinksMovie.onEnterFrame = DrawItems; oForcesMovie.onEnterFrame = DrawForces; //////////////////////////////////////////////////////////////////////////// // Experimenting with the load of an XML file //////////////////////////////////////////////////////////////////////////// // Create a new XML object. var myLoader:XML = new XML(); // Set the ignoreWhite property to true (default value is false). myLoader.ignoreWhite = true; // After loading is complete, trace the XML object. myLoader.onLoad = function(success) { DumpClips("Beginning of (asynchronous) load"); if (success) { myXML = new XML(); myXML.parseXML(myLoader); oRootNode = myXML.firstChild; trace("root node: "+oRootNode.nodeName); if (oRootNode.attributes.title != undefined) { StaticContainer.Schema_title = oRootNode.attributes.title; } else { StaticContainer.Schema_title = ""; } oFirstNode = oRootNode.firstChild; oStartPoint = {x:0, y:0}; var placement = ""; switch (oRootNode.attributes.position) { case "top": oStartPoint.x = pWidth/2; oStartPoint.y = 2*radius; break; case "left": oStartPoint.x = 2*radius; oStartPoint.y = pHeight/2; break; case "center": default: oStartPoint.x = pWidth /2; oStartPoint.y = pHeight /2; placement = "surround"; } LoadNode(oFirstNode, undefined, oStartPoint.x, oStartPoint.y, placement); } else { trace("Failed to load XML data:"+newline+myLoader); } _level0.LoadingAnimation._alpha = 0; _level0.LoadingAnimation.stop(); DumpClips("End of (asynchronous) load"); } function LoadNode(oXmlNode:Object, parentIndex:Number, x:Number, y:Number, placementMethod:String) { trace("Loading Node: "+oXmlNode); var nodeId = oXmlNode.attributes.id; var nodeClass = oXmlNode.attributes.obj_class; var nodeName = oXmlNode.attributes.name; var nodeIcon = oXmlNode.attributes.icon; var nodeIndex = FindItemByIdAndClass(nodeId, nodeClass); var nodeZlist = oXmlNode.attributes.zlist; var aNodeZlist = nodeZlist.split(','); var oNodeDetails = { names: new Array(), values: new Array() }; for(var att_index=0; att_index