use of eu.esdihumboldt.hale.ui.common.service.style.StyleService 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.common.service.style.StyleService 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.common.service.style.StyleService in project hale by halestudio.
the class DefinitionImages method getLegendImage.
/**
* Get a legend image for a given type definition
*
* @param type the type definition
* @param dataSet the data set the type definition belongs to
* @param definedOnly if only for defined styles a image shall be created
* @return the legend image or <code>null</code>
*/
protected BufferedImage getLegendImage(TypeDefinition type, DataSet dataSet, boolean definedOnly) {
StyleService ss = PlatformUI.getWorkbench().getService(StyleService.class);
Style style = (definedOnly) ? (ss.getDefinedStyle(type)) : (ss.getStyle(type, dataSet));
if (style == null) {
return null;
}
// create a dummy feature based on the style
Drawer d = Drawer.create();
SimpleFeature feature = null;
Symbolizer[] symbolizers = SLD.symbolizers(style);
if (symbolizers.length > 0) {
Symbolizer symbolizer = symbolizers[0];
if (symbolizer instanceof LineSymbolizer) {
feature = d.feature(d.line(LINE_POINTS));
} else if (symbolizer instanceof PointSymbolizer) {
feature = d.feature(d.point(WIDTH / 2, HEIGHT / 2));
}
if (symbolizer instanceof PolygonSymbolizer) {
feature = d.feature(d.polygon(POLY_POINTS));
}
}
if (feature != null) {
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
// GraphicsEnvironment.getLocalGraphicsEnvironment().
// getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(WIDTH, HEIGHT,
// Transparency.TRANSLUCENT);
// use white background to have a neutral color even if selected
Color bg = Color.WHITE;
Graphics2D g = image.createGraphics();
try {
g.setColor(bg);
g.fillRect(0, 0, WIDTH, HEIGHT);
} finally {
g.dispose();
}
d.drawDirect(image, feature, style);
return image;
}
return null;
}
use of eu.esdihumboldt.hale.ui.common.service.style.StyleService in project hale by halestudio.
the class SaveStyle method prepareProvider.
/**
* @see AbstractIOAdvisor#prepareProvider(IOProvider)
*/
@Override
public void prepareProvider(StyleWriter provider) {
super.prepareProvider(provider);
StyleService ss = getService(StyleService.class);
provider.setStyle(ss.getStyle());
}
use of eu.esdihumboldt.hale.ui.common.service.style.StyleService in project hale by halestudio.
the class StyledMapExtra method partOpened.
/**
* @see IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partOpened(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == mapView) {
mapView.restoreState();
// 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
updateScenePainters(selection);
// add listeners
enableScenePainterListeners(selection, instances, styles, geometries);
layoutController.enable();
}
}
Aggregations