1- primitives . common . VerticalConnectorBundle = function ( fromItems , toItems ) {
2- this . fromItems = fromItems ;
3- this . toItems = toItems ;
1+ primitives . common . VerticalConnectorBundle = function ( fromItems , toItems , oppositeFlowItems ) {
2+ this . fromItems = fromItems ;
3+ this . toItems = toItems ;
44
5- this . childConnectorId = { } ;
5+ this . oppositeFlowItems = oppositeFlowItems || [ ] ;
66
7- this . fromOffset = 0 ;
8- this . fromStackSize = 0 ;
7+ this . fromOffset = 0 ;
8+ this . fromStackSize = 0 ;
99} ;
1010
1111primitives . common . VerticalConnectorBundle . prototype = new primitives . common . BaseConnectorBundle ( ) ;
1212
1313primitives . common . VerticalConnectorBundle . prototype . trace = function ( data , params , options ) {
14- var points ,
15- parents , children , items ,
16- treeItem , treeItemId , treeItemPosition , treeItemHighlightPath ,
17- index , len ,
18- isSquared , hasSquared ,
19- parentHorizontalCenter ,
20- parentsConnectorOffset ,
21- childrenConnectorOffset ,
22- connectorPoint ,
23- connectorStep ,
24- chartHasSquaredConnectors = ( options . connectorType === primitives . common . ConnectorType . Squared ) ,
25- paletteItem , polyline ;
26-
27- /* Draw fork for parents */
28- parents = [ ] ;
29- if ( this . fromItems . length > 0 ) {
30- items = this . fromItems ;
31- for ( index = 0 , len = items . length ; index < len ; index += 1 ) {
32- treeItemId = items [ index ] ;
33- treeItemPosition = params . treeItemsPositions [ treeItemId ] ;
34-
35- connectorPoint = new this . ConnectorDestination ( {
36- id : params . nestedLayoutBottomConnectorIds . hasOwnProperty ( treeItemId ) ? params . nestedLayoutBottomConnectorIds [ treeItemId ] : treeItemId ,
37- bundleid : this . getId ( data ) ,
38- x : treeItemPosition . actualPosition . horizontalCenter ( ) ,
39- y : treeItemPosition . actualPosition . bottom ( ) ,
40- isSquared : true ,
41- visibility : treeItemPosition . actualVisibility
42- } ) ;
43- parents . push ( connectorPoint ) ;
44- }
45- parents . sort ( function ( a , b ) { return a . x - b . x ; } ) ;
46-
47- /* Find offset of horizontal connector line between parents */
48- parentsConnectorOffset = treeItemPosition . bottomConnectorShift - treeItemPosition . bottomConnectorInterval * ( this . fromStackSize - this . fromOffset + 1 ) ;
49- }
50-
51- children = [ ] ;
52- if ( this . toItems . length > 0 ) {
53- hasSquared = false ;
54-
55- items = this . toItems ;
56- for ( index = 0 ; index < items . length ; index += 1 ) {
57- treeItemId = items [ index ] ;
58- treeItemPosition = params . treeItemsPositions [ treeItemId ] ;
59-
60- isSquared = true ;
61- if ( params . hasGraphics ) {
62- switch ( treeItemPosition . actualVisibility ) {
63- case primitives . common . Visibility . Dot :
64- case primitives . common . Visibility . Line :
65- isSquared = chartHasSquaredConnectors ;
66- break ;
67- }
68- }
69- connectorStep = 0 ;
70- connectorPoint = new this . ConnectorDestination ( {
71- id : treeItemId ,
72- bundleid : this . getId ( data ) ,
73- x : ( treeItemPosition . actualPosition . horizontalCenter ( ) + connectorStep ) ,
74- y : treeItemPosition . actualPosition . top ( ) ,
75- isSquared : isSquared ,
76- visibility : treeItemPosition . actualVisibility
77- } ) ;
78- children . push ( connectorPoint ) ;
79-
80- /* is true if any child point has squared connector */
81- hasSquared = hasSquared || connectorPoint . isSquared ;
82- }
83- children . sort ( function ( a , b ) { return a . x - b . x ; } ) ;
84-
85- /* Find offset of horizontal connector line between children */
86- childrenConnectorOffset = treeItemPosition . topConnectorShift ;
87- }
88-
89- if ( children . length == 1 ) {
90- parentHorizontalCenter = children [ 0 ] . x ;
91- } else if ( parents . length == 1 ) {
92- parentHorizontalCenter = parents [ 0 ] . x ;
93- } else if ( children . length > 0 && parents . length > 0 ) {
94- parentHorizontalCenter = ( parents [ 0 ] . x + parents [ parents . length - 1 ] . x + children [ 0 ] . x + children [ children . length - 1 ] . x ) / 4.0 ;
95- } else if ( children . length > 0 ) {
96- parentHorizontalCenter = ( children [ 0 ] . x + children [ children . length - 1 ] . x ) / 2.0 ;
97- } else {
98- parentHorizontalCenter = ( parents [ 0 ] . x + parents [ parents . length - 1 ] . x ) / 2.0 ;
99- }
100-
101- var topCenterPoint = null ;
102- if ( parents . length > 0 ) {
103- topCenterPoint = new this . ConnectorDestination ( {
104- id : this . getId ( data ) ,
105- x : parentHorizontalCenter ,
106- y : parentsConnectorOffset
107- } ) ;
108- this . traceFork ( data , params , options , topCenterPoint , parents , true , true , this . fromOffset , options . showExtraArrows && ( children . length > 0 ) ) ;
109- }
110-
111- var bottomCenterPoint = null ;
112- if ( children . length > 0 ) {
113- bottomCenterPoint = new this . ConnectorDestination ( {
114- id : this . getId ( data ) ,
115- x : parentHorizontalCenter ,
116- y : childrenConnectorOffset
117- } ) ;
118- if ( topCenterPoint != null && bottomCenterPoint . y == topCenterPoint . y ) {
119- bottomCenterPoint = topCenterPoint ;
120- }
121- this . traceFork ( data , params , options , bottomCenterPoint , children , hasSquared , false , 0 , options . showExtraArrows && ( parents . length > 0 ) ) ;
122- }
123-
124- /* draw connector line between children and parents */
125- if ( topCenterPoint != null && bottomCenterPoint != null && topCenterPoint . id != bottomCenterPoint . id ) {
126- params . transform . transformPoints ( topCenterPoint . x , topCenterPoint . y , bottomCenterPoint . x , bottomCenterPoint . y ,
127- true , this , function ( fromX , fromY , toX , toY ) {
128- var polyline = new primitives . common . Polyline ( ) ;
129- polyline . addSegment ( new primitives . common . MoveSegment ( fromX , fromY ) ) ;
130- polyline . addSegment ( new primitives . common . LineSegment ( toX , toY ) ) ;
131-
132- data . graph . addEdge ( topCenterPoint . id , bottomCenterPoint . id , new this . ConnectorEdge ( topCenterPoint . id , bottomCenterPoint . id , polyline , null , null , null , 0 /* weight */ ) ) ;
133- } ) ;
134- }
14+ var points ,
15+ parents , children , items ,
16+ treeItem , treeItemId , treeItemPosition , treeItemHighlightPath ,
17+ index , len ,
18+ isSquared , hasSquared ,
19+ parentHorizontalCenter ,
20+ parentsConnectorOffset ,
21+ childrenConnectorOffset ,
22+ connectorPoint ,
23+ connectorStep ,
24+ chartHasSquaredConnectors = ( options . connectorType === primitives . common . ConnectorType . Squared ) ,
25+ paletteItem , polyline ;
26+
27+ /* Draw fork for parents */
28+ parents = [ ] ;
29+ if ( this . fromItems . length > 0 ) {
30+ items = this . fromItems ;
31+ for ( index = 0 , len = items . length ; index < len ; index += 1 ) {
32+ treeItemId = items [ index ] ;
33+ treeItemPosition = params . treeItemsPositions [ treeItemId ] ;
34+
35+ connectorPoint = new this . ConnectorDestination ( {
36+ id : params . nestedLayoutBottomConnectorIds . hasOwnProperty ( treeItemId ) ? params . nestedLayoutBottomConnectorIds [ treeItemId ] : treeItemId ,
37+ bundleid : this . getId ( data ) ,
38+ x : treeItemPosition . actualPosition . horizontalCenter ( ) ,
39+ y : treeItemPosition . actualPosition . bottom ( ) ,
40+ isSquared : true ,
41+ visibility : treeItemPosition . actualVisibility
42+ } ) ;
43+ parents . push ( connectorPoint ) ;
44+ }
45+ parents . sort ( function ( a , b ) { return a . x - b . x ; } ) ;
46+
47+ /* Find offset of horizontal connector line between parents */
48+ parentsConnectorOffset = treeItemPosition . bottomConnectorShift - treeItemPosition . bottomConnectorInterval * ( this . fromStackSize - this . fromOffset + 1 ) ;
49+ }
50+
51+ children = [ ] ;
52+ if ( this . toItems . length > 0 ) {
53+ hasSquared = false ;
54+
55+ items = this . toItems ;
56+ for ( index = 0 ; index < items . length ; index += 1 ) {
57+ treeItemId = items [ index ] ;
58+ treeItemPosition = params . treeItemsPositions [ treeItemId ] ;
59+
60+ isSquared = true ;
61+ if ( params . hasGraphics ) {
62+ switch ( treeItemPosition . actualVisibility ) {
63+ case primitives . common . Visibility . Dot :
64+ case primitives . common . Visibility . Line :
65+ isSquared = chartHasSquaredConnectors ;
66+ break ;
67+ }
68+ }
69+ connectorStep = 0 ;
70+ connectorPoint = new this . ConnectorDestination ( {
71+ id : treeItemId ,
72+ bundleid : this . getId ( data ) ,
73+ x : ( treeItemPosition . actualPosition . horizontalCenter ( ) + connectorStep ) ,
74+ y : treeItemPosition . actualPosition . top ( ) ,
75+ isSquared : isSquared ,
76+ visibility : treeItemPosition . actualVisibility
77+ } ) ;
78+ children . push ( connectorPoint ) ;
79+
80+ /* is true if any child point has squared connector */
81+ hasSquared = hasSquared || connectorPoint . isSquared ;
82+ }
83+ children . sort ( function ( a , b ) { return a . x - b . x ; } ) ;
84+
85+ /* Find offset of horizontal connector line between children */
86+ childrenConnectorOffset = treeItemPosition . topConnectorShift ;
87+ }
88+
89+ if ( children . length == 1 ) {
90+ parentHorizontalCenter = children [ 0 ] . x ;
91+ } else if ( parents . length == 1 ) {
92+ parentHorizontalCenter = parents [ 0 ] . x ;
93+ } else if ( children . length > 0 && parents . length > 0 ) {
94+ parentHorizontalCenter = ( parents [ 0 ] . x + parents [ parents . length - 1 ] . x + children [ 0 ] . x + children [ children . length - 1 ] . x ) / 4.0 ;
95+ } else if ( children . length > 0 ) {
96+ parentHorizontalCenter = ( children [ 0 ] . x + children [ children . length - 1 ] . x ) / 2.0 ;
97+ } else {
98+ parentHorizontalCenter = ( parents [ 0 ] . x + parents [ parents . length - 1 ] . x ) / 2.0 ;
99+ }
100+
101+ var topCenterPoint = null ;
102+ if ( parents . length > 0 ) {
103+ topCenterPoint = new this . ConnectorDestination ( {
104+ id : this . getId ( data ) ,
105+ x : parentHorizontalCenter ,
106+ y : parentsConnectorOffset
107+ } ) ;
108+ this . traceFork ( data , params , options , topCenterPoint , parents , true , true , this . fromOffset , options . showExtraArrows && ( children . length > 0 ) ) ;
109+ }
110+
111+ var bottomCenterPoint = null ;
112+ if ( children . length > 0 ) {
113+ bottomCenterPoint = new this . ConnectorDestination ( {
114+ id : this . getId ( data ) ,
115+ x : parentHorizontalCenter ,
116+ y : childrenConnectorOffset
117+ } ) ;
118+ if ( topCenterPoint != null && bottomCenterPoint . y == topCenterPoint . y ) {
119+ bottomCenterPoint = topCenterPoint ;
120+ }
121+ this . traceFork ( data , params , options , bottomCenterPoint , children , hasSquared , false , 0 , options . showExtraArrows && ( parents . length > 0 ) ) ;
122+ }
123+
124+ /* draw connector line between children and parents */
125+ if ( topCenterPoint != null && bottomCenterPoint != null && topCenterPoint . id != bottomCenterPoint . id ) {
126+ params . transform . transformPoints ( topCenterPoint . x , topCenterPoint . y , bottomCenterPoint . x , bottomCenterPoint . y ,
127+ true , this , function ( fromX , fromY , toX , toY ) {
128+ var polyline = new primitives . common . Polyline ( ) ;
129+ polyline . addSegment ( new primitives . common . MoveSegment ( fromX , fromY ) ) ;
130+ polyline . addSegment ( new primitives . common . LineSegment ( toX , toY ) ) ;
131+
132+ data . graph . addEdge ( topCenterPoint . id , bottomCenterPoint . id , new this . ConnectorEdge ( topCenterPoint . id , bottomCenterPoint . id , polyline , null , null , null , 0 /* weight */ ) ) ;
133+ } ) ;
134+ }
135135} ;
0 commit comments