Skip to content

Commit d3158d3

Browse files
committed
Simplify stage building with assumption Dockable parent will always be a leaf
1 parent 7470205 commit d3158d3

1 file changed

Lines changed: 7 additions & 34 deletions

File tree

core/src/main/java/software/coley/bentofx/building/StageBuilding.java

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import software.coley.bentofx.Bento;
1111
import software.coley.bentofx.control.DragDropStage;
1212
import software.coley.bentofx.dockable.Dockable;
13-
import software.coley.bentofx.layout.DockContainer;
1413
import software.coley.bentofx.layout.container.DockContainerLeaf;
1514
import software.coley.bentofx.layout.container.DockContainerLeafMenuFactory;
1615
import software.coley.bentofx.layout.container.DockContainerRootBranch;
@@ -30,7 +29,7 @@ public StageBuilding(@NonNull Bento bento) {
3029
}
3130

3231
/**
33-
* Create a new stage for the given dockable.,
32+
* Create a new stage for the given dockable.
3433
*
3534
* @param sourceScene
3635
* Original scene to copy state from.
@@ -42,43 +41,17 @@ public StageBuilding(@NonNull Bento bento) {
4241
* @return Newly created stage.
4342
*/
4443
@NonNull
45-
public DragDropStage newStageForDockable(@NonNull Scene sourceScene, @NonNull DockContainer source, @NonNull Dockable dockable) {
44+
public DragDropStage newStageForDockable(@NonNull Scene sourceScene, @NonNull DockContainerLeaf source, @NonNull Dockable dockable) {
4645
Region sourceRegion = source.asRegion();
4746
double width = sourceRegion.getWidth();
4847
double height = sourceRegion.getHeight();
49-
if (source instanceof final DockContainerLeaf leaf) {
50-
final DockContainerLeafMenuFactory leafMenuFactory = leaf.getMenuFactory();
51-
final Side side = leaf.getSide();
52-
return newStageForDockable(sourceScene, dockable, width, height, leafMenuFactory, side);
53-
} else {
54-
return newStageForDockable(sourceScene, dockable, width, height);
55-
}
48+
final DockContainerLeafMenuFactory leafMenuFactory = source.getMenuFactory();
49+
final Side side = source.getSide();
50+
return newStageForDockable(sourceScene, dockable, width, height, leafMenuFactory, side);
5651
}
5752

5853
/**
59-
* Create a new stage for the given dockable.,
60-
*
61-
* @param sourceScene
62-
* Original scene to copy state from.
63-
* @param dockable
64-
* Dockable to place into the newly created stage.
65-
* @param width
66-
* Preferred stage width.
67-
* @param height
68-
* Preferred stage height.
69-
*
70-
* @return Newly created stage.
71-
*/
72-
@NonNull
73-
public DragDropStage newStageForDockable(@Nullable Scene sourceScene, @NonNull Dockable dockable, double width, double height) {
74-
DockBuilding builder = bento.dockBuilding();
75-
DockContainerRootBranch root = builder.root();
76-
DockContainerLeaf leaf = builder.leaf();
77-
return newStageForDockable(sourceScene, root, leaf, dockable, width, height);
78-
}
79-
80-
/**
81-
* Create a new stage for the given dockable.,
54+
* Create a new stage for the given dockable.
8255
*
8356
* @param sourceScene
8457
* Original scene to copy state from.
@@ -124,7 +97,7 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene,
12497
}
12598

12699
/**
127-
* Create a new stage for the given dockable.,
100+
* Create a new stage for the given dockable.
128101
*
129102
* @param sourceScene
130103
* Original scene to copy state from.

0 commit comments

Comments
 (0)