Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method AdjustTrees () id:Method_FormSupplyChainVisualization_AdjustTrees 
 | 
{ 
 | 
  #keys: '[132894.0.984127057]' 
 | 
  Body: 
 | 
  [* 
 | 
    // Adjust trees position, this is the last step of populate Y position 
 | 
    // If downstream tree taller, we adjust upstream tree, vice versa 
 | 
    scvConfig := DataHolderSCVConfiguration.Data(); 
 | 
     
 | 
    root := select( scvConfig, SCVNode, node, 
 | 
                    node.IsRoot() ); 
 | 
     
 | 
    // To adjust the tree Y position, we pre-compute the root node position 
 | 
    // from upstream and downstream, whoever is at the higher position, needs 
 | 
    // to adjust its side lower  
 | 
    this.AdjusNodeYPos( root, true /*isupstream*/ );  
 | 
    upStreamY := root.Y(); 
 | 
    this.AdjusNodeYPos( root, false /*isupstream*/ ); 
 | 
    downStreamY := root.Y(); 
 | 
     
 | 
    offset := upStreamY - downStreamY; 
 | 
    isupstream := false; 
 | 
     
 | 
    // If upStream is higher, move it down 
 | 
    // vice versa 
 | 
    if( offset < 0 ) 
 | 
    { 
 | 
      isupstream := true; 
 | 
    } 
 | 
     
 | 
    // Adjust the whole side of the tree 
 | 
    traverse( scvConfig, SCVNode, node, 
 | 
              node.IsUpstream() = isupstream ) 
 | 
    { 
 | 
      node.Y( node.Y() + abs( offset ) ); 
 | 
    } 
 | 
     
 | 
    root.Y( ifexpr( offset < 0, downStreamY, upStreamY ) ); 
 | 
  *] 
 | 
} 
 |