Example usage for java.awt.geom Rectangle2D.Double getX

List of usage examples for java.awt.geom Rectangle2D.Double getX

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D.Double getX.

Prototype

public abstract double getX();

Source Link

Document

Returns the X coordinate of the upper-left corner of the framing rectangle in double precision.

Usage

From source file:com.hp.autonomy.frontend.reports.powerpoint.SlideShowTemplate.java

/**
 * Utility function to clone the graphical object which represents a chart on a slide.
 * @param base the object to clone.//from w  w  w.j a  v  a  2 s .c  o m
 * @param relId the new relation ID we should insert.
 * @param shapeId the new shape ID we should insert.
 * @param shapeName the new shape name we should insert.
 * @param anchor the bounds of the new shape object in PowerPoint coordinates, if set, or null to use the existing clone's bounds.
 * @return a new clone object with the desired properties.
 */
private CTGraphicalObjectFrame cloneShapeXML(final CTGraphicalObjectFrame base, final String relId,
        final int shapeId, final String shapeName, final Rectangle2D.Double anchor) {
    /* Based on viewing the raw chart.
      <p:graphicFrame>
    <p:nvGraphicFramePr>
      <p:cNvPr id="4" name="Chart 3"/>
      <p:cNvGraphicFramePr/>
      <p:nvPr>
        <p:extLst>
          <p:ext uri="{D42A27DB-BD31-4B8C-83A1-F6EECF244321}">
            <p14:modId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="866141002"/>
          </p:ext>
        </p:extLst>
      </p:nvPr>
    </p:nvGraphicFramePr>
    <p:xfrm>
      <a:off x="0" y="0"/>
      <a:ext cx="12192000" cy="6858000"/>
    </p:xfrm>
    <a:graphic>
      <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart">
        <c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
                 xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId2"/>
      </a:graphicData>
    </a:graphic>
      </p:graphicFrame>
     */
    final CTGraphicalObjectFrame copy = (CTGraphicalObjectFrame) base.copy();

    final CTNonVisualDrawingProps cNvPr = copy.getNvGraphicFramePr().getCNvPr();
    cNvPr.setName(shapeName);
    cNvPr.setId(shapeId);

    final XmlObject[] children = copy.getGraphic().getGraphicData()
            .selectChildren(new QName(XSSFRelation.NS_CHART, "chart"));

    if (anchor != null) {
        final CTPoint2D off = copy.getXfrm().getOff();
        off.setX((int) (anchor.getX() * EMU_PER_POINT));
        off.setY((int) (anchor.getY() * EMU_PER_POINT));

        final CTPositiveSize2D ext = copy.getXfrm().getExt();
        ext.setCx((int) (anchor.getWidth() * EMU_PER_POINT));
        ext.setCy((int) (anchor.getHeight() * EMU_PER_POINT));
    }

    for (final XmlObject child : children) {
        child.getDomNode().getAttributes().getNamedItemNS(RELATION_NAMESPACE, "id").setNodeValue(relId);
    }

    return copy;
}