Search in sources :

Example 1 with IPolyline

use of net.sf.latexdraw.models.interfaces.shape.IPolyline 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)

Example 2 with IPolyline

use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.

the class LPolyline method duplicate.

@Override
public IPolyline duplicate() {
    final IPolyline dup = ShapeFactory.INST.createPolyline(points);
    dup.copy(this);
    return dup;
}
Also used : IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline)

Example 3 with IPolyline

use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.

the class TestModifyShapeProperty method configureShapes.

private void configureShapes() {
    final IGrid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
    final IAxes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final IDot dot = ShapeFactory.INST.createDot(ShapeFactory.INST.createPoint());
    final ICircle circle = ShapeFactory.INST.createCircle();
    final IEllipse ell = ShapeFactory.INST.createEllipse();
    final IText txt = ShapeFactory.INST.createText();
    final IBezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.emptyList());
    final IPolyline pl = ShapeFactory.INST.createPolyline(Collections.emptyList());
    final IPolygon pg = ShapeFactory.INST.createPolygon(Collections.emptyList());
    final ITriangle tr = ShapeFactory.INST.createTriangle();
    final IRhombus rh = ShapeFactory.INST.createRhombus();
    final IRectangle r1 = ShapeFactory.INST.createRectangle();
    final IPlot plot = ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0d, 1d, "x", false);
    final ICircleArc carc = ShapeFactory.INST.createCircleArc();
    final ISquare sq = ShapeFactory.INST.createSquare();
    final IFreehand fh = ShapeFactory.INST.createFreeHand(Collections.emptyList());
    r1.setLineStyle(LineStyle.DASHED);
    r1.setBordersPosition(BorderPos.INTO);
    r1.setFillingStyle(FillingStyle.PLAIN);
    r1.setThickness(2.3);
    r1.setHasDbleBord(true);
    r1.setLineArc(0.2);
    r1.setDbleBordSep(1.3);
    r1.setHatchingsAngle(0.33);
    r1.setHatchingsSep(9.1);
    r1.setHatchingsWidth(12.11);
    r1.setShadowAngle(0.1);
    r1.setGradMidPt(0.66);
    r1.setHatchingsCol(DviPsColors.CYAN);
    r1.setLineColour(DviPsColors.NAVYBLUE);
    r1.setShadowSize(87.2);
    r1.setFillingCol(DviPsColors.CARNATIONPINK);
    r1.setShadowCol(DviPsColors.CORNFLOWERBLUE);
    r1.setDashSepBlack(1.2);
    r1.setDashSepWhite(2.1);
    r1.setDotSep(23.1);
    r1.setGradAngle(1.3);
    r1.setDbleBordCol(DviPsColors.RED);
    r1.setGradColEnd(DviPsColors.BITTERSWEET);
    r1.setGradColStart(DviPsColors.FORESTGREEN);
    r1.setShowPts(true);
    final IRectangle r2 = ShapeFactory.INST.createRectangle();
    r2.setLineStyle(LineStyle.SOLID);
    r2.setBordersPosition(BorderPos.MID);
    r2.setFillingStyle(FillingStyle.HLINES);
    r2.setThickness(6.3);
    r2.setHasShadow(true);
    r2.setLineArc(0.33);
    r2.setDbleBordSep(2.3);
    r2.setHatchingsAngle(-0.53);
    r2.setHatchingsSep(1.1);
    r2.setHatchingsWidth(2.11);
    r2.setShadowAngle(-0.1);
    r2.setGradMidPt(0.31);
    r2.setHatchingsCol(DviPsColors.APRICOT);
    r2.setLineColour(DviPsColors.YELLOW);
    r2.setShadowSize(8.1);
    r2.setFillingCol(DviPsColors.CERULEAN);
    r2.setShadowCol(DviPsColors.DARKORCHID);
    r1.setDashSepBlack(11.2);
    r1.setDashSepWhite(21.1);
    r1.setDotSep(231.1);
    r1.setGradAngle(11.3);
    r1.setDbleBordCol(DviPsColors.ROYALBLUE);
    r1.setGradColEnd(DviPsColors.CADETBLUE);
    r1.setGradColStart(DviPsColors.OLIVE);
    txt.copy(r1);
    ell.copy(r1);
    circle.copy(r2);
    dot.copy(r2);
    bc.copy(r2);
    pl.copy(r1);
    pg.copy(r2);
    tr.copy(r1);
    rh.copy(r2);
    plot.copy(r1);
    carc.copy(r2);
    sq.copy(r1);
    fh.copy(r2);
    group.addShape(r1);
    group.addShape(txt);
    group.addShape(grid);
    group.addShape(pl);
    group.addShape(pg);
    group.addShape(r2);
    group.addShape(axes);
    group.addShape(ell);
    group.addShape(circle);
    group.addShape(tr);
    group.addShape(rh);
    group.addShape(dot);
    group.addShape(bc);
    group.addShape(plot);
    group.addShape(carc);
    group.addShape(sq);
    group.addShape(fh);
}
Also used : IPlot(net.sf.latexdraw.models.interfaces.shape.IPlot) ICircle(net.sf.latexdraw.models.interfaces.shape.ICircle) IDot(net.sf.latexdraw.models.interfaces.shape.IDot) IEllipse(net.sf.latexdraw.models.interfaces.shape.IEllipse) IGrid(net.sf.latexdraw.models.interfaces.shape.IGrid) IAxes(net.sf.latexdraw.models.interfaces.shape.IAxes) IPolygon(net.sf.latexdraw.models.interfaces.shape.IPolygon) IFreehand(net.sf.latexdraw.models.interfaces.shape.IFreehand) IBezierCurve(net.sf.latexdraw.models.interfaces.shape.IBezierCurve) IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline) ITriangle(net.sf.latexdraw.models.interfaces.shape.ITriangle) ICircleArc(net.sf.latexdraw.models.interfaces.shape.ICircleArc) IText(net.sf.latexdraw.models.interfaces.shape.IText) ISquare(net.sf.latexdraw.models.interfaces.shape.ISquare) IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus) IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle)

Example 4 with IPolyline

use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.

the class TestParsingPsline method testCoordinatesInch.

@Test
public void testCoordinatesInch() {
    parser("\\psline(35in,20in)(1.2in,0.2in)");
    final IPolyline line = (IPolyline) listener.getShapes().get(0);
    assertEquals(35d * IShape.PPC / 2.54, line.getPtAt(0).getX(), 0.0001);
    assertEquals(-20d * IShape.PPC / 2.54, line.getPtAt(0).getY(), 0.0001);
    assertEquals(1.2 * IShape.PPC / 2.54, line.getPtAt(1).getX(), 0.0001);
    assertEquals(-0.2 * IShape.PPC / 2.54, line.getPtAt(1).getY(), 0.0001);
}
Also used : IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline) Test(org.junit.Test)

Example 5 with IPolyline

use of net.sf.latexdraw.models.interfaces.shape.IPolyline in project latexdraw by arnobl.

the class TestParsingPsline method testMoreThanTwoPointsCoordinates.

@Test
public void testMoreThanTwoPointsCoordinates() {
    parser("\\psline(5,10)(6, 7) (1, 2) % foo \n(3, \t4)");
    final IPolyline line = (IPolyline) listener.getShapes().get(0);
    assertEquals(4, line.getNbPoints());
    assertEquals(5d * IShape.PPC, line.getPtAt(0).getX(), 0.0001);
    assertEquals(-10d * IShape.PPC, line.getPtAt(0).getY(), 0.0001);
    assertEquals(6d * IShape.PPC, line.getPtAt(1).getX(), 0.0001);
    assertEquals(-7d * IShape.PPC, line.getPtAt(1).getY(), 0.0001);
    assertEquals(1d * IShape.PPC, line.getPtAt(2).getX(), 0.0001);
    assertEquals(-2d * IShape.PPC, line.getPtAt(2).getY(), 0.0001);
    assertEquals(3d * IShape.PPC, line.getPtAt(3).getX(), 0.0001);
    assertEquals(-4d * IShape.PPC, line.getPtAt(3).getY(), 0.0001);
}
Also used : IPolyline(net.sf.latexdraw.models.interfaces.shape.IPolyline) Test(org.junit.Test)

Aggregations

IPolyline (net.sf.latexdraw.models.interfaces.shape.IPolyline)25 Test (org.junit.Test)17 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)4 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)3 HelperTest (net.sf.latexdraw.HelperTest)2 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)2 ICircle (net.sf.latexdraw.models.interfaces.shape.ICircle)2 IFreehand (net.sf.latexdraw.models.interfaces.shape.IFreehand)2 IModifiablePointsShape (net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape)2 IRectangle (net.sf.latexdraw.models.interfaces.shape.IRectangle)2 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)2 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Function (java.util.function.Function)1 Platform (javafx.application.Platform)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 Point2D (javafx.geometry.Point2D)1