## com.vividsolutions.jts.util
Class GeometricShapeFactory

    java.lang.Object
      com.vividsolutions.jts.util.GeometricShapeFactory

Direct Known Subclasses:
  SineStarFactory

public class GeometricShapeFactory
extends java.lang.Object

Computes various kinds of common geometric shapes. Allows various ways of specifying the location and extent of the shapes, as well as number of line segments used to form them.

Example:

      GeometricShapeFactory gsf = new GeometricShapeFactory();
      gsf.setSize(100);
      gsf.setNumPoints(100);
      gsf.setBase(new Coordinate(0, 0));
      Polygon rect = gsf.createRectangle();

Version:
  1.7

Nested Class Summary
`protected class` `GeometricShapeFactory.Dimensions`

Field Summary
`protected GeometricShapeFactory.Dimensions` `dim`
`protected GeometryFactory` `geomFact`
`protected int` `nPts`
`protected PrecisionModel` `precModel`

Constructor Summary
`GeometricShapeFactory()` Create a shape factory which will create shapes using the default `GeometryFactory`.
`GeometricShapeFactory(GeometryFactory geomFact)` Create a shape factory which will create shapes using the given `GeometryFactory`.

Method Summary
`LineString` `createArc(double startAng, double angExtent)` Creates an elliptical arc, as a `LineString`.
`Polygon` `createArcPolygon(double startAng, double angExtent)` Creates an elliptical arc polygon.
`Polygon` `createCircle()` Creates a circular `Polygon`.
`protected Coordinate` `createCoord(double x, double y)`
`protected Coordinate` `createCoordTrans(double x, double y, Coordinate trans)`
`Polygon` `createRectangle()` Creates a rectangular `Polygon`.
`Polygon` `createSquircle()` Creates a squircular `Polygon`.
`Polygon` `createSupercircle(double power)` Creates a supercircular `Polygon` of a given positive power.
`void` `setBase(Coordinate base)` Sets the location of the shape by specifying the base coordinate (which in most cases is the lower left point of the envelope containing the shape).
`void` `setCentre(Coordinate centre)` Sets the location of the shape by specifying the centre of the shape's bounding box
`void` `setEnvelope(Envelope env)`
`void` `setHeight(double height)` Sets the height of the shape.
`void` `setNumPoints(int nPts)` Sets the total number of points in the created `Geometry`.
`void` `setSize(double size)` Sets the size of the extent of the shape in both x and y directions.
`void` `setWidth(double width)` Sets the width of the shape.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### geomFact

    protected GeometryFactory geomFact

### precModel

    protected PrecisionModel precModel

### dim

    protected GeometricShapeFactory.Dimensions dim

### nPts

    protected int nPts

Constructor Detail

### GeometricShapeFactory

    public GeometricShapeFactory()

  Create a shape factory which will create shapes using the default `GeometryFactory`.

### GeometricShapeFactory

    public GeometricShapeFactory(GeometryFactory geomFact)

  Create a shape factory which will create shapes using the given `GeometryFactory`.

Parameters:
  `geomFact` - the factory to use

Method Detail

### setEnvelope

    public void setEnvelope(Envelope env)

### setBase

    public void setBase(Coordinate base)

  Sets the location of the shape by specifying the base coordinate (which in most cases is the lower left point of the envelope containing the shape).

  Parameters:
    `base` - the base coordinate of the shape

### setCentre

    public void setCentre(Coordinate centre)

  Sets the location of the shape by specifying the centre of the shape's bounding box

  Parameters:
    `centre` - the centre coordinate of the shape

### setNumPoints

    public void setNumPoints(int nPts)

  Sets the total number of points in the created `Geometry`. The created geometry will have no more than this number of points, unless more are needed to create a valid geometry.

### setSize

    public void setSize(double size)

  Sets the size of the extent of the shape in both x and y directions.

  Parameters:
    `size` - the size of the shape's extent

### setWidth

    public void setWidth(double width)

  Sets the width of the shape.

  Parameters:
    `width` - the width of the shape

### setHeight

    public void setHeight(double height)

  Sets the height of the shape.

  Parameters:
    `height` - the height of the shape

### createRectangle

    public Polygon createRectangle()

  Creates a rectangular `Polygon`.

  Returns:
    a rectangular Polygon

### createCircle

    public Polygon createCircle()

  Creates a circular `Polygon`.

  Returns:
    a circle

### createSquircle

    public Polygon createSquircle()

  Creates a squircular `Polygon`.

  Returns:
    a squircle

### createSupercircle

    public Polygon createSupercircle(double power)

  Creates a supercircular `Polygon` of a given positive power.

  Returns:
    a supercircle

### createArc

    public LineString createArc(double startAng,
                                double angExtent)

  Creates an elliptical arc, as a `LineString`. The arc is always created in a counter-clockwise direction.

  Parameters:
    `startAng` - start angle in radians
    `angExtent` - size of angle in radians
  Returns:
    an elliptical arc

### createArcPolygon

    public Polygon createArcPolygon(double startAng,
                                    double angExtent)

  Creates an elliptical arc polygon. The polygon is formed from the specified arc of an ellipse and the two radii connecting the endpoints to the centre of the ellipse.

  Parameters:
    `startAng` - start angle in radians
    `angExtent` - size of angle in radians
  Returns:
    an elliptical arc polygon

### createCoord

    protected Coordinate createCoord(double x,
                                     double y)

### createCoordTrans

    protected Coordinate createCoordTrans(double x,
                                          double y,
                                          Coordinate trans)