Search in sources :

Example 1 with SVGEllipseElement

use of net.sf.latexdraw.parsers.svg.SVGEllipseElement in project latexdraw by arnobl.

the class SVGEllipse method toSVG.

@Override
public SVGElement toSVG(final SVGDocument doc) {
    if (doc == null || doc.getFirstChild().getDefs() == null)
        throw new IllegalArgumentException();
    final IPoint tl = shape.getTopLeftPoint();
    final IPoint br = shape.getBottomRightPoint();
    final double tlx = tl.getX();
    final double tly = tl.getY();
    final double brx = br.getX();
    final double bry = br.getY();
    SVGElement elt;
    final SVGElement root = new SVGGElement(doc);
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_ELLIPSE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    final double gap = getPositionGap();
    final double width = Math.max(1., (brx - tlx + gap) / 2.);
    final double height = Math.max(1., (bry - tly + gap) / 2.);
    final double x = (brx + tlx) / 2.;
    final double y = (bry + tly) / 2.;
    if (shape.hasShadow()) {
        elt = new SVGEllipseElement(x, y, width, height, doc);
        setSVGShadowAttributes(elt, true);
        root.appendChild(elt);
    }
    if (shape.hasShadow() && !shape.getLineStyle().getLatexToken().equals(PSTricksConstants.LINE_NONE_STYLE)) {
        // The background of the borders must be filled is there is a shadow.
        elt = new SVGEllipseElement(x, y, width, height, doc);
        setSVGBorderBackground(elt, root);
    }
    elt = new SVGEllipseElement(x, y, width, height, doc);
    setSVGAttributes(doc, elt, true);
    root.appendChild(elt);
    if (shape.hasDbleBord()) {
        elt = new SVGEllipseElement(x, y, width, height, doc);
        setSVGDoubleBordersAttributes(elt);
        root.appendChild(elt);
    }
    setSVGRotationAttribute(root);
    return root;
}
Also used : SVGGElement(net.sf.latexdraw.parsers.svg.SVGGElement) SVGElement(net.sf.latexdraw.parsers.svg.SVGElement) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) SVGEllipseElement(net.sf.latexdraw.parsers.svg.SVGEllipseElement)

Example 2 with SVGEllipseElement

use of net.sf.latexdraw.parsers.svg.SVGEllipseElement in project latexdraw by arnobl.

the class JFXToSVG method ellipseToSVGEllipse.

public SVGEllipseElement ellipseToSVGEllipse(final Ellipse ell, final SVGDocument doc) {
    final SVGEllipseElement elt = new SVGEllipseElement(ell.getCenterX(), ell.getCenterY(), ell.getRadiusX(), ell.getRadiusY(), doc);
    copyPropertiesToSVG(elt, ell);
    return elt;
}
Also used : SVGEllipseElement(net.sf.latexdraw.parsers.svg.SVGEllipseElement)

Aggregations

SVGEllipseElement (net.sf.latexdraw.parsers.svg.SVGEllipseElement)2 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)1 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)1 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)1