/** * Return the URI for this image * @return the URI of image */ public URI getImageUri() { try { if (mImageURI == null) { mImageURI = new URI(AnyURI.encodePath(this.getXlinkHrefAttribute().toString())); } } catch (URISyntaxException ex) { Logger.getLogger(OdfDrawImage.class.getName()).log(Level.SEVERE, null, ex); } return mImageURI; }
/** * Return the URI for this image * @return the URI of image */ public URI getImageUri() { try { if (mImageURI == null) { mImageURI = new URI(AnyURI.encodePath(this.getXlinkHrefAttribute().toString())); } } catch (URISyntaxException ex) { Logger.getLogger(OdfDrawImage.class.getName()).log(Level.SEVERE, null, ex); } return mImageURI; }
/** * Return the URI for this image * @return the URI of image */ public URI getImageUri() { try { if (mImageURI == null) { mImageURI = new URI(AnyURI.encodePath(this.getXlinkHrefAttribute().toString())); } } catch (URISyntaxException ex) { Logger.getLogger(OdfDrawImage.class.getName()).log(Level.SEVERE, null, ex); } return mImageURI; }
/** * The image path will be stored as URI of the href attribute * * @param packagePath The relative path from the package root to the image */ public void setImagePath(String packagePath) { try { packagePath = packagePath.replaceFirst(mOdfSchemaDocument.getDocumentPath(), ""); URI uri = new URI(AnyURI.encodePath(packagePath).toString()); this.setXlinkHrefAttribute(AnyURI.decodePath(uri.toString())); mImageURI = uri; } catch (URISyntaxException ex) { Logger.getLogger(OdfDrawImage.class.getName()).log(Level.SEVERE, null, ex); } }
/** * The image path will be stored as URI of the href attribute * * @param packagePath The relative path from the package root to the image */ public void setImagePath(String packagePath) { try { packagePath = packagePath.replaceFirst(mOdfSchemaDocument.getDocumentPath(), ""); URI uri = new URI(AnyURI.encodePath(packagePath).toString()); this.setXlinkHrefAttribute(AnyURI.decodePath(uri.toString())); mImageURI = uri; } catch (URISyntaxException ex) { Logger.getLogger(OdfDrawImage.class.getName()).log(Level.SEVERE, null, ex); } }
/** * The image path will be stored as URI of the href attribute * * @param packagePath The relative path from the package root to the image */ public void setImagePath(String packagePath) { try { packagePath = packagePath.replaceFirst(mOdfSchemaDocument.getDocumentPath(), ""); URI uri = new URI(AnyURI.encodePath(packagePath).toString()); this.setXlinkHrefAttribute(AnyURI.decodePath(uri.toString())); mImageURI = uri; } catch (URISyntaxException ex) { Logger.getLogger(OdfDrawImage.class.getName()).log(Level.SEVERE, null, ex); } }
public static URI configureInsertedImage(OdfSchemaDocument mOdfSchemaDoc, DrawImageElement imageElement, String packagePath, boolean isResetSize) throws Exception { // Set path to image attribute URI uri = new URI(AnyURI.encodePath(packagePath).toString()); imageElement.setXlinkHrefAttribute(AnyURI.decodePath(uri.toString())); // Set mandatory attribute xlink:type imageElement.setXlinkTypeAttribute("simple"); // A draw:image is always embedded in a draw:frame InputStream is = mOdfSchemaDoc.getPackage().getInputStream(packagePath); DrawFrameElement odfFrame = (DrawFrameElement) imageElement.getParentNode(); Frame aFrame = Frame.getInstanceof(odfFrame); FrameRectangle oldRect = aFrame.getRectangle(); if (oldRect.getLinearMeasure() != StyleTypeDefinitions.SupportedLinearMeasure.CM) oldRect.setLinearMeasure(StyleTypeDefinitions.SupportedLinearMeasure.CM); if (odfFrame != null) { BufferedImage image = ImageIO.read(is); int height = image.getHeight(null); int width = image.getWidth(null); odfFrame.setSvgHeightAttribute(Length.mapToUnit(String.valueOf(height) + "px", Unit.CENTIMETER)); odfFrame.setSvgWidthAttribute(Length.mapToUnit(String.valueOf(width) + "px", Unit.CENTIMETER)); if (isResetSize) { FrameRectangle newRect = aFrame.getRectangle(); newRect.setX(oldRect.getX()+(oldRect.getWidth()-newRect.getWidth())/2); newRect.setY(oldRect.getY()+(oldRect.getHeight()-newRect.getHeight())/2); aFrame.setRectangle(newRect); } } return uri; }
private static URI configureInsertedImage(OdfSchemaDocument mOdfSchemaDoc, DrawImageElement imageElement, String packagePath, boolean isResetSize) throws Exception { // Set path to image attribute URI uri = new URI(AnyURI.encodePath(packagePath).toString()); imageElement.setXlinkHrefAttribute(AnyURI.decodePath(uri.toString())); // Set mandatory attribute xlink:type imageElement.setXlinkTypeAttribute("simple"); // A draw:image is always embedded in a draw:frame InputStream is = mOdfSchemaDoc.getPackage().getInputStream(packagePath); DrawFrameElement odfFrame = (DrawFrameElement) imageElement.getParentNode(); Frame aFrame = Frame.getInstanceof(odfFrame); FrameRectangle oldRect = aFrame.getRectangle(); if (oldRect.getLinearMeasure() != StyleTypeDefinitions.SupportedLinearMeasure.CM) oldRect.setLinearMeasure(StyleTypeDefinitions.SupportedLinearMeasure.CM); if (odfFrame != null) { BufferedImage image = ImageIO.read(is); int height = image.getHeight(null); int width = image.getWidth(null); odfFrame.setSvgHeightAttribute(Length.mapToUnit(String.valueOf(height) + "px", Unit.CENTIMETER)); odfFrame.setSvgWidthAttribute(Length.mapToUnit(String.valueOf(width) + "px", Unit.CENTIMETER)); if (isResetSize) { FrameRectangle newRect = aFrame.getRectangle(); newRect.setX(oldRect.getX()+(oldRect.getWidth()-newRect.getWidth())/2); newRect.setY(oldRect.getY()+(oldRect.getHeight()-newRect.getHeight())/2); aFrame.setRectangle(newRect); } } return uri; }
public static URI configureInsertedImage(OdfSchemaDocument mOdfSchemaDoc, DrawImageElement imageElement, String packagePath, boolean isResetSize) throws Exception { // Set path to image attribute URI uri = new URI(AnyURI.encodePath(packagePath).toString()); imageElement.setXlinkHrefAttribute(AnyURI.decodePath(uri.toString())); // Set mandatory attribute xlink:type imageElement.setXlinkTypeAttribute("simple"); // A draw:image is always embedded in a draw:frame InputStream is = mOdfSchemaDoc.getPackage().getInputStream(packagePath); DrawFrameElement odfFrame = (DrawFrameElement) imageElement.getParentNode(); Frame aFrame = Frame.getInstanceof(odfFrame); FrameRectangle oldRect = aFrame.getRectangle(); if (oldRect.getLinearMeasure() != StyleTypeDefinitions.SupportedLinearMeasure.CM) oldRect.setLinearMeasure(StyleTypeDefinitions.SupportedLinearMeasure.CM); if (odfFrame != null) { BufferedImage image = ImageIO.read(is); int height = image.getHeight(null); int width = image.getWidth(null); odfFrame.setSvgHeightAttribute(Length.mapToUnit(String.valueOf(height) + "px", Unit.CENTIMETER)); odfFrame.setSvgWidthAttribute(Length.mapToUnit(String.valueOf(width) + "px", Unit.CENTIMETER)); if (isResetSize) { FrameRectangle newRect = aFrame.getRectangle(); newRect.setX(oldRect.getX()+(oldRect.getWidth()-newRect.getWidth())/2); newRect.setY(oldRect.getY()+(oldRect.getHeight()-newRect.getHeight())/2); aFrame.setRectangle(newRect); } } return uri; }