if( resolutions == null ){
return;
}
Display.getCurrent().asyncExec( new Runnable() {
public void run() {
ViewportModel model = map.getViewportModelInternal();
double nextresolution = resolutions[ level ];
// find the center of the screen
double centerx = model.getCenter().x;
double centery = model.getCenter().y;
// using the next resolution, screen size, and center of the
// screen
// compute a bounding box
double pixelwidth = viewport.getWidth();
double newunitwidth = nextresolution * pixelwidth;
double xmin = centerx - (newunitwidth / 2.0);
double xmax = centerx + (newunitwidth / 2.0);
double newunitheight = nextresolution * viewport.getHeight();
double ymin = centery - (newunitheight / 2.0);
double ymax = centery + (newunitheight / 2.0);
// new bounding box
ReferencedEnvelope re = new ReferencedEnvelope( xmin, xmax, ymin, ymax, model.getCRS() );
// create a navigation command to update the viewport
map.sendCommandSync( new SetViewportBBoxCommand(re) );
}
} );