protected final PointPair calculateEdge(DisplayNode comp1,DisplayNode comp2){
  Rectangle r1=comp1.getBounds();
  Rectangle r2=comp2.getBounds();
  Point c1=new Point((int)(r1.x + r1.width / 2.0),(int)(r1.y + r1.height / 2.0));
  Point c2=new Point((int)(r2.x + r2.width / 2.0),(int)(r2.y + r2.height / 2.0));
  double angle=Math.atan2(c1.y - c2.y,c1.x - c2.x);
  angle+=Math.PI / 2;
  Point d=new Point((int)(offset * Math.cos(angle)),(int)(offset * Math.sin(angle)));
  c1.translate(d.x,d.y);
  c2.translate(d.x,d.y);
  Point p1=getBoundaryIntersection(comp1,c1,c2);
  Point p2=getBoundaryIntersection(comp2,c2,c1);
  if ((p1 == null) || (p2 == null)) {
    c1=new Point((int)(r1.x + r1.width / 2.0),(int)(r1.y + r1.height / 2.0));
    c2=new Point((int)(r2.x + r2.width / 2.0),(int)(r2.y + r2.height / 2.0));
    p1=getBoundaryIntersection(comp1,c1,c2);
    p2=getBoundaryIntersection(comp2,c2,c1);
  }
  if ((p1 == null) || (p2 == null)) {
    return null;
  }
  return new PointPair(p1,p2);
}

protected final PointPair calculateEdge ( DisplayNode comp1 , DisplayNode comp2 ) { Rectangle r1 = comp1 . getBounds ( ) ; Rectangle r2 = comp2 . getBounds ( ) ; Point c1 = new Point ( ( int ) ( r1 . x + r1 . width / 2.0 ) , ( int ) ( r1 . y + r1 . height / 2.0 ) ) ; Point c2 = new Point ( ( int ) ( r2 . x + r2 . width / 2.0 ) , ( int ) ( r2 . y + r2 . height / 2.0 ) ) ; double angle = Math . atan2 ( c1 . y - c2 . y , c1 . x - c2 . x ) ; angle += Math . PI / 2 ; Point d = new Point ( ( int ) ( offset * Math . cos ( angle ) ) , ( int ) ( offset * Math . sin ( angle ) ) ) ; c1 . translate ( d . x , d . y ) ; c2 . translate ( d . x , d . y ) ; Point p1 = getBoundaryIntersection ( comp1 , c1 , c2 ) ; Point p2 = getBoundaryIntersection ( comp2 , c2 , c1 ) ; if ( ( p1 == null ) || ( p2 == null ) ) { c1 = new Point ( ( int ) ( r1 . x + r1 . width / 2.0 ) , ( int ) ( r1 . y + r1 . height / 2.0 ) ) ; c2 = new Point ( ( int ) ( r2 . x + r2 . width / 2.0 ) , ( int ) ( r2 . y + r2 . height / 2.0 ) ) ; p1 = getBoundaryIntersection ( comp1 , c1 , c2 ) ; p2 = getBoundaryIntersection ( comp2 , c2 , c1 ) ; } if ( ( p1 == null ) || ( p2 == null ) ) { return null ; } return new PointPair ( p1 , p2 ) ; }
calculates the two endpoints of the line segment connecting two given non - overlapping rectangles . ( should give back null for overlapping rectangles but doesn ' t always . . . )
