Package org.tinyuml.draw

Examples of org.tinyuml.draw.Association


    ClassElement class2 = factory.createClass();

    mockElementFactory.expects(atLeastOnce()).method("create").
      with(eq(ElementType.DEPENDENCY)).will(returnValue(assoc));

    Association conn = (Association) factory.createAssociation(class1, class2);
    assertEquals(assoc, conn.getModelElement());
    assertEquals(class1, conn.getNode0());
    assertEquals(class2, conn.getNode1());
    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 UmlNode && elem != source) {
      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

TOP

Related Classes of org.tinyuml.draw.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.