Examples of UmlNode


Examples of org.tinyuml.draw.UmlNode

   */
  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);
    }
View Full Code Here

Examples of org.tinyuml.umldraw.shared.UmlNode

  /**
   * {@inheritDoc}
   */
  public UmlNode createNode(ElementType elementType) {
    UmlNode umlnode = (UmlNode) elementPrototypes.get(elementType).clone();
    umlnode.addNodeChangeListener(diagram);
    return umlnode;
  }
View Full Code Here

Examples of org.tinyuml.umldraw.shared.UmlNode

  /**
   * {@inheritDoc}
   */
  public UmlNode createNode(ElementType elementType) {
    UmlNode umlnode = (UmlNode) elementPrototypes.get(elementType).clone();
    umlnode.addNodeChangeListener(diagram);
    return umlnode;
  }
View Full Code Here

Examples of org.tinyuml.umldraw.shared.UmlNode

   */
  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);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.