Take a look at http://tsusiatsoftware.net/jts/javadoc/index.html
If I assume that you are using an instance of GeometryCollection. If true, you can directly call
geometry.getEnvelope();
or
geometry.getEnvelopeInternal();
If you need an instance of Envelope
It will return you the minimum GeometryCollection rectangle.
If you have a collection of geometries, you can use the envelope directly and expand it each time you process the new geometry of your collection.
Envelope env = new Envelope(); for(Geometry g : mySet){ env.expandToInclude(g.getEnvelopeInternal()): }
or
Envelope env = new Envelope(); for(Geometry g : mySet){ env.expandToInclude(g.getBoundary().getEnvelopeInternal()): }
source share