Package org.locationtech.udig.project.internal

Examples of org.locationtech.udig.project.internal.Map


        }
        if(layer.getMap().getProject() == null) {
          // this check is here because we are probably loading
          return;
        }
        Map map = layer.getMapInternal();

        ReferencedEnvelope bounds = map.getViewportModelInternal().getBounds();
        //  If first layer or if the crs has been unchanged from the original BBox
    if( map.getMapLayers().size()==1 || bounds==ViewportModel.NIL_BBOX){
            bounds = map.getBounds(ProgressManager.instance().get());
            map.getViewportModelInternal().setBounds(bounds);
        }
    }
View Full Code Here


       
        assertNull(getActiveWindow().getActivePage().getActiveEditor());
       
        SimpleFeature[] features = UDIGTestUtil.createDefaultTestFeatures("test", 4); //$NON-NLS-1$
        IGeoResource resource = MapTests.createGeoResource(features, false);
        final Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(512,512));
       
        TestIssue issue = new TestIssue(){
            @Override
            public String getEditorID() {
                return MapEditorWithPalette.ID;
View Full Code Here

        // TODO implement test
    }

    @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)));
       
        Iterator<Layer> iter = layers.iterator();
       
        Layer layer = iter.next();
        assertEquals( map.getLayersInternal().get(0),layer );
        layer = iter.next();
        assertEquals( map.getLayersInternal().get(1),layer );
        SelectionLayer sl = (SelectionLayer) iter.next();
        assertEquals( map.getLayersInternal().get(0),sl.getWrappedLayer() );
        sl = (SelectionLayer) iter.next();
        assertEquals( map.getLayersInternal().get(1),sl.getWrappedLayer() );
       
       
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    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,
View Full Code Here

    }
   
    @Test
    public void testGetConfigurationMultiLayerRenderer() throws Throwable {
        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());
View Full Code Here

    @Ignore
    @Test
    public void testBlackboardPreferred() throws Exception {
        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$
       
        firstLayerR2SecondR1(creator);       
       
        // now both layers have it so both should use renderer2
        layer2.getBlackboard().put(RendererCreator.PREFERRED_RENDERER_ID, "org.locationtech.udig.project.tests.single2"); //$NON-NLS-1$
       
        sameRenderer(creator , SingleRenderer2.class, 2);
       
        map.getBlackboard().put(RendererCreator.PREFERRED_RENDERER_ID, "org.locationtech.udig.project.tests.single2"); //$NON-NLS-1$
       
        sameRenderer(creator, SingleRenderer2.class, 2);
       
        layer2.getBlackboard().clear();
       
View Full Code Here

    @Ignore
    @Test
    public void testBlackBoardLastResort() throws Exception {
        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.LAST_RESORT_RENDERER_ID, "org.locationtech.udig.project.tests.single"); //$NON-NLS-1$
       
        firstLayerR2SecondR1(creator);       
       
        // now both layers have it so both should use renderer2
        layer2.getBlackboard().put(RendererCreator.LAST_RESORT_RENDERER_ID, "org.locationtech.udig.project.tests.single"); //$NON-NLS-1$
       
        sameRenderer(creator , SingleRenderer2.class, 2);
       
        map.getBlackboard().put(RendererCreator.LAST_RESORT_RENDERER_ID, "org.locationtech.udig.project.tests.single"); //$NON-NLS-1$
       
        sameRenderer(creator, SingleRenderer2.class, 2);
       
        layer2.getBlackboard().clear();
       
View Full Code Here

        setTitle(Messages.PalettePropertyPage_Title);
    }

    @Override
    public void setElement( IAdaptable element ) {
        Map map;
        if( element instanceof Map){
            map=(Map)element;
        }else{
            map=(Map) element.getAdapter(Map.class);
        }
View Full Code Here

                if (ProjectPackage.CONTEXT_MODEL__LAYERS == msg.getFeatureID(ContextModel.class)) {
                    switch (msg.getEventType()) {
                    case Notification.ADD: {
                        final Object eventNewObj = msg.getNewValue();
                        if (eventNewObj instanceof Layer) {
                            Map map = getMap();
                            if (map != null) {
                                List<ILegendItem> legend = map.getLegend();
                                if (legend != null) {
                                    final LayerLegendItem layerLegendItem = ProjectFactory.eINSTANCE
                                            .createLayerLegendItem();
                                    layerLegendItem.setLayer((Layer) eventNewObj);
View Full Code Here

     * @param layer
     * @return true if removed, otherwise false
     */
    private boolean removeLayerLegendItem(Layer layer) {
        LayerLegendItem flaggedLayerItem = null;
        Map map = getMap();
        if (map == null) {
            return false; // legend not available
        }
        for (ILegendItem item : map.getLegend()) {
            if (item instanceof Folder) {
                final boolean isRemoved = removeLayerLegendItem((Folder) item, layer);
                if (isRemoved) {
                    return true;
                }
            } else if (item instanceof LayerLegendItem) {
                final LayerLegendItem layerItem = (LayerLegendItem) item;
                if (layer == layerItem.getLayer()) {
                    flaggedLayerItem = layerItem;
                    break;
                }
            }
        }
        if (flaggedLayerItem != null) {
            map.getLegend().remove(flaggedLayerItem);
            return true;
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.internal.Map

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.