com.mapinfo.midev.geometry

## Class PolygonRingBuilder

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

    public final class PolygonRingBuilder
    extends Object

A builder to create outer and inner rings for polygons.

### Method Summary

All Methods Instance Methods Concrete Methods
`IPolygonBuilder` `build()` Creates a new ring and adds it to the parent polygon builder.
`PolygonRingBuilder` `withLineString(DirectPosition[] positions)` Adds a new line string to the ring to be created with this builder.
`PolygonRingBuilder` `withLineString(IDirectPositionList positions)` Adds a new line string to the ring to be created with this builder.
`PolygonRingBuilder` `withLineString(Iterable positions)` Adds a new line string to the ring to be created with this builder.
`PolygonRingBuilder` `withPoint(DirectPosition position)` Adds a new point to the ring constructed by this builder.
`PolygonRingBuilder` `withPoint(double x, double y)` Adds a new point to the ring constructed by this builder.
`PolygonRingBuilder` `withPoint(String x, String y)` Adds a new point to the ring constructed by this builder.

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

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

### Method Detail

#### withLineString

    public PolygonRingBuilder withLineString(DirectPosition[] positions)

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

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

#### withLineString

    public PolygonRingBuilder withLineString(Iterable positions)

Adds a new line string to the ring 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 instance.

#### withLineString

    public PolygonRingBuilder withLineString(IDirectPositionList positions)

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

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

#### withPoint

    public PolygonRingBuilder withPoint(double x,
                                        double y)

Adds a new point to the ring 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 instance

#### withPoint

    public PolygonRingBuilder withPoint(String x,
                                        String y)

Adds a new point to the ring 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 instance
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 PolygonRingBuilder withPoint(DirectPosition position)

Adds a new point to the ring 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 coordinates of the point to be added.
Returns:
  this builder instance

#### build

    public IPolygonBuilder build()

Creates a new ring and adds it to the parent polygon builder. The line strings added to this builder are generally expected to form a contiguous closed sequence of lines. However, the following modifications are 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 neither starts or ends with the point the previously added line string ended with, the end point of the previous line string will be inserted at the start of the next line string. If the last line string doesn't end with the same point as the first line string ended with, it will be appended to the end of the last line string.

Returns:
  the parent polygon builder instance.