@@ -30,8 +30,8 @@ public class GraphvizAutomaticLayout {
3030 private final File path ;
3131
3232 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 ;
3535
3636 private int margin = 400 ;
3737 private boolean changePaperSize = true ;
@@ -75,8 +75,21 @@ public void setLocale(Locale locale) {
7575 this .locale = locale ;
7676 }
7777
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+
8093 exporter .setLocale (locale );
8194
8295 return exporter ;
@@ -130,87 +143,101 @@ private void runGraphviz(View view) throws Exception {
130143
131144 public void apply (CustomView view ) throws Exception {
132145 log .debug ("Running Graphviz for view with key " + view .getKey ());
133- Diagram diagram = createDOTExporter ().export (view );
146+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
134147 writeFile (diagram );
135148 runGraphviz (view );
136149 createSVGReader ().parseAndApplyLayout (view );
137150 }
138151
139152 public void apply (SystemLandscapeView view ) throws Exception {
140153 log .debug ("Running Graphviz for view with key " + view .getKey ());
141- Diagram diagram = createDOTExporter ().export (view );
154+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
142155 writeFile (diagram );
143156 runGraphviz (view );
144157 createSVGReader ().parseAndApplyLayout (view );
145158 }
146159
147160 public void apply (SystemContextView view ) throws Exception {
148161 log .debug ("Running Graphviz for view with key " + view .getKey ());
149- Diagram diagram = createDOTExporter ().export (view );
162+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
150163 writeFile (diagram );
151164 runGraphviz (view );
152165 createSVGReader ().parseAndApplyLayout (view );
153166 }
154167
155168 public void apply (ContainerView view ) throws Exception {
156169 log .debug ("Running Graphviz for view with key " + view .getKey ());
157- Diagram diagram = createDOTExporter ().export (view );
170+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
158171 writeFile (diagram );
159172 runGraphviz (view );
160173 createSVGReader ().parseAndApplyLayout (view );
161174 }
162175
163176 public void apply (ComponentView view ) throws Exception {
164177 log .debug ("Running Graphviz for view with key " + view .getKey ());
165- Diagram diagram = createDOTExporter ().export (view );
178+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
166179 writeFile (diagram );
167180 runGraphviz (view );
168181 createSVGReader ().parseAndApplyLayout (view );
169182 }
170183
171184 public void apply (DynamicView view ) throws Exception {
172185 log .debug ("Running Graphviz for view with key " + view .getKey ());
173- Diagram diagram = createDOTExporter ().export (view );
186+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
174187 writeFile (diagram );
175188 runGraphviz (view );
176189 createSVGReader ().parseAndApplyLayout (view );
177190 }
178191
179192 public void apply (DeploymentView view ) throws Exception {
180193 log .debug ("Running Graphviz for view with key " + view .getKey ());
181- Diagram diagram = createDOTExporter ().export (view );
194+ Diagram diagram = createDOTExporter (view . getAutomaticLayout () ).export (view );
182195 writeFile (diagram );
183196 runGraphviz (view );
184197 createSVGReader ().parseAndApplyLayout (view );
185198 }
186199
187200 public void apply (Workspace workspace ) throws Exception {
188201 for (CustomView view : workspace .getViews ().getCustomViews ()) {
189- apply (view );
202+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
203+ apply (view );
204+ }
190205 }
191206
192207 for (SystemLandscapeView view : workspace .getViews ().getSystemLandscapeViews ()) {
193- apply (view );
208+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
209+ apply (view );
210+ }
194211 }
195212
196213 for (SystemContextView view : workspace .getViews ().getSystemContextViews ()) {
197- apply (view );
214+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
215+ apply (view );
216+ }
198217 }
199218
200219 for (ContainerView view : workspace .getViews ().getContainerViews ()) {
201- apply (view );
220+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
221+ apply (view );
222+ }
202223 }
203224
204225 for (ComponentView view : workspace .getViews ().getComponentViews ()) {
205- apply (view );
226+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
227+ apply (view );
228+ }
206229 }
207230
208231 for (DynamicView view : workspace .getViews ().getDynamicViews ()) {
209- apply (view );
232+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
233+ apply (view );
234+ }
210235 }
211236
212237 for (DeploymentView view : workspace .getViews ().getDeploymentViews ()) {
213- apply (view );
238+ if (view .getAutomaticLayout () != null && view .getAutomaticLayout ().getImplementation () == AutomaticLayout .Implementation .Graphviz ) {
239+ apply (view );
240+ }
214241 }
215242 }
216243
0 commit comments