2929
3030import javafx .geometry .Insets ;
3131import javafx .scene .Parent ;
32- import javafx .scene .Group ;
3332import javafx .scene .control .ScrollPane ;
3433import javafx .scene .control .ScrollPane .ScrollBarPolicy ;
3534import javafx .scene .layout .Background ;
@@ -61,23 +60,23 @@ public class EmbeddedDisplayRepresentation extends RegionBaseRepresentation<Pane
6160 private static final Background TRANSPARENT_BACKGROUND = new Background (new BackgroundFill (Color .TRANSPARENT , CornerRadii .EMPTY , Insets .EMPTY ));
6261 private static final Background EDIT_TRANSPARENT_BACKGROUND = new Background (new BackgroundFill (
6362 new LinearGradient (
64- 0 , 0 , 10 , 10 , false , CycleMethod .REPEAT ,
65- new Stop (0.0 , new Color (0.53 , 0.52 , 0.51 , 0.15 )),
66- new Stop (0.5 , new Color (0.53 , 0.52 , 0.51 , 0.15 )),
67- new Stop (0.5 , Color .TRANSPARENT ),
68- new Stop (1.0 , Color .TRANSPARENT )
63+ 0 , 0 , 10 , 10 , false , CycleMethod .REPEAT ,
64+ new Stop (0.0 , new Color (0.53 , 0.52 , 0.51 , 0.15 )),
65+ new Stop (0.5 , new Color (0.53 , 0.52 , 0.51 , 0.15 )),
66+ new Stop (0.5 , Color .TRANSPARENT ),
67+ new Stop (1.0 , Color .TRANSPARENT )
6968 ), CornerRadii .EMPTY , Insets .EMPTY
70- ));
69+ ));
7170
7271 private static final Background EDIT_OVERDRAWN_BACKGROUND = new Background (new BackgroundFill (
7372 new LinearGradient (
74- 10 , 0 , 0 , 10 , false , CycleMethod .REPEAT ,
75- new Stop (0.0 , Color .TRANSPARENT ),
76- new Stop (0.5 , Color .TRANSPARENT ),
77- new Stop (0.5 , new Color (0.93 , 0.1 , 0.1 , 0.45 )),
78- new Stop (1.0 , new Color (0.93 , 0.1 , 0.1 , 0.45 ))
73+ 10 , 0 , 0 , 10 , false , CycleMethod .REPEAT ,
74+ new Stop (0.0 , Color .TRANSPARENT ),
75+ new Stop (0.5 , Color .TRANSPARENT ),
76+ new Stop (0.5 , new Color (0.93 , 0.1 , 0.1 , 0.45 )),
77+ new Stop (1.0 , new Color (0.93 , 0.1 , 0.1 , 0.45 ))
7978 ), CornerRadii .EMPTY , Insets .EMPTY
80- ));
79+ ));
8180
8281 private final DirtyFlag dirty_sizes = new DirtyFlag ();
8382 private final DirtyFlag dirty_background = new DirtyFlag ();
@@ -90,16 +89,12 @@ public class EmbeddedDisplayRepresentation extends RegionBaseRepresentation<Pane
9089 private volatile double zoom_factor_y = 1.0 ;
9190
9291
93- /** Inner pane & group that holds child widgets
94- * We need the group, since the Pane does NOT account for child widget transforms
95- * when computing prefWidth / prefHeight, making embedded displays larger than
96- * they actually are, when containing a tall (interpreted as wide) rotated child widget.
92+ /** Inner pane that holds child widgets
9793 *
9894 * <p>Set to null when representation is disposed,
9995 * which is used as indicator to pending display updates.
10096 */
10197 private volatile Pane inner ;
102- private volatile Group inner_parent ;
10398 private volatile Background inner_background = Background .EMPTY ;
10499
105100 /** Zoom for 'inner' pane */
@@ -108,7 +103,7 @@ public class EmbeddedDisplayRepresentation extends RegionBaseRepresentation<Pane
108103 /** Optional scroll pane between 'jfx_node' Pane and 'inner'.
109104 *
110105 * To allow scrolling, the scene graph is
111- * jfx_node -> scroll -> inner -> inner_parent .
106+ * jfx_node -> scroll -> inner.
112107 *
113108 * If no scrolling is desired, the scrollbars can be hidden via
114109 * scroll.setHbarPolicy(ScrollBarPolicy.NEVER),
@@ -118,7 +113,7 @@ public class EmbeddedDisplayRepresentation extends RegionBaseRepresentation<Pane
118113 *
119114 * The easiest way to remove the scroll bars and any of its impact on
120115 * event handling is to simply remove the scrollpane from the scene graph:
121- * jfx_node-> inner -> inner_parent .
116+ * jfx_node-> inner.
122117 */
123118 private ScrollPane scroll ;
124119
@@ -142,20 +137,12 @@ protected boolean isFilteringEditModeClicks()
142137 @ Override
143138 public Pane createJFXNode () throws Exception
144139 {
145- // rotated child widgets break the prefWidth / prefHeight of a Pane as its own prefWidth / prefHeight uses
146- // the non-transformed dimensions of its children. So the child widget parent must be a Group instead
147- // See https://forums.oracle.com/ords/apexds/post/java-fx-strange-behaviour-when-trying-to-write-a-label-vert-3164
148- // This is easily reproducible, by creating an embedded display with sufficient width and height,
149- // and placing a very tall rotated label inside of it. The resulting embedded display will get a horizontal
150- // scrollbar, as the pane containing it would be wider than it is shown to be.
151- inner_parent = new Group ();
152-
153140 // inner.setScaleX() and setScaleY() zoom from the center
154141 // and not the top-left edge, requiring adjustments to
155142 // inner.setTranslateX() and ..Y() to compensate.
156143 // Using a separate Scale transformation does not have that problem.
157144 // See http://stackoverflow.com/questions/10707880/javafx-scale-and-translate-operation-results-in-anomaly
158- inner = new Pane (inner_parent );
145+ inner = new Pane ();
159146 inner .getTransforms ().add (zoom = new Scale ());
160147
161148 scroll = new NonCachingScrollPane (inner );
@@ -178,7 +165,7 @@ public Pane createJFXNode() throws Exception
178165 @ Override
179166 protected Parent getChildParent (final Parent parent )
180167 {
181- return inner_parent ;
168+ return inner ;
182169 }
183170
184171 @ Override
@@ -256,7 +243,7 @@ else if (resize == Resize.StretchContent)
256243 private void fileChanged (final WidgetProperty <?> property , final Object old_value , final Object new_value )
257244 {
258245 final DisplayAndGroup file_and_group =
259- new DisplayAndGroup (model_widget .propFile ().getValue (), model_widget .propGroupName ().getValue ());
246+ new DisplayAndGroup (model_widget .propFile ().getValue (), model_widget .propGroupName ().getValue ());
260247
261248 // System.out.println("Requested: " + file_and_group);
262249 final DisplayAndGroup skipped = pending_display_and_group .getAndSet (file_and_group );
@@ -356,7 +343,7 @@ private void representContent(final DisplayModel content_model)
356343 zoom .setX (zoom_factor_x );
357344 zoom .setY (zoom_factor_y );
358345
359- toolkit .representModel (inner_parent , content_model );
346+ toolkit .representModel (inner , content_model );
360347 backgroundChanged (null , null , null );
361348 }
362349 catch (final Exception ex )
@@ -439,7 +426,7 @@ public void updateChanges()
439426 else
440427 { // Don't use a scroll pane
441428 scroll .setContent (null );
442- jfx_node .getChildren ().setAll (inner_parent );
429+ jfx_node .getChildren ().setAll (inner );
443430
444431 // During runtime or if the resize property is set to Crop we clip inner
445432 // but allow 'overdrawing' in edit mode so the out-of-region widgets are visible to the user
@@ -463,7 +450,7 @@ else if (inner.getHeight() != 0.0 && inner.getWidth() != 0.0)
463450 rect .setManaged (false );
464451 rect .resizeRelocate (0 , scaled_height , inner .getWidth (), inner .getHeight () - scaled_height );
465452 rect .setBackground (EDIT_OVERDRAWN_BACKGROUND );
466- inner_parent .getChildren ().addAll (rect );
453+ inner .getChildren ().addAll (rect );
467454 }
468455
469456 // Check if wider than allowed
@@ -473,7 +460,7 @@ else if (inner.getHeight() != 0.0 && inner.getWidth() != 0.0)
473460 rect .setManaged (false );
474461 rect .resizeRelocate (scaled_width , 0 , inner .getWidth () - scaled_width , inner .getHeight ());
475462 rect .setBackground (EDIT_OVERDRAWN_BACKGROUND );
476- inner_parent .getChildren ().addAll (rect );
463+ inner .getChildren ().addAll (rect );
477464 }
478465 }
479466 }
0 commit comments