Package org.locationtech.udig.project.internal

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


    /**
     * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
     */
    protected void setInput( IEditorInput input ) {
        if (getEditorInput() != null) {
            Map map = (Map) ((UDIGEditorInput) getEditorInput()).getProjectElement();
            if (viewer != null) {
                viewer.setMap(null);
            }
            map.removeMapCompositionListener(mapCompositionListener);
            map.removeMapListener(mapListener);
            map.getEditManager().removeListener(editListener);
        }
        super.setInput(input);
        if (input != null) {
            if (viewer != null) {
                viewer.setMap((Map) ((UDIGEditorInput) input).getProjectElement());
View Full Code Here


            viewer = new MapViewer(composite, SWT.MULTI | SWT.NO_BACKGROUND);
        }
        // allow the viewer to open our context menu; work with our selection proivder etc
        viewer.init(this);
        // if a map was provided as input we can ask the viewer to use it
        Map input = (Map) ((UDIGEditorInput) getEditorInput()).getProjectElement();
        if (input != null) {
            viewer.setMap(input);
        }

        FormData formdata = new FormData();
View Full Code Here

    /**
     * Creates a location box - which tracks the viewport of the main map
     * in the overview window.
     */
    public void createLocationBox(ViewportPane mainMapViewportPane){
        final Map overviewMap = this.mapviewer.getMap();
        rectDrawCommand = new AbstractDrawCommand(){

            public Rectangle getValidArea() {
                return null;
            }

            public void run( IProgressMonitor monitor ) throws Exception {
                //draw a bounding box around the area that is associated
                //with the main map
                ReferencedEnvelope bounds = mainmap.getViewportModel().getBounds();
               
                double xmin = bounds.getMinX();
                double xmax = bounds.getMaxX();
                double ymin = bounds.getMinY();
                double ymax = bounds.getMaxY();
               
                 Point ll = overviewMap.getViewportModel().worldToPixel(new Coordinate(xmin, ymin));
                 Point ur = overviewMap.getViewportModel().worldToPixel(new Coordinate(xmax, ymax));
                
                
                 int width = ur.x - ll.x;
                 int height = ur.y - ll.y;
                 if (width < 2) width = 2;
View Full Code Here

    /**
     * Add a context listener that listens to when layers are added/removed
     * from the map.
     */
    private void addContextListener(){
        final Map overviewmap = this.mapviewer.getMap();
        contextListener = new ContextModelListenerAdapter(){
            protected void layerAdded( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void manyLayersAdded( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void layerRemoved( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void manyLayersRemoved( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void zorderChanged( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void glyphChanged( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void styleChanged( Notification msg ) {
                updateMapAndRefresh(msg);
            }

            protected void visibilityChanged( Notification msg ) {
                updateMapAndRefresh(msg);
            }
          
            private void updateMapAndRefresh(Notification msg){
                overviewmap.getContextModel().eNotify(msg);
                ReferencedEnvelope bnds = findNewOverviewZoom(mainmap.getViewportModel().getBounds(), mainmap.getRenderManager().getMapDisplay(), mapviewer.getMap().getViewportModel().getBounds());
                mapviewer.getMap().getViewportModelInternal().setBounds(bnds);               
            }
        };
        mainmap.getContextModel().eAdapters().add(contextListener);
       
        //add a deep listener to listen to layer hide/show events
        Adapter layerVisibilityAdapter = new AdapterImpl(){
            @SuppressWarnings("unchecked")
            public void notifyChanged( final Notification msg ) {
                if (msg.getNotifier() instanceof Layer && msg.getFeatureID(Layer.class) == ProjectPackage.LAYER__VISIBLE) {
                    if (msg.getNewBooleanValue() != msg.getOldBooleanValue()){
                        // mapviewer needs refreshing
                        overviewmap.getRenderManager().refresh((Layer)msg.getNotifier(), null);
                    }
                }
            }
        };
        mainmap.addDeepAdapter(layerVisibilityAdapter);
View Full Code Here

    @Override
    public void createPartControl( Composite parent ) {
        parent.setLayout(new FormLayout());

        // create two maps
        final Map overviewmap = (Map) ProjectFactory.eINSTANCE.createMap();
        final Map mainmap = (Map) ProjectFactory.eINSTANCE.createMap();

        // create overview
        overviewmapviewer = new OverviewMapViewer(parent, SWT.MULTI | SWT.NO_BACKGROUND
                | SWT.BORDER, mainmap);
        int size = 25;
View Full Code Here

     * Test method for {@link org.locationtech.udig.render.internal.feature.basic.BasicFeatureRenderer#validateBounds(com.vividsolutions.jts.geom.Envelope, org.eclipse.core.runtime.IProgressMonitor, org.locationtech.udig.project.render.IRenderContext)}.
     */
    @Ignore
    @Test
    public void testValidateBounds() throws Exception {
        Map map = MapTests.createDefaultMap("BasicFeatureRenderer", 4, true, new Dimension(1024,1024)); //$NON-NLS-1$
        map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);
       
        createContext(map);
        context.getRenderManagerInternal().setMapDisplay(new TestMapDisplay(new Dimension( 1000, 200)));

        map.getViewportModelInternal().setBounds(0,100,0,90);
       
        CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
        Envelope result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope(0,50,0,10, crs), new NullProgressMonitor(), context);
       
        assertEquals( new Envelope( 0,50,0,10 ), result);
View Full Code Here

                linestring
        }
        , null, crs);
       
        IGeoResource resource = MapTests.createGeoResource(features, false );
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(1024,1024));
        map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);
       
        createContext(map);
       
        map.getViewportModelInternal().setBounds(-150,-120,45,65);
       
        Envelope result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( minx,maxx,miny,maxy,crs ), new NullProgressMonitor(), context);
        compareEnvelopes( new Envelope( minx,maxx,miny,maxy ), result);
       
        result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( minx,maxx,miny,maxy-5, crs), new NullProgressMonitor(), context);
        compareEnvelopes( new Envelope( minx,maxx,miny,maxy-5 ), result);

        result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( minx,maxx,miny-20,maxy+20, crs ), new NullProgressMonitor(), context);
        compareEnvelopes( new Envelope( minx,maxx,50,60 ), result);
       
        map.getViewportModelInternal().setBounds(minx-5,minx+5,miny-5,miny+5);

        result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( minx,maxx,miny,maxy,crs ), new NullProgressMonitor(), context);
        compareEnvelopes( new Envelope( minx,minx+5,miny,miny+5 ), result);
       
        map.getViewportModelInternal().setBounds(minx+2,minx+4,miny+2,miny+4);

        result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( minx,maxx,miny,maxy,crs ), new NullProgressMonitor(), context);
        compareEnvelopes( new Envelope( minx+2,minx+4,miny+2,miny+4 ), result);
       
        result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( 0,20,0,20,crs ), new NullProgressMonitor(), context);
View Full Code Here

        SimpleFeature[] features = UDIGTestUtil.createTestFeatures("testNoBounds_Viewport", new Geometry[]{ //$NON-NLS-1$
        }
        , null, DefaultGeographicCRS.WGS84);
       
        IGeoResource resource = MapTests.createGeoResource(features, false );
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(1024,1024));
        map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);
       
        createContext(map);
       
        map.getViewportModelInternal().setBounds(-150,-120,45,65);
        CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
       
        Envelope result = BasicFeatureRenderer.validateBounds(new ReferencedEnvelope( 0,20,0,20,crs ), new NullProgressMonitor(), context);
        assertTrue( result.isNull() );
    }
View Full Code Here

    private ILayer layer;
    private GeometryProperty prop;

    @Before
    public void setUp() throws Exception {
        Map map = MapTests.createDefaultMap("GeomPropertyTest", 2, true, null); //$NON-NLS-1$
        layer=map.getMapLayers().get(0);
        prop=new GeometryProperty();
    }
View Full Code Here

        features[1] = SimpleFeatureBuilder.build(ft,new Object[]{line[1], attrValues[1]}, Integer.toString(1));
        features[2] = SimpleFeatureBuilder.build(ft,new Object[]{line[2], attrValues[2]}, Integer.toString(2));
        features[3] = SimpleFeatureBuilder.build(ft,new Object[]{line[3], attrValues[3]}, Integer.toString(3));

        IGeoResource resource = MapTests.createGeoResource(features, true);
        Map map = MapTests.createNonDynamicMapAndRenderer(resource, new Dimension(500, 512));
        ValidateOverlaps validator = new ValidateOverlaps();
        validator.op(Display.getDefault(), map.getLayersInternal().get(0),
                new NullProgressMonitor());
        assertEquals(1, validator.genericResults.failedFeatures.size()); //only line[0] and line[1] should fail (counts as 1)
        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[0].getID(), fids[0]); //it was feature 0 that failed?
    }
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.