Search in sources :

Example 16 with CTLineProperties

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);
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 17 with CTLineProperties

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));
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)

Example 18 with CTLineProperties

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));
    }
}
Also used : CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) CTPresetLineDashProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTPresetLineDashProperties)

Example 19 with CTLineProperties

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;
}
Also used : DecorationSize(org.apache.poi.sl.usermodel.LineDecoration.DecorationSize) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)

Example 20 with CTLineProperties

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();
}
Also used : CTSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) PropertyFetcher(org.apache.poi.xslf.model.PropertyFetcher) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) CTShapeStyle(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle) PaintStyle(org.apache.poi.sl.usermodel.PaintStyle) CTStyleMatrixReference(org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference) XSLFFillProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)

Aggregations

CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)31 CTLineEndProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineEndProperties)7 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)6 PropertyFetcher (org.apache.poi.xslf.model.PropertyFetcher)5 CTSolidColorFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)5 DecorationSize (org.apache.poi.sl.usermodel.LineDecoration.DecorationSize)4 CTStyleMatrixReference (org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrixReference)3 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 DecorationShape (org.apache.poi.sl.usermodel.LineDecoration.DecorationShape)2 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)2 XmlObject (org.apache.xmlbeans.XmlObject)2 CTPresetLineDashProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetLineDashProperties)2 CTShapeStyle (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeStyle)2 STCompoundLine (org.openxmlformats.schemas.drawingml.x2006.main.STCompoundLine)2 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)1 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)1 LineCap (org.apache.poi.sl.usermodel.StrokeStyle.LineCap)1 LineDash (org.apache.poi.sl.usermodel.StrokeStyle.LineDash)1 XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)1 CTBaseStyles (org.openxmlformats.schemas.drawingml.x2006.main.CTBaseStyles)1