diff --git a/pom.xml b/pom.xml index 77836bfc..8bbeade9 100644 --- a/pom.xml +++ b/pom.xml @@ -135,14 +135,16 @@ 1.0.2 ${n5-zstandard.version} - 9.1.2 + 9.1.0 10.4.13 1.0.0-beta-34 - 0.41 - 0.41 + 4.0.1 - 3.0.4 + + + 3.0.3 @@ -197,7 +199,7 @@ ${bigwarp_fiji.version} - + diff --git a/src/main/java/bdv/util/RAIHelper.java b/src/main/java/bdv/util/RAIHelper.java index fcf8c086..69ce341a 100644 --- a/src/main/java/bdv/util/RAIHelper.java +++ b/src/main/java/bdv/util/RAIHelper.java @@ -41,7 +41,6 @@ import net.imglib2.img.cell.CellGrid; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.ARGBType; -import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.GenericByteType; import net.imglib2.type.numeric.integer.GenericIntType; import net.imglib2.type.numeric.integer.GenericLongType; @@ -49,10 +48,7 @@ import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.Intervals; -import net.imglib2.util.Util; import net.imglib2.view.Views; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import static net.imglib2.img.basictypeaccess.AccessFlags.VOLATILE; import static net.imglib2.type.PrimitiveType.BYTE; @@ -69,57 +65,52 @@ public class RAIHelper { - private static Logger logger = LoggerFactory.getLogger(RAIHelper.class); - - @SuppressWarnings({ "unchecked", "rawtypes" }) public static > RandomAccessibleInterval - wrapAsVolatileCachedCellImg(final RandomAccessibleInterval source, - final int[] blockSize, Object objectSource, int timepoint, int level) + wrapAsVolatileCachedCellImg(final RandomAccessibleInterval source, + final int[] blockSize, Object objectSource, int timepoint, int level, T type) { final long[] dimensions = Intervals.dimensionsAsLongArray(source); final CellGrid grid = new CellGrid(dimensions, blockSize); final Caches.RandomAccessibleLoader loader = - new Caches.RandomAccessibleLoader<>(Views.zeroMin(source)); - - final T type = Util.getTypeFromInterval(source); + new Caches.RandomAccessibleLoader<>(Views.zeroMin(source)); final CachedCellImg img; final Cache> cache = new GlobalLoaderCache(objectSource, - timepoint, level).withLoader(LoadedCellCacheLoader.get(grid, loader, type, + timepoint, level).withLoader(LoadedCellCacheLoader.get(grid, loader, type, AccessFlags.setOf(VOLATILE))); if (GenericByteType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get( - BYTE, AccessFlags.setOf(VOLATILE))); + BYTE, AccessFlags.setOf(VOLATILE))); } else if (GenericShortType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get( - SHORT, AccessFlags.setOf(VOLATILE))); + SHORT, AccessFlags.setOf(VOLATILE))); } else if (GenericIntType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(INT, - AccessFlags.setOf(VOLATILE))); + AccessFlags.setOf(VOLATILE))); } else if (GenericLongType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get( - LONG, AccessFlags.setOf(VOLATILE))); + LONG, AccessFlags.setOf(VOLATILE))); } else if (FloatType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get( - FLOAT, AccessFlags.setOf(VOLATILE))); + FLOAT, AccessFlags.setOf(VOLATILE))); } else if (DoubleType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get( - DOUBLE, AccessFlags.setOf(VOLATILE))); + DOUBLE, AccessFlags.setOf(VOLATILE))); } else if (ARGBType.class.isInstance(type)) { img = new CachedCellImg(grid, type, cache, ArrayDataAccessFactory.get(INT, - AccessFlags.setOf(VOLATILE))); + AccessFlags.setOf(VOLATILE))); } else { - img = null; + throw new UnsupportedOperationException("Cannot resample RAI (wrapAsVolatileCachedCellImg) of pixel type "+type.getClass().getName()); } return img; diff --git a/src/main/java/bdv/util/ResampledSource.java b/src/main/java/bdv/util/ResampledSource.java index ea8794d1..ab18b7f8 100644 --- a/src/main/java/bdv/util/ResampledSource.java +++ b/src/main/java/bdv/util/ResampledSource.java @@ -256,7 +256,7 @@ public Interpolation originInterpolation() { } @Override - public RandomAccessibleInterval getSource(int t, int level) { + public RandomAccessibleInterval getSource(int t, int level) { // TODO: shouldn't this be synchronized ? if (cache) { if (!cachedRAIs.containsKey(t)) { cachedRAIs.put(t, new ConcurrentHashMap<>()); @@ -275,7 +275,7 @@ public RandomAccessibleInterval getSource(int t, int level) { .dimension(2); cachedRAIs.get(t).put(level, RAIHelper.wrapAsVolatileCachedCellImg( - nonCached, blockSize, this, t, level)); + nonCached, blockSize, this, t, level, this.getType())); } return cachedRAIs.get(t).get(level); } diff --git a/src/main/java/sc/fiji/bdvpg/bdv/navigate/RayCastPositionerSliderAdder.java b/src/main/java/sc/fiji/bdvpg/bdv/navigate/RayCastPositionerSliderAdder.java index 6d155c21..5384f658 100644 --- a/src/main/java/sc/fiji/bdvpg/bdv/navigate/RayCastPositionerSliderAdder.java +++ b/src/main/java/sc/fiji/bdvpg/bdv/navigate/RayCastPositionerSliderAdder.java @@ -114,41 +114,43 @@ public void run() { bdvh.getViewerPanel().revalidate(); slider.addChangeListener((e) -> { - if (zLocations.size() > 0) { - JSlider slider = (JSlider) e.getSource(); - int newValue = slider.getValue(); - // Plane : slider.getValue() / slider.getMaximum() - if ((currentPosition != newValue) && (newValue != -1)) { - // User slider action: needs update of viewer from currentPosition to - // newValue - currentPosition = newValue; - double shiftZ = zLocations.get(currentPosition); - // Need to shift z by shiftZ - - AffineTransform3D at3d = new AffineTransform3D(); - - // Change the position of the viewer with the new offset - bdvh.getViewerPanel().state().getViewerTransform(at3d); - double[] currentCenter = BdvHandleHelper - .getWindowCentreInCalibratedUnits(bdvh); - double[] newCenter = new double[3]; - newCenter[0] = currentCenter[0] + lastDirection.getDoublePosition(0) * - shiftZ; - newCenter[1] = currentCenter[1] + lastDirection.getDoublePosition(1) * - shiftZ; - newCenter[2] = currentCenter[2] + lastDirection.getDoublePosition(2) * - shiftZ; - bdvh.getViewerPanel().state().setViewerTransform(BdvHandleHelper - .getViewerTransformWithNewCenter(bdvh, newCenter)); - - } // else: Bdv user movement: no update required - + synchronized (RayCastPositionerSliderAdder.this) { + if (zLocations.size() > 0) { + JSlider slider = (JSlider) e.getSource(); + int newValue = slider.getValue(); + // Plane : slider.getValue() / slider.getMaximum() + if ((currentPosition != newValue) && (newValue != -1)) { + // User slider action: needs update of viewer from currentPosition to + // newValue + currentPosition = newValue; + double shiftZ = zLocations.get(currentPosition); + // Need to shift z by shiftZ + + AffineTransform3D at3d = new AffineTransform3D(); + + // Change the position of the viewer with the new offset + bdvh.getViewerPanel().state().getViewerTransform(at3d); + double[] currentCenter = BdvHandleHelper + .getWindowCentreInCalibratedUnits(bdvh); + double[] newCenter = new double[3]; + newCenter[0] = currentCenter[0] + lastDirection.getDoublePosition(0) * + shiftZ; + newCenter[1] = currentCenter[1] + lastDirection.getDoublePosition(1) * + shiftZ; + newCenter[2] = currentCenter[2] + lastDirection.getDoublePosition(2) * + shiftZ; + bdvh.getViewerPanel().state().setViewerTransform(BdvHandleHelper + .getViewerTransformWithNewCenter(bdvh, newCenter)); + + } // else: Bdv user movement: no update required + + } } }); } - public void updatePositions() { + public synchronized void updatePositions() { // Find origin and direction of ray - center of the bdv window double[] c = BdvHandleHelper.getWindowCentreInCalibratedUnits(bdvh);