Package org.locationtech.udig.project.render

Examples of org.locationtech.udig.project.render.IRenderContext


        RenderExecutorComposite parent  = t.getRenderExecutor();
        Collection<TiledCompositeRendererImpl.RenderInfo>  kids = ((TiledCompositeRendererImpl)parent.getRenderer()).getChildren();
       
        for( Iterator<TiledCompositeRendererImpl.RenderInfo> iterator = kids.iterator(); iterator.hasNext(); ) {
            TiledCompositeRendererImpl.RenderInfo kid = iterator.next();
            IRenderContext childcontext = kid.getRenderer().getContext()
            ;
            if (childcontext instanceof CompositeRenderContext){
                if (((CompositeRenderContext) childcontext).getLayers().contains(layer)){
                    if( ((CompositeRenderContext) childcontext).getLayers().contains(contained)){
                        //composite context and contains layer + contained
                        //these layers are related through a composite context
                        return true;
                    }else{
                        //composite context that contains layer but not contained
                        //cannot be related
                        return false;
                    }
                }
            }else{
                if (childcontext.getLayer() == layer){
                    //layer is not part of a composite context and cannot be related in
                    //any way to contained
                    return false;
                }
            }
View Full Code Here


    public synchronized void render( Graphics2D graphics, IProgressMonitor monitor )
            throws RenderException {
        try {
          // get the current context
          final IRenderContext currentContext = getContext();        
          final IGeoResource geoResource = currentContext.getGeoResource();
         
          if (geoResource.canResolve(RendererImpl.class)) {
              // if the service wants to use its own renderer, let it be
                RendererImpl rendererImpl = geoResource.resolve(RendererImpl.class, monitor);
                rendererImpl.setContext(currentContext);
                rendererImpl.render(graphics, monitor);
                rendererImpl.dispose();
                return;
            }
         
          //check that actually we have something to draw
            currentContext.setStatus(ILayer.WAIT);
            currentContext.setStatusMessage(Messages.BasicGridCoverageRenderer_rendering_status);
           
            //get the envelope and the screen extent
            ReferencedEnvelope envelope = getRenderBounds();
            if( envelope == null || envelope.isNull()){
                envelope = context.getImageBounds();
            }
            Point upperLeft = currentContext.worldToPixel( new Coordinate( envelope.getMinX(), envelope.getMinY()) );
            Point bottomRight = currentContext.worldToPixel( new Coordinate( envelope.getMaxX(), envelope.getMaxY()) );
            Rectangle screenSize = new Rectangle( upperLeft );
            screenSize.add( bottomRight );
          IMapDisplay mapDisplay = currentContext.getMapDisplay();
           
          
             AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) geoResource.resolve( AbstractGridCoverage2DReader.class, monitor);
             if( reader == null ){
                 return; // unable to connect!
             }
             CoordinateReferenceSystem destinationCRS = currentContext.getCRS();
             ReferencedEnvelope bounds = (ReferencedEnvelope) currentContext.getImageBounds();
             bounds=bounds.transform(destinationCRS, true);
            
             ParameterValueGroup group = geoResource.resolve( ParameterValueGroup.class, monitor);
             if(group==null){
                 group=reader.getFormat().getReadParameters();
             }
             else{
                 // temporary fix for image-io (JG: what is the nature of this fix?)
                 try{
                     ParameterValue<?> jaiImageReaderParam = group.parameter(AbstractGridFormat.USE_JAI_IMAGEREAD.getName().toString());
                     if(jaiImageReaderParam!=null){
                         jaiImageReaderParam.setValue(false);
                     }
                 }catch (ParameterNotFoundException e) {
                     // do nothing
                 }
             }
             ParameterValue<?> readGridGeometry2DParam = group.parameter(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString());

//            GridEnvelope range = new GridEnvelope2D(0, 0, mapDisplay.getWidth(), mapDisplay.getHeight());
//            MathTransform displayToLayer = currentContext.worldToScreenMathTransform().inverse();
//            ReferencingFactoryFinder.getMathTransformFactory(null).createConcatenatedTransform(displayToLayer,
//                    currentContext.getLayer().mapToLayerTransform());
//            GridGeometry2D geom = new GridGeometry2D(range, displayToLayer, destinationCRS);
//            readGridGeometry2DParam.setValue(geom);

            GridEnvelope2D gridEnvelope = new GridEnvelope2D(0, 0, mapDisplay.getWidth(), mapDisplay.getHeight());
            org.opengis.geometry.Envelope env;
            double west= bounds.getMinX();
            double east= bounds.getMaxX();
            double south= bounds.getMinY();
            double north= bounds.getMaxY();
            if (destinationCRS != null) {
                env = new ReferencedEnvelope(west, east, south, north, destinationCRS);
            } else {
                DirectPosition2D minDp = new DirectPosition2D(west, south);
                DirectPosition2D maxDp = new DirectPosition2D(east, north);
                env = new Envelope2D(minDp, maxDp);
            }
            readGridGeometry2DParam.setValue(new GridGeometry2D(gridEnvelope, env));

             currentContext.setStatus(ILayer.WORKING);
             setState( STARTING );
            
             ParameterValue[] parameterValues = group.values().toArray(new ParameterValue[0]);
            GridCoverage2D coverage = (GridCoverage2D) reader.read(parameterValues);
             if(coverage!=null){             
              //setting rendering hints
                 //
              RenderingHints hints = new RenderingHints(new HashMap<RenderingHints.Key,Object>());
              hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED));
              hints.add(new RenderingHints(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE));
              hints.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED));
              hints.add(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED));
              hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
              hints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE));
              hints.add(new RenderingHints(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF));
              hints.add(new RenderingHints(JAI.KEY_INTERPOLATION,new InterpolationNearest()));
              graphics.addRenderingHints(hints);
             
              // JG: Store title cache on the layer blackboard so it can last between runs.
              //     Performance question: may do better to have a single larger tile cache on the map blackboard?
              //
              final TileCache tempCache=currentContext.getTileCache();
              hints.add(new RenderingHints(JAI.KEY_TILE_CACHE,tempCache));
              //hints.add( new Hints( Hints.RESAMPLE_TOLERANCE, 0.000000000001 ));
               
              if( CRS.getHorizontalCRS(destinationCRS) == null ){
                  destinationCRS = coverage.getCoordinateReferenceSystem2D();
              }
              //
              AffineTransform worldToScreen = null; // we are leting the GridCoverageRenderer sort that out
             
              //draw
              try {
                  Style style = grabStyle();
                  Rule rule = SLDs.getRasterSymbolizerRule(style);
                 
                  final double currentScale = currentContext.getViewportModel().getScaleDenominator();               
                  double minScale = rule.getMinScaleDenominator();
                  double maxScale = rule.getMaxScaleDenominator();
                  if (minScale <= currentScale && currentScale <= maxScale ) {
                      final GridCoverageRenderer paint = new GridCoverageRenderer( destinationCRS, envelope, screenSize,worldToScreen,hints );
                      final RasterSymbolizer rasterSymbolizer = SLD.rasterSymbolizer(style);
View Full Code Here

    @SuppressWarnings("unchecked")
  public synchronized void render( Graphics2D graphics, IProgressMonitor monitor )
            throws RenderException {
        try {
          // get the current context
          final IRenderContext currentContext = getContext();        
         
          //check that actually we have something to draw
            currentContext.setStatus(ILayer.WAIT);
            currentContext.setStatusMessage(Messages.BasicGridCoverageRenderer_rendering_status);
           
            //get the envelope and the screen extent
            ReferencedEnvelope envelope = getRenderBounds();
            if( envelope == null || envelope.isNull()){
                envelope = context.getImageBounds();
            }
            Point upperLeft = currentContext.worldToPixel( new Coordinate( envelope.getMinX(), envelope.getMinY()) );
            Point bottomRight = currentContext.worldToPixel( new Coordinate( envelope.getMaxX(), envelope.getMaxY()) );
            Rectangle screenSize = new Rectangle( upperLeft );
            screenSize.add( bottomRight );
          IMapDisplay mapDisplay = currentContext.getMapDisplay();
           
          CoordinateReferenceSystem destinationCRS = currentContext.getCRS();

            final IGeoResource geoResource = currentContext.getGeoResource();
            ReferencedEnvelope bounds = (ReferencedEnvelope) currentContext.getImageBounds();
            bounds=bounds.transform(destinationCRS, true);
           
            GridEnvelope range=new GridEnvelope2D(0,0, mapDisplay.getWidth(), mapDisplay.getHeight() );
           
            MathTransform displayToLayer=currentContext.worldToScreenMathTransform().inverse();
            ReferencingFactoryFinder.getMathTransformFactory(null).createConcatenatedTransform(displayToLayer, currentContext.getLayer().mapToLayerTransform());
            GridGeometry2D geom=new GridGeometry2D(range, displayToLayer, destinationCRS );

            currentContext.setStatus(ILayer.WORKING);
            setState( STARTING );
           
            GridCoverageLoader loader = geoResource.resolve(GridCoverageLoader.class, monitor);
            if( loader == null ){
                // unable to load in memory
                return;
            }
            GridCoverage2D coverage = (GridCoverage2D) loader.load(geom, monitor);

            if(coverage!=null)
      {
             
              //setting rendering hints
              RenderingHints hints = new RenderingHints(Collections.EMPTY_MAP);
              hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED));
              hints.add(new RenderingHints(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE));
              hints.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED));
              hints.add(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED));
              hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR));
              hints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE));
              hints.add(new RenderingHints(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF));
              hints.add(new RenderingHints(JAI.KEY_INTERPOLATION,new InterpolationNearest()));
              graphics.addRenderingHints(hints);
             
              final TileCache tempCache=currentContext.getTileCache();
              hints.add(new RenderingHints(JAI.KEY_TILE_CACHE,tempCache));
             
              if( CRS.getHorizontalCRS(destinationCRS) == null ){
                  destinationCRS = coverage.getCoordinateReferenceSystem2D();
              }
              //draw
              try {
                  Style style = grabStyle();
                  Rule rule = SLDs.getRasterSymbolizerRule(style);
                 
                  final double currentScale = currentContext.getViewportModel().getScaleDenominator();               
                  double minScale = rule.getMinScaleDenominator();
                  double maxScale = rule.getMaxScaleDenominator();
                  if (minScale <= currentScale && currentScale <= maxScale ) {
                      final GridCoverageRenderer paint = new GridCoverageRenderer( destinationCRS, envelope, screenSize,null, hints );
                      final RasterSymbolizer rasterSymbolizer = SLD.rasterSymbolizer(style);
View Full Code Here

            {2, 111000000, 39135.758482, 55346.851197, 78271.516964}//
    };

    public void render( Graphics2D g2d, IProgressMonitor monitor ) throws RenderException {
        try {
            final IRenderContext currentContext = getContext();
            currentContext.setStatus(ILayer.WAIT);

            CoordinateReferenceSystem mercatorCrs = CRS.decode(EPSG_MERCATOR);
            CoordinateReferenceSystem latLongCrs = DefaultGeographicCRS.WGS84;

            ReferencedEnvelope renderREnv = getRenderBounds();
            if (renderREnv == null || renderREnv.isNull()) {
                renderREnv = context.getImageBounds();
            }

            ReferencedEnvelope mercatorREnv = renderREnv.transform(mercatorCrs, true);
            ReferencedEnvelope latlongREnv = renderREnv.transform(latLongCrs, true);

            Point upperLeft = currentContext.worldToPixel(new Coordinate(renderREnv.getMinX(), renderREnv.getMinY()));
            Point bottomRight = currentContext.worldToPixel(new Coordinate(renderREnv.getMaxX(), renderREnv.getMaxY()));
            Rectangle screenSize = new Rectangle(upperLeft);
            screenSize.add(bottomRight);

            final IGeoResource resource = getContext().getGeoResource();
            if (resource == null || !resource.canResolve(JGTtmsGeoResource.class)) {
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.render.IRenderContext

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.