Search in sources :

Example 1 with TileOverlayFactory

use of de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory 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);
}
Also used : PainterLayoutController(eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController) AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter) StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) IPartService(org.eclipse.ui.IPartService) TileOverlayFactory(de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) ITileOverlayService(de.fhg.igd.mapviewer.view.overlay.ITileOverlayService) ISelectionService(org.eclipse.ui.ISelectionService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) TileOverlayPainter(org.jdesktop.swingx.mapviewer.TileOverlayPainter)

Example 2 with TileOverlayFactory

use of de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory in project hale by halestudio.

the class TileOverlayProxy method getName.

/**
 * @see PainterProxy#getName()
 */
@Override
public String getName() {
    ITileOverlayService tos = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
    TileOverlayFactory def = tos.getFactory(id);
    if (def != null) {
        return def.getDisplayName();
    }
    return null;
}
Also used : TileOverlayFactory(de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory) ITileOverlayService(de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)

Example 3 with TileOverlayFactory

use of de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory in project hale by halestudio.

the class TileOverlayProxy method enable.

/**
 * @see PainterProxy#enable()
 */
@Override
public void enable() {
    ITileOverlayService tos = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
    TileOverlayFactory def = tos.getFactory(id);
    if (def != null) {
        tos.activate(def);
    }
}
Also used : TileOverlayFactory(de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory) ITileOverlayService(de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)

Example 4 with TileOverlayFactory

use of de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory in project hale by halestudio.

the class TileOverlayProxy method disable.

/**
 * @see PainterProxy#disable()
 */
@Override
public void disable() {
    ITileOverlayService tos = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
    TileOverlayFactory def = tos.getFactory(id);
    if (def != null) {
        tos.deactivate(def);
    }
}
Also used : TileOverlayFactory(de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory) ITileOverlayService(de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)

Aggregations

ITileOverlayService (de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)4 TileOverlayFactory (de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory)4 StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)1 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)1 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)1 PainterLayoutController (eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController)1 AbstractInstancePainter (eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter)1 IPartService (org.eclipse.ui.IPartService)1 ISelectionService (org.eclipse.ui.ISelectionService)1 TileOverlayPainter (org.jdesktop.swingx.mapviewer.TileOverlayPainter)1