• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NewImage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ij.gui.NewImage的典型用法代码示例。如果您正苦于以下问题:Java NewImage类的具体用法?Java NewImage怎么用?Java NewImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NewImage类属于ij.gui包,在下文中一共展示了NewImage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testNoImageWhenNoSkeletonisation

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Test that no skeleton image pops open, when the input is already a skeleton
 * (or skeletonisation didn't change it)
 */
@Test
public void testNoImageWhenNoSkeletonisation() throws Exception {
	// SETUP
	final UserInterface mockUI = mock(UserInterface.class);
	IMAGE_J.ui().setDefaultUI(mockUI);
	final ImagePlus pixel = NewImage.createByteImage("Test", 3, 3, 1,
		FILL_BLACK);
	pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		AnalyseSkeletonWrapper.class, true, "inputImage", pixel,
		"pruneCycleMethod", "None").get();

	// VERIFY
	assertFalse(
		"Sanity check failed: plugin cancelled before image could have been shown",
		module.isCanceled());
	verify(mockUI, after(250).never()).show(any(ImagePlus.class));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:25,代码来源:AnalyseSkeletonWrapperTest.java


示例2: testSkeletonImageWhenSkeletonised

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Test that the skeleton is displayed, when the input image gets skeletonised
 */
@Test
public void testSkeletonImageWhenSkeletonised() throws Exception {
	final UserInterface mockUI = mock(UserInterface.class);
	IMAGE_J.ui().setDefaultUI(mockUI);
	final ImagePlus square = NewImage.createByteImage("Test", 4, 4, 1,
		FILL_BLACK);
	square.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
	square.getStack().getProcessor(1).set(1, 2, (byte) 0xFF);
	square.getStack().getProcessor(1).set(2, 1, (byte) 0xFF);
	square.getStack().getProcessor(1).set(2, 2, (byte) 0xFF);

	// EXECUTE
	CommandModule module = IMAGE_J.command().run(AnalyseSkeletonWrapper.class,
		true, "inputImage", square, "pruneCycleMethod", "None").get();

	// VERIFY
	assertFalse(
		"Sanity check failed: plugin cancelled before image could have been shown",
		module.isCanceled());
	verify(mockUI, timeout(1000)).show(any(ImagePlus.class));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:25,代码来源:AnalyseSkeletonWrapperTest.java


示例3: testResultsTableShortestPathFalse

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Results table should have different number of columns when option
 * "calculateShortestPath" is false see {@link #testResultsTable()}
 */
@Test
public void testResultsTableShortestPathFalse() throws Exception {
	// SETUP
	final ImagePlus pixel = NewImage.createByteImage("Test", 4, 4, 1,
		FILL_BLACK);
	pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		AnalyseSkeletonWrapper.class, true, "inputImage", pixel,
		"pruneCycleMethod", "None", "calculateShortestPath", false).get();

	// VERIFY
	@SuppressWarnings("unchecked")
	final Table<DefaultColumn<String>, String> table =
		(Table<DefaultColumn<String>, String>) module.getOutput("resultsTable");
	assertNotNull(table);
	assertEquals("Results table has wrong number of columns", 11, table.size());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:24,代码来源:AnalyseSkeletonWrapperTest.java


示例4: testAdditionalResultsTableNullWhenVerboseFalse

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testAdditionalResultsTableNullWhenVerboseFalse()
	throws Exception
{
	// SETUP
	final ImagePlus pixel = NewImage.createByteImage("Test", 4, 4, 1,
		FILL_BLACK);
	pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		AnalyseSkeletonWrapper.class, true, "inputImage", pixel,
		"pruneCycleMethod", "None", "verbose", false).get();

	// VERIFY
	assertNull(module.getOutput("verboseTable"));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:AnalyseSkeletonWrapperTest.java


示例5: testNullROIManagerCancelsPlugin

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testNullROIManagerCancelsPlugin() throws Exception {
	// SETUP
	final UserInterface mockUI = CommonWrapperTests.mockUIService(IMAGE_J);
	final ImagePlus imagePlus = NewImage.createByteImage("", 5, 5, 5, 1);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(ThicknessWrapper.class,
		true, "inputImage", imagePlus, "cropToRois", true).get();

	// VERIFY
	assertTrue("No ROI Manager should have cancelled the plugin", module
		.isCanceled());
	assertEquals("Cancel reason is incorrect",
		"Can't crop without valid ROIs in the ROIManager", module
			.getCancelReason());
	verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
		any());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:ThicknessWrapperTest.java


示例6: testNullROIManagerCancelsPlugin

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testNullROIManagerCancelsPlugin() throws Exception {
	// SETUP
	final UserInterface mockUI = CommonWrapperTests.mockUIService(IMAGE_J);
	final ImagePlus imagePlus = NewImage.createImage("", 5, 5, 5, 8, 1);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		FitEllipsoidWrapper.class, true, "inputImage", imagePlus).get();

	// VERIFY
	assertTrue("No ROI Manager should have cancelled the plugin", module
		.isCanceled());
	assertTrue("Cancel reason is incorrect", module.getCancelReason()
		.startsWith("Please populate ROI Manager with at least " +
			QUADRIC_TERMS));
	verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
		any());
   }
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:FitEllipsoidWrapperTest.java


示例7: testRun

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testRun() throws Exception {
	// SETUP
	final String expectedTitle = "Skeleton of Test";
	final ImagePlus imagePlus = NewImage.createImage("Test", 5, 5, 5, 8, 1);
	final Calibration calibration = new Calibration();
	calibration.setUnit("my unit");
	imagePlus.setCalibration(calibration);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(SkeletoniseWrapper.class,
		true, "inputImage", imagePlus).get();

	// VERIFY
	final ImagePlus skeleton = (ImagePlus) module.getOutput("skeleton");
	assertNotNull("Skeleton image should not be null", skeleton);
	assertEquals("Skeleton has wrong title", expectedTitle, skeleton
		.getTitle());
	assertEquals("Skeleton should have same calibration", "my unit", skeleton
		.getCalibration().getUnit());
       assertNotSame("Original image should not have been overwritten",
		imagePlus, skeleton);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:24,代码来源:SkeletoniseWrapperTest.java


示例8: testNoImageWhenNoSkeletonisation

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Test that no skeleton image pops open, when the input is already a skeleton
 * (or skeletonisation didn't change it)
 */
@Test
public void testNoImageWhenNoSkeletonisation() throws Exception {
	// SETUP
	final UserInterface mockUI = mock(UserInterface.class);
	doNothing().when(mockUI).show(any(ImagePlus.class));
	IMAGE_J.ui().setDefaultUI(mockUI);
	final ImagePlus pixel = NewImage.createByteImage("Test", 3, 3, 1,
		FILL_BLACK);
	pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		IntertrabecularAngleWrapper.class, true, "inputImage", pixel).get();

	// VERIFY
	assertEquals(
		"Sanity check failed: plugin cancelled before image could have been shown",
		NO_RESULTS_MSG, module.getCancelReason());
	verify(mockUI, after(250).never()).show(any(ImagePlus.class));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:25,代码来源:IntertrabecularAngleWrapperTest.java


示例9: testSkeletonImageWhenSkeletonised

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Test that the skeleton is displayed, when the input image gets skeletonised
 */
@Test
public void testSkeletonImageWhenSkeletonised() throws Exception {
	// SETUP
	final UserInterface mockUI = mock(UserInterface.class);
	doNothing().when(mockUI).show(any(ImagePlus.class));
	IMAGE_J.ui().setDefaultUI(mockUI);
	final ImagePlus square = NewImage.createByteImage("Test", 4, 4, 1,
		FILL_BLACK);
	square.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
	square.getStack().getProcessor(1).set(1, 2, (byte) 0xFF);
	square.getStack().getProcessor(1).set(2, 1, (byte) 0xFF);
	square.getStack().getProcessor(1).set(2, 2, (byte) 0xFF);

	// EXECUTE
	IMAGE_J.command().run(IntertrabecularAngleWrapper.class, true, "inputImage",
		square).get();

	// VERIFY
	verify(mockUI, timeout(1000)).show(any(ImagePlus.class));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:24,代码来源:IntertrabecularAngleWrapperTest.java


示例10: testNoResultsCancelsPlugin

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testNoResultsCancelsPlugin() throws Exception {
	// SETUP
	final UserInterface mockUI = CommonWrapperTests.mockUIService(IMAGE_J);
	final ImagePlus pixel = NewImage.createByteImage("Test", 3, 3, 1,
		FILL_BLACK);
	pixel.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		IntertrabecularAngleWrapper.class, true, "inputImage", pixel).get();

	// VERIFY
	assertTrue("Plugin should have cancelled", module.isCanceled());
	assertEquals("Cancel reason is incorrect", NO_RESULTS_MSG, module
		.getCancelReason());
	verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
		any());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:IntertrabecularAngleWrapperTest.java


示例11: testMultipleGraphsShowsWarningDialog

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testMultipleGraphsShowsWarningDialog() throws Exception {
	// SETUP
	final UserInterface mockUI = mock(UserInterface.class);
	final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class);
	when(mockUI.dialogPrompt(startsWith("Image has multiple skeletons"),
		anyString(), eq(WARNING_MESSAGE), any())).thenReturn(mockPrompt);
	IMAGE_J.ui().setDefaultUI(mockUI);
	final ImagePlus pixels = NewImage.createByteImage("Test", 4, 4, 1,
		FILL_BLACK);
	pixels.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
	pixels.getStack().getProcessor(1).set(3, 3, (byte) 0xFF);

	// EXECUTE
	IMAGE_J.command().run(IntertrabecularAngleWrapper.class, true, "inputImage",
		pixels).get();

	// VERIFY
	verify(mockUI, timeout(1000)).dialogPrompt(startsWith(
		"Image has multiple skeletons"), anyString(), eq(WARNING_MESSAGE), any());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:22,代码来源:IntertrabecularAngleWrapperTest.java


示例12: createImage

import ij.gui.NewImage; //导入依赖的package包/类
/** Creates a new imagePlus. <code>Type</code> should contain "8-bit", "16-bit", "32-bit" or "RGB". 
	 In addition, it can contain "white", "black" or "ramp" (the default is "white"). <code>Width</code> 
 	and <code>height</code> specify the width and height of the image in pixels.  
 	<code>Depth</code> specifies the number of stack slices. */
 public static ImagePlus createImage(String title, String type, int width, int height, int depth) {
	type = type.toLowerCase(Locale.US);
	int bitDepth = 8;
	if (type.indexOf("16")!=-1) bitDepth = 16;
	if (type.indexOf("24")!=-1||type.indexOf("rgb")!=-1) bitDepth = 24;
	if (type.indexOf("32")!=-1) bitDepth = 32;
	int options = NewImage.FILL_WHITE;
	if (bitDepth==16 || bitDepth==32)
		options = NewImage.FILL_BLACK;
	if (type.indexOf("white")!=-1)
		options = NewImage.FILL_WHITE;
	else if (type.indexOf("black")!=-1)
		options = NewImage.FILL_BLACK;
	else if (type.indexOf("ramp")!=-1)
		options = NewImage.FILL_RAMP;
	options += NewImage.CHECK_AVAILABLE_MEMORY;
	return NewImage.createImage(title, width, height, depth, bitDepth, options);
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:23,代码来源:IJJazzOMR.java


示例13: createTestImage

import ij.gui.NewImage; //导入依赖的package包/类
private ImagePlus createTestImage()
{
	final ImagePlus imp = NewImage.createByteImage( "Test image", 100, 100, 1, NewImage.FILL_BLACK );
	final ImageProcessor ip = imp.getProcessor();
	ip.setRoi( new Rectangle( 10, 10, 10, 10 ) );
	ip.setColor( 1 );
	ip.fill();
	ip.setRoi( new Rectangle( 20, 20, 10, 20 ) );
	ip.setColor( 2 );
	ip.fill();
	ip.setRoi( new Rectangle( 40, 40, 10, 30 ) );
	ip.setColor( 3 );
	ip.fill();

	return imp;
}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:17,代码来源:LabelingExample.java


示例14: produceNoiseImage

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Creates a noisy image that is created by repeatedly adding points
 * with random intensity to the canvas. That way it tries to mimic the
 * way a microscope produces images.
 *
 * @param <T> The wanted output type.
 * @param width The image width.
 * @param height The image height.
 * @param dotSize The size of the dots.
 * @param numDots The number of dots.
 * @param smoothingSigma The two dimensional sigma for smoothing.
 * @return The noise image.
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> produceNoiseImage(int width,
		int height, float dotSize, int numDots) {
	/* For now (probably until ImageJ2 is out) we use an
	 * ImageJ image to draw circles.
	 */
	int options = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY;
        ImagePlus img = NewImage.createByteImage("Noise", width, height, 1, options);
	ImageProcessor imp = img.getProcessor();

	float dotRadius = dotSize * 0.5f;
	int dotIntSize = (int) dotSize;

	for (int i=0; i < numDots; i++) {
		int x = (int) (Math.random() * width - dotRadius);
		int y = (int) (Math.random() * height - dotRadius);
		imp.setColor(Color.WHITE);
		imp.fillOval(x, y, dotIntSize, dotIntSize);
	}
	// we changed the data, so update it
	img.updateImage();
	// create the new image
	RandomAccessibleInterval<T> noiseImage = ImagePlusAdapter.wrap(img);

	return noiseImage;
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:39,代码来源:TestImageAccessor.java


示例15: createRectengularMaskImage

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Creates a mask image with a black background and a white
 * rectangular foreground.
 *
 * @param width The width of the result image.
 * @param height The height of the result image.
 * @param offset The offset of the rectangular mask.
 * @param size The size of the rectangular mask.
 * @return A black image with a white rectangle on it.
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> createRectengularMaskImage(
		long width, long height, long[] offset, long[] size) {
	/* For now (probably until ImageJ2 is out) we use an
	 * ImageJ image to draw lines.
	 */
	int options = NewImage.FILL_BLACK + NewImage.CHECK_AVAILABLE_MEMORY;
        ImagePlus img = NewImage.createByteImage("Noise", (int)width, (int)height, 1, options);
	ImageProcessor imp = img.getProcessor();
	imp.setColor(Color.WHITE);
	Roi rect = new Roi(offset[0], offset[1], size[0], size[1]);

	imp.fill(rect);
	// we changed the data, so update it
	img.updateImage();

	return ImagePlusAdapter.wrap(img);
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:28,代码来源:TestImageAccessor.java


示例16: createHistogramImage

import ij.gui.NewImage; //导入依赖的package包/类
void createHistogramImage(String title) {
	if (title == null)
		title = "Histogram Plot";
	hist_img  = NewImage.createByteImage(title,width,height,1,0);
	ip = hist_img.getProcessor();
       ip.setValue(BACKGROUND);
       ip.fill();
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:9,代码来源:HistogramPlot.java


示例17: testAdditionalResultsTable

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testAdditionalResultsTable() throws Exception {
	// SETUP
	final ImagePlus line = NewImage.createByteImage("Test", 3, 3, 1,
		FILL_BLACK);
	line.getStack().getProcessor(1).set(1, 1, (byte) 0xFF);
	line.getStack().getProcessor(1).set(2, 2, (byte) 0xFF);
	final String length = String.valueOf(Math.sqrt(2.0));
	final String[] expectedHeaders = { "# Skeleton", "# Branch",
		"Branch length", "V1 x", "V1 y", "V1 z", "V2 x", "V2 y", "V2 z",
		"Euclidean distance", "running average length",
		"average intensity (inner 3rd)", "average intensity" };
	final String[] expectedValues = { "1", "1", length, "1", "1", "0", "2", "2",
		"0", length, length, "255.0", "255.0" };

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(
		AnalyseSkeletonWrapper.class, true, "inputImage", line,
		"pruneCycleMethod", "None", "verbose", true, "pruneEnds", false).get();

	// VERIFY
	final DefaultGenericTable table = (DefaultGenericTable) module.getOutput(
		"verboseTable");
	assertNotNull(table);
	assertEquals("Results table has wrong number of columns",
		expectedHeaders.length, table.size());
	for (int i = 0; i < table.size(); i++) {
		final PrimitiveColumn<?, ?> column = (PrimitiveColumn<?, ?>) table.get(i);
		assertEquals("Column has incorrect header", expectedHeaders[i], column
			.getHeader());
		assertEquals("Column has wrong number of rows", 1, column.size());
		assertEquals("Column has an incorrect value", expectedValues[i], String
			.valueOf(column.get(0)));
	}
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:36,代码来源:AnalyseSkeletonWrapperTest.java


示例18: testResults

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testResults() throws Exception {
	// SETUP
	final ImagePlus imagePlus = NewImage.createByteImage("", 2, 2, 2, 1);
	final Calibration calibration = new Calibration();
	calibration.setUnit("mm");
	imagePlus.setCalibration(calibration);
	final String[] expectedHeaders = { "Tb.Th Mean (mm)", "Tb.Th Std Dev (mm)",
		"Tb.Th Max (mm)", "Tb.Sp Mean (mm)", "Tb.Sp Std Dev (mm)",
		"Tb.Sp Max (mm)" };
	final String[][] expectedValues = { { "", "NaN" }, { "", "NaN" }, { "",
		"NaN" }, { "10.392304420471191", "" }, { "0.0", "" }, {
			"10.392304420471191", "" } };

	// EXECUTE
	final CommandModule module = IMAGE_J.command().run(ThicknessWrapper.class,
		true, "inputImage", imagePlus, "mapChoice", "Both", "maskArtefacts",
		false, "cropToRois", false, "showMaps", false).get();

	// VERIFY
	@SuppressWarnings("unchecked")
	final Table<DefaultColumn<String>, String> table =
		(Table<DefaultColumn<String>, String>) module.getOutput("resultsTable");
	assertNotNull(table);
	assertEquals("Results table has wrong number of columns", 7, table.size());
	for (int i = 0; i < 6; i++) {
		final DefaultColumn<String> column = table.get(i + 1);
		assertEquals(expectedHeaders[i], column.getHeader());
		for (int j = 0; j < 2; j++) {
			assertEquals("Column has an incorrect value", expectedValues[i][j],
				column.getValue(j));
		}
	}
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:35,代码来源:ThicknessWrapperTest.java


示例19: testMapImages

import ij.gui.NewImage; //导入依赖的package包/类
@Test
public void testMapImages() throws Exception {
	final ImagePlus imagePlus = NewImage.createByteImage("", 2, 2, 2, 1);

	CommandModule module = IMAGE_J.command().run(ThicknessWrapper.class, true,
		"inputImage", imagePlus, "mapChoice", "Both", "showMaps", false).get();
	assertNull(module.getOutput("trabecularMap"));
	assertNull(module.getOutput("spacingMap"));

	module = IMAGE_J.command().run(ThicknessWrapper.class, true, "inputImage",
		imagePlus, "mapChoice", "Trabecular thickness", "showMaps", true).get();
	assertNotNull(module.getOutput("trabecularMap"));
	assertNull(module.getOutput("spacingMap"));

	module = IMAGE_J.command().run(ThicknessWrapper.class, true, "inputImage",
		imagePlus, "mapChoice", "Trabecular spacing", "showMaps", true).get();
	assertNull(module.getOutput("trabecularMap"));
	assertNotNull(module.getOutput("spacingMap"));

	module = IMAGE_J.command().run(ThicknessWrapper.class, true, "inputImage",
		imagePlus, "mapChoice", "Both", "showMaps", true).get();
	final ImagePlus trabecularMap = (ImagePlus) module.getOutput(
		"trabecularMap");
	final ImagePlus spacingMap = (ImagePlus) module.getOutput("spacingMap");
	assertNotNull(trabecularMap);
	assertNotNull(spacingMap);
       assertNotSame("Original image should not have been overwritten",
		imagePlus, trabecularMap);
       assertNotSame("Original image should not have been overwritten",
		imagePlus, spacingMap);
       assertNotSame("Map images should be independent", trabecularMap, spacingMap);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:33,代码来源:ThicknessWrapperTest.java


示例20: testAnisotropyWarning

import ij.gui.NewImage; //导入依赖的package包/类
/**
 * Tests that running the given command with an anisotropic {@link ImagePlus}
 * shows a warning dialog that can be used to cancel the plugin
 */
public static <C extends Command> void testAnisotropyWarning(
		final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
	// SETUP
	final UserInterface mockUI = mock(UserInterface.class);
	final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class);
	when(mockPrompt.prompt()).thenReturn(DialogPrompt.Result.CANCEL_OPTION);
	when(mockUI.dialogPrompt(startsWith("The image is anisotropic"),
			anyString(), eq(WARNING_MESSAGE), any())).thenReturn(mockPrompt);
	imageJ.ui().setDefaultUI(mockUI);
	final Calibration calibration = new Calibration();
	calibration.pixelWidth = 300;
	calibration.pixelHeight = 1;
	calibration.pixelDepth = 1;
	final ImagePlus imagePlus = NewImage.createByteImage("", 5, 5, 5, 1);
	imagePlus.setCalibration(calibration);

	// EXECUTE
	final CommandModule module = imageJ.command().run(commandClass, true,
			"inputImage", imagePlus).get();

	// VERIFY
	verify(mockUI, timeout(1000).times(1)).dialogPrompt(startsWith(
			"The image is anisotropic"), anyString(), eq(WARNING_MESSAGE), any());
	assertTrue("Pressing cancel on warning dialog should have cancelled plugin",
			module.isCanceled());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:32,代码来源:CommonWrapperTests.java



注:本文中的ij.gui.NewImage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SoundMediaHeaderBox类代码示例发布时间:2022-05-22
下一篇:
Java Parser类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap