Search in sources :

Example 21 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIPositionShape method testGetSetPositionKONULL.

@Theory
public void testGetSetPositionKONULL(@PosShapeData final IPositionShape shape) {
    IPoint pt = ShapeFactory.INST.createPoint(15d, 25d);
    shape.setPosition(pt);
    shape.setPosition(null);
    assertEqualsDouble(pt.getX(), shape.getPosition().getX());
    assertEqualsDouble(pt.getY(), shape.getPosition().getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 22 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIPositionShape method testGetSetPositionKO.

@Theory
public void testGetSetPositionKO(@PosShapeData final IPositionShape shape, @DoubleData(vals = {}, bads = true) final double value) {
    IPoint 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 : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 23 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIPositionShape method testGetSetPosition.

@Theory
public void testGetSetPosition(@PosShapeData final IPositionShape shape) {
    IPoint 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 : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 24 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIRectangularShape method testTranslate.

@Theory
public void testTranslate(@RectangularData final IRectangularShape shape, @DoubleData final double tx, @DoubleData final double ty) {
    final IPoint p1 = ShapeFactory.INST.createPoint(3, 1);
    final IPoint p2 = ShapeFactory.INST.createPoint(1, 3);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.setHeight(p2.getY() - p1.getY());
    shape.translate(tx, ty);
    assertEqualsDouble(p2.getX() + tx, shape.getPtAt(0).getX());
    assertEqualsDouble(p1.getX() + tx, shape.getPtAt(1).getX());
    assertEqualsDouble(p1.getX() + tx, shape.getPtAt(2).getX());
    assertEqualsDouble(p2.getX() + tx, shape.getPtAt(-1).getX());
    assertEqualsDouble(p1.getY() + ty, shape.getPtAt(0).getY());
    assertEqualsDouble(p1.getY() + ty, shape.getPtAt(1).getY());
    assertEqualsDouble(p2.getY() + ty, shape.getPtAt(2).getY());
    assertEqualsDouble(p2.getY() + ty, shape.getPtAt(-1).getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 25 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIRectangularShape method testTranslateKO.

@Theory
public void testTranslateKO(@RectangularData final IRectangularShape shape, @DoubleData(vals = { 0d }, bads = true) final double tx, @DoubleData(vals = { 0d }, bads = true) final double ty) {
    final IPoint p1 = ShapeFactory.INST.createPoint(3, 1);
    final IPoint p2 = ShapeFactory.INST.createPoint(1, 3);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.setHeight(p2.getY() - p1.getY());
    shape.translate(tx, ty);
    assertEqualsDouble(1d, shape.getPtAt(0).getX());
    assertEqualsDouble(3d, shape.getPtAt(1).getX());
    assertEqualsDouble(3d, shape.getPtAt(2).getX());
    assertEqualsDouble(1d, shape.getPtAt(-1).getX());
    assertEqualsDouble(1d, shape.getPtAt(0).getY());
    assertEqualsDouble(1d, shape.getPtAt(1).getY());
    assertEqualsDouble(3d, shape.getPtAt(2).getY());
    assertEqualsDouble(3d, shape.getPtAt(-1).getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Aggregations

IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)191 Test (org.junit.Test)45 HelperTest (net.sf.latexdraw.HelperTest)25 Theory (org.junit.experimental.theories.Theory)21 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)15 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)11 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)11 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)10 ILine (net.sf.latexdraw.models.interfaces.shape.ILine)10 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)9 IGroup (net.sf.latexdraw.models.interfaces.shape.IGroup)9 ArrayList (java.util.ArrayList)8 MathUtils (net.sf.latexdraw.models.MathUtils)8 Collections (java.util.Collections)7 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)7 Arrays (java.util.Arrays)6 Cursor (javafx.scene.Cursor)6 BorderPos (net.sf.latexdraw.models.interfaces.shape.BorderPos)6 IModifiablePointsShape (net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape)6 Inject (net.sf.latexdraw.util.Inject)6