Package org.locationtech.udig.project.internal.render.impl

Examples of org.locationtech.udig.project.internal.render.impl.RendererCreatorImpl$DumbRenderer


                ReferencedEnvelope bounds = (ReferencedEnvelope) params.toDraw.getViewportModel().getBounds();
                ReferencedEnvelope boundsCopy = new ReferencedEnvelope(bounds);
                RenderContext tools = configureMapForRendering(map, params.destinationSize, params.dpi, params.boundsStrategy, boundsCopy);
               
                RendererCreator decisive = new RendererCreatorImpl();
                decisive.setContext(tools);

                decisive.getLayers().addAll(layersToRender);

                SortedSet<RenderContext> sortedContexts = new TreeSet<RenderContext>(
                        decisive.getConfiguration());

                render(params, monitor, decisive, sortedContexts);

            }

            private void render(final DrawMapParameter params,
                    IProgressMonitor monitor, RendererCreator decisive,
                    SortedSet<RenderContext> sortedContexts)
                    throws InvocationTargetException {
               
                monitor.beginTask("Rendering map", sortedContexts.size());
                RenderContext mainContext = decisive.getContext();

                ILabelPainter labelPainter = mainContext.getLabelPainter();
                labelPainter.clear();
                labelPainter.start();
               
                Dimension displaySize = params.destinationSize;
                Iterator<RenderContext> iter = sortedContexts.iterator();
                while (iter.hasNext()) {
                    RenderContext context = (RenderContext) iter.next();

                    ILayer layer = context.getLayer();
                    boolean isLayerFromGrid = layer.getGeoResource().canResolve(GridCoverage.class);
                    String layerId = getLayerId(layer);

                    if( !(layer instanceof SelectionLayer) ||
                            ((layer instanceof SelectionLayer) && params.selectionStyle.getShowLabels()) ){
                        labelPainter.startLayer(layerId);
                    }
                    try {
                        if (context instanceof CompositeRenderContext) {
                            CompositeRenderContext compositeContext = (CompositeRenderContext) context;
                            List<ILayer> layers = compositeContext.getLayers();
                            boolean visible = false;
                            for (ILayer tmpLayer : layers) {
                                visible = visible || tmpLayer.isVisible();
                            }
                            if (!visible)
                                continue;
                        } else if (!layer.isVisible())
                            continue;
                        Renderer renderer = decisive.getRenderer(context);
                        ProjectUIPlugin
                                .trace(
                                        ApplicationGIS.class,
                                        "Issuing render call to " + renderer.getName(), null); //$NON-NLS-1$
                        try {
View Full Code Here


    @Test
    public void testGetLayers() throws Exception {
        Map map = MapTests.createDefaultMap("typename", 2, true, null); //$NON-NLS-1$
        map.getLayersInternal().add(map.getLayerFactory().createLayer(MapTests.createGeoResource("type2", 3, false))); //$NON-NLS-1$
       
        RendererCreatorImpl creator = MapTests.createRendererCreator(map);
       
        SortedSet<Layer> layers = creator.getLayers();
        layers.clear();
        layers.addAll(map.getLayersInternal());
        layers.add(new SelectionLayer(map.getLayersInternal().get(0)));
        layers.add(new SelectionLayer(map.getLayersInternal().get(1)));
       
View Full Code Here

    @Ignore
    @Test
    public void testGetRenderer() throws Exception {
        LayerImpl layer = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), null);
       
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());
        creator.getLayers().add(layer);
       
        creator.reset();
        RenderContext context = creator.getConfiguration().iterator().next();
        Renderer renderer = creator.getRenderer(context);
        assertTrue( renderer instanceof SingleRenderer );
       
        // now test case where there is no good renderer
        layer = MapTests.createLayer(null, "HELLO", null); //$NON-NLS-1$
       
        creator = MapTests.createRendererCreator(layer.getMapInternal());
        creator.getLayers().add(layer);
       
        creator.reset();
       
        context = creator.getConfiguration().iterator().next();
        renderer = creator.getRenderer(context);
        assertTrue( renderer instanceof PlaceHolder );
        assertEquals(context, renderer.getContext());
       
       
    }
View Full Code Here

    @Test
    public void testChanged() throws Exception {
       
        LayerImpl layer = MapTests.createLayer(null, new TestFeatureStore(), null);
   
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());
   
        NotificationImpl notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer);
        creator.changed(notificationImpl);
      
        SortedSet<Layer> layers = creator.getLayers();
       
        assertEquals(2, layers.size());
       
        Iterator<Layer> iter = layers.iterator();
        boolean selectionLayerFound=false;
        while( iter.hasNext() ){
            Layer next = iter.next();
            if (next instanceof SelectionLayer) {
                SelectionLayer sl = (SelectionLayer) next;
                selectionLayerFound=true;
                assertEquals(layer,sl.getWrappedLayer());
            }else{
                assertEquals(layer, next);
            }
        }
        assertTrue( selectionLayerFound );
       
        ContextModelListener listener = new ContextModelListener();
        layer.getContextModel().eAdapters().add(listener);
       
        layer.getMapInternal().getLayersInternal().remove(layer);
        creator.changed(listener.lastNotification);
      

        layers = creator.getLayers();
       
        assertEquals(0, layers.size());
    }
View Full Code Here

    public void testFindSelectionLayer() throws Exception {
        LayerImpl layer = MapTests.createLayer(null, new TestFeatureStore(), null);
        Map map = layer.getMapInternal();
        LayerImpl layer2 = MapTests.createLayer(null, new TestFeatureStore(), map);
       
        RendererCreatorImpl creator = MapTests.createRendererCreator(map);
       
        NotificationImpl event = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer);

        creator.changed(event);
        event = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer2);

        creator.changed(event);
        assertEquals( layer, ((SelectionLayer)creator.findSelectionLayer(layer)).getWrappedLayer());
        assertEquals( layer2, ((SelectionLayer)creator.findSelectionLayer(layer2)).getWrappedLayer());
       
    }
View Full Code Here

    @Ignore
    @Test
    public void testGetConfigurationSingleLayer() throws Throwable {
        LayerImpl layer = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), null);
       
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());

        NotificationImpl notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer);
        creator.changed(notificationImpl);
        RenderContext context = creator.getConfiguration().iterator().next();

        assertEquals(1, creator.getLayers().size());
        Renderer renderer = creator.getRenderer(context);
        assertTrue("Expected SingleRenderer but was "+renderer, renderer instanceof SingleRenderer); //$NON-NLS-1$
        assertEquals(1, creator.getConfiguration().size());

        layer=MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), layer.getMapInternal());
        notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer);
        creator.changed(notificationImpl);
       
        assertEquals(2, creator.getLayers().size());
        assertEquals(2, creator.getConfiguration().size());
        for( RenderContext context2 : creator.getConfiguration() ) {       
            renderer = creator.getRenderer(context2);
            assertTrue("Expected SingleRenderer but was "+renderer, renderer instanceof SingleRenderer); //$NON-NLS-1$
        }

        notificationImpl = new ENotificationImpl((InternalEObjectlayer.getContextModel(), Notification.REMOVE,
                ProjectPackage.CONTEXT_MODEL__LAYERS, layer,  null);
        creator.changed(notificationImpl);
        context = creator.getConfiguration().iterator().next();

        assertEquals(1, creator.getLayers().size());
        renderer = creator.getRenderer(context);
        assertTrue("Expected SingleRenderer but was "+renderer, renderer instanceof SingleRenderer); //$NON-NLS-1$
        assertEquals(1, creator.getConfiguration().size());
    }
View Full Code Here

        LayerImpl layer = MapTests.createLayer(null, new RendererCreatorTestObjForMulitRenderer(), null);
        Map map=layer.getMapInternal();
        ContextModelListener listener = new ContextModelListener();
        layer.getContextModel().eAdapters().add(listener);
       
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());

        // Listener added after first layer was added so make notification by hand
        NotificationImpl notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer);
        creator.changed(notificationImpl);
        RenderContext context = creator.getConfiguration().iterator().next();
       
        assertEquals(1, creator.getLayers().size());
        Renderer renderer = creator.getRenderer(context);
        assertSame( context, renderer.getContext() );
        assertTrue("Expected MultiLayerRenderer but was "+renderer, renderer instanceof MultiLayerRenderer); //$NON-NLS-1$
        assertEquals(1, creator.getConfiguration().size());

        layer=MapTests.createLayer(new URL( "http://multi_dummy"), new RendererCreatorTestObjForMulitRenderer(), layer.getMapInternal()); //$NON-NLS-1$
        creator.changed(listener.lastNotification);
       
        assertEquals(2, creator.getLayers().size());
        assertEquals(1, creator.getConfiguration().size());
        context=creator.getConfiguration().iterator().next();
        renderer = creator.getRenderer(context);
        assertSame( context, renderer.getContext() );
        CompositeRenderContext compositeRenderContext = ((CompositeRenderContext)creator.getConfiguration().iterator().next());
        assertEquals(2, compositeRenderContext.getContexts().size());
       
        assertTrue("Expected MultiRenderer but was "+renderer, renderer instanceof MultiLayerRenderer); //$NON-NLS-1$
       
        layer=MapTests.createLayer(new URL( "http://othername"), new RendererCreatorTestObjForMulitRenderer(), layer.getMapInternal()); //$NON-NLS-1$
        creator.changed(listener.lastNotification);

        assertEquals(3, creator.getLayers().size());
        assertEquals(2, creator.getConfiguration().size());
        for( RenderContext context2 : creator.getConfiguration() ) {       
            renderer = creator.getRenderer(context2);
            assertTrue("Expected SingleRenderer but was "+renderer, renderer instanceof MultiLayerRenderer); //$NON-NLS-1$
        }
       
        map.lowerLayer(layer);
       
        int indexOfOtherName=map.getMapLayers().indexOf(layer);
       
        creator.changed(listener.lastNotification);

        assertEquals(3, creator.getLayers().size());
        assertEquals(3, creator.getConfiguration().size());
        for( RenderContext context2 : creator.getConfiguration() ) {       
            renderer = creator.getRenderer(context2);
            assertTrue("Expected SingleRenderer but was "+renderer, renderer instanceof MultiLayerRenderer); //$NON-NLS-1$
        }

        layer=MapTests.createLayer(new URL( "http://dummy"), new RendererCreatorTestObjForMulitRenderer(), null); //$NON-NLS-1$
        map.getLayersInternal().set(indexOfOtherName, layer);
        creator.changed(listener.lastNotification);
       
        assertEquals(3, creator.getLayers().size());
        assertEquals(1, creator.getConfiguration().size());
        renderer = creator.getRenderer(creator.getConfiguration().iterator().next());
        compositeRenderContext = ((CompositeRenderContext)creator.getConfiguration().iterator().next());
        assertEquals(3, compositeRenderContext.getContexts().size());
       
        map.getLayersInternal().remove(0);
        creator.changed(listener.lastNotification);
        assertEquals(2, creator.getLayers().size());
        assertEquals(1, creator.getConfiguration().size());
        renderer = creator.getRenderer(creator.getConfiguration().iterator().next());
        compositeRenderContext = ((CompositeRenderContext)creator.getConfiguration().iterator().next());
        assertEquals(2, compositeRenderContext.getContexts().size());
       
    }
View Full Code Here

    @Ignore
    @Test
    public void testGetConfigurationMixedLayers() throws Exception {
        LayerImpl layer = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), null);
       
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());

        LayerImpl layer2 = MapTests.createLayer(null, new RendererCreatorTestObjForMulitRenderer(), layer.getMapInternal());
        LayerImpl layer3 = MapTests.createLayer(null, new RendererCreatorTestObjForMulitRenderer(), layer.getMapInternal());
        LayerImpl layer4 = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), layer.getMapInternal());
       
        NotificationImpl notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer);
        creator.changed(notificationImpl);
       
        creator.reset();
        Collection<RenderContext> config = creator.getConfiguration();
       
        assertEquals( 1, config.size() );
       
        Iterator<RenderContext> iter = config.iterator();
       
        RenderContext context = iter.next();
        assertEquals(layer, context.getLayer());
       
        notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD_MANY,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, Arrays.asList(new Layer[]{layer2, layer3, layer4}));
        creator.changed(notificationImpl);
        creator.reset();
        config = creator.getConfiguration();

        iter = config.iterator();
       
        context = iter.next();
        assertEquals(layer, context.getLayer());
View Full Code Here

    @Ignore
    @Test
    public void testBugWithMultiLayerRenderers() throws Exception {
        LayerImpl layer = MapTests.createLayer(null, new RendererCreatorTestObjForMulitRenderer(), null);
        layer.setName("layer1"); //$NON-NLS-1$
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());

        LayerImpl layer2 = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), layer.getMapInternal());
        LayerImpl layer3 = MapTests.createLayer(null, new RendererCreatorTestObjForMulitRenderer(), layer.getMapInternal());
        layer2.setName("layer2"); //$NON-NLS-1$
        layer3.setName("layer3"); //$NON-NLS-1$

        creator.getLayers().addAll(Arrays.asList(new Layer[]{layer,layer2,layer3}));
       
        creator.reset();
       
        layer3.setZorder(0);
        NotificationImpl notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.MOVE,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, layer3,0);
        creator.changed(notificationImpl);

        Collection<RenderContext> config = creator.getConfiguration();
       
        assertEquals(3, creator.getLayers().size());
        assertEquals(2, config.size());
    }
View Full Code Here

        LayerImpl layer = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), null);
        layer.setName("Layer1"); //$NON-NLS-1$
        Map map=layer.getMapInternal();
        LayerImpl layer2 = MapTests.createLayer(null, new RendererCreatorTestObjForSingleRenderer(), map);
        layer2.setName("Layer2"); //$NON-NLS-1$
        RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());

        layer.getBlackboard().clear();
        layer2.getBlackboard().clear();
        map.getBlackboard().clear();
       
        NotificationImpl notificationImpl = new ENotificationImpl((InternalEObject) layer.getContextModel(), Notification.ADD_MANY,
                ProjectPackage.CONTEXT_MODEL__LAYERS, null, Arrays.asList(new Layer[]{layer,layer2}));
        creator.changed(notificationImpl);
       
        sameRenderer(creator, SingleRenderer.class, 2);
       
        layer.getBlackboard().put(RendererCreator.PREFERRED_RENDERER_ID, "org.locationtech.udig.project.tests.single2"); //$NON-NLS-1$
       
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.internal.render.impl.RendererCreatorImpl$DumbRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.