use of org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D in project poi by apache.
the class XSSFShapeGroup method prototype.
/**
* Initialize default structure of a new shape group
*/
protected static CTGroupShape prototype() {
if (prototype == null) {
CTGroupShape shape = CTGroupShape.Factory.newInstance();
CTGroupShapeNonVisual nv = shape.addNewNvGrpSpPr();
CTNonVisualDrawingProps nvpr = nv.addNewCNvPr();
nvpr.setId(0);
nvpr.setName("Group 0");
nv.addNewCNvGrpSpPr();
CTGroupShapeProperties sp = shape.addNewGrpSpPr();
CTGroupTransform2D t2d = sp.addNewXfrm();
CTPositiveSize2D p1 = t2d.addNewExt();
p1.setCx(0);
p1.setCy(0);
CTPoint2D p2 = t2d.addNewOff();
p2.setX(0);
p2.setY(0);
CTPositiveSize2D p3 = t2d.addNewChExt();
p3.setCx(0);
p3.setCy(0);
CTPoint2D p4 = t2d.addNewChOff();
p4.setX(0);
p4.setY(0);
prototype = shape;
}
return prototype;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D in project poi by apache.
the class XSSFShapeGroup method setCoordinates.
/**
* Sets the coordinate space of this group. All children are constrained
* to these coordinates.
*/
public void setCoordinates(int x1, int y1, int x2, int y2) {
CTGroupTransform2D t2d = ctGroup.getGrpSpPr().getXfrm();
CTPoint2D off = t2d.getOff();
off.setX(x1);
off.setY(y1);
CTPositiveSize2D ext = t2d.getExt();
ext.setCx(x2);
ext.setCy(y2);
CTPoint2D chOff = t2d.getChOff();
chOff.setX(x1);
chOff.setY(y1);
CTPositiveSize2D chExt = t2d.getChExt();
chExt.setCx(x2);
chExt.setCy(y2);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D in project poi by apache.
the class XSSFDrawing method createXfrm.
private CTTransform2D createXfrm(XSSFClientAnchor anchor) {
CTTransform2D xfrm = CTTransform2D.Factory.newInstance();
CTPoint2D off = xfrm.addNewOff();
off.setX(anchor.getDx1());
off.setY(anchor.getDy1());
XSSFSheet sheet = getSheet();
double widthPx = 0;
for (int col = anchor.getCol1(); col < anchor.getCol2(); col++) {
widthPx += sheet.getColumnWidthInPixels(col);
}
double heightPx = 0;
for (int row = anchor.getRow1(); row < anchor.getRow2(); row++) {
heightPx += ImageUtils.getRowHeightInPixels(sheet, row);
}
long width = Units.pixelToEMU((int) widthPx);
long height = Units.pixelToEMU((int) heightPx);
CTPositiveSize2D ext = xfrm.addNewExt();
ext.setCx(width - anchor.getDx1() + anchor.getDx2());
ext.setCy(height - anchor.getDy1() + anchor.getDy2());
// TODO: handle vflip/hflip
return xfrm;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D in project poi by apache.
the class XSSFPicture method prototype.
/**
* Returns a prototype that is used to construct new shapes
*
* @return a prototype that is used to construct new shapes
*/
protected static CTPicture prototype() {
if (prototype == null) {
CTPicture pic = CTPicture.Factory.newInstance();
CTPictureNonVisual nvpr = pic.addNewNvPicPr();
CTNonVisualDrawingProps nvProps = nvpr.addNewCNvPr();
nvProps.setId(1);
nvProps.setName("Picture 1");
nvProps.setDescr("Picture");
CTNonVisualPictureProperties nvPicProps = nvpr.addNewCNvPicPr();
nvPicProps.addNewPicLocks().setNoChangeAspect(true);
CTBlipFillProperties blip = pic.addNewBlipFill();
blip.addNewBlip().setEmbed("");
blip.addNewStretch().addNewFillRect();
CTShapeProperties sppr = pic.addNewSpPr();
CTTransform2D t2d = sppr.addNewXfrm();
CTPositiveSize2D ext = t2d.addNewExt();
//should be original picture width and height expressed in EMUs
ext.setCx(0);
ext.setCy(0);
CTPoint2D off = t2d.addNewOff();
off.setX(0);
off.setY(0);
CTPresetGeometry2D prstGeom = sppr.addNewPrstGeom();
prstGeom.setPrst(STShapeType.RECT);
prstGeom.addNewAvLst();
prototype = pic;
}
return prototype;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D in project poi by apache.
the class XSSFGraphicFrame method prototype.
/**
* Initialize default structure of a new graphic frame
*/
protected static CTGraphicalObjectFrame prototype() {
if (prototype == null) {
CTGraphicalObjectFrame graphicFrame = CTGraphicalObjectFrame.Factory.newInstance();
CTGraphicalObjectFrameNonVisual nvGraphic = graphicFrame.addNewNvGraphicFramePr();
CTNonVisualDrawingProps props = nvGraphic.addNewCNvPr();
props.setId(0);
props.setName("Diagramm 1");
nvGraphic.addNewCNvGraphicFramePr();
CTTransform2D transform = graphicFrame.addNewXfrm();
CTPositiveSize2D extPoint = transform.addNewExt();
CTPoint2D offPoint = transform.addNewOff();
extPoint.setCx(0);
extPoint.setCy(0);
offPoint.setX(0);
offPoint.setY(0);
/* CTGraphicalObject graphic = */
graphicFrame.addNewGraphic();
prototype = graphicFrame;
}
return prototype;
}
Aggregations