use of net.sf.latexdraw.parsers.svg.SVGMarkerElement in project latexdraw by arnobl.
the class SVGArrow method toSVG.
/**
* Return the SVG tree of the arrowhead or null if this arrowhead has no style.
* @param document The document used to create elements.
* @param isShadow True: this operation is call to create the SVG shadow of the shape.
* @return The SVG tree of the arrowhead or null if the document is null.
*/
public SVGElement toSVG(final SVGDocument document, final boolean isShadow) {
if (document == null || !arrow.hasStyle()) {
return null;
}
final ILine line = arrow.getArrowLine();
final double lineAngle = (-line.getLineAngle() + Math.PI * 2d) % (Math.PI * 2d);
currentDoc = document;
currentMarker = new SVGMarkerElement(document);
currentMarker.setAttribute(SVGAttributes.SVG_OVERFLOW, SVGAttributes.SVG_VALUE_VISIBLE);
currentMarker.setAttribute(SVGAttributes.SVG_MARKER_UNITS, SVGAttributes.SVG_UNITS_VALUE_USR);
if (arrow.getArrowStyle() != ArrowStyle.NONE && !MathUtils.INST.equalsDouble(lineAngle, 0d)) {
currentMarker.setAttribute(SVGAttributes.SVG_ORIENT, MathUtils.INST.format.format(Math.toDegrees(lineAngle)));
} else {
currentMarker.setAttribute(SVGAttributes.SVG_ORIENT, SVGAttributes.SVG_VALUE_AUTO);
}
updatePath(isShadow);
if (currentPath != null) {
createPathElement();
currentPathElt.setAttribute(SVGAttributes.SVG_D, currentPath.toString());
currentPathElt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_ARROW_SIZE_NUM, MathUtils.INST.format.format(arrow.getArrowSizeNum()));
currentPathElt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_ARROW_TBAR_SIZE_NUM, MathUtils.INST.format.format(arrow.getTBarSizeNum()));
}
return currentMarker;
}
Aggregations