// selection should be an Feture (of some sort)
SimpleFeature feature = (SimpleFeature) selection;
Geometry geom = (Geometry) feature.getDefaultGeometry();
Point point = geom.getCentroid();
IMap imap = ApplicationGIS.getActiveMap();
if( imap == ApplicationGIS.NO_MAP ) return;
CoordinateReferenceSystem world = imap.getViewportModel().getCRS();
CoordinateReferenceSystem wsg84 = DefaultGeographicCRS.WGS84;
double buffer = 0.01; // how much of the wgs84 world to see
Envelope view = point.buffer( buffer ).getEnvelopeInternal();
MathTransform transform;
try {
transform = CRS.findMathTransform( wsg84, world, true ); // relaxed
} catch (FactoryException e) {
return; // no go
}
Envelope areaOfInterest;
try {
areaOfInterest = JTS.transform( view, null, transform, 10 );
} catch (TransformException e) {
return; // no go
}
//NavigationCommandFactory navigate = NavigationCommandFactory.getInstance();
NavCommand show = new SetViewportBBoxCommand(areaOfInterest, world);
imap.sendCommandASync( show );
}