Search in sources :

Example 1 with CTNonVisualConnectorProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualConnectorProperties in project poi by apache.

the class TestXSLFConnectorShape method testAddConnector.

@Test
public void testAddConnector() throws IOException {
    XMLSlideShow pptx = new XMLSlideShow();
    XSLFSlide slide = pptx.createSlide();
    XSLFAutoShape rect1 = slide.createAutoShape();
    rect1.setShapeType(ShapeType.RECT);
    rect1.setAnchor(new Rectangle2D.Double(100, 100, 100, 100));
    rect1.setFillColor(Color.blue);
    XSLFAutoShape rect2 = slide.createAutoShape();
    rect2.setShapeType(ShapeType.RECT);
    rect2.setAnchor(new Rectangle2D.Double(300, 300, 100, 100));
    rect2.setFillColor(Color.red);
    XSLFConnectorShape connector1 = slide.createConnector();
    connector1.setAnchor(new Rectangle2D.Double(200, 150, 100, 200));
    CTConnector ctConnector = (CTConnector) connector1.getXmlObject();
    ctConnector.getSpPr().getPrstGeom().setPrst(STShapeType.BENT_CONNECTOR_3);
    CTNonVisualConnectorProperties cx = ctConnector.getNvCxnSpPr().getCNvCxnSpPr();
    // connection start
    CTConnection stCxn = cx.addNewStCxn();
    stCxn.setId(rect1.getShapeId());
    // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4
    stCxn.setIdx(2);
    CTConnection end = cx.addNewEndCxn();
    end.setId(rect2.getShapeId());
    // side of the rectangle to attach the connector: left=1, bottom=2,right=3, top=4
    end.setIdx(3);
    pptx.close();
}
Also used : CTConnection(org.openxmlformats.schemas.drawingml.x2006.main.CTConnection) CTNonVisualConnectorProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualConnectorProperties) CTConnector(org.openxmlformats.schemas.presentationml.x2006.main.CTConnector) Rectangle2D(java.awt.geom.Rectangle2D) Test(org.junit.Test)

Aggregations

Rectangle2D (java.awt.geom.Rectangle2D)1 Test (org.junit.Test)1 CTConnection (org.openxmlformats.schemas.drawingml.x2006.main.CTConnection)1 CTNonVisualConnectorProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualConnectorProperties)1 CTConnector (org.openxmlformats.schemas.presentationml.x2006.main.CTConnector)1