From 35a6393dd98d89a27002538351a40960e0f6f5e1 Mon Sep 17 00:00:00 2001 From: Phil Bryant Date: Wed, 15 Apr 2026 14:41:10 -0500 Subject: [PATCH 1/6] BENTO-18: * When undocking a `Dockable` to a `DragDropStage`, open the `DragDropStage` at the dropped location. * When undocking a `Dockable` to a `DragDropStage`, make the `DragDropStage` ownerless. --- .../coley/bentofx/building/StageBuilding.java | 83 ++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java index fd558f0a..0abb6bf0 100644 --- a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java @@ -1,7 +1,10 @@ package software.coley.bentofx.building; +import javafx.geometry.Point2D; +import javafx.geometry.Side; import javafx.scene.Scene; import javafx.scene.layout.Region; +import javafx.scene.robot.Robot; import javafx.stage.Stage; import javafx.stage.Window; import org.jspecify.annotations.NonNull; @@ -11,6 +14,7 @@ import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.layout.container.DockContainerLeaf; +import software.coley.bentofx.layout.container.DockContainerLeafMenuFactory; import software.coley.bentofx.layout.container.DockContainerRootBranch; /** @@ -93,6 +97,42 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, @NonNull DockContainerLeaf leaf, @NonNull Dockable dockable, double width, double height) { + return newStageForDockable(sourceScene, root, leaf, dockable, width, height, false, true); + } + + /** + * Create a new stage for the given dockable., + * + * @param sourceScene + * Original scene to copy state from. + * @param root + * Newly created root branch to place into the resulting stage. + * @param leaf + * Newly created leaf container to place the dockable into. + * @param dockable + * Dockable to place into the newly created stage. + * @param width + * Preferred stage width. + * @param height + * Preferred stage height. + * @param sourceIsOwner + * {@code true} to invoke {@link Stage#initOwner(Window)}, where the + * owner is the source stage. + * @param applyMousePosition + * {@code true} to set the stage's X and Y positions to the position of + * the mouse when the new stage is created. + * + * @return Newly created stage. + */ + public DragDropStage newStageForDockable(@Nullable Scene sourceScene, + @NonNull DockContainerRootBranch root, + @NonNull DockContainerLeaf leaf, + @NonNull Dockable dockable, + double width, + double height, + boolean sourceIsOwner, + boolean applyMousePosition + ) { // Sanity check, leaf shouldn't have an existing parent. if (leaf.getParentContainer() != root && leaf.getParentContainer() != null) leaf.removeFromParent(); @@ -110,11 +150,52 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, // Copy properties from the source scene/stage. if (sourceScene != null) - initializeFromSource(sourceScene, scene, sourceStage, stage, true); + initializeFromSource(sourceScene, scene, sourceStage, stage, sourceIsOwner); + + if (applyMousePosition) { + final Robot robot = new Robot(); + final Point2D mousePosition = robot.getMousePosition(); + stage.setX(mousePosition.getX()); + stage.setY(mousePosition.getY()); + } return stage; } + /** + * Create a new stage for the given dockable., + * + * @param sourceScene + * Original scene to copy state from. + * @param dockable + * Dockable to place into the newly created stage. + * @param width + * Preferred stage width. + * @param height + * Preferred stage height. + * @param leafMenuFactory + * DockContainerLeafMenuFactory for creating leaf menus + * @param side + * Side of this container to place {@code Header} displays on. + * {@code null} to not display any headers. + * + * @return Newly created stage. + */ + @NonNull + public DragDropStage newStageForDockable(@Nullable Scene sourceScene, + @NonNull Dockable dockable, + double width, + double height, + @Nullable DockContainerLeafMenuFactory leafMenuFactory, + @Nullable Side side) { + DockBuilding builder = bento.dockBuilding(); + DockContainerRootBranch root = builder.root(); + DockContainerLeaf leaf = builder.leaf(); + leaf.setMenuFactory(leafMenuFactory); + leaf.setSide(side); + return newStageForDockable(sourceScene, root, leaf, dockable, width, height); + } + /** * Copy attributes from the source scene/stage housing a dockable * to the new scene/stage the dockable will be moved to. From 7ae07394a9cd8e125f4b8825761082c12c10830b Mon Sep 17 00:00:00 2001 From: Phil Bryant Date: Wed, 15 Apr 2026 14:59:47 -0500 Subject: [PATCH 2/6] BENTO-17: * Remove unused method. --- .../coley/bentofx/building/StageBuilding.java | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java index 0abb6bf0..ae7129c8 100644 --- a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java @@ -1,7 +1,6 @@ package software.coley.bentofx.building; import javafx.geometry.Point2D; -import javafx.geometry.Side; import javafx.scene.Scene; import javafx.scene.layout.Region; import javafx.scene.robot.Robot; @@ -14,7 +13,6 @@ import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.layout.container.DockContainerLeaf; -import software.coley.bentofx.layout.container.DockContainerLeafMenuFactory; import software.coley.bentofx.layout.container.DockContainerRootBranch; /** @@ -162,40 +160,6 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, return stage; } - /** - * Create a new stage for the given dockable., - * - * @param sourceScene - * Original scene to copy state from. - * @param dockable - * Dockable to place into the newly created stage. - * @param width - * Preferred stage width. - * @param height - * Preferred stage height. - * @param leafMenuFactory - * DockContainerLeafMenuFactory for creating leaf menus - * @param side - * Side of this container to place {@code Header} displays on. - * {@code null} to not display any headers. - * - * @return Newly created stage. - */ - @NonNull - public DragDropStage newStageForDockable(@Nullable Scene sourceScene, - @NonNull Dockable dockable, - double width, - double height, - @Nullable DockContainerLeafMenuFactory leafMenuFactory, - @Nullable Side side) { - DockBuilding builder = bento.dockBuilding(); - DockContainerRootBranch root = builder.root(); - DockContainerLeaf leaf = builder.leaf(); - leaf.setMenuFactory(leafMenuFactory); - leaf.setSide(side); - return newStageForDockable(sourceScene, root, leaf, dockable, width, height); - } - /** * Copy attributes from the source scene/stage housing a dockable * to the new scene/stage the dockable will be moved to. From 7bf2dc7513477a47ccdaecaf9533421a570d66b8 Mon Sep 17 00:00:00 2001 From: Phil Bryant Date: Wed, 15 Apr 2026 17:08:41 -0500 Subject: [PATCH 3/6] BENTO-31: * Set the `core` module o default to `@NonNull` types. * Remove redundant `@NonNull` and added missing `@Nullable` annotations. --- core/src/main/java/module-info.java | 5 +- .../java/software/coley/bentofx/Bento.java | 22 +------- .../software/coley/bentofx/BentoBacked.java | 5 +- .../software/coley/bentofx/Identifiable.java | 7 +-- .../coley/bentofx/building/CanvasFactory.java | 4 +- .../building/ContentWrapperFactory.java | 4 +- .../bentofx/building/ControlsBuilding.java | 21 ++------ .../coley/bentofx/building/DockBuilding.java | 22 +++----- .../coley/bentofx/building/HeaderFactory.java | 4 +- .../bentofx/building/HeaderPaneFactory.java | 4 +- .../bentofx/building/HeadersFactory.java | 4 +- .../bentofx/building/PlaceholderBuilding.java | 13 ++--- .../coley/bentofx/building/SceneFactory.java | 4 +- .../coley/bentofx/building/StageBuilding.java | 28 +++++----- .../coley/bentofx/building/StageFactory.java | 2 - .../coley/bentofx/control/ButtonHBar.java | 3 +- .../coley/bentofx/control/ButtonVBar.java | 3 +- .../coley/bentofx/control/ContentWrapper.java | 5 +- .../coley/bentofx/control/Header.java | 8 +-- .../coley/bentofx/control/HeaderPane.java | 14 ++--- .../coley/bentofx/control/Headers.java | 5 +- .../coley/bentofx/control/LinearItemPane.java | 11 ++-- .../canvas/ArgbBufferedImageSource.java | 13 +++-- .../control/canvas/ArgbImageSource.java | 13 +++-- .../bentofx/control/canvas/ArgbSource.java | 3 +- .../bentofx/control/canvas/PixelCanvas.java | 13 +++-- .../bentofx/control/canvas/PixelPainter.java | 9 ++-- .../control/canvas/PixelPainterByteBgra.java | 9 ++-- .../canvas/PixelPainterByteBgraPre.java | 2 - .../control/canvas/PixelPainterIntArgb.java | 9 ++-- .../canvas/PixelPainterIntArgbPre.java | 2 - .../coley/bentofx/dockable/Dockable.java | 48 ++++++----------- .../dockable/DockableClickBehavior.java | 8 +-- .../dockable/DockableCloseListener.java | 3 +- .../dockable/DockableDragDropBehavior.java | 5 +- .../bentofx/dockable/DockableIconFactory.java | 5 +- .../bentofx/dockable/DockableMenuFactory.java | 5 +- .../dockable/DockableMoveListener.java | 3 +- .../dockable/DockableOpenListener.java | 3 +- .../dockable/DockablePlaceholderFactory.java | 4 +- .../dockable/DockableSelectListener.java | 3 +- .../coley/bentofx/event/DockEvent.java | 31 +++++------ .../bentofx/event/DockEventListener.java | 6 +-- .../coley/bentofx/event/EventBus.java | 28 ++++------ .../coley/bentofx/layout/DockContainer.java | 20 +++---- .../layout/container/DockContainerBranch.java | 53 +++++++++---------- .../layout/container/DockContainerLeaf.java | 45 ++++++---------- .../DockContainerLeafMenuFactory.java | 3 +- .../DockContainerLeafPlaceholderFactory.java | 4 +- .../container/DockContainerRootBranch.java | 6 +-- .../coley/bentofx/path/BentoPath.java | 2 - .../coley/bentofx/path/DockContainerPath.java | 11 ++-- .../coley/bentofx/path/DockablePath.java | 5 +- .../bentofx/search/DockContainerVisitor.java | 11 ++-- .../coley/bentofx/search/DockableVisitor.java | 7 ++- .../coley/bentofx/search/SearchHandler.java | 18 +++---- .../coley/bentofx/search/SearchVisitor.java | 7 ++- .../coley/bentofx/util/BentoUtils.java | 30 +++++------ .../coley/bentofx/util/DragUtils.java | 17 +++--- demos/basic/src/main/java/demo/BoxApp.java | 10 ++-- 60 files changed, 242 insertions(+), 430 deletions(-) diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index f5a14abd..ac37d09f 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -1,3 +1,6 @@ +import org.jspecify.annotations.NullMarked; + +@NullMarked module bento.fx { requires static org.jspecify; @@ -29,4 +32,4 @@ opens software.coley.bentofx.path; opens software.coley.bentofx.search; opens software.coley.bentofx.util; -} \ No newline at end of file +} diff --git a/core/src/main/java/software/coley/bentofx/Bento.java b/core/src/main/java/software/coley/bentofx/Bento.java index 4deed5ba..fb8c77bb 100644 --- a/core/src/main/java/software/coley/bentofx/Bento.java +++ b/core/src/main/java/software/coley/bentofx/Bento.java @@ -2,7 +2,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.building.ControlsBuilding; import software.coley.bentofx.building.DockBuilding; import software.coley.bentofx.building.PlaceholderBuilding; @@ -34,42 +33,34 @@ public class Bento { private final DockableDragDropBehavior dragDropBehavior = newDragDropBehavior(); private final DockableClickBehavior clickBehavior = newClickBehavior(); - @NonNull protected EventBus newEventBus() { return new EventBus(); } - @NonNull protected SearchHandler newSearchHandler() { return new SearchHandler(this); } - @NonNull protected StageBuilding newStageBuilding() { return new StageBuilding(this); } - @NonNull protected ControlsBuilding newControlsBuilding() { return new ControlsBuilding(); } - @NonNull protected DockBuilding newDockBuilding() { return new DockBuilding(this); } - @NonNull protected PlaceholderBuilding newPlaceholderBuilding() { return new PlaceholderBuilding(); } - @NonNull protected DockableDragDropBehavior newDragDropBehavior() { return new DockableDragDropBehavior() {}; } - @NonNull protected DockableClickBehavior newClickBehavior() { return new DockableClickBehavior() {}; } @@ -77,7 +68,6 @@ protected DockableClickBehavior newClickBehavior() { /** * @return Bus for handling event firing and event listeners. */ - @NonNull public EventBus events() { return eventBus; } @@ -85,7 +75,6 @@ public EventBus events() { /** * @return Search operations. */ - @NonNull public SearchHandler search() { return searchHandler; } @@ -93,7 +82,6 @@ public SearchHandler search() { /** * @return Builders for {@link DragDropStage}. */ - @NonNull public StageBuilding stageBuilding() { return stageBuilding; } @@ -101,7 +89,6 @@ public StageBuilding stageBuilding() { /** * @return Builders for various bento UI controls. */ - @NonNull public ControlsBuilding controlsBuilding() { return controlsBuilding; } @@ -109,7 +96,6 @@ public ControlsBuilding controlsBuilding() { /** * @return Builders for {@link DockContainer} and {@link Dockable}. */ - @NonNull public DockBuilding dockBuilding() { return dockBuilding; } @@ -117,7 +103,6 @@ public DockBuilding dockBuilding() { /** * @return Builders for placeholder content. */ - @NonNull public PlaceholderBuilding placeholderBuilding() { return placeholderBuilding; } @@ -125,7 +110,6 @@ public PlaceholderBuilding placeholderBuilding() { /** * @return Behavior implementation for drag-drop operations. */ - @NonNull public DockableDragDropBehavior getDragDropBehavior() { return dragDropBehavior; } @@ -133,7 +117,6 @@ public DockableDragDropBehavior getDragDropBehavior() { /** * @return Behavior implementation for click operations. */ - @NonNull public DockableClickBehavior getClickBehavior() { return clickBehavior; } @@ -144,7 +127,6 @@ public DockableClickBehavior getClickBehavior() { * @see #registerRoot(DockContainerRootBranch) * @see #unregisterRoot(DockContainerRootBranch) */ - @NonNull public ObservableList getRootContainers() { return rootContainersView; } @@ -155,7 +137,7 @@ public ObservableList getRootContainers() { * * @return {@code true} when registered. */ - public boolean registerRoot(@NonNull DockContainerRootBranch container) { + public boolean registerRoot(DockContainerRootBranch container) { if (!rootContainers.contains(container)) { rootContainers.add(container); eventBus.fire(new DockEvent.RootContainerAdded(container)); @@ -170,7 +152,7 @@ public boolean registerRoot(@NonNull DockContainerRootBranch container) { * * @return {@code true} when unregistered. */ - public boolean unregisterRoot(@NonNull DockContainerRootBranch container) { + public boolean unregisterRoot(DockContainerRootBranch container) { if (rootContainers.remove(container)) { eventBus.fire(new DockEvent.RootContainerRemoved(container)); return true; diff --git a/core/src/main/java/software/coley/bentofx/BentoBacked.java b/core/src/main/java/software/coley/bentofx/BentoBacked.java index 09e6106a..5468b433 100644 --- a/core/src/main/java/software/coley/bentofx/BentoBacked.java +++ b/core/src/main/java/software/coley/bentofx/BentoBacked.java @@ -1,7 +1,5 @@ package software.coley.bentofx; -import org.jspecify.annotations.NonNull; - /** * Outline of an object with access to its originating {@link Bento} instance. * @@ -11,6 +9,5 @@ public interface BentoBacked { /** * @return Bento instance responsible for this object. */ - @NonNull Bento getBento(); -} \ No newline at end of file +} diff --git a/core/src/main/java/software/coley/bentofx/Identifiable.java b/core/src/main/java/software/coley/bentofx/Identifiable.java index b0cba87a..d97034d1 100644 --- a/core/src/main/java/software/coley/bentofx/Identifiable.java +++ b/core/src/main/java/software/coley/bentofx/Identifiable.java @@ -1,7 +1,5 @@ package software.coley.bentofx; -import org.jspecify.annotations.NonNull; - /** * Outline of an (ideally uniquely) identifiable object. * @@ -11,7 +9,6 @@ public interface Identifiable { /** * @return This objects identifier. */ - @NonNull String getIdentifier(); /** @@ -20,5 +17,5 @@ public interface Identifiable { * * @return {@code true} when the other object has the same identifier. */ - boolean matchesIdentity(@NonNull Identifiable other); -} \ No newline at end of file + boolean matchesIdentity(Identifiable other); +} diff --git a/core/src/main/java/software/coley/bentofx/building/CanvasFactory.java b/core/src/main/java/software/coley/bentofx/building/CanvasFactory.java index f1a916c0..d413fd6d 100644 --- a/core/src/main/java/software/coley/bentofx/building/CanvasFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/CanvasFactory.java @@ -1,6 +1,5 @@ package software.coley.bentofx.building; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.control.canvas.PixelCanvas; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -16,6 +15,5 @@ public interface CanvasFactory { * * @return New canvas. */ - @NonNull - PixelCanvas newCanvas(@NonNull DockContainerLeaf container); + PixelCanvas newCanvas(DockContainerLeaf container); } diff --git a/core/src/main/java/software/coley/bentofx/building/ContentWrapperFactory.java b/core/src/main/java/software/coley/bentofx/building/ContentWrapperFactory.java index b44fce67..882d7c5b 100644 --- a/core/src/main/java/software/coley/bentofx/building/ContentWrapperFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/ContentWrapperFactory.java @@ -1,6 +1,5 @@ package software.coley.bentofx.building; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.control.ContentWrapper; import software.coley.bentofx.control.HeaderPane; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -17,6 +16,5 @@ public interface ContentWrapperFactory { * * @return Newly created content wrapper. */ - @NonNull - ContentWrapper newContentWrapper(@NonNull DockContainerLeaf container); + ContentWrapper newContentWrapper(DockContainerLeaf container); } diff --git a/core/src/main/java/software/coley/bentofx/building/ControlsBuilding.java b/core/src/main/java/software/coley/bentofx/building/ControlsBuilding.java index 31960b30..cb6043fd 100644 --- a/core/src/main/java/software/coley/bentofx/building/ControlsBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/ControlsBuilding.java @@ -2,7 +2,6 @@ import javafx.geometry.Orientation; import javafx.geometry.Side; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.control.ContentWrapper; import software.coley.bentofx.control.Header; @@ -32,7 +31,6 @@ public class ControlsBuilding implements HeaderPaneFactory, HeadersFactory, Head /** * @return Factory for creating {@link HeaderPane}. */ - @NonNull public HeaderPaneFactory getHeaderPaneFactory() { return headerPaneFactory; } @@ -51,7 +49,6 @@ public void setHeaderPaneFactory(@Nullable HeaderPaneFactory headerPaneFactory) /** * @return Factory for creating {@link Headers}. */ - @NonNull public HeadersFactory getHeadersFactory() { return headersFactory; } @@ -70,7 +67,6 @@ public void setHeadersFactory(@Nullable HeadersFactory headersFactory) { /** * @return Factory for creating {@link Header}. */ - @NonNull public HeaderFactory getHeaderFactory() { return headerFactory; } @@ -89,7 +85,6 @@ public void setHeaderFactory(@Nullable HeaderFactory headerFactory) { /** * @return Factory for creating {@link ContentWrapper}. */ - @NonNull public ContentWrapperFactory getContentWrapperFactory() { return contentWrapperFactory; } @@ -108,7 +103,6 @@ public void setContentWrapperFactory(@Nullable ContentWrapperFactory contentWrap /** * @return Factory for creating {@link PixelCanvas}. */ - @NonNull public CanvasFactory getCanvasFactory() { return canvasFactory; } @@ -124,33 +118,28 @@ public void setCanvasFactory(@Nullable CanvasFactory canvasFactory) { this.canvasFactory = canvasFactory; } - @NonNull @Override - public HeaderPane newHeaderPane(@NonNull DockContainerLeaf container) { + public HeaderPane newHeaderPane(DockContainerLeaf container) { return headerPaneFactory.newHeaderPane(container); } - @NonNull @Override - public Headers newHeaders(@NonNull DockContainerLeaf container, @NonNull Orientation orientation, @NonNull Side side) { + public Headers newHeaders(DockContainerLeaf container, Orientation orientation, Side side) { return headersFactory.newHeaders(container, orientation, side); } - @NonNull @Override - public Header newHeader(@NonNull Dockable dockable, @NonNull HeaderPane parentPane) { + public Header newHeader(Dockable dockable, HeaderPane parentPane) { return headerFactory.newHeader(dockable, parentPane); } - @NonNull @Override - public ContentWrapper newContentWrapper(@NonNull DockContainerLeaf container) { + public ContentWrapper newContentWrapper(DockContainerLeaf container) { return contentWrapperFactory.newContentWrapper(container); } - @NonNull @Override - public PixelCanvas newCanvas(@NonNull DockContainerLeaf container) { + public PixelCanvas newCanvas(DockContainerLeaf container) { return canvasFactory.newCanvas(container); } } diff --git a/core/src/main/java/software/coley/bentofx/building/DockBuilding.java b/core/src/main/java/software/coley/bentofx/building/DockBuilding.java index d97fd4f0..b36ed67c 100644 --- a/core/src/main/java/software/coley/bentofx/building/DockBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/DockBuilding.java @@ -1,6 +1,5 @@ package software.coley.bentofx.building; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.Bento; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.DockContainer; @@ -23,14 +22,13 @@ public class DockBuilding { * @param bento * Parent bento instance. */ - public DockBuilding(@NonNull Bento bento) { + public DockBuilding(Bento bento) { this.bento = bento; } /** * @return New dockable. */ - @NonNull public Dockable dockable() { return dockable(uid("dockable")); } @@ -41,8 +39,7 @@ public Dockable dockable() { * * @return New dockable. */ - @NonNull - public Dockable dockable(@NonNull String identifier) { + public Dockable dockable(String identifier) { return new Dockable(bento, identifier); } @@ -52,7 +49,6 @@ public Dockable dockable(@NonNull String identifier) { * @see Bento#registerRoot(DockContainerRootBranch) * @see Bento#unregisterRoot(DockContainerRootBranch) */ - @NonNull public DockContainerRootBranch root() { return root(uid("croot")); } @@ -67,15 +63,13 @@ public DockContainerRootBranch root() { * @see Bento#registerRoot(DockContainerRootBranch) * @see Bento#unregisterRoot(DockContainerRootBranch) */ - @NonNull - public DockContainerRootBranch root(@NonNull String identifier) { + public DockContainerRootBranch root(String identifier) { return new DockContainerRootBranch(bento, identifier); } /** * @return New branch container. */ - @NonNull public DockContainerBranch branch() { return branch(uid("cbranch")); } @@ -86,15 +80,13 @@ public DockContainerBranch branch() { * * @return New branch container. */ - @NonNull - public DockContainerBranch branch(@NonNull String identifier) { + public DockContainerBranch branch(String identifier) { return new DockContainerBranch(bento, identifier); } /** * @return New leaf container. */ - @NonNull public DockContainerLeaf leaf() { return leaf(uid("cleaf")); } @@ -105,13 +97,11 @@ public DockContainerLeaf leaf() { * * @return New branch container. */ - @NonNull - public DockContainerLeaf leaf(@NonNull String identifier) { + public DockContainerLeaf leaf(String identifier) { return new DockContainerLeaf(bento, identifier); } - @NonNull - private static String uid(@NonNull String prefix) { + private static String uid(String prefix) { StringBuilder suffix = new StringBuilder(8); for (int i = 0; i < 8; i++) suffix.append((char) RANDOM.nextInt('A', 'Z')); diff --git a/core/src/main/java/software/coley/bentofx/building/HeaderFactory.java b/core/src/main/java/software/coley/bentofx/building/HeaderFactory.java index 7b208e61..f8d4b850 100644 --- a/core/src/main/java/software/coley/bentofx/building/HeaderFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/HeaderFactory.java @@ -1,6 +1,5 @@ package software.coley.bentofx.building; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.control.Header; import software.coley.bentofx.control.HeaderPane; import software.coley.bentofx.dockable.Dockable; @@ -19,6 +18,5 @@ public interface HeaderFactory { * * @return New header. */ - @NonNull - Header newHeader(@NonNull Dockable dockable, @NonNull HeaderPane parentPane); + Header newHeader(Dockable dockable, HeaderPane parentPane); } diff --git a/core/src/main/java/software/coley/bentofx/building/HeaderPaneFactory.java b/core/src/main/java/software/coley/bentofx/building/HeaderPaneFactory.java index 9ab7368b..f2e364f0 100644 --- a/core/src/main/java/software/coley/bentofx/building/HeaderPaneFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/HeaderPaneFactory.java @@ -1,6 +1,5 @@ package software.coley.bentofx.building; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.control.HeaderPane; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -16,6 +15,5 @@ public interface HeaderPaneFactory { * * @return New header pane. */ - @NonNull - HeaderPane newHeaderPane(@NonNull DockContainerLeaf container); + HeaderPane newHeaderPane(DockContainerLeaf container); } diff --git a/core/src/main/java/software/coley/bentofx/building/HeadersFactory.java b/core/src/main/java/software/coley/bentofx/building/HeadersFactory.java index 90dece01..255471f0 100644 --- a/core/src/main/java/software/coley/bentofx/building/HeadersFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/HeadersFactory.java @@ -2,7 +2,6 @@ import javafx.geometry.Orientation; import javafx.geometry.Side; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.control.HeaderPane; import software.coley.bentofx.control.Headers; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -23,6 +22,5 @@ public interface HeadersFactory { * * @return Newly created headers. */ - @NonNull - Headers newHeaders(@NonNull DockContainerLeaf container, @NonNull Orientation orientation, @NonNull Side side); + Headers newHeaders(DockContainerLeaf container, Orientation orientation, Side side); } diff --git a/core/src/main/java/software/coley/bentofx/building/PlaceholderBuilding.java b/core/src/main/java/software/coley/bentofx/building/PlaceholderBuilding.java index a6d0bb67..cd1d4579 100644 --- a/core/src/main/java/software/coley/bentofx/building/PlaceholderBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/PlaceholderBuilding.java @@ -2,7 +2,6 @@ import javafx.scene.Node; import javafx.scene.layout.Pane; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.dockable.DockablePlaceholderFactory; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -24,7 +23,6 @@ public class PlaceholderBuilding implements DockablePlaceholderFactory, DockCont /** * @return Current placeholder factory for dockables with no content to show. */ - @NonNull public DockablePlaceholderFactory getDockablePlaceholderFactory() { return dockablePlaceholderFactory; } @@ -33,14 +31,13 @@ public DockablePlaceholderFactory getDockablePlaceholderFactory() { * @param dockablePlaceholderFactory * Placeholder factory for dockables with no content to show. */ - public void setDockablePlaceholderFactory(@NonNull DockablePlaceholderFactory dockablePlaceholderFactory) { + public void setDockablePlaceholderFactory(DockablePlaceholderFactory dockablePlaceholderFactory) { this.dockablePlaceholderFactory = dockablePlaceholderFactory; } /** * @return Current placeholder factory for containers with no content to show. */ - @NonNull public DockContainerLeafPlaceholderFactory getContainerPlaceholderFactory() { return containerPlaceholderFactory; } @@ -49,19 +46,17 @@ public DockContainerLeafPlaceholderFactory getContainerPlaceholderFactory() { * @param containerPlaceholderFactory * Placeholder factory for containers with no content to show. */ - public void setContainerPlaceholderFactory(@NonNull DockContainerLeafPlaceholderFactory containerPlaceholderFactory) { + public void setContainerPlaceholderFactory(DockContainerLeafPlaceholderFactory containerPlaceholderFactory) { this.containerPlaceholderFactory = containerPlaceholderFactory; } - @NonNull @Override - public Node build(@NonNull Dockable dockable) { + public Node build(Dockable dockable) { return getDockablePlaceholderFactory().build(dockable); } - @NonNull @Override - public Node build(@NonNull DockContainerLeaf container) { + public Node build(DockContainerLeaf container) { return getContainerPlaceholderFactory().build(container); } } diff --git a/core/src/main/java/software/coley/bentofx/building/SceneFactory.java b/core/src/main/java/software/coley/bentofx/building/SceneFactory.java index b5651c06..17413600 100644 --- a/core/src/main/java/software/coley/bentofx/building/SceneFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/SceneFactory.java @@ -2,7 +2,6 @@ import javafx.scene.Scene; import javafx.scene.layout.Region; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.control.DragDropStage; @@ -24,6 +23,5 @@ public interface SceneFactory { * * @return Newly created scene. */ - @NonNull - Scene newScene(@Nullable Scene sourceScene, @NonNull Region content, double width, double height); + Scene newScene(@Nullable Scene sourceScene, Region content, double width, double height); } diff --git a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java index ae7129c8..115bdde0 100644 --- a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java @@ -6,7 +6,6 @@ import javafx.scene.robot.Robot; import javafx.stage.Stage; import javafx.stage.Window; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.control.DragDropStage; @@ -25,7 +24,7 @@ public class StageBuilding { private StageFactory stageFactory = DEFAULT_STAGE_FACTORY; private SceneFactory sceneFactory = DEFAULT_SCENE_FACTORY; - public StageBuilding(@NonNull Bento bento) { + public StageBuilding(Bento bento) { this.bento = bento; } @@ -41,8 +40,7 @@ public StageBuilding(@NonNull Bento bento) { * * @return Newly created stage. */ - @NonNull - public DragDropStage newStageForDockable(@NonNull Scene sourceScene, @NonNull DockContainer source, @NonNull Dockable dockable) { + public DragDropStage newStageForDockable(Scene sourceScene, DockContainer source, Dockable dockable) { Region sourceRegion = source.asRegion(); double width = sourceRegion.getWidth(); double height = sourceRegion.getHeight(); @@ -63,8 +61,7 @@ public DragDropStage newStageForDockable(@NonNull Scene sourceScene, @NonNull Do * * @return Newly created stage. */ - @NonNull - public DragDropStage newStageForDockable(@Nullable Scene sourceScene, @NonNull Dockable dockable, double width, double height) { + public DragDropStage newStageForDockable(@Nullable Scene sourceScene, Dockable dockable, double width, double height) { DockBuilding builder = bento.dockBuilding(); DockContainerRootBranch root = builder.root(); DockContainerLeaf leaf = builder.leaf(); @@ -89,11 +86,10 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, @NonNull D * * @return Newly created stage. */ - @NonNull public DragDropStage newStageForDockable(@Nullable Scene sourceScene, - @NonNull DockContainerRootBranch root, - @NonNull DockContainerLeaf leaf, - @NonNull Dockable dockable, + DockContainerRootBranch root, + DockContainerLeaf leaf, + Dockable dockable, double width, double height) { return newStageForDockable(sourceScene, root, leaf, dockable, width, height, false, true); } @@ -123,9 +119,9 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, * @return Newly created stage. */ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, - @NonNull DockContainerRootBranch root, - @NonNull DockContainerLeaf leaf, - @NonNull Dockable dockable, + DockContainerRootBranch root, + DockContainerLeaf leaf, + Dockable dockable, double width, double height, boolean sourceIsOwner, @@ -175,10 +171,10 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, * @param sourceIsOwner * {@code true} to invoke {@link Stage#initOwner(Window)}, where the owner is the source stage. */ - protected void initializeFromSource(@NonNull Scene sourceScene, - @NonNull Scene newScene, + protected void initializeFromSource(Scene sourceScene, + Scene newScene, @Nullable Stage sourceStage, - @NonNull DragDropStage newStage, + DragDropStage newStage, boolean sourceIsOwner) { // Copy stylesheets. newScene.setUserAgentStylesheet(sourceScene.getUserAgentStylesheet()); diff --git a/core/src/main/java/software/coley/bentofx/building/StageFactory.java b/core/src/main/java/software/coley/bentofx/building/StageFactory.java index e13dddb2..a4b8c62a 100644 --- a/core/src/main/java/software/coley/bentofx/building/StageFactory.java +++ b/core/src/main/java/software/coley/bentofx/building/StageFactory.java @@ -1,7 +1,6 @@ package software.coley.bentofx.building; import javafx.stage.Stage; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.control.DragDropStage; @@ -17,6 +16,5 @@ public interface StageFactory { * * @return Newly created stage. */ - @NonNull DragDropStage newStage(@Nullable Stage sourceStage); } diff --git a/core/src/main/java/software/coley/bentofx/control/ButtonHBar.java b/core/src/main/java/software/coley/bentofx/control/ButtonHBar.java index 80711804..2d379253 100644 --- a/core/src/main/java/software/coley/bentofx/control/ButtonHBar.java +++ b/core/src/main/java/software/coley/bentofx/control/ButtonHBar.java @@ -3,7 +3,6 @@ import javafx.scene.Node; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.layout.container.DockContainerLeaf; import static software.coley.bentofx.util.BentoStates.PSEUDO_ORIENTATION_H; @@ -20,7 +19,7 @@ public class ButtonHBar extends HBox { * @param children * Children to add to this box. */ - public ButtonHBar(@NonNull Region parent, Node... children) { + public ButtonHBar(Region parent, Node... children) { getStyleClass().add("button-bar"); pseudoClassStateChanged(PSEUDO_ORIENTATION_H, true); diff --git a/core/src/main/java/software/coley/bentofx/control/ButtonVBar.java b/core/src/main/java/software/coley/bentofx/control/ButtonVBar.java index d58f66ea..5867b2a3 100644 --- a/core/src/main/java/software/coley/bentofx/control/ButtonVBar.java +++ b/core/src/main/java/software/coley/bentofx/control/ButtonVBar.java @@ -3,7 +3,6 @@ import javafx.scene.Node; import javafx.scene.layout.Region; import javafx.scene.layout.VBox; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.layout.container.DockContainerLeaf; import static software.coley.bentofx.util.BentoStates.PSEUDO_ORIENTATION_V; @@ -20,7 +19,7 @@ public class ButtonVBar extends VBox { * @param children * Children to add to this box. */ - public ButtonVBar(@NonNull Region parent, Node... children) { + public ButtonVBar(Region parent, Node... children) { getStyleClass().add("button-bar"); pseudoClassStateChanged(PSEUDO_ORIENTATION_V, true); diff --git a/core/src/main/java/software/coley/bentofx/control/ContentWrapper.java b/core/src/main/java/software/coley/bentofx/control/ContentWrapper.java index 214d93c0..f7117e58 100644 --- a/core/src/main/java/software/coley/bentofx/control/ContentWrapper.java +++ b/core/src/main/java/software/coley/bentofx/control/ContentWrapper.java @@ -5,7 +5,6 @@ import javafx.scene.input.Dragboard; import javafx.scene.input.TransferMode; import javafx.scene.layout.BorderPane; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.Bento; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.container.DockContainerBranch; @@ -27,14 +26,14 @@ public class ContentWrapper extends BorderPane { * @param container * Parent container. */ - public ContentWrapper(@NonNull DockContainerLeaf container) { + public ContentWrapper(DockContainerLeaf container) { getStyleClass().add("node-wrapper"); // Handle drag-drop setupDragDrop(container); } - protected void setupDragDrop(@NonNull DockContainerLeaf container) { + protected void setupDragDrop(DockContainerLeaf container) { Bento bento = container.getBento(); setOnDragOver(e -> { Dragboard dragboard = e.getDragboard(); diff --git a/core/src/main/java/software/coley/bentofx/control/Header.java b/core/src/main/java/software/coley/bentofx/control/Header.java index b5ea8d50..2e644f21 100644 --- a/core/src/main/java/software/coley/bentofx/control/Header.java +++ b/core/src/main/java/software/coley/bentofx/control/Header.java @@ -29,7 +29,6 @@ import javafx.scene.layout.Region; import javafx.scene.text.Text; import javafx.stage.Stage; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.dockable.Dockable; @@ -72,7 +71,7 @@ public class Header extends Region { * @param parentPane * Parent header pane. */ - public Header(@NonNull Dockable dockable, @NonNull HeaderPane parentPane) { + public Header(Dockable dockable, HeaderPane parentPane) { this.parentPane = parentPane; this.dockable = dockable; @@ -189,7 +188,6 @@ public Header(@NonNull Dockable dockable, @NonNull HeaderPane parentPane) { * * @return This. */ - @NonNull public Header withDragDrop() { Bento bento = dockable.getBento(); @@ -378,7 +376,7 @@ private void recomputeLayout(@Nullable Side side) { * @param header * Some other header to draw as a ghost. */ - private void enableInsertionGhost(@NonNull Header header) { + private void enableInsertionGhost(Header header) { grid.setMouseTransparent(true); grid.setManaged(false); Orientation ourOrientation = BentoUtils.sideToOrientation(getSide()); @@ -419,7 +417,6 @@ public void setSelected(boolean selected) { /** * @return Wrapped dockable. */ - @NonNull public Dockable getDockable() { return dockable; } @@ -427,7 +424,6 @@ public Dockable getDockable() { /** * @return Side of the {@link #parentPane} at the time of construction. */ - @Nullable private Side getSide() { return sideProperty.get(); } diff --git a/core/src/main/java/software/coley/bentofx/control/HeaderPane.java b/core/src/main/java/software/coley/bentofx/control/HeaderPane.java index 5868149f..c2cee8f2 100644 --- a/core/src/main/java/software/coley/bentofx/control/HeaderPane.java +++ b/core/src/main/java/software/coley/bentofx/control/HeaderPane.java @@ -13,7 +13,6 @@ import javafx.scene.control.MenuItem; import javafx.scene.control.TabPane; import javafx.scene.layout.BorderPane; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.dockable.Dockable; @@ -31,13 +30,13 @@ public class HeaderPane extends BorderPane { private final DockContainerLeaf container; private final ContentWrapper contentWrapper; - private Headers headers; + private @Nullable Headers headers; /** * @param container * Parent container. */ - public HeaderPane(@NonNull DockContainerLeaf container) { + public HeaderPane(DockContainerLeaf container) { this.container = container; this.contentWrapper = container.getBento().controlsBuilding().newContentWrapper(container); @@ -163,7 +162,6 @@ private void recomputeLayout(@Nullable Side side) { * @see #createDockableListButton() * @see #createContainerConfigButton() */ - @NonNull protected Node[] createButtonArray() { Button dockableListButton = createDockableListButton(); Button containerConfigButton = createContainerConfigButton(); @@ -173,7 +171,6 @@ protected Node[] createButtonArray() { /** * @return New button that displays all dockables in this space. */ - @NonNull protected Button createDockableListButton() { Button button = new Button("▼"); button.setEllipsisString("▼"); @@ -201,7 +198,6 @@ protected Button createDockableListButton() { * * @see DockContainerLeaf#setMenuFactory(DockContainerLeafMenuFactory) */ - @NonNull protected Button createContainerConfigButton() { Button button = new Button("≡"); button.setEllipsisString("≡"); @@ -213,8 +209,7 @@ protected Button createContainerConfigButton() { return button; } - @NonNull - private Header createHeader(@NonNull Dockable dockable) { + private Header createHeader(Dockable dockable) { return getBento().controlsBuilding().newHeader(dockable, this); } @@ -237,7 +232,6 @@ public Header getHeader(@Nullable Dockable dockable) { /** * @return Parent container. */ - @NonNull public DockContainerLeaf getContainer() { return container; } @@ -245,7 +239,6 @@ public DockContainerLeaf getContainer() { /** * @return The border-pane that holds the currently selected {@link Dockable#getNode()}. */ - @NonNull public ContentWrapper getContentWrapper() { return contentWrapper; } @@ -261,7 +254,6 @@ public Headers getHeaders() { /** * @return Convenience call. */ - @NonNull private Bento getBento() { return container.getBento(); } diff --git a/core/src/main/java/software/coley/bentofx/control/Headers.java b/core/src/main/java/software/coley/bentofx/control/Headers.java index a1a6cf9d..0a3af456 100644 --- a/core/src/main/java/software/coley/bentofx/control/Headers.java +++ b/core/src/main/java/software/coley/bentofx/control/Headers.java @@ -8,7 +8,6 @@ import javafx.scene.input.TransferMode; import javafx.scene.layout.Region; import javafx.scene.shape.Rectangle; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.container.DockContainerLeaf; import software.coley.bentofx.path.DockablePath; @@ -31,7 +30,7 @@ public class Headers extends LinearItemPane { * @param side * Side in the parent container where tabs are displayed. */ - public Headers(@NonNull DockContainerLeaf container, @NonNull Orientation orientation, @NonNull Side side) { + public Headers(DockContainerLeaf container, Orientation orientation, Side side) { super(orientation); // Create side-specific header region class. @@ -108,7 +107,7 @@ protected void setupClip() { setClip(clip); } - protected void setupDragDrop(@NonNull DockContainerLeaf container) { + protected void setupDragDrop(DockContainerLeaf container) { setOnDragOver(e -> { Dragboard dragboard = e.getDragboard(); String dockableIdentifier = DragUtils.extractIdentifier(dragboard); diff --git a/core/src/main/java/software/coley/bentofx/control/LinearItemPane.java b/core/src/main/java/software/coley/bentofx/control/LinearItemPane.java index adef6e1e..2a53e0da 100644 --- a/core/src/main/java/software/coley/bentofx/control/LinearItemPane.java +++ b/core/src/main/java/software/coley/bentofx/control/LinearItemPane.java @@ -14,7 +14,6 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; -import org.jspecify.annotations.NonNull; /** * A basic pane that lays out children in a single line. @@ -34,7 +33,7 @@ public class LinearItemPane extends Pane { * @param orientation * Which axis to layout children on. */ - public LinearItemPane(@NonNull Orientation orientation) { + public LinearItemPane(Orientation orientation) { this.orientation = orientation; // When the child to keep in view changes, update the layout. @@ -47,7 +46,6 @@ public LinearItemPane(@NonNull Orientation orientation) { /** * @return Orientation of this linear pane. */ - @NonNull public Orientation getOrientation() { return orientation; } @@ -56,7 +54,6 @@ public Orientation getOrientation() { * @return {@code true} when children overflow beyond the visible bounds of this pane. * {@code false} when all children are visible in-bounds. */ - @NonNull public BooleanProperty overflowingProperty() { return overflowing; } @@ -64,7 +61,6 @@ public BooleanProperty overflowingProperty() { /** * @return A child to keep in view. */ - @NonNull public ObjectProperty keepInViewProperty() { return keepInView; } @@ -75,7 +71,6 @@ public ObjectProperty keepInViewProperty() { * * @return {@code true} to fit child widths/height to the dimensions of this pane on the perpendicular axis. */ - @NonNull public BooleanProperty fitChildrenToPerpendicularProperty() { return fitChildrenToPerpendicular; } @@ -86,7 +81,7 @@ public BooleanProperty fitChildrenToPerpendicularProperty() { * @param node * Child to add. */ - public void add(@NonNull Node node) { + public void add(Node node) { getChildren().add(node); } @@ -205,7 +200,7 @@ protected void layoutVertical() { overflowing.set(overflow); } - protected double computeChildPerpendicularSize(@NonNull Bounds childBounds, @NonNull Orientation orientation) { + protected double computeChildPerpendicularSize(Bounds childBounds, Orientation orientation) { if (orientation == Orientation.HORIZONTAL) { return Math.max(fitChildrenToPerpendicular.get() ? getHeight() : childBounds.getHeight(), MIN_PERPENDICULAR); } else { diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/ArgbBufferedImageSource.java b/core/src/main/java/software/coley/bentofx/control/canvas/ArgbBufferedImageSource.java index e947baa5..1db54b10 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/ArgbBufferedImageSource.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/ArgbBufferedImageSource.java @@ -1,6 +1,6 @@ package software.coley.bentofx.control.canvas; -import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import java.awt.image.BufferedImage; import java.util.Arrays; @@ -12,14 +12,14 @@ */ public class ArgbBufferedImageSource implements ArgbSource { private final BufferedImage image; - private int[] fullArgbCache; + private int @Nullable[] fullArgbCache; private int hash; /** * @param image * Wrapped image. */ - public ArgbBufferedImageSource(@NonNull BufferedImage image) { + public ArgbBufferedImageSource(BufferedImage image) { this.image = image; } @@ -45,7 +45,7 @@ public int getArgb(int x, int y) { } @Override - public int[] getArgb(int x, int y, int width, int height) { + public int @Nullable [] getArgb(int x, int y, int width, int height) { try { return image.getRGB(x, y, width, height, null, 0, width); } catch (Throwable t) { @@ -55,10 +55,9 @@ public int[] getArgb(int x, int y, int width, int height) { } @Override - public int @NonNull [] getArgb() { + public int[] getArgb() { // We will likely be using this a bit, so it makes sense to cache the result. - if (fullArgbCache == null) - fullArgbCache = ArgbSource.super.getArgb(); + fullArgbCache = ArgbSource.super.getArgb(); return fullArgbCache; } diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/ArgbImageSource.java b/core/src/main/java/software/coley/bentofx/control/canvas/ArgbImageSource.java index 50ab02ab..20caad31 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/ArgbImageSource.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/ArgbImageSource.java @@ -2,7 +2,7 @@ import javafx.scene.image.Image; import javafx.scene.image.PixelFormat; -import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import java.nio.IntBuffer; import java.util.Arrays; @@ -14,14 +14,14 @@ */ public class ArgbImageSource implements ArgbSource { private final Image image; - private int[] fullArgbCache; + private int @Nullable[] fullArgbCache; private int hash; /** * @param image * Wrapped image. */ - public ArgbImageSource(@NonNull Image image) { + public ArgbImageSource(Image image) { this.image = image; } @@ -47,7 +47,7 @@ public int getArgb(int x, int y) { } @Override - public int[] getArgb(int x, int y, int width, int height) { + public int @Nullable[] getArgb(int x, int y, int width, int height) { try { IntBuffer buffer = IntBuffer.allocate(width * height); image.getPixelReader().getPixels(x, y, width, height, PixelFormat.getIntArgbInstance(), buffer, width); @@ -59,10 +59,9 @@ public int[] getArgb(int x, int y, int width, int height) { } @Override - public int @NonNull [] getArgb() { + public int[] getArgb() { // We will likely be using this a bit, so it makes sense to cache the result. - if (fullArgbCache == null) - fullArgbCache = ArgbSource.super.getArgb(); + fullArgbCache = ArgbSource.super.getArgb(); return fullArgbCache; } diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/ArgbSource.java b/core/src/main/java/software/coley/bentofx/control/canvas/ArgbSource.java index d94d9034..2a368147 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/ArgbSource.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/ArgbSource.java @@ -1,6 +1,5 @@ package software.coley.bentofx.control.canvas; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import java.util.Objects; @@ -50,7 +49,7 @@ public interface ArgbSource { /** * @return ARGB {@code int[]} for the full image. */ - default int @NonNull [] getArgb() { + default int[] getArgb() { return Objects.requireNonNull(getArgb(0, 0, getWidth(), getHeight()), "Failed computing ARGB for full image dimensions"); } diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/PixelCanvas.java b/core/src/main/java/software/coley/bentofx/control/canvas/PixelCanvas.java index 4b8741c4..1b535011 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/PixelCanvas.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/PixelCanvas.java @@ -4,7 +4,7 @@ import javafx.scene.image.ImageView; import javafx.scene.image.WritableImage; import javafx.scene.layout.Region; -import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * This is a very simple alternative to {@link Canvas} that does not keep track of draw operations. @@ -25,7 +25,7 @@ public class PixelCanvas extends Region { /** Wrapped display. */ private final ImageView view = new ImageView(); /** The image to display. */ - private WritableImage image; + private @Nullable WritableImage image; /** Last committed draw hash. */ private int lastDrawHash; /** Current draw hash. */ @@ -37,7 +37,7 @@ public class PixelCanvas extends Region { * @param pixelPainter * Painter to draw pixels. */ - public PixelCanvas(@NonNull PixelPainter pixelPainter) { + public PixelCanvas(PixelPainter pixelPainter) { this.pixelPainter = pixelPainter; getChildren().add(view); @@ -65,7 +65,7 @@ public PixelCanvas() { * @param height * Assigned height. */ - public PixelCanvas(@NonNull PixelPainter pixelPainter, int width, int height) { + public PixelCanvas(PixelPainter pixelPainter, int width, int height) { this.pixelPainter = pixelPainter; getChildren().add(view); @@ -289,7 +289,7 @@ public void drawVerticalLine(int x, int y, int lineLength, int lineWidth, int co * @param image * Image to draw. */ - public void drawImage(int x, int y, @NonNull ArgbSource image) { + public void drawImage(int x, int y, ArgbSource image) { updateDrawHash(hash(OP_FILL_IMG, x, y, image.hashCode())); pixelPainter.drawImage(x, y, image); } @@ -312,7 +312,7 @@ public void drawImage(int x, int y, @NonNull ArgbSource image) { * @param image * Image to draw. */ - public void drawImage(int x, int y, int sx, int sy, int sw, int sh, @NonNull ArgbSource image) { + public void drawImage(int x, int y, int sx, int sy, int sw, int sh, ArgbSource image) { updateDrawHash(hash(OP_FILL_IMG, x, y, sx, sy, sw, sh, image.hashCode())); pixelPainter.drawImage(x, y, sx, sy, sw, sh, image); } @@ -412,7 +412,6 @@ protected void reallocate() { * * @return New writable image of the given dimensions. */ - @NonNull protected WritableImage newImage(int width, int height) { return new WritableImage(width, height); } diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainter.java b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainter.java index 4ffb5507..65b06ad4 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainter.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainter.java @@ -2,7 +2,6 @@ import javafx.scene.image.PixelFormat; import javafx.scene.image.PixelWriter; -import org.jspecify.annotations.NonNull; import java.nio.Buffer; @@ -44,7 +43,7 @@ public interface PixelPainter { * @param pixelWriter * Pixel writer. */ - void commit(@NonNull PixelWriter pixelWriter); + void commit(PixelWriter pixelWriter); /** * Fills the given rectangle with the given color. @@ -228,7 +227,7 @@ default void drawVerticalLine(int x, int y, int lineLength, int lineWidth, int c * @param image * Image to draw. */ - void drawImage(int x, int y, @NonNull ArgbSource image); + void drawImage(int x, int y, ArgbSource image); /** * Draws an image at the given coordinates. @@ -248,7 +247,7 @@ default void drawVerticalLine(int x, int y, int lineLength, int lineWidth, int c * @param image * Image to draw. */ - void drawImage(int x, int y, int sx, int sy, int sw, int sh, @NonNull ArgbSource image); + void drawImage(int x, int y, int sx, int sy, int sw, int sh, ArgbSource image); /** * Set a given pixel to the given color. @@ -270,12 +269,10 @@ default void drawVerticalLine(int x, int y, int lineLength, int lineWidth, int c /** * @return Backing buffer. */ - @NonNull B getBuffer(); /** * @return Pixel format for contents in this painter's buffer. */ - @NonNull PixelFormat getPixelFormat(); } diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgra.java b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgra.java index 96685254..ffa49730 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgra.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgra.java @@ -2,7 +2,6 @@ import javafx.scene.image.PixelFormat; import javafx.scene.image.PixelWriter; -import org.jspecify.annotations.NonNull; import java.nio.ByteBuffer; import java.util.Arrays; @@ -44,7 +43,7 @@ public void release() { } @Override - public void commit(@NonNull PixelWriter pixelWriter) { + public void commit(PixelWriter pixelWriter) { pixelWriter.setPixels( 0, 0, @@ -81,7 +80,7 @@ public void fillRect(int x, int y, int width, int height, int color) { } @Override - public void drawImage(int x, int y, @NonNull ArgbSource source) { + public void drawImage(int x, int y, ArgbSource source) { int sourceWidth = source.getWidth(); int sourceHeight = source.getHeight(); int[] argb = source.getArgb(0, 0, sourceWidth, sourceHeight); @@ -100,7 +99,7 @@ public void drawImage(int x, int y, @NonNull ArgbSource source) { } @Override - public void drawImage(int x, int y, int sx, int sy, int sw, int sh, @NonNull ArgbSource source) { + public void drawImage(int x, int y, int sx, int sy, int sw, int sh, ArgbSource source) { int[] argb = source.getArgb(sx, sy, sw, sh); if (argb == null) return; @@ -136,13 +135,11 @@ public void clear() { Arrays.fill(drawBuffer.array(), 0, drawBufferCapacity(), (byte) 0); } - @NonNull @Override public ByteBuffer getBuffer() { return drawBuffer; } - @NonNull @Override public PixelFormat getPixelFormat() { return PixelFormat.getByteBgraInstance(); diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgraPre.java b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgraPre.java index 39290a06..1cebbeb2 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgraPre.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterByteBgraPre.java @@ -1,7 +1,6 @@ package software.coley.bentofx.control.canvas; import javafx.scene.image.PixelFormat; -import org.jspecify.annotations.NonNull; import java.nio.ByteBuffer; @@ -70,7 +69,6 @@ public void setColor(int x, int y, int color) { } } - @NonNull @Override public PixelFormat getPixelFormat() { return PixelFormat.getByteBgraPreInstance(); diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgb.java b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgb.java index 3a46bf5e..6b7b39f8 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgb.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgb.java @@ -2,7 +2,6 @@ import javafx.scene.image.PixelFormat; import javafx.scene.image.PixelWriter; -import org.jspecify.annotations.NonNull; import java.nio.IntBuffer; import java.util.Arrays; @@ -43,7 +42,7 @@ public void release() { } @Override - public void commit(@NonNull PixelWriter pixelWriter) { + public void commit(PixelWriter pixelWriter) { pixelWriter.setPixels( 0, 0, @@ -72,7 +71,7 @@ public void fillRect(int x, int y, int width, int height, int color) { } @Override - public void drawImage(int x, int y, @NonNull ArgbSource source) { + public void drawImage(int x, int y, ArgbSource source) { int sourceWidth = source.getWidth(); int sourceHeight = source.getHeight(); int[] argb = source.getArgb(); @@ -89,7 +88,7 @@ public void drawImage(int x, int y, @NonNull ArgbSource source) { } @Override - public void drawImage(int x, int y, int sx, int sy, int sw, int sh, @NonNull ArgbSource source) { + public void drawImage(int x, int y, int sx, int sy, int sw, int sh, ArgbSource source) { int[] argb = source.getArgb(sx, sy, sw, sh); if (argb == null) return; @@ -117,13 +116,11 @@ public void clear() { Arrays.fill(drawBuffer.array(), 0, drawBufferCapacity(), 0); } - @NonNull @Override public IntBuffer getBuffer() { return drawBuffer; } - @NonNull @Override public PixelFormat getPixelFormat() { return PixelFormat.getIntArgbInstance(); diff --git a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgbPre.java b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgbPre.java index da83e908..8e0cfb9e 100644 --- a/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgbPre.java +++ b/core/src/main/java/software/coley/bentofx/control/canvas/PixelPainterIntArgbPre.java @@ -1,7 +1,6 @@ package software.coley.bentofx.control.canvas; import javafx.scene.image.PixelFormat; -import org.jspecify.annotations.NonNull; import java.nio.IntBuffer; @@ -21,7 +20,6 @@ public void setColor(int x, int y, int color) { super.setColor(x, y, argbToArgbPre(color)); } - @NonNull @Override public PixelFormat getPixelFormat() { return PixelFormat.getIntArgbPreInstance(); diff --git a/core/src/main/java/software/coley/bentofx/dockable/Dockable.java b/core/src/main/java/software/coley/bentofx/dockable/Dockable.java index e7b2b7c9..34a6d3c9 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/Dockable.java +++ b/core/src/main/java/software/coley/bentofx/dockable/Dockable.java @@ -10,7 +10,6 @@ import javafx.beans.property.StringProperty; import javafx.scene.Node; import javafx.scene.control.Tooltip; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.BentoBacked; @@ -33,17 +32,17 @@ public class Dockable implements BentoBacked, Identifiable { private final Bento bento; private final String identifier; - private StringProperty title; - private ObjectProperty tooltip; - private ObjectProperty iconFactory; - private ObjectProperty contextMenuFactory; - private ObjectProperty node; - private ObjectProperty container; - private IntegerProperty dragGroupMask; - private BooleanProperty closable; - private BooleanProperty canBeDragged; - private BooleanProperty canBeDroppedToNewWindow; - private List closeListeners; + private @Nullable StringProperty title; + private @Nullable ObjectProperty tooltip; + private @Nullable ObjectProperty iconFactory; + private @Nullable ObjectProperty contextMenuFactory; + private @Nullable ObjectProperty node; + private @Nullable ObjectProperty container; + private @Nullable IntegerProperty dragGroupMask; + private @Nullable BooleanProperty closable; + private @Nullable BooleanProperty canBeDragged; + private @Nullable BooleanProperty canBeDroppedToNewWindow; + private @Nullable List closeListeners; /** * @param bento @@ -51,7 +50,7 @@ public class Dockable implements BentoBacked, Identifiable { * @param identifier * This dockable's identifier. */ - public Dockable(@NonNull Bento bento, @NonNull String identifier) { + public Dockable(Bento bento, String identifier) { this.bento = bento; this.identifier = identifier; } @@ -76,7 +75,7 @@ public void fireCloseListeners() { * @param consumer * Action to run in the parent container, if one exists. */ - public void inContainer(@NonNull Consumer consumer) { + public void inContainer(Consumer consumer) { DockContainerLeaf container = getContainer(); if (container != null) consumer.accept(container); @@ -86,7 +85,7 @@ public void inContainer(@NonNull Consumer consumer) { * @param consumer * Action to run in the parent container, if one exists. */ - public void inContainer(@NonNull BiConsumer consumer) { + public void inContainer(BiConsumer consumer) { DockContainerLeaf container = getContainer(); if (container != null) consumer.accept(container, this); @@ -104,27 +103,24 @@ public DockablePath getPath() { return parent.getPath().withChild(this); } - @NonNull @Override public Bento getBento() { return bento; } - @NonNull @Override public String getIdentifier() { return identifier; } @Override - public boolean matchesIdentity(@NonNull Identifiable other) { + public boolean matchesIdentity(Identifiable other) { return getIdentifier().equals(other.getIdentifier()); } /** * @return Current title. */ - @NonNull public String getTitle() { if (title == null) return ""; @@ -134,7 +130,6 @@ public String getTitle() { /** * @return Title property. */ - @NonNull public StringProperty titleProperty() { if (title == null) title = new SimpleStringProperty(""); @@ -162,7 +157,6 @@ public Tooltip getTooltip() { /** * @return Tooltip property. */ - @NonNull public ObjectProperty tooltipProperty() { if (tooltip == null) tooltip = new SimpleObjectProperty<>(); @@ -190,7 +184,6 @@ public DockableIconFactory getIconFactory() { /** * @return Icon factory property. */ - @NonNull public ObjectProperty iconFactoryProperty() { if (iconFactory == null) iconFactory = new SimpleObjectProperty<>(); return iconFactory; @@ -217,7 +210,6 @@ public DockableMenuFactory getContextMenuFactory() { /** * @return Context menu factory property. */ - @NonNull public ObjectProperty contextMenuFactoryProperty() { if (contextMenuFactory == null) contextMenuFactory = new SimpleObjectProperty<>(); @@ -245,7 +237,6 @@ public Node getNode() { /** * @return Node to display when this dockable is selected. */ - @NonNull public ObjectProperty nodeProperty() { if (node == null) node = new SimpleObjectProperty<>(); @@ -273,7 +264,6 @@ public DockContainerLeaf getContainer() { /** * @return Parent container property. */ - @NonNull public ObjectProperty containerProperty() { if (container == null) container = new SimpleObjectProperty<>(); @@ -302,7 +292,6 @@ public int getDragGroupMask() { /** * @return Drag group mask property. */ - @NonNull public IntegerProperty dragGroupMaskProperty() { if (dragGroupMask == null) dragGroupMask = new SimpleIntegerProperty(); @@ -329,7 +318,6 @@ public boolean isClosable() { /** * @return Closable property. */ - @NonNull public BooleanProperty closableProperty() { if (closable == null) closable = new SimpleBooleanProperty(true); @@ -356,7 +344,6 @@ public boolean isCanBeDragged() { /** * @return Draggable property. */ - @NonNull public BooleanProperty canBeDraggedProperty() { if (canBeDragged == null) canBeDragged = new SimpleBooleanProperty(); @@ -383,7 +370,6 @@ public boolean isCanBeDroppedToNewWindow() { /** * @return Window droppable property. */ - @NonNull public BooleanProperty canBeDroppedToNewWindowProperty() { if (canBeDroppedToNewWindow == null) canBeDroppedToNewWindow = new SimpleBooleanProperty(); @@ -404,7 +390,7 @@ public void setCanBeDroppedToNewWindow(boolean canBeDroppedToNewWindow) { * @param listener * Listener to add. */ - public void addCloseListener(@NonNull DockableCloseListener listener) { + public void addCloseListener(DockableCloseListener listener) { if (closeListeners == null) closeListeners = new ArrayList<>(); closeListeners.add(listener); @@ -416,7 +402,7 @@ public void addCloseListener(@NonNull DockableCloseListener listener) { * @param listener * Listener to remove. */ - public void removeCloseListener(@NonNull DockableCloseListener listener) { + public void removeCloseListener(DockableCloseListener listener) { if (closeListeners != null) closeListeners.remove(listener); } diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableClickBehavior.java b/core/src/main/java/software/coley/bentofx/dockable/DockableClickBehavior.java index 756a3eea..9e8c423b 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableClickBehavior.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableClickBehavior.java @@ -25,10 +25,10 @@ public interface DockableClickBehavior { * @param e * The click event. */ - default void onMouseClick(@NonNull DockContainerLeaf container, - @NonNull Dockable dockable, - @NonNull Header header, - @NonNull MouseEvent e) { + default void onMouseClick(DockContainerLeaf container, + Dockable dockable, + Header header, + MouseEvent e) { // Primary click --> select dockable if not selected, otherwise toggle collapsed state. if (e.getButton() == MouseButton.PRIMARY) { if (container.getSelectedDockable() == dockable || container.isCollapsed()) { diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableCloseListener.java b/core/src/main/java/software/coley/bentofx/dockable/DockableCloseListener.java index 6d0db671..f2f727b2 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableCloseListener.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableCloseListener.java @@ -1,6 +1,5 @@ package software.coley.bentofx.dockable; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.path.DockablePath; @@ -16,5 +15,5 @@ public interface DockableCloseListener { * @param dockable * Closed dockable. */ - void onClose(@NonNull DockablePath path, @NonNull Dockable dockable); + void onClose(DockablePath path, Dockable dockable); } diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableDragDropBehavior.java b/core/src/main/java/software/coley/bentofx/dockable/DockableDragDropBehavior.java index be26debd..cf6f2e20 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableDragDropBehavior.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableDragDropBehavior.java @@ -1,7 +1,6 @@ package software.coley.bentofx.dockable; import javafx.geometry.Side; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -40,9 +39,9 @@ public interface DockableDragDropBehavior { * * @return {@code true} when this container can receive the dockable. */ - default boolean canReceiveDockable(@NonNull DockContainerLeaf targetContainer, + default boolean canReceiveDockable(DockContainerLeaf targetContainer, @Nullable Side targetSide, - @NonNull Dockable dockable) { + Dockable dockable) { // The incoming dockable must have a compatible group. return targetContainer.getDockables().stream() .anyMatch(d -> d.getDragGroupMask() == dockable.getDragGroupMask()); diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableIconFactory.java b/core/src/main/java/software/coley/bentofx/dockable/DockableIconFactory.java index 29a20dfa..9fe7c245 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableIconFactory.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableIconFactory.java @@ -1,7 +1,6 @@ package software.coley.bentofx.dockable; import javafx.scene.Node; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -18,5 +17,5 @@ public interface DockableIconFactory { * @return Graphic for the dockable. */ @Nullable - Node build(@NonNull Dockable dockable); -} \ No newline at end of file + Node build(Dockable dockable); +} diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableMenuFactory.java b/core/src/main/java/software/coley/bentofx/dockable/DockableMenuFactory.java index 1a1292be..ade0300a 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableMenuFactory.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableMenuFactory.java @@ -1,7 +1,6 @@ package software.coley.bentofx.dockable; import javafx.scene.control.ContextMenu; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -17,5 +16,5 @@ public interface DockableMenuFactory { * @return Context menu for the dockable. */ @Nullable - ContextMenu build(@NonNull Dockable dockable); -} \ No newline at end of file + ContextMenu build(Dockable dockable); +} diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableMoveListener.java b/core/src/main/java/software/coley/bentofx/dockable/DockableMoveListener.java index 04dd5dbc..e59fdb47 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableMoveListener.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableMoveListener.java @@ -1,6 +1,5 @@ package software.coley.bentofx.dockable; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.path.DockablePath; @@ -18,5 +17,5 @@ public interface DockableMoveListener { * @param dockable * Moved dockable. */ - void onMove(@NonNull DockablePath oldPath, @NonNull DockablePath newPath, @NonNull Dockable dockable); + void onMove(DockablePath oldPath, DockablePath newPath, Dockable dockable); } diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableOpenListener.java b/core/src/main/java/software/coley/bentofx/dockable/DockableOpenListener.java index d6d6c5e5..6ab661ab 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableOpenListener.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableOpenListener.java @@ -1,6 +1,5 @@ package software.coley.bentofx.dockable; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.path.DockablePath; @@ -16,5 +15,5 @@ public interface DockableOpenListener { * @param dockable * Closed dockable. */ - void onOpen(@NonNull DockablePath path, @NonNull Dockable dockable); + void onOpen(DockablePath path, Dockable dockable); } diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockablePlaceholderFactory.java b/core/src/main/java/software/coley/bentofx/dockable/DockablePlaceholderFactory.java index 044d449f..13e49dd0 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockablePlaceholderFactory.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockablePlaceholderFactory.java @@ -1,7 +1,6 @@ package software.coley.bentofx.dockable; import javafx.scene.Node; -import org.jspecify.annotations.NonNull; /** * Factory to create a {@link Node} placeholder display for some given {@link Dockable}. @@ -16,6 +15,5 @@ public interface DockablePlaceholderFactory { * * @return Placeholder for the dockable. */ - @NonNull - Node build(@NonNull Dockable dockable); + Node build(Dockable dockable); } diff --git a/core/src/main/java/software/coley/bentofx/dockable/DockableSelectListener.java b/core/src/main/java/software/coley/bentofx/dockable/DockableSelectListener.java index 59ba4443..10f279f8 100644 --- a/core/src/main/java/software/coley/bentofx/dockable/DockableSelectListener.java +++ b/core/src/main/java/software/coley/bentofx/dockable/DockableSelectListener.java @@ -1,6 +1,5 @@ package software.coley.bentofx.dockable; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.path.DockablePath; /** @@ -15,5 +14,5 @@ public interface DockableSelectListener { * @param dockable * Selected dockable. */ - void onSelect(@NonNull DockablePath path, @NonNull Dockable dockable); + void onSelect(DockablePath path, Dockable dockable); } diff --git a/core/src/main/java/software/coley/bentofx/event/DockEvent.java b/core/src/main/java/software/coley/bentofx/event/DockEvent.java index 5c164870..3689f3b3 100644 --- a/core/src/main/java/software/coley/bentofx/event/DockEvent.java +++ b/core/src/main/java/software/coley/bentofx/event/DockEvent.java @@ -1,6 +1,5 @@ package software.coley.bentofx.event; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.dockable.Dockable; @@ -21,7 +20,7 @@ public sealed interface DockEvent { * @param container * Root container added. */ - record RootContainerAdded(@NonNull DockContainer container) implements DockEvent {} + record RootContainerAdded(DockContainer container) implements DockEvent {} /** * Event for when a {@link DockContainer} is {@link Bento#unregisterRoot(DockContainerRootBranch) uunregistered}. @@ -29,7 +28,7 @@ record RootContainerAdded(@NonNull DockContainer container) implements DockEvent * @param container * Root container removed. */ - record RootContainerRemoved(@NonNull DockContainer container) implements DockEvent {} + record RootContainerRemoved(DockContainer container) implements DockEvent {} /** * Event for when a {@link DockContainer}'s parent is changed. @@ -41,7 +40,7 @@ record RootContainerRemoved(@NonNull DockContainer container) implements DockEve * @param newParent * The container's new parent. */ - record ContainerParentChanged(@NonNull DockContainer container, @Nullable DockContainerBranch priorParent, + record ContainerParentChanged(DockContainer container, @Nullable DockContainerBranch priorParent, @Nullable DockContainerBranch newParent) implements DockEvent {} /** @@ -52,8 +51,8 @@ record ContainerParentChanged(@NonNull DockContainer container, @Nullable DockCo * @param child * Child added to the container. */ - record ContainerChildAdded(@NonNull DockContainerBranch container, - @NonNull DockContainer child) implements DockEvent {} + record ContainerChildAdded(DockContainerBranch container, + DockContainer child) implements DockEvent {} /** * Event for when a {@link DockContainerBranch} removes a child {@link DockContainer}. @@ -63,8 +62,8 @@ record ContainerChildAdded(@NonNull DockContainerBranch container, * @param child * Child removed from the container. */ - record ContainerChildRemoved(@NonNull DockContainerBranch container, - @NonNull DockContainer child) implements DockEvent {} + record ContainerChildRemoved(DockContainerBranch container, + DockContainer child) implements DockEvent {} /** * Event for when a {@link DockContainerLeaf} adds a {@link Dockable} item. @@ -74,15 +73,15 @@ record ContainerChildRemoved(@NonNull DockContainerBranch container, * @param dockable * Dockable added. */ - record DockableAdded(@NonNull DockContainerLeaf container, @NonNull Dockable dockable) implements DockEvent {} + record DockableAdded(DockContainerLeaf container, Dockable dockable) implements DockEvent {} /** * Event for when a {@link DockContainerLeaf} closes a {@link Dockable} item. * Can be cancelled to prevent closure. */ final class DockableClosing implements DockEvent { - private final @NonNull Dockable dockable; - private final @NonNull DockContainerLeaf container; + private final Dockable dockable; + private final DockContainerLeaf container; private boolean cancelled; /** @@ -91,7 +90,7 @@ final class DockableClosing implements DockEvent { * @param container * Container the dockable belongs to. */ - public DockableClosing(@NonNull Dockable dockable, @NonNull DockContainerLeaf container) { + public DockableClosing(Dockable dockable, DockContainerLeaf container) { this.dockable = dockable; this.container = container; } @@ -99,7 +98,6 @@ public DockableClosing(@NonNull Dockable dockable, @NonNull DockContainerLeaf co /** * @return Dockable being closed. */ - @NonNull public Dockable dockable() { return dockable; } @@ -107,7 +105,6 @@ public Dockable dockable() { /** * @return Container the dockable belongs to. */ - @NonNull public DockContainerLeaf container() { return container; } @@ -159,7 +156,7 @@ public String toString() { * @param container * Container the dockable belonged to. */ - record DockableRemoved(@NonNull Dockable dockable, @NonNull DockContainerLeaf container) implements DockEvent {} + record DockableRemoved(Dockable dockable, DockContainerLeaf container) implements DockEvent {} /** * Event for when a {@link DockContainerLeaf} updates its selected {@link Dockable} item. @@ -169,7 +166,7 @@ record DockableRemoved(@NonNull Dockable dockable, @NonNull DockContainerLeaf co * @param container * Container the dockable belongs to. */ - record DockableSelected(@NonNull Dockable dockable, @NonNull DockContainerLeaf container) implements DockEvent {} + record DockableSelected(Dockable dockable, DockContainerLeaf container) implements DockEvent {} /** * Event for when a {@link Dockable}'s parent is changed. @@ -181,6 +178,6 @@ record DockableSelected(@NonNull Dockable dockable, @NonNull DockContainerLeaf c * @param newParent * Dockable's new parent. */ - record DockableParentChanged(@NonNull Dockable dockable, @Nullable DockContainerLeaf priorParent, + record DockableParentChanged(Dockable dockable, @Nullable DockContainerLeaf priorParent, @Nullable DockContainerLeaf newParent) implements DockEvent {} } diff --git a/core/src/main/java/software/coley/bentofx/event/DockEventListener.java b/core/src/main/java/software/coley/bentofx/event/DockEventListener.java index 13e53a51..8b24ffa1 100644 --- a/core/src/main/java/software/coley/bentofx/event/DockEventListener.java +++ b/core/src/main/java/software/coley/bentofx/event/DockEventListener.java @@ -1,7 +1,5 @@ package software.coley.bentofx.event; -import org.jspecify.annotations.NonNull; - /** * Listener invoked by the firing of any {@link DockEvent}. * @@ -12,5 +10,5 @@ public interface DockEventListener { * @param event * Event fired. */ - void onDockEvent(@NonNull DockEvent event); -} \ No newline at end of file + void onDockEvent(DockEvent event); +} diff --git a/core/src/main/java/software/coley/bentofx/event/EventBus.java b/core/src/main/java/software/coley/bentofx/event/EventBus.java index 7d3397c0..e281b64c 100644 --- a/core/src/main/java/software/coley/bentofx/event/EventBus.java +++ b/core/src/main/java/software/coley/bentofx/event/EventBus.java @@ -1,6 +1,5 @@ package software.coley.bentofx.event; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.dockable.DockableCloseListener; import software.coley.bentofx.dockable.DockableMoveListener; @@ -30,7 +29,7 @@ public class EventBus { * @param event * Event to fire. */ - public void fire(@NonNull DockEvent event) { + public void fire(DockEvent event) { // Fire generic event listeners for (DockEventListener listener : eventListeners) listener.onDockEvent(event); @@ -82,7 +81,6 @@ public void fire(@NonNull DockEvent event) { /** * @return Generic event listeners. */ - @NonNull public List getEventListeners() { return Collections.unmodifiableList(eventListeners); } @@ -91,7 +89,7 @@ public List getEventListeners() { * @param listener * Generic event listener to add. */ - public void addEventListener(@NonNull DockEventListener listener) { + public void addEventListener(DockEventListener listener) { eventListeners.add(listener); } @@ -99,14 +97,13 @@ public void addEventListener(@NonNull DockEventListener listener) { * @param listener * Generic event listener to remove. */ - public boolean removeEventListener(@NonNull DockEventListener listener) { + public boolean removeEventListener(DockEventListener listener) { return eventListeners.remove(listener); } /** * @return Dockable opening listeners. */ - @NonNull public List getDockableOpenListener() { return Collections.unmodifiableList(openListeners); } @@ -115,7 +112,7 @@ public List getDockableOpenListener() { * @param listener * Dockable opening listener to add. */ - public void addDockableOpenListener(@NonNull DockableOpenListener listener) { + public void addDockableOpenListener(DockableOpenListener listener) { openListeners.add(listener); } @@ -123,14 +120,13 @@ public void addDockableOpenListener(@NonNull DockableOpenListener listener) { * @param listener * Dockable opening listener to remove. */ - public boolean removeDockableOpenListener(@NonNull DockableOpenListener listener) { + public boolean removeDockableOpenListener(DockableOpenListener listener) { return openListeners.remove(listener); } /** * @return Dockable moving listeners. */ - @NonNull public List getDockableMoveListener() { return Collections.unmodifiableList(moveListeners); } @@ -139,7 +135,7 @@ public List getDockableMoveListener() { * @param listener * Dockable moving listener to add. */ - public void addDockableMoveListener(@NonNull DockableMoveListener listener) { + public void addDockableMoveListener(DockableMoveListener listener) { moveListeners.add(listener); } @@ -147,14 +143,13 @@ public void addDockableMoveListener(@NonNull DockableMoveListener listener) { * @param listener * Dockable moving listener to remove. */ - public boolean removeDockableMoveListener(@NonNull DockableMoveListener listener) { + public boolean removeDockableMoveListener(DockableMoveListener listener) { return moveListeners.remove(listener); } /** * @return Dockable closing listeners. */ - @NonNull public List getDockableCloseListener() { return Collections.unmodifiableList(closeListeners); } @@ -163,7 +158,7 @@ public List getDockableCloseListener() { * @param listener * Dockable closing listener to add. */ - public void addDockableCloseListener(@NonNull DockableCloseListener listener) { + public void addDockableCloseListener(DockableCloseListener listener) { closeListeners.add(listener); } @@ -171,14 +166,13 @@ public void addDockableCloseListener(@NonNull DockableCloseListener listener) { * @param listener * Dockable closing listener to remove. */ - public boolean removeDockableCloseListener(@NonNull DockableCloseListener listener) { + public boolean removeDockableCloseListener(DockableCloseListener listener) { return closeListeners.remove(listener); } /** * @return Dockable selecting listeners. */ - @NonNull public List getDockableSelectListener() { return Collections.unmodifiableList(selectListeners); } @@ -187,7 +181,7 @@ public List getDockableSelectListener() { * @param listener * Dockable selecting listener to add. */ - public void addDockableSelectListener(@NonNull DockableSelectListener listener) { + public void addDockableSelectListener(DockableSelectListener listener) { selectListeners.add(listener); } @@ -195,7 +189,7 @@ public void addDockableSelectListener(@NonNull DockableSelectListener listener) * @param listener * Dockable selecting listener to remove. */ - public boolean removeDockableSelectListener(@NonNull DockableSelectListener listener) { + public boolean removeDockableSelectListener(DockableSelectListener listener) { return selectListeners.remove(listener); } } diff --git a/core/src/main/java/software/coley/bentofx/layout/DockContainer.java b/core/src/main/java/software/coley/bentofx/layout/DockContainer.java index 7d08f88e..b46133f6 100644 --- a/core/src/main/java/software/coley/bentofx/layout/DockContainer.java +++ b/core/src/main/java/software/coley/bentofx/layout/DockContainer.java @@ -1,7 +1,6 @@ package software.coley.bentofx.layout; import javafx.scene.layout.Region; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.BentoBacked; import software.coley.bentofx.Identifiable; @@ -25,7 +24,6 @@ public sealed interface DockContainer extends BentoBacked, Identifiable permits /** * @return Path to this container from the root container that holds this container. */ - @NonNull default DockContainerPath getPath() { DockContainer parent = getParentContainer(); if (parent != null) @@ -46,7 +44,7 @@ default DockContainerPath getPath() { * @param container * Container to assign as this container's parent. */ - void setParentContainer(@NonNull DockContainerBranch container); + void setParentContainer(DockContainerBranch container); /** * Remove the given container as this container's parent. @@ -55,7 +53,7 @@ default DockContainerPath getPath() { * @param parent * Container to remove as this container's parent. */ - void removeAsParentContainer(@NonNull DockContainerBranch parent); + void removeAsParentContainer(DockContainerBranch parent); /** * @param visitor @@ -63,12 +61,11 @@ default DockContainerPath getPath() { * * @return {@code true} when the visit shall continue. */ - boolean visit(@NonNull SearchVisitor visitor); + boolean visit(SearchVisitor visitor); /** * @return Unmodifiable list of dockables within this container. */ - @NonNull List getDockables(); /** @@ -77,7 +74,7 @@ default DockContainerPath getPath() { * * @return {@code true} if one or more of the dockables were added. */ - default boolean addDockables(@NonNull Dockable... dockables) { + default boolean addDockables(Dockable... dockables) { boolean changed = false; for (Dockable dockable : dockables) changed |= addDockable(dockable); @@ -90,7 +87,7 @@ default boolean addDockables(@NonNull Dockable... dockables) { * * @return {@code true} when added. */ - boolean addDockable(@NonNull Dockable dockable); + boolean addDockable(Dockable dockable); /** * @param dockable @@ -100,7 +97,7 @@ default boolean addDockables(@NonNull Dockable... dockables) { * * @return {@code true} when added. */ - boolean addDockable(int index, @NonNull Dockable dockable); + boolean addDockable(int index, Dockable dockable); /** * @param dockable @@ -108,7 +105,7 @@ default boolean addDockables(@NonNull Dockable... dockables) { * * @return {@code true} when removed. */ - boolean removeDockable(@NonNull Dockable dockable); + boolean removeDockable(Dockable dockable); /** * @param dockable @@ -116,7 +113,7 @@ default boolean addDockables(@NonNull Dockable... dockables) { * * @return {@code true} when removed. */ - boolean closeDockable(@NonNull Dockable dockable); + boolean closeDockable(Dockable dockable); /** * Remove this container within the {@link #getParentContainer() parent container}. @@ -144,7 +141,6 @@ default boolean removeFromParent() { /** * @return Self, cast to region. */ - @NonNull default Region asRegion() { return (Region) this; } diff --git a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerBranch.java b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerBranch.java index 47f7175c..1763509d 100644 --- a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerBranch.java +++ b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerBranch.java @@ -7,7 +7,6 @@ import javafx.geometry.Side; import javafx.scene.Node; import javafx.scene.control.SplitPane; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.Identifiable; @@ -31,8 +30,8 @@ public non-sealed class DockContainerBranch extends SplitPane implements DockCon private final ObservableList childContainersView = FXCollections.unmodifiableObservableList(childContainers); private final Bento bento; private final String identifier; - private List queue; - private DockContainerBranch parent; + private @Nullable List queue; + private @Nullable DockContainerBranch parent; private boolean pruneWhenEmpty = true; /** @@ -41,14 +40,13 @@ public non-sealed class DockContainerBranch extends SplitPane implements DockCon * @param identifier * This container's identifier. */ - public DockContainerBranch(@NonNull Bento bento, @NonNull String identifier) { + public DockContainerBranch(Bento bento, String identifier) { this.bento = bento; this.identifier = identifier; getStyleClass().addAll("bento", "container", "container-branch"); } - @NonNull @Override public Bento getBento() { return bento; @@ -61,14 +59,14 @@ public DockContainerBranch getParentContainer() { } @Override - public void setParentContainer(@NonNull DockContainerBranch parent) { + public void setParentContainer(DockContainerBranch parent) { DockContainerBranch priorParent = this.parent; this.parent = parent; bento.events().fire(new DockEvent.ContainerParentChanged(this, priorParent, parent)); } @Override - public void removeAsParentContainer(@NonNull DockContainerBranch parent) { + public void removeAsParentContainer(DockContainerBranch parent) { if (this.parent == parent) { DockContainerBranch priorParent = this.parent; this.parent = null; @@ -77,7 +75,7 @@ public void removeAsParentContainer(@NonNull DockContainerBranch parent) { } @Override - public boolean visit(@NonNull SearchVisitor visitor) { + public boolean visit(SearchVisitor visitor) { if (visitor.visitBranch(this)) for (DockContainer container : childContainers) if (!container.visit(visitor)) @@ -91,7 +89,7 @@ public boolean visit(@NonNull SearchVisitor visitor) { * * @return {@code true} if one or more of the containers were added. */ - public boolean addContainers(@NonNull DockContainer... containers) { + public boolean addContainers(DockContainer... containers) { boolean changed = false; for (DockContainer container : containers) changed |= addContainer(container); @@ -104,7 +102,7 @@ public boolean addContainers(@NonNull DockContainer... containers) { * * @return {@code true} when added. */ - public boolean addContainer(@NonNull DockContainer container) { + public boolean addContainer(DockContainer container) { return addContainer(childContainers.size(), container); } @@ -116,7 +114,7 @@ public boolean addContainer(@NonNull DockContainer container) { * * @return {@code true} when added. */ - public boolean addContainer(int index, @NonNull DockContainer container) { + public boolean addContainer(int index, DockContainer container) { if (index < 0 || index > childContainers.size()) return false; @@ -140,7 +138,7 @@ public boolean addContainer(int index, @NonNull DockContainer container) { * * @return {@code true} when replaced. */ - public boolean replaceContainer(@NonNull DockContainer child, @NonNull DockContainer replacement) { + public boolean replaceContainer(DockContainer child, DockContainer replacement) { if (childContainers.contains(child)) { child.removeAsParentContainer(this); @@ -165,7 +163,7 @@ public boolean replaceContainer(@NonNull DockContainer child, @NonNull DockConta * * @return {@code true} when removed. */ - public boolean removeContainer(@NonNull DockContainer child) { + public boolean removeContainer(DockContainer child) { if (childContainers.remove(child)) { getItems().remove(child.asRegion()); child.removeAsParentContainer(this); @@ -196,11 +194,11 @@ public boolean removeContainer(@NonNull DockContainer child) { * * @return {@code true} when updated. */ - public boolean setContainerSizePx(@NonNull DockContainer child, double size) { + public boolean setContainerSizePx(DockContainer child, double size) { return setContainerSizePx0(child, size, true); } - private boolean setContainerSizePx0(@NonNull DockContainer child, double size, boolean updateSize) { + private boolean setContainerSizePx0(DockContainer child, double size, boolean updateSize) { // We rely on knowing the current layout sizes for this implementation, so we need to delegate // any requests to this method to later when the layout for this container and all children // has been computed. @@ -261,7 +259,7 @@ private boolean setContainerSizePx0(@NonNull DockContainer child, double size, b * * @return {@code true} when updated. */ - public boolean setContainerSizePercent(@NonNull DockContainer child, double percent) { + public boolean setContainerSizePercent(DockContainer child, double percent) { // TODO: This does not need to be queued in the same way the SizePx does however... // - when the child is collapsed we need to determine how to persist the percent // so that when it uncollapses the percentage is correct. @@ -290,7 +288,7 @@ public boolean setContainerSizePercent(@NonNull DockContainer child, double perc * * @return {@code true} if the child is resizable. */ - public boolean isContainerResizable(@NonNull DockContainer child) { + public boolean isContainerResizable(DockContainer child) { // Get our direct children that are dividers. List dividers = getChildren().stream().filter(DIVIDER_SELECTOR::applies).toList(); if (dividers.isEmpty()) @@ -322,7 +320,7 @@ public boolean isContainerResizable(@NonNull DockContainer child) { * * @return {@code true} when updated. */ - public boolean setContainerResizable(@NonNull DockContainer child, boolean resizable) { + public boolean setContainerResizable(DockContainer child, boolean resizable) { // We rely on the split-pane skin having laid out the divders for this implementation, so we need to delegate // any requests to this method to later when the layout for this container and all children // has been computed. @@ -361,7 +359,7 @@ public boolean setContainerResizable(@NonNull DockContainer child, boolean resiz * * @return {@code true} if the child is collapsed. */ - public boolean isContainerCollapsed(@NonNull DockContainer child) { + public boolean isContainerCollapsed(DockContainer child) { return child instanceof DockContainerLeaf leaf && leaf.isCollapsed(); } @@ -373,7 +371,7 @@ public boolean isContainerCollapsed(@NonNull DockContainer child) { * * @return {@code true} when updated. */ - public boolean setContainerCollapsed(@NonNull DockContainerLeaf child, boolean collapse) { + public boolean setContainerCollapsed(DockContainerLeaf child, boolean collapse) { // Skip if there is nothing to branch between. If there is only one child collapsing makes no sense // as the same layout space will still be occupied by the leaf, but the leaf display will be hidden. // Collapsing can only occur if there is a splitter between two or more child containers. @@ -425,12 +423,10 @@ public boolean setContainerCollapsed(@NonNull DockContainerLeaf child, boolean c /** * @return Unmodifiable list of containers within this container. */ - @NonNull public ObservableList getChildContainers() { return childContainersView; } - @NonNull @Override public List getDockables() { return childContainers.stream() @@ -439,7 +435,7 @@ public List getDockables() { } @Override - public boolean addDockable(@NonNull Dockable dockable) { + public boolean addDockable(Dockable dockable) { for (DockContainer container : childContainers) if (container.addDockable(dockable)) return true; @@ -447,7 +443,7 @@ public boolean addDockable(@NonNull Dockable dockable) { } @Override - public boolean addDockable(int index, @NonNull Dockable dockable) { + public boolean addDockable(int index, Dockable dockable) { // Calling the indexed add on the branch container is probably a bad idea. for (DockContainer container : childContainers) if (container.addDockable(index, dockable)) @@ -456,7 +452,7 @@ public boolean addDockable(int index, @NonNull Dockable dockable) { } @Override - public boolean removeDockable(@NonNull Dockable dockable) { + public boolean removeDockable(Dockable dockable) { DockContainer updatedContainer = null; for (DockContainer container : childContainers) if (container.removeDockable(dockable)) { @@ -474,7 +470,7 @@ public boolean removeDockable(@NonNull Dockable dockable) { } @Override - public boolean closeDockable(@NonNull Dockable dockable) { + public boolean closeDockable(Dockable dockable) { DockContainer updatedContainer = null; for (DockContainer container : childContainers) if (container.closeDockable(dockable)) { @@ -501,14 +497,13 @@ public void setPruneWhenEmpty(boolean pruneWhenEmpty) { this.pruneWhenEmpty = pruneWhenEmpty; } - @NonNull @Override public String getIdentifier() { return identifier; } @Override - public boolean matchesIdentity(@NonNull Identifiable other) { + public boolean matchesIdentity(Identifiable other) { return identifier.equals(other.getIdentifier()); } @@ -522,7 +517,7 @@ protected void layoutChildren() { } } - private void addQueue(@NonNull Runnable action) { + private void addQueue(Runnable action) { // Gee, two layers of indirection? // Yes. I know this is stupid, but it delays registering the actions to a point // later where the reliance on the current layout is actually correct and not diff --git a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeaf.java b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeaf.java index 629ac7e5..dc1abc5f 100644 --- a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeaf.java +++ b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeaf.java @@ -16,7 +16,6 @@ import javafx.scene.control.ContextMenu; import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.Identifiable; @@ -40,19 +39,19 @@ public non-sealed class DockContainerLeaf extends StackPane implements DockContainer { private final ObservableList dockables = FXCollections.observableArrayList(); private final ObservableList dockablesView = FXCollections.unmodifiableObservableList(dockables); - private final ObjectProperty selectedDockable = new SimpleObjectProperty<>(); + private final ObjectProperty<@Nullable Dockable> selectedDockable = new SimpleObjectProperty<>(); private final ObjectProperty side = new SimpleObjectProperty<>(Side.TOP); private final ObservableValue orientation = side.map(s -> s.isHorizontal() ? Orientation.HORIZONTAL : Orientation.VERTICAL); private final BooleanProperty collapsed = new SimpleBooleanProperty(); private final ObjectProperty menuFactory = new SimpleObjectProperty<>(); private final DoubleProperty uncollapsedWidth = new SimpleDoubleProperty(); private final DoubleProperty uncollapsedHeight = new SimpleDoubleProperty(); - private BooleanProperty canSplit; + private @Nullable BooleanProperty canSplit; private final PixelCanvas canvas; private final HeaderPane headerPane; private final Bento bento; private final String identifier; - private DockContainerBranch parent; + private @Nullable DockContainerBranch parent; private boolean pruneWhenEmpty = true; /** @@ -61,7 +60,7 @@ public non-sealed class DockContainerLeaf extends StackPane implements DockConta * @param identifier * This container's identifier. */ - public DockContainerLeaf(@NonNull Bento bento, @NonNull String identifier) { + public DockContainerLeaf(Bento bento, String identifier) { this.bento = bento; this.identifier = identifier; this.headerPane = bento.controlsBuilding().newHeaderPane(this); @@ -87,14 +86,14 @@ public DockContainerBranch getParentContainer() { } @Override - public void setParentContainer(@NonNull DockContainerBranch parent) { + public void setParentContainer(DockContainerBranch parent) { DockContainerBranch priorParent = this.parent; this.parent = parent; bento.events().fire(new DockEvent.ContainerParentChanged(this, priorParent, parent)); } @Override - public void removeAsParentContainer(@NonNull DockContainerBranch parent) { + public void removeAsParentContainer(DockContainerBranch parent) { if (this.parent == parent) { DockContainerBranch priorParent = this.parent; this.parent = null; @@ -103,13 +102,12 @@ public void removeAsParentContainer(@NonNull DockContainerBranch parent) { } @Override - public boolean visit(@NonNull SearchVisitor visitor) { + public boolean visit(SearchVisitor visitor) { if (visitor.visitLeaf(this)) for (Dockable dockable : dockables) if (!visitor.visitDockable(dockable)) return false; return true; } - @NonNull @Override public ObservableList getDockables() { return dockablesView; @@ -120,8 +118,7 @@ public Dockable getSelectedDockable() { return selectedDockable.get(); } - @NonNull - public ObservableObjectValue selectedDockableProperty() { + public ObservableObjectValue<@Nullable Dockable> selectedDockableProperty() { return selectedDockable; } @@ -153,12 +150,12 @@ public boolean selectDockable(@Nullable Dockable dockable) { } @Override - public boolean addDockable(@NonNull Dockable dockable) { + public boolean addDockable(Dockable dockable) { return addDockable(dockables.size(), dockable); } @Override - public boolean addDockable(int index, @NonNull Dockable dockable) { + public boolean addDockable(int index, Dockable dockable) { // Containment check if (dockables.contains(dockable)) return false; @@ -179,7 +176,7 @@ public boolean addDockable(int index, @NonNull Dockable dockable) { } @Override - public boolean removeDockable(@NonNull Dockable dockable) { + public boolean removeDockable(Dockable dockable) { int i = dockables.indexOf(dockable); // Update dockable model @@ -211,7 +208,7 @@ public boolean removeDockable(@NonNull Dockable dockable) { } @Override - public boolean closeDockable(@NonNull Dockable dockable) { + public boolean closeDockable(Dockable dockable) { if (dockable.isClosable() && dockables.contains(dockable)) { dockable.fireCloseListeners(); @@ -236,7 +233,7 @@ public boolean closeDockable(@NonNull Dockable dockable) { * * @return {@code true} when this container can receive the dockable. */ - public boolean canReceiveDockable(@NonNull Dockable dockable, @Nullable Side receivedSide) { + public boolean canReceiveDockable(Dockable dockable, @Nullable Side receivedSide) { // Must not already have the given dockable if not splitting. if (receivedSide == null && dockables.contains(dockable)) return false; @@ -261,7 +258,7 @@ public void setPruneWhenEmpty(boolean pruneWhenEmpty) { * @param target * Region to draw as an overlay on this container's canvas. */ - public void drawCanvasHint(@NonNull Region target) { + public void drawCanvasHint(Region target) { drawCanvasHint(target, null); } @@ -271,7 +268,7 @@ public void drawCanvasHint(@NonNull Region target) { * @param side * Side of the region to draw, or {@code null} for the full region. */ - public void drawCanvasHint(@NonNull Region target, @Nullable Side side) { + public void drawCanvasHint(Region target, @Nullable Side side) { // Compute xy offset when 'target' is not a direct child of this view. double ox = 0; double oy = 0; @@ -315,7 +312,6 @@ public void clearCanvas() { /** * @return Overlay canvas. */ - @NonNull public PixelCanvas getCanvas() { return canvas; } @@ -418,7 +414,7 @@ protected double getUncollapsedSize() { * @return Associated header within this container that represents the given dockable. */ @Nullable - public Header getHeader(@NonNull Dockable dockable) { + public Header getHeader(Dockable dockable) { return headerPane.getHeader(dockable); } @@ -443,7 +439,6 @@ public void setSide(@Nullable Side side) { /** * @return {@link Header} display side property. */ - @NonNull public ObjectProperty sideProperty() { return side; } @@ -466,7 +461,6 @@ public Orientation getOrientation() { * @see Side#isHorizontal() * @see Side#isVertical() */ - @NonNull public ObservableValue orientationProperty() { return orientation; } @@ -474,7 +468,6 @@ public ObservableValue orientationProperty() { /** * @return Collapsed state property. */ - @NonNull public BooleanProperty collapsedProperty() { return collapsed; } @@ -499,7 +492,6 @@ public DockContainerLeafMenuFactory getMenuFactory() { /** * @return Menu factory property. */ - @NonNull public ObjectProperty menuFactoryProperty() { return menuFactory; } @@ -524,7 +516,6 @@ public boolean isCanSplit() { /** * @return Splittable property. */ - @NonNull public BooleanProperty canSplitProperty() { if (canSplit == null) canSplit = new SimpleBooleanProperty(true); return canSplit; @@ -538,20 +529,18 @@ public void setCanSplit(boolean canSplit) { canSplitProperty().set(canSplit); } - @NonNull @Override public Bento getBento() { return bento; } - @NonNull @Override public String getIdentifier() { return identifier; } @Override - public boolean matchesIdentity(@NonNull Identifiable other) { + public boolean matchesIdentity(Identifiable other) { return identifier.equals(other.getIdentifier()); } diff --git a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafMenuFactory.java b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafMenuFactory.java index 351c8003..e986a1c5 100644 --- a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafMenuFactory.java +++ b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafMenuFactory.java @@ -1,7 +1,6 @@ package software.coley.bentofx.layout.container; import javafx.scene.control.ContextMenu; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; /** @@ -17,5 +16,5 @@ public interface DockContainerLeafMenuFactory { * @return Context menu for the container. */ @Nullable - ContextMenu build(@NonNull DockContainerLeaf container); + ContextMenu build(DockContainerLeaf container); } diff --git a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafPlaceholderFactory.java b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafPlaceholderFactory.java index 6f2cca56..b73cec38 100644 --- a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafPlaceholderFactory.java +++ b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerLeafPlaceholderFactory.java @@ -1,7 +1,6 @@ package software.coley.bentofx.layout.container; import javafx.scene.Node; -import org.jspecify.annotations.NonNull; /** * Factory to create a {@link Node} placeholder display for some given {@link DockContainerLeaf}. @@ -16,6 +15,5 @@ public interface DockContainerLeafPlaceholderFactory { * * @return Placeholder for the container. */ - @NonNull - Node build(@NonNull DockContainerLeaf container); + Node build(DockContainerLeaf container); } diff --git a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerRootBranch.java b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerRootBranch.java index fe60e6c5..08ff1d25 100644 --- a/core/src/main/java/software/coley/bentofx/layout/container/DockContainerRootBranch.java +++ b/core/src/main/java/software/coley/bentofx/layout/container/DockContainerRootBranch.java @@ -2,7 +2,6 @@ import javafx.scene.Scene; import javafx.scene.layout.Region; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.control.DragDropStage; @@ -26,7 +25,7 @@ public class DockContainerRootBranch extends DockContainerBranch { * @param identifier * This container's identifier. */ - public DockContainerRootBranch(@NonNull Bento bento, @NonNull String identifier) { + public DockContainerRootBranch(Bento bento, String identifier) { super(bento, identifier); pseudoClassStateChanged(PSEUDO_ROOT, true); @@ -61,12 +60,11 @@ public DockContainerBranch getParentContainer() { } @Override - public void setParentContainer(@NonNull DockContainerBranch parent) { + public void setParentContainer(DockContainerBranch parent) { throw new IllegalStateException("Root should not have a parent container assigned"); } - @NonNull @Override public DockContainerPath getPath() { return path; diff --git a/core/src/main/java/software/coley/bentofx/path/BentoPath.java b/core/src/main/java/software/coley/bentofx/path/BentoPath.java index 2af4e4c4..328c38c2 100644 --- a/core/src/main/java/software/coley/bentofx/path/BentoPath.java +++ b/core/src/main/java/software/coley/bentofx/path/BentoPath.java @@ -1,6 +1,5 @@ package software.coley.bentofx.path; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.layout.DockContainer; /** @@ -12,6 +11,5 @@ public sealed interface BentoPath permits DockContainerPath, DockablePath { /** * @return Root container of the path. */ - @NonNull DockContainer rootContainer(); } diff --git a/core/src/main/java/software/coley/bentofx/path/DockContainerPath.java b/core/src/main/java/software/coley/bentofx/path/DockContainerPath.java index 1c825625..a646ac32 100644 --- a/core/src/main/java/software/coley/bentofx/path/DockContainerPath.java +++ b/core/src/main/java/software/coley/bentofx/path/DockContainerPath.java @@ -1,6 +1,5 @@ package software.coley.bentofx.path; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.DockContainer; @@ -14,15 +13,14 @@ * @param containers * Containers up to and including some target container. */ -public record DockContainerPath(@NonNull List containers) implements BentoPath { +public record DockContainerPath(List containers) implements BentoPath { /** * @param child * Child to append to new path. * * @return New path with the given child at the end. */ - @NonNull - public DockContainerPath withChild(@NonNull DockContainer child) { + public DockContainerPath withChild(DockContainer child) { List containersWithChild = new ArrayList<>(containers.size() + 1); containersWithChild.addAll(containers); containersWithChild.add(child); @@ -35,12 +33,10 @@ public DockContainerPath withChild(@NonNull DockContainer child) { * * @return New path with the given child at the end. */ - @NonNull - public DockablePath withChild(@NonNull Dockable child) { + public DockablePath withChild(Dockable child) { return new DockablePath(containers, child); } - @NonNull @Override public DockContainer rootContainer() { // There must always be at least one container since we must have a result for the path. @@ -50,7 +46,6 @@ public DockContainer rootContainer() { /** * @return Tail container in the path / intended target of the path. */ - @NonNull public DockContainer tailContainer() { // There must always be at least one container since we must have a result for the path. return containers.getLast(); diff --git a/core/src/main/java/software/coley/bentofx/path/DockablePath.java b/core/src/main/java/software/coley/bentofx/path/DockablePath.java index 7d2d032e..05fe2391 100644 --- a/core/src/main/java/software/coley/bentofx/path/DockablePath.java +++ b/core/src/main/java/software/coley/bentofx/path/DockablePath.java @@ -1,6 +1,5 @@ package software.coley.bentofx.path; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.layout.container.DockContainerLeaf; @@ -16,15 +15,13 @@ * @param dockable * Target dockable. */ -public record DockablePath(@NonNull List containers, @NonNull Dockable dockable) implements BentoPath { - @NonNull +public record DockablePath(List containers, Dockable dockable) implements BentoPath { @Override public DockContainer rootContainer() { // There must always be at least one container in a path since a dockable needs a parent to be placed into. return containers.getFirst(); } - @NonNull public DockContainerLeaf leafContainer() { // A dockable can only be put in a leaf, so this should be a safe cast. return (DockContainerLeaf) containers.getLast(); diff --git a/core/src/main/java/software/coley/bentofx/search/DockContainerVisitor.java b/core/src/main/java/software/coley/bentofx/search/DockContainerVisitor.java index 186838c7..254ece9b 100644 --- a/core/src/main/java/software/coley/bentofx/search/DockContainerVisitor.java +++ b/core/src/main/java/software/coley/bentofx/search/DockContainerVisitor.java @@ -1,6 +1,5 @@ package software.coley.bentofx.search; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.layout.container.DockContainerBranch; @@ -15,23 +14,23 @@ */ public class DockContainerVisitor implements SearchVisitor { private final Predicate matcher; - private DockContainer result; + private @Nullable DockContainer result; - public DockContainerVisitor(@NonNull Predicate matcher) { + public DockContainerVisitor(Predicate matcher) { this.matcher = matcher; } @Override - public boolean visitBranch(@NonNull DockContainerBranch container) { + public boolean visitBranch(DockContainerBranch container) { return visitContainer(container); } @Override - public boolean visitLeaf(@NonNull DockContainerLeaf container) { + public boolean visitLeaf(DockContainerLeaf container) { return visitContainer(container); } - private boolean visitContainer(@NonNull DockContainer container) { + private boolean visitContainer(DockContainer container) { if (matcher.test(container)) { // Match found, stop visiting. result = container; diff --git a/core/src/main/java/software/coley/bentofx/search/DockableVisitor.java b/core/src/main/java/software/coley/bentofx/search/DockableVisitor.java index 482071fc..385e4b4d 100644 --- a/core/src/main/java/software/coley/bentofx/search/DockableVisitor.java +++ b/core/src/main/java/software/coley/bentofx/search/DockableVisitor.java @@ -1,6 +1,5 @@ package software.coley.bentofx.search; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.dockable.Dockable; @@ -13,18 +12,18 @@ */ public class DockableVisitor implements SearchVisitor { private final Predicate matcher; - private Dockable result; + private @Nullable Dockable result; /** * @param matcher * Dockable predicate. */ - public DockableVisitor(@NonNull Predicate matcher) { + public DockableVisitor(Predicate matcher) { this.matcher = matcher; } @Override - public boolean visitDockable(@NonNull Dockable dockable) { + public boolean visitDockable(Dockable dockable) { if (matcher.test(dockable)) { // Match found, stop visiting. result = dockable; diff --git a/core/src/main/java/software/coley/bentofx/search/SearchHandler.java b/core/src/main/java/software/coley/bentofx/search/SearchHandler.java index bf30b754..0335d1b1 100644 --- a/core/src/main/java/software/coley/bentofx/search/SearchHandler.java +++ b/core/src/main/java/software/coley/bentofx/search/SearchHandler.java @@ -1,7 +1,6 @@ package software.coley.bentofx.search; import javafx.scene.input.DragEvent; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.dockable.Dockable; @@ -30,7 +29,7 @@ public class SearchHandler { * @param bento * Parent bento instance. */ - public SearchHandler(@NonNull Bento bento) { + public SearchHandler(Bento bento) { this.bento = bento; } @@ -42,7 +41,7 @@ public SearchHandler(@NonNull Bento bento) { * * @return {@code true} when replacement was completed. */ - public boolean replaceContainer(@NonNull String identifier, @NonNull DockContainer replacement) { + public boolean replaceContainer(String identifier, DockContainer replacement) { return replaceContainer(identifier, () -> replacement); } @@ -54,7 +53,7 @@ public boolean replaceContainer(@NonNull String identifier, @NonNull DockContain * * @return {@code true} when replacement was completed. */ - public boolean replaceContainer(@NonNull String identifier, @NonNull Supplier replacement) { + public boolean replaceContainer(String identifier, Supplier replacement) { DockContainerPath container = container(identifier); if (container == null) return false; @@ -74,7 +73,7 @@ public boolean replaceContainer(@NonNull String identifier, @NonNull Supplier c.getIdentifier().equals(identifier)); } @@ -85,7 +84,7 @@ public DockContainerPath container(@NonNull String identifier) { * @return Path to the first matched container, if found. */ @Nullable - public DockContainerPath container(@NonNull Predicate predicate) { + public DockContainerPath container(Predicate predicate) { DockContainerVisitor visitor = new DockContainerVisitor(predicate); for (DockContainer container : bento.getRootContainers()) { if (!container.visit(visitor)) @@ -102,7 +101,7 @@ public DockContainerPath container(@NonNull Predicate predicate) * @return Path to the associated {@link Dockable} if found. */ @Nullable - public DockablePath dockable(@NonNull DragEvent event) { + public DockablePath dockable(DragEvent event) { String identifier = DragUtils.extractIdentifier(event.getDragboard()); return identifier == null ? null : dockable(identifier); } @@ -114,7 +113,7 @@ public DockablePath dockable(@NonNull DragEvent event) { * @return Path to the matched container, if found. */ @Nullable - public DockablePath dockable(@NonNull String identifier) { + public DockablePath dockable(String identifier) { return dockable(d -> d.getIdentifier().equals(identifier)); } @@ -125,7 +124,7 @@ public DockablePath dockable(@NonNull String identifier) { * @return Path to the first matched dockable, if found. */ @Nullable - public DockablePath dockable(@NonNull Predicate predicate) { + public DockablePath dockable(Predicate predicate) { DockableVisitor visitor = new DockableVisitor(predicate); for (DockContainer container : bento.getRootContainers()) { if (!container.visit(visitor)) @@ -138,7 +137,6 @@ public DockablePath dockable(@NonNull Predicate predicate) { /** * @return All found dockable paths in the current bento instance. */ - @NonNull public List allDockables() { List paths = new ArrayList<>(); for (DockContainerRootBranch root : bento.getRootContainers()) { diff --git a/core/src/main/java/software/coley/bentofx/search/SearchVisitor.java b/core/src/main/java/software/coley/bentofx/search/SearchVisitor.java index 7adc5e0e..8d68dbfe 100644 --- a/core/src/main/java/software/coley/bentofx/search/SearchVisitor.java +++ b/core/src/main/java/software/coley/bentofx/search/SearchVisitor.java @@ -1,6 +1,5 @@ package software.coley.bentofx.search; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.dockable.Dockable; import software.coley.bentofx.layout.DockContainer; import software.coley.bentofx.layout.container.DockContainerBranch; @@ -18,7 +17,7 @@ public interface SearchVisitor { * * @return {@code true} to continue visitation. */ - default boolean visitBranch(@NonNull DockContainerBranch container) { + default boolean visitBranch(DockContainerBranch container) { return true; } @@ -28,7 +27,7 @@ default boolean visitBranch(@NonNull DockContainerBranch container) { * * @return {@code true} to continue visitation. */ - default boolean visitLeaf(@NonNull DockContainerLeaf container) { + default boolean visitLeaf(DockContainerLeaf container) { return true; } @@ -38,7 +37,7 @@ default boolean visitLeaf(@NonNull DockContainerLeaf container) { * * @return {@code true} to continue visitation. */ - default boolean visitDockable(@NonNull Dockable dockable) { + default boolean visitDockable(Dockable dockable) { return true; } } diff --git a/core/src/main/java/software/coley/bentofx/util/BentoUtils.java b/core/src/main/java/software/coley/bentofx/util/BentoUtils.java index ff7fc1c1..80f335d4 100644 --- a/core/src/main/java/software/coley/bentofx/util/BentoUtils.java +++ b/core/src/main/java/software/coley/bentofx/util/BentoUtils.java @@ -12,7 +12,6 @@ import javafx.scene.Scene; import javafx.scene.layout.BorderPane; import javafx.scene.layout.Region; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.control.HeaderPane; @@ -32,7 +31,6 @@ public class BentoUtils { * * @return Respective orientation if it were to be used for a {@link HeaderPane}. */ - @NonNull public static Orientation sideToOrientation(@Nullable Side side) { return switch (side) { case TOP, BOTTOM -> Orientation.HORIZONTAL; @@ -52,7 +50,7 @@ public static Orientation sideToOrientation(@Nullable Side side) { * @return The closest side for the given target position in the given region. */ @Nullable - public static Side computeClosestSide(@NonNull Region target, double x, double y) { + public static Side computeClosestSide(Region target, double x, double y) { double w = target.getWidth(); double h = target.getHeight(); double mw = w / 2; @@ -64,7 +62,7 @@ public static Side computeClosestSide(@NonNull Region target, double x, double y Point2D right = new Point2D(w, mh); Point2D center = new Point2D(mw, mh); Point2D[] candidates = new Point2D[]{center, top, bottom, left, right}; - Side[] sides = new Side[]{null, Side.TOP, Side.BOTTOM, Side.LEFT, Side.RIGHT}; + final @Nullable Side[] sides = new @Nullable Side[]{null, Side.TOP, Side.BOTTOM, Side.LEFT, Side.RIGHT}; int closest = 0; double closestDistance = Double.MAX_VALUE; for (int i = 0; i < candidates.length; i++) { @@ -93,7 +91,7 @@ public static Side computeClosestSide(@NonNull Region target, double x, double y * @return All matching children of any level with the given type. */ @SuppressWarnings("unchecked") - public static List getCastChildren(@NonNull Parent parent, @NonNull Class nodeType) { + public static List getCastChildren(Parent parent, Class nodeType) { return (List) getChildren(parent, nodeType); } @@ -110,8 +108,7 @@ public static List getCastChildren(@NonNull Parent parent, @NonNull Class * * @return All matching children of any level with the given type. */ - @NonNull - public static List getChildren(@NonNull Parent parent, @NonNull Class nodeType) { + public static List getChildren(Parent parent, Class nodeType) { List list = new ArrayList<>(); visitAndMatchChildren(parent, nodeType, list); return list; @@ -130,17 +127,16 @@ public static List getChildren(@NonNull Parent parent, @NonNull Class n * * @return All matching children of any level with the given CSS selector. */ - @NonNull - public static List getChildren(@NonNull Parent parent, @NonNull String cssSelector) { + public static List getChildren(Parent parent, String cssSelector) { Selector selector = Selector.createSelector(cssSelector); List list = new ArrayList<>(); visitAndMatchChildren(parent, selector, list); return list; } - private static void visitAndMatchChildren(@NonNull Parent parent, - @NonNull Selector selector, - @NonNull List list) { + private static void visitAndMatchChildren(Parent parent, + Selector selector, + List list) { for (Node node : parent.getChildrenUnmodifiable()) { if (selector.applies(node)) { list.add(node); @@ -150,9 +146,9 @@ private static void visitAndMatchChildren(@NonNull Parent parent, } } - private static void visitAndMatchChildren(@NonNull Parent parent, - @NonNull Class nodeType, - @NonNull List list) { + private static void visitAndMatchChildren(Parent parent, + Class nodeType, + List list) { for (Node node : parent.getChildrenUnmodifiable()) { if (nodeType.isAssignableFrom(node.getClass())) { list.add(node); @@ -172,7 +168,7 @@ private static void visitAndMatchChildren(@NonNull Parent parent, * @param * Node type. */ - public static void scheduleWhenShown(@NonNull T node, @NonNull Consumer action) { + public static void scheduleWhenShown(T node, Consumer action) { // Already showing, do the action immediately. Scene scene = node.getScene(); if (scene != null) { @@ -183,7 +179,7 @@ public static void scheduleWhenShown(@NonNull T node, @NonNull // Schedule again when the node is attached to a scene. node.sceneProperty().addListener(new ChangeListener<>() { @Override - public void changed(ObservableValue observable, Scene oldScene, Scene newScene) { + public void changed(ObservableValue observable, Scene oldScene, @Nullable Scene newScene) { if (newScene != null) { node.sceneProperty().removeListener(this); diff --git a/core/src/main/java/software/coley/bentofx/util/DragUtils.java b/core/src/main/java/software/coley/bentofx/util/DragUtils.java index ea5b95fe..575ac9de 100644 --- a/core/src/main/java/software/coley/bentofx/util/DragUtils.java +++ b/core/src/main/java/software/coley/bentofx/util/DragUtils.java @@ -5,7 +5,6 @@ import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.stage.Stage; -import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import software.coley.bentofx.Bento; import software.coley.bentofx.control.Header; @@ -33,8 +32,7 @@ public class DragUtils { * @see #extractIdentifier(Dragboard) * @see #extractDragGroup(Dragboard) */ - @NonNull - public static Map content(@NonNull Dockable dockable) { + public static Map content(Dockable dockable) { return content(dockable, null); } @@ -52,8 +50,7 @@ public static Map content(@NonNull Dockable dockable) { * @see #extractDragGroup(Dragboard) * @see #extractDropTargetType(Dragboard) */ - @NonNull - public static Map content(@NonNull Dockable dockable, @Nullable DragDropTarget target) { + public static Map content(Dockable dockable, @Nullable DragDropTarget target) { ClipboardContent content = new ClipboardContent(); String format = PREFIX + dockable.getDragGroupMask() + ";" + dockable.getIdentifier(); if (target != null) @@ -72,7 +69,7 @@ public static Map content(@NonNull Dockable dockable, @Nulla * @param target * The completed drag-drop type for a completed operation */ - public static void completeDnd(@NonNull DragEvent event, @NonNull Dockable dockable, @NonNull DragDropTarget target) { + public static void completeDnd(DragEvent event, Dockable dockable, DragDropTarget target) { event.getDragboard().setContent(content(dockable, target)); event.consume(); } @@ -87,7 +84,7 @@ public static void completeDnd(@NonNull DragEvent event, @NonNull Dockable docka * @see #content(Dockable) */ @Nullable - public static String extractIdentifier(@NonNull Dragboard dragboard) { + public static String extractIdentifier(Dragboard dragboard) { if (!dragboard.hasString()) return null; String[] parts = dragboard.getString().split(";"); @@ -106,7 +103,7 @@ public static String extractIdentifier(@NonNull Dragboard dragboard) { * @see #content(Dockable) */ @Nullable - public static Integer extractDragGroup(@NonNull Dragboard dragboard) { + public static Integer extractDragGroup(Dragboard dragboard) { if (!dragboard.hasString()) return null; String[] parts = dragboard.getString().split(";"); @@ -129,7 +126,7 @@ public static Integer extractDragGroup(@NonNull Dragboard dragboard) { * @see #content(Dockable, DragDropTarget) */ @Nullable - public static DragDropTarget extractDropTargetType(@NonNull Dragboard dragboard) { + public static DragDropTarget extractDropTargetType(Dragboard dragboard) { if (!dragboard.hasString()) return null; String[] parts = dragboard.getString().split(";"); @@ -155,7 +152,7 @@ public static DragDropTarget extractDropTargetType(@NonNull Dragboard dragboard) * @return The {@link Header} that initiated this drag gesture. */ @Nullable - public static Header getHeader(@NonNull Bento bento, @NonNull DragEvent event) { + public static Header getHeader(Bento bento, DragEvent event) { // Ideally the header is just known to the event. Object source = event.getGestureSource(); if (source instanceof Header headerSource) diff --git a/demos/basic/src/main/java/demo/BoxApp.java b/demos/basic/src/main/java/demo/BoxApp.java index b23445a7..613a695f 100644 --- a/demos/basic/src/main/java/demo/BoxApp.java +++ b/demos/basic/src/main/java/demo/BoxApp.java @@ -18,7 +18,6 @@ import javafx.scene.shape.Rectangle; import javafx.scene.shape.Shape; import javafx.stage.Stage; -import org.jspecify.annotations.NonNull; import software.coley.bentofx.Bento; import software.coley.bentofx.building.DockBuilding; import software.coley.bentofx.dockable.Dockable; @@ -112,8 +111,7 @@ public void start(Stage stage) { stage.show(); } - @NonNull - private Dockable buildDockable(@NonNull DockBuilding builder, int s, int i, @NonNull String title) { + private Dockable buildDockable(DockBuilding builder, int s, int i, String title) { Dockable dockable = builder.dockable(); dockable.setTitle(title); dockable.setIconFactory(d -> makeIcon(s, i)); @@ -132,7 +130,7 @@ private Dockable buildDockable(@NonNull DockBuilding builder, int s, int i, @Non return dockable; } - private void handleDockableClosing(DockEvent.@NonNull DockableClosing closingEvent) { + private void handleDockableClosing(DockEvent.DockableClosing closingEvent) { final Dockable dockable = closingEvent.dockable(); if (!dockable.getTitle().startsWith("Class ")) return; @@ -161,7 +159,6 @@ private void handleDockableClosing(DockEvent.@NonNull DockableClosing closingEve } } - @NonNull private static Shape makeIcon(int shapeMode, int i) { final int radius = 6; Shape icon = switch (shapeMode) { @@ -182,8 +179,7 @@ private static Shape makeIcon(int shapeMode, int i) { return icon; } - @NonNull - private static ContextMenu addSideOptions(@NonNull ContextMenu menu, @NonNull DockContainerLeaf space) { + private static ContextMenu addSideOptions(ContextMenu menu, DockContainerLeaf space) { for (Side side : Side.values()) { MenuItem item = new MenuItem(side.name()); item.setGraphic(new Label(side == space.getSide() ? "✓" : " ")); From eddf3ef744b15e2d746efed9a40e9fc36e8b7dac Mon Sep 17 00:00:00 2001 From: Phil Bryant Date: Wed, 15 Apr 2026 17:27:07 -0500 Subject: [PATCH 4/6] BENTO-31: * Remove change leaked from separate PR. --- .../coley/bentofx/building/StageBuilding.java | 47 +------------------ 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java index 115bdde0..de2a395a 100644 --- a/core/src/main/java/software/coley/bentofx/building/StageBuilding.java +++ b/core/src/main/java/software/coley/bentofx/building/StageBuilding.java @@ -1,9 +1,7 @@ package software.coley.bentofx.building; -import javafx.geometry.Point2D; import javafx.scene.Scene; import javafx.scene.layout.Region; -import javafx.scene.robot.Robot; import javafx.stage.Stage; import javafx.stage.Window; import org.jspecify.annotations.Nullable; @@ -91,42 +89,6 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, DockContainerLeaf leaf, Dockable dockable, double width, double height) { - return newStageForDockable(sourceScene, root, leaf, dockable, width, height, false, true); - } - - /** - * Create a new stage for the given dockable., - * - * @param sourceScene - * Original scene to copy state from. - * @param root - * Newly created root branch to place into the resulting stage. - * @param leaf - * Newly created leaf container to place the dockable into. - * @param dockable - * Dockable to place into the newly created stage. - * @param width - * Preferred stage width. - * @param height - * Preferred stage height. - * @param sourceIsOwner - * {@code true} to invoke {@link Stage#initOwner(Window)}, where the - * owner is the source stage. - * @param applyMousePosition - * {@code true} to set the stage's X and Y positions to the position of - * the mouse when the new stage is created. - * - * @return Newly created stage. - */ - public DragDropStage newStageForDockable(@Nullable Scene sourceScene, - DockContainerRootBranch root, - DockContainerLeaf leaf, - Dockable dockable, - double width, - double height, - boolean sourceIsOwner, - boolean applyMousePosition - ) { // Sanity check, leaf shouldn't have an existing parent. if (leaf.getParentContainer() != root && leaf.getParentContainer() != null) leaf.removeFromParent(); @@ -144,14 +106,7 @@ public DragDropStage newStageForDockable(@Nullable Scene sourceScene, // Copy properties from the source scene/stage. if (sourceScene != null) - initializeFromSource(sourceScene, scene, sourceStage, stage, sourceIsOwner); - - if (applyMousePosition) { - final Robot robot = new Robot(); - final Point2D mousePosition = robot.getMousePosition(); - stage.setX(mousePosition.getX()); - stage.setY(mousePosition.getY()); - } + initializeFromSource(sourceScene, scene, sourceStage, stage, true); return stage; } From 0fdd253bb0e8bcf483d89036113a83a52494a411 Mon Sep 17 00:00:00 2001 From: Phil Bryant Date: Wed, 15 Apr 2026 17:35:10 -0500 Subject: [PATCH 5/6] BENTO-31: * Restore missing `@Nullable` and mark additional types according to the change. --- core/src/main/java/software/coley/bentofx/control/Header.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/software/coley/bentofx/control/Header.java b/core/src/main/java/software/coley/bentofx/control/Header.java index 2e644f21..4c2e9407 100644 --- a/core/src/main/java/software/coley/bentofx/control/Header.java +++ b/core/src/main/java/software/coley/bentofx/control/Header.java @@ -55,7 +55,7 @@ public class Header extends Region { private final StringProperty titleProperty = new SimpleStringProperty(); private final ObjectProperty graphicProperty = new SimpleObjectProperty<>(); private final BooleanProperty closableProperty = new SimpleBooleanProperty(); - private final ObjectProperty sideProperty = new SimpleObjectProperty<>(); + private final ObjectProperty<@Nullable Side> sideProperty = new SimpleObjectProperty<>(); private final ObjectProperty tooltipProperty = new SimpleObjectProperty<>(); private final GridPane grid = new GridPane(); private final Text label = new Text(); @@ -424,7 +424,7 @@ public Dockable getDockable() { /** * @return Side of the {@link #parentPane} at the time of construction. */ - private Side getSide() { + private @Nullable Side getSide() { return sideProperty.get(); } From e0a53df846e2038bfa58550a2bb6a9c43b747af7 Mon Sep 17 00:00:00 2001 From: Phil Bryant Date: Fri, 17 Apr 2026 09:52:03 -0500 Subject: [PATCH 6/6] BENTO-31: * Apply the `open` keyword at the module level. --- core/src/main/java/module-info.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/module-info.java b/core/src/main/java/module-info.java index ac37d09f..3bc43b16 100644 --- a/core/src/main/java/module-info.java +++ b/core/src/main/java/module-info.java @@ -1,7 +1,13 @@ import org.jspecify.annotations.NullMarked; +/** + * A docking system for JavaFX. + *

+ * Everything is open/exported. Do whatever you want. + *

+ */ @NullMarked -module bento.fx { +open module bento.fx { requires static org.jspecify; requires javafx.base; @@ -9,7 +15,6 @@ requires javafx.controls; requires java.desktop; - // Just open/export everything. Do whatever you want. exports software.coley.bentofx; exports software.coley.bentofx.building; exports software.coley.bentofx.control; @@ -21,15 +26,4 @@ exports software.coley.bentofx.path; exports software.coley.bentofx.search; exports software.coley.bentofx.util; - opens software.coley.bentofx; - opens software.coley.bentofx.building; - opens software.coley.bentofx.control; - opens software.coley.bentofx.control.canvas; - opens software.coley.bentofx.dockable; - opens software.coley.bentofx.event; - opens software.coley.bentofx.layout; - opens software.coley.bentofx.layout.container; - opens software.coley.bentofx.path; - opens software.coley.bentofx.search; - opens software.coley.bentofx.util; }