Search in sources :

Example 1 with Line

use of net.sf.latexdraw.model.api.shape.Line in project latexdraw by arnobl.

the class TestBorder method testArcEndHandlerRotated.

@Test
public void testArcEndHandlerRotated() {
    Cmds.of(addArc, selectAllShapes, () -> addedArc.setRotationAngle(0.5)).execute();
    final Point gc = addedArc.getGravityCentre();
    final Point point = addedArc.getEndPoint().rotatePoint(addedArc.getGravityCentre(), addedArc.getRotationAngle());
    final Point newpoint = point.rotatePoint(gc, Math.PI / 3d).rotatePoint(addedArc.getGravityCentre(), addedArc.getRotationAngle());
    Cmds.of(() -> drag(border.arcHandlerEnd).dropBy(newpoint.getX() - point.getX(), newpoint.getY() - point.getY())).execute();
    final Line l1 = ShapeFactory.INST.createLine(gc, addedArc.getEndPoint().rotatePoint(addedArc.getGravityCentre(), addedArc.getRotationAngle()));
    final Line l2 = ShapeFactory.INST.createLine(gc, newpoint);
    assertEquals(l1.getA(), l2.getA(), 0.02);
}
Also used : Line(net.sf.latexdraw.model.api.shape.Line) Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 2 with Line

use of net.sf.latexdraw.model.api.shape.Line in project latexdraw by arnobl.

the class TestBorder method testArcStartHandler.

@Test
public void testArcStartHandler() {
    Cmds.of(addArc, selectAllShapes).execute();
    final Point gc = addedArc.getGravityCentre();
    final Point point = ShapeFactory.INST.createPoint(addedArc.getStartPoint());
    final Point newpoint = point.rotatePoint(gc, -Math.PI / 4d);
    Cmds.of(() -> drag(border.arcHandlerStart).dropBy(newpoint.getX() - point.getX(), newpoint.getY() - point.getY())).execute();
    final Line l1 = ShapeFactory.INST.createLine(gc, ShapeFactory.INST.createPoint(addedArc.getStartPoint()));
    final Line l2 = ShapeFactory.INST.createLine(gc, newpoint);
    assertEquals(l1.getA(), l2.getA(), 0.02);
}
Also used : Line(net.sf.latexdraw.model.api.shape.Line) Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 3 with Line

use of net.sf.latexdraw.model.api.shape.Line in project latexdraw by arnobl.

the class TestCircleArc method testGetArrowLineArrow0StartLesserEnd.

@Theory
public void testGetArrowLineArrow0StartLesserEnd(@ArcData final CircleArc shape) {
    shape.setPosition(0d, 0d);
    shape.setWidth(10d);
    shape.setAngleStart(Math.PI * 1.3);
    shape.setAngleEnd(Math.PI * 1.5);
    shape.setArrowStyle(ArrowStyle.RIGHT_ARROW, 0);
    final Line line = shape.getArrowLine(0);
    assertThat(line.getX1()).isLessThan(line.getX2());
    assertTrue(line.getY1() > line.getY2());
}
Also used : Line(net.sf.latexdraw.model.api.shape.Line) Theory(org.junit.experimental.theories.Theory)

Example 4 with Line

use of net.sf.latexdraw.model.api.shape.Line in project latexdraw by arnobl.

the class TestLine method testGetIntersectionSegment.

@Test
public void testGetIntersectionSegment() {
    final Line line2 = ShapeFactory.INST.createLine(0, 0, 1, 0);
    line.setLine(1, 1, 0, -1);
    line.updateAandB();
    final Point pt = line.getIntersectionSegment(line2);
    assertNotNull(pt);
    assertEqualsDouble(0.5, pt.getX());
    assertEqualsDouble(0d, pt.getY());
}
Also used : Line(net.sf.latexdraw.model.api.shape.Line) Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 5 with Line

use of net.sf.latexdraw.model.api.shape.Line in project latexdraw by arnobl.

the class TestLine method testGetIntersectionVert.

@Test
public void testGetIntersectionVert() {
    final Line line2 = ShapeFactory.INST.createLine(0, 0, 1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    final Point pt = line.getIntersection(line2);
    assertNotNull(pt);
    assertEqualsDouble(0d, pt.getX());
    assertEqualsDouble(0d, pt.getY());
}
Also used : Line(net.sf.latexdraw.model.api.shape.Line) Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Aggregations

Line (net.sf.latexdraw.model.api.shape.Line)21 Test (org.junit.Test)12 Point (net.sf.latexdraw.model.api.shape.Point)10 HelperTest (net.sf.latexdraw.HelperTest)7 Theory (org.junit.experimental.theories.Theory)4 Rotate (javafx.scene.transform.Rotate)1 SVGMarkerElement (net.sf.latexdraw.parser.svg.SVGMarkerElement)1