Package org.tinyuml.draw

Examples of org.tinyuml.draw.Connection


    PackageElement target = factory.createPackage();
   
    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(ElementType.DEPENDENCY)).will(returnValue(assoc));
   
    Connection conn = factory.createDependency(source, target);
    assertEquals(assoc, conn.getModelElement());
    assertEquals(source, conn.getNode0());
    assertEquals(target, conn.getNode1());
    assertNull(conn.getParent());
  }
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 creation of a Connection with an existing UmlAssociation object.
   */
  public void testCreateConnection() {
    Connection conn = factory.createConnection(assoc);
    assertNotNull(conn);
    assertNull(conn.getParent());
  }
View Full Code Here

   */
  public void mouseReleased(EditorMouseEvent event) {
    double mx = event.getX(), my = event.getY();
    DiagramElement elem = editor.getDiagram().getChildAt(mx, my);
    if (elem instanceof Node && elem != source) {
      Connection connection =
        editor.getDiagram().getElementFactory().createDependency((Node) source,
          (Node) elem);
      AddElementCommand command = new AddElementCommand(editor,
        editor.getDiagram(), connection);
      editor.execute(command);
View Full Code Here

   */
  public void mouseReleased(EditorMouseEvent event) {
    double mx = event.getX(), my = event.getY();
    DiagramElement elem = editor.getDiagram().getChildAt(mx, my);
    if (source != null && isValidTarget(elem)) {
      Connection connection = null;
      if (associationType == RelationType.DEPENDENCY) {
        connection = editor.getDiagram().getElementFactory().createDependency(
          (UmlNode) source, (UmlNode) elem);
      } else if (associationType == RelationType.NOTE_CONNECTOR) {
        connection = editor.getDiagram().getElementFactory()
View Full Code Here

      will(returnValue(target));
    mockDiagram.expects(once()).method("addConnection");
    mockNotification.expects(once()).method("notifyElementAdded");
   
    command.run();
    Connection conn = command.getConnection();
    assertNotNull(conn);
    assertEquals(source, assoc.getSource());
    assertEquals(target, assoc.getTarget());
  }
View Full Code Here

      double width = Double.valueOf(attributes.getValue("width"));
      double height = Double.valueOf(attributes.getValue("height"));
      currentNode.setSize(width, height);
    } else if ("connection".equals(qName)) {
      int id = Integer.valueOf(attributes.getValue("element-id"));
      currentConnection = new Connection((UmlAssociation)
        elementMap.get(id));
      int sourceShapeId = Integer.valueOf(attributes.getValue("source"));
      int targetShapeId = Integer.valueOf(attributes.getValue("target"));
      currentConnection.setSource(shapeMap.get(sourceShapeId));
      currentConnection.setTarget(shapeMap.get(targetShapeId));
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 mouseReleased(EditorMouseEvent event) {
    double mx = event.getX(), my = event.getY();
    DiagramElement elem = editor.getDiagram().getChildAt(mx, my);
    if (elem instanceof UmlNode && elem != source) {
      Connection connection = null;
      if (connectionType == ConnectionType.DEPENDENCY) {
        connection = editor.getDiagram().getElementFactory().createDependency(
          (UmlNode) source, (UmlNode) elem);
      } else if (connectionType == ConnectionType.NOTE_CONNECTOR) {
        connection = editor.getDiagram().getElementFactory()
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.