Search in sources :

Example 51 with Shape

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

the class TestPolyline method testIsTypeOf.

@Test
public void testIsTypeOf() {
    final Polyline shape = ShapeFactory.INST.createPolyline(Collections.emptyList());
    assertFalse(shape.isTypeOf(Rectangle.class));
    assertFalse(shape.isTypeOf(Circle.class));
    assertTrue(shape.isTypeOf(Shape.class));
    assertTrue(shape.isTypeOf(ModifiablePointsShape.class));
    assertTrue(shape.isTypeOf(Polygon.class));
    assertTrue(shape.isTypeOf(Polyline.class));
    assertTrue(shape.isTypeOf(shape.getClass()));
}
Also used : Circle(net.sf.latexdraw.model.api.shape.Circle) ModifiablePointsShape(net.sf.latexdraw.model.api.shape.ModifiablePointsShape) Shape(net.sf.latexdraw.model.api.shape.Shape) Polyline(net.sf.latexdraw.model.api.shape.Polyline) Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) ModifiablePointsShape(net.sf.latexdraw.model.api.shape.ModifiablePointsShape) Polygon(net.sf.latexdraw.model.api.shape.Polygon) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 52 with Shape

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

the class TestRhombus method testIsTypeOf.

@Test
public void testIsTypeOf() {
    final Rhombus shape = ShapeFactory.INST.createRhombus();
    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(Rhombus.class));
    assertTrue(shape.isTypeOf(shape.getClass()));
}
Also used : Circle(net.sf.latexdraw.model.api.shape.Circle) Shape(net.sf.latexdraw.model.api.shape.Shape) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) PositionShape(net.sf.latexdraw.model.api.shape.PositionShape) PositionShape(net.sf.latexdraw.model.api.shape.PositionShape) Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) Rhombus(net.sf.latexdraw.model.api.shape.Rhombus) HelperTest(net.sf.latexdraw.HelperTest) Test(org.junit.Test)

Example 53 with Shape

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

the class TestControlPointShapeBase method testDuplicateDoNotShareCtrlPoints.

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

Example 54 with Shape

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

the class TestDrawing method testSetSelectionList1.

@Test
public void testSetSelectionList1() {
    final List<Shape> list = new ArrayList<>();
    final Group selection = drawing.getSelection();
    final Shape sh = ShapeFactory.INST.createRectangle();
    list.add(sh);
    drawing.setSelection(list);
    assertEquals(selection, drawing.getSelection());
    assertEquals(1, drawing.getSelection().size());
    assertEquals(sh, drawing.getSelection().getShapeAt(0).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 55 with Shape

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

the class TestParsingShape method testParamDoublesep.

@ParameterizedTest
@MethodSource(value = "cmdUnitProvider")
void testParamDoublesep(final Tuple<String, String> cmd, final String unit) {
    parser(cmd.a + "[doubleline=true, doublesep=3.1" + unit + "]" + cmd.b);
    final Shape sh = getShapeAt(0);
    assumeTrue(sh.isDbleBorderable());
    assertEquals(PSTContext.doubleUnitToUnit(3.1, unit) * Shape.PPC, sh.getDbleBordSep(), 0.00001);
}
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