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();
}
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);
}
}
}
Aggregations