private static Shape createBondHighlight ( IBond bond , double radius ) { double x1 = bond . getBegin ( ) . getPoint2d ( ) . x ; double x2 = bond . getEnd ( ) . getPoint2d ( ) . x ; double y1 = bond . getBegin ( ) . getPoint2d ( ) . y ; double y2 = bond . getEnd ( ) . getPoint2d ( ) . y ; double dx = x2 - x1 ; double dy = y2 - y1 ; double mag = Math . sqrt ( ( dx * dx ) + ( dy * dy ) ) ; dx /= mag ; dy /= mag ; double r2 = radius / 2 ; Shape s = new RoundRectangle2D . Double ( x1 - r2 , y1 - r2 , mag + radius , radius , radius , radius ) ; double theta = Math . atan2 ( dy , dx ) ; return AffineTransform . getRotateInstance ( theta , x1 , y1 ) . createTransformedShape ( s ) ; }
Create the shape which will highlight the provided bond .