Search in sources :

Example 36 with Point

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

the class TestPositionShapeBase method testGetSetPosition.

@Theory
public void testGetSetPosition(@PosShapeData final PositionShape shape) {
    final Point pt = ShapeFactory.INST.createPoint(15d, 25d);
    shape.setPosition(pt);
    assertEqualsDouble(pt.getX(), shape.getPosition().getX());
    assertEqualsDouble(pt.getY(), shape.getPosition().getY());
    assertEqualsDouble(15d, shape.getX());
    assertEqualsDouble(25d, shape.getY());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 37 with Point

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

the class TestPositionShapeBase method testGetSetPositionKO.

@Theory
public void testGetSetPositionKO(@PosShapeData final PositionShape shape, @DoubleData(vals = {}, bads = true) final double value) {
    final Point pt = ShapeFactory.INST.createPoint(15d, 25d);
    shape.setPosition(pt);
    shape.setPosition(ShapeFactory.INST.createPoint(value, value));
    assertEqualsDouble(pt.getX(), shape.getPosition().getX());
    assertEqualsDouble(pt.getY(), shape.getPosition().getY());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 38 with Point

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

the class TestRectangularShapeBase method testMirrorVertical.

@Theory
public void testMirrorVertical(@RectangularData final RectangularShape shape) {
    final Point p1 = ShapeFactory.INST.createPoint(4, 1);
    final Point p2 = ShapeFactory.INST.createPoint(1, 3);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.setHeight(p2.getY() - p1.getY());
    shape.mirrorVertical(shape.getGravityCentre().getY());
    assertEqualsDouble(1d, shape.getTopLeftPoint().getX());
    assertEqualsDouble(4d, shape.getTopRightPoint().getX());
    assertEqualsDouble(1d, shape.getTopLeftPoint().getY());
    assertEqualsDouble(3d, shape.getBottomLeftPoint().getY());
    assertEqualsDouble(1d, shape.getPtAt(0).getX());
    assertEqualsDouble(1d, shape.getPtAt(0).getY());
    assertEqualsDouble(4d, shape.getPtAt(2).getX());
    assertEqualsDouble(3d, shape.getPtAt(2).getY());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 39 with Point

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

the class TestShape method testGetFullTopLeftPoint.

@Theory
public void testGetFullTopLeftPoint(@ShapeData final Shape shape) {
    shape.setThickness(10.);
    shape.setHasDbleBord(false);
    shape.setBordersPosition(BorderPos.INTO);
    final Point pt = shape.getTopLeftPoint();
    final double gap = shape.getBorderGap();
    pt.translate(-gap, -gap);
    assertEquals(pt, shape.getFullTopLeftPoint());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 40 with Point

use of net.sf.latexdraw.model.api.shape.Point 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)

Aggregations

Point (net.sf.latexdraw.model.api.shape.Point)139 Test (org.junit.Test)52 HelperTest (net.sf.latexdraw.HelperTest)27 Theory (org.junit.experimental.theories.Theory)23 NotNull (org.jetbrains.annotations.NotNull)19 Line (net.sf.latexdraw.model.api.shape.Line)10 Shape (net.sf.latexdraw.model.api.shape.Shape)9 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)9 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)9 Test (org.junit.jupiter.api.Test)8 ArrayList (java.util.ArrayList)7 Polyline (net.sf.latexdraw.model.api.shape.Polyline)5 Color (javafx.scene.paint.Color)4 MathUtils (net.sf.latexdraw.model.MathUtils)4 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)4 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)4 Canvas (net.sf.latexdraw.view.jfx.Canvas)4 Point2D (java.awt.geom.Point2D)3 List (java.util.List)3 ShapeData (net.sf.latexdraw.data.ShapeData)3