Package org.locationtech.udig.project.internal

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


  }
 
    @Ignore
    @Test
  public void testMultiLayerRenderer() throws Exception {
    Map map = ProjectFactory.eINSTANCE.createMap();
       
    Layer layer = MapTests.createLayer(map, MapGraphicService.class,
        "file:/localhost/mapgraphic",//$NON-NLS-1$
    "file:/localhost/mapgraphic#Scalebar", //$NON-NLS-1$
    "layer1");//$NON-NLS-1$
View Full Code Here


     *
     * @return a page
     */
    protected Page makePage(Rectangle pageSize, Document doc, Template template) {
       
        Map mapOnlyRasterLayers = null;
        Map mapNoRasterLayers = null;
       
        // **Note: the iText API doesn't render rasters at a high enough resolution if
        //they are written to the PDF via graphics2d.  To work around this problem, I
        //create two copies of the map: one with only the raster layers, and one with
        //everything else.
        //The "everything else" map gets drawn by a graphics2d.  The other layer must be
        //rasterized and inserted into the PDF via iText's API. 
       
        //make one copy of the map with no raster layers
        mapNoRasterLayers = (Map) ApplicationGIS.copyMap(map);
        List<Layer> layersNoRasters = mapNoRasterLayers.getLayersInternal();
        List<Layer> toRemove = new ArrayList<Layer>();
        for (Layer layer : layersNoRasters ) {
            for (IGeoResource resource : layer.getGeoResources()) {
                if (resource.canResolve(GridCoverageReader.class)) {
                    toRemove.add(layer);
                }
            }
        }
        layersNoRasters.removeAll(toRemove);            
       
       
        //adjust scale       
        double currentViewportScaleDenom = map.getViewportModel().getScaleDenominator();
        if (currentViewportScaleDenom == -1)
            throw new IllegalStateException("no scale denominator is available from the viewport model"); //$NON-NLS-1$
       
        if (page1.getScaleOption() == PrintWizardPage1.CUSTOM_MAP_SCALE) {
            float customScale = page1.getCustomScale();
            template.setMapScaleHint(customScale);
        }
        else if (page1.getScaleOption() == PrintWizardPage1.CURRENT_MAP_SCALE) {
           template.setMapScaleHint(currentViewportScaleDenom);           
        }
        else if (page1.getScaleOption() == PrintWizardPage1.ZOOM_TO_SELECTION) {
            template.setZoomToSelectionHint(true);
            template.setMapScaleHint(currentViewportScaleDenom);
       
       
        //3. make the page itself
        Page page = ModelFactory.eINSTANCE.createPage();
        page.setSize(new Dimension((int)pageSize.getWidth(), (int)pageSize.getHeight()));

        //page name stuff not required, because this page will just get discarded
        MessageFormat formatter = new MessageFormat(Messages.CreatePageAction_newPageName, Locale.getDefault());
        if (page.getName() == null || page.getName().length() == 0) {
            page.setName(formatter.format(new Object[] { mapNoRasterLayers.getName() }));
        }

        template.init(page, mapNoRasterLayers);
       
        if (page1.getRasterEnabled()) {
            //make another copy with only raster layers
            mapOnlyRasterLayers = (Map) ApplicationGIS.copyMap(map);
            List<Layer> layersOnlyRasters = mapOnlyRasterLayers.getLayersInternal();
            List<Layer> toRemove2 = new ArrayList<Layer>();
            for (Layer layer : layersOnlyRasters ) {
                for (IGeoResource resource : layer.getGeoResources()) {
                    if (!resource.canResolve(GridCoverageReader.class)) {
                        toRemove2.add(layer);
                    }
                }
            }
            layersOnlyRasters.removeAll(toRemove2);
           
            //set bounds to match the other map
            SetViewportBBoxCommand cmdBbox = new SetViewportBBoxCommand(mapNoRasterLayers.getViewportModel().getBounds());
            mapOnlyRasterLayers.sendCommandSync(cmdBbox);
           
            if (layersNoRasters.size() > 0) {
                writeRasterLayersOnlyToDocument(mapOnlyRasterLayers, template.getMapBounds(), doc, page.getSize(), /*currentViewportScaleDenom*/mapNoRasterLayers.getViewportModel().getScaleDenominator());
            }
        }
       
        //copy the boxes from the template into the page
        Iterator<Box> iter = template.iterator();       
View Full Code Here

            @SuppressWarnings("unchecked")
            @Override
            protected IStatus run(IProgressMonitor monitor) {
                if (parent instanceof Map) {
                    Map map = (Map) parent;
                    boolean found = false;
                    SynchronizedEList adapters = (SynchronizedEList) map.getContextModel()
                            .eAdapters();
                    adapters.lock();
                    try {
                        for (Iterator<Adapter> iter = adapters.iterator(); iter.hasNext();) {
                            Adapter next = iter.next();
View Full Code Here

        throw new IllegalArgumentException("Object must be a Map.  Was: " + object); //$NON-NLS-1$
    }

    @Override
    public Object getChild(Object object, int childIndex) {
        Map map = (Map) object;
        if (childIndex >= map.getMapLayers().size())
            return null;
        return map.getMapLayers().get(childIndex);
    }
View Full Code Here

     * -->
     *
     * @generated NOT
     */
    public String getText(Object object) {
        Map map = ((Map) object);
        String label = map.getName();
        if (label == null) {
            Resource resource = map.eResource();
            if (resource != null) {
                String toString = resource.toString();
                int lastSlash = toString.lastIndexOf(File.pathSeparator);
                if (lastSlash == -1)
                    lastSlash = 0;
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));
        ValidateLineNoSelfOverlapping isValidLine = new ValidateLineNoSelfOverlapping();
        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

        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));   
        //FeatureFactory ff = new FeatureFactory();
       
        IGeoResource resource = MapTests.createGeoResource(features, true);
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500,512));
        ValidateNullZero isValidAttr = new ValidateNullZero();

        // test the dialog
        Dialog dialog = isValidAttr.getDialog(Display.getDefault().getActiveShell(), ((ILayer) map.getLayersInternal().get(0)).getSchema());
        dialog.setBlockOnOpen(false);
        dialog.open();
        // check the default xPath
        assertEquals(isValidAttr.xPath,"geom"); // first entry in attributes //$NON-NLS-1$
        //set a new xPath
View Full Code Here

                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }

                Map map = new CurrentMapFinder().getCurrentMap();
                boolean mapExists = (map != null); // this is used later, and I don't understand
                                                    // what for!
                if (map == null || newMap) {
                    map = getMap(monitor, target, newMap);
                }
               
                if( map.getBlackboard().get(ProjectBlackboardConstants.MAP__BACKGROUND_COLOR)==null ){
                    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 ));
                }

                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }

                LayerFactory factory = map.getLayerFactory();
                if (factory == null) {
                    factory = ProjectFactory.eINSTANCE.createLayerFactory();
                }

                if (monitor.isCanceled()) {
                    return Status.CANCEL_STATUS;
                }

                for( IGeoResource resource : geoResources ) {
                    monitor.beginTask(Messages.MapFactory_retrieveTask, geoResources.size());
                    if (monitor.isCanceled()) {
                        return Status.CANCEL_STATUS;
                    }

                    try {
                        IService service = resource.service(monitor);
                        CatalogPlugin.getDefault().getLocalCatalog().add(service);

                        Layer layer = factory.createLayer(resource);
                        if (layer != null) {
                            layers.add(layer);
                        }
                    } catch (IOException e) {
                        exceptions.add(e);
                        ProjectUIPlugin.log(null, e);
                    }
                    monitor.worked(1);
                }
                if( !layers.isEmpty() )
                map.getLayersInternal().addAll(layers);
                if (map.getLayersInternal().size() > 0 || newMap == true) {
                    ProjectExplorer.getProjectExplorer().open(map);
                } else if (!mapExists) {
                    // this is very ambigious? what is going on here?
                    map.getProjectInternal().getElementsInternal().remove(map);
                }

                if (exceptions.size() != 0) {
                    String message = null;
                    if (exceptions.size() > 1) {
View Full Code Here

        return build;
    }

    public Map getMap( IProgressMonitor monitor, Project project2, boolean createMap ) {

        Map map = null;
        if (!createMap) {
            map = new CurrentMapFinder().getCurrentMap();
        }
        if (map != null) {
            return map;
        }
        Project project=project2;
        if (project == null) {
            project = ProjectPlugin.getPlugin().getProjectRegistry().getCurrentProject();
        }
        if (project == null) {
            project = ProjectPlugin.getPlugin().getProjectRegistry().getDefaultProject();
        }

        String mapName = getNewMapName(project);

        Map newmap = ProjectFactory.eINSTANCE.createMap(project, mapName, new ArrayList<Layer>());

        return newmap;

    }
View Full Code Here

           
            Object selection = firstSelectedElement();

            if (contents != null) {
                MapEditorPart activeEditor = ApplicationGISInternal.getActiveEditor();
                final Map finalMap;
                final UDIGDropHandler finalDropHandler;
                if( selection instanceof Map){
                    finalMap = (Map)selection;
                    finalDropHandler = new UDIGDropHandler();
                    activeEditor=null;
                } else if( activeEditor==null ){
                    CreateMapCommand command = new CreateMapCommand(null,Collections.<IGeoResource>emptyList(), null);
                    try {
                        command.run(new NullProgressMonitor());
                    } catch (Exception e) {
                        throw (RuntimeException) new RuntimeException( ).initCause( e );
                    }
                    finalMap = (Map) command.getCreatedMap();
                    finalDropHandler = new UDIGDropHandler();
                } else {
                    finalDropHandler = activeEditor.getDropHandler();
                    finalMap = activeEditor.getMap();
                }
               
                final MapEditorPart finalActiveEditor = activeEditor;
                ILayer selectedLayer = finalMap.getEditManager().getSelectedLayer();
                if( selectedLayer==null ){
                    finalDropHandler.setTarget(finalMap);
                }else{
                    finalDropHandler.setTarget(selectedLayer);
                }
                finalDropHandler.addListener(new IDropHandlerListener(){

                    public void done( IDropAction action, Throwable error ) {

                        if( finalActiveEditor==null && finalMap.getMapLayers().size()==0 ){
                            finalMap.getProjectInternal().getElementsInternal().remove(finalMap);
                        }
                       
                        finalDropHandler.removeListener(this);
                    }

                    public void noAction( Object data ) {
                        if( finalActiveEditor==null && finalMap.getMapLayers().size()==0 ){
                            finalMap.getProjectInternal().getElementsInternal().remove(finalMap);
                        }
                        finalDropHandler.removeListener(this);
                    }

                    public void starting( IDropAction action ) {
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.