@Test public void testWeirdSpatialImageCancelsPlugin() throws Exception { final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class); when(MOCK_UI.dialogPrompt(anyString(), anyString(), any(), any())) .thenReturn(mockPrompt); final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X); final DefaultLinearAxis cAxis = new DefaultLinearAxis(Axes.CHANNEL); final Img<DoubleType> img = ArrayImgs.doubles(5, 5); final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis, cAxis); final CommandModule module = command().run( ElementFractionWrapper.class, true, "inputImage", imgPlus).get(); assertTrue("A non 2D and 3D image should have cancelled the plugin", module .isCanceled()); assertEquals("Cancel reason is incorrect", CommonMessages.WEIRD_SPATIAL, module.getCancelReason()); verify(MOCK_UI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(), any()); }
@Override public void run() { statusService.showStatus("Element fraction: initializing"); findSubspaces(inputImage); prepareResultDisplay(); final String name = inputImage.getName(); for (int i = 0; i < subspaces.size(); i++) { final Subspace<BitType> subspace = subspaces.get(i); statusService.showStatus("Element fraction: calculating subspace #" + (i + 1)); statusService.showProgress(i, subspaces.size()); final IterableInterval<BitType> interval = Views.flatIterable( subspace.interval); final double foregroundSize = opService.stats().sum(interval) .getRealDouble() * elementSize; final double totalSize = interval.size() * elementSize; final double ratio = foregroundSize / totalSize; final String suffix = subspace.toString(); final String label = suffix.isEmpty() ? name : name + " " + suffix; addResults(label, foregroundSize, totalSize, ratio); } resultsTable = SharedTable.getTable(); reportUsage(); }
ElementFractionWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Element fraction: initializing"); findSubspaces(inputImage); prepareResultDisplay(); final String name = inputImage.getName(); for (int i = 0; i < subspaces.size(); i++) { final Subspace<BitType> subspace = subspaces.get(i); statusService.showStatus("Element fraction: calculating subspace #" + (i + 1)); statusService.showProgress(i, subspaces.size()); final IterableInterval<BitType> interval = Views.flatIterable( subspace.interval); final double foregroundSize = opService.stats().sum(interval) .getRealDouble() * elementSize; final double totalSize = interval.size() * elementSize; final double ratio = foregroundSize / totalSize; final String suffix = subspace.toString(); final String label = suffix.isEmpty() ? name : name + " " + suffix; addResults(label, foregroundSize, totalSize, ratio); } resultsTable = SharedTable.getTable(); reportUsage(); } }
ElementFractionWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Element fraction: initializing"); findSubspaces(inputImage); prepareResultDisplay(); final String name = inputImage.getName(); for (int i = 0; i < subspaces.size(); i++) { final Subspace<BitType> subspace = subspaces.get(i); statusService.showStatus("Element fraction: calculating subspace #" + (i + 1)); statusService.showProgress(i, subspaces.size()); final IterableInterval<BitType> interval = Views.flatIterable( subspace.interval); final double foregroundSize = opService.stats().sum(interval) .getRealDouble() * elementSize; final double totalSize = interval.size() * elementSize; final double ratio = foregroundSize / totalSize; final String suffix = subspace.toString(); final String label = suffix.isEmpty() ? name : name + " " + suffix; addResults(label, foregroundSize, totalSize, ratio); } resultsTable = SharedTable.getTable(); reportUsage(); }  }
ElementFractionWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Element fraction: initializing"); findSubspaces(inputImage); prepareResultDisplay(); final String name = inputImage.getName(); for (int i = 0; i < subspaces.size(); i++) { final Subspace<BitType> subspace = subspaces.get(i); statusService.showStatus("Element fraction: calculating subspace #" + (i + 1)); statusService.showProgress(i, subspaces.size()); final IterableInterval<BitType> interval = Views.flatIterable( subspace.interval); final double foregroundSize = opService.stats().sum(interval) .getRealDouble() * elementSize; final double totalSize = interval.size() * elementSize; final double ratio = foregroundSize / totalSize; final String suffix = subspace.toString(); final String label = suffix.isEmpty() ? name : name + " " + suffix; addResults(label, foregroundSize, totalSize, ratio); } resultsTable = SharedTable.getTable(); reportUsage(); }  @Override void run(); }
ElementFractionWrapper extends BoneJCommand { @Override public void run() { statusService.showStatus("Element fraction: initializing"); findSubspaces(inputImage); prepareResultDisplay(); final String name = inputImage.getName(); for (int i = 0; i < subspaces.size(); i++) { final Subspace<BitType> subspace = subspaces.get(i); statusService.showStatus("Element fraction: calculating subspace #" + (i + 1)); statusService.showProgress(i, subspaces.size()); final IterableInterval<BitType> interval = Views.flatIterable( subspace.interval); final double foregroundSize = opService.stats().sum(interval) .getRealDouble() * elementSize; final double totalSize = interval.size() * elementSize; final double ratio = foregroundSize / totalSize; final String suffix = subspace.toString(); final String label = suffix.isEmpty() ? name : name + " " + suffix; addResults(label, foregroundSize, totalSize, ratio); } resultsTable = SharedTable.getTable(); reportUsage(); }  @Override void run();  }