当前位置: 首页>>代码示例>>Java>>正文


Java Roi.setName方法代码示例

本文整理汇总了Java中ij.gui.Roi.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Roi.setName方法的具体用法?Java Roi.setName怎么用?Java Roi.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ij.gui.Roi的用法示例。


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

示例1: testGetLimitsReturnsNullIfThereAreNoValidRois

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetLimitsReturnsNullIfThereAreNoValidRois() throws Exception {
	final Roi badXYRoi = new Roi(-100, -100, 10, 10);
	badXYRoi.setName("0001-0000-0001");

	final Roi badSliceRoi = new Roi(10, 10, 30, 60);
	badSliceRoi.setName("9999-0000-0001"); // slice #9999

	final Roi badRois[] = { badXYRoi, badSliceRoi };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(badRois);
	when(mockRoiManager.getCount()).thenReturn(badRois.length);

	final int limitsResult[] = RoiMan.getLimits(mockRoiManager, testStack);
	assertNull("Limits should be null if there are no valid ROIs", limitsResult);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:RoiManTest.java

示例2: testGetLimitsAccountsForRoiActiveOnAllSlides

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetLimitsAccountsForRoiActiveOnAllSlides() throws Exception {
	final Roi roi = new Roi(10, 10, 30, 60);
	roi.setName("0001-0000-0001");
	final Roi allActive = new Roi(80, 80, 10, 10);
	allActive.setName(""); // name can't be null
	final Roi rois[] = { roi, allActive };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);
	when(mockRoiManager.getCount()).thenReturn(rois.length);

	final int limitsResult[] = RoiMan.getLimits(mockRoiManager, testStack);

	assertEquals("Limits should start from the first slide", 1, limitsResult[MIN_Z_INDEX]);
	assertEquals("Limits should end on the last slide", testStack.getSize(), limitsResult[MAX_Z_INDEX]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:RoiManTest.java

示例3: testGetLimitsCropsTooLargeRois

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetLimitsCropsTooLargeRois() throws Exception {
	final int STACK_WIDTH = testStack.getWidth();
	final int STACK_HEIGHT = testStack.getHeight();
	final Roi hugeRoi = new Roi(-100, -100, STACK_WIDTH + 100, STACK_HEIGHT + 100);
	hugeRoi.setName("0001-0000-0001");
	final Roi rois[] = { hugeRoi };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);
	when(mockRoiManager.getCount()).thenReturn(rois.length);

	final int limitsResult[] = RoiMan.getLimits(mockRoiManager, testStack);
	assertEquals("Limits minimum x is incorrect", 0, limitsResult[0]);
	assertEquals("Limits maximum x is incorrect", STACK_WIDTH, limitsResult[1]);
	assertEquals("Limits minimum y is incorrect", 0, limitsResult[2]);
	assertEquals("Limits maximum y is incorrect", STACK_HEIGHT, limitsResult[3]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:19,代码来源:RoiManTest.java

示例4: testGetLimitsAllActiveSlide

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetLimitsAllActiveSlide() throws Exception {
	// Mock a RoiManager with Rois
	final Roi roi = new Roi(0, 0, 10, 10);
	final Roi allActive = new Roi(0, 0, 10, 10);
	final Roi rois[] = { roi, allActive };
	roi.setName("0001-0000-0001");
	allActive.setName("ALL_ACTIVE");
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);

	Optional<int[]> result = RoiManagerUtil.getLimits(MOCK_ROI_MANAGER,
		testStack);
	assertTrue(result.isPresent());
	final int[] limits = result.get();
	assertEquals(1, limits[MIN_Z_INDEX]);
	assertEquals(testStack.size(), limits[MAX_Z_INDEX]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:20,代码来源:RoiManagerUtilTest.java

示例5: testGetLimitsIgnoresBadRois

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetLimitsIgnoresBadRois() throws Exception {
	// Mock a RoiManager with invalid Rois
	final Roi farZRoi = new Roi(10, 10, 10, 10);
	final Roi badRoi = new Roi(-100, -100, 10, 10);
	final Roi rois[] = { farZRoi, badRoi };
	farZRoi.setName("9999-0000-0001"); // slice no == 9999
	badRoi.setName("0001-0000-0001");
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);

	Optional<int[]> result = RoiManagerUtil.getLimits(MOCK_ROI_MANAGER,
		testStack);

	assertFalse(result.isPresent());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:RoiManagerUtilTest.java

示例6: addRoisToCurrent

import ij.gui.Roi; //导入方法依赖的package包/类
public static void addRoisToCurrent (List<Roi> rois) {
	
		//RoiManager rm = RoiManager.getInstance();
		RoiManager rm = getRM();
		rm.runCommand("reset");
		
		rm.runCommand("show all");
		rm.runCommand("show all with labels");
		rm.runCommand("usenames", "true");
		
		for (Roi roi : rois) {
			if (roi != null) {					
				Roi r = roi;
//				String t = WindowManager.getCurrentImage().getTitle();
				//r.setName(j + " - " + r.getName());
				r.setName(r.getName());
				rm.addRoi(r);
				rm.select(rm.getCount()-1);  // assign newly added Roi to curr image
			}
		}	

				
		
		
	}
 
开发者ID:mekterovic,项目名称:bactimas,代码行数:26,代码来源:BridgeToRoiManager.java

示例7: testCropStack

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testCropStack() throws Exception {
	final int WIDTH = 6;
	final int HEIGHT = 3;
	final int DEPTH = 3;
	final int ROI_WIDTH = 2;
	final int ROI_HEIGHT = 2;
	final int WHITE_COUNT = 8;
	final int BINARY_WHITE = -1;
	final int BACKGROUND_COLOR = 0;
	final int BACKGROUND_COUNT = 46;

	final Roi roi1 = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	roi1.setName("0002-0000-0001");
	final Roi roi2 = new Roi(6, 3, ROI_WIDTH, ROI_HEIGHT);
	roi2.setName("0003-0000-0001");
	final Roi noColorRoi = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	noColorRoi.setName("0001-0000-0001");
	final Roi rois[] = { noColorRoi, roi1, roi2 };

	final ImagePlus image = TestDataMaker.brick(10, 10, 10);
	final ImageStack originalStack = image.getStack();

	when(mockRoiManager.getCount()).thenReturn(rois.length);
	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);

	final ImageStack resultStack = RoiMan.cropStack(mockRoiManager, originalStack, false, 0x00, 0);
	assertEquals("Cropped stack has wrong width", WIDTH, resultStack.getWidth());
	assertEquals("Cropped stack has wrong height", HEIGHT, resultStack.getHeight());
	assertEquals("Cropped stack has wrong depth", DEPTH, resultStack.getSize());

	final int foregroundCount = countColorPixels(resultStack, BINARY_WHITE);
	assertEquals("Cropped area has wrong amount of foreground color", WHITE_COUNT, foregroundCount);

	final int backgroundCount = countColorPixels(resultStack, BACKGROUND_COLOR);
	assertEquals("Cropped area has wrong amount of background color", BACKGROUND_COUNT, backgroundCount);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:39,代码来源:RoiManTest.java

示例8: testCropStackPadding

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testCropStackPadding() throws Exception {
	final int WIDTH = 6;
	final int HEIGHT = 3;
	final int DEPTH = 3;
	final int PADDING = 2;
	final int TOTAL_PADDING = 2 * PADDING;
	final int ROI_WIDTH = 2;
	final int ROI_HEIGHT = 2;

	final Roi roi1 = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	roi1.setName("0002-0000-0001");
	final Roi roi2 = new Roi(6, 3, ROI_WIDTH, ROI_HEIGHT);
	roi2.setName("0003-0000-0001");
	final Roi noColorRoi = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	noColorRoi.setName("0001-0000-0001");
	final Roi rois[] = { noColorRoi, roi1, roi2 };

	final ImagePlus image = TestDataMaker.brick(10, 10, 10);
	final ImageStack originalStack = image.getStack();

	when(mockRoiManager.getCount()).thenReturn(rois.length);
	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);

	final ImageStack paddedResultStack = RoiMan.cropStack(mockRoiManager, originalStack, false, 0x00, PADDING);
	assertEquals("Cropped stack has wrong padded width", WIDTH + TOTAL_PADDING, paddedResultStack.getWidth());
	assertEquals("Cropped stack has wrong padded height", HEIGHT + TOTAL_PADDING, paddedResultStack.getHeight());
	assertEquals("Cropped stack has wrong padded depth", DEPTH + TOTAL_PADDING, paddedResultStack.getSize());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:31,代码来源:RoiManTest.java

示例9: testCropStackFilling

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testCropStackFilling() throws Exception {
	final int TEST_COLOR_COUNT = 8;
	final byte TEST_COLOR = -1;
	final byte BACKGROUND_COLOR = 0x00;
	final int BACKGROUND_COLOR_COUNT = 46;
	final byte FILL_COLOR = 0x10;
	final int ORIGINAL_BG_COLOR_COUNT = 4;
	final int FILL_COLOR_COUNT = BACKGROUND_COLOR_COUNT - ORIGINAL_BG_COLOR_COUNT;
	final int ROI_WIDTH = 2;
	final int ROI_HEIGHT = 2;

	final Roi roi1 = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	roi1.setName("0002-0000-0001");
	final Roi roi2 = new Roi(6, 3, ROI_WIDTH, ROI_HEIGHT);
	roi2.setName("0003-0000-0001");
	final Roi noColorRoi = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	noColorRoi.setName("0001-0000-0001");
	final Roi rois[] = { noColorRoi, roi1, roi2 };

	final ImagePlus image = TestDataMaker.brick(10, 10, 10);
	final ImageStack originalStack = image.getStack();

	when(mockRoiManager.getCount()).thenReturn(rois.length);
	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);

	final ImageStack resultStack = RoiMan.cropStack(mockRoiManager, originalStack, true, FILL_COLOR, 0);

	final int foregroundCount = countColorPixels(resultStack, TEST_COLOR);
	assertEquals("Cropped area has wrong amount of foreground color", TEST_COLOR_COUNT, foregroundCount);

	final int backgroundCount = countColorPixels(resultStack, BACKGROUND_COLOR);
	assertEquals("Cropped area has wrong amount of original background color", ORIGINAL_BG_COLOR_COUNT,
			backgroundCount);

	final int fillCount = countColorPixels(resultStack, FILL_COLOR);
	assertEquals("Cropped area has wrong amount of background fill color", FILL_COLOR_COUNT, fillCount);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:40,代码来源:RoiManTest.java

示例10: testGetSliceRoi

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetSliceRoi() throws Exception {
	// Mock a RoiManager with several Rois
	// RoiManager.getSliceNumber tries to parse the number of the slice from the
	// label of the Roi
	final String singleRoiLabel = "0003-0000-0001";
	final String multiRoi1Label = "0004-0000-0001";
	final String multiRoi2Label = "0004-0000-0002";
	final String noSliceLabel = "ALL_SLIDES";
	final Roi otherSliceRoi = new Roi(10, 10, 10, 10);
	final Roi sliceRoi1 = new Roi(10, 10, 10, 10);
	final Roi sliceRoi2 = new Roi(30, 30, 10, 10);
	final Roi allSliceRoi = new Roi(50, 50, 10, 10);
	final Roi rois[] = { otherSliceRoi, sliceRoi1, sliceRoi2, allSliceRoi };
	otherSliceRoi.setName(singleRoiLabel);
	sliceRoi1.setName(multiRoi1Label);
	sliceRoi2.setName(multiRoi2Label);
	allSliceRoi.setName(noSliceLabel);
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);

	final List<Roi> result = RoiManagerUtil.getSliceRoi(MOCK_ROI_MANAGER,
		testStack, 4);

	assertEquals("Wrong number of ROIs returned", 3, result.size());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", multiRoi1Label,
		result.get(0).getName());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", multiRoi2Label,
		result.get(1).getName());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", noSliceLabel,
		result.get(2).getName());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:33,代码来源:RoiManagerUtilTest.java

示例11: testGetLimits

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetLimits() throws Exception {
	// Mock a RoiManager with two Rois
	final int ROI1_X = 10;
	final int ROI1_Y = 10;
	final int ROI1_WIDTH = 30;
	final int ROI1_HEIGHT = 60;
	final int ROI2_X = 20;
	final int ROI2_Y = 5;
	final int ROI2_WIDTH = 40;
	final int ROI2_HEIGHT = 30;
	final int ROI1_Z = 2;
	final int ROI2_Z = 3;
	final String roi1Label = "000" + ROI1_Z + "-0000-0001";
	final String roi2Label = "000" + ROI2_Z + "-0000-0001";
	final Roi roi1 = new Roi(ROI1_X, ROI1_Y, ROI1_WIDTH, ROI1_HEIGHT);
	final Roi roi2 = new Roi(ROI2_X, ROI2_Y, ROI2_WIDTH, ROI2_HEIGHT);
	final Roi rois[] = { roi1, roi2 };
	roi1.setName(roi1Label);
	roi2.setName(roi2Label);
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);

	Optional<int[]> result = RoiManagerUtil.getLimits(MOCK_ROI_MANAGER,
		testStack);

	assertTrue(result.isPresent());
	int[] limitsResult = result.get();
	assertEquals(6, limitsResult.length);
	assertEquals(ROI1_X, limitsResult[0]);
	assertEquals(ROI2_X + ROI2_WIDTH, limitsResult[1]);
	assertEquals(ROI2_Y, limitsResult[2]);
	assertEquals(ROI1_Y + ROI1_HEIGHT, limitsResult[3]);
	assertEquals(ROI1_Z, limitsResult[MIN_Z_INDEX]);
	assertEquals(ROI2_Z, limitsResult[MAX_Z_INDEX]);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:38,代码来源:RoiManagerUtilTest.java

示例12: testCropStackWithPadding

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testCropStackWithPadding() throws Exception {
	// Mock a RoiManager
	final int WIDTH = 6;
	final int HEIGHT = 3;
	final int DEPTH = 3;
	final int PADDING = 2;
	final int ROI_WIDTH = 2;
	final int ROI_HEIGHT = 2;
	final int TOTAL_PADDING = 2 * PADDING;
	final Roi roi1 = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	final Roi roi2 = new Roi(6, 3, ROI_WIDTH, ROI_HEIGHT);
	final Roi roi3 = new Roi(2, 2, ROI_WIDTH, ROI_HEIGHT);
	final Roi rois[] = { roi3, roi1, roi2 };
	roi1.setName("0002-0000-0001");
	roi2.setName("0003-0000-0001");
	roi3.setName("0001-0000-0001");
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);

	// Create a test image
	final ImageStack stack = createCuboid(10, 10, 10, (byte) 0xFF, 0)
		.getStack();
	final ImageStack unpadded = RoiManagerUtil.cropToRois(MOCK_ROI_MANAGER,
		stack, false, 0x00, 0).get();

	final ImageStack result = RoiManagerUtil.cropToRois(MOCK_ROI_MANAGER, stack,
		false, 0x00, PADDING).get();

	assertEquals("Cropped stack has wrong padded width", WIDTH + TOTAL_PADDING,
		result.getWidth());
	assertEquals("Cropped stack has wrong padded height", HEIGHT +
		TOTAL_PADDING, result.getHeight());
	assertEquals("Cropped stack has wrong padded depth", DEPTH + TOTAL_PADDING,
		result.getSize());
	assertTrue("Padding didn't shift the pixels correctly", pixelsShifted(
		unpadded, result, PADDING));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:40,代码来源:RoiManagerUtilTest.java

示例13: testCropStackFillColor

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testCropStackFillColor() throws Exception {
	// Mock a RoiManager and create a test image
	final int TEST_COLOR_COUNT = 8;
	final byte TEST_COLOR = 0x40;
	final byte BACKGROUND_COLOR = 0x00;
	final int BACKGROUND_COLOR_COUNT = 46;
	final int ORIGINAL_BG_COLOR_COUNT = 4;
	final int FILL_COLOR_COUNT = BACKGROUND_COLOR_COUNT -
		ORIGINAL_BG_COLOR_COUNT;
	final byte FILL_COLOR = 0x10;
	final ImageStack stack = createCuboid(10, 10, 10, TEST_COLOR, 1).getStack();
	final Roi roi1 = new Roi(2, 2, 2, 2);
	final Roi roi2 = new Roi(6, 3, 2, 2);
	final Roi roi3 = new Roi(2, 2, 2, 2);
	final Roi rois[] = { roi3, roi1, roi2 };
	roi1.setName("0002-0000-0001");
	roi2.setName("0003-0000-0001");
	roi3.setName("0001-0000-0001");
	when(MOCK_ROI_MANAGER.getCount()).thenReturn(rois.length);
	when(MOCK_ROI_MANAGER.getSliceNumber(anyString())).thenCallRealMethod();
	when(MOCK_ROI_MANAGER.getRoisAsArray()).thenReturn(rois);

	final Optional<ImageStack> optional = RoiManagerUtil.cropToRois(
		MOCK_ROI_MANAGER, stack, true, FILL_COLOR, 0);
	ImageStack result = optional.get();

	final int foregroundCount = countColorPixels(result, TEST_COLOR);
	assertEquals("Cropped area has wrong amount of foreground color",
		TEST_COLOR_COUNT, foregroundCount);
	final int backgroundCount = countColorPixels(result, BACKGROUND_COLOR);
	assertEquals("Cropped area has wrong amount of original background color",
		ORIGINAL_BG_COLOR_COUNT, backgroundCount);
	final int fillCount = countColorPixels(result, FILL_COLOR);
	assertEquals("Cropped area has wrong amount of background fill color",
		FILL_COLOR_COUNT, fillCount);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:38,代码来源:RoiManagerUtilTest.java

示例14: addRoisToAll

import ij.gui.Roi; //导入方法依赖的package包/类
public static void addRoisToAll (List<Roi> rois) {
		//RoiManager rm = RoiManager.getInstance();
		RoiManager rm = getRM();
		rm.runCommand("reset");
		
//		showAll();
		int[] ids = WindowManager.getIDList();
		int i=0;
		while (ids != null && i < ids.length) {			
			WindowManager.setTempCurrentImage(WindowManager.getImage(ids[i]));
			rm.runCommand("show all");
			rm.runCommand("show all with labels");
			rm.runCommand("usenames", "true");
			for (Roi roi : rois) {
				if (roi != null) {
//					Roi r = (Roi) roi.clone();
					Roi r = roi;
//					String t = WindowManager.getImage(ids[i]).getTitle();
//					t = t.substring(0, t.indexOf("File"));
					//r.setName(++j + " - " + r.getName());
					r.setName(r.getName());
					rm.addRoi(r);
					rm.select(rm.getCount()-1);  // assign newly added Roi to curr image
				}
			}	
//			showAll();
			WindowManager.setTempCurrentImage(null);
			i++;
		}		
		
		
	}
 
开发者ID:mekterovic,项目名称:bactimas,代码行数:33,代码来源:BridgeToRoiManager.java

示例15: testGetSliceRoi

import ij.gui.Roi; //导入方法依赖的package包/类
@Test
public void testGetSliceRoi() throws Exception {
	final int NO_ROI_SLICE_NO = 2;
	final int SINGLE_ROI_SLICE_NO = 3;
	final int MULTI_ROI_SLICE_NO = 4;

	// RoiManager.getSliceNumber tries to parse the number of the slice from
	// the label of the Roi it's given.
	// It doesn't - for example - check the slice attribute of the given
	// Roi...
	final String singleRoiLabel = "000" + SINGLE_ROI_SLICE_NO + "-0000-0001";
	final String multiRoi1Label = "000" + MULTI_ROI_SLICE_NO + "-0000-0001";
	final String multiRoi2Label = "000" + MULTI_ROI_SLICE_NO + "-0000-0002";
	final String noSliceLabel = "NO_SLICE";

	final Roi singleRoi = new Roi(10, 10, 10, 10);
	singleRoi.setName(singleRoiLabel);

	final Roi multiRoi1 = new Roi(10, 10, 10, 10);
	multiRoi1.setName(multiRoi1Label);

	final Roi multiRoi2 = new Roi(30, 30, 10, 10);
	multiRoi2.setName(multiRoi2Label);

	final Roi noSliceRoi = new Roi(50, 50, 10, 10);
	noSliceRoi.setName(noSliceLabel);

	final Roi rois[] = { singleRoi, multiRoi1, multiRoi2, noSliceRoi };

	when(mockRoiManager.getSliceNumber(anyString())).thenCallRealMethod();
	when(mockRoiManager.getRoisAsArray()).thenReturn(rois);

	// Slice with no (associated) Rois
	ArrayList<Roi> resultRois = RoiMan.getSliceRoi(mockRoiManager, testStack, NO_ROI_SLICE_NO);
	assertEquals("Wrong number of ROIs returned", 1, resultRois.size());
	assertEquals("Wrong ROI returned", noSliceLabel, resultRois.get(0).getName());

	// Slice with one Roi
	resultRois = RoiMan.getSliceRoi(mockRoiManager, testStack, SINGLE_ROI_SLICE_NO);

	assertEquals("Wrong number of ROIs returned", 2, resultRois.size());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", singleRoiLabel, resultRois.get(0).getName());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", noSliceLabel, resultRois.get(1).getName());

	// Slice with multiple Rois
	resultRois = RoiMan.getSliceRoi(mockRoiManager, testStack, MULTI_ROI_SLICE_NO);

	assertEquals("Wrong number of ROIs returned", 3, resultRois.size());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", multiRoi1Label, resultRois.get(0).getName());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", multiRoi2Label, resultRois.get(1).getName());
	assertEquals("Wrong ROI returned, or ROIs in wrong order", noSliceLabel, resultRois.get(2).getName());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:53,代码来源:RoiManTest.java


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