Package org.locationtech.udig.project.internal.render.impl

Examples of org.locationtech.udig.project.internal.render.impl.ViewportModelImpl


            }
            else {
                // end of the world!
                updateAOIService(null, null);
                bounds = getMap().getBounds(null);
                ViewportModelImpl vmi = (ViewportModelImpl) getMap().getViewportModel();
                vmi.zoomToBox(bounds);
                return;
            }
        }
        else if (isNavigate && (mouseEvent.button == MapMouseEvent.BUTTON1)) {
            selectedLayer = nextLayer != null ? nextLayer : activeLayer;
            if( activeLayer != null ){
                // please stay on the active layer until you have a geometry
                if( geometry == null || !geometry.contains( testLocation)){
                    // we need a selected geometry before we let people navigate away
                    selectedLayer = activeLayer;
                }
            }
        }
       
        if( selectedLayer == null){
            return; // nothing to do!
        }
        if (!selectedLayer.getInteraction(Interaction.AOI)){
            return; // eek!
        }
        // use the bbox to see if we hit anything!
        SimpleFeatureCollection featureCollection = getFeaturesInBbox(selectedLayer, bbox, monitor);
       
        if (featureCollection.isEmpty()) {
            // the user did not click on anything useful (so sad)!
            // see if they were trying to click around on the active layer instead!
            if( selectedLayer == activeLayer){
                return; // give up no change to AOI stuffs
            }
            else {
                // quickly test to see if they clicked on a neighbour
                SimpleFeatureCollection testCollection = getFeaturesInBbox(activeLayer, bbox, monitor);
                if(!testCollection.isEmpty() ){
                    // okay let us go to neighbour
                    selectedLayer = activeLayer;
                    featureCollection = testCollection;
                }
                else {
                    return; // user really did not find anything to click on
                }
            }
        }       
        bounds = featureCollection.getBounds();
        Geometry newAOI = unionGeometry(featureCollection);
       
        updateAOIService(selectedLayer,newAOI );

        if (isNavigate) {
            IMap map = selectedLayer.getMap();
            ViewportModelImpl vmi = (ViewportModelImpl) map.getViewportModel();
            vmi.zoomToBox(bounds);
        }
    }
View Full Code Here


        trackingGull.setLocationListener(new Seagull.SeagullLocationListener(){
            public void gullMoved( final Coordinate newLoc ) {
                Display.getDefault().asyncExec(new Runnable(){

                    private void scroll(int newx, int newy, int startx, int starty){
                        ViewportModelImpl vm =  (ViewportModelImpl)map.getViewportModel();
                        final ViewportPaneTiledSWT viewera = (ViewportPaneTiledSWT)viewer;
                       
                        org.eclipse.swt.graphics.Point p = Display.getCurrent().map((Canvas)viewera, null, newx, newy);
                        org.eclipse.swt.graphics.Point p2 = Display.getCurrent().map((Canvas)viewera, null, startx, starty);
                        int xdiff = p2.x - p.x;
                        int ydiff = p2.y - p.y;
                        ((Canvas)viewera).scroll(xdiff, ydiff, 0,0, map.getRenderManager().getMapDisplay().getWidth(), map.getRenderManager().getMapDisplay().getHeight(), true);
                       
                    }
                    public void run() {
                        ViewportModelImpl vm =  (ViewportModelImpl)map.getViewportModel();
                        final ViewportPaneTiledSWT viewera = (ViewportPaneTiledSWT)viewer;
                        final ReferencedEnvelope bounds = vm.getBounds();
                        Coordinate currentc = vm.getCenter();
                     
                        final Point newpnt = vm.worldToPixel(newLoc);
                        final Point oldpnt = vm.worldToPixel(currentc);
                       
                        vm.setIsBoundsChanging(true);
                       
                        int xoffset =  oldpnt.x - newpnt.x;
                        int yoffset = oldpnt.y - newpnt.y;
                       
                        int diffx = 0;
                        int diffy = 0;
                       
                        int xdiff = (int)(xoffset / 10.0);
                        int ydiff = (int)(yoffset / 10.0);
                        if (xdiff == 0){
                            if (xoffset > 0){
                                xdiff = 1;
                            }else{
                                xdiff = -1;
                            }
                        }
                        if (ydiff == 0){
                            if (yoffset > 0){
                                ydiff = 1;
                            }else{
                                ydiff = -1;
                            }
                        }
                        int lastx = oldpnt.x;
                        int lasty = oldpnt.y;
                       
                        while(Math.abs(diffx) < Math.abs(xoffset|| Math.abs(diffy) < Math.abs(yoffset) ){
                            if (Math.abs(diffx) < Math.abs(xoffset))
                                diffx += xdiff;
                            if (Math.abs(diffy) < Math.abs(yoffset))
                                diffy += ydiff;
                           
                            scroll(lastx - xdiff, lasty-ydiff, lastx,lasty  );
                            lastx -= xdiff;
                            lasty -= ydiff;    
                        }
                        lastx -= xdiff;
                        lasty -=ydiff;
                        Coordinate newCoo = vm.pixelToWorld(lastx, lasty);
                        vm.setIsBoundsChanging(false);
                        vm.setCenter(newCoo);
                    }});
               
//                SetViewportCenterCommand cmd = new SetViewportCenterCommand(newLoc);
//                map.sendCommandASync(cmd);
            }
View Full Code Here

        features=UDIGTestUtil.createTestFeatures("DifferenceFeatureTests", new Geometry[]{line, poly}, new String[]{"line", "poly"});   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        map = MapTests.createNonDynamicMapAndRenderer(MapTests.createGeoResource(features, true), new Dimension(500,500));
       
        Envelope env=map.getBounds(null);
        map.getRenderManagerInternal().setMapDisplay(new TestViewportPane(new Dimension((int)env.getWidth(),(int)env.getHeight())));
        map.setViewportModelInternal(new ViewportModelImpl(){
           @Override
        public AffineTransform worldToScreenTransform() {
            return new AffineTransform();
        }
        });
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.internal.render.impl.ViewportModelImpl

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.