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

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


  @Test
  public void testGetPerpendicularLineHoriz() {
    line.setLine(-10, 0, 10, 0);
    line.updateAandB();
    ILine line2 = line.getPerpendicularLine(ShapeFactory.createPoint());
    assertNotNull(line2);
    assertEquals(0., line2.getX1(), 0.1);
    assertEquals(0., line2.getX2(), 0.1);
    line.setLine(-10, 1, 10, 1);
    line.updateAandB();
    line2 = line.getPerpendicularLine(ShapeFactory.createPoint(1,1));
    assertNotNull(line2);
    assertEquals(1., line2.getX1(), 0.1);
    assertEquals(1., line2.getX2(), 0.1);
    line.setLine(-10, -1, 10, -1);
    line.updateAandB();
    line2 = line.getPerpendicularLine(ShapeFactory.createPoint(-1,-1));
    assertNotNull(line2);
    assertEquals(-1., line2.getX1(), 0.1);
    assertEquals(-1., line2.getX2(), 0.1);
  }
View Full Code Here


  @Test
  public void testGetPerpendicularLineVert() {
    line.setLine(0, 10, 0, -10);
    line.updateAandB();
    ILine line2 = line.getPerpendicularLine(ShapeFactory.createPoint());
    assertNotNull(line2);
    assertEquals(0., line2.getY1(), 0.1);
    assertEquals(0., line2.getY2(), 0.1);
    line.setLine(1, 10, 1, -10);
    line.updateAandB();
    line2 = line.getPerpendicularLine(ShapeFactory.createPoint(1,1));
    assertNotNull(line2);
    assertEquals(1., line2.getY1(), 0.1);
    assertEquals(1., line2.getY2(), 0.1);
    line.setLine(-1, 10, -1, -10);
    line.updateAandB();
    line2 = line.getPerpendicularLine(ShapeFactory.createPoint(-1,-1));
    assertNotNull(line2);
    assertEquals(-1., line2.getY1(), 0.1);
    assertEquals(-1., line2.getY2(), 0.1);
  }
View Full Code Here

  @Test
  public void testGetPerpendicularLineDiag() {
    line.setLine(1, 1, 2, 2);
    line.updateAandB();
    ILine line2 = line.getPerpendicularLine(ShapeFactory.createPoint());
    assertNotNull(line2);
    assertEquals(0., line2.getB(), 0.1);
    assertEquals(-1., line2.getA(), 0.1);
    line.setLine(-1, 1, 1, -1);
    line.updateAandB();
    line2 = line.getPerpendicularLine(ShapeFactory.createPoint(0,0));
    assertNotNull(line2);
    assertEquals(0., line2.getB(), 0.1);
    assertEquals(1., line2.getA(), 0.1);

    assertNull(line.getPerpendicularLine(null));
    assertNull(line.getPerpendicularLine(ShapeFactory.createPoint(Double.NaN, 0)));
    assertNull(line.getPerpendicularLine(ShapeFactory.createPoint(0, Double.NEGATIVE_INFINITY)));
  }
View Full Code Here

  }


  @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));
View Full Code Here

  }


  @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);
View Full Code Here

  }


  @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

  }


  @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);
View Full Code Here

  }


  @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);
View Full Code Here



  @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

  /**
   * Method used by the balance method. Just returns the balanced control points of the given points.
   */
  private IPoint[] getBalancedPoints(final IPoint pt, final IPoint prevPt, final IPoint nextPt) {
    final ILine line = ShapeFactory.createLine(prevPt, nextPt);

    if(line.isHorizontalLine())
      line.setLine(pt.getX(), pt.getY(), pt.getX()+10, pt.getY());
    else {
      final double b = pt.getY() - line.getA()*pt.getX();
      line.setLine(pt.getX(), pt.getY(), pt.getX()+10, line.getA()*(pt.getX()+10) + b);
    }

    return line.findPoints(pt, DEFAULT_BALANCE_GAP);
  }
View Full Code Here

TOP

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

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.