Package org.tinyuml.umldraw.structure

Examples of org.tinyuml.umldraw.structure.Association


    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(ElementType.CLASS)).will(returnValue(clss));
    ClassElement class1 = factory.createClass();
    ClassElement class2 = factory.createClass();

    Association conn = (Association) factory.createConnection(
      RelationType.ASSOCIATION, class1, class2);
    assertEquals(class1, conn.getNode1());
    assertEquals(class2, conn.getNode2());
    assertEquals(1, class1.getConnections().size());
    assertEquals(1, class2.getConnections().size());
    assertNull(conn.getParent());   
  }
View Full Code Here


   */
  public void testCreateAssociation() {
    ClassElement class1 = (ClassElement) factory.createNode(ElementType.CLASS);
    ClassElement class2 = (ClassElement) factory.createNode(ElementType.CLASS);

    Association conn = (Association) factory.createConnection(
      RelationType.ASSOCIATION, class1, class2);
    assertStdConnectionConditions(conn, class1, class2);
    Relation relation = (Relation) conn.getModelElement();
    assertTrue(relation.canSetElement1Navigability());
    assertTrue(relation.canSetElement2Navigability());
  }
View Full Code Here

   */
  public void testCreateComposition() {
    ClassElement class1 = (ClassElement) factory.createNode(ElementType.CLASS);
    ClassElement class2 = (ClassElement) factory.createNode(ElementType.CLASS);
   
    Association composition = (Association) factory.createConnection(
      RelationType.COMPOSITION, class1, class2);
    assertStdConnectionConditions(composition, class1, class2);
    Relation umlcomp = (Relation) composition.getModelElement();
    assertFalse(umlcomp.canSetElement1Navigability());
    assertTrue(umlcomp.canSetElement2Navigability());   
  }
View Full Code Here

   */
  public void testCreateAggregation() {
    ClassElement class1 = (ClassElement) factory.createNode(ElementType.CLASS);
    ClassElement class2 = (ClassElement) factory.createNode(ElementType.CLASS);
   
    Association composition = (Association) factory.createConnection(
      RelationType.AGGREGATION, class1, class2);
    assertStdConnectionConditions(composition, class1, class2);
    Relation umlcomp = (Relation) composition.getModelElement();
    assertFalse(umlcomp.canSetElement1Navigability());
    assertTrue(umlcomp.canSetElement2Navigability());   
  }
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)) {
      UmlNode target = (UmlNode) elem;
      Association assoc =
        editor.getDiagram().getElementFactory().createAssociation(
          (UmlNode) source, target);
      List<Point2D> points = linebuilder.calculateLineSegments(anchor.getX(),
        anchor.getY(), tmpPos.getX(), tmpPos.getY(), Orientation.HORIZONTAL);
      List<Point2D> linepoints = new LinkedList<Point2D>();
      for (Point2D point : points) {
        linepoints.add(point);
      }
      // calculate intersections with the nodes
      Line2D line = new Line2D.Double();
      // first
      // check if we could start at the second segment
      line.setLine(points.get(1), points.get(2));
      // if not, start at the first segment
      if (source.intersects(line)) {
        linepoints.remove(0);
      } else {
        line.setLine(points.get(0), points.get(1));
      }
      source.calculateIntersection(line, linepoints.get(0));

      // last
      // check if we could end at the segment before the last one
      line.setLine(points.get(points.size() - 3),
                   points.get(points.size() - 2));
      if (target.intersects(line)) {
        linepoints.remove(linepoints.size() - 1);
      } else {
        line.setLine(points.get(points.size() - 2),
                     points.get(points.size() - 1));
      }
      target.calculateIntersection(line, linepoints.get(linepoints.size() - 1));
      assoc.setPoints(linepoints);
      AddElementCommand command = new AddElementCommand(editor,
        editor.getDiagram(), assoc);
      editor.execute(command);
    }
    isDragging = false;
View Full Code Here

        umlclass.setAttributes(dialog.getAttributes());
        umlclass.setStereotypes(dialog.getStereotypes());
        redraw();
      }
    } else if (element instanceof Association) {
      Association association = (Association) element;
      EditAssociationDialog dialog = new EditAssociationDialog(window,
        association, true);
      dialog.setLocationRelativeTo(mainWindow);
      dialog.setVisible(true);
      redraw();
View Full Code Here

TOP

Related Classes of org.tinyuml.umldraw.structure.Association

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.