Package org.locationtech.udig.project.ui.render.displayAdapter

Examples of org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane


    public void perform( IProgressMonitor monitor ) {
        final String string=getData().toString();
       
        // Since I declared my target to be a ViewportPane then I know that is what the
        // destination is going to be.
        ViewportPane pane=(ViewportPane) getDestination();

        // In order to know where to draw the string we have to calculate where the
        // drop event has taken place with respect to the ViewportPane.
        // The Event returns the location but it is w.r.t the Display.
        // All SWT widgets have helper methods to determine this so:
        Control control=pane.getControl();
        final Point drawLocation = control.toControl(getEvent().x, getEvent().y);
       
        // By Adding a custom draw command we can draw on the viewport model...
        pane.addDrawCommand(new AbstractDrawCommand(){

            public Rectangle getValidArea() {
                // I'm being lazy and returning null so that this will be re-drawn every time the
                // Viewport is updated.
                return null;
View Full Code Here


                    + " support animation", new RuntimeException()); //$NON-NLS-1$
            return;
        }
       
        short frameInterval = calculateFrameInterval(animation);
        ViewportPane viewport=(ViewportPane) mapDisplay;
       
        // Try to get the map from animationInterval to the AnimationUpdater for that interval
        List<AnimationUpdater> tasks=displayToTaskMap.get(frameInterval);
        boolean requiresRun=false;
       
        if (tasks == null) {
            requiresRun=true;
            tasks = new CopyOnWriteArrayList<AnimationUpdater>();
            displayToTaskMap.put(frameInterval, tasks);
        }

        AnimationUpdater updater = findUpdater(frameInterval,  viewport);
        viewport.addDrawCommand(animation);

        if (updater != null) {
            updater.getAnimations().add(animation);
        } else {
            AnimationUpdater task = new AnimationUpdater((ViewportPane) viewport, frameInterval);
            task.getAnimations().add(animation);
            tasks.add(task);
            if( requiresRun ){
                runTimer(frameInterval, new RunUpdaters(frameInterval));
            }
        }
       
        Rectangle bounds = animation.getValidArea();
        if( bounds==null ){
            viewport.repaint();
        }else{
            viewport.repaint(bounds.x, bounds.y, bounds.width, bounds.height);
        }
    }
View Full Code Here

        final IMap map = (IMap) target;  //ApplicationGIS.getActiveMap();
        if (map == null)
            return;
       
       
        final ViewportPane viewer = (ViewportPane)map.getRenderManager().getMapDisplay();
       
        //create a flock of seagulls
        final Collection<Seagull> gulls = createSeagulls(map.getViewportModel().getCenter(), map.getViewportModel().getCRS());
       
        //create a glass pane that draws the seagulls
        addFlockGlassPane(viewer, gulls);
    
        //timer to update map
        int refreshrate = 250;

        //draws the map at given intervals
        Timer mapupdatetimer = new Timer();
        mapupdatetimer.scheduleAtFixedRate(new TimerTask(){

            @Override
            public void run() {
                viewer.repaint();
               
            }}, new Date(), refreshrate);
       

        //moves the seagulls at given intervals
View Full Code Here

        final IMap map = (IMap) target;  //ApplicationGIS.getActiveMap();
        if (map == null)
            return;

       
        final ViewportPane viewer = (ViewportPane)map.getRenderManager().getMapDisplay();
       
        //create a flock of seagulls
        final Collection<Seagull> gulls = createSeagulls(map.getViewportModel().getCenter(), map.getViewportModel().getCRS());
       
        Seagull trackingGull = gulls.iterator().next();
        trackingGull.setColor(SWT.COLOR_RED);
        trackingGull.moveSeagull(new Coordinate(0,0));
        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);
            }
        });
       
       
       
        //create a glass pane that draws the seagulls
        addFlockGlassPane(viewer, gulls);
    
        //timer to update map
        int refreshrate = 300;

        //draws the map at given intervals
        Timer mapupdatetimer = new Timer();
        mapupdatetimer.scheduleAtFixedRate(new TimerTask(){

            @Override
            public void run() {
                viewer.repaint();
               
            }}, new Date(), refreshrate);
       

        //moves the seagulls at given intervals
View Full Code Here

        // get the map
        IMap map = getContext().getMap();
        if (map == null)
            return;

        final ViewportPane viewer = (ViewportPane) map.getRenderManager().getMapDisplay();
        // creates seagulls
        gulls = createSeagulls(map.getViewportModel().getBounds(), map.getViewportModel().getCRS());
        // creates glass panel
        addFlockGlassPane(viewer, gulls);

        // timer to update map
        int refreshrate = 100;

        // redraw map
        mapupdatetimer = new Timer();
        mapupdatetimer.scheduleAtFixedRate(new TimerTask(){

            @Override
            public void run() {
                viewer.repaint();

            }
        }, new Date(), refreshrate);
    }
View Full Code Here

   *
   */
  public void executeOperation() {


    ViewportPane pane = this.udigContext.getViewportPane();
    Display display = getDisplay();

    try {
      setEnabled(false);

      // sets the wait cursor and disables this panel

      pane.setCursor(display.getSystemCursor(SWT.CURSOR_WAIT));

      this.cmd.execute();

    } catch (IOException e) {
      displayMessage(new InfoMessage( e.getMessage(), InfoMessage.Type.FAIL ) );     
    } finally {
      pane.setCursor(null);

      setEnabled(true);
    }

  }
View Full Code Here

                    handler.setCurrentState(EditState.NONE);
                }
            }
        };

        ViewportPane pane = handler.getContext().getViewportPane();
        AppGISAdapter.showWhile(pane, runnable);
    }
View Full Code Here

        if (drawShapeCommand == null) {
            DrawCommandFactory dcf = DrawCommandFactory.getInstance();
            drawShapeCommand = dcf.createDrawShapeCommand(shape);
            IToolContext context = handler.getContext();
            ViewportPane viewportPane = context.getViewportPane();
            viewportPane.addDrawCommand(drawShapeCommand);
        } else {
            drawShapeCommand.setShape(shape);
        }
        handler.repaint();
       
View Full Code Here

    private void removeMapMouseListener() {
        if (currentMapMouseListener != null) {
            final IMap activeMap = ApplicationGIS.getActiveMap();
            final IRenderManager renderManager = activeMap.getRenderManager();
            final ViewportPane viewportPane = (ViewportPane) renderManager.getMapDisplay();
            viewportPane.removeMouseListener(currentMapMouseListener);
        }
    }
View Full Code Here

        }
        final IRenderManager renderManager = activeMap.getRenderManager();
        if (renderManager == null) {
            return;
        }
        final ViewportPane viewportPane = (ViewportPane) renderManager.getMapDisplay();
        if (viewportPane == null) {
            return;
        }

        currentMapMouseListener = new MapMouseListener(){
            public void mouseReleased( MapMouseEvent event ) {
                Point point = event.getPoint();
                Coordinate worldClick = activeMap.getViewportModel().pixelToWorld(point.x, point.y);
                if (isEastingNorthing) {
                    text.setText(String.valueOf(worldClick.x) + "," + String.valueOf(worldClick.y));
                }
                if (isNorthing) {
                    text.setText(String.valueOf(worldClick.y));
                }
                if (isEasting) {
                    text.setText(String.valueOf(worldClick.x));
                }
            }
            public void mousePressed( MapMouseEvent event ) {
            }
            public void mouseExited( MapMouseEvent event ) {
            }
            public void mouseEntered( MapMouseEvent event ) {
            }
            public void mouseDoubleClicked( MapMouseEvent event ) {
            }
        };
        viewportPane.addMouseListener(currentMapMouseListener);
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.ui.render.displayAdapter.ViewportPane

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.