Package org.locationtech.udig.project.render

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


    public void clearReadyTiles() {
      //Collection<Tile> values = readyTiles.values();
      //for (Tile tile : values) {
        Set<Entry<ReferencedEnvelope, Tile>> entrySet = readyTiles.entrySet();
        for( Entry<ReferencedEnvelope, Tile> set : entrySet ) {
            Tile tile = set.getValue();       
        tile.disposeSWTImage();
      }
      readyTiles.clear();
    }   
View Full Code Here


          GC gc = g.getGraphics(GC.class);
          if (gc != null ) {
            // SWT, draw all the tiles
            Set<ReferencedEnvelope> keySet = tiles.keySet();
              for (ReferencedEnvelope env : keySet) {
                Tile tile = tiles.get(env);
                //System.out.println("SWTImage: "+tile.getSWTImage());
                ViewportModel viewportModelInternal = tile.getRenderExecutor().getRenderer().getContext().getViewportModelInternal();
                java.awt.Point a = viewportModelInternal.worldToPixel(new Coordinate(env.getMinX(), env.getMinY()));
              java.awt.Point b = viewportModelInternal.worldToPixel(new Coordinate(env.getMaxX(), env.getMaxY()));
                    int width = b.x - a.x;
                    int height = a.y - b.y;
              synchronized (tile) {
                      //an exception can be thrown here if the image has been disposed of
                      //since it was retrieved or something else bad happens while drawing
                      //this is OK in our case because another paint event should be coming soon
                      //which will fix the issue; so for now we just catch the errors
                      //and don't worry about them.
                      try{
                          org.eclipse.swt.graphics.Image im = tile.getSWTImage();
                          gc.drawImage(im, 0, 0, im.getBounds().width, im.getBounds().height, a.x, b.y, width, height);
                      }catch (Exception ex){
                      }   
                    }
              if( TESTING ){
                    g.setColor(Color.BLUE);
                      g.drawLine(a.x, a.y, a.x, b.y);
                      g.drawLine(a.x, b.y, b.x, b.y);
                      g.drawLine(b.x, b.y, b.x, a.y);
                      g.drawLine(b.x, a.y, a.x, a.y);               
              }
              }  
            }
          else {
            // AWT, draw all the tiles
            Set<ReferencedEnvelope> keySet = tiles.keySet();
              for (ReferencedEnvelope env : keySet) {
                Tile tile = tiles.get(env);
                //System.out.println("BufferedImage: "+tile.getBufferedImage());
                ViewportModel viewportModelInternal = tile.getRenderExecutor().getRenderer().getContext().getViewportModelInternal();
                java.awt.Point a = viewportModelInternal.worldToPixel(new Coordinate(env.getMinX(), env.getMinY()));
                java.awt.Point b = viewportModelInternal.worldToPixel(new Coordinate(env.getMaxX(), env.getMaxY()));
                g.drawImage((RenderedImage)tile.getBufferedImage(), a.x, b.y);
                g.setColor(Color.BLUE);
                  g.drawLine(a.x, a.y, a.x, b.y);
                  g.drawLine(a.x, b.y, b.x, b.y);
                  g.drawLine(b.x, b.y, b.x, a.y);
                  g.drawLine(b.x, a.y, a.x, a.y);                 
View Full Code Here

     * @param env
     * @return
     */
    private Tile getOrCreateTile(ReferencedEnvelope env){
       
        Tile tile = (Tile) tileCache.get(env);
        if (tile == null) {
            try {
                tileCache.writeLock(env);
                tile = (Tile) tileCache.peek(env);
                if (tile == null) {
View Full Code Here

     * @param key
     * @return
     */
    private Tile createTile(ReferencedEnvelope key){
        RenderExecutorComposite newRE = createRenderExecutor(key);
        Tile tile = new Tile(key, newRE, getTileSize());
        tile.setStateChangedListener(tileStateListener);
        importantTiles.add(tile);
        ((RenderContextImpl)newRE.getContext()).setLabelPainterLocal(newRE.getContext().getLabelPainter());
        return tile;
    }
View Full Code Here

                //nothing to do; the bounding box of the tile does not intersect the area of intersect
                //this shouldn't occur but it does???  (maybe a double precision thing)
                continue;
            }
           
            Tile tile = getOrCreateTile(env);
           
            tile.setTileState(Tile.ValidatedState.VALIDATED);
            tile.setRenderState(Tile.RenderState.RENDERED);
           
            RenderExecutorComposite re = tile.getRenderExecutor();
           
            //validate the context if necessary
            List<AbstractRenderMetrics> torefresh = new ArrayList<AbstractRenderMetrics>();
            if (tile.getContextState() == Tile.ContextState.INVALID){
                torefresh = validateRendererConfiguration(tile);
                tile.setContextState(Tile.ContextState.OKAY);
            }
           
            //determine which layers need to be updated
            Collection<ILayer> layersToUpdate = new ArrayList<ILayer>();
            layersToUpdate.add(layer);
View Full Code Here

        //get only the tile in the bounds in the area of interest
        Collection<ReferencedEnvelope> tileBounds = computeTileBounds(areaOfInterest, resolution);
        setTileStateToOld(tileBounds);
       
        for( ReferencedEnvelope env : tileBounds ) {
            Tile tile = getOrCreateTile(env);
           
            tile.setRenderState(Tile.RenderState.RENDERED);
            tile.setTileState(Tile.ValidatedState.VALIDATED);
            RenderExecutorComposite re = tile.getRenderExecutor();
        
            // creates the contexts
            if (tile.getContextState() == Tile.ContextState.INVALID){
                validateRendererConfiguration(tile);
                tile.setContextState(Tile.ContextState.OKAY);
            }

            final Envelope bbox = env;

            //set render requests for the selection layer
View Full Code Here

     */
    private void setTileStateToOld( Collection<ReferencedEnvelope> validTiles ) {
        // mark all tiles as offscreen
        for( Iterator<Object> iterator = tileCache.getKeys().iterator(); iterator.hasNext(); ) {
            ReferencedEnvelope key = (ReferencedEnvelope) iterator.next();
            Tile t = (Tile) tileCache.get(key);
            if (t != null && !validTiles.contains(key)) {
                t.setTileState(Tile.ValidatedState.OLD);
            }
        }
    }
View Full Code Here

        //update tile states
        setTileStateToOld(tileBounds);
        for( Iterator<ReferencedEnvelope> iterator = tileBounds.iterator(); iterator.hasNext(); ) {
            ReferencedEnvelope referencedEnvelope = (ReferencedEnvelope) iterator.next();
           
            Tile tile = getOrCreateTile(referencedEnvelope);
            boolean rendertile = (tile.getRenderState() == Tile.RenderState.INVALID || tile.getRenderState() == Tile.RenderState.NEW);
          
            tile.setTileState(Tile.ValidatedState.VALIDATED);
            RenderExecutorComposite re = tile.getRenderExecutor();

            // creates the contexts - this function returns the "new" contexts; these are the ones
            //that need to be refreshed.
            List<AbstractRenderMetrics> forrefresh = null;
            if (tile.getContextState() == Tile.ContextState.INVALID){
                forrefresh = validateRendererConfiguration(tile);
                tile.setContextState(Tile.ContextState.OKAY);
                if (forrefresh == null){
                    rendertile = true;
                }
            }
                       
View Full Code Here

TOP

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

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.