Search in sources :

Example 1 with AbstractInstancePainter

use of eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter in project hale by halestudio.

the class StyledMapExtra method enableScenePainterListeners.

/**
 * Add the instance painters as listeners.
 *
 * @param selection the selection service
 * @param instances the instance service
 * @param styles the style service
 * @param geometries the geometry schema service
 */
private void enableScenePainterListeners(ISelectionService selection, InstanceService instances, StyleService styles, GeometrySchemaService geometries) {
    for (AbstractInstancePainter painter : mapView.getMapKit().getTilePainters(AbstractInstancePainter.class)) {
        selection.addSelectionListener(painter);
        instances.addListener(painter);
        styles.addListener(painter.getStyleListener());
        geometries.addListener(painter.getGeometryListener());
    }
}
Also used : AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter)

Example 2 with AbstractInstancePainter

use of eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter 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 3 with AbstractInstancePainter

use of eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter in project hale by halestudio.

the class StyledMapUtil method zoomToAll.

/**
 * Zoom to all instances available in the map. Does nothing if there are no
 * instances displayed.
 *
 * @param mapKit the map kit
 */
public static void zoomToAll(BasicMapKit mapKit) {
    BoundingBox bb = null;
    // determine bounding box
    for (AbstractInstancePainter painter : mapKit.getTilePainters(AbstractInstancePainter.class)) {
        BoundingBox painterBB = painter.getBoundingBox();
        if (painterBB.checkIntegrity() && !painterBB.isEmpty()) {
            if (bb == null) {
                bb = new BoundingBox(painterBB);
            } else {
                bb.add(painterBB);
            }
        }
    }
    if (bb != null) {
        Set<GeoPosition> positions = new HashSet<GeoPosition>();
        positions.add(new GeoPosition(bb.getMinX(), bb.getMinY(), SelectableWaypoint.COMMON_EPSG));
        positions.add(new GeoPosition(bb.getMaxX(), bb.getMaxY(), SelectableWaypoint.COMMON_EPSG));
        mapKit.zoomToPositions(positions);
    }
}
Also used : AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter) BoundingBox(de.fhg.igd.geom.BoundingBox) GeoPosition(org.jdesktop.swingx.mapviewer.GeoPosition) HashSet(java.util.HashSet)

Example 4 with AbstractInstancePainter

use of eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter in project hale by halestudio.

the class StyledMapUtil method zoomToSelection.

/**
 * Zoom to the selected instances. Does nothing if the selection is empty or
 * contains no {@link Instance}s or {@link InstanceReference}s.
 *
 * @param mapKit the map kit
 * @param selection the selection
 */
public static void zoomToSelection(BasicMapKit mapKit, IStructuredSelection selection) {
    BoundingBox bb = null;
    // determine bounding box for each reference and accumulate it
    for (AbstractInstancePainter painter : mapKit.getTilePainters(AbstractInstancePainter.class)) {
        for (Object element : selection.toList()) {
            InstanceReference ref = getReference(element);
            if (ref != null) {
                InstanceWaypoint wp = painter.findWaypoint(ref);
                if (wp != null) {
                    BoundingBox wpBB = wp.getBoundingBox();
                    if (wpBB.checkIntegrity() && !wpBB.isEmpty()) {
                        if (bb == null) {
                            bb = new BoundingBox(wpBB);
                        } else {
                            bb.add(wpBB);
                        }
                    }
                }
            }
        }
    }
    if (bb != null) {
        Set<GeoPosition> positions = new HashSet<GeoPosition>();
        positions.add(new GeoPosition(bb.getMinX(), bb.getMinY(), SelectableWaypoint.COMMON_EPSG));
        positions.add(new GeoPosition(bb.getMaxX(), bb.getMaxY(), SelectableWaypoint.COMMON_EPSG));
        mapKit.zoomToPositions(positions);
    }
}
Also used : InstanceWaypoint(eu.esdihumboldt.hale.ui.views.styledmap.painter.InstanceWaypoint) AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter) InstanceReference(eu.esdihumboldt.hale.common.instance.model.InstanceReference) BoundingBox(de.fhg.igd.geom.BoundingBox) GeoPosition(org.jdesktop.swingx.mapviewer.GeoPosition) HashSet(java.util.HashSet)

Example 5 with AbstractInstancePainter

use of eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter in project hale by halestudio.

the class AbstractInstanceTool method updateSelection.

/**
 * Update the selection for the given selection area.
 *
 * @param selectionArea the selection area (as supported by
 *            {@link #getSelection(AbstractInstancePainter, Object)})
 * @param combineWithLast if the selection shall be combined with the last
 *            selection
 * @param allowPainterCombine if selections from different painters may be
 *            combined
 */
protected void updateSelection(Object selectionArea, boolean combineWithLast, boolean allowPainterCombine) {
    ISelection newSelection = null;
    // determine new selection
    for (AbstractInstancePainter painter : mapKit.getTilePainters(AbstractInstancePainter.class)) {
        ISelection selection = getSelection(painter, selectionArea);
        if (allowPainterCombine) {
            newSelection = AbstractInstancePainter.combineSelection(newSelection, selection);
        } else {
            newSelection = AbstractInstancePainter.preferSelection(newSelection, selection);
        }
    }
    // combine with old
    if (combineWithLast) {
        newSelection = AbstractInstancePainter.combineSelection(lastSelection, newSelection);
    }
    if (newSelection == null) {
        newSelection = new DefaultInstanceSelection();
    }
    // selection update
    lastSelection = newSelection;
    fireSelectionChange(newSelection);
}
Also used : AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter) ISelection(org.eclipse.jface.viewers.ISelection) DefaultInstanceSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultInstanceSelection)

Aggregations

AbstractInstancePainter (eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter)6 BoundingBox (de.fhg.igd.geom.BoundingBox)2 HashSet (java.util.HashSet)2 GeoPosition (org.jdesktop.swingx.mapviewer.GeoPosition)2 ITileOverlayService (de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)1 TileOverlayFactory (de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory)1 InstanceReference (eu.esdihumboldt.hale.common.instance.model.InstanceReference)1 StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)1 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)1 DefaultInstanceSelection (eu.esdihumboldt.hale.ui.selection.impl.DefaultInstanceSelection)1 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)1 PainterLayoutController (eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController)1 InstanceWaypoint (eu.esdihumboldt.hale.ui.views.styledmap.painter.InstanceWaypoint)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IPartService (org.eclipse.ui.IPartService)1 ISelectionService (org.eclipse.ui.ISelectionService)1 TileOverlayPainter (org.jdesktop.swingx.mapviewer.TileOverlayPainter)1