From acc36551c66438f175100a27dd514cb6936f3ab4 Mon Sep 17 00:00:00 2001 From: Christian Tischer Date: Tue, 29 Oct 2024 16:04:37 +0100 Subject: [PATCH] Implement AnnotationOverlay --- .../embl/mobie/lib/bdv/OverlayStringItem.java | 13 -- .../bdv/overlay/AnnotatedRegionsOverlay.java | 116 ++++++++++++++++++ .../AnnotatedSegmentsOrSpotsOverlay.java} | 116 ++++++++---------- .../lib/bdv/overlay/AnnotationOverlay.java | 6 + .../lib/bdv/{ => overlay}/CircleOverlay.java | 2 +- .../bdv/{ => overlay}/ImageNameOverlay.java | 7 +- .../lib/bdv/{ => overlay}/OverlayHelper.java | 41 +------ .../lib/bdv/overlay/OverlayTextItem.java | 12 ++ .../embl/mobie/lib/bdv/view/SliceViewer.java | 1 + .../org/embl/mobie/lib/table/TableView.java | 15 ++- .../viewer/ViewerTransformChanger.java | 2 +- .../org/embl/mobie/lib/view/ViewManager.java | 2 +- .../platybrowser/GeneSearchCommand.java | 2 +- .../java/org/embl/mobie/ui/UserInterface.java | 3 +- .../embl/mobie/ui/UserInterfaceHelper.java | 2 +- src/test/java/examples/OpenPlatybrowser.java | 6 +- 16 files changed, 217 insertions(+), 129 deletions(-) delete mode 100644 src/main/java/org/embl/mobie/lib/bdv/OverlayStringItem.java create mode 100644 src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedRegionsOverlay.java rename src/main/java/org/embl/mobie/lib/bdv/{AnnotationOverlay.java => overlay/AnnotatedSegmentsOrSpotsOverlay.java} (55%) create mode 100644 src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotationOverlay.java rename src/main/java/org/embl/mobie/lib/bdv/{ => overlay}/CircleOverlay.java (98%) rename src/main/java/org/embl/mobie/lib/bdv/{ => overlay}/ImageNameOverlay.java (96%) rename src/main/java/org/embl/mobie/lib/bdv/{ => overlay}/OverlayHelper.java (57%) create mode 100644 src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayTextItem.java diff --git a/src/main/java/org/embl/mobie/lib/bdv/OverlayStringItem.java b/src/main/java/org/embl/mobie/lib/bdv/OverlayStringItem.java deleted file mode 100644 index 6d3b360c7..000000000 --- a/src/main/java/org/embl/mobie/lib/bdv/OverlayStringItem.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.embl.mobie.lib.bdv; - -import java.awt.*; - -public class OverlayStringItem -{ - public String text; - Font font; - int x; - int y; - int width; - int height; -} diff --git a/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedRegionsOverlay.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedRegionsOverlay.java new file mode 100644 index 000000000..b98cae694 --- /dev/null +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedRegionsOverlay.java @@ -0,0 +1,116 @@ +/*- + * #%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 org.embl.mobie.lib.bdv.overlay; + +import bdv.util.*; +import net.imglib2.FinalRealInterval; +import net.imglib2.realtransform.AffineTransform3D; +import net.imglib2.roi.RealMaskRealInterval; +import net.imglib2.util.Intervals; +import org.embl.mobie.lib.annotation.AnnotatedRegion; +import org.embl.mobie.lib.bdv.view.SliceViewer; +import sc.fiji.bdvpg.bdv.BdvHandleHelper; + +import java.awt.*; +import java.util.ArrayList; + +public class AnnotatedRegionsOverlay< AR extends AnnotatedRegion > + extends BdvOverlay implements AnnotationOverlay +{ + private final SliceViewer sliceViewer; + private final ArrayList< AR > annotatedRegions; + private final String annotationColumn; + private BdvOverlaySource< AnnotatedRegionsOverlay > overlaySource; + public static final int MAX_FONT_SIZE = 20; + private static final Font font = new Font( "Monospaced", Font.PLAIN, MAX_FONT_SIZE ); + + public AnnotatedRegionsOverlay( + SliceViewer sliceViewer, + ArrayList< AR > annotatedRegions, + String annotationColumn ) + { + this.sliceViewer = sliceViewer; + this.annotatedRegions = annotatedRegions; + this.annotationColumn = annotationColumn; + + this.overlaySource = BdvFunctions.showOverlay( + this, + "annotationOverlay", + BdvOptions.options().addTo( sliceViewer.getBdvHandle() ) ); + + // The below seems needed probably due a bug: + // https://imagesc.zulipchat.com/#narrow/stream/327326-BigDataViewer/topic/BdvOverlay.20and.20Timepoints + // https://github.com/mobie/mobie-viewer-fiji/issues/976 + sliceViewer.updateTimepointSlider(); + } + + @Override + public void close() + { + overlaySource.removeFromBdv(); + sliceViewer.getBdvHandle().getViewerPanel().requestRepaint(); + } + + @Override + protected void draw( Graphics2D g ) + { + BdvHandle bdvHandle = sliceViewer.getBdvHandle(); + final AffineTransform3D viewerTransform = bdvHandle.getViewerPanel().state().getViewerTransform(); + + FinalRealInterval viewerInterval = BdvHandleHelper.getViewerGlobalBoundingInterval( bdvHandle ); + + ArrayList< AR > visibleRegions = new ArrayList<>(); + for ( AR annotatedRegion : annotatedRegions ) + { + if ( Intervals.isEmpty( Intervals.intersect( viewerInterval, annotatedRegion.getMask() ) ) ) + { + continue; // The region is not currently visible on the canvas + } + else + { + visibleRegions.add( annotatedRegion ); + } + } + + for ( AR annotation : visibleRegions ) + { + final RealMaskRealInterval mask = annotation.getMask(); + FinalRealInterval bounds = viewerTransform.estimateBounds( mask ); + + OverlayTextItem item = OverlayHelper.itemFromBounds( + g, + bounds, + annotation.getValue( annotationColumn ).toString(), + font + ); + + OverlayHelper.drawTextWithBackground( g, item ); + } + } +} diff --git a/src/main/java/org/embl/mobie/lib/bdv/AnnotationOverlay.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedSegmentsOrSpotsOverlay.java similarity index 55% rename from src/main/java/org/embl/mobie/lib/bdv/AnnotationOverlay.java rename to src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedSegmentsOrSpotsOverlay.java index 8a3fa60eb..3d6180194 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/AnnotationOverlay.java +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotatedSegmentsOrSpotsOverlay.java @@ -26,16 +26,16 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package org.embl.mobie.lib.bdv; +package org.embl.mobie.lib.bdv.overlay; import bdv.util.*; import bdv.viewer.ViewerState; import net.imglib2.FinalRealInterval; import net.imglib2.realtransform.AffineTransform3D; import net.imglib2.roi.RealMaskRealInterval; -import net.imglib2.util.Intervals; import org.embl.mobie.lib.annotation.AnnotatedRegion; import org.embl.mobie.lib.annotation.Annotation; +import org.embl.mobie.lib.bdv.ActiveListener; import org.embl.mobie.lib.bdv.view.SliceViewer; import org.embl.mobie.lib.select.Listeners; import sc.fiji.bdvpg.bdv.BdvHandleHelper; @@ -43,20 +43,20 @@ import java.awt.*; import java.util.ArrayList; -public class AnnotationOverlay< A extends Annotation > extends BdvOverlay +public class AnnotatedSegmentsOrSpotsOverlay< A extends Annotation > + extends BdvOverlay implements AnnotationOverlay { private final SliceViewer sliceViewer; private final ArrayList< A > annotations; private final String annotationColumn; - private BdvOverlaySource< AnnotationOverlay > overlaySource; + private BdvOverlaySource< AnnotatedSegmentsOrSpotsOverlay > overlaySource; public static final int MAX_FONT_SIZE = 20; private static final Font font = new Font( "Monospaced", Font.PLAIN, MAX_FONT_SIZE ); - protected final Listeners.SynchronizedList< ActiveListener > listeners - = new Listeners.SynchronizedList< ActiveListener >( ); - private AffineTransform3D viewerTransform; - - public AnnotationOverlay( SliceViewer sliceViewer, ArrayList< A > annotations, String annotationColumn ) + public AnnotatedSegmentsOrSpotsOverlay( + SliceViewer sliceViewer, + ArrayList< A > annotations, + String annotationColumn ) { this.sliceViewer = sliceViewer; this.annotations = annotations; @@ -73,6 +73,7 @@ public AnnotationOverlay( SliceViewer sliceViewer, ArrayList< A > annotations, S sliceViewer.updateTimepointSlider(); } + @Override public void close() { overlaySource.removeFromBdv(); @@ -82,65 +83,48 @@ public void close() @Override protected void draw( Graphics2D g ) { - final ViewerState viewerState = sliceViewer.getBdvHandle().getViewerPanel().state().snapshot(); - viewerTransform = viewerState.getViewerTransform(); - FinalRealInterval viewerInterval = BdvHandleHelper.getViewerGlobalBoundingInterval( sliceViewer.getBdvHandle() ); - double[] min = viewerInterval.minAsDoubleArray(); - double[] max = viewerInterval.maxAsDoubleArray(); - - // add some extent along the z-axis (which is otherwise 0) - double zMargin = ( max[ 0 ] - min[ 0 ] ) / 100; // FIXME: how much?? - min[ 2 ] -= zMargin; - max[ 2 ] += zMargin; - FinalRealInterval expandedViewerGlobalInterval = new FinalRealInterval( min, max ); - - ArrayList< A > visibleAnnotations = new ArrayList<>(); - for ( A annotation : annotations ) - { - if ( Intervals.contains( expandedViewerGlobalInterval, annotation ) ) - { - visibleAnnotations.add( annotation ); - } - } + // TODO: If there are 10k annotations that slows down the BDV rendering - for ( A annotation : visibleAnnotations ) - { - if ( annotation instanceof AnnotatedRegion ) - { - // use the bounds - final RealMaskRealInterval mask = ( ( AnnotatedRegion ) annotation ).getMask(); - FinalRealInterval bounds = viewerTransform.estimateBounds( mask ); - - OverlayStringItem item = OverlayHelper.itemFromBounds( - g, - bounds, - annotation.getValue( annotationColumn ).toString(), - font - ); - - OverlayHelper.drawTextWithBackground( g, item ); - } - else - { - // only use the location - double[] canvasPosition = new double[ 3 ]; - viewerTransform.apply( annotation.positionAsDoubleArray(), canvasPosition ); - - OverlayStringItem item = OverlayHelper.itemFromLocation( - g, - annotation.getValue( annotationColumn ).toString(), - canvasPosition, - visibleAnnotations.size(), - font ); - - OverlayHelper.drawTextWithBackground( g, item ); - } - } - } + BdvHandle bdvHandle = sliceViewer.getBdvHandle(); + final AffineTransform3D viewerTransform = bdvHandle.getViewerPanel().state().getViewerTransform(); + //double scale = Affine3DHelpers.extractScale( viewerTransform, 2 ); + int width = bdvHandle.getViewerPanel().getWidth(); + int height = bdvHandle.getViewerPanel().getHeight(); + if ( annotations == null || annotations.size() == 0 ) + return; - public void addListener( ActiveListener activeListener ) - { - listeners.add( activeListener ); + OverlayTextItem item = new OverlayTextItem(); + double[] globalPosition = new double[ 3 ]; + double[] viewPosition = new double[ 3 ]; + + for ( A annotation : annotations ) + { + annotation.localize( globalPosition ); + viewerTransform.apply( globalPosition, viewPosition ); + + if ( viewPosition[ 0 ] < 0 + || viewPosition[ 1 ] < 0 + || viewPosition[ 0 ] > width + || viewPosition[ 1 ] > height ) + continue; + + // final double depth = Math.abs( viewPosition[ 2 ] ) / scale; + //System.out.println( text + ": " + depth + "; " + Math.abs( viewPosition[ 2 ] )); + //float computedFontSize = ( float ) ( 3.0 * AnnotationOverlay.MAX_FONT_SIZE / Math.sqrt( numAnnotations ) ); + + float fontSize = (float) ( MAX_FONT_SIZE - Math.abs( viewPosition[ 2 ] ) ); + if ( fontSize < 2 ) + continue; + + g.setFont( font.deriveFont( Math.min( MAX_FONT_SIZE, fontSize ) ) ); + item.text = annotation.getValue( annotationColumn ).toString(); + item.width = g.getFontMetrics().stringWidth( item.text ); + item.height = g.getFontMetrics().getHeight(); + item.x = ( int ) ( viewPosition[ 0 ] - item.width / 2 ); + item.y = ( int ) ( viewPosition[ 1 ] + 1.5 * item.height ); // paint a bit below (good for points) + + OverlayHelper.drawTextWithBackground( g, item ); + } } } diff --git a/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotationOverlay.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotationOverlay.java new file mode 100644 index 000000000..fdae21ee4 --- /dev/null +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/AnnotationOverlay.java @@ -0,0 +1,6 @@ +package org.embl.mobie.lib.bdv.overlay; + +public interface AnnotationOverlay +{ + void close(); +} diff --git a/src/main/java/org/embl/mobie/lib/bdv/CircleOverlay.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/CircleOverlay.java similarity index 98% rename from src/main/java/org/embl/mobie/lib/bdv/CircleOverlay.java rename to src/main/java/org/embl/mobie/lib/bdv/overlay/CircleOverlay.java index 985517ad5..885dfd881 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/CircleOverlay.java +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/CircleOverlay.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package org.embl.mobie.lib.bdv; +package org.embl.mobie.lib.bdv.overlay; import bdv.util.Affine3DHelpers; import bdv.util.BdvOverlay; diff --git a/src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/ImageNameOverlay.java similarity index 96% rename from src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java rename to src/main/java/org/embl/mobie/lib/bdv/overlay/ImageNameOverlay.java index 85783d3b5..f4562bc93 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/ImageNameOverlay.java +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/ImageNameOverlay.java @@ -26,7 +26,7 @@ * POSSIBILITY OF SUCH DAMAGE. * #L% */ -package org.embl.mobie.lib.bdv; +package org.embl.mobie.lib.bdv.overlay; import bdv.util.BdvFunctions; import bdv.util.BdvHandle; @@ -41,6 +41,7 @@ import net.imglib2.roi.RealMaskRealInterval; import net.imglib2.util.Intervals; import org.embl.mobie.DataStore; +import org.embl.mobie.lib.bdv.ActiveListener; import org.embl.mobie.lib.bdv.view.SliceViewer; import org.embl.mobie.lib.image.Image; import org.embl.mobie.lib.image.RegionAnnotationImage; @@ -176,9 +177,9 @@ protected void draw( Graphics2D g ) for ( Map.Entry< String, FinalRealInterval > entry : imageNameToBounds.entrySet() ) { final FinalRealInterval bounds = entry.getValue(); - final String name = entry.getKey(); + final String imageName = entry.getKey(); - OverlayStringItem item = OverlayHelper.itemFromBounds( g, bounds, name, font ); + OverlayTextItem item = OverlayHelper.itemFromBounds( g, bounds, imageName, font ); OverlayHelper.drawTextWithBackground( g, item ); } diff --git a/src/main/java/org/embl/mobie/lib/bdv/OverlayHelper.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayHelper.java similarity index 57% rename from src/main/java/org/embl/mobie/lib/bdv/OverlayHelper.java rename to src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayHelper.java index 4852eff75..29278ce84 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/OverlayHelper.java +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayHelper.java @@ -1,13 +1,12 @@ -package org.embl.mobie.lib.bdv; +package org.embl.mobie.lib.bdv.overlay; import net.imglib2.FinalRealInterval; -import org.embl.mobie.lib.annotation.Annotation; import java.awt.*; public class OverlayHelper { - public static void drawTextWithBackground( Graphics2D g, OverlayStringItem item ) + public static void drawTextWithBackground( Graphics2D g, OverlayTextItem item ) { // draw background (this helps with https://github.com/mobie/mobie-viewer-fiji/issues/1013) // TODO in addition, one could also determine all the text bounds as an Interval @@ -24,58 +23,28 @@ public static void drawTextWithBackground( Graphics2D g, OverlayStringItem item g.drawString( item.text, item.x, item.y ); } - public static OverlayStringItem itemFromBounds( + public static OverlayTextItem itemFromBounds( Graphics2D g, FinalRealInterval bounds, String text, final Font font ) { - OverlayStringItem item = new OverlayStringItem(); - item.text = text; - final double width = bounds.realMax( 0 ) - bounds.realMin( 0 ); final double center = ( bounds.realMax( 0 ) + bounds.realMin( 0 ) ) / 2.0; - // font size g.setFont( font ); final float computedFontSize = ( float ) ( 1.0F * ImageNameOverlay.MAX_FONT_SIZE * width / ( 1.0F * g.getFontMetrics().stringWidth( text ) ) ); final float finalFontSize = Math.min( ImageNameOverlay.MAX_FONT_SIZE, computedFontSize ); Font finalFont = font.deriveFont( finalFontSize ); g.setFont( finalFont ); - // text width and height + final OverlayTextItem item = new OverlayTextItem(); + item.text = text; item.width = g.getFontMetrics().stringWidth( text ); item.height = g.getFontMetrics().getHeight(); - - // text coordinates item.x = (int) ( center - item.width / 2.0 ); item.y = (int) ( bounds.realMax( 1 ) + 1.1F * finalFont.getSize() ); return item; } - public static < A extends Annotation > OverlayStringItem itemFromLocation( - Graphics2D g, - String text, - double[] position, - int numAnnotations, - final Font font ) - { - OverlayStringItem item = new OverlayStringItem(); - item.text = text; - - g.setFont( font ); - - final float computedFontSize = ( float ) ( 3.0 * AnnotationOverlay.MAX_FONT_SIZE / Math.sqrt( numAnnotations ) ); - final float finalFontSize = Math.min ( AnnotationOverlay.MAX_FONT_SIZE, computedFontSize ); - - Font finalFont = font.deriveFont( finalFontSize ); - g.setFont( finalFont ); - - item.width = g.getFontMetrics().stringWidth( text ); - item.height = g.getFontMetrics().getHeight(); - - item.x = (int) ( position[ 0 ] - item.width / 2 ); - item.y = (int) ( position[ 1 ] + 1.5 * item.height ); // paint a bit below (good for points) - return item; - } } diff --git a/src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayTextItem.java b/src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayTextItem.java new file mode 100644 index 000000000..73f488e5e --- /dev/null +++ b/src/main/java/org/embl/mobie/lib/bdv/overlay/OverlayTextItem.java @@ -0,0 +1,12 @@ +package org.embl.mobie.lib.bdv.overlay; + +import java.awt.*; + +public class OverlayTextItem +{ + public String text; + public int x; + public int y; + public int width; + public int height; +} 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 8a0cb0c92..e6c37ea02 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 @@ -40,6 +40,7 @@ import org.embl.mobie.lib.bdv.*; import org.embl.mobie.lib.bdv.blend.AccumulateAlphaBlendingProjectorARGB; import org.embl.mobie.lib.bdv.blend.BlendingMode; +import org.embl.mobie.lib.bdv.overlay.ImageNameOverlay; import org.embl.mobie.lib.color.OpacityHelper; import org.embl.mobie.lib.image.Image; import org.embl.mobie.lib.image.RegionAnnotationImage; diff --git a/src/main/java/org/embl/mobie/lib/table/TableView.java b/src/main/java/org/embl/mobie/lib/table/TableView.java index 5cdce018f..83fe32e1b 100644 --- a/src/main/java/org/embl/mobie/lib/table/TableView.java +++ b/src/main/java/org/embl/mobie/lib/table/TableView.java @@ -28,15 +28,19 @@ */ package org.embl.mobie.lib.table; +import bdv.util.BdvOverlay; import de.embl.cba.tables.Logger; import de.embl.cba.tables.TableUIs; import de.embl.cba.tables.Tables; import ij.IJ; import ij.gui.GenericDialog; import org.embl.mobie.io.util.IOHelper; +import org.embl.mobie.lib.annotation.AnnotatedRegion; import org.embl.mobie.lib.annotation.AnnotationUI; import org.embl.mobie.lib.annotation.Annotation; -import org.embl.mobie.lib.bdv.AnnotationOverlay; +import org.embl.mobie.lib.bdv.overlay.AnnotatedRegionsOverlay; +import org.embl.mobie.lib.bdv.overlay.AnnotatedSegmentsOrSpotsOverlay; +import org.embl.mobie.lib.bdv.overlay.AnnotationOverlay; import org.embl.mobie.lib.bdv.view.SliceViewer; import org.embl.mobie.lib.color.CategoricalAnnotationColoringModel; import org.embl.mobie.lib.color.ColorHelper; @@ -498,7 +502,14 @@ private void overlayAnnotationDialog() annotationOverlay.close(); } - annotationOverlay = new AnnotationOverlay( sliceViewer, tableModel.annotations(), annotationColumn ); + if ( tableModel.annotations().get( 0 ) instanceof AnnotatedRegion ) + { + annotationOverlay = new AnnotatedRegionsOverlay( sliceViewer, tableModel.annotations(), annotationColumn ); + } + else + { + annotationOverlay = new AnnotatedSegmentsOrSpotsOverlay( sliceViewer, tableModel.annotations(), annotationColumn ); + } }); } diff --git a/src/main/java/org/embl/mobie/lib/transform/viewer/ViewerTransformChanger.java b/src/main/java/org/embl/mobie/lib/transform/viewer/ViewerTransformChanger.java index ac24d1687..f1559b318 100644 --- a/src/main/java/org/embl/mobie/lib/transform/viewer/ViewerTransformChanger.java +++ b/src/main/java/org/embl/mobie/lib/transform/viewer/ViewerTransformChanger.java @@ -34,7 +34,7 @@ import bdv.util.BdvOverlay; import bdv.util.BdvOverlaySource; import bdv.viewer.animate.SimilarityTransformAnimator; -import org.embl.mobie.lib.bdv.CircleOverlay; +import org.embl.mobie.lib.bdv.overlay.CircleOverlay; import org.embl.mobie.lib.playground.BdvPlaygroundHelper; import net.imglib2.realtransform.AffineTransform3D; import org.embl.mobie.lib.serialize.transformation.NormalizedAffineViewerTransform; diff --git a/src/main/java/org/embl/mobie/lib/view/ViewManager.java b/src/main/java/org/embl/mobie/lib/view/ViewManager.java index f4561a016..7140d93c2 100644 --- a/src/main/java/org/embl/mobie/lib/view/ViewManager.java +++ b/src/main/java/org/embl/mobie/lib/view/ViewManager.java @@ -40,7 +40,7 @@ import org.embl.mobie.lib.annotation.AnnotatedRegion; import org.embl.mobie.lib.annotation.AnnotatedSegment; import org.embl.mobie.lib.annotation.Annotation; -import org.embl.mobie.lib.bdv.ImageNameOverlay; +import org.embl.mobie.lib.bdv.overlay.ImageNameOverlay; import org.embl.mobie.lib.bdv.view.AnnotationSliceView; import org.embl.mobie.lib.bdv.view.ImageSliceView; import org.embl.mobie.lib.bdv.view.SliceViewer; diff --git a/src/main/java/org/embl/mobie/plugins/platybrowser/GeneSearchCommand.java b/src/main/java/org/embl/mobie/plugins/platybrowser/GeneSearchCommand.java index fef9901a5..3ba1ea540 100644 --- a/src/main/java/org/embl/mobie/plugins/platybrowser/GeneSearchCommand.java +++ b/src/main/java/org/embl/mobie/plugins/platybrowser/GeneSearchCommand.java @@ -34,7 +34,7 @@ import bdv.viewer.SourceAndConverter; import ij.IJ; import org.embl.mobie.MoBIE; -import org.embl.mobie.lib.bdv.CircleOverlay; +import org.embl.mobie.lib.bdv.overlay.CircleOverlay; import org.embl.mobie.lib.bdv.CalibratedMousePositionProvider; import org.embl.mobie.command.CommandConstants; import org.scijava.plugin.Parameter; diff --git a/src/main/java/org/embl/mobie/ui/UserInterface.java b/src/main/java/org/embl/mobie/ui/UserInterface.java index f923def16..b35e88492 100644 --- a/src/main/java/org/embl/mobie/ui/UserInterface.java +++ b/src/main/java/org/embl/mobie/ui/UserInterface.java @@ -28,9 +28,8 @@ */ package org.embl.mobie.ui; -import ij.IJ; import org.embl.mobie.MoBIE; -import org.embl.mobie.lib.bdv.ImageNameOverlay; +import org.embl.mobie.lib.bdv.overlay.ImageNameOverlay; import org.embl.mobie.lib.serialize.display.ImageDisplay; import org.embl.mobie.lib.serialize.display.RegionDisplay; import org.embl.mobie.lib.serialize.display.SegmentationDisplay; diff --git a/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java b/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java index 065db37d2..db28967ef 100644 --- a/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java +++ b/src/main/java/org/embl/mobie/ui/UserInterfaceHelper.java @@ -880,7 +880,7 @@ private JPanel createClearAndSourceNamesOverlayPanel( MoBIE moBIE ) } ); } ); - overlayNamesCheckbox = new JCheckBox( "overlay names" ); + overlayNamesCheckbox = new JCheckBox( "overlay image names" ); overlayNamesCheckbox.setSelected( false ); overlayNamesCheckbox.addActionListener( e -> new Thread( () -> moBIE.getViewManager().getSliceViewer() diff --git a/src/test/java/examples/OpenPlatybrowser.java b/src/test/java/examples/OpenPlatybrowser.java index 3dfbaa34b..ebf48245b 100644 --- a/src/test/java/examples/OpenPlatybrowser.java +++ b/src/test/java/examples/OpenPlatybrowser.java @@ -41,7 +41,9 @@ public static void main( String[] args ) throws IOException final ImageJ imageJ = new ImageJ(); imageJ.ui().showUI(); - final MoBIE moBIE = new MoBIE( "https://github.com/mobie/covid-if-project", - MoBIESettings.settings().gitProjectBranch( "main" ).view( "default" ) ); + final MoBIE moBIE = new MoBIE( "https://github.com/mobie/platybrowser-project", + MoBIESettings.settings() + .gitProjectBranch( "main" ) + .view( "default" ) ); } }