ILayer nextLayer = strategy.getNextLayer();
ILayer selectedLayer = activeLayer;
// change the layer we are looking at based on navigation
Geometry geometry = strategy.getGeometry();
Polygon testLocation = JTS.toGeometry(this.bbox);
if(isNavigate && (mouseEvent.button == MapMouseEvent.BUTTON3)){
if( previousLayer != null ){
selectedLayer = previousLayer;
}
else {
// end of the world!
updateAOIService(null, null);
bounds = getMap().getBounds(null);
ViewportModelImpl vmi = (ViewportModelImpl) getMap().getViewportModel();
vmi.zoomToBox(bounds);
return;
}
}
else if (isNavigate && (mouseEvent.button == MapMouseEvent.BUTTON1)) {
selectedLayer = nextLayer != null ? nextLayer : activeLayer;
if( activeLayer != null ){
// please stay on the active layer until you have a geometry
if( geometry == null || !geometry.contains( testLocation)){
// we need a selected geometry before we let people navigate away
selectedLayer = activeLayer;
}
}
}
if( selectedLayer == null){
return; // nothing to do!
}
if (!selectedLayer.getInteraction(Interaction.AOI)){
return; // eek!
}
// use the bbox to see if we hit anything!
SimpleFeatureCollection featureCollection = getFeaturesInBbox(selectedLayer, bbox, monitor);
if (featureCollection.isEmpty()) {
// the user did not click on anything useful (so sad)!
// see if they were trying to click around on the active layer instead!
if( selectedLayer == activeLayer){
return; // give up no change to AOI stuffs
}
else {
// quickly test to see if they clicked on a neighbour
SimpleFeatureCollection testCollection = getFeaturesInBbox(activeLayer, bbox, monitor);
if(!testCollection.isEmpty() ){
// okay let us go to neighbour
selectedLayer = activeLayer;
featureCollection = testCollection;
}
else {
return; // user really did not find anything to click on
}
}
}
bounds = featureCollection.getBounds();
Geometry newAOI = unionGeometry(featureCollection);
updateAOIService(selectedLayer,newAOI );
if (isNavigate) {
IMap map = selectedLayer.getMap();