use of org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFGeometryProperties in project poi by apache.
the class XSLFSimpleShape method getGeometry.
/**
*
* @return definition of the shape geometry
*/
@Override
public CustomGeometry getGeometry() {
XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());
if (gp == null) {
return null;
}
CustomGeometry geom;
PresetGeometries dict = PresetGeometries.getInstance();
if (gp.isSetPrstGeom()) {
String name = gp.getPrstGeom().getPrst().toString();
geom = dict.get(name);
if (geom == null) {
throw new IllegalStateException("Unknown shape geometry: " + name + ", available geometries are: " + dict.keySet());
}
} else if (gp.isSetCustGeom()) {
XMLStreamReader staxReader = gp.getCustGeom().newXMLStreamReader();
geom = PresetGeometries.convertCustomGeometry(staxReader);
try {
staxReader.close();
} catch (XMLStreamException e) {
LOG.log(POILogger.WARN, "An error occurred while closing a Custom Geometry XML Stream Reader: " + e.getMessage());
}
} else {
geom = dict.get("rect");
}
return geom;
}
use of org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFGeometryProperties in project poi by apache.
the class XSLFSimpleShape method setShapeType.
@Override
public void setShapeType(ShapeType type) {
XSLFGeometryProperties gp = XSLFPropertiesDelegate.getGeometryDelegate(getShapeProperties());
if (gp == null) {
return;
}
if (gp.isSetCustGeom()) {
gp.unsetCustGeom();
}
CTPresetGeometry2D prst = (gp.isSetPrstGeom()) ? gp.getPrstGeom() : gp.addNewPrstGeom();
prst.setPrst(STShapeType.Enum.forInt(type.ooxmlId));
}
Aggregations