Search in sources :

Example 21 with Shape

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

the class TestShape method testDuplicateDoNotSharePoints.

@Theory
public void testDuplicateDoNotSharePoints(@ShapeData final Shape shape) {
    final List<Point> pts = cloneList(shape.getPoints(), pt -> ShapeFactory.INST.createPoint(pt));
    final Shape sh = shape.duplicate();
    sh.translate(11d, 12d);
    assertEquals(pts, shape.getPoints());
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 22 with Shape

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

the class TestDrawing method testSetSelectionList2.

@Test
public void testSetSelectionList2() {
    final List<Shape> list = new ArrayList<>();
    final Group selection = drawing.getSelection();
    final Shape sh = ShapeFactory.INST.createRectangle();
    final Shape sh2 = ShapeFactory.INST.createRectangle();
    list.add(sh);
    list.add(sh2);
    drawing.setSelection(list);
    assertEquals(selection, drawing.getSelection());
    assertEquals(2, drawing.getSelection().size());
    assertEquals(sh, drawing.getSelection().getShapeAt(0).orElseThrow());
    assertEquals(sh2, drawing.getSelection().getShapeAt(1).orElseThrow());
}
Also used : Group(net.sf.latexdraw.model.api.shape.Group) Shape(net.sf.latexdraw.model.api.shape.Shape) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 23 with Shape

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

the class TestEllipse method testIsTypeOf.

@Test
public void testIsTypeOf() {
    final Ellipse shape = ShapeFactory.INST.createEllipse();
    assertFalse(shape.isTypeOf(Rectangle.class));
    assertFalse(shape.isTypeOf(Circle.class));
    assertTrue(shape.isTypeOf(Shape.class));
    assertTrue(shape.isTypeOf(PositionShape.class));
    assertTrue(shape.isTypeOf(RectangularShape.class));
    assertTrue(shape.isTypeOf(Ellipse.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) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 24 with Shape

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

the class PolymorphShapeTest method testLoadShapeShowPtsParams.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
default void testLoadShapeShowPtsParams(final Shape sh) {
    assumeTrue(sh.isShowPtsable());
    final Shape s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualShapeShowPts(sh, s2);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 25 with Shape

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

the class PolymorphShapeTest method testLoadFillStyleParams.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
default void testLoadFillStyleParams(final Shape sh) {
    assumeTrue(sh.isInteriorStylable());
    final Shape s2 = produceOutputShapeFrom(sh);
    CompareShapeMatcher.INST.assertEqualShapeFillStyle(sh, s2);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

Shape (net.sf.latexdraw.model.api.shape.Shape)75 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 MethodSource (org.junit.jupiter.params.provider.MethodSource)41 Test (org.junit.Test)12 Point (net.sf.latexdraw.model.api.shape.Point)8 PositionShape (net.sf.latexdraw.model.api.shape.PositionShape)7 HelperTest (net.sf.latexdraw.HelperTest)6 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)6 Circle (net.sf.latexdraw.model.api.shape.Circle)6 RectangularShape (net.sf.latexdraw.model.api.shape.RectangularShape)6 NotNull (org.jetbrains.annotations.NotNull)6 Click (io.github.interacto.jfx.interaction.library.Click)5 ArrayList (java.util.ArrayList)5 Objects (java.util.Objects)5 MathUtils (net.sf.latexdraw.model.MathUtils)5 Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)5 Inject (net.sf.latexdraw.util.Inject)5 CommandsRegistry (io.github.interacto.command.CommandsRegistry)3 Redo (io.github.interacto.command.library.Redo)3 Undo (io.github.interacto.command.library.Undo)3