com.mapinfo.midev.geometry

## Class CurveBuilder

- java.lang.Object
- - com.mapinfo.midev.geometry.CurveBuilder

    public final class CurveBuilder
    extends Object

A builder for creating new `ICurve` instances.

### Method Summary

All Methods Instance Methods Concrete Methods
`ICurve` `build()` Creates a curve constructed from the line strings in this builder.
`CurveBuilder` `withLineString(DirectPosition[] positions)` Adds a new line string to the curve to be created with this builder.
`CurveBuilder` `withLineString(IDirectPositionList positions)` Adds a new line string to the curve to be created with this builder.
`CurveBuilder` `withLineString(Iterable positions)` Adds a new line string to the curve to be created with this builder.
`CurveBuilder` `withPoint(DirectPosition position)` Adds a new point to the curve constructed by this builder.
`CurveBuilder` `withPoint(double x, double y)` Adds a new point to the curve constructed by this builder.
`CurveBuilder` `withPoint(String x, String y)` Adds a new point to the curve constructed by this builder.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### withLineString

    public CurveBuilder withLineString(DirectPosition[] positions)

Adds a new line string to the curve to be created with this builder.

Parameters:
  `positions` - An array of direct positions representing the points of the line string.
Returns:
  this builder object

#### withLineString

    public CurveBuilder withLineString(Iterable positions)

Adds a new line string to the curve to be created with this builder.

Parameters:
  `positions` - An iterable data structure of direct positions representing the points of the line string.
Returns:
  this builder object

#### withLineString

    public CurveBuilder withLineString(IDirectPositionList positions)

Adds a new line string to the curve to be created with this builder.

Parameters:
  `positions` - A direct position list representing the points of the line string.
Returns:
  this builder object

#### withPoint

    public CurveBuilder withPoint(double x,
                                  double y)

Adds a new point to the curve constructed by this builder. Adding a point is interpreted as adding a line from the end of the previously added line string or point to the newly added point. If no line string or point has been added yet, and a new line string is added after adding only a single point, the single point will be connected to the starting point of the added line string.

Parameters:
  `x` - the x coordinate of the point to be added.
  `y` - the y coordinate of the point to be added.
Returns:
  this builder object

#### withPoint

    public CurveBuilder withPoint(String x,
                                  String y)

Adds a new point to the curve constructed by this builder. Adding a point is interpreted as adding a line from the end of the previously added line string or point to the newly added point. If no line string or point has been added yet, and a new line string is added after adding only a single point, the single point will be connected to the starting point of the added line string.

Parameters:
  `x` - the x coordinate of the point to be added.
  `y` - the y coordinate of the point to be added.
Returns:
  this builder object
Throws:
  `NumberFormatException` - if any of the coordinate values cannot be parsed into a double value
  `NullPointerException` - if any of the coordinate values is `null`.

#### withPoint

    public CurveBuilder withPoint(DirectPosition position)

Adds a new point to the curve constructed by this builder. Adding a point is interpreted as adding a line from the end of the previously added line string or point to the newly added point. If no line string or point has been added yet, and a new line string is added after adding only a single point, the single point will be connected to the starting point of the added line string.

Parameters:
  `position` - the position of the point to add
Returns:
  this builder object

#### build

    public ICurve build()

Creates a curve constructed from the line strings in this builder. The line strings are generally expected to form a contiguous sequence of lines. However, the following modifications will be applied, if that's not the case: If a line string ends with the same point as the previously added line string, it will be reversed. If a line string doesn't start or end with the same point as the previously added line string, the end point of the previous line string will be inserted at the start of the next line string.

Returns:
  A new curve instance
Throws:
  `InvalidGeometryException` - if no valid curve can be created from the previously added line strings