Package net.sf.latexdraw.glib.models.interfaces.shape

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


  }


  @Test
  public void testConstructor() {
    IPoint pt1   = ShapeFactory.createPoint(1, 1);
    IPoint pt2   = ShapeFactory.createPoint(2, 2);
    IPolyline pol = ShapeFactory.createPolyline(pt1, pt2);

    pol = ShapeFactory.createPolyline(pt1, pt2);
    assertEquals(pt1, pol.getPtAt(0));
    assertEquals(pt2, pol.getPtAt(-1));
View Full Code Here


//  }


  @Test
  public void testConstructor() {
    IPoint pt1   = ShapeFactory.createPoint(1, 1);
    IPoint pt2   = ShapeFactory.createPoint(2, 2);
    IPolygon pol = ShapeFactory.createPolygon(pt1, pt2);

    pol = ShapeFactory.createPolygon(pt1, pt2);
    assertEquals(pt1, pol.getPtAt(0));
    assertEquals(pt2, pol.getPtAt(-1));
View Full Code Here

import org.junit.Test;

public class TestLPoint {
  @Test
  public void testLPoint() {
    IPoint pt = ShapeFactory.createPoint(1.,-200.);

    assertEquals(ShapeFactory.createPoint(), ShapeFactory.createPoint(0.,0.));
    assertEquals(pt.getX(), 1., 0.1);
    assertEquals(pt.getY(), -200., 0.1);

    pt = ShapeFactory.createPoint((IPoint)null);
    assertEquals(pt.getX(), 0., 0.1);
    assertEquals(pt.getY(), 0., 0.1);

    pt = ShapeFactory.createPoint(ShapeFactory.createPoint(-1.34, Double.POSITIVE_INFINITY));
    assertEquals(pt.getX(), -1.34, 0.1);
    assertEquals(pt.getY(), Double.POSITIVE_INFINITY, 0.1);
  }
View Full Code Here

  }


  @Test
  public void testRotatePoint() {
    IPoint pt = ShapeFactory.createPoint();

    assertNull(pt.rotatePoint( null, 0));
    assertNull(pt.rotatePoint(null, 0));
    assertNull(pt.rotatePoint(ShapeFactory.createPoint(), Double.NaN));
    assertNull(pt.rotatePoint(ShapeFactory.createPoint(), Double.NEGATIVE_INFINITY));
    assertNull(pt.rotatePoint(ShapeFactory.createPoint(), Double.POSITIVE_INFINITY));

    assertEquals(ShapeFactory.createPoint(0,1),  ShapeFactory.createPoint(1,0).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
    assertEquals(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(0,1).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
    assertEquals(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(-1,0).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
    assertEquals(ShapeFactory.createPoint(1,0),  ShapeFactory.createPoint(0,-1).rotatePoint(ShapeFactory.createPoint(), Math.PI/2.));
View Full Code Here



  @Test
  public void testCentralSymmetry() {
    IPoint pt = ShapeFactory.createPoint();
    assertNull(pt.centralSymmetry(null));
    assertEquals(ShapeFactory.createPoint(-1,0),  ShapeFactory.createPoint(1,0).centralSymmetry(pt));
    assertEquals(ShapeFactory.createPoint(0,-1),  ShapeFactory.createPoint(0,1).centralSymmetry(pt));
    assertEquals(ShapeFactory.createPoint(1,0),  ShapeFactory.createPoint(-1,0).centralSymmetry(pt));
    assertEquals(ShapeFactory.createPoint(0,1),  ShapeFactory.createPoint(0,-1).centralSymmetry(pt));
  }
View Full Code Here

  }


  @Test
  public void testComputeAngle() {
    IPoint pt1 = ShapeFactory.createPoint();

    assertEquals(Double.NaN, pt1.computeAngle(null), 0.1);
    assertEquals(0., pt1.computeAngle(ShapeFactory.createPoint(1,0)), 0.1);
    assertEquals(Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(Math.PI, pt1.computeAngle(ShapeFactory.createPoint(-1,0)), 0.1);
    assertEquals(3.*Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(0,-1)), 0.1);

    pt1.setPoint(1, 1);
    assertEquals(0., pt1.computeAngle(ShapeFactory.createPoint(2,1)), 0.1);
    assertEquals(Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(1,2)), 0.1);
    assertEquals(Math.PI, pt1.computeAngle(ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(3.*Math.PI/2., pt1.computeAngle(ShapeFactory.createPoint(1,0)), 0.1);
  }
View Full Code Here

  }


  @Test
  public void testComputeRotationAngle() {
    IPoint pt1 = ShapeFactory.createPoint();

    assertEquals(Double.NaN, pt1.computeRotationAngle(null, null), 0.1);
    assertEquals(Double.NaN, pt1.computeRotationAngle(ShapeFactory.createPoint(), null), 0.1);
    assertEquals(Double.NaN, pt1.computeRotationAngle(null, ShapeFactory.createPoint()), 0.1);

    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(1,0)), 0.1);
    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(-1,0)), 0.1);
    assertEquals(0., pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(0,-1)), 0.1);

    assertEquals(Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(0,1)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(-1,0))), 0.1);
    assertEquals(3.*Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(1,0), ShapeFactory.createPoint(0,-1)), 0.1);

    assertEquals(Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(-1,0)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(0,-1))), 0.1);
    assertEquals(-Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,1), ShapeFactory.createPoint(1,0)), 0.1);

    assertEquals(Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(0,-1)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(1,0))), 0.1);
    assertEquals(-Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(-1,0), ShapeFactory.createPoint(0,1)), 0.1);

    assertEquals(-3.*Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(1,0)), 0.1);
    assertEquals(Math.PI, Math.abs(pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(0,1))), 0.1);
    assertEquals(-Math.PI/2., pt1.computeRotationAngle(ShapeFactory.createPoint(0,-1), ShapeFactory.createPoint(-1,0)), 0.1);
  }
View Full Code Here

  }


  @Test
  public void testTranslate() {
    IPoint pt1 = ShapeFactory.createPoint(2., 1.);
    IPoint pt2 = ShapeFactory.createPoint(2., 1.);

    pt1.translate(Double.NaN, Double.NaN);
    assertEquals(pt1, pt2);
    pt1.translate(Double.NaN, 2.);
    assertEquals(pt1, pt2);
View Full Code Here

  }


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

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

  }


  @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

TOP

Related Classes of net.sf.latexdraw.glib.models.interfaces.shape.IPoint

Copyright © 2018 www.massapicom. 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.