Search in sources :

Example 1 with SVGNodeList

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

the class TestSVGNodeList method setUp.

@Before
public void setUp() {
    doc = new SVGDocument();
    list = new SVGNodeList();
}
Also used : SVGNodeList(net.sf.latexdraw.parsers.svg.SVGNodeList) SVGDocument(net.sf.latexdraw.parsers.svg.SVGDocument) Before(org.junit.Before)

Example 2 with SVGNodeList

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

the class SVGAxes method setAxesStyleFromSVG.

private void setAxesStyleFromSVG(final SVGGElement elt) {
    /* Looking for the two axe in order to get the position of the axes. */
    final SVGNodeList nl = elt.getChildren(SVGElements.SVG_G);
    int i = 0;
    final int size = nl.getLength();
    SVGGElement l1 = null;
    SVGGElement l2 = null;
    SVGElement element;
    while ((l1 == null || l2 == null) && i < size) {
        element = nl.item(i);
        if (element instanceof SVGGElement) {
            if (l1 == null) {
                l1 = (SVGGElement) element;
            } else {
                l2 = (SVGGElement) element;
            }
        }
        i++;
    }
    if (l1 != null && l2 != null) {
        try {
            final IPolyline la = new SVGPolylines(l1, false).shape;
            final IPolyline lb = new SVGPolylines(l2, false).shape;
            // now, a translation is used.
            if (elt.getTransform().stream().noneMatch(tr -> tr.isTranslation())) {
                shape.setPosition(ShapeFactory.INST.createPoint(lb.getPtAt(0).getX(), la.getPtAt(0).getY()));
            }
            // End of legacy
            shape.setLineStyle(la.getLineStyle());
            shape.getArrowAt(1).setArrowStyle(la.getArrowAt(0).getArrowStyle());
            shape.getArrowAt(3).setArrowStyle(la.getArrowAt(1).getArrowStyle());
            shape.getArrowAt(0).setArrowStyle(lb.getArrowAt(0).getArrowStyle());
            shape.getArrowAt(2).setArrowStyle(lb.getArrowAt(1).getArrowStyle());
        } catch (final IllegalArgumentException ex) {
            BadaboomCollector.INSTANCE.add(ex);
        }
    }
}
Also used : SVGNodeList(net.sf.latexdraw.parsers.svg.SVGNodeList) SVGGElement(net.sf.latexdraw.parsers.svg.SVGGElement) SVGElement(net.sf.latexdraw.parsers.svg.SVGElement) IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Aggregations

SVGNodeList (net.sf.latexdraw.parsers.svg.SVGNodeList)2 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)1 IPolyline (net.sf.latexdraw.models.interfaces.shape.IPolyline)1 SVGDocument (net.sf.latexdraw.parsers.svg.SVGDocument)1 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)1 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)1 Before (org.junit.Before)1