Search in sources :

Example 1 with LineCap

use of org.apache.poi.sl.usermodel.StrokeStyle.LineCap in project poi by apache.

the class XSLFSimpleShape method getLineCap.

/**
     *
     * @return the line end cap style
     */
public LineCap getLineCap() {
    PropertyFetcher<LineCap> fetcher = new PropertyFetcher<LineCap>() {

        @Override
        public boolean fetch(XSLFShape shape) {
            CTLineProperties ln = getLn(shape, false);
            if (ln != null && ln.isSetCap()) {
                setValue(LineCap.fromOoxmlId(ln.getCap().intValue()));
                return true;
            }
            return false;
        }
    };
    fetchShapeProperty(fetcher);
    LineCap cap = fetcher.getValue();
    if (cap == null) {
        CTLineProperties defaultLn = getDefaultLineProperties();
        if (defaultLn != null && defaultLn.isSetCap()) {
            cap = LineCap.fromOoxmlId(defaultLn.getCap().intValue());
        }
    }
    return cap;
}
Also used : CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) PropertyFetcher(org.apache.poi.xslf.model.PropertyFetcher) LineCap(org.apache.poi.sl.usermodel.StrokeStyle.LineCap) STLineCap(org.openxmlformats.schemas.drawingml.x2006.main.STLineCap)

Example 2 with LineCap

use of org.apache.poi.sl.usermodel.StrokeStyle.LineCap in project poi by apache.

the class XSLFSimpleShape method copy.

@Override
void copy(XSLFShape sh) {
    super.copy(sh);
    XSLFSimpleShape s = (XSLFSimpleShape) sh;
    Color srsSolidFill = s.getFillColor();
    Color tgtSoliFill = getFillColor();
    if (srsSolidFill != null && !srsSolidFill.equals(tgtSoliFill)) {
        setFillColor(srsSolidFill);
    }
    XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(getShapeProperties());
    if (fp != null && fp.isSetBlipFill()) {
        CTBlip blip = fp.getBlipFill().getBlip();
        String blipId = blip.getEmbed();
        String relId = getSheet().importBlip(blipId, s.getSheet().getPackagePart());
        blip.setEmbed(relId);
    }
    Color srcLineColor = s.getLineColor();
    Color tgtLineColor = getLineColor();
    if (srcLineColor != null && !srcLineColor.equals(tgtLineColor)) {
        setLineColor(srcLineColor);
    }
    double srcLineWidth = s.getLineWidth();
    double tgtLineWidth = getLineWidth();
    if (srcLineWidth != tgtLineWidth) {
        setLineWidth(srcLineWidth);
    }
    LineDash srcLineDash = s.getLineDash();
    LineDash tgtLineDash = getLineDash();
    if (srcLineDash != null && srcLineDash != tgtLineDash) {
        setLineDash(srcLineDash);
    }
    LineCap srcLineCap = s.getLineCap();
    LineCap tgtLineCap = getLineCap();
    if (srcLineCap != null && srcLineCap != tgtLineCap) {
        setLineCap(srcLineCap);
    }
}
Also used : CTBlip(org.openxmlformats.schemas.drawingml.x2006.main.CTBlip) Color(java.awt.Color) CTSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor) LineDash(org.apache.poi.sl.usermodel.StrokeStyle.LineDash) LineCap(org.apache.poi.sl.usermodel.StrokeStyle.LineCap) STLineCap(org.openxmlformats.schemas.drawingml.x2006.main.STLineCap) XSLFFillProperties(org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)

Example 3 with LineCap

use of org.apache.poi.sl.usermodel.StrokeStyle.LineCap in project poi by apache.

the class XSLFTableCell method setBorderStyle.

@Override
public void setBorderStyle(BorderEdge edge, StrokeStyle style) {
    if (style == null) {
        throw new IllegalArgumentException("StrokeStyle needs to be specified.");
    }
    LineCap cap = style.getLineCap();
    if (cap != null) {
        setBorderCap(edge, cap);
    }
    LineCompound compound = style.getLineCompound();
    if (compound != null) {
        setBorderCompound(edge, compound);
    }
    LineDash dash = style.getLineDash();
    if (dash != null) {
        setBorderDash(edge, dash);
    }
    double width = style.getLineWidth();
    setBorderWidth(edge, width);
}
Also used : LineCompound(org.apache.poi.sl.usermodel.StrokeStyle.LineCompound) LineDash(org.apache.poi.sl.usermodel.StrokeStyle.LineDash) LineCap(org.apache.poi.sl.usermodel.StrokeStyle.LineCap) STLineCap(org.openxmlformats.schemas.drawingml.x2006.main.STLineCap)

Example 4 with LineCap

use of org.apache.poi.sl.usermodel.StrokeStyle.LineCap in project poi by apache.

the class DrawShape method getStroke.

protected static BasicStroke getStroke(StrokeStyle strokeStyle) {
    float lineWidth = (float) strokeStyle.getLineWidth();
    if (lineWidth == 0.0f) {
        // Both PowerPoint and OOo draw zero-length lines as 0.25pt
        lineWidth = 0.25f;
    }
    LineDash lineDash = strokeStyle.getLineDash();
    if (lineDash == null) {
        lineDash = LineDash.SOLID;
    }
    int[] dashPatI = lineDash.pattern;
    final float dash_phase = 0;
    float[] dashPatF = null;
    if (dashPatI != null) {
        dashPatF = new float[dashPatI.length];
        for (int i = 0; i < dashPatI.length; i++) {
            dashPatF[i] = dashPatI[i] * Math.max(1, lineWidth);
        }
    }
    LineCap lineCapE = strokeStyle.getLineCap();
    if (lineCapE == null) {
        lineCapE = LineCap.FLAT;
    }
    int lineCap;
    switch(lineCapE) {
        case ROUND:
            lineCap = BasicStroke.CAP_ROUND;
            break;
        case SQUARE:
            lineCap = BasicStroke.CAP_SQUARE;
            break;
        default:
        case FLAT:
            lineCap = BasicStroke.CAP_BUTT;
            break;
    }
    int lineJoin = BasicStroke.JOIN_ROUND;
    return new BasicStroke(lineWidth, lineCap, lineJoin, lineWidth, dashPatF, dash_phase);
}
Also used : BasicStroke(java.awt.BasicStroke) LineDash(org.apache.poi.sl.usermodel.StrokeStyle.LineDash) LineCap(org.apache.poi.sl.usermodel.StrokeStyle.LineCap)

Aggregations

LineCap (org.apache.poi.sl.usermodel.StrokeStyle.LineCap)4 LineDash (org.apache.poi.sl.usermodel.StrokeStyle.LineDash)3 STLineCap (org.openxmlformats.schemas.drawingml.x2006.main.STLineCap)3 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 LineCompound (org.apache.poi.sl.usermodel.StrokeStyle.LineCompound)1 PropertyFetcher (org.apache.poi.xslf.model.PropertyFetcher)1 XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)1 CTBlip (org.openxmlformats.schemas.drawingml.x2006.main.CTBlip)1 CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)1 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)1