org.scijava.convert.Converter Java Examples
The following examples show how to use
org.scijava.convert.Converter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StringToDatasetConverterTest.java From scifio with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testFileToDatasetConverter() { final ConvertService convertService = c.service(ConvertService.class); String imagePath = "image&pixelType=uint8&axes=X,Y,Z&lengths=256,128,32.fake"; Converter<?, ?> handler = convertService.getHandler(imagePath, Dataset.class); // Make sure we got the right converter back assertSame(StringToDatasetConverter.class, handler.getClass()); // Test handler capabilities assertTrue(handler.canConvert(imagePath, Dataset.class)); assertFalse(handler.canConvert(null, Dataset.class)); // Make sure we can convert with ConvertService assertTrue(convertService.supports(imagePath, Dataset.class)); // Convert and check dimensions Dataset dataset = convertService.convert(imagePath, Dataset.class); assertEquals(256, dataset.dimension(0)); assertEquals(128, dataset.dimension(1)); assertEquals(32, dataset.dimension(2)); }
Example #2
Source File: FileToDatasetConverterTest.java From scifio with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void testFileToDatasetConverter() { final ConvertService convertService = c.service(ConvertService.class); File imageFile = new File("image&pixelType=uint8&axes=X,Y,Z&lengths=256,128,32.fake"); Converter<?, ?> handler = convertService.getHandler(imageFile, Dataset.class); // Make sure we got the right converter back assertSame(FileToDatasetConverter.class, handler.getClass()); // Test handler capabilities assertTrue(handler.canConvert(imageFile, Dataset.class)); assertFalse(handler.canConvert(null, Dataset.class)); // Make sure we can convert with ConvertService assertTrue(convertService.supports(imageFile, Dataset.class)); // Convert and check dimensions Dataset dataset = convertService.convert(imageFile, Dataset.class); assertEquals(256, dataset.dimension(0)); assertEquals(128, dataset.dimension(1)); assertEquals(32, dataset.dimension(2)); }