// only BasisStrokes are written
if (!(s instanceof BasicStroke)) {
return result;
}
BasicStroke stroke = (BasicStroke) s;
// append linecap
if (all || (stroke.getEndCap() != defaultStroke.getEndCap())) {
// append cap
switch (stroke.getEndCap()) {
default:
case BasicStroke.CAP_BUTT:
result.put("stroke-linecap", "butt");
break;
case BasicStroke.CAP_ROUND:
result.put("stroke-linecap", "round");
break;
case BasicStroke.CAP_SQUARE:
result.put("stroke-linecap", "square");
break;
}
}
// append dasharray
if (all
|| !Arrays.equals(stroke.getDashArray(), defaultStroke
.getDashArray())) {
if (stroke.getDashArray() != null
&& stroke.getDashArray().length > 0) {
StringBuffer array = new StringBuffer();
for (int i = 0; i < stroke.getDashArray().length; i++) {
if (i > 0) {
array.append(",");
}
// SVG does not allow dash entry to be zero (Firefox 2.0).
float dash = stroke.getDashArray()[i];
array.append(fixedPrecision(dash > 0 ? dash : 0.1));
}
result.put("stroke-dasharray", array.toString());
} else {
result.put("stroke-dasharray", "none");
}
}
if (all || (stroke.getDashPhase() != defaultStroke.getDashPhase())) {
result.put("stroke-dashoffset", fixedPrecision(stroke.getDashPhase()));
}
// append meter limit
if (all || (stroke.getMiterLimit() != defaultStroke.getMiterLimit())) {
result.put("stroke-miterlimit", fixedPrecision(stroke.getMiterLimit()));
}
// append join
if (all || (stroke.getLineJoin() != defaultStroke.getLineJoin())) {
switch (stroke.getLineJoin()) {
default:
case BasicStroke.JOIN_MITER:
result.put("stroke-linejoin", "miter");
break;
case BasicStroke.JOIN_ROUND:
result.put("stroke-linejoin", "round");
break;
case BasicStroke.JOIN_BEVEL:
result.put("stroke-linejoin", "bevel");
break;
}
}
// append linewidth
if (all || (stroke.getLineWidth() != defaultStroke.getLineWidth())) {
// width of 0 means thinnest line, which does not exist in SVG
if (stroke.getLineWidth() == 0) {
result.put("stroke-width", fixedPrecision(0.000001f));
} else {
result.put("stroke-width", fixedPrecision(stroke.getLineWidth()));
}
}
return result;
}