@Override protected void countImages() { // count number of images files = (String[]) poi.getDocumentList().toArray(new String[0]); Arrays.sort(files, new Comparator<String>() { @Override public int compare(String o1, String o2) { final Integer n1 = getImageNumber(o1, -1); final Integer n2 = getImageNumber(o2, -1); return n1.compareTo(n2); } }); core.get(0).imageCount = 0; for (String file : files) { String uname = file.toUpperCase(); uname = uname.substring(uname.indexOf(File.separator) + 1); if (uname.endsWith("CONTENTS") && (uname.startsWith("IMAGE") || uname.indexOf("ITEM") != -1) && poi.getFileSize(file) > 1024) { int imageNumber = getImageNumber(file, 0); if (imageNumber >= getImageCount()) { core.get(0).imageCount++; } } } super.countImages(); coordinates = new int[getSeriesCount() * getImageCount()][4]; }
private RandomAccessInputStream getFile(String name) throws FormatException, IOException { if (isOIB) { if (poi == null) { initPOIService(); } name = name.replace('\\', File.separatorChar); name = name.replace('/', File.separatorChar); String realName = oibMapping.get(name); if (realName == null) { throw new FormatException("File " + name + " not found."); } return poi.getDocumentStream(realName); } return new RandomAccessInputStream(name, 16); }
@Override public void close(boolean fileOnly) throws IOException { super.close(fileOnly); if (!fileOnly) { if (poi != null) poi.close(); poi = null; imageFiles = null; } }
private String mapOIBFiles() throws FormatException, IOException { String oifName = null; String infoFile = null; final List<String> list = poi.getDocumentList(); for (String name : list) { if (name.endsWith("OibInfo.txt")) { throw new FormatException("OibInfo.txt not found in " + currentId); RandomAccessInputStream ras = poi.getDocumentStream(infoFile);
poi.initialize(id); Vector<String> documents = poi.getDocumentList(); try (RandomAccessInputStream s = poi.getDocumentStream(name)) { s.order(true); in = poi.getDocumentStream(name); break; populateMetadataStore(); poi.close(); poi = null;
Vector<String> fileList = poi.getDocumentList(); if (relativePath.equals("CONTENTS")) { addGlobalMeta("Version", new String( poi.getDocumentBytes(name), Constants.ENCODING).trim()); byte[] b = poi.getDocumentBytes(name, 4); addGlobalMeta("Frame Rate", DataTools.bytesToInt(b, true)); RandomAccessInputStream s = poi.getDocumentStream(name); s.order(true); for (int q=0; q<s.length()/2; q++) { new String(poi.getDocumentBytes(name), Constants.ENCODING).trim(); addGlobalMeta("Image Description", description); try (RandomAccessInputStream stream = poi.getDocumentStream(imageFiles.get(0))) { TiffParser tp = new TiffParser(stream); firstIFD = tp.getFirstIFD();
final List<String> allFiles = poi.getDocumentList(); if (allFiles.isEmpty()) { throw new FormatException( (relativePath.equals("Data") && parent.indexOf("Image") != -1))) stream = poi.getDocumentStream(name); stream.order(true); int bpp = FormatTools.getBytesPerPixel(getPixelType()); int plane = getSizeX() * getSizeY() * bpp; if (getSizeC() == 0 || getSizeC() * plane > poi.getFileSize(name)) { m.sizeC = poi.getFileSize(name) / plane; int expectedPlaneSize = m.sizeX * m.sizeY * bpp * m.sizeC; String file = imageFiles.get(0); try (RandomAccessInputStream s = poi.getDocumentStream(file)) { TiffParser tp = new TiffParser(s);
@BeforeMethod public void setUp() throws DependencyException, IOException { ServiceFactory sf = new ServiceFactory(); service = sf.getInstance(POIService.class); URL file = this.getClass().getResource(TEST_XLS); service.initialize(file.getPath()); }
@Test public void testWorkbookFileSize() { assertEquals(WORKBOOK_LENGTH, service.getFileSize(WORKBOOK_DOCUMENT)); } }
@Test public void testDocuments() { Vector<String> documents = service.getDocumentList(); for (String document : documents) { if (document.equals(WORKBOOK_DOCUMENT)) { return; } } fail("Unable to find document: " + WORKBOOK_DOCUMENT); }
@Test public void testWorkbookDocumentBytes() throws IOException { byte[] bytes = service.getDocumentBytes(WORKBOOK_DOCUMENT); assertNotNull(bytes); assertEquals(WORKBOOK_LENGTH, bytes.length); }
poi.initialize(id); Vector<String> documents = poi.getDocumentList(); try (RandomAccessInputStream s = poi.getDocumentStream(name)) { s.order(true); in = poi.getDocumentStream(name); break; populateMetadataStore(); poi.close(); poi = null;
Vector<String> fileList = poi.getDocumentList(); if (relativePath.equals("CONTENTS")) { addGlobalMeta("Version", new String( poi.getDocumentBytes(name), Constants.ENCODING).trim()); byte[] b = poi.getDocumentBytes(name, 4); addGlobalMeta("Frame Rate", DataTools.bytesToInt(b, true)); RandomAccessInputStream s = poi.getDocumentStream(name); s.order(true); for (int q=0; q<s.length()/2; q++) { new String(poi.getDocumentBytes(name), Constants.ENCODING).trim(); addGlobalMeta("Image Description", description); try (RandomAccessInputStream stream = poi.getDocumentStream(imageFiles.get(0))) { TiffParser tp = new TiffParser(stream); firstIFD = tp.getFirstIFD();
final List<String> allFiles = poi.getDocumentList(); if (allFiles.isEmpty()) { throw new FormatException( (relativePath.equals("Data") && parent.indexOf("Image") != -1))) stream = poi.getDocumentStream(name); stream.order(true); int bpp = FormatTools.getBytesPerPixel(getPixelType()); int plane = getSizeX() * getSizeY() * bpp; if (getSizeC() == 0 || getSizeC() * plane > poi.getFileSize(name)) { m.sizeC = poi.getFileSize(name) / plane; int expectedPlaneSize = m.sizeX * m.sizeY * bpp * m.sizeC; String file = imageFiles.get(0); try (RandomAccessInputStream s = poi.getDocumentStream(file)) { TiffParser tp = new TiffParser(s);
private void initPOIService() throws FormatException, IOException { try { ServiceFactory factory = new ServiceFactory(); poi = factory.getInstance(POIService.class); } catch (DependencyException de) { throw new FormatException("POI library not found", de); } poi.initialize(Location.getMappedId(getCurrentFile())); }
private String mapOIBFiles() throws FormatException, IOException { String oifName = null; String infoFile = null; final List<String> list = poi.getDocumentList(); for (String name : list) { if (name.endsWith("OibInfo.txt")) { throw new FormatException("OibInfo.txt not found in " + currentId); RandomAccessInputStream ras = poi.getDocumentStream(infoFile);
private RandomAccessInputStream getFile(String name) throws FormatException, IOException { if (isOIB) { if (poi == null) { initPOIService(); } name = name.replace('\\', File.separatorChar); name = name.replace('/', File.separatorChar); String realName = oibMapping.get(name); if (realName == null) { throw new FormatException("File " + name + " not found."); } return poi.getDocumentStream(realName); } return new RandomAccessInputStream(name, 16); }
private void initPOIService() throws FormatException, IOException { try { ServiceFactory factory = new ServiceFactory(); poi = factory.getInstance(POIService.class); } catch (DependencyException de) { throw new FormatException("POI library not found", de); } poi.initialize(Location.getMappedId(getCurrentFile())); }
@Override protected void countImages() { // count number of images files = (String[]) poi.getDocumentList().toArray(new String[0]); Arrays.sort(files, new Comparator<String>() { @Override public int compare(String o1, String o2) { final Integer n1 = getImageNumber(o1, -1); final Integer n2 = getImageNumber(o2, -1); return n1.compareTo(n2); } }); core.get(0).imageCount = 0; for (String file : files) { String uname = file.toUpperCase(); uname = uname.substring(uname.indexOf(File.separator) + 1); if (uname.endsWith("CONTENTS") && (uname.startsWith("IMAGE") || uname.indexOf("ITEM") != -1) && poi.getFileSize(file) > 1024) { int imageNumber = getImageNumber(file, 0); if (imageNumber >= getImageCount()) { core.get(0).imageCount++; } } } super.countImages(); coordinates = new int[getSeriesCount() * getImageCount()][4]; }
@Override public void close(boolean fileOnly) throws IOException { super.close(fileOnly); if (!fileOnly) { imageFiles = null; timestamps = null; if (poi != null) poi.close(); poi = null; binning = 0; creationDate = null; uniqueZ = null; } }