public static Geometry bufferBySegments(Geometry g,double distance){
  Geometry segs=LineHandlingFunctions.extractSegments(g);
  double posDist=Math.abs(distance);
  Geometry segBuf=bufferByComponents(segs,posDist);
  if (distance < 0.0)   return g.difference(segBuf);
  return g.union(segBuf);
}

public static Geometry bufferBySegments ( Geometry g , double distance ) { Geometry segs = LineHandlingFunctions . extractSegments ( g ) ; double posDist = Math . abs ( distance ) ; Geometry segBuf = bufferByComponents ( segs , posDist ) ; if ( distance < 0.0 ) return g . difference ( segBuf ) ; return g . union ( segBuf ) ; }
buffer polygons by buffering the individual boundary segments and either unioning or differencing them .
