From a068ddffc06af8c8bca520eb17beb55be96156e7 Mon Sep 17 00:00:00 2001 From: Christian Tischer Date: Tue, 11 Jun 2024 15:46:10 +0200 Subject: [PATCH] Improve image name overlay --- pom.xml | 2 +- .../embl/mobie/lib/bdv/ImageNameOverlay.java | 10 ++-- .../embl/mobie/lib/bdv/view/SliceViewer.java | 5 +- .../embl/mobie/ui/UserInterfaceHelper.java | 6 ++- src/test/java/projects/OpenGiulia.java | 47 ++++++++++++++++++ .../java/projects/OpenLocalThomasMolDev.java | 49 +++++++++++++++++++ 6 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 src/test/java/projects/OpenGiulia.java create mode 100644 src/test/java/projects/OpenLocalThomasMolDev.java diff --git a/pom.xml b/pom.xml index 7dab4be1..3685fb94 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.embl.mobie mobie-viewer-fiji - 5.0.1 + 5.0.3-SNAPSHOT diff --git a/src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java b/src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java index 82fadb05..25e9732a 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java +++ b/src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java @@ -68,17 +68,18 @@ public class ImageNameOverlay extends BdvOverlay implements TransformListener< A protected final Listeners.SynchronizedList< ActiveListener > listeners = new Listeners.SynchronizedList< ActiveListener >( ); - - public ImageNameOverlay( BdvHandle bdvHandle, boolean isActive, SliceViewer sliceViewer ) + public ImageNameOverlay( BdvHandle bdvHandle, SliceViewer sliceViewer ) { this.bdvHandle = bdvHandle; this.sliceViewer = sliceViewer; bdvHandle.getViewerPanel().transformListeners().add( this ); - setActive( isActive ); } public void setActive( boolean isActive ) { + if ( this.isActive == isActive ) + return; + this.isActive = isActive; if ( isActive && overlaySource == null ) @@ -106,6 +107,9 @@ public void setActive( boolean isActive ) { activeListener.isActive( isActive ); } + + updateImages(); + bdvHandle.getViewerPanel().requestRepaint(); } public boolean isActive() diff --git a/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java b/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java index 20136035..735a3db3 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java +++ b/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java @@ -81,7 +81,7 @@ public class SliceViewer private SourceAndConverterContextMenuClickBehaviour contextMenu; private final SourceAndConverterService sacService; - private ImageNameOverlay imageNameOverlay; + private final ImageNameOverlay imageNameOverlay; public SliceViewer( MoBIE moBIE, boolean is2D ) { @@ -100,12 +100,11 @@ public SliceViewer( MoBIE moBIE, boolean is2D ) tileRenderOverlay = false; // don't show twice } - imageNameOverlay = new ImageNameOverlay( bdvHandle, false, this ); + imageNameOverlay = new ImageNameOverlay( bdvHandle, this ); installContextMenuAndKeyboardShortCuts(); WindowArrangementHelper.rightAlignWindow( moBIE.getUserInterface().getWindow(), SwingUtilities.getWindowAncestor( bdvHandle.getViewerPanel() ), true, true ); - } public ImageNameOverlay getImageNameOverlay() diff --git a/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java b/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java index 93b1f057..3854dfb9 100644 --- a/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java +++ b/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java @@ -928,9 +928,11 @@ private JPanel createClearAndSourceNamesOverlayPanel( MoBIE moBIE ) } ); } ); - overlayNamesCheckbox =new JCheckBox( "overlay names" ); + overlayNamesCheckbox = new JCheckBox( "overlay names" ); overlayNamesCheckbox.setSelected( false ); - overlayNamesCheckbox.addActionListener( e -> new Thread( () -> moBIE.getViewManager().getSliceViewer().getImageNameOverlay().setActive( overlayNamesCheckbox.isSelected() ) ).start() ); + overlayNamesCheckbox.addActionListener( e -> new Thread( () -> + moBIE.getViewManager().getSliceViewer() + .getImageNameOverlay().setActive( overlayNamesCheckbox.isSelected() ) ).start() ); panel.add( overlayNamesCheckbox ); panel.add( space() ); diff --git a/src/test/java/projects/OpenGiulia.java b/src/test/java/projects/OpenGiulia.java new file mode 100644 index 00000000..7038b83e --- /dev/null +++ b/src/test/java/projects/OpenGiulia.java @@ -0,0 +1,47 @@ +/*- + * #%L + * Fiji viewer for MoBIE projects + * %% + * Copyright (C) 2018 - 2024 EMBL + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package projects; + +import net.imagej.ImageJ; +import org.embl.mobie.MoBIE; +import org.embl.mobie.MoBIESettings; +import org.embl.mobie.command.open.OpenHCSDatasetCommand; + +import java.io.IOException; + +public class OpenGiulia +{ + public static void main( String[] args ) throws IOException + { + final ImageJ imageJ = new ImageJ(); + imageJ.ui().showUI(); + + new MoBIE("/Volumes/emcf/mizzon/projects/2024/HEV_vCLEM/HEV_D7-1_oRblended_sec5-8/mobie_backup", MoBIESettings.settings() ); + } +} diff --git a/src/test/java/projects/OpenLocalThomasMolDev.java b/src/test/java/projects/OpenLocalThomasMolDev.java new file mode 100644 index 00000000..75c09184 --- /dev/null +++ b/src/test/java/projects/OpenLocalThomasMolDev.java @@ -0,0 +1,49 @@ +/*- + * #%L + * Fiji viewer for MoBIE projects + * %% + * Copyright (C) 2018 - 2024 EMBL + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package projects; + +import net.imagej.ImageJ; +import org.embl.mobie.MoBIE; +import org.embl.mobie.MoBIESettings; +import org.embl.mobie.command.open.OpenHCSDatasetCommand; + +import java.io.IOException; + +public class OpenLocalThomasMolDev +{ + public static void main( String[] args ) + { + final ImageJ imageJ = new ImageJ(); + imageJ.ui().showUI(); + + OpenHCSDatasetCommand command = new OpenHCSDatasetCommand(); + command.hcsDirectory = "/Users/tischer/Downloads/TBO-Test31-01-2024-10x-TL-DAPI_Plate_260/TimePoint_1"; + command.run(); + } +}