Package org.locationtech.udig.project.render

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


                SortedSet<RenderExecutor> executors;
                synchronized (renderExecutors) {
                    executors = new TreeSet<RenderExecutor>(comparator);
                    executors.addAll(getRenderExecutors());
                }
                ILabelPainter cache = getContext().getLabelPainter();
               
                RENDERERS: for( RenderExecutor executor : executors ) {

                    if (!executor.getContext().isVisible()){
                        if(paintLabels && !(executor.getContext().getLayer() instanceof SelectionLayer)){
                          //disable layer from label cache
                            cache.disableLayer(executor.getContext().getLayer().getID().toString());
                        }
                        continue RENDERERS;
                    }
                       

                    if (executor.getState() == NEVER || executor.getState() == STARTING || executor.getState() == RENDER_REQUEST) {
                        continue RENDERERS;
                    }
                    if( isFullAlphaUsed(executor) ){
                        g.setComposite(AlphaComposite.getInstance(
                                AlphaComposite.SRC_OVER, 1.0f));
                    }else{
                        g.setComposite(AlphaComposite.getInstance(
                                AlphaComposite.SRC_OVER, 0.5f));                       
                    }
                    g.drawRenderedImage(executor.getContext().getImage(), IDENTITY);
                }
                if(paintLabels){
                    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                    g.setRenderingHints(hints);
                    Dimension displaySize = getContext().getMapDisplay().getDisplaySize();
                    try {
                        cache.end(g, new Rectangle(displaySize));
                    }
                    catch( Throwable t ){
                        ProjectPlugin.trace( CompositeRenderContextImpl.class,"painting labels failed", t );
                    }
                }
View Full Code Here


        synchronized (LABEL_PAINTER) {
            if (labelPainterLocal != null){
                return labelPainterLocal;
            }
       
            ILabelPainter labelPainter = (ILabelPainter) getMap().getBlackboard().get(LABEL_PAINTER);
            if (labelPainter == null){
                //create a new one and put it on the blackboard for others to use
                LabelCacheImpl defaultLabelCache = new LabelCacheImpl();
                labelPainter=new UDIGLabelCache(defaultLabelCache);
                getMap().getBlackboard().put(LABEL_PAINTER, labelPainter);
View Full Code Here

                synchronized (childrenRenderers) {
                    executors = new TreeSet<RenderExecutor>(comparator);
                    executors.addAll(getRenderExecutors());
                }
               
                ILabelPainter cache = getContext().getLabelPainter();
                RENDERERS: for( RenderExecutor executor : executors ) {
                    if (!executor.getContext().isVisible()){
                        if(paintLabels && !(executor.getContext().getLayer() instanceof SelectionLayer)){
                            //disable layer from label cache
                              cache.disableLayer(executor.getContext().getLayer().getID().toString());
                          }
                        continue RENDERERS;
                    }
                    if (executor.getState() == NEVER || executor.getState() == STARTING || executor.getState() == RENDER_REQUEST) {
                        continue RENDERERS;
                    }
                    if( isFullAlphaUsed(executor) ){
                        g.setComposite(AlphaComposite.getInstance(
                                AlphaComposite.SRC_OVER, 1.0f));
                    }else{
                        g.setComposite(AlphaComposite.getInstance(
                                AlphaComposite.SRC_OVER, 0.5f));                       
                    }
                    g.drawRenderedImage(executor.getContext().getImage(), IDENTITY);
                }
                if(paintLabels){
                    RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                    g.setRenderingHints(hints);
                    Dimension displaySize = getContext().getImageSize();
                    cache.end(g, new Rectangle(displaySize));
                }
                //update the context with the new image
                ((RenderContextImpl)getContext()).setImage(copy);
               
            } catch (IllegalStateException e) {
View Full Code Here

                    throws InvocationTargetException {
               
                monitor.beginTask("Rendering map", sortedContexts.size());
                RenderContext mainContext = decisive.getContext();

                ILabelPainter labelPainter = mainContext.getLabelPainter();
                labelPainter.clear();
                labelPainter.start();
               
                Dimension displaySize = params.destinationSize;
                Iterator<RenderContext> iter = sortedContexts.iterator();
                while (iter.hasNext()) {
                    RenderContext context = (RenderContext) iter.next();

                    ILayer layer = context.getLayer();
                    boolean isLayerFromGrid = layer.getGeoResource().canResolve(GridCoverage.class);
                    String layerId = getLayerId(layer);

                    if( !(layer instanceof SelectionLayer) ||
                            ((layer instanceof SelectionLayer) && params.selectionStyle.getShowLabels()) ){
                        labelPainter.startLayer(layerId);
                    }
                    try {
                        if (context instanceof CompositeRenderContext) {
                            CompositeRenderContext compositeContext = (CompositeRenderContext) context;
                            List<ILayer> layers = compositeContext.getLayers();
                            boolean visible = false;
                            for (ILayer tmpLayer : layers) {
                                visible = visible || tmpLayer.isVisible();
                            }
                            if (!visible)
                                continue;
                        } else if (!layer.isVisible())
                            continue;
                        Renderer renderer = decisive.getRenderer(context);
                        ProjectUIPlugin
                                .trace(
                                        ApplicationGIS.class,
                                        "Issuing render call to " + renderer.getName(), null); //$NON-NLS-1$
                        try {
                            Graphics2D graphics = (Graphics2D) params.graphics.create();
                            if (params.doBufferedImageForGrids && isLayerFromGrid) {
                                Rectangle clipBounds = graphics.getClipBounds();
                                BufferedImage bi = new BufferedImage(clipBounds.width,
                                        clipBounds.height, BufferedImage.TYPE_INT_ARGB);
                                Graphics2D biG2D = (Graphics2D) bi.getGraphics();
                                renderer.render(biG2D, monitor);
                                graphics.drawImage(bi, null, 0, 0);
                                biG2D.dispose();
                            }else{
                                renderer.render(graphics, monitor);
                            }
                           
                        } catch (RenderException e) {
                            throw new InvocationTargetException(e);
                        }
                    } finally {
                        labelPainter.endLayer(layerId, params.graphics,
                                new Rectangle(displaySize));
                    }
                }
                labelPainter.end(
                        params.graphics,
                        new Rectangle(displaySize));
                labelPainter.clear();
            }

            private String getLayerId(ILayer layer ) {
                String layerId = layer.getID().toString();
                if ( layer instanceof SelectionLayer )
View Full Code Here

            rendererHints.put(StreamingRenderer.DECLARED_SCALE_DENOM_KEY, getContext()
                    .getViewportModel().getScaleDenominator());
            rendererHints.put(StreamingRenderer.SCALE_COMPUTATION_METHOD_KEY,
                    StreamingRenderer.SCALE_ACCURATE);
            ILabelPainter labelPainter = getContext().getLabelPainter();
            Point origin = new Point(paintArea.x, paintArea.y);
            String layerId = getContext().getLayer().getID().toString();
            if (getContext().getLayer() instanceof SelectionLayer)
                layerId = layerId + "-Selection"; //$NON-NLS-1$
            rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY, new LabelCacheDecorator(
View Full Code Here

        try {
            //Clear label cache for this layer.
            ILayer renderingLayer = getContext().getLayer();
            if (renderingLayer != null) {
                //Only if it as a usual layer's renderer
                ILabelPainter labelPainter = getContext().getLabelPainter();
                String layerId = renderingLayer.getID().toString();
                if (getContext().getLayer() instanceof SelectionLayer)
                    layerId = layerId + "-Selection"; //$NON-NLS-1$
                labelPainter.clear(layerId);
            }
        } catch (Exception exc) {
            exc.printStackTrace();
        }
View Full Code Here

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

TOP

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

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.