use of org.apache.poi.sl.usermodel.StrokeStyle.LineDash in project poi by apache.
the class XSLFSimpleShape method getLineDash.
/**
* @return a preset line dashing scheme to stroke the shape outline
*/
public LineDash getLineDash() {
PropertyFetcher<LineDash> fetcher = new PropertyFetcher<LineDash>() {
@Override
public boolean fetch(XSLFShape shape) {
CTLineProperties ln = getLn(shape, false);
if (ln == null || !ln.isSetPrstDash()) {
return false;
}
setValue(LineDash.fromOoxmlId(ln.getPrstDash().getVal().intValue()));
return true;
}
};
fetchShapeProperty(fetcher);
LineDash dash = fetcher.getValue();
if (dash == null) {
CTLineProperties defaultLn = getDefaultLineProperties();
if (defaultLn != null && defaultLn.isSetPrstDash()) {
dash = LineDash.fromOoxmlId(defaultLn.getPrstDash().getVal().intValue());
}
}
return dash;
}
use of org.apache.poi.sl.usermodel.StrokeStyle.LineDash in project poi by apache.
the class HSLFTableCell method setBorderStyle.
@Override
public void setBorderStyle(BorderEdge edge, StrokeStyle style) {
if (style == null) {
throw new IllegalArgumentException("StrokeStyle needs to be specified.");
}
// setting the line cap is not implemented, as the border lines aren't connected
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.LineDash 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.LineDash 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.LineDash 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