Package org.tinyuml.draw

Examples of org.tinyuml.draw.GeometryUtil


  /**
   * Tests if the specified ranges overlap.
   */
  public void testRangesOverlap() {
    GeometryUtil util = GeometryUtil.getInstance();
    // disjoint
    assertFalse(util.rangesOverlap(1, 10, 20, 25));
    // r1 == r2
    assertTrue(util.rangesOverlap(1, 10, 1, 10));
    // r1 in r2
    assertTrue(util.rangesOverlap(12, 20, 10, 25));
    // r2 in r1
    assertTrue(util.rangesOverlap(50, 100, 75, 80));
    // r1 and r2 have overlapping region
    assertTrue(util.rangesOverlap(30, 45, 40, 70));
  }
View Full Code Here


  /**
   * Tests the getOrientation() method.
   */
  public void testGetOrientation() {
    Point2D p1 = new Point2D.Double(), p2 = new Point2D.Double();
    GeometryUtil util = GeometryUtil.getInstance();
    p1.setLocation(10, 10);
    p2.setLocation(100, 10);
    assertEquals(Orientation.HORIZONTAL, util.getSegmentOrientation(p1, p2));
    p1.setLocation(10, 10);
    p2.setLocation(10, 100);
    assertEquals(Orientation.VERTICAL, util.getSegmentOrientation(p1, p2));
    p1.setLocation(10, 10);
    p2.setLocation(10, 10);
    assertEquals(Orientation.UNDEFINED, util.getSegmentOrientation(p1, p2));
    p1.setLocation(10, 10);
    p2.setLocation(20, 20);
    assertEquals(Orientation.UNDEFINED, util.getSegmentOrientation(p1, p2));
  }
View Full Code Here

  /**
   * Tests if the specified ranges overlap.
   */
  public void testRangesOverlap() {
    GeometryUtil util = GeometryUtil.getInstance();
    // disjoint
    assertFalse(util.rangesOverlap(1, 10, 20, 25));
    // r1 == r2
    assertTrue(util.rangesOverlap(1, 10, 1, 10));
    // r1 in r2
    assertTrue(util.rangesOverlap(12, 20, 10, 25));
    // r2 in r1
    assertTrue(util.rangesOverlap(50, 100, 75, 80));
    // r1 and r2 have overlapping region
    assertTrue(util.rangesOverlap(30, 45, 40, 70));
  }
View Full Code Here

  /**
   * Tests the getOrientation() method.
   */
  public void testGetOrientation() {
    Point2D p1 = new Point2D.Double(), p2 = new Point2D.Double();
    GeometryUtil util = GeometryUtil.getInstance();
    p1.setLocation(10, 10);
    p2.setLocation(100, 10);
    assertEquals(Orientation.HORIZONTAL, util.getSegmentOrientation(p1, p2));
    p1.setLocation(10, 10);
    p2.setLocation(10, 100);
    assertEquals(Orientation.VERTICAL, util.getSegmentOrientation(p1, p2));
    p1.setLocation(10, 10);
    p2.setLocation(10, 10);
    assertEquals(Orientation.UNDEFINED, util.getSegmentOrientation(p1, p2));
    p1.setLocation(10, 10);
    p2.setLocation(20, 20);
    assertEquals(Orientation.UNDEFINED, util.getSegmentOrientation(p1, p2));
  }
View Full Code Here

TOP

Related Classes of org.tinyuml.draw.GeometryUtil

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.