public void addLineEndCap(Coordinate p0,Coordinate p1){
  LineSegment seg=new LineSegment(p0,p1);
  LineSegment offsetL=new LineSegment();
  computeOffsetSegment(seg,Position.LEFT,distance,offsetL);
  LineSegment offsetR=new LineSegment();
  computeOffsetSegment(seg,Position.RIGHT,distance,offsetR);
  double dx=p1.x - p0.x;
  double dy=p1.y - p0.y;
  double angle=Math.atan2(dy,dx);
switch (bufParams.getEndCapStyle()) {
case BufferParameters.CAP_ROUND:
    segList.addPt(offsetL.p1);
  addFillet(p1,angle + Math.PI / 2,angle - Math.PI / 2,CGAlgorithms.CLOCKWISE,distance);
segList.addPt(offsetR.p1);
break;
case BufferParameters.CAP_FLAT:
segList.addPt(offsetL.p1);
segList.addPt(offsetR.p1);
break;
case BufferParameters.CAP_SQUARE:
Coordinate squareCapSideOffset=new Coordinate();
squareCapSideOffset.x=Math.abs(distance) * Math.cos(angle);
squareCapSideOffset.y=Math.abs(distance) * Math.sin(angle);
Coordinate squareCapLOffset=new Coordinate(offsetL.p1.x + squareCapSideOffset.x,offsetL.p1.y + squareCapSideOffset.y);
Coordinate squareCapROffset=new Coordinate(offsetR.p1.x + squareCapSideOffset.x,offsetR.p1.y + squareCapSideOffset.y);
segList.addPt(squareCapLOffset);
segList.addPt(squareCapROffset);
break;
}
}

public void addLineEndCap ( Coordinate p0 , Coordinate p1 ) { LineSegment seg = new LineSegment ( p0 , p1 ) ; LineSegment offsetL = new LineSegment ( ) ; computeOffsetSegment ( seg , Position . LEFT , distance , offsetL ) ; LineSegment offsetR = new LineSegment ( ) ; computeOffsetSegment ( seg , Position . RIGHT , distance , offsetR ) ; double dx = p1 . x - p0 . x ; double dy = p1 . y - p0 . y ; double angle = Math . atan2 ( dy , dx ) ; switch ( bufParams . getEndCapStyle ( ) ) { case BufferParameters . CAP_ROUND : segList . addPt ( offsetL . p1 ) ; addFillet ( p1 , angle + Math . PI / 2 , angle - Math . PI / 2 , CGAlgorithms . CLOCKWISE , distance ) ; segList . addPt ( offsetR . p1 ) ; break ; case BufferParameters . CAP_FLAT : segList . addPt ( offsetL . p1 ) ; segList . addPt ( offsetR . p1 ) ; break ; case BufferParameters . CAP_SQUARE : Coordinate squareCapSideOffset = new Coordinate ( ) ; squareCapSideOffset . x = Math . abs ( distance ) * Math . cos ( angle ) ; squareCapSideOffset . y = Math . abs ( distance ) * Math . sin ( angle ) ; Coordinate squareCapLOffset = new Coordinate ( offsetL . p1 . x + squareCapSideOffset . x , offsetL . p1 . y + squareCapSideOffset . y ) ; Coordinate squareCapROffset = new Coordinate ( offsetR . p1 . x + squareCapSideOffset . x , offsetR . p1 . y + squareCapSideOffset . y ) ; segList . addPt ( squareCapLOffset ) ; segList . addPt ( squareCapROffset ) ; break ; } }
add an end cap around point p1 , terminating a line segment coming from p0
