Package pl.balon.gwt.diagrams.client.connection.data

Examples of pl.balon.gwt.diagrams.client.connection.data.ConnectionData


    }
   
    Connector c1 = (Connector) connectors.get(0);
    Connector c2 = (Connector) connectors.get(1);
   
    ConnectionData data = new ConnectionData();
   
    Point center1 = new Point(c1.getLeft() + c1.getWidth()/2, c1.getTop() + c1.getHeight()/2);
    Point center2 = new Point(c2.getLeft() + c2.getWidth()/2, c2.getTop() + c2.getHeight()/2);

    Point diff = new Point(center2.left - center1.left, center2.top - center1.top);

    int leftSign = diff.left >= 0 ? -1 : 1
    int topSign = diff.top >= 0 ? -1 : 1
   
    //c1 vertical
    int top = c1.getHeight()/2;
    int left = diff.top != 0 ? top * diff.left / Math.abs(diff.top) : Integer.MAX_VALUE;
    top *= -topSign;
   
    if( Math.abs(left) > c1.getWidth()/2 ){
      //c1 horizontal
      left = c1.getWidth()/2;
      top = diff.left != 0 ? left * diff.top / Math.abs(diff.left) : Integer.MAX_VALUE;
      left *= -leftSign;
    }
    data.getPoints().add(new Point(center1.left + left, center1.top + top));

    //c2 vertical
    top = c2.getHeight()/2;
    left = diff.top != 0 ? top * diff.left / Math.abs(diff.top) : Integer.MAX_VALUE;
    top *= topSign;
    left = -left;
   
    if( Math.abs(left) > c2.getWidth()/2 ){
      //c2 horizontal
      left = c2.getWidth()/2;
      top = diff.left != 0 ? left * diff.top / Math.abs(diff.left) : Integer.MAX_VALUE;
      left *= leftSign;
      top = -top;
    }
    data.getPoints().add(new Point(center2.left + left, center2.top + top));

    return data;
  }
View Full Code Here


    }
   
    Connector c1 = (Connector) connectors.get(0);
    Connector c2 = (Connector) connectors.get(1);
   
    ConnectionData data = new ConnectionData();
   
    data.getPoints().add(new Point( c1.getLeft() + c1.getWidth()/2, c1.getTop() + c1.getHeight()/2 ));
    data.getPoints().add(new Point( c1.getLeft() + c1.getWidth()/2, c2.getTop() + c2.getHeight()/2 ));
    data.getPoints().add(new Point( c2.getLeft() + c2.getWidth()/2, c2.getTop() + c2.getHeight()/2 ));
   
    return data;
  }
View Full Code Here

    }
   
    Connector c1 = (Connector) connectors.get(0);
    Connector c2 = (Connector) connectors.get(1);
   
    ConnectionData data = new ConnectionData();
   
    Direction[] directions = computeDirections(c1, c2);
   
    Point s1 = c1.pointOnBorder(directions[0]);
    Point s11 = s1.move(directions[0], 10); // TODO paremetrize it
   
    Point s2 = c2.pointOnBorder(directions[1]);
    Point s21 = s2.move(directions[1], 10); // TODO paremetrize it
   
    int horizontal = s21.left - s11.left;
    int vertical = s21.top - s11.top;

    Point n1 = null;
    Point n2 = null;
   
    // if h - zgodny h - zgodny
    // else if v - zgodny v - zgodny
    // else if h - zgodny v - zgodny
    // else if v - zgodny h - zgodny

    // else if h - zgodny h - mozliwy
    // else if h - mozliwy h - zgodny
    // else if v - zgodny v - mozliwy
    // else if v - mozliwy v - zgodny
   
    // else if h - mozliwy h - mozliwy
    // else if v - mozliwy v - mozliwy
    // else if h - mozliwy v - mozliwy
    // else if v - mozliwy h - mozliwy
    // else ?

    if( equalDirection(directions[0], 0, horizontal, true) && equalDirection(directions[1], 1, horizontal, true) ){
      n1 = s11.move(directions[0], Math.abs(horizontal/2) );
      n2 = new Point(n1.left, s21.top);
    } else if( equalDirection(directions[0], 0, vertical, false) && equalDirection(directions[1], 1, vertical, false) ){
      n1 = s11.move(directions[0], Math.abs(vertical/2) );
      n2 = new Point(s21.left, n1.top);
    } else if( equalDirection(directions[0], 0, horizontal, true) && equalDirection(directions[1], 1, vertical, false) ){
      n1 = s11.move(directions[0], Math.abs(horizontal));
      n2 = s21.move(directions[1], Math.abs(vertical));
    } else if( equalDirection(directions[0], 0, vertical, false) && equalDirection(directions[1], 1, horizontal, true) ){
      n1 = s11.move(directions[0], Math.abs(vertical));
      n2 = s21.move(directions[1], Math.abs(horizontal));
    } else if( equalDirection(directions[0], 0, horizontal, true) && canMove(directions[1], 1, horizontal, true) ){
      n1 = s11.move(directions[0], Math.abs(horizontal/2) );
      n2 = new Point(n1.left, s21.top);
    } else if( canMove(directions[0], 0, horizontal, true) && equalDirection(directions[1], 1, horizontal, true) ){
      n2 = s21.move(directions[1], Math.abs(horizontal/2) );
      n1 = new Point(n2.left, s11.top);
    } else if( equalDirection(directions[0], 0, vertical, false) && canMove(directions[1], 1, vertical, false) ){
      n1 = s11.move(directions[0], Math.abs(vertical/2) );
      n2 = new Point(s21.left, n1.top);
    } else if( canMove(directions[0], 0, vertical, false) && equalDirection(directions[1], 1, vertical, false) ){
      n2 = s21.move(directions[1], Math.abs(vertical/2) );
      n1 = new Point(s11.left, n2.top);
    } else if( canMove(directions[0], 0, horizontal, true) && canMove(directions[1], 1, horizontal, true) ){
      n1 = s11.move(Direction.RIGHT, horizontal/2 );
      n2 = new Point(n1.left, s21.top);
    } else if( canMove(directions[0], 0, vertical, false) && canMove(directions[1], 1, vertical, false) ){
      n1 = s11.move(Direction.DOWN, vertical/2 );
      n2 = new Point(s21.left, n1.top);
    } else if( canMove(directions[0], 0, horizontal, true) && canMove(directions[1], 1, vertical, false) ){
      n1 = s11.move(Direction.RIGHT, horizontal);
    } else if( canMove(directions[0], 0, vertical, false) && canMove(directions[1], 1, horizontal, true) ){
      n1 = s11.move(Direction.DOWN, vertical );
    }
//    } else {
// We are silent, nobody notice that inconsistence ;)       
//      GWT.log("??", null);
//    }
   
    data.getPoints().add(s1);
    data.getPoints().add(s11);
    if(n1!=null){
      data.getPoints().add(n1);
    }
    if(n2!=null){
      data.getPoints().add(n2);
    }
    data.getPoints().add(s21);
    data.getPoints().add(s2);
   
    return data;
  }
View Full Code Here

TOP

Related Classes of pl.balon.gwt.diagrams.client.connection.data.ConnectionData

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.