Class BufferParameters

Hierarchy: Object , BufferParameters
public class BufferParameters
A value class containing the parameters which specify how a buffer should be constructed.

The parameters allow control over:

  • Quadrant segments (accuracy of approximation for circular arcs)
  • End Cap style
  • Join style
  • Mitre limit
  • whether the buffer is single-sided
Authors:
Martin Davis
public BufferParameters()
Creates a default set of parameters
public BufferParameters(int quadrantSegments)
Creates a set of parameters with the given quadrantSegments value.
Parameters:
quadrantSegments - quadrantSegments the number of quadrant segments to use
public BufferParameters(int quadrantSegments, int endCapStyle)
Creates a set of parameters with the given quadrantSegments and endCapStyle values.
Parameters:
quadrantSegments - quadrantSegments the number of quadrant segments to use
endCapStyle - endCapStyle the end cap style to use
public BufferParameters(int quadrantSegments, int endCapStyle, int joinStyle, double mitreLimit)
Creates a set of parameters with the given parameter values.
Parameters:
quadrantSegments - quadrantSegments the number of quadrant segments to use
endCapStyle - endCapStyle the end cap style to use
joinStyle - joinStyle the join style to use
mitreLimit - mitreLimit the mitre limit to use
public int getQuadrantSegments()
Gets the number of quadrant segments which will be used
Returns:
the number of quadrant segments
public void setQuadrantSegments(int quadSegs)
Sets the number of line segments used to approximate an angle fillet.
  • If quadSegs >= 1, joins are round, and quadSegs indicates the number of segments to use to approximate a quarter-circle.
  • If quadSegs = 0, joins are bevelled (flat)
  • If quadSegs < 0, joins are mitred, and the value of qs indicates the mitre ration limit as
     mitreLimit = |quadSegs|
     
For round joins, quadSegs determines the maximum error in the approximation to the true buffer curve. The default value of 8 gives less than 2% max error in the buffer distance. For a max error of < 1%, use QS = 12. For a max error of < 0.1%, use QS = 18. The error is always less than the buffer distance (in other words, the computed buffer curve is always inside the true curve).
Parameters:
quadSegs - quadSegs the number of segments in a fillet for a quadrant
public static double bufferDistanceError(int quadSegs)
Computes the maximum distance error due to a given level of approximation to a true arc.
Parameters:
quadSegs - quadSegs the number of segments used to approximate a quarter-circle
Returns:
the error of approximation
public int getEndCapStyle()
Gets the end cap style.
Returns:
the end cap style
public void setEndCapStyle(int endCapStyle)
Specifies the end cap style of the generated buffer. The styles supported are CAP_ROUND, CAP_FLAT, and CAP_SQUARE. The default is CAP_ROUND.
Parameters:
endCapStyle - endCapStyle the end cap style to specify
public int getJoinStyle()
Gets the join style
Returns:
the join style code
public void setJoinStyle(int joinStyle)
Sets the join style for outside (reflex) corners between line segments. Allowable values are JOIN_ROUND (which is the default), JOIN_MITRE and {link JOIN_BEVEL}.
Parameters:
joinStyle - joinStyle the code for the join style
public double getMitreLimit()
Gets the mitre ratio limit.
Returns:
the limit value
public void setMitreLimit(double mitreLimit)
Sets the limit on the mitre ratio used for very sharp corners. The mitre ratio is the ratio of the distance from the corner to the end of the mitred offset corner. When two line segments meet at a sharp angle, a miter join will extend far beyond the original geometry. (and in the extreme case will be infinitely far.) To prevent unreasonable geometry, the mitre limit allows controlling the maximum length of the join corner. Corners with a ratio which exceed the limit will be beveled.
Parameters:
mitreLimit - mitreLimit the mitre ratio limit
public void setSingleSided(boolean isSingleSided)
Sets whether the computed buffer should be single-sided. A single-sided buffer is constructed on only one side of each input line.

The side used is determined by the sign of the buffer distance:

  • a positive distance indicates the left-hand side
  • a negative distance indicates the right-hand side
The single-sided buffer of point geometries is the same as the regular buffer.

The End Cap Style for single-sided buffers is always ignored, and forced to the equivalent of CAP_FLAT.

Parameters:
isSingleSided - isSingleSided true if a single-sided buffer should be constructed
public boolean isSingleSided()
Tests whether the buffer is to be generated on a single side only.
Returns:
true if the generated buffer is to be single-sided
public double getSimplifyFactor()
Gets the simplify factor.
Returns:
the simplify factor
public void setSimplifyFactor(double simplifyFactor)
Sets the factor used to determine the simplify distance tolerance for input simplification. Simplifying can increase the performance of computing buffers. Generally the simplify factor should be greater than 0. Values between 0.01 and .1 produce relatively good accuracy for the generate buffer. Larger values sacrifice accuracy in return for performance.
Parameters:
simplifyFactor - simplifyFactor a value greater than or equal to zero.