Examples of IPoint


Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  }


  @Test
  public void testVerticalSymmetry() {
    IPoint pt = ShapeFactory.createPoint(10., 10.);

    assertNull(pt.verticalSymmetry(null));
    assertNull(pt.verticalSymmetry(ShapeFactory.createPoint(Double.NaN, 1.)));
    assertNull(pt.verticalSymmetry(ShapeFactory.createPoint(1., Double.NaN)));
    assertNull(pt.verticalSymmetry(ShapeFactory.createPoint(Double.POSITIVE_INFINITY, 1.)));
    assertNull(pt.verticalSymmetry(ShapeFactory.createPoint(1., Double.POSITIVE_INFINITY)));
    assertNull(pt.verticalSymmetry(ShapeFactory.createPoint(Double.NEGATIVE_INFINITY, 1.)));
    assertNull(pt.verticalSymmetry(ShapeFactory.createPoint(1., Double.NEGATIVE_INFINITY)));
    assertEquals(pt.verticalSymmetry(ShapeFactory.createPoint(0.,0.)), ShapeFactory.createPoint(10., -10.));
    assertEquals(pt.verticalSymmetry(ShapeFactory.createPoint(18780., 0.)), ShapeFactory.createPoint(10., -10.));
    assertEquals(ShapeFactory.createPoint(10., -10.).verticalSymmetry(ShapeFactory.createPoint(18780., 0.)), pt);
    assertEquals(ShapeFactory.createPoint(0.,0.).verticalSymmetry(ShapeFactory.createPoint(0.,0.)), ShapeFactory.createPoint(0., 0.));
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  @Test
  public void testGetIntersection() {
    ILine line2 = ShapeFactory.createLine(72, -981, 0, 0);
    line.setLine(-237, 17, 13, -82);
    line.updateAandB();
    IPoint pt = line.getIntersection(line2);
    assertNotNull(pt);
    assertTrue(LNumber.equalsDouble(5.809358228, pt.getX(), 0.00000001));
    assertTrue(LNumber.equalsDouble(-79.152505858, pt.getY(), 0.00000001));

    assertNull(line.getIntersection(null));
    assertNull(line.getIntersection(line));
    assertNull(line.getIntersection(ShapeFactory.createLine(1, 1, 1, 1)));
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  @Test
  public void testGetIntersectionVert() {
    ILine line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    IPoint pt = line.getIntersection(line2);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(1, -10, 1, 10);
    line.updateAandB();
    pt = line.getIntersection(line2);
    assertNotNull(pt);
    assertEquals(1., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(-1, -10, -1, 10);
    line.updateAandB();
    pt = line.getIntersection(line2);
    assertNotNull(pt);
    assertEquals(-1., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(1, 2, -1, 0);
    line.setLine(0., -10, 0., 10);
    line.updateAandB();
    pt = line.getIntersection(line2);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(1., pt.getY(), 0.1);
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  @Test
  public void testGetIntersectionHoriz() {
    ILine line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    IPoint pt = line2.getIntersection(line);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(1, -10, 1, 10);
    line.updateAandB();
    pt = line2.getIntersection(line);
    assertNotNull(pt);
    assertEquals(1., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(-1, -10, -1, 10);
    line.updateAandB();
    pt = line2.getIntersection(line);
    assertNotNull(pt);
    assertEquals(-1., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(1, 2, -1, 0);
    line.setLine(0., -10, 0., 10);
    line.updateAandB();
    pt = line2.getIntersection(line);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(1., pt.getY(), 0.1);
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  @Test
  public void testGetIntersectionSegment() {
    ILine line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(1, 1, 0, -1);
    line.updateAandB();
    IPoint pt = line.getIntersectionSegment(line2);
    assertNotNull(pt);
    assertEquals(0.5, pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    assertNull(line.getIntersectionSegment(null));
    assertNull(line.getIntersectionSegment(line));
    assertNull(line.getIntersectionSegment(ShapeFactory.createLine(1, 1, 1, 1)));
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  @Test
  public void testGetIntersectionSegmentVert() {
    ILine line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    IPoint pt = line.getIntersectionSegment(line2);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(1, -10, 1, 10);
    line.updateAandB();
    pt = line.getIntersectionSegment(line2);
    assertNotNull(pt);
    assertEquals(1., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(1.001, -10, 1.001, 10);
    line.updateAandB();
    pt = line.getIntersectionSegment(line2);
    assertNull(pt);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(-0.1, -10, -0.1, 10);
    line.updateAandB();
    pt = line.getIntersectionSegment(line2);
    assertNull(pt);

    line2 = ShapeFactory.createLine(1, 2, -1, 0);
    line.setLine(0., -10, 0., 10);
    line.updateAandB();
    pt = line.getIntersectionSegment(line2);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(1., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(1, 2, -1, 0);
    line.setLine(0., 10, 0., 1.01);
    line.updateAandB();
    pt = line.getIntersectionSegment(line2);
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

  @Test
  public void testGetIntersectionSegmentHoriz() {
    ILine line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    IPoint pt = line2.getIntersectionSegment(line);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(0.01, 0, 1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    pt = line2.getIntersectionSegment(line);
    assertNull(pt);

    line2 = ShapeFactory.createLine(-0.01, 0, -1, 0);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    pt = line2.getIntersectionSegment(line);
    assertNull(pt);

    line2 = ShapeFactory.createLine(0, 10.01, 1, 11);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    pt = line2.getIntersectionSegment(line);
    assertNull(pt);

    line2 = ShapeFactory.createLine(0, -10.01, 1, -11);
    line.setLine(0, -10, 0, 10);
    line.updateAandB();
    pt = line2.getIntersectionSegment(line);
    assertNull(pt);

    line2 = ShapeFactory.createLine(0, 0, 1, 0);
    line.setLine(1, -10, 1, 10);
    line.updateAandB();
    pt = line2.getIntersectionSegment(line);
    assertNotNull(pt);
    assertEquals(1., pt.getX(), 0.1);
    assertEquals(0., pt.getY(), 0.1);

    line2 = ShapeFactory.createLine(1, 2, -1, 0);
    line.setLine(0., -10, 0., 10);
    line.updateAandB();
    pt = line2.getIntersectionSegment(line);
    assertNotNull(pt);
    assertEquals(0., pt.getX(), 0.1);
    assertEquals(1., pt.getY(), 0.1);
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint


  @Override
  @Test
  public void testMirrorHorizontal() {
    IPoint pt2 = ShapeFactory.createPoint(4,1);
    IPoint pt4 = ShapeFactory.createPoint(1,3);

    shape.setPosition(pt4);
    shape.setWidth(pt2.getX()-pt4.getX());
    shape.setHeight(pt4.getY()-pt2.getY());

    shape.mirrorHorizontal(shape.getGravityCentre());
    HelperTest.assertEqualsDouble(1., shape.getTopLeftPoint().getX());
    HelperTest.assertEqualsDouble(4., shape.getTopRightPoint().getX());
    HelperTest.assertEqualsDouble(1., shape.getTopLeftPoint().getY());
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint


  @Override
  @Test
  public void testMirrorVertical() {
    IPoint pt2 = ShapeFactory.createPoint(4,1);
    IPoint pt4 = ShapeFactory.createPoint(1,3);

    shape.setPosition(pt4);
    shape.setWidth(pt2.getX()-pt4.getX());
    shape.setHeight(pt4.getY()-pt2.getY());

    shape.mirrorVertical(shape.getGravityCentre());
    HelperTest.assertEqualsDouble(1., shape.getTopLeftPoint().getX());
    HelperTest.assertEqualsDouble(4., shape.getTopRightPoint().getX());
    HelperTest.assertEqualsDouble(1., shape.getTopLeftPoint().getY());
View Full Code Here

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IPoint


  @Override
  @Test
  public void testTranslate() {
    IPoint pt2 = ShapeFactory.createPoint(3,1);
    IPoint pt4 = ShapeFactory.createPoint(1,3);

    shape.setPosition(pt4);
    shape.setWidth(pt2.getX()-pt4.getX());
    shape.setHeight(pt4.getY()-pt2.getY());

    shape.translate(10, 0);
    HelperTest.assertEqualsDouble(11., shape.getPtAt(0).getX());
    HelperTest.assertEqualsDouble(13., shape.getPtAt(1).getX());
    HelperTest.assertEqualsDouble(13., shape.getPtAt(2).getX());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.