Search in sources :

Example 1 with Square

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

the class TestSquare method testConstructorsOKPoints.

@Test
public void testConstructorsOKPoints() {
    final Square sq = ShapeFactory.INST.createSquare();
    assertEquals(4, sq.getNbPoints());
}
Also used : Square(net.sf.latexdraw.model.api.shape.Square) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 2 with Square

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

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

the class TestCanvasCreation method testDrawSquare.

@Test
public void testDrawSquare() {
    final Point2D pos = point(canvas).query();
    Cmds.of(CmdFXVoid.of(() -> editing.setCurrentChoice(EditionChoice.SQUARE)), () -> drag(pos, MouseButton.PRIMARY).dropBy(101d, 11d)).execute();
    assertEquals(1, drawing.size());
    assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Square);
    assertEquals(202d, drawing.getShapeAt(0).orElseThrow().getWidth(), 0.00001d);
    assertEquals(202d, drawing.getShapeAt(0).orElseThrow().getHeight(), 0.00001d);
    assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX() - 101d, drawing.getShapeAt(0).orElseThrow().getTopLeftPoint().getX(), 0.00001d);
    assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY() - 101d, drawing.getShapeAt(0).orElseThrow().getTopLeftPoint().getY(), 0.00001d);
}
Also used : Point2D(javafx.geometry.Point2D) Square(net.sf.latexdraw.model.api.shape.Square) Test(org.junit.Test)

Example 4 with Square

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

the class ModifyShapePropertyTest method commonCanDoFixture.

@Override
protected void commonCanDoFixture() {
    shapes = ShapeFactory.INST.createGroup();
    final Grid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
    final Axes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final Dot dot = ShapeFactory.INST.createDot(ShapeFactory.INST.createPoint());
    final Circle circle = ShapeFactory.INST.createCircle();
    final Ellipse ell = ShapeFactory.INST.createEllipse();
    final Text txt = ShapeFactory.INST.createText();
    final BezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.emptyList());
    final Polyline pl = ShapeFactory.INST.createPolyline(Collections.emptyList());
    final Polygon pg = ShapeFactory.INST.createPolygon(Collections.emptyList());
    final Triangle tr = ShapeFactory.INST.createTriangle();
    final Rhombus rh = ShapeFactory.INST.createRhombus();
    final Rectangle r1 = ShapeFactory.INST.createRectangle();
    final Plot plot = ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0d, 1d, "x", false);
    final CircleArc carc = ShapeFactory.INST.createCircleArc();
    final Square sq = ShapeFactory.INST.createSquare();
    final Freehand fh = ShapeFactory.INST.createFreeHand(Collections.emptyList());
    r1.setLineStyle(LineStyle.DASHED);
    r1.setBordersPosition(BorderPos.INTO);
    r1.setFillingStyle(FillingStyle.PLAIN);
    r1.setThickness(2.3);
    r1.setHasDbleBord(true);
    r1.setLineArc(0.2);
    r1.setDbleBordSep(1.3);
    r1.setHatchingsAngle(0.33);
    r1.setHatchingsSep(9.1);
    r1.setHatchingsWidth(12.11);
    r1.setShadowAngle(0.1);
    r1.setGradMidPt(0.66);
    r1.setHatchingsCol(DviPsColors.CYAN);
    r1.setLineColour(DviPsColors.NAVYBLUE);
    r1.setShadowSize(87.2);
    r1.setFillingCol(DviPsColors.CARNATIONPINK);
    r1.setShadowCol(DviPsColors.CORNFLOWERBLUE);
    r1.setDashSepBlack(1.2);
    r1.setDashSepWhite(2.1);
    r1.setDotSep(23.1);
    r1.setGradAngle(1.3);
    r1.setDbleBordCol(DviPsColors.RED);
    r1.setGradColEnd(DviPsColors.BITTERSWEET);
    r1.setGradColStart(DviPsColors.FORESTGREEN);
    r1.setShowPts(true);
    final Rectangle r2 = ShapeFactory.INST.createRectangle();
    r2.setLineStyle(LineStyle.SOLID);
    r2.setBordersPosition(BorderPos.MID);
    r2.setFillingStyle(FillingStyle.HLINES);
    r2.setThickness(6.3);
    r2.setHasShadow(true);
    r2.setLineArc(0.33);
    r2.setDbleBordSep(2.3);
    r2.setHatchingsAngle(-0.53);
    r2.setHatchingsSep(1.1);
    r2.setHatchingsWidth(2.11);
    r2.setShadowAngle(-0.1);
    r2.setGradMidPt(0.31);
    r2.setHatchingsCol(DviPsColors.APRICOT);
    r2.setLineColour(DviPsColors.YELLOW);
    r2.setShadowSize(8.1);
    r2.setFillingCol(DviPsColors.CERULEAN);
    r2.setShadowCol(DviPsColors.DARKORCHID);
    r1.setDashSepBlack(11.2);
    r1.setDashSepWhite(21.1);
    r1.setDotSep(231.1);
    r1.setGradAngle(11.3);
    r1.setDbleBordCol(DviPsColors.ROYALBLUE);
    r1.setGradColEnd(DviPsColors.CADETBLUE);
    r1.setGradColStart(DviPsColors.OLIVE);
    dot.setDotStyle(DotStyle.DIAMOND);
    txt.copy(r1);
    ell.copy(r1);
    circle.copy(r2);
    dot.copy(r2);
    bc.copy(r2);
    pl.copy(r1);
    pg.copy(r2);
    tr.copy(r1);
    rh.copy(r2);
    plot.copy(r1);
    carc.copy(r2);
    sq.copy(r1);
    fh.copy(r2);
    sq.setFillingStyle(FillingStyle.GRAD);
    shapes.addShape(r1);
    shapes.addShape(txt);
    shapes.addShape(grid);
    shapes.addShape(pl);
    shapes.addShape(pg);
    shapes.addShape(r2);
    shapes.addShape(axes);
    shapes.addShape(ell);
    shapes.addShape(circle);
    shapes.addShape(tr);
    shapes.addShape(rh);
    shapes.addShape(dot);
    shapes.addShape(bc);
    shapes.addShape(plot);
    shapes.addShape(carc);
    shapes.addShape(sq);
    shapes.addShape(fh);
}
Also used : Circle(net.sf.latexdraw.model.api.shape.Circle) Ellipse(net.sf.latexdraw.model.api.shape.Ellipse) Grid(net.sf.latexdraw.model.api.shape.Grid) Plot(net.sf.latexdraw.model.api.shape.Plot) Dot(net.sf.latexdraw.model.api.shape.Dot) Triangle(net.sf.latexdraw.model.api.shape.Triangle) Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Freehand(net.sf.latexdraw.model.api.shape.Freehand) Text(net.sf.latexdraw.model.api.shape.Text) Rhombus(net.sf.latexdraw.model.api.shape.Rhombus) Square(net.sf.latexdraw.model.api.shape.Square) Polyline(net.sf.latexdraw.model.api.shape.Polyline) CircleArc(net.sf.latexdraw.model.api.shape.CircleArc) Axes(net.sf.latexdraw.model.api.shape.Axes) BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Polygon(net.sf.latexdraw.model.api.shape.Polygon)

Example 5 with Square

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

the class TestSquare method testConstructorsOK.

@Test
public void testConstructorsOK() {
    final Square sq = ShapeFactory.INST.createSquare(ShapeFactory.INST.createPoint(20, 26), 11);
    assertEqualsDouble(20., sq.getPosition().getX());
    assertEqualsDouble(26., sq.getPosition().getY());
    assertEqualsDouble(11., sq.getWidth());
    assertEqualsDouble(11., sq.getHeight());
}
Also used : Square(net.sf.latexdraw.model.api.shape.Square) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Aggregations

Square (net.sf.latexdraw.model.api.shape.Square)5 Test (org.junit.Test)4 HelperTest (net.sf.latexdraw.HelperTest)3 Circle (net.sf.latexdraw.model.api.shape.Circle)2 Grid (net.sf.latexdraw.model.api.shape.Grid)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 Dot (net.sf.latexdraw.model.api.shape.Dot)1 Ellipse (net.sf.latexdraw.model.api.shape.Ellipse)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 PositionShape (net.sf.latexdraw.model.api.shape.PositionShape)1 Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)1 Rhombus (net.sf.latexdraw.model.api.shape.Rhombus)1 Shape (net.sf.latexdraw.model.api.shape.Shape)1