@Test public void getImagesTest() throws IOException, AnalysisException, JDOMException, SAXException { InputStream testStream = ContentExtractorTest.class.getResourceAsStream(TEST_PDF_4); List<BxImage> images; try { extractor.setPDF(testStream); images = extractor.getImages("pref"); } finally { testStream.close(); } assertEquals(4, images.size()); Collections.sort(images, new Comparator<BxImage>(){ @Override public int compare(BxImage o1, BxImage o2) { return o1.getFilename().compareTo(o2.getFilename()); } }); List<String> files = IOUtils.readLines(ContentExtractorTest.class.getResourceAsStream(EXP_IMGS_4), "UTF-8"); Collections.sort(files); for (int i = 0; i < files.size(); i++) { String fileName = files.get(i); BxImage image = images.get(i); assertEquals(fileName, image.getFilename()); BufferedImage expImg = ImageIO.read(ContentExtractorTest.class.getResourceAsStream(EXP_IMGS_4+fileName)); BufferedImage testImg = image.getImage(); assertEquals(expImg.getHeight(), testImg.getHeight()); assertEquals(expImg.getWidth(), testImg.getWidth()); for (int y = 0; y < expImg.getHeight(); y++) { for (int x = 0; x < expImg.getWidth(); x++) { assertEquals(expImg.getRGB(x, y), testImg.getRGB(x, y)); } } } }
private List<BxImage> getImages(String imagesPrefix, Timeout timeout) throws AnalysisException, TimeoutException { try { TimeoutRegister.set(timeout); TimeoutRegister.get().check(); return extractor.getImages(imagesPrefix); } finally { TimeoutRegister.remove(); } }
ContentExtractor { private List<BxImage> getImages(String imagesPrefix, Timeout timeout) throws AnalysisException, TimeoutException { try { TimeoutRegister.set(timeout); TimeoutRegister.get().check(); return extractor.getImages(imagesPrefix); } finally { TimeoutRegister.remove(); } } }
ContentExtractor { private List<BxImage> getImages(String imagesPrefix, Timeout timeout) throws AnalysisException, TimeoutException { try { TimeoutRegister.set(timeout); TimeoutRegister.get().check(); return extractor.getImages(imagesPrefix); } finally { TimeoutRegister.remove(); } } ContentExtractor();  ContentExtractor(long timeoutSeconds); }
ContentExtractor { private List<BxImage> getImages(String imagesPrefix, Timeout timeout) throws AnalysisException, TimeoutException { try { TimeoutRegister.set(timeout); TimeoutRegister.get().check(); return extractor.getImages(imagesPrefix); } finally { TimeoutRegister.remove(); } } ContentExtractor();  ContentExtractor(long timeoutSeconds); void setTimeout(long timeoutSeconds); void removeTimeout(); void setPDF(InputStream pdfFile); void setBxDocument(BxDocument bxDocument); void reset(); ComponentConfiguration getConf(); void setConf(ComponentConfiguration conf); BxDocument getBxDocument(); BxDocument getBxDocument(long timeoutSeconds); BxDocument getBxDocumentWithGeneralLabels(); BxDocument getBxDocumentWithGeneralLabels(long timeoutSeconds); BxDocument getBxDocumentWithSpecificLabels(); BxDocument getBxDocumentWithSpecificLabels(long timeoutSeconds); List<BxImage> getImages(String imagesPrefix); List<BxImage> getImages(String imagesPrefix, long timeoutSeconds); DocumentMetadata getMetadata(); DocumentMetadata getMetadata(long timeoutSeconds); Element getMetadataAsNLM(); Element getMetadataAsNLM(long timeoutSeconds); List<BibEntry> getReferences(); List<BibEntry> getReferences(long timeoutSeconds); List<Element> getReferencesAsNLM(); List<Element> getReferencesAsNLM(long timeoutSeconds); String getRawFullText(); String getRawFullText(long timeoutSeconds); Element getLabelledFullText(); Element getLabelledFullText(long timeoutSeconds); ContentStructure getBody(); ContentStructure getBody(long timeoutSeconds); Element getBodyAsNLM(); Element getBodyAsNLM(String imagesPrefix); Element getBodyAsNLM(long timeoutSeconds); Element getBodyAsNLM(String imagesPrefix, long timeoutSeconds); Element getContentAsNLM(); Element getContentAsNLM(String imagesPrefix); Element getContentAsNLM(long timeoutSeconds); Element getContentAsNLM(String imagesPrefix, long timeoutSeconds); static void main(String[] args); }
ContentExtractor { private List<BxImage> getImages(String imagesPrefix, Timeout timeout) throws AnalysisException, TimeoutException { try { TimeoutRegister.set(timeout); TimeoutRegister.get().check(); return extractor.getImages(imagesPrefix); } finally { TimeoutRegister.remove(); } } ContentExtractor();  ContentExtractor(long timeoutSeconds); void setTimeout(long timeoutSeconds); void removeTimeout(); void setPDF(InputStream pdfFile); void setBxDocument(BxDocument bxDocument); void reset(); ComponentConfiguration getConf(); void setConf(ComponentConfiguration conf); BxDocument getBxDocument(); BxDocument getBxDocument(long timeoutSeconds); BxDocument getBxDocumentWithGeneralLabels(); BxDocument getBxDocumentWithGeneralLabels(long timeoutSeconds); BxDocument getBxDocumentWithSpecificLabels(); BxDocument getBxDocumentWithSpecificLabels(long timeoutSeconds); List<BxImage> getImages(String imagesPrefix); List<BxImage> getImages(String imagesPrefix, long timeoutSeconds); DocumentMetadata getMetadata(); DocumentMetadata getMetadata(long timeoutSeconds); Element getMetadataAsNLM(); Element getMetadataAsNLM(long timeoutSeconds); List<BibEntry> getReferences(); List<BibEntry> getReferences(long timeoutSeconds); List<Element> getReferencesAsNLM(); List<Element> getReferencesAsNLM(long timeoutSeconds); String getRawFullText(); String getRawFullText(long timeoutSeconds); Element getLabelledFullText(); Element getLabelledFullText(long timeoutSeconds); ContentStructure getBody(); ContentStructure getBody(long timeoutSeconds); Element getBodyAsNLM(); Element getBodyAsNLM(String imagesPrefix); Element getBodyAsNLM(long timeoutSeconds); Element getBodyAsNLM(String imagesPrefix, long timeoutSeconds); Element getContentAsNLM(); Element getContentAsNLM(String imagesPrefix); Element getContentAsNLM(long timeoutSeconds); Element getContentAsNLM(String imagesPrefix, long timeoutSeconds); static void main(String[] args);  }