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;
}
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);
}
}
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);
}
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);
}
Aggregations