Package pl.balon.gwt.diagrams.client.connector

Examples of pl.balon.gwt.diagrams.client.connector.Connector


  public ConnectionData calculateConnectionData(List connectors) {
    if( connectors.size() != 2 ){
      throw new IllegalArgumentException("Unsupported connectors count");
    }
   
    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));
View Full Code Here


   */
  public AbstractConnection(List toConnect) {
    connected.addAll(toConnect);
    setCalculator(createCalculator());
    for (Iterator i = connected.iterator(); i.hasNext();) {
      Connector c = (Connector) i.next();
      c.connect(this);
    }
  }
View Full Code Here

  /**
   * @see pl.balon.gwt.diagrams.client.connection.Connection#remove()
   */
  public void remove(){
    for (ListIterator i = connected.listIterator(); i.hasNext();) {
      Connector c = (Connector) i.next();
      i.remove();
      c.disconnect(this);
    }
    removeFromParent();
  }
View Full Code Here

  public ConnectionData calculateConnectionData(List connectors) {
    if( connectors.size() != 2 ){
      throw new IllegalArgumentException("Unsupported connectors count");
    }
   
    Connector c1 = (Connector) connectors.get(0);
    Connector c2 = (Connector) connectors.get(1);

    Direction[] d = computeDirections(c1, c2);
   
    Point p1 = c1.pointOnBorder(d[0]);
    Point p2 = c2.pointOnBorder(d[1]);
   
    Point b1 = p1.move(d[0], 50); // TODO parametrize it?
    Point b2 = p2.move(d[1], 50); // TODO parametrize it?

//    Point b1 = p1.move(d[0], 3*(d[0].isHorizontal() ? c1.getHeight() : c1.getWidth()));
View Full Code Here

  public ConnectionData calculateConnectionData(List connectors) {
    if( connectors.size() != 2 ){
      throw new IllegalArgumentException("Unsupported connectors count");
    }
   
    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

  public ConnectionData calculateConnectionData(List connectors) {
    if( connectors.size() != 2 ){
      throw new IllegalArgumentException("Unsupported connectors count");
    }
   
    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;
View Full Code Here

TOP

Related Classes of pl.balon.gwt.diagrams.client.connector.Connector

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.