use of org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties in project poi by apache.
the class XSSFShape method setLineStyleColor.
@Override
public void setLineStyleColor(int red, int green, int blue) {
CTShapeProperties props = getShapeProperties();
CTLineProperties ln = props.isSetLn() ? props.getLn() : props.addNewLn();
CTSolidColorFillProperties fill = ln.isSetSolidFill() ? ln.getSolidFill() : ln.addNewSolidFill();
CTSRgbColor rgb = CTSRgbColor.Factory.newInstance();
rgb.setVal(new byte[] { (byte) red, (byte) green, (byte) blue });
fill.setSrgbClr(rgb);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties in project poi by apache.
the class XSSFShape method setLineWidth.
/**
* 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 * EMU_PER_POINT));
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties in project poi by apache.
the class XSLFSimpleShape method setLineDash.
/**
*
* @param dash a preset line dashing scheme to stroke thr shape outline
*/
public void setLineDash(LineDash dash) {
CTLineProperties ln = getLn(this, true);
if (ln == null) {
return;
}
if (dash == null) {
if (ln.isSetPrstDash()) {
ln.unsetPrstDash();
}
} else {
CTPresetLineDashProperties ldp = ln.isSetPrstDash() ? ln.getPrstDash() : ln.addNewPrstDash();
ldp.setVal(STPresetLineDashVal.Enum.forInt(dash.ooxmlId));
}
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties in project poi by apache.
the class XSLFSimpleShape method getLineTailLength.
/**
* @return the line end decoration length
*/
public DecorationSize getLineTailLength() {
CTLineProperties ln = getLn(this, false);
DecorationSize ds = DecorationSize.MEDIUM;
if (ln != null && ln.isSetTailEnd() && ln.getTailEnd().isSetLen()) {
ds = DecorationSize.fromOoxmlId(ln.getTailEnd().getLen().intValue());
}
return ds;
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties in project poi by apache.
the class XSLFSimpleShape method getLinePaint.
protected PaintStyle getLinePaint() {
XSLFSheet sheet = getSheet();
final XSLFTheme theme = sheet.getTheme();
final boolean hasPlaceholder = getPlaceholder() != null;
PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {
@Override
public boolean fetch(XSLFShape shape) {
CTLineProperties spPr = getLn(shape, false);
XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(spPr);
if (fp != null && fp.isSetNoFill()) {
setValue(null);
return true;
}
PackagePart pp = shape.getSheet().getPackagePart();
PaintStyle paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
if (paint != null) {
setValue(paint);
return true;
}
CTShapeStyle style = shape.getSpStyle();
if (style != null) {
fp = XSLFPropertiesDelegate.getFillDelegate(style.getLnRef());
paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
// line color was not found, check if it is defined in the theme
if (paint == null) {
paint = getThemePaint(style, pp);
}
}
if (paint != null) {
setValue(paint);
return true;
}
return false;
}
PaintStyle getThemePaint(CTShapeStyle style, PackagePart pp) {
// get a reference to a line style within the style matrix.
CTStyleMatrixReference lnRef = style.getLnRef();
if (lnRef == null) {
return null;
}
int idx = (int) lnRef.getIdx();
CTSchemeColor phClr = lnRef.getSchemeClr();
if (idx <= 0) {
return null;
}
CTLineProperties props = theme.getXmlObject().getThemeElements().getFmtScheme().getLnStyleLst().getLnArray(idx - 1);
XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(props);
return selectPaint(fp, phClr, pp, theme, hasPlaceholder);
}
};
fetchShapeProperty(fetcher);
return fetcher.getValue();
}
Aggregations