Image extends Component { public static Image newImage(FrameContainer container, URI uri) { Image mImage; try { OdfElement parent = container.getFrameContainerElement(); OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument(); DrawFrameElement fElement = ownerDom.newOdfElement(DrawFrameElement.class); parent.appendChild(fElement); DrawImageElement imageElement = fElement.newDrawImageElement(); String packagePath = insertImageResourceIntoPackage((OdfSchemaDocument) ownerDom.getDocument(), uri); packagePath = packagePath.replaceFirst(ownerDom.getDocument().getDocumentPath(), ""); URI newURI = configureInsertedImage((OdfSchemaDocument) ownerDom.getDocument(), imageElement, packagePath, false); mImage = new Image(imageElement); mImage.mImageURI = newURI; Component.registerComponent(mImage, imageElement); if (container instanceof Paragraph) { mImage.getStyleHandler().setAchorType(AnchorType.TO_PARAGRAPH); } return mImage; } catch (Exception e) { Logger.getLogger(Image.class.getName()).log(Level.SEVERE, e.getMessage(), e); } return null; } private  Image(DrawImageElement drawElement); static Image getInstanceof(DrawImageElement imageElement); void setHyperlink(URI linkto); URI getHyperlink(); Document getOwnerDocument(); FrameStyleHandler getStyleHandler(); DrawImageElement getOdfElement(); Frame getFrame(); static Image newImage(FrameContainer container, URI uri); static Image newImage(Frame frame, URI uri); static String getPackagePath(OdfSchemaDocument mOdfSchemaDoc, String imageRef); static URI configureInsertedImage(OdfSchemaDocument mOdfSchemaDoc, DrawImageElement imageElement,
			String packagePath, boolean isResetSize); static Iterator<Image> imageIterator(FrameContainer container); boolean remove(); void updateImage(URI imageUri); InputStream getImageInputStream(); String getInternalPath(); String getMediaTypeString(); void setName(String name); String getName(); void setRectangle(FrameRectangle rectangle); FrameRectangle getRectangle(); void setTitle(String title); String getTitle(); String getDesciption(); void setDescription(String description); void setHorizontalPosition(FrameHorizontalPosition horizontalPos); void setVerticalPosition(FrameVerticalPosition verticalPos); FrameHorizontalPosition getHorizontalPosition(); FrameVerticalPosition getVerticalPosition();  }
@Test public void testNewImage() { try { TextDocument doc = TextDocument.newTextDocument(); Paragraph para = doc.addParagraph(""); Image image = Image.newImage(para, ResourceUtilities.getURI("image_list_item.png")); image.setName("this image"); image.setHyperlink(new URI("http: doc.save(ResourceUtilities.newTestOutputFile("imagetest.odt")); Iterator<Image> iter = Image.imageIterator(para); if (iter.hasNext()) { Image aImage = iter.next(); Assert.assertEquals(image, aImage); } PresentationDocument pDoc = PresentationDocument.newPresentationDocument(); Slide slide = pDoc.newSlide(0, "test", SlideLayout.TITLE_OUTLINE); Textbox box = slide.getTextboxByUsage(PresentationDocument.PresentationClass.TITLE).get(0); box.setImage(ResourceUtilities.getURI("image_list_item.png")); pDoc.save(ResourceUtilities.newTestOutputFile("imagep.odp")); TextDocument sDoc = TextDocument.newTextDocument(); Table table1 = sDoc.addTable(2, 2); Cell cell1 = table1.getCellByPosition(0, 0); Image image3 = cell1.setImage(ResourceUtilities.getURI("image_list_item.png")); image3.setHorizontalPosition(FrameHorizontalPosition.LEFT); image3.setHyperlink(new URI("http: Assert.assertEquals("http: sDoc.save(ResourceUtilities.newTestOutputFile("imges.odt")); SpreadsheetDocument sheet = SpreadsheetDocument.newSpreadsheetDocument(); Table table2 = sheet.getTableList().get(0); Cell cell2 = table2.getCellByPosition(1, 1); Image image4 = cell2.setImage(ResourceUtilities.getURI("image_list_item.png")); sheet.save(ResourceUtilities.newTestOutputFile("imgesheet.ods")); Image aImage4 = cell2.getImage(); Assert.assertEquals(image4, aImage4); } catch (Exception e) { Logger.getLogger(ImageTest.class.getName()).log(Level.SEVERE, null, e); Assert.fail(); } }