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

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


   
        if (rendererCreator == null){
            initRenderCreator();
        }
        RenderExecutorComposite re = t.getRenderExecutor();
        TiledCompositeRendererImpl renderer = null;
        try{
            renderer = (TiledCompositeRendererImpl)re.getRenderer();
        }catch (Exception ex){
            ProjectPlugin.log("Error creating context for tile - Tile does not have a renderer.", ex); //$NON-NLS-1$
            return null;
        }
       
        if (renderer == null){
            //the tile doesn't have a renderer there is some error;
            ProjectPlugin.log("Error creating context for tile - Tile does not have a renderer."); //$NON-NLS-1$
            return null;
        }
        Collection<AbstractRenderMetrics> currentconfiguration;
        synchronized (this) {
            if (renderer.getChildren().size() == 0){
                currentconfiguration = null;
            }else{
                currentconfiguration = renderer.getChildrenMetrics();
            }
        }
      
       ArrayList<AbstractRenderMetrics> newcontexts = new ArrayList<AbstractRenderMetrics>();
       ILabelPainter tilelabelpainter = ((RenderContextImpl)t.getRenderExecutor().getContext()).getLabelPainter();
       if (currentconfiguration == null){
            //get new configurations
            Collection<AbstractRenderMetrics> newconfig = ((TiledRendererCreatorImpl)getRendererCreator()).getConfiguration(t.getReferencedEnvelope());
            // need this because this is taking place in a non-synchronized
            // block so it is possible for
            // this code to be executed twice. I want the second run to be
            // accurate.
            // might need to be thought about more.
            renderer.removeAllChildren();
            renderer.addChildren(newconfig);
            newcontexts = null;
            for( Iterator<AbstractRenderMetrics> iterator = newconfig.iterator(); iterator.hasNext(); ) {
                AbstractRenderMetrics abstractRenderMetrics = (AbstractRenderMetrics) iterator.next();
                //setup label painter
                ((RenderContextImpl)abstractRenderMetrics.getRenderContext()).setLabelPainterLocal(tilelabelpainter);
            }
        }else{
            //we have an existing configuration; lets recycle as many of the contexts as possible
            //lets get the new configuration
            Collection <AbstractRenderMetrics> newconfig = ((TiledRendererCreatorImpl) getRendererCreator()).getConfiguration(t.getReferencedEnvelope());
           
            //items to add/remove from the existing configuration
            List<AbstractRenderMetrics> removeList = new ArrayList<AbstractRenderMetrics>();
            List<AbstractRenderMetrics> addList = new ArrayList<AbstractRenderMetrics>();
           
            for(AbstractRenderMetrics metric: currentconfiguration){
                if (!newconfig.contains(metric)){
                    //this is an existing context the doesn't exist in the new set
                    removeList.add(metric);
                }
            }
            for (AbstractRenderMetrics metric: newconfig){
                if (!currentconfiguration.contains(metric)){
                    //this is in the new configuration but not the only one therefore we need to add it
                    addList.add(metric);
                    //setup label painter
                    ((RenderContextImpl)metric.getRenderContext()).setLabelPainterLocal(tilelabelpainter);
                }
            }
           
            newcontexts.addAll(addList);
           
            renderer.removeChildren(removeList);
           
            if (!addList.isEmpty()){
                renderer.removeChildren(addList);
            }
            renderer.addChildren(addList);
           
            //let's properly dispose of anything in the remove List
            for( Iterator<AbstractRenderMetrics> iterator = removeList.iterator(); iterator.hasNext(); ) {
                AbstractRenderMetrics metric = (AbstractRenderMetrics) iterator.next();
                ((RenderContextImpl)metric.getRenderContext()).dispose();
View Full Code Here

TOP

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

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.