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);
}
}
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);
}
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);
}
}
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;
}
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;
}
Aggregations