public Geometry create(){
  if (generator == null)   throw new NullPointerException("Missing child generator");
  if (numberGeometries < 1)   throw new IllegalStateException("Too few child geoms to create");
  ArrayList geoms=new ArrayList(numberGeometries);
  GridGenerator grid=GeometryGenerator.createGridGenerator();
  grid.setBoundingBox(boundingBox);
  grid.setGeometryFactory(geometryFactory);
switch (generationAlgorithm) {
case BOX:
    int nrow=(int)Math.sqrt(numberGeometries);
  int ncol=numberGeometries / nrow;
grid.setNumberRows(nrow);
grid.setNumberColumns(ncol);
break;
case VERT:
grid.setNumberRows(1);
grid.setNumberColumns(numberGeometries);
break;
case HORZ:
grid.setNumberRows(numberGeometries);
grid.setNumberColumns(1);
break;
default :
throw new IllegalStateException("Invalid Alg. Specified");
}
while (grid.canCreate()) {
generator.setBoundingBox(grid.createEnv());
geoms.add(generator.create());
}
if (generator instanceof PointGenerator) {
return geometryFactory.createMultiPoint((Point[])geoms.toArray(new Point[numberGeometries]));
}
 else {
if (generator instanceof LineStringGenerator) {
return geometryFactory.createMultiLineString((LineString[])geoms.toArray(new LineString[numberGeometries]));
}
 else {
if (generator instanceof PolygonGenerator) {
return geometryFactory.createMultiPolygon((Polygon[])geoms.toArray(new Polygon[numberGeometries]));
}
 else {
return geometryFactory.createGeometryCollection((Geometry[])geoms.toArray(new Geometry[numberGeometries]));
}
}
}
}

public Geometry create ( ) { if ( generator == null ) throw new NullPointerException ( "Missing child generator" ) ; if ( numberGeometries < 1 ) throw new IllegalStateException ( "Too few child geoms to create" ) ; ArrayList geoms = new ArrayList ( numberGeometries ) ; GridGenerator grid = GeometryGenerator . createGridGenerator ( ) ; grid . setBoundingBox ( boundingBox ) ; grid . setGeometryFactory ( geometryFactory ) ; switch ( generationAlgorithm ) { case BOX : int nrow = ( int ) Math . sqrt ( numberGeometries ) ; int ncol = numberGeometries / nrow ; grid . setNumberRows ( nrow ) ; grid . setNumberColumns ( ncol ) ; break ; case VERT : grid . setNumberRows ( 1 ) ; grid . setNumberColumns ( numberGeometries ) ; break ; case HORZ : grid . setNumberRows ( numberGeometries ) ; grid . setNumberColumns ( 1 ) ; break ; default : throw new IllegalStateException ( "Invalid Alg. Specified" ) ; } while ( grid . canCreate ( ) ) { generator . setBoundingBox ( grid . createEnv ( ) ) ; geoms . add ( generator . create ( ) ) ; } if ( generator instanceof PointGenerator ) { return geometryFactory . createMultiPoint ( ( Point [ ] ) geoms . toArray ( new Point [ numberGeometries ] ) ) ; } else { if ( generator instanceof LineStringGenerator ) { return geometryFactory . createMultiLineString ( ( LineString [ ] ) geoms . toArray ( new LineString [ numberGeometries ] ) ) ; } else { if ( generator instanceof PolygonGenerator ) { return geometryFactory . createMultiPolygon ( ( Polygon [ ] ) geoms . toArray ( new Polygon [ numberGeometries ] ) ) ; } else { return geometryFactory . createGeometryCollection ( ( Geometry [ ] ) geoms . toArray ( new Geometry [ numberGeometries ] ) ) ; } } } }
creates a geometry collection representing the set of child geometries created .
