Class GeometricShapeFactory

Hierarchy: Object , GeometricShapeFactory
Direct Known Subclasses: SineStarFactory
public class GeometricShapeFactory
Computes various kinds of common geometric shapes. Provides various ways of specifying the location and extent and rotations of the generated shapes, as well as number of line segments used to form them.

Example of usage:

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

Other

  • version: 1.7
public GeometricShapeFactory()
Create a shape factory which will create shapes using the default GeometryFactory.
public GeometricShapeFactory(GeometryFactory geomFact)
Create a shape factory which will create shapes using the given GeometryFactory.
Parameters:
geomFact - geomFact the factory to use
public void setEnvelope(Envelope env)
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 - base the base coordinate of the shape
public void setCentre(Coordinate centre)
Sets the location of the shape by specifying the centre of the shape's bounding box
Parameters:
centre - centre the centre coordinate of the shape
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.
public void setSize(double size)
Sets the size of the extent of the shape in both x and y directions.
Parameters:
size - size the size of the shape's extent
public void setWidth(double width)
Sets the width of the shape.
Parameters:
width - width the width of the shape
public void setHeight(double height)
Sets the height of the shape.
Parameters:
height - height the height of the shape
public void setRotation(double radians)
Sets the rotation angle to use for the shape. The rotation is applied relative to the centre of the shape.
Parameters:
radians - radians the rotation angle in radians.
protected Geometry rotate(Geometry geom)
public Polygon createRectangle()
Creates a rectangular Polygon.
Returns:
a rectangular Polygon
public Polygon createCircle()
Creates a circular or elliptical Polygon.
Returns:
a circle or ellipse
public Polygon createEllipse()
Creates an elliptical Polygon. If the supplied envelope is square the result will be a circle.
Returns:
an ellipse or circle
public Polygon createSquircle()
Creates a squircular Polygon.
Returns:
a squircle
public Polygon createSupercircle(double power)
Creates a supercircular Polygon of a given positive power.
Returns:
a supercircle
public LineString createArc(double startAng, double angExtent)
Creates an elliptical arc, as a LineString. The arc is always created in a counter-clockwise direction. This can easily be reversed if required by using {#link LineString.reverse()}
Parameters:
startAng - startAng start angle in radians
angExtent - angExtent size of angle in radians
Returns:
an elliptical arc
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 - startAng start angle in radians
angExtent - angExtent size of angle in radians
Returns:
an elliptical arc polygon
protected Coordinate coord(double x, double y)
protected Coordinate coordTrans(double x, double y, Coordinate trans)