Package org.odftoolkit.odfdom.dom.element.draw

Examples of org.odftoolkit.odfdom.dom.element.draw.DrawFrameElement


   */
  public static Image newImage(Frame frame, URI uri) {
    Image mImage;

    try {
      DrawFrameElement fElement = (DrawFrameElement) frame.getDrawFrameElement();
      OdfFileDom ownerDom = (OdfFileDom) fElement.getOwnerDocument();
      DrawImageElement imageElement = fElement.newDrawImageElement();
      // set uri and copy resource
      String packagePath = insertImageResourceIntoPackage((OdfSchemaDocument) ownerDom.getDocument(), uri);
      packagePath = packagePath.replaceFirst(ownerDom.getDocument().getDocumentPath(), "");
      URI newURI = configureInsertedImage((OdfSchemaDocument) ownerDom.getDocument(), imageElement, packagePath,
          true);
View Full Code Here


    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);
View Full Code Here

    if (!mDocument.getMediaTypeString().equals(Document.OdfMediaType.TEXT.getMediaTypeString()) &&
        !mDocument.getMediaTypeString().equals(Document.OdfMediaType.TEXT_TEMPLATE.getMediaTypeString()))
      return;
    GraphicProperties graphicPropertiesForWrite = getGraphicPropertiesForWrite();

    DrawFrameElement frameElement = (DrawFrameElement)mOdfElement;
    frameElement.setTextAnchorTypeAttribute(achorType.toString());
   
    //set default relative
    switch(achorType)
    {
    case AS_CHARACTER:
View Full Code Here

   */
  public BufferedImage getBufferedImage() {
    try {
      TextPElement pElement = OdfElement.findFirstChildNode(TextPElement.class, mCellElement);
      if (pElement != null) {
        DrawFrameElement drawFrame = OdfElement.findFirstChildNode(DrawFrameElement.class, pElement);
        if (drawFrame != null) {
          DrawImageElement imageElement = OdfElement.findFirstChildNode(DrawImageElement.class, drawFrame);
          if (imageElement != null) {
            String packagePath = imageElement.getXlinkHrefAttribute();
            OdfFileDom dom = (OdfFileDom) mCellElement.getOwnerDocument();
View Full Code Here

   */
  public Image getImage() {
    try {
      TextPElement pElement = OdfElement.findFirstChildNode(TextPElement.class, mCellElement);
      if (pElement != null) {
        DrawFrameElement drawFrame = OdfElement.findFirstChildNode(DrawFrameElement.class, pElement);
        if (drawFrame != null) {
          DrawImageElement imageElement = OdfElement.findFirstChildNode(DrawImageElement.class, drawFrame);
          return Image.getInstanceof(imageElement);
        }
      } else {
        DrawFrameElement drawFrame = OdfElement.findFirstChildNode(DrawFrameElement.class, mCellElement);
        if (drawFrame != null) {
          DrawImageElement imageElement = OdfElement.findFirstChildNode(DrawImageElement.class, drawFrame);
          return Image.getInstanceof(imageElement);
        }
      }
View Full Code Here

   * @return true if the text box is removed successfully, false if errors
   *         happen.
   */
  public boolean removeTextbox(Textbox box) {
    OdfElement containerElement = getFrameContainerElement();
    DrawFrameElement drawFrame = box.getDrawFrameElement();
    try {
      drawFrame.removeChild(box.getOdfElement());
      if (drawFrame.hasChildNodes() == false)
        containerElement.removeChild(box.getDrawFrameElement());
    } catch (DOMException exception) {
      Logger.getLogger(AbstractParagraphContainer.class.getName()).log(Level.WARNING, exception.getMessage());
      return false;
    }
View Full Code Here

      }
      containerElement.removeChild(nextElement.getDrawFrameElement());
    }

    private Textbox findNext(Textbox thisBox) {
      DrawFrameElement nextFrame = null;
      if (thisBox == null) {
        nextFrame = OdfElement.findFirstChildNode(DrawFrameElement.class, containerElement);
      } else {
        nextFrame = OdfElement.findNextChildNode(DrawFrameElement.class, thisBox.getDrawFrameElement());
      }
View Full Code Here

   */
  public static Textbox newTextbox(TextboxContainer container) {
    Textbox textbox = null;
    OdfElement parent = container.getFrameContainerElement();
    OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument();
    DrawFrameElement fElement = ownerDom.newOdfElement(DrawFrameElement.class);
    parent.appendChild(fElement);
    DrawTextBoxElement boxElement = fElement.newDrawTextBoxElement();
    textbox = new Textbox(boxElement);
    textbox.mFrameContainer = container;
    Component.registerComponent(textbox, boxElement);

    // set text box default style
View Full Code Here

   */
  protected static Frame newFrame(FrameContainer container) {
    Frame frame = null;
    OdfElement parent = container.getFrameContainerElement();
    OdfFileDom ownerDom = (OdfFileDom) parent.getOwnerDocument();
    DrawFrameElement fElement = ownerDom.newOdfElement(DrawFrameElement.class);
    parent.appendChild(fElement);
    frame = new Frame(fElement);
    frame.mFrameContainer = container;
    // Component.registerComponent(frame, fElement);

View Full Code Here

  }

  private class TableContainerImpl extends AbstractTableContainer {

    public OdfElement getTableContainerElement() {
      DrawFrameElement frame = null;
      NodeList frameList = maSlideElement.getElementsByTagNameNS(OdfDocumentNamespace.DRAW.getUri(), "frame");
      if (frameList.getLength() > 0) {
        int index = frameList.getLength() - 1;
        while (index >= 0) {
          frame = (DrawFrameElement) frameList.item(index);
          String presentationClass = frame.getPresentationClassAttribute();
          if (presentationClass == null || "table".equals(presentationClass)) {
            break;
          } else {
            index--;
          }
          frame = null;
        }
      }
      if (frame == null) {
        frame = maSlideElement.newDrawFrameElement();
        frame.setPresentationClassAttribute("table");
        frame.setDrawLayerAttribute("layout");
        frame.setStyleName("standard");
        frame.setSvgHeightAttribute("1.945cm");
        frame.setSvgWidthAttribute("14.098cm");
        frame.setSvgXAttribute("6.922cm");
        frame.setSvgYAttribute("10.386cm");
      }
      return frame;
    }
View Full Code Here

TOP

Related Classes of org.odftoolkit.odfdom.dom.element.draw.DrawFrameElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.