/** * Calculate the preferred size for this picture. * * @param scaleX the amount by which image width is multiplied relative to the original width. * @param scaleY the amount by which image height is multiplied relative to the original height. * @return XSSFClientAnchor with the preferred size for this image */ public XSSFClientAnchor getPreferredSize(double scaleX, double scaleY){ Dimension dim = ImageUtils.setPreferredSize(this, scaleX, scaleY); CTPositiveSize2D size2d = ctPicture.getSpPr().getXfrm().getExt(); size2d.setCx((int)dim.getWidth()); size2d.setCy((int)dim.getHeight()); return getClientAnchor(); }
/** * Specifies the width to be used for the underline stroke. * * @param lineWidth width in points */ public void setLineWidth( double lineWidth ) { CTShapeProperties props = getShapeProperties(); CTLineProperties ln = props.isSetLn() ? props.getLn() : props.addNewLn(); ln.setW((int)(lineWidth*Units.EMU_PER_POINT)); }
@Override public CTCustomGeometry2D addNewCustGeom() { return props.addNewCustGeom(); }
public XDDFCustomGeometry2D getCustomGeometry2D() { if (props.isSetCustGeom()) { return new XDDFCustomGeometry2D(props.getCustGeom()); } else { return null; } }
public XDDFFillProperties getFillProperties() { if (props.isSetGradFill()) { return new XDDFGradientFillProperties(props.getGradFill()); } else if (props.isSetGrpFill()) { return new XDDFGroupFillProperties(props.getGrpFill()); } else if (props.isSetNoFill()) { return new XDDFNoFillProperties(props.getNoFill()); } else if (props.isSetPattFill()) { return new XDDFPatternFillProperties(props.getPattFill()); } else if (props.isSetBlipFill()) { return new XDDFPictureFillProperties(props.getBlipFill()); } else if (props.isSetSolidFill()) { return new XDDFSolidFillProperties(props.getSolidFill()); } else { return null; } }
/** * Specifies a solid color fill. The shape is filled entirely with the * specified color. * * @param color the solid color fill. The value of <code>null</code> unsets * the solidFIll attribute from the underlying xml */ public void setFillColor(Color color) { CTShapeProperties spPr = getSpPr(); if (color == null) { if (spPr.isSetSolidFill()) spPr.unsetSolidFill(); if (!spPr.isSetNoFill()) spPr.addNewNoFill(); } else { if (spPr.isSetNoFill()) spPr.unsetNoFill(); CTSolidColorFillProperties fill = spPr.isSetSolidFill() ? spPr .getSolidFill() : spPr.addNewSolidFill(); CTSRgbColor rgb = CTSRgbColor.Factory.newInstance(); rgb.setVal(new byte[]{(byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()}); fill.setSrgbClr(rgb); if(fill.isSetHslClr()) fill.unsetHslClr(); if(fill.isSetPrstClr()) fill.unsetPrstClr(); if(fill.isSetSchemeClr()) fill.unsetSchemeClr(); if(fill.isSetScrgbClr()) fill.unsetScrgbClr(); if(fill.isSetSysClr()) fill.unsetSysClr(); } }
@Override public void setFlipHorizontal(boolean flip) { CTShapeProperties spPr = getSpPr(); CTTransform2D xfrm = spPr.isSetXfrm() ? spPr.getXfrm() : spPr.addNewXfrm(); xfrm.setFlipH(flip); }
CTTransform2D t2d = sp.addNewXfrm(); CTPositiveSize2D p1 = t2d.addNewExt(); p1.setCx(0); p2.setY(0); CTPresetGeometry2D geom = sp.addNewPrstGeom(); geom.setPrst(STShapeType.RECT); geom.addNewAvLst();
/** * * @return definition of the shape geometry */ CustomGeometry getGeometry(){ CTShapeProperties spPr = getSpPr(); CustomGeometry geom; PresetGeometries dict = PresetGeometries.getInstance(); if(spPr.isSetPrstGeom()){ String name = spPr.getPrstGeom().getPrst().toString(); geom = dict.get(name); if(geom == null) { throw new IllegalStateException("Unknown shape geometry: " + name); } } else if (spPr.isSetCustGeom()){ geom = new CustomGeometry(spPr.getCustGeom()); } else { geom = dict.get("rect"); } return geom; }
@Override public void setFillColor(int red, int green, int blue) { CTShapeProperties props = getShapeProperties(); CTSolidColorFillProperties fill = props.isSetSolidFill() ? props.getSolidFill() : props.addNewSolidFill(); CTSRgbColor rgb = CTSRgbColor.Factory.newInstance(); rgb.setVal(new byte[]{(byte)red, (byte)green, (byte)blue}); fill.setSrgbClr(rgb); }
/** * @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); nvSpPr.addNewCNvCxnSpPr(); nvSpPr.addNewNvPr(); CTShapeProperties spPr = ct.addNewSpPr(); CTPresetGeometry2D prst = spPr.addNewPrstGeom(); prst.setPrst(STShapeType.LINE); prst.addNewAvLst(); /* CTLineProperties ln = */ spPr.addNewLn(); return ct; }
public LineEndLength getLineHeadLength() { CTLineProperties ln = getSpPr().getLn(); if (ln == null || !ln.isSetHeadEnd()) return LineEndLength.MEDIUM; STLineEndLength.Enum len = ln.getHeadEnd().getLen(); return len == null ? LineEndLength.MEDIUM : LineEndLength.values()[len.intValue() - 1]; }
@Override public CTPresetGeometry2D addNewPrstGeom() { return props.addNewPrstGeom(); }
@Override public CTCustomGeometry2D getCustGeom() { return props.getCustGeom(); }
if(getSpPr().isSetBlipFill()){ CTBlip blip = getSpPr().getBlipFill().getBlip(); String blipId = blip.getEmbed();
@Override public CTNoFillProperties addNewNoFill() { return props.addNewNoFill(); }
@Override public CTBlipFillProperties getBlipFill() { return props.getBlipFill(); }
@Override public CTSolidColorFillProperties addNewSolidFill() { return props.addNewSolidFill(); }