123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- /****************************************************************************************************************************
- Licensed Materials - Property of IBM
- BI and PM: QFW
- © Copyright IBM Corp. 2005, 2010
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *****************************************************************************************************************************/
- function LogTreeNode( id, parentNode, nestedParentNode, tree, content, width, height, boxColor, title )
- {
- this.id = id;
- this.parentNode = parentNode;
- this.tree = tree;
- this.content = content;
- this.visible = true;
-
- if( title )
- this.title = title;
- if( width != null )
- this.width = width;
- else
- this.width = (tree.config.nodeWidth)? tree.config.nodeWidth: 0;
- if( height != null )
- this.height = height;
- else
- this.height = (tree.config.nodeHeight)? tree.config.nodeHeight: 0;
- this.X = 0;
- this.Y = 0;
-
- this.groupHeight = 0;
- this.groupWidth = 0;
- this.groupX = 0;
- this.groupY = 0;
-
- this.boxColor = boxColor;
- this.connectorElems = [];
- this.childNodes = [];
- this.connectorNestedElems = [];
- this.nestedChildNodes = [];
- this.createContent();
-
- if( id >= 0 )
- {
- this.tree.config.tempTreeContainer.appendChild( this.contentNode );
- if( this.contentNode.offsetWidth > this.width - 10 )
- {
- this.width = this.contentNode.offsetWidth + 10;
- }
- this.contentHeight = this.contentNode.offsetHeight;
- this.tree.config.tempTreeContainer.removeChild( this.contentNode );
- this.tree.config.tempTreeContainer.innerHTML = "";
- }
- }
- LogTreeNode.prototype.updateLocation_nestedInside = function updateLocation_nestedInside()
- {
- if( this.nestedChildNodes.length == 0 )
- return;
- var nestedChildGroupY = this.Y + this.contentHeight;
-
- for( var i = 0; i < this.nestedChildNodes.length; ++i )
- {
- if( i == 0 )
- nestedChildGroupY += this.tree.config.nestedChildGroupYMarginTop;
- else
- nestedChildGroupY += this.tree.config.siblingMargin;
- var child = this.nestedChildNodes[i];
- child.updateLocation( this.X + this.tree.config.nestedChildGroupXMargin, nestedChildGroupY );
- nestedChildGroupY += child.groupHeight;
- if( this.width < 2 * this.tree.config.nestedChildGroupXMargin + child.groupWidth )
- this.width = 2 * this.tree.config.nestedChildGroupXMargin + child.groupWidth;
- }
-
- this.height = nestedChildGroupY + this.tree.config.nestedChildGroupYMarginBottom - this.Y;
- }
- LogTreeNode.prototype.updateLocation_children = function updateLocation_children( childGroupX, childGroupY )
- {
- var i = 0;
- this.groupWidth = this.width;
-
- for( ; i < this.childNodes.length; ++i )
- {
- if( i > 0 )
- childGroupY += this.tree.config.siblingMargin;
- var child = this.childNodes[i];
- child.updateLocation( childGroupX, childGroupY );
- childGroupY += child.groupHeight;
- if( this.groupWidth < this.width + this.tree.config.levelMargin + child.groupWidth )
- this.groupWidth = this.width + this.tree.config.levelMargin + child.groupWidth;
- }
-
- return childGroupY;
- }
- LogTreeNode.prototype.updateLocation = function updateLocation( groupX, groupY )
- {
- this.groupX = this.X = groupX;
- this.groupY = groupY;
- if( this.tree.config.bNestedInside )
- this.updateLocation_nestedInside();
-
- var childGroupX = this.X + this.width + this.tree.config.levelMargin;
-
- this.groupWidth = this.width;
-
- var childGroupYBottom = this.updateLocation_children( childGroupX, groupY );
- this.groupHeight = childGroupYBottom - groupY;
-
- if( this.groupHeight < this.height )
- {
- this.updateLocation_children( childGroupX, groupY + this.height/2 - this.groupHeight/2 );
- this.groupHeight = this.height;
- this.Y = groupY;
- }
- else
- if( this.childNodes.length == 1 && this.tree.config.bNestedUnder )
- this.Y = this.childNodes[0].Y;
- else
- this.Y = this.groupHeight / 2 - this.height / 2 + this.groupY;
- if( this.tree.config.bNestedUnder )
- this.updateLocaltion_nestedUnder();
- }
- LogTreeNode.prototype.updateLocation_nestedUnder = function updateLocation_nestedUnder()
- {
- var nestedChildGroupX = this.X;
- for( var i = 0; i < this.nestedChildNodes.length; ++i )
- {
- if( i == 0 )
- this.groupHeight += this.tree.config.nestedChildGroupYMarginTop;
- else
- this.groupHeight += this.tree.config.siblingMargin;
- var child = this.nestedChildNodes[i];
- child.updateLocation( nestedChildGroupX, this.groupHeight + this.groupY );
- this.groupHeight += child.groupHeight;
- if( this.groupWidth < nestedChildGroupX + child.groupWidth )
- this.groupWidth = nestedChildGroupX + child.groupWidth;
- }
- }
- LogTreeNode.prototype.createContent = function createContent()
- {
- this.contentNode = document.createElement( "div" );
- if( this.title )
- {
- var title = document.createElement( "b" );
- title.innerHTML = this.title;
- this.contentNode.appendChild( title );
- }
- var info = document.createElement( "div" );
- //info.style.marginLeft = 10;
- info.innerHTML = this.content;
- this.contentNode.appendChild( info );
- }
- LogTreeNode.prototype.createElement = function createElement()
- {
- if( this.id < 0 )
- return null;
- var v_dArcsize = 0.20;
- if( this.tree.config.bNestedInside && this.nestedChildNodes.length > 0 )
- v_dArcsize = 0.05;
- this.tree.tempDiv.innerHTML = "<v:roundrect arcsize=\"" + v_dArcsize + "\" />";
- this.elem = this.tree.tempDiv.firstChild;
- this.tree.container.appendChild( this.elem );
- this.elem.id = this.id;
- this.elem.style.position = "absolute";
- this.elem.style.top = this.Y;
- this.elem.style.left = this.X;
- this.elem.style.height = this.height;
- this.elem.style.width = this.width;
- this.elem.style.paddingTop = 3;
- this.elem.style.paddingBottom = 3;
- this.elem.style.paddingLeft = 3;
- this.elem.style.paddingRight = 3;
-
- if( this.boxColor )
- {
- //if( !(this.tree.config.bNestedInside && this.nestedChildNodes.length > 0) )
- this.elem.fillColor = this.boxColor;
- }
- this.elem.appendChild( this.contentNode );
- return this.elem;
- }
- var plID = 0;
- var arrAngle = 0.25;
- var arrLength = 7;
- LogTreeNode.prototype.createConnector = function createConnector( toChildOrdinal )
- {
- var childNode = this.childNodes[ toChildOrdinal ];
- var connectorElem = document.createElement( "v:polyline" );
- this.tree.container.appendChild( connectorElem );
-
-
- //defines points and draws line and arrowhead
- var A = (this.X + this.width) + "," + (this.Y + this.height/2);
- var B = (3*this.X + 3*this.width + childNode.X)/4 + "," + (this.Y + .45*this.height );
- var C = (3*this.X + 3*this.width + childNode.X)/4 + "," + (this.Y + .55*this.height );
- var D = childNode.X + "," + (childNode.Y + childNode.height/2);
-
- var angle = Math.atan( ( (childNode.Y + childNode.height/2) -
- (this.Y + this.height/2) ) /
- ( childNode.X - (this.X + this.width) ) );
-
- var B1 = (this.X + this.width + arrLength * Math.cos(angle+arrAngle)) + "," +
- (this.Y + this.height/2 + arrLength * Math.sin(angle+arrAngle));
- var C1 = (this.X + this.width + arrLength * Math.cos(angle-arrAngle)) + "," +
- (this.Y + this.height/2 + arrLength * Math.sin(angle-arrAngle));
-
-
- connectorElem.points.value = A +" "+ B1 +" "+ A +" "+ C1 +" "+ A +" "+ D;
-
- this.connectorElems[toChildOrdinal] = connectorElem;
- }
- LogTreeNode.prototype.createNestingConnector = function createConnector( toChildOrdinal )
- {
- if( !this.tree.config.bNestedUnder )
- return;
-
- var childNode = this.nestedChildNodes[ toChildOrdinal ];
- var connectorElem = document.createElement( "v:polyline" );
- this.tree.container.appendChild( connectorElem );
- //defines points and draws line and arrowhead
- var A = (this.X + 10) + "," + (this.Y + this.height);
- var B = (childNode.X + 10) + "," + (childNode.Y);
- var C = (this.X + 14) + "," + (this.Y + this.height);
- var D = (childNode.X + 14) + "," + (childNode.Y);
- connectorElem.points.value = A +" "+ B +" "+ D +" "+ C;
-
- this.connectorNestedElems[toChildOrdinal] = connectorElem;
- }
- LogTreeNode.prototype.createSubtree = function createSubtree()
- {
- this.createElement();
- var i = 0;
- for( ; i < this.childNodes.length; ++i )
- {
- this.childNodes[i].createSubtree();
-
- if( this != this.tree.rootNode )
- this.createConnector( i );
- }
- for( i = 0; i < this.nestedChildNodes.length; ++i )
- {
- this.nestedChildNodes[i].createSubtree();
-
- if( this != this.tree.rootNode )
- this.createNestingConnector( i );
- }
- }
- function LogTree( objectRef, container )
- {
- this.objectRef = objectRef;
- this.container = document.createElement( "v:group" );
- container.appendChild( this.container );
- this.container.style.position = "absolute";
- this.config = new Object();
- this.width = 0;
- this.height = 0;
- this.nodes = new Array();
- this.tempDiv = document.createElement( "DIV" );
-
- this.rootNode = new LogTreeNode( -1, null, null, this, null );
-
- return this;
- }
- LogTree.prototype.UpdateTree = function UpdateTree()
- {
- this.rootNode.updateLocation( 0, 0 );
- this.rootNode.createSubtree();
- this.container.style.width = this.rootNode.groupWidth;
- this.container.style.height = this.rootNode.groupHeight;
- this.container.coordsize = "" + this.rootNode.groupWidth + "," + this.rootNode.groupHeight;
- }
- LogTree.prototype.add = function add( id, parentId, content, width, height, boxColor, title )
- {
- var v_oParentNode;
-
- if( parentId < 0 )
- v_oParentNode = this.rootNode;
- else
- v_oParentNode = this.nodes[parentId];
- var v_oNewNode = new LogTreeNode( id, v_oParentNode, null, this, content, width, height, boxColor, title );
- this.nodes[id] = v_oNewNode;
- v_oParentNode.childNodes.push( v_oNewNode );
- return v_oNewNode;
- }
- LogTree.prototype.addNested = function addNested( id, nestedParentId, content, width, height, boxColor, title )
- {
- if( !nestedParentId || nestedParentId < 0 )
- return this.add( id, -1, content, width, height, boxColor, title );
-
- var v_oParentNode = this.nodes[nestedParentId];
-
- var v_oNewNode = new LogTreeNode( id, null, v_oParentNode, this, content, width, height, boxColor, title );
- this.nodes[id] = v_oNewNode;
- v_oParentNode.nestedChildNodes.push( v_oNewNode );
- return v_oNewNode;
- }
|