Search in sources :

Example 11 with Rectangle

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

the class TestParsingPsframe method testParse2CoordinatesFloat2.

@Test
public void testParse2CoordinatesFloat2() {
    parser("\\psframe(.5,.5)(35.5,50.5)");
    final Rectangle rec = getShapeAt(0);
    assertEquals(0.5 * Shape.PPC, rec.getPosition().getX(), 0.001);
    assertEquals(0.5 * -Shape.PPC, rec.getPosition().getY(), 0.001);
    assertEquals(35d * Shape.PPC, rec.getWidth(), 0.001);
    assertEquals(50d * Shape.PPC, rec.getHeight(), 0.001);
}
Also used : Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with Rectangle

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

the class TestParsingPsframe method testPssetunit.

@Test
public void testPssetunit() {
    parser("\\psset{unit=2}\\psframe(1,1)(5,5)");
    final Rectangle rec = getShapeAt(0);
    assertEquals(2d * Shape.PPC, rec.getX(), 0.000001);
    assertEquals(-2d * Shape.PPC, rec.getY(), 0.000001);
    assertEquals(2d * 4d * Shape.PPC, rec.getWidth(), 0.000001);
    assertEquals(2d * 4d * Shape.PPC, rec.getHeight(), 0.000001);
}
Also used : Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with Rectangle

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

the class TestParsingRPut method testDoubleRputRotationMustNotRotateOtherShapes.

@Test
void testDoubleRputRotationMustNotRotateOtherShapes() {
    parser("\\rput{10}(0,0){\\rput{80}(0,0){coucou}}\\psframe(10,10)");
    final Text txt = getShapeAt(0);
    final Rectangle rec = getShapeAt(1);
    assertEquals(Math.toRadians(-90), txt.getRotationAngle(), 0.001);
    assertEquals(0d, rec.getRotationAngle(), 0.001);
}
Also used : Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Text(net.sf.latexdraw.model.api.shape.Text) Test(org.junit.jupiter.api.Test)

Example 14 with Rectangle

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

the class TestRectangle method testIsTypeOf.

@Test
public void testIsTypeOf() {
    final Rectangle shape = ShapeFactory.INST.createRectangle();
    assertFalse(shape.isTypeOf(Ellipse.class));
    assertFalse(shape.isTypeOf(Circle.class));
    assertTrue(shape.isTypeOf(Shape.class));
    assertTrue(shape.isTypeOf(LineArcProp.class));
    assertTrue(shape.isTypeOf(PositionShape.class));
    assertTrue(shape.isTypeOf(RectangularShape.class));
    assertTrue(shape.isTypeOf(Rectangle.class));
    assertTrue(shape.isTypeOf(shape.getClass()));
}
Also used : Circle(net.sf.latexdraw.model.api.shape.Circle) Ellipse(net.sf.latexdraw.model.api.shape.Ellipse) PositionShape(net.sf.latexdraw.model.api.shape.PositionShape) Shape(net.sf.latexdraw.model.api.shape.Shape) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) PositionShape(net.sf.latexdraw.model.api.shape.PositionShape) Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) LineArcProp(net.sf.latexdraw.model.api.property.LineArcProp) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 15 with Rectangle

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

the class TestRectangle method testConstructorsOK2.

@Test
public void testConstructorsOK2() {
    final Rectangle rec = ShapeFactory.INST.createRectangle(ShapeFactory.INST.createPoint(5, 6), 11, 12);
    assertEqualsDouble(5., rec.getPosition().getX());
    assertEqualsDouble(18., rec.getPosition().getY());
    assertEqualsDouble(11., rec.getWidth());
    assertEqualsDouble(12., rec.getHeight());
}
Also used : Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Aggregations

Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)39 Test (org.junit.jupiter.api.Test)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 Test (org.junit.Test)7 HelperTest (net.sf.latexdraw.HelperTest)5 Grid (net.sf.latexdraw.model.api.shape.Grid)5 Circle (net.sf.latexdraw.model.api.shape.Circle)2 Dot (net.sf.latexdraw.model.api.shape.Dot)2 Ellipse (net.sf.latexdraw.model.api.shape.Ellipse)2 Text (net.sf.latexdraw.model.api.shape.Text)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 Point2D (javafx.geometry.Point2D)1 LineArcProp (net.sf.latexdraw.model.api.property.LineArcProp)1 Axes (net.sf.latexdraw.model.api.shape.Axes)1 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)1 CircleArc (net.sf.latexdraw.model.api.shape.CircleArc)1 Freehand (net.sf.latexdraw.model.api.shape.Freehand)1 Plot (net.sf.latexdraw.model.api.shape.Plot)1 Polygon (net.sf.latexdraw.model.api.shape.Polygon)1 Polyline (net.sf.latexdraw.model.api.shape.Polyline)1