use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.
the class SVGPathElement method isLines.
/**
* @return True if the path is composed of lines and has a 'close path' segment at the end.
* @since 0.1
*/
public boolean isLines() {
final SVGPathSegList segList = getSegList();
if (segList.size() < 3 || !(segList.get(0) instanceof SVGPathSegMoveto))
return false;
boolean ok = true;
int i;
final int size;
for (i = 1, size = segList.size() - 1; i < size && ok; i++) if (!(segList.get(i) instanceof SVGPathSegLineto))
ok = false;
return ok;
}
use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.
the class SVGPathParser method parseMoveto.
/**
* Parses an SVGPath moveto.
* @param isRelative True if segment is relative.
* @throws ParseException If a problem occurs.
*/
protected void parseMoveto(final boolean isRelative) throws ParseException {
nextChar();
skipWSP();
final double x = parseNumber(false);
skipWSPComma();
final double y = parseNumber(false);
skipWSPComma();
handler.onPathSeg(new SVGPathSegMoveto(x, y, isRelative));
parserPathSeg(isRelative);
}
use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.
the class TestSVGPathSegArc method testToString.
@Test
public void testToString() throws ParseException {
SVGPathSegMoveto m = new SVGPathSegMoveto(0, 0, false);
SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
cpt++;
return;
}
assertTrue(pathSeg instanceof SVGPathSegArc);
SVGPathSegArc seg2 = (SVGPathSegArc) pathSeg;
assertEquals(seg.getAngle(), seg2.getAngle(), 0.0001);
assertEquals(seg.getRX(), seg2.getRX(), 0.0001);
assertEquals(seg.getRY(), seg2.getRY(), 0.0001);
assertEquals(seg.getX(), seg2.getX(), 0.0001);
assertEquals(seg.getY(), seg2.getY(), 0.0001);
assertEquals(seg.isLargeArcFlag(), seg2.isLargeArcFlag());
assertEquals(seg.isRelative(), seg2.isRelative());
assertEquals(seg.isSweepFlag(), seg2.isSweepFlag());
});
parser.parse();
}
use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.
the class TestSVGPathSegCurvetoCubic method testToString.
@Test
public void testToString() throws ParseException {
SVGPathSegMoveto m = new SVGPathSegMoveto(0, 0, false);
SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
cpt++;
return;
}
assertTrue(pathSeg instanceof SVGPathSegCurvetoCubic);
SVGPathSegCurvetoCubic seg2 = (SVGPathSegCurvetoCubic) pathSeg;
assertEquals(seg.getX(), seg2.getX(), 0.0001);
assertEquals(seg.getY(), seg2.getY(), 0.0001);
assertEquals(seg.isRelative(), seg2.isRelative());
});
parser.parse();
}
use of net.sf.latexdraw.parsers.svg.path.SVGPathSegMoveto in project latexdraw by arnobl.
the class TestSVGPathSegCurvetoCubicSmooth method testToString.
@Test
public void testToString() throws ParseException {
SVGPathSegMoveto m = new SVGPathSegMoveto(0d, 0d, false);
SVGPathParser parser = new SVGPathParser(m.toString() + " " + seg.toString(), pathSeg -> {
if (pathSeg instanceof SVGPathSegMoveto && cpt == 0) {
cpt++;
return;
}
assertTrue(pathSeg instanceof SVGPathSegCurvetoCubicSmooth);
SVGPathSegCurvetoCubicSmooth seg2 = (SVGPathSegCurvetoCubicSmooth) pathSeg;
assertEquals(seg.getX(), seg2.getX(), 0.0001);
assertEquals(seg.getY(), seg2.getY(), 0.0001);
assertEquals(seg.isRelative(), seg2.isRelative());
});
parser.parse();
}
Aggregations