Package org.locationtech.udig.project.internal

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


    public AbstractToggleMapGraphicAction() {
    }

    @Override
    public void run( IAction action ) {
        Map map = ApplicationGISInternal.getActiveMap();
        if (map == ApplicationGIS.NO_MAP)
            return;
        List<ILayer> layers = map.getMapLayers();
        for( ILayer layer : layers ) {
            if (layer.hasResource(getMapGraphicClass())) {
                removeLegend();
                return;
            }
View Full Code Here


        // map does not contain legend so add it.
        addLegend();
    }

    private void removeLegend() {
        Map map = ApplicationGISInternal.getActiveMap();
        if (map == ApplicationGIS.NO_MAP)
            return;

        List<ILayer> layers = map.getMapLayers();
        List<ILayer> toRemove = new ArrayList<ILayer>();

        for( ILayer layer : layers ) {
            if (layer.hasResource(getMapGraphicClass())) {
                toRemove.add(layer);
            }
        }

        UndoableComposite composite = new UndoableComposite();
        for( ILayer layer : toRemove ) {
            composite.getCommands().add( new DeleteLayerCommand((Layer)layer) );
        }

        map.sendCommandASync(composite);
    }
View Full Code Here

        SimpleFeature[] features = UDIGTestUtil.createDefaultTestFeatures("someType", 5); //$NON-NLS-1$
        Geometry geometry = (Geometry) features[0].getDefaultGeometry();
    geometry.getCoordinates()[0].x = 2;
        //features[0].setDefaultGeometry(null);
        IGeoResource resource = MapTests.createGeoResource(features, true);
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500,512));
        ValidateGeometry isValidGeometry = new ValidateGeometry();
        isValidGeometry.op(Display.getDefault(), map.getLayersInternal().get(0), new NullProgressMonitor());
        assertEquals(1,isValidGeometry.results.failedFeatures.size());
        map.sendCommandSync(new AbstractCommand(){

            public void run( IProgressMonitor monitor ) throws Exception {
            }

            public String getName() {
                return null;
            }
           
        });//send a sync command so async doesn't give us a false junit failure
       
        //System.out.println("\n"+map.getLayersInternal().get(0).getFilter().getClass());
        Id filter = (Id) map.getLayersInternal().get(0).getFilter();
        String[] fids = filter.getIDs().toArray(new String[0]);
        assertEquals(1,fids[0].length());
        assertEquals(features[0].getID(),fids[0]);
    }
View Full Code Here

        map.sendCommandASync(composite);
    }

    private void addLegend() {
        Map map = ApplicationGISInternal.getActiveMap();
        try {
            IGeoResource legendResource = null;

            URL url = new URL(MapGraphicService.SERVICE_URL, "#" + getExtensionID()); //$NON-NLS-1$
            List<IGeoResource> matches = CatalogPlugin.getDefault().getLocalCatalog().find(IGeoResource.class,
                url, ProgressManager.instance().get());
            if (!matches.isEmpty())
                legendResource = matches.get(0);

            if (legendResource == null) {
                List<IService> results = CatalogPlugin.getDefault().getServiceFactory()
                        .createService(url);
                for( IGeoResource resource : results.get(0).resources(new NullProgressMonitor()) ) {
                    if (resource.getIdentifier().getRef().equals(url.getRef())) {
                        legendResource = resource;
                        break;
                    }
                }
            }
            if (legendResource == null)
                return;
            Layer layer = map.getLayerFactory().createLayer(legendResource);
            map.sendCommandSync(BasicCommandFactory.getInstance().createAddLayer(layer));
        } catch (MalformedURLException e) {
            MapGraphicPlugin.log("", e); //$NON-NLS-1$
        } catch (IOException e) {
            MapGraphicPlugin.log("", e); //$NON-NLS-1$
        }
View Full Code Here

        // add lines
        features[0]=SimpleFeatureBuilder.build(ft,new Object[]{line[0], attrValues[0]}, Integer.toString(0));   
        features[1]=SimpleFeatureBuilder.build(ft,new Object[]{line[1], attrValues[1]}, Integer.toString(1));   
       
        IGeoResource resource = MapTests.createGeoResource(features, true);
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500,512));
        ValidateLineMustBeASinglePart isValidLine = new ValidateLineMustBeASinglePart();
        isValidLine.op(Display.getDefault(), map.getLayersInternal().get(0), new NullProgressMonitor());
        //System.out.println(isValidLine.genericResults.failedFeatures.size()+" failed feature");
        assertEquals(1,isValidLine.results.failedFeatures.size());
        map.sendCommandSync(new AbstractCommand(){

            public void run( IProgressMonitor monitor ) throws Exception {
            }

            public String getName() {
                return null;
            }
           
        });//send a sync command so async doesn't give us a false junit failure
       
        Id filter = (Id) map.getLayersInternal().get(0).getFilter();
        String[] fids = filter.getIDs().toArray(new String[0]);
        //System.out.println(fids[0].length()+" features in FID");
        assertEquals(1,fids[0].length()); //only 1 feature failed?
        assertEquals(features[1].getID(),fids[0]); //feature 1 failed?
    }
View Full Code Here

        // add lines
        features[0]=SimpleFeatureBuilder.build(ft,new Object[]{line[0], attrValues[0]}, Integer.toString(0));   
        features[1]=SimpleFeatureBuilder.build(ft,new Object[]{line[1], attrValues[1]}, Integer.toString(1));   
       
        IGeoResource resource = MapTests.createGeoResource(features, true);
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500,512));
        ValidateLineNoSelfIntersect isValidLine = new ValidateLineNoSelfIntersect();
        isValidLine.op(Display.getDefault(), map.getLayersInternal().get(0), new NullProgressMonitor());
        //System.out.println(isValidLine.genericResults.failedFeatures.size()+" failed feature");
        assertEquals(1,isValidLine.results.failedFeatures.size());
        map.sendCommandSync(new AbstractCommand(){

            public void run( IProgressMonitor monitor ) throws Exception {
            }

            public String getName() {
                return null;
            }
           
        });//send a sync command so async doesn't give us a false junit failure
       
        Id filter = (Id) map.getLayersInternal().get(0).getFilter();
        String[] fids = filter.getIDs().toArray(new String[0]);
        //System.out.println(fids[0].length()+" features in FID");
        assertEquals(1,fids[0].length()); //only 1 feature failed?
        assertEquals(features[1].getID(),fids[0]); //feature 1 failed?
    }
View Full Code Here

    /**
     * @see org.locationtech.udig.project.internal.LayerDecorator#getZorder()
     */
    @Override
    public int getZorder() {
        Map mapInternal = getMapInternal();
        if( mapInternal==null )
            return Integer.MAX_VALUE;
        return super.getZorder() + mapInternal.getLayersInternal().size();
    }
View Full Code Here

     */
    public GlassPane(ViewportPane parent){
        this.parent = parent;

        // create a new site
        Map map = parent.getMapEditor().getMap();
        RenderManager manager = map.getRenderManagerInternal();
        site = new GlassPaneSite(manager, map);
    }
View Full Code Here

     */
    public static IMap drawMap(final DrawMapParameter drawMapParams) throws RenderException {
        final DrawMapParameter params = new DrawMapParameter( drawMapParams );
        IProgressMonitor monitor = params.monitor;
       
        final Map map = (Map) EcoreUtil.copy((EObject) params.toDraw);
       
        map.getBlackboard().addAll(drawMapParams.toDraw.getBlackboard());
       
        for (int i = 0; i < map.getMapLayers().size(); i++) {
            ILayer source = params.toDraw.getMapLayers().get(i);
            Layer dest = map.getLayersInternal().get(i);
            dest.setFilter(source.getFilter());
            dest.getBlackboard().addAll(source.getBlackboard());
        }
       
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                // Load IGeoResources using original map. The new map can't do this because it doesn't have a
                // Resource(file) and therefore can't resolve relative URIs
                List<ILayer> layers = drawMapParams.toDraw.getMapLayers();
                for (ILayer layer : layers) {
                    layer.getGeoResources();
                }
               
                Color background = (Color) map.getBlackboard().get(ProjectBlackboardConstants.MAP__BACKGROUND_COLOR);
                params.graphics.setBackground(background);
                if (!drawMapParams.transparent) {
                    params.graphics.clearRect(0, 0, params.destinationSize.width, params.destinationSize.height);
                }
                List<Layer> layersToRender = params.selectionStyle.handleSelection(map.getLayersInternal());
               
                ProjectUIPlugin
                        .trace(
                                ApplicationGIS.class,
                                "ApplicationGIS.drawMap() beginning rendering of map '" + map.getName() + "'", null); //$NON-NLS-1$ //$NON-NLS-2$

                ReferencedEnvelope bounds = (ReferencedEnvelope) params.toDraw.getViewportModel().getBounds();
                ReferencedEnvelope boundsCopy = new ReferencedEnvelope(bounds);
                RenderContext tools = configureMapForRendering(map, params.destinationSize, params.dpi, params.boundsStrategy, boundsCopy);
               
View Full Code Here

        List<ILayer> layers = mapToCopy.getMapLayers();
        for (ILayer layer : layers) {
            layer.getGeoResources();
        }

        final Map copy = (Map) EcoreUtil.copy((EObject) mapToCopy);
        copy.getBlackboard().addAll(mapToCopy.getBlackboard());
        for (int i = 0; i < copy.getMapLayers().size(); i++) {
            ILayer source = mapToCopy.getMapLayers().get(i);
            Layer dest = copy.getLayersInternal().get(i);
            dest.setFilter(source.getFilter());
            dest.getBlackboard().addAll(source.getBlackboard());
           
            dest.setStyleBlackboard((StyleBlackboard)dest.getStyleBlackboard().clone());
           
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.