use of eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController in project hale by halestudio.
the class StyledMapExtra method setMapView.
/**
* @see MapViewExtension#setMapView(MapView)
*/
@Override
public void setMapView(MapView mapView) {
this.mapView = mapView;
layoutController = new PainterLayoutController(mapView.getMapKit());
/*
* Listen for activated/deactivated instance painters
*
* - remove listeners for deactivated painters and clear the waypoints -
* update activated listeners and add the corresponding listeners
*/
ITileOverlayService overlayService = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
overlayService.addListener(new SelectiveExtensionListener<TileOverlayPainter, TileOverlayFactory>() {
@Override
public void deactivated(TileOverlayPainter object, TileOverlayFactory definition) {
if (object instanceof AbstractInstancePainter) {
AbstractInstancePainter painter = (AbstractInstancePainter) object;
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// remove listeners
selection.removeSelectionListener(painter);
instances.removeListener(painter);
styles.removeListener(painter.getStyleListener());
geometries.removeListener(painter.getGeometryListener());
// clear way-points
painter.clearWaypoints();
}
}
@Override
public void activated(TileOverlayPainter object, TileOverlayFactory definition) {
if (object instanceof AbstractInstancePainter) {
AbstractInstancePainter painter = (AbstractInstancePainter) object;
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// update
painter.update(selection.getSelection());
// add listeners
selection.addSelectionListener(painter);
instances.addListener(painter);
styles.addListener(painter.getStyleListener());
geometries.addListener(painter.getGeometryListener());
}
}
});
IPartService partService = mapView.getSite().getService(IPartService.class);
partService.addPartListener(this);
// map tips
mapView.getMapTips().addMapTip(new InstanceMapTip(mapView.getMapKit()), 5);
}
Aggregations