@@ -7,16 +7,14 @@ import {
7
7
select as d3select ,
8
8
scaleOrdinal as d3scaleOrdinal ,
9
9
schemeTableau10 as d3schemeTableau10 ,
10
- ContainerElement ,
11
10
} from 'd3' ;
11
+ import { log } from '../../logger.js' ;
12
12
13
13
import { BlockDB } from './blockDB.js' ;
14
14
import type { Block } from './blockTypes.js' ;
15
15
16
16
// import { diagram as BlockDiagram } from './blockDiagram.js';
17
17
import { configureSvgSize } from '../../setupGraphViewbox.js' ;
18
- import { Uid } from '../../rendering-util/uid.js' ;
19
- import { pad } from 'lodash' ;
20
18
21
19
export const draw = async function (
22
20
text : string ,
@@ -43,27 +41,28 @@ export const draw = async function (
43
41
const nodes = svg . insert ( 'g' ) . attr ( 'class' , 'block' ) ;
44
42
await calculateBlockSizes ( nodes , bl , db ) ;
45
43
const bounds = layout ( db ) ;
46
- console . log ( 'Here blocks' , bl ) ;
44
+ log . debug ( 'Here blocks' , bl ) ;
47
45
await insertBlocks ( nodes , bl , db ) ;
48
46
49
- // console. log('Here', bl);
47
+ // log.debug ('Here', bl);
50
48
51
49
// Establish svg dimensions and get width and height
52
50
//
53
51
// const bounds2 = nodes.node().getBoundingClientRect();
54
- const bounds2 = bounds ;
55
- const padding = 10 ;
56
52
// Why, oh why ????
57
- const magicFactor = Math . max ( 1 , Math . round ( 0.125 * ( bounds2 . width / bounds2 . height ) ) ) ;
58
- const height = bounds2 . height + magicFactor + 10 ;
59
- const width = bounds2 . width + 10 ;
60
- const useMaxWidth = false ;
61
- configureSvgSize ( svg , height , width , useMaxWidth ) ;
62
- console . log ( 'Here Bounds' , bounds , bounds2 ) ;
63
- svg . attr (
64
- 'viewBox' ,
65
- `${ bounds2 . x - 5 } ${ bounds2 . y - 5 } ${ bounds2 . width + 10 } ${ bounds2 . height + 10 } `
66
- ) ;
53
+ if ( bounds ) {
54
+ const bounds2 = bounds ;
55
+ const magicFactor = Math . max ( 1 , Math . round ( 0.125 * ( bounds2 . width / bounds2 . height ) ) ) ;
56
+ const height = bounds2 . height + magicFactor + 10 ;
57
+ const width = bounds2 . width + 10 ;
58
+ const useMaxWidth = false ;
59
+ configureSvgSize ( svg , height , width , useMaxWidth ) ;
60
+ log . debug ( 'Here Bounds' , bounds , bounds2 ) ;
61
+ svg . attr (
62
+ 'viewBox' ,
63
+ `${ bounds2 . x - 5 } ${ bounds2 . y - 5 } ${ bounds2 . width + 10 } ${ bounds2 . height + 10 } `
64
+ ) ;
65
+ }
67
66
// svg.attr('viewBox', `${-200} ${-200} ${400} ${400}`);
68
67
69
68
// Prepare data for construction based on diagObj.db
@@ -83,92 +82,6 @@ export const draw = async function (
83
82
y ?: number ;
84
83
}
85
84
86
- const blocks : LayedBlock [ ] = [
87
- {
88
- ID : 'ApplicationLayer' ,
89
- label : 'Application Layer' ,
90
- x : 0 ,
91
- y : 0 ,
92
- children : [
93
- {
94
- ID : 'UserInterface' ,
95
- label : 'User Interface (WPF, HTML5/CSS3, Swing)' ,
96
- x : 0 ,
97
- y : 50 ,
98
- } ,
99
- ] ,
100
- } ,
101
- {
102
- ID : 'PresentationLayer' ,
103
- label : 'Presentation Layer' ,
104
- x : 0 ,
105
- y : 50 ,
106
- children : [
107
- {
108
- ID : 'Smack' ,
109
- label : 'J2SE Mobil App (Smack)' ,
110
- } ,
111
- {
112
- ID : 'JsJAC' ,
113
- label : 'Java Script Browser App (JsJAC)' ,
114
- } ,
115
- {
116
- ID : 'babelim' ,
117
- label : '.NET Windows App (Babel-im)' ,
118
- } ,
119
- ] ,
120
- } ,
121
- {
122
- ID : 'SessionLayer' ,
123
- label : 'Session Layer' ,
124
- x : 0 ,
125
- y : 100 ,
126
- children : [
127
- {
128
- ID : 'XMPP' ,
129
- label : 'XMPP Component' ,
130
- } ,
131
- {
132
- children : [
133
- {
134
- ID : 'Authentication' ,
135
- label : 'Authentication' ,
136
- } ,
137
- {
138
- ID : 'Authorization' ,
139
- label : 'Authorization' ,
140
- } ,
141
- ] ,
142
- } ,
143
- {
144
- ID : 'LDAP' ,
145
- label : 'LDAP, DB, POP' ,
146
- } ,
147
- ] ,
148
- } ,
149
- {
150
- ID : 'NetworkLayer' ,
151
- label : 'Network Layer' ,
152
- x : 0 ,
153
- y : 150 ,
154
- children : [
155
- { ID : 'HTTP' , label : 'HTTP' } ,
156
- { ID : 'SOCK' , label : 'SOCK' } ,
157
- ] ,
158
- } ,
159
- {
160
- ID : 'DataLayer' ,
161
- label : 'Data Layer' ,
162
- x : 0 ,
163
- y : 200 ,
164
- children : [
165
- { ID : 'XMPP' , label : 'XMPP' } ,
166
- { ID : 'BDB' , label : 'Business DB' } ,
167
- { ID : 'AD' , label : 'Active Directory' } ,
168
- ] ,
169
- } ,
170
- ] ;
171
-
172
85
// Get color scheme for the graph
173
86
const colorScheme = d3scaleOrdinal ( d3schemeTableau10 ) ;
174
87
} ;
0 commit comments