41
41
import eu .mihosoft .vrl .workflow .VisualizationRequest ;
42
42
import eu .mihosoft .vrl .workflow .skin .VNodeSkin ;
43
43
44
-
45
44
import javafx .beans .property .IntegerProperty ;
46
45
import javafx .beans .property .ObjectProperty ;
47
46
import javafx .beans .property .SimpleIntegerProperty ;
@@ -143,7 +142,7 @@ protected FlowNodeWindow createNodeWindow() {
143
142
cShape .getNode ().setCache (!flowNodeWindow .isResizing ());
144
143
});
145
144
});
146
-
145
+
147
146
flowNodeWindow .resizingProperty ().addListener ((ov ) -> {
148
147
if (flowNodeWindow .isResizing ()) {
149
148
flowNodeWindow .setCache (false );
@@ -177,7 +176,6 @@ private void init() {
177
176
addConnector (connector );
178
177
}
179
178
180
-
181
179
getModel ().getConnectors ().addListener (
182
180
(ListChangeListener .Change <? extends Connector > change ) -> {
183
181
boolean numConnectorsHasChanged = false ;
@@ -192,7 +190,7 @@ private void init() {
192
190
// // TODO update item
193
191
// }
194
192
// else
195
-
193
+
196
194
if (change .wasRemoved ()) {
197
195
numConnectorsHasChanged = true ;
198
196
// removed
@@ -335,12 +333,37 @@ private void layoutConnector(Connector c, boolean updateOthers) {
335
333
336
334
ConnectorShape connectorShape = connectors .get (c );
337
335
338
- connectorShape .getNode ().setLayoutX (computeConnectorXValue (c ) - connectorShape .getRadius () );
339
- connectorShape .getNode ().setLayoutY (computeConnectorYValue (c ) - connectorShape .getRadius () );
336
+ connectorShape .getNode ().setLayoutX (computeConnectorXValue (c ) - connectorShape .getRadius ());
337
+ connectorShape .getNode ().setLayoutY (computeConnectorYValue (c ) - connectorShape .getRadius ());
340
338
341
339
Collection <Connection > conns = getModel ().getFlow ().
342
340
getConnections (c .getType ()).getAllWith (c );
341
+ //----------------------------B
342
+
343
+ Optional <Boolean > preferTD = c .getVisualizationRequest ().
344
+ get (VisualizationRequest .KEY_CONNECTOR_PREFER_TOP_DOWN );
345
+ boolean preferTopDown = preferTD .orElse (false );
346
+
347
+ if (preferTopDown && conns .isEmpty ()) {
348
+ int oldEdgeIndex = connectorToIndexMap .get (c );
349
+
350
+ int newEdgeIndex = c .isInput () ? TOP : BOTTOM ;
351
+
352
+ connectorShape .getNode ().setLayoutX (computeConnectorXValue (c )- connectorShape .getRadius ());
353
+ connectorShape .getNode ().setLayoutY (computeConnectorYValue (c )- connectorShape .getRadius ());
354
+
355
+ if (newEdgeIndex != oldEdgeIndex ) {
343
356
357
+ shapeLists .get (oldEdgeIndex ).remove (connectorShape );
358
+ shapeLists .get (newEdgeIndex ).add (connectorShape );
359
+ connectorToIndexMap .put (c , newEdgeIndex );
360
+
361
+ // update all other connectors
362
+ layoutConnectors ();
363
+ }
364
+ }
365
+
366
+ //----------------------------E
344
367
if (conns .isEmpty ()) {
345
368
return ;
346
369
}
@@ -410,8 +433,10 @@ private void layoutConnector(Connector c, boolean updateOthers) {
410
433
}
411
434
} // end if switchEdges
412
435
413
- connectorShape .getNode ().setLayoutX (computeConnectorXValue (c ) - connectorShape .getRadius ());
414
- connectorShape .getNode ().setLayoutY (computeConnectorYValue (c ) - connectorShape .getRadius ());
436
+ connectorShape .getNode ().setLayoutX (computeConnectorXValue (c )
437
+ - connectorShape .getRadius ());
438
+ connectorShape .getNode ().setLayoutY (computeConnectorYValue (c )
439
+ - connectorShape .getRadius ());
415
440
416
441
// System.out.println("c: " + c);
417
442
if (updateOthers ) {
@@ -535,15 +560,21 @@ protected void addConnector(final Connector connector) {
535
560
connectorNode .setManaged (false );
536
561
537
562
connectors .put (connector , connectorShape );
538
-
563
+ //--------------------B
564
+ Optional <Boolean > preferTD = connector .getVisualizationRequest ().
565
+ get (VisualizationRequest .KEY_CONNECTOR_PREFER_TOP_DOWN );
566
+ boolean preferTopDown = preferTD .orElse (false );
567
+ int inputDefault = preferTopDown ? TOP : LEFT ;
568
+ int outputDefault = preferTopDown ? BOTTOM : RIGHT ;
569
+ //--------------------E
539
570
if (connector .isInput ()) {
540
571
// inputList.add(connectorNode);
541
- shapeLists .get (LEFT ).add (connectorShape );
542
- connectorToIndexMap .put (connector , LEFT );
572
+ shapeLists .get (inputDefault ).add (connectorShape );
573
+ connectorToIndexMap .put (connector , inputDefault );
543
574
} else if (connector .isOutput ()) {
544
575
// outputList.add(connectorNode);
545
- shapeLists .get (RIGHT ).add (connectorShape );
546
- connectorToIndexMap .put (connector , RIGHT );
576
+ shapeLists .get (outputDefault ).add (connectorShape );
577
+ connectorToIndexMap .put (connector , outputDefault );
547
578
}
548
579
549
580
node .boundsInLocalProperty ().addListener ((ov , oldValue , newValue ) -> {
0 commit comments