Search in sources :

Example 16 with Shape

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

the class ViewShape method getActivatedGroupNodes.

private static Collection<javafx.scene.shape.Shape> getActivatedGroupNodes(final Group gp) {
    // Adding all the shape children
    final Collection<javafx.scene.shape.Shape> shapes = gp.getChildren().stream().filter(node -> node instanceof javafx.scene.shape.Shape && node.isVisible() && !node.isDisable()).map(node -> (javafx.scene.shape.Shape) node).collect(Collectors.toList());
    // Adding all the view shape children
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ViewShape<?> && node.isVisible() && !node.isDisable()).map(vs -> ((ViewShape<?>) vs).getActivatedShapes()).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the shapes contained in groups that are not view shapes
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof Group && !(node instanceof ViewShape<?>)).map(node -> getActivatedGroupNodes((Group) node)).flatMap(st -> st.stream()).collect(Collectors.toList()));
    // Adding the images contained in the group
    shapes.addAll(gp.getChildren().stream().filter(node -> node instanceof ImageView && node.isVisible() && !node.isDisable()).map(node -> {
        final Bounds bounds = node.getBoundsInParent();
        final Rectangle rec = new Rectangle(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
        rec.setFill(Color.WHITE);
        rec.getTransforms().setAll(gp.getLocalToSceneTransform());
        return rec;
    }).collect(Collectors.toList()));
    return shapes;
}
Also used : Parent(javafx.scene.Parent) Color(javafx.scene.paint.Color) Shape(net.sf.latexdraw.model.api.shape.Shape) Flushable(net.sf.latexdraw.util.Flushable) ImageView(javafx.scene.image.ImageView) Collection(java.util.Collection) Optional(java.util.Optional) Rectangle(javafx.scene.shape.Rectangle) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) Bounds(javafx.geometry.Bounds) Group(javafx.scene.Group) Shape(net.sf.latexdraw.model.api.shape.Shape) Bounds(javafx.geometry.Bounds) Rectangle(javafx.scene.shape.Rectangle) ImageView(javafx.scene.image.ImageView)

Example 17 with Shape

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

the class TestSquare method testIsTypeOf.

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

Example 18 with Shape

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

the class TestTriangle method testIsTypeOf.

@Test
public void testIsTypeOf() {
    final Triangle shape = ShapeFactory.INST.createTriangle();
    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(Triangle.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) Triangle(net.sf.latexdraw.model.api.shape.Triangle) Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) HelperTest(net.sf.latexdraw.HelperTest) Test(org.junit.Test)

Example 19 with Shape

use of net.sf.latexdraw.model.api.shape.Shape 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 20 with Shape

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

the class TestShape method testDuplicate.

@Theory
public void testDuplicate(@ShapeData final Shape shape) {
    final Shape sh = shape.duplicate();
    assertNotNull(sh);
    assertEquals(sh.getClass(), shape.getClass());
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) Theory(org.junit.experimental.theories.Theory)

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