Search in sources :

Example 1 with GeometrySchemaService

use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.

the class StyledMapExtra method partClosed.

/**
 * @see IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
 */
@Override
public void partClosed(IWorkbenchPartReference partRef) {
    if (partRef.getPart(false) == mapView) {
        layoutController.disable();
        // 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
        disableScenePainterListeners(selection, instances, styles, geometries);
    }
}
Also used : StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) ISelectionService(org.eclipse.ui.ISelectionService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)

Example 2 with GeometrySchemaService

use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService 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 GeometrySchemaService

use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.

the class ServiceSchemaExplorer method dispose.

/**
 * Remove all service listeners.
 */
public void dispose() {
    if (schemaListener != null) {
        schemaService.removeSchemaServiceListener(schemaListener);
    }
    if (alignmentListener != null) {
        AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
        as.removeListener(alignmentListener);
    }
    if (entityListener != null) {
        EntityDefinitionService eds = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
        eds.removeListener(entityListener);
    }
    if (geometryListener != null) {
        GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
        gss.removeListener(geometryListener);
    }
    if (populationListener != null) {
        PopulationService ps = PlatformUI.getWorkbench().getService(PopulationService.class);
        ps.removeListener(populationListener);
    }
}
Also used : AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) PopulationService(eu.esdihumboldt.hale.ui.common.service.population.PopulationService) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) EntityDefinitionService(eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionService)

Example 4 with GeometrySchemaService

use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.

the class StyleHelper method getSpectrumStyles.

/**
 * Returns a default style for the given type.
 *
 * @param dataSetTypes type definitions associated to their data set
 * @return the style
 */
public static Style getSpectrumStyles(SetMultimap<DataSet, TypeDefinition> dataSetTypes) {
    int defWidth = StylePreferences.getDefaultWidth();
    Style style = styleFactory.createStyle();
    GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
    for (DataSet dataSet : dataSetTypes.keySet()) {
        float saturation;
        float brightness;
        switch(dataSet) {
            case TRANSFORMED:
                saturation = 0.8f;
                brightness = 0.6f;
                break;
            case SOURCE:
            default:
                saturation = 0.75f;
                brightness = 0.8f;
                break;
        }
        Set<TypeDefinition> types = new HashSet<>(dataSetTypes.get(dataSet));
        Iterator<TypeDefinition> it = types.iterator();
        while (it.hasNext()) {
            TypeDefinition type = it.next();
            // remove invalid types
            if (type.getConstraint(AbstractFlag.class).isEnabled() || gss.getDefaultGeometry(type) == null) {
                it.remove();
            }
        }
        int numberOfTypes = types.size();
        int index = 0;
        for (TypeDefinition typeDef : types) {
            FeatureTypeStyle fts;
            // TODO based on default geometry?
            // polygon is always OK as it contains stroke and fill
            // Color color = generateRandomColor(Color.WHITE);
            Color color;
            if (numberOfTypes == 1) {
                color = generateRandomColor(saturation, brightness);
            } else {
                color = Color.getHSBColor((float) index / (float) numberOfTypes, saturation, brightness);
            }
            fts = createPolygonStyle(color, defWidth);
            fts.featureTypeNames().add(new NameImpl(getFeatureTypeName(typeDef)));
            style.featureTypeStyles().add(fts);
            index++;
        }
    }
    return style;
}
Also used : NameImpl(org.geotools.feature.NameImpl) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) Color(java.awt.Color) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) HashSet(java.util.HashSet)

Example 5 with GeometrySchemaService

use of eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService in project hale by halestudio.

the class SetDefaultGeometryHandler method execute.

/**
 * @see IHandler#execute(ExecutionEvent)
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    /*
		 * Set the defaut geometry to the first valid child entity definition
		 * from the selection (for the type the entity definition is associated
		 * to)
		 */
    if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
        for (Object element : ((IStructuredSelection) selection).toList()) {
            if (element instanceof EntityDefinition) {
                EntityDefinition def = (EntityDefinition) element;
                if (!def.getPropertyPath().isEmpty()) {
                    // path must not be empty
                    // XXX is this true? we could set the default geometry
                    // to the type to use all geometries
                    List<QName> path = new ArrayList<QName>(def.getPropertyPath().size());
                    for (ChildContext child : def.getPropertyPath()) {
                        path.add(child.getChild().getName());
                    }
                    GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
                    gss.setDefaultGeometry(def.getType(), path);
                }
            }
        }
    }
    // otherwise does nothing
    return null;
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) QName(javax.xml.namespace.QName) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)

Aggregations

GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)9 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)4 QName (javax.xml.namespace.QName)4 StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)3 ISelectionService (org.eclipse.ui.ISelectionService)3 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)2 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ITileOverlayService (de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)1 TileOverlayFactory (de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory)1 PropertyParameter (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)1 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)1 PropertyCondition (eu.esdihumboldt.hale.common.align.model.condition.PropertyCondition)1 PropertyOrChildrenTypeCondition (eu.esdihumboldt.hale.common.align.model.condition.PropertyOrChildrenTypeCondition)1 GeometryCondition (eu.esdihumboldt.hale.common.align.model.condition.impl.GeometryCondition)1 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)1 PopulationService (eu.esdihumboldt.hale.ui.common.service.population.PopulationService)1