@@ -30,8 +30,8 @@ public class GraphvizAutomaticLayout {
30
30
private final File path ;
31
31
32
32
private RankDirection rankDirection = RankDirection .TopBottom ;
33
- private double rankSeparation = 1.0 ;
34
- private double nodeSeparation = 1.0 ;
33
+ private double rankSeparation = 300 ;
34
+ private double nodeSeparation = 300 ;
35
35
36
36
private int margin = 400 ;
37
37
private boolean changePaperSize = true ;
@@ -75,8 +75,21 @@ public void setLocale(Locale locale) {
75
75
this .locale = locale ;
76
76
}
77
77
78
- private DOTExporter createDOTExporter () {
79
- DOTExporter exporter = new DOTExporter (rankDirection , rankSeparation , nodeSeparation );
78
+ private DOTExporter createDOTExporter (AutomaticLayout automaticLayout ) {
79
+ DOTExporter exporter ;
80
+
81
+ if (automaticLayout == null ) {
82
+ // use the configured defaults
83
+ exporter = new DOTExporter (rankDirection , rankSeparation , nodeSeparation );
84
+ } else {
85
+ // use the values from the automatic layout configuration associated with the view
86
+ exporter = new DOTExporter (
87
+ RankDirection .valueOf (automaticLayout .getRankDirection ().name ()),
88
+ automaticLayout .getRankSeparation (),
89
+ automaticLayout .getNodeSeparation ()
90
+ );
91
+ }
92
+
80
93
exporter .setLocale (locale );
81
94
82
95
return exporter ;
@@ -130,87 +143,101 @@ private void runGraphviz(View view) throws Exception {
130
143
131
144
public void apply (CustomView view ) throws Exception {
132
145
log .debug ("Running Graphviz for view with key " + view .getKey ());
133
- Diagram diagram = createDOTExporter ().export (view );
146
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
134
147
writeFile (diagram );
135
148
runGraphviz (view );
136
149
createSVGReader ().parseAndApplyLayout (view );
137
150
}
138
151
139
152
public void apply (SystemLandscapeView view ) throws Exception {
140
153
log .debug ("Running Graphviz for view with key " + view .getKey ());
141
- Diagram diagram = createDOTExporter ().export (view );
154
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
142
155
writeFile (diagram );
143
156
runGraphviz (view );
144
157
createSVGReader ().parseAndApplyLayout (view );
145
158
}
146
159
147
160
public void apply (SystemContextView view ) throws Exception {
148
161
log .debug ("Running Graphviz for view with key " + view .getKey ());
149
- Diagram diagram = createDOTExporter ().export (view );
162
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
150
163
writeFile (diagram );
151
164
runGraphviz (view );
152
165
createSVGReader ().parseAndApplyLayout (view );
153
166
}
154
167
155
168
public void apply (ContainerView view ) throws Exception {
156
169
log .debug ("Running Graphviz for view with key " + view .getKey ());
157
- Diagram diagram = createDOTExporter ().export (view );
170
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
158
171
writeFile (diagram );
159
172
runGraphviz (view );
160
173
createSVGReader ().parseAndApplyLayout (view );
161
174
}
162
175
163
176
public void apply (ComponentView view ) throws Exception {
164
177
log .debug ("Running Graphviz for view with key " + view .getKey ());
165
- Diagram diagram = createDOTExporter ().export (view );
178
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
166
179
writeFile (diagram );
167
180
runGraphviz (view );
168
181
createSVGReader ().parseAndApplyLayout (view );
169
182
}
170
183
171
184
public void apply (DynamicView view ) throws Exception {
172
185
log .debug ("Running Graphviz for view with key " + view .getKey ());
173
- Diagram diagram = createDOTExporter ().export (view );
186
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
174
187
writeFile (diagram );
175
188
runGraphviz (view );
176
189
createSVGReader ().parseAndApplyLayout (view );
177
190
}
178
191
179
192
public void apply (DeploymentView view ) throws Exception {
180
193
log .debug ("Running Graphviz for view with key " + view .getKey ());
181
- Diagram diagram = createDOTExporter ().export (view );
194
+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
182
195
writeFile (diagram );
183
196
runGraphviz (view );
184
197
createSVGReader ().parseAndApplyLayout (view );
185
198
}
186
199
187
200
public void apply (Workspace workspace ) throws Exception {
188
201
for (CustomView view : workspace .getViews ().getCustomViews ()) {
189
- apply (view );
202
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
203
+ apply (view );
204
+ }
190
205
}
191
206
192
207
for (SystemLandscapeView view : workspace .getViews ().getSystemLandscapeViews ()) {
193
- apply (view );
208
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
209
+ apply (view );
210
+ }
194
211
}
195
212
196
213
for (SystemContextView view : workspace .getViews ().getSystemContextViews ()) {
197
- apply (view );
214
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
215
+ apply (view );
216
+ }
198
217
}
199
218
200
219
for (ContainerView view : workspace .getViews ().getContainerViews ()) {
201
- apply (view );
220
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
221
+ apply (view );
222
+ }
202
223
}
203
224
204
225
for (ComponentView view : workspace .getViews ().getComponentViews ()) {
205
- apply (view );
226
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
227
+ apply (view );
228
+ }
206
229
}
207
230
208
231
for (DynamicView view : workspace .getViews ().getDynamicViews ()) {
209
- apply (view );
232
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
233
+ apply (view );
234
+ }
210
235
}
211
236
212
237
for (DeploymentView view : workspace .getViews ().getDeploymentViews ()) {
213
- apply (view );
238
+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
239
+ apply (view );
240
+ }
214
241
}
215
242
}
216
243
0 commit comments