Package org.tinyuml.draw

Examples of org.tinyuml.draw.Connection


 
  /**
   * Tests adding Connections.
   */
  public void testAddRemoveConnection() {
    Connection conn = new SimpleConnection() {
      public boolean contains(double mx, double my) { return true; }
    };
    diagram.addChild(conn);
    assertEquals(diagram, conn.getParent());
    assertEquals(conn, diagram.getChildAt(6.0, 5.0));
    diagram.removeChild(conn);
    assertEquals(NullElement.getInstance(), diagram.getChildAt(6.0, 5.0));
  }
View Full Code Here


 
  /**
   * Tests the characteristics of a multi segment connection.
   */
  public void testGetMultiSegmentLineCharacteristics() {
    Connection connection = createMultiSegmentConnection();
    Point2D p1 = new Point2D.Double(10.0, 5.0);
    Point2D p2 = new Point2D.Double(20.0, 5.0);
    Point2D p3 = new Point2D.Double(30.0, 5.0);
   
    // end points
    assertEquals(p1, connection.getEndPoint1());
    assertEquals(p3, connection.getEndPoint2());
   
    // getSegmentAtPoint()
    assertNull("no segment should be found here",
      connection.getSegmentAtPoint(100.0, 6.0));

    Line2D segment1 = connection.getSegmentAtPoint(13.0, 5.0);
    assertEquals(p1, segment1.getP1());
    assertEquals(p2, segment1.getP2());
   
    Line2D segment2 = connection.getSegmentAtPoint(26.0, 5.0);
    assertEquals(p2, segment2.getP1());
    assertEquals(p3, segment2.getP2());
    System.out.println("dist: " + segment2.ptSegDist(26, 5));
   
    // contains
    assertFalse(connection.contains(100, 6));
    assertTrue(connection.contains(26, 5));
  }
View Full Code Here

 
  /**
   * Tests rotations methods.
   */
  public void testCalculateRotations() {
    Connection conn = createMultiSegmentConnection();
    assertNotNull(conn.calculateRotationInEndPoint1());
    assertNotNull(conn.calculateRotationInEndPoint2());
  }
View Full Code Here

 
  /**
   * Tests drawing.
   */
  public void testDrawMultiSegment() {
    Connection conn = createMultiSegmentConnection();
    Mock mockDrawingContext = mock(DrawingContext.class);
    // undashed
    mockDrawingContext.expects(once()).method("drawLine")
      .with(eq(10.0), eq(5.0), eq(20.0), eq(5.0));
    mockDrawingContext.expects(once()).method("drawLine")
      .with(eq(20.0), eq(5.0), eq(30.0), eq(5.0));
    conn.draw((DrawingContext) mockDrawingContext.proxy());
   
    // dashed
    conn.setIsDashed(true);
    mockDrawingContext.expects(once()).method("drawDashedLine")
      .with(eq(10.0), eq(5.0), eq(20.0), eq(5.0));
    mockDrawingContext.expects(once()).method("drawDashedLine")
      .with(eq(20.0), eq(5.0), eq(30.0), eq(5.0));
    conn.draw((DrawingContext) mockDrawingContext.proxy());
  }
View Full Code Here

 
  /**
   * Tests adding Connections.
   */
  public void testAddRemoveConnection() {
    Connection conn = new SimpleConnection() {
      public boolean contains(double mx, double my) { return true; }
    };
    diagram.addChild(conn);
    assertEquals(diagram, conn.getParent());
    assertEquals(conn, diagram.getChildAt(6.0, 5.0));
    diagram.removeChild(conn);
    assertEquals(NullElement.getInstance(), diagram.getChildAt(6.0, 5.0));
  }
View Full Code Here

  /**
   * Tests the overridden getChildren() method, which contains both connections
   * and nodes.
   */
  public void testOverriddenGetChildren() {
    Connection conn = new SimpleConnection();
    Mock mockNode = mock(Node.class);
    mockNode.expects(atLeastOnce()).method("getAbsoluteX2")
      .will(returnValue(2.0));
    mockNode.expects(atLeastOnce()).method("getAbsoluteY2")
      .will(returnValue(2.0));
View Full Code Here

  public void run() {
    association = (UmlAssociation)
      elementFactory.create(ElementType.DEPENDENCY);
    association.setSource(sourceNode.getModelElement());
    association.setTarget(targetNode.getModelElement());
    connection = new Connection(association);
    connection.setSource(sourceNode);
    connection.setTarget(targetNode);
    diagram.addConnection(connection);
    notification.notifyElementAdded(connection);
  }
View Full Code Here

TOP

Related Classes of org.tinyuml.draw.Connection

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.