use of org.openxmlformats.schemas.presentationml.x2006.main.CTConnector in project poi by apache.
the class XSLFDrawing method createConnector.
public XSLFConnectorShape createConnector() {
CTConnector sp = _spTree.addNewCxnSp();
sp.set(XSLFConnectorShape.prototype(_shapeId++));
XSLFConnectorShape shape = new XSLFConnectorShape(sp, _sheet);
shape.setAnchor(new Rectangle2D.Double());
shape.setLineColor(Color.black);
shape.setLineWidth(0.75);
return shape;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTConnector in project poi by apache.
the class XSLFConnectorShape method prototype.
/**
* @param shapeId 1-based shapeId
*/
static CTConnector prototype(int shapeId) {
CTConnector ct = CTConnector.Factory.newInstance();
CTConnectorNonVisual nvSpPr = ct.addNewNvCxnSpPr();
CTNonVisualDrawingProps cnv = nvSpPr.addNewCNvPr();
cnv.setName("Connector " + shapeId);
cnv.setId(shapeId + 1);
nvSpPr.addNewCNvCxnSpPr();
nvSpPr.addNewNvPr();
CTShapeProperties spPr = ct.addNewSpPr();
CTPresetGeometry2D prst = spPr.addNewPrstGeom();
prst.setPrst(STShapeType.LINE);
prst.addNewAvLst();
/* CTLineProperties ln = */
spPr.addNewLn();
return ct;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTConnector in project poi by apache.
the class XSLFSheet method removeShape.
/**
* Removes the specified shape from this sheet, if it is present
* (optional operation). If this sheet does not contain the element,
* it is unchanged.
*
* @param xShape shape to be removed from this sheet, if present
* @return <tt>true</tt> if this sheet contained the specified element
* @throws IllegalArgumentException if the type of the specified shape
* is incompatible with this sheet (optional)
*/
public boolean removeShape(XSLFShape xShape) {
XmlObject obj = xShape.getXmlObject();
CTGroupShape spTree = getSpTree();
if (obj instanceof CTShape) {
spTree.getSpList().remove(obj);
} else if (obj instanceof CTGroupShape) {
spTree.getGrpSpList().remove(obj);
} else if (obj instanceof CTConnector) {
spTree.getCxnSpList().remove(obj);
} else if (obj instanceof CTGraphicalObjectFrame) {
spTree.getGraphicFrameList().remove(obj);
} else if (obj instanceof CTPicture) {
XSLFPictureShape ps = (XSLFPictureShape) xShape;
removePictureRelation(ps);
spTree.getPicList().remove(obj);
} else {
throw new IllegalArgumentException("Unsupported shape: " + xShape);
}
return getShapes().remove(xShape);
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTConnector in project poi by apache.
the class XSLFSheet method buildShapes.
protected static List<XSLFShape> buildShapes(CTGroupShape spTree, XSLFSheet sheet) {
List<XSLFShape> shapes = new ArrayList<XSLFShape>();
for (XmlObject ch : spTree.selectPath("*")) {
if (ch instanceof CTShape) {
// simple shape
XSLFAutoShape shape = XSLFAutoShape.create((CTShape) ch, sheet);
shapes.add(shape);
} else if (ch instanceof CTGroupShape) {
shapes.add(new XSLFGroupShape((CTGroupShape) ch, sheet));
} else if (ch instanceof CTConnector) {
shapes.add(new XSLFConnectorShape((CTConnector) ch, sheet));
} else if (ch instanceof CTPicture) {
shapes.add(new XSLFPictureShape((CTPicture) ch, sheet));
} else if (ch instanceof CTGraphicalObjectFrame) {
XSLFGraphicFrame shape = XSLFGraphicFrame.create((CTGraphicalObjectFrame) ch, sheet);
shapes.add(shape);
}
}
return shapes;
}
use of org.openxmlformats.schemas.presentationml.x2006.main.CTConnector 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