Search in sources :

Example 6 with StyleService

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);
    }
}
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 7 with StyleService

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);
}
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 8 with StyleService

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;
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Color(java.awt.Color) Style(org.geotools.styling.Style) Drawer(org.geotools.legend.Drawer) SimpleFeature(org.opengis.feature.simple.SimpleFeature) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Example 9 with StyleService

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());
}
Also used : StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService)

Example 10 with StyleService

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

Aggregations

StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)10 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)3 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)3 ISelectionService (org.eclipse.ui.ISelectionService)3 Style (org.geotools.styling.Style)3 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)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 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)1 PainterLayoutController (eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController)1 AbstractInstancePainter (eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 IPartService (org.eclipse.ui.IPartService)1 Drawer (org.geotools.legend.Drawer)1 LineSymbolizer (org.geotools.styling.LineSymbolizer)1 PointSymbolizer (org.geotools.styling.PointSymbolizer)1