Package org.locationtech.udig.project.internal

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


    public void run( IProgressMonitor monitor ) throws Exception {
        Map map = getMap();
        if (layers == null) {
            layers = new ArrayList<Layer>();
            LayerFactory layerFactory = map.getLayerFactory();

            selection = (Layer) map.getEditManager().getSelectedLayer();

            for( Object o : resources ) {
                try {
                    Layer layer = null;
   
                    if (o instanceof IGeoResource) {
                        // ensure that the service is part of the Catalog so that the find method in
                        // layer turn into layer
                        IGeoResource resource = (IGeoResource) o;
                        layer = layerFactory.createLayer(resource);
                    }
                    if (o instanceof Layer) {
                        // leave as is
                        layer = (Layer) o;
                    }
View Full Code Here


  private static Layer createWhitebox(Map map, Rectangle location) {
      try {

          ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();

            LayerFactory layerFactory = map.getLayerFactory();
            URL resourceID = new URL(null, "mapgraphic://localhost/mapgraphic#org.locationtech.udig.tutorial.mapgraphic.Whitebox", CorePlugin.RELAXED_HANDLER); //$NON-NLS-1$
            ID id = new ID(resourceID);
            IGeoResource resource = localCatalog.getById(IGeoResource.class, id, new NullProgressMonitor());
            Layer whiteboxLayer = layerFactory.createLayer(resource);
           
            whiteboxLayer.getStyleBlackboard().put(LocationStyleContent.ID, location);
            return whiteboxLayer;
      }
      catch (Exception e) {
View Full Code Here

    protected static Layer createTitleArea(Map map, Rectangle location, IProgressMonitor monitor) {
        try {

            ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
            List<Layer> layersInternal = map.getLayersInternal();
            LayerFactory layerFactory = map.getLayerFactory();
           
            Iterator layerIterator = layersInternal.iterator();
            Layer farmParcelLayer = null;
            while (layerIterator.hasNext()) {
                Layer layer = (Layer)layerIterator.next();
                if (layer.getName().equals("SDE.DATE_PRIMARE")) {
                    farmParcelLayer = layer;
                }
            }
           
            if (farmParcelLayer == null) {
                throw new IllegalStateException("cannot find farm layer");
            }
           

            //get title from selected feature of farm layer           
            Filter farmParcelFilter = farmParcelLayer.getFilter();
            Query query = new DefaultQuery(farmParcelLayer.getSchema().getTypeName(),
                                           farmParcelFilter,
                                           new String[0]  ); //{"nume_com", "fbid"}
           
             FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
                farmParcelLayer.getResource(FeatureSource.class,
                                            new SubProgressMonitor(monitor, 1));
            FeatureCollection<SimpleFeatureType, SimpleFeature>  features = featureSource.getFeatures(query);
            FeatureIterator<SimpleFeature> featureIterator = features.features();
            if (!featureIterator.hasNext()) {
                throw new IllegalStateException("At least one feature must be selected in the farm layer. "+features.size()+ " found.");
            }
            SimpleFeature selectedFarmFeature = featureIterator.next();
            String prov = (String)selectedFarmFeature.getAttribute(0);
            String id = (String)selectedFarmFeature.getAttribute(1);
           
            //put layer info on the mapgraphic's style blackboard
            URL detailsResId = new URL(null, "mapgraphic://localhost/mapgraphic#org.locationtech.udig.tutorial.mapgraphic.TitleArea", CorePlugin.RELAXED_HANDLER);
            IGeoResource detailsRes = localCatalog.getById(IGeoResource.class, new ID(detailsResId), new NullProgressMonitor());
            
            Layer titleAreaLayer = layerFactory.createLayer(detailsRes);
            titleAreaLayer.getStyleBlackboard().put(LocationStyleContent.ID, location);
            XMLMemento selectedFeatureMemento = XMLMemento.createWriteRoot("style");
            selectedFeatureMemento.putString(FEATURE_ID_KEY, id);
            titleAreaLayer.getStyleBlackboard().put(DialogSettingsStyleContent.EXTENSION_ID, selectedFeatureMemento);
            return titleAreaLayer;
View Full Code Here

        List< ? extends IGeoResource> resources = service.resources(null);
       
        IGeoResource resource = resources.get(0);
       
        Map map = ((Map)layers[0].getMap());
        LayerFactory factory = map.getLayerFactory();
        Layer outLayer = factory.createLayer(resource);
        map.getLayersInternal().add(outLayer);
    }
View Full Code Here

      }

      private Collection<Layer> toLayers(Layer found,
          Collection<IGeoResource> exported) {
        LayerFactory layerFactory = MapSaveStrategy.this.editor
            .getMap().getLayerFactory();
        Collection<Layer> newLayers = new ArrayList<Layer>();

        for (IGeoResource exportedResource : exported) {
          try {
            Layer createLayer = layerFactory
                .createLayer(exportedResource);
            StyleBlackboard clone = (StyleBlackboard) found
                .getStyleBlackboard().clone();
            createLayer.setStyleBlackboard(clone);
            newLayers.add(createLayer);
View Full Code Here

      }

      private Collection<Layer> toLayers(Layer found,
          Collection<IGeoResource> exported) {
        LayerFactory layerFactory = MapPaletteSaveStrategy.this.editor
            .getMap().getLayerFactory();
        Collection<Layer> newLayers = new ArrayList<Layer>();

        for (IGeoResource exportedResource : exported) {
          try {
            Layer createLayer = layerFactory
                .createLayer(exportedResource);
            StyleBlackboard clone = (StyleBlackboard) found
                .getStyleBlackboard().clone();
            createLayer.setStyleBlackboard(clone);
            newLayers.add(createLayer);
View Full Code Here

     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetLayerFactory(LayerFactory newLayerFactory,
            NotificationChain msgs) {
        LayerFactory oldLayerFactory = layerFactory;
        layerFactory = newLayerFactory;
        if (eNotificationRequired()) {
            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
                    ProjectPackage.MAP__LAYER_FACTORY, oldLayerFactory, newLayerFactory);
            if (msgs == null)
View Full Code Here

            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case ProjectPackage.LAYER_FACTORY: {
            LayerFactory layerFactory = (LayerFactory) theEObject;
            T result = caseLayerFactory(layerFactory);
            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
View Full Code Here

        IPreferenceStore store = ProjectPlugin.getPlugin().getPreferenceStore();
        RGB background = PreferenceConverter.getColor(store, PreferenceConstants.P_BACKGROUND);
        map.getBlackboard().put(ProjectBlackboardConstants.MAP__BACKGROUND_COLOR, new Color(background.red, background.green, background.blue ));
       
        LayerFactory layerFactory = map.getLayerFactory();
        List<Layer> toAdd=new ArrayList<Layer>(resources.size());
        for( IGeoResource resource : resources ) {
            Layer layer = layerFactory.createLayer(resource);
            toAdd.add(layer);
        }

        map.getLayersInternal().addAll(toAdd);
       
View Full Code Here

            return;
        }

        IMap map = ApplicationGIS.getActiveMap();

        LayerFactory layerFactory = map.getLayerFactory();
        for( IGeoResource resource : resources ) {
            if (resource instanceof JGrassMapGeoResource) {
                JGrassMapGeoResource grassMGR = (JGrassMapGeoResource) resource;
                File locationFile = grassMGR.getLocationFile();
                File mapsetFile = grassMGR.getMapsetFile();
                File mapFile = grassMGR.getMapFile();
                IGeoResource addedMapToCatalog = JGrassCatalogUtilities.addMapToCatalog(locationFile.getAbsolutePath(),
                        mapsetFile.getName(), mapFile.getName(), JGrassConstants.GRASSBINARYRASTERMAP);
                int index = map.getMapLayers().size();
                ApplicationGIS.addLayersToMap(map, Arrays.asList(addedMapToCatalog), index);
            } else {
                Layer layer = layerFactory.createLayer(resource);
                AddLayerCommand cmd = new AddLayerCommand(layer);
                map.sendCommandASync(cmd);
            }
        }
    }
View Full Code Here

TOP

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

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.