@ -159,6 +159,7 @@ class LayoutEngine {
this . _determineLevelsDirected ( ) ;
this . _determineLevelsDirected ( ) ;
}
}
}
}
// check the distribution of the nodes per level.
// check the distribution of the nodes per level.
let distribution = this . _getDistribution ( ) ;
let distribution = this . _getDistribution ( ) ;
@ -177,7 +178,6 @@ class LayoutEngine {
_placeNodesByHierarchy ( distribution ) {
_placeNodesByHierarchy ( distribution ) {
let nodeId , node ;
let nodeId , node ;
this . positionedNodes = { } ;
this . positionedNodes = { } ;
// start placing all the level 0 nodes first. Then recursively position their branches.
// start placing all the level 0 nodes first. Then recursively position their branches.
for ( let level in distribution ) {
for ( let level in distribution ) {
if ( distribution . hasOwnProperty ( level ) ) {
if ( distribution . hasOwnProperty ( level ) ) {
@ -185,6 +185,7 @@ class LayoutEngine {
if ( distribution [ level ] . nodes . hasOwnProperty ( nodeId ) ) {
if ( distribution [ level ] . nodes . hasOwnProperty ( nodeId ) ) {
node = distribution [ level ] . nodes [ nodeId ] ;
node = distribution [ level ] . nodes [ nodeId ] ;
if ( this . options . hierarchical . direction === "UD" || this . options . hierarchical . direction === "DU" ) {
if ( this . options . hierarchical . direction === "UD" || this . options . hierarchical . direction === "DU" ) {
if ( node . x === undefined ) { node . x = distribution [ level ] . distance ; }
if ( node . x === undefined ) { node . x = distribution [ level ] . distance ; }
distribution [ level ] . distance = node . x + this . nodeSpacing ;
distribution [ level ] . distance = node . x + this . nodeSpacing ;
@ -218,19 +219,20 @@ class LayoutEngine {
for ( nodeId in this . body . nodes ) {
for ( nodeId in this . body . nodes ) {
if ( this . body . nodes . hasOwnProperty ( nodeId ) ) {
if ( this . body . nodes . hasOwnProperty ( nodeId ) ) {
node = this . body . nodes [ nodeId ] ;
node = this . body . nodes [ nodeId ] ;
let level = this . hierarchicalLevels [ nodeId ] === undefined ? 0 : this . hierarchicalLevels [ nodeId ] ;
if ( this . options . hierarchical . direction === "UD" || this . options . hierarchical . direction === "DU" ) {
if ( this . options . hierarchical . direction === "UD" || this . options . hierarchical . direction === "DU" ) {
node . y = this . options . hierarchical . levelSeparation * this . hierarchica lL evels [ nodeId ] ;
node . y = this . options . hierarchical . levelSeparation * level ;
node . options . fixed . y = true ;
node . options . fixed . y = true ;
}
}
else {
else {
node . x = this . options . hierarchical . levelSeparation * this . hierarchica lL evels [ nodeId ] ;
node . x = this . options . hierarchical . levelSeparation * level ;
node . options . fixed . x = true ;
node . options . fixed . x = true ;
}
}
if ( distribution [ this . hierarchica lL evels [ nodeId ] ] === undefined ) {
distribution [ this . hierarchica lL evels [ nodeId ] ] = { amount : 0 , nodes : { } , distance : 0 } ;
if ( distribution [ level ] === undefined ) {
distribution [ level ] = { amount : 0 , nodes : { } , distance : 0 } ;
}
}
distribution [ this . hierarchica lL evels [ nodeId ] ] . amount += 1 ;
distribution [ this . hierarchica lL evels [ nodeId ] ] . nodes [ nodeId ] = node ;
distribution [ level ] . amount += 1 ;
distribution [ level ] . nodes [ nodeId ] = node ;
}
}
}
}
return distribution ;
return distribution ;
@ -398,6 +400,7 @@ class LayoutEngine {
parentNode = edges [ i ] . from ;
parentNode = edges [ i ] . from ;
}
}
let childNodeLevel = this . hierarchicalLevels [ childNode . id ] ;
let childNodeLevel = this . hierarchicalLevels [ childNode . id ] ;
if ( this . positionedNodes [ childNode . id ] === undefined ) {
if ( this . positionedNodes [ childNode . id ] === undefined ) {
// if a node is conneceted to another node on the same level (or higher (means lower level))!, this is not handled here.
// if a node is conneceted to another node on the same level (or higher (means lower level))!, this is not handled here.
if ( childNodeLevel > parentLevel ) {
if ( childNodeLevel > parentLevel ) {