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

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


    prepareElements(data.getPoints().size()-1);

    for (int i = 0; i < elements.size(); i++) {
      Element div = (Element) elements.get(i);
      Point start = (Point) data.getPoints().get(i);
      Point end = (Point) data.getPoints().get(i+1);
     
      String style = "gwt-diagrams-line";

      DOM.setElementAttribute(div, "style", "");
      DOM.setElementProperty(div, "className", style);
View Full Code Here


    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

    DOM.setElementAttribute(canvas, "class", prev + " gwt-diagrams-canvas");
  }
 
  public void draw(Point p1, Point p2, Point c1, Point c2) {

    Point start = new Point( Math.min(p1.left, p2.left), Math.min(p1.top, p2.top) );
    int width = Math.abs(p1.left - p2.left);
    int height = Math.abs(p1.top - p2.top);

    int size = Math.max(width, height);
    size = Math.max(size,Math.abs(p1.left - c1.left));
    size = Math.max(size,Math.abs(p1.top - c1.top));
    size = Math.max(size,Math.abs(p2.left - c2.left));
    size = Math.max(size,Math.abs(p2.top - c2.top));
    Point realStart = new Point(start.left - size, start.top - size);
   
    DOM.setStyleAttribute(canvas, "left", Integer.toString(realStart.left));
    DOM.setStyleAttribute(canvas, "top", Integer.toString(realStart.top));
    DOM.setElementAttribute(canvas, "width", Integer.toString(width+size*2));
    DOM.setElementAttribute(canvas, "height", Integer.toString(height+size*2));
    DOM.setStyleAttribute(canvas, "width", Integer.toString(width+size*2));
    DOM.setStyleAttribute(canvas, "height", Integer.toString(height+size*2));
   
    drawImpl(
        p1.move(realStart.negative()),
        p2.move(realStart.negative()),
        c1.move(realStart.negative()),
        c2.move(realStart.negative()),
        getComputedStyle(canvas, "color"));
   
    // TODO lineWidth, maybe shadows etc.
  }
View Full Code Here

    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()));
//    Point b2 = p2.move(d[1], 3*(d[1].isHorizontal() ? c2.getHeight() : c2.getWidth()));

    BezierConnectionData data = new BezierConnectionData(
View Full Code Here

    }
   
    DOM.setElementAttribute(vmlCurve, "strokecolor", getComputedStyle(styledDiv, "color"));
    DOM.setElementAttribute(vmlCurve, "strokeweight", getComputedStyle(styledDiv, "width"));

    Point start = new Point( Math.min(p1.left, p2.left), Math.min(p1.top, p2.top));

    DOM.setStyleAttribute(vmlGroup, "left", Integer.toString(start.left));
    DOM.setStyleAttribute(vmlGroup, "top", Integer.toString(start.top));

    drawImpl(
        p1.move(start.negative()),
        p2.move(start.negative()),
        c1.move(start.negative()),
        c2.move(start.negative()));

  }
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

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

 
  /**
   * @see pl.balon.gwt.diagrams.client.connector.Connector#pointOnBorder(pl.balon.gwt.diagrams.client.connector.Direction)
   */
  public Point pointOnBorder(Direction d) {
    return new Point( getLeft() + getWidth()/2, getTop() + getHeight()/2 )
      .move(d, ((d.isHorizontal())?getWidth()/2:getHeight()/2));
  }
View Full Code Here

TOP

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

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.