Search in sources :

Example 31 with Rectangle

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

the class TestParsingPsframe method testPssetunitxunit.

@Test
public void testPssetunitxunit() {
    parser("\\psset{unit=2,xunit=3}\\psframe(1,1)(5,5)");
    final Rectangle rec = getShapeAt(0);
    assertEquals(2d * 3d * Shape.PPC, rec.getX(), 0.000001);
    assertEquals(-2d * Shape.PPC, rec.getY(), 0.000001);
    assertEquals(2d * 4d * 3d * 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 32 with Rectangle

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

the class TestParsingPsframe method testCoordinatesPt.

@Test
public void testCoordinatesPt() {
    parser("\\psframe(0,0)(35pt,20pt)");
    final Rectangle rec = getShapeAt(0);
    assertEquals(0d, rec.getPosition().getX(), 0.001);
    assertEquals(0d, rec.getPosition().getY(), 0.001);
    assertEquals(35d * Shape.PPC / PSTricksConstants.CM_VAL_PT, rec.getWidth(), 0.001);
    assertEquals(20d * Shape.PPC / PSTricksConstants.CM_VAL_PT, 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 33 with Rectangle

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

the class TestParsingPsframe method testPssetunityunit.

@Test
public void testPssetunityunit() {
    parser("\\psset{unit=2,yunit=3}\\psframe(1,1)(5,5)");
    final Rectangle rec = getShapeAt(0);
    assertEquals(2d * Shape.PPC, rec.getX(), 0.000001);
    assertEquals(-2d * 3d * Shape.PPC, rec.getY(), 0.000001);
    assertEquals(2d * 4d * Shape.PPC, rec.getWidth(), 0.000001);
    assertEquals(2d * 4d * 3d * 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 34 with Rectangle

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

the class TestParsingPsframe method testParamFramearcKO.

@ParameterizedTest
@ValueSource(doubles = { -1d, 2 })
public void testParamFramearcKO(final double arc) {
    parser("\\psframe[framearc=" + arc + "](35,20)");
    final Rectangle rec = getShapeAt(0);
    assertEquals(0d, rec.getLineArc(), 0.00001);
}
Also used : Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with Rectangle

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

the class TestPSTGeneralFeatures method testBugpssetsetOfShapes.

@Test
void testBugpssetsetOfShapes() {
    parser("\\psframe(0.5,0.5)(1.5,1.5)\\psdot[linewidth=1cm,dotsize=1](1,1)\\psset{unit=2}\\psframe(0.5,0.5)(1.5,1.5)\\psdot(2," + "2)");
    Rectangle rec = getShapeAt(0);
    assertEquals(0.5 * Shape.PPC, rec.getX(), 0.000001);
    assertEquals(-0.5 * Shape.PPC, rec.getY(), 0.000001);
    assertEquals(Shape.PPC, rec.getWidth(), 0.000001);
    assertEquals(Shape.PPC, rec.getHeight(), 0.000001);
    Dot dot = getShapeAt(1);
    assertEquals(Shape.PPC, dot.getX(), 0.000001);
    assertEquals(-Shape.PPC, dot.getY(), 0.000001);
    rec = getShapeAt(2);
    assertEquals(0.5 * 2d * Shape.PPC, rec.getX(), 0.000001);
    assertEquals(-0.5 * 2d * Shape.PPC, rec.getY(), 0.000001);
    assertEquals(2d * Shape.PPC, rec.getWidth(), 0.000001);
    assertEquals(2d * Shape.PPC, rec.getHeight(), 0.000001);
    dot = getShapeAt(3);
    assertEquals(2d * 2d * Shape.PPC, dot.getX(), 0.000001);
    assertEquals(-2d * 2d * Shape.PPC, dot.getY(), 0.000001);
}
Also used : Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Dot(net.sf.latexdraw.model.api.shape.Dot) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

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