Package org.geotools.geometry.jts

Examples of org.geotools.geometry.jts.ReferencedEnvelope


    public Rectangle getValidArea() {
        SimpleFeature feature=getMap().getEditManager().getEditFeature();
        if( feature!=null ){
            try {
                Envelope bounds = new ReferencedEnvelope(feature.getBounds())
                        .transform(getMap().getViewportModel().getCRS(), true);
                double[] points = new double[] { bounds.getMinX(),
                        bounds.getMinY(), bounds.getMaxX(), bounds.getMaxY() };
                getMap().getViewportModel().worldToScreenTransform().transform(points, 0, points, 0, 2);
                return new Rectangle((int)points[0], (int)points[1], (int)Math.abs(points[2]-points[0]), (int)Math.abs(points[3]-points[1]));
View Full Code Here


    class SetZoomToMapToolAction extends Action {
        public SetZoomToMapToolAction() {
            super("Zoom to Map"); //$NON-NLS-1$
        }
        public void run() {
            ReferencedEnvelope bounds = map.getBounds(new NullProgressMonitor());
            map.sendCommandASync(new SetViewportBBoxCommand(bounds));
        }
View Full Code Here

        AffineTransform toScreen=getMap().getViewportModel().worldToScreenTransform();

        // calculate the size of the image and where it will be in the display
        Envelope envelope;
        try{
            ReferencedEnvelope bounds = new ReferencedEnvelope(feature.getBounds());
            envelope = bounds.transform(getMap().getViewportModel().getCRS(), true);
        }catch (Exception e) {
            envelope=new ReferencedEnvelope(feature.getBounds());
        }
        double[] screenbounds=new double[]{
                envelope.getMinX(), envelope.getMinY(),
                envelope.getMaxX(), envelope.getMaxY(),
                };
View Full Code Here

    }

    public Rectangle getValidArea() {
        if( feature!=null ){
            try {
                Envelope bounds = new ReferencedEnvelope(feature.getBounds()).transform(getMap().getViewportModel().getCRS(), true);
                double[] points=new double[]{bounds.getMinX(), bounds.getMinY(), bounds.getMaxX(), bounds.getMaxY()};
                getMap().getViewportModel().worldToScreenTransform().transform(points, 0, points, 0, 2);
                return new Rectangle((int)points[0], (int)points[1], (int)Math.abs(points[2]-points[0]), (int)Math.abs(points[3]-points[1]));
            } catch (TransformException e) {
                if( !errorReported ){
View Full Code Here

            }

            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));
                
                
View Full Code Here

                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);
       
View Full Code Here

                    CoordinateReferenceSystem newcrs = (CoordinateReferenceSystem)event.getNewValue();
                    mapviewer.getMap().getViewportModelInternal().setCRS(newcrs);
                }else if (event.getType() == EventType.BOUNDS){
                    //bounds have changed change the overview box correspondingly
                    if (!mainmap.getViewportModel().isBoundsChanging()) {
                        ReferencedEnvelope bnds = findNewOverviewZoom(mainmap.getViewportModel().getBounds(), mainmap.getRenderManager().getMapDisplay(), mapviewer.getMap().getViewportModel().getBounds());
                        mapviewer.getMap().getViewportModelInternal().setBounds(bnds);

                    }
                    mapviewer.getViewport().repaint();
                }else{
                    // repaint to update the box representing the location
                    mapviewer.getViewport().repaint();
                }
            }

        };
        mainmap.getViewportModelInternal().addViewportModelListener(viewportListener);
       
        mapviewer.getViewport().addPaneListener(new IMapDisplayListener(){

            public void sizeChanged( MapDisplayEvent event ) {
                //update the bounds
                ReferencedEnvelope bnds = findNewOverviewZoom(mainmap.getViewportModel().getBounds(), mainmap.getRenderManager().getMapDisplay(), mapviewer.getMap().getViewportModel().getBounds());
                mapviewer.getMap().getViewportModelInternal().setBounds(bnds);
            }});
    }
View Full Code Here

                    double newunitheight = newres * mapviewer.getViewport().getHeight();
                    double ymin = centery - (newunitheight / 2.0);
                    double ymax = centery + (newunitheight / 2.0);

                    // new bounding box
                    ReferencedEnvelope re = new ReferencedEnvelope(xmin, xmax, ymin, ymax,overviewMapEnvelope.getCoordinateReferenceSystem());
                    if (!mainMapEnvelope.contains((Envelope)re)){
                        return re;
                    }
                } catch (Exception ex) {
                }
            }
        }

        ReferencedEnvelope bnds = new ReferencedEnvelope(mainMapEnvelope);                                   
        bnds.expandBy(Math.max(bnds.getWidth() * 3, bnds.getHeight() * 3));
        //this may be too slow and may need to done in a job ??
        ReferencedEnvelope maximumExtent = mainmap.getBounds(new NullProgressMonitor());
        ReferencedEnvelope ret = new ReferencedEnvelope(maximumExtent.intersection(bnds), bnds.getCoordinateReferenceSystem());
        return ret;
    }
View Full Code Here

                Point p2 = mainmap.getViewportModel().worldToPixel(oldc);
                xdiff = p2.x - p1.x;
                ydiff = p2.y - p1.y;
               
                //compute and update bounds
                final ReferencedEnvelope bounds = mainmap.getViewportModel().getBounds();

                ReferencedEnvelope newbounds = new ReferencedEnvelope(bounds.getMinX() + xoffset,
                        bounds.getMaxX() + xoffset, bounds.getMinY() + yoffset, bounds.getMaxY()
                                + yoffset, bounds.getCoordinateReferenceSystem());


View Full Code Here

                Coordinate newc = context.pixelToWorld(p.x, p.y);
                double xoffset = newc.x - oldc.x;
                double yoffset = newc.y - oldc.y;
                               
                //compute and update bounds
                final ReferencedEnvelope bounds = mainmap.getViewportModel().getBounds();
                ReferencedEnvelope newbounds = new ReferencedEnvelope(bounds.getMinX() + xoffset,
                        bounds.getMaxX() + xoffset, bounds.getMinY() + yoffset, bounds.getMaxY()
                                + yoffset, bounds.getCoordinateReferenceSystem());
                mainmap.getViewportModelInternal().setBounds(newbounds);
                dragging = false;
            }
View Full Code Here

TOP

Related Classes of org.geotools.geometry.jts.ReferencedEnvelope

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.