46
46
import eu .mihosoft .vrl .workflow .VFlowModel ;
47
47
import eu .mihosoft .vrl .workflow .VNode ;
48
48
import eu .mihosoft .vrl .workflow .VisualizationRequest ;
49
+ import eu .mihosoft .vrl .workflow .fx .FlowNodeWindow ;
50
+ import eu .mihosoft .vrl .workflow .fx .FXFlowNodeSkin ;
49
51
import eu .mihosoft .vrl .workflow .fx .FXSkinFactory ;
52
+ import eu .mihosoft .vrl .workflow .fx .InnerCanvas ;
53
+ import eu .mihosoft .vrl .workflow .fx .NodeUtil ;
50
54
import eu .mihosoft .vrl .workflow .fx .OptimizableContentPane ;
51
55
import eu .mihosoft .vrl .workflow .fx .ScalableContentPane ;
52
56
import eu .mihosoft .vrl .workflow .fx .VCanvas ;
69
73
import java .io .IOException ;
70
74
import java .net .URL ;
71
75
import java .nio .file .Paths ;
76
+ import java .text .SimpleDateFormat ;
77
+ import java .util .Calendar ;
78
+ import java .util .Collection ;
72
79
import java .util .Iterator ;
73
80
import java .util .LinkedList ;
81
+ import java .util .List ;
74
82
import java .util .ResourceBundle ;
75
83
import java .util .logging .Level ;
76
84
import java .util .logging .Logger ;
77
85
import javafx .embed .swing .SwingFXUtils ;
86
+ import javafx .scene .Node ;
78
87
import javafx .scene .SnapshotParameters ;
79
88
import javafx .scene .image .WritableImage ;
80
89
import javafx .scene .transform .Translate ;
@@ -189,24 +198,6 @@ public void onSaveAction(ActionEvent e) {
189
198
// <editor-fold defaultstate="collapsed" desc="Menu items">
190
199
@ FXML
191
200
private CheckMenuItem checkDebugLayout ;
192
-
193
- @ FXML
194
- private CheckMenuItem checkNaiveRecursive ;
195
-
196
- @ FXML
197
- private CheckMenuItem checkNaiveAutoscaleNodes ;
198
-
199
- @ FXML
200
- private CheckMenuItem checkNaiveLaunchRemoveCycles ;
201
-
202
- @ FXML
203
- private CheckMenuItem checkCreateLayering ;
204
-
205
- @ FXML
206
- private CheckMenuItem checkCalcVertPos ;
207
-
208
- @ FXML
209
- private CheckMenuItem checkCalcHorPos ;
210
201
// </editor-fold>
211
202
212
203
// <editor-fold desc="Development" defaultstate="collapsed">
@@ -287,6 +278,78 @@ public void onNaiveOptionsAction(ActionEvent e) {
287
278
optionsNaive .set ();
288
279
optionsstageNaive .show ();
289
280
}
281
+
282
+ @ FXML
283
+ public void onLayoutSnapshotAction (ActionEvent e ) {
284
+ String abspath = new File ("." ).getAbsolutePath ();
285
+ String path = abspath .substring (0 , abspath .length ()-1 );
286
+ File dir = new File (path + "snapshots" );
287
+ if (!dir .exists ()) {
288
+ System .out .println ("Creating directory: " + dir .getAbsolutePath ());
289
+ dir .mkdir ();
290
+ }
291
+ path += "snapshots/" ;
292
+ WritableImage wim = new WritableImage ((int ) Math .round (contentPane .getWidth ()), (int ) Math .round (contentPane .getHeight ()));
293
+ SnapshotParameters param = new SnapshotParameters ();
294
+ param .setTransform (new Translate (0 , 200 ));
295
+ Calendar calendar = Calendar .getInstance ();
296
+ SimpleDateFormat format = new SimpleDateFormat ("yyyyMMddHHmmssSSS" );
297
+ String now = format .format (calendar .getTime ());
298
+ try {
299
+ rootPane .snapshot (param , wim );
300
+ dir = new File (path + now + ".png" );
301
+ ImageIO .write (SwingFXUtils .fromFXImage (wim , null ), "png" , dir );
302
+ System .out .println ("snapshot " + now + ".png saved." );
303
+ } catch (IOException ex ) {
304
+ Logger .getLogger (Main .class .getName ()).log (Level .SEVERE , null , ex );
305
+ }
306
+ subSnaps ((InnerCanvas ) canvas .getContent (), path , now );
307
+ }
308
+
309
+ private void subSnaps (InnerCanvas inner , String path , String now ) {
310
+ ObservableList <Node > childnodes = inner .getChildrenUnmodifiable ();
311
+ for (Node n : childnodes ) {
312
+ if ((n instanceof FlowNodeWindow ) && (n .isManaged ())) {
313
+ FlowNodeWindow w = (FlowNodeWindow ) n ;
314
+ List <String > style = NodeUtil .getStylesheetsOfAncestors (w );
315
+ FXFlowNodeSkin wskin = w .nodeSkinProperty ().get ();
316
+ VFlow cont = wskin .getController ();
317
+ Collection <VFlow > subconts = cont .getSubControllers ();
318
+ for (VFlow currsub : subconts ) {
319
+ if (currsub .getModel ().equals (wskin .getModel ())) {
320
+ String title = currsub .getModel ().getId ().replace (':' , '-' );
321
+ if ((currsub .getNodes ().size () > 0 ) && (currsub .isVisible ())) {
322
+ VCanvas subcanvas = new VCanvas ();
323
+ FlowNodeWindow .addResetViewMenu (subcanvas );
324
+ subcanvas .setMinScaleX (0.1 );
325
+ subcanvas .setMinScaleY (0.1 );
326
+ subcanvas .setMaxScaleX (1 );
327
+ subcanvas .setMaxScaleY (1 );
328
+ subcanvas .setTranslateToMinNodePos (true );
329
+
330
+ FXSkinFactory fxSkinFactory = w .nodeSkinProperty ().get ().getSkinFactory ().newInstance (subcanvas .getContent (), null );
331
+ currsub .addSkinFactories (fxSkinFactory );
332
+
333
+ Scene subscene = new Scene (subcanvas , (int ) Math .round (rootPane .getWidth ()), (int ) Math .round (rootPane .getHeight ()));
334
+ subscene .getStylesheets ().setAll (style );
335
+ WritableImage wim = new WritableImage ((int ) Math .round (subscene .getWidth ()), (int ) Math .round (subscene .getHeight ()));
336
+ try {
337
+ subscene .snapshot (wim );
338
+ File dir = new File (path + now + "_" + title + ".png" );
339
+ ImageIO .write (SwingFXUtils .fromFXImage (wim , null ), "png" , dir );
340
+ System .out .println ("snapshot " + now + "_" + title + ".png saved" );
341
+ } catch (IOException ex ) {
342
+ Logger .getLogger (Main .class .getName ()).log (Level .SEVERE , null , ex );
343
+ }
344
+ if (w .getWorkflowContentPane () instanceof InnerCanvas ) {
345
+ subSnaps ((InnerCanvas ) w .getWorkflowContentPane (), path , now );
346
+ }
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
290
353
// </editor-fold>
291
354
292
355
// <editor-fold desc="Test cases" defaultstate="collapsed">
@@ -929,6 +992,8 @@ public void onTestSizes3(ActionEvent e) {
929
992
.getInputs ().get (1 ));
930
993
workflow .connect (nodes .get (3 ).getOutputs ().get (1 ), nodes .get (1 )
931
994
.getInputs ().get (1 ));
995
+ workflow .connect (nodes .get (3 ).getOutputs ().get (1 ), nodes .get (6 )
996
+ .getInputs ().get (1 ));
932
997
workflow .connect (nodes .get (4 ).getOutputs ().get (1 ), nodes .get (5 )
933
998
.getInputs ().get (1 ));
934
999
workflow .connect (nodes .get (5 ).getOutputs ().get (1 ), nodes .get (3 )
@@ -945,6 +1010,8 @@ public void onTestSizes3(ActionEvent e) {
945
1010
.getInputs ().get (1 ));
946
1011
workflow .connect (nodes .get (8 ).getOutputs ().get (1 ), nodes .get (0 )
947
1012
.getInputs ().get (1 ));
1013
+ workflow .connect (nodes .get (9 ).getOutputs ().get (1 ), nodes .get (5 )
1014
+ .getInputs ().get (1 ));
948
1015
nodes .get (0 ).setWidth (nodes .get (0 ).getWidth () * 3 );
949
1016
nodes .get (1 ).setWidth (nodes .get (1 ).getWidth () * 0.5 );
950
1017
nodes .get (2 ).setWidth (nodes .get (2 ).getWidth () * 1.5 );
0 commit comments