use of org.openxmlformats.schemas.drawingml.x2006.main.CTConnection 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();
}
Aggregations