Package org.locationtech.udig.project.internal

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


public class CompositeRenderContextImplTest {

    @Test
    public void testAddRemoveClear() 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$
       
        CompositeRendererImpl renderer = (CompositeRendererImpl) map.getRenderManagerInternal().getRenderExecutor().getRenderer();
        renderer.getContext().clear();
        RendererCreator creator=map.getRenderManagerInternal().getRendererCreator();
       
        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)));
       
        creator.reset();
       
        CompositeRenderContextImpl comp=new CompositeRenderContextImpl();
        comp.addContexts(creator.getConfiguration());
       
        Iterator iter = comp.getContexts().iterator()
       
        RenderContext executor = (RenderContext) iter.next();
        assertEquals( map.getLayersInternal().get(0),executor.getLayer() );
        executor = (RenderContext) iter.next();
        assertEquals( map.getLayersInternal().get(1),executor.getLayer() );
        executor = (RenderContext) iter.next();
        SelectionLayer sl = (SelectionLayer) executor.getLayer();
        assertEquals( map.getLayersInternal().get(0),sl.getWrappedLayer() );
        executor = (RenderContext) iter.next();
        sl = (SelectionLayer) executor.getLayer();
        assertEquals( map.getLayersInternal().get(1),sl.getWrappedLayer() );
    }
View Full Code Here


    /*
     * Test method for 'org.locationtech.udig.project.internal.commands.edit.AddFeatureCommand.run(IProgressMonitor)'
     */
    @Test
    public void testRun() throws Exception {
        Map map = MapTests.createDefaultMap("test", 2, true, new Dimension(10,10)); //$NON-NLS-1$
        Layer layer = map.getLayersInternal().get(0);
        SimpleFeatureType schema = layer.getSchema();
    SimpleFeature feature = SimpleFeatureBuilder.build(schema, new Object[]{null,null}, "id");
       
        AddFeatureCommand command=new AddFeatureCommand(feature, layer);
       
View Full Code Here

    private Map map;

    @Before
    public void setUp() throws Exception {
        map=MapTests.createDefaultMap("RMDTestType", 3, true, null, false); //$NON-NLS-1$
        Map m2 = MapTests.createDefaultMap("RMDTestType2", 3, true, null, false); //$NON-NLS-1$
        map.getLayersInternal().add(m2.getLayersInternal().get(0));
       
        ApplicationGIS.openMap(map, true);
        UDIGTestUtil.inDisplayThreadWait(2000, new WaitCondition(){

            public boolean isTrue() {
View Full Code Here

    //TODO: use more unique identifier than layer ID for scheme mapping key
   
    @Test
    public void testColourScheme() throws Exception {
         //add and remove some layers, and make sure the colours are proper
        Map map = MapTests.createDefaultMap("test", 2, true, new Dimension(10,10)); //$NON-NLS-1$
        IGeoResource resource1 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
                "type1", 4), false); //$NON-NLS-1$
        IGeoResource resource2 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
                "type2", 4), false); //$NON-NLS-1$
        IGeoResource resource3 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
                "type3", 4), false); //$NON-NLS-1$
        IGeoResource resource4 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
                "type4", 4), false); //$NON-NLS-1$
        IGeoResource resource5 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
                "type5", 4), false); //$NON-NLS-1$
        IGeoResource resource6 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
                "type6", 4), false); //$NON-NLS-1$
        assertEquals(1, map.getMapLayers().size());
       
        assertEquals(8, map.getColourScheme().getColourPalette().getMaxColors());
       
        List<IGeoResource> resources = new ArrayList<IGeoResource>();
        resources.add(resource1);
       
        assertTrue(coloursAreUnique(map.getColourScheme()));
       
        addLayer(resource1, map);
        assertEquals(2, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);
       
        removeLayer(map, 0);
        assertEquals(1, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        addLayer(resource2, map);
        assertEquals(2, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        addLayer(resource3, map);
        assertEquals(3, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        addLayer(resource4, map);
        assertEquals(4, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        addLayer(resource5, map);
        assertEquals(5, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        removeLayer(map, 2);
        assertEquals(4, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        addLayer(resource6, map);
        assertEquals(5, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

        addLayer(resource3, map);
        assertEquals(6, map.getMapLayers().size());
        assertTrue(coloursAreUnique(map.getColourScheme()));
        showDefaultColours(map);

    }
View Full Code Here

public class ViewerLayerSorterTest {

    @Test
    public void testCompareViewerObjectObject() throws Throwable {
        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$
        ViewerLayerSorter sorter=new ViewerLayerSorter();
        assertEquals( -1, sorter.compare(null, map.getLayersInternal().get(1), map.getLayersInternal().get(0)));
        assertEquals( 0, sorter.compare(null, map.getLayersInternal().get(1), map.getLayersInternal().get(1)));
        assertEquals( 1, sorter.compare(null, map.getLayersInternal().get(0), map.getLayersInternal().get(1)));
    }
View Full Code Here

    Layer layer;

    @Before
    public void setUp() throws Exception {
        SimpleFeature[] features=UDIGTestUtil.createDefaultTestFeatures("testType", 3); //$NON-NLS-1$
        Map map=MapTests.createNonDynamicMapAndRenderer(MapTests.createGeoResource(features,true), new Dimension(512,512));
        context = map.getRenderManagerInternal().getRenderExecutor().getContext();
        layer = map.getLayersInternal().get(0);
//        layer.setZorder(5);
        selectionLayer = new SelectionLayer(layer);
    }
View Full Code Here

        registry.eResource().getResourceSet().getResources().removeAll(toRemove);
       
        project=registry.getProject(FileLocator.toFileURL(Platform.getInstanceLocation().getURL()).getFile());

    resource1 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(type1Name,4),false);
    Map map = MapTests.createNonDynamicMapAndRenderer(resource1, new Dimension(512,512));
        map.setName(firstMapName);
    map.getLayersInternal().get(0).setName(firstMapLayerName);
   
    resource2 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(type2Name,6),false);
    map=MapTests.createNonDynamicMapAndRenderer(resource2, new Dimension(512,512));
    map.setName(secondMapName);
    map.getLayersInternal().get(0).setName(secondMapLayerName);
  }
View Full Code Here

    boolean foundFirstMap=false;
    boolean foundSecondMap=false;
   
    List resources=project.getElements();
    for (Iterator iter = resources.iterator(); iter.hasNext();) {
      Map map=(Map) iter.next();
 
      assertFalse(map.eIsProxy());
      assertEquals(1, map.getLayersInternal().size());
      assertNotNull(map.getLayersInternal().get(0).getGeoResources().get(0));
      assertNotNull(map.getLayersInternal().get(0).getResource(FeatureSource.class, new NullProgressMonitor()));
 
      if( map.getName().equals(firstMapName)){
        foundFirstMap=true;
        assertEquals( firstMapLayerName, map.getLayersInternal().get(0).getName());
        FeatureSource<SimpleFeatureType, SimpleFeature> source=map.getLayersInternal().get(0).getResource(FeatureSource.class, null);       
        assertEquals( 4, source.getCount(Query.ALL));
        assertEquals( firstMapLayerName, map.getLayersInternal().get(0).getName());
      }
      if( map.getName().equals(secondMapName)){
        foundSecondMap=true;
        assertEquals( secondMapLayerName, map.getLayersInternal().get(0).getName());
        FeatureSource<SimpleFeatureType, SimpleFeature> source=map.getLayersInternal().get(0).getResource(FeatureSource.class, null);       
        assertEquals( 6, source.getCount(Query.ALL));
        assertEquals( secondMapLayerName, map.getLayersInternal().get(0).getName());
      }
      maps++;
    }
    assertEquals(2,maps);
    assertTrue(foundFirstMap);
View Full Code Here

           
      List<IProjectElement> elements = project.getElements();
          for (IProjectElement element : elements) {
        if( element instanceof Map){
          Map map=(Map) element;
          map.eSetDeliver(false);
          map.sendCommandSync(new NullCommand());
          map.eSetDeliver(true);
        }
      }
           
            project.getElementsInternal().clear();
          // Map commands could have put another command on the project stack so
View Full Code Here

        final int[] expectedLayers=new int[1];
        expectedLayers[0]=1;

        WaitCondition c=new WaitCondition(){
      public boolean isTrue() {
        Map map = ApplicationGISInternal.getActiveMap();
        if( map==null )
          return false;
        List<ILayer> layers = map.getMapLayers();
        if (layers.size()<expectedLayers[0])
          return false;
        return true;
      }
    };

    UDIGTestUtil.inDisplayThreadWait(15000,c, true);
   
    IMap map = ApplicationGIS.getActiveMap();
    assertNotNull(map);
   
    List<ILayer> layers = map.getMapLayers();
    assertFalse(layers.isEmpty());
   
    List<String> typeNames=Arrays.asList(new String[]{"streams"})//$NON-NLS-1$
   
    for (ILayer layer : layers) {
      assertLayerType(layer,typeNames, ShapefileDataStore.class);
    }
       

        MapEditorPart activeEditor = ApplicationGISInternal.getActiveEditor();
        UDIGDropHandler dropHandler = activeEditor.getDropHandler();
        dropHandler.setTarget(activeEditor);
        dropHandler.setViewerLocation(ViewerDropLocation.NONE);
        dropHandler.performDrop(data, null);

        expectedLayers[0]=2;
       
        UDIGTestUtil.inDisplayThreadWait(4000,c, true);
   
        map = ApplicationGIS.getActiveMap();
        assertNotNull(map);
       
        layers = map.getMapLayers();
        assertEquals(2,layers.size());
       
        for (ILayer layer : layers) {
            assertLayerType(layer, typeNames, ShapefileDataStore.class);
        }
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.