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

Examples of org.locationtech.udig.project.internal.render.SelectionLayer


        case Notification.ADD: {
            Layer layer = (Layer) event.getNewValue();
            List<Layer> layers=new ArrayList<Layer>();
            layers.add(layer);
            if (layer.hasResource(FeatureSource.class))
                 layers.add(new SelectionLayer(layer));
            synchronized (this.layers){
                this.layers.addAll(layers);
            }
            break;
        }
        case Notification.ADD_MANY: {
            List<Layer> layers = new ArrayList<Layer>();
            for( Layer layer : (Collection< ? extends Layer>) event.getNewValue() ) {
                layers.add(layer);
                if (layer.hasResource(FeatureSource.class)
                        && findSelectionLayer(layer) == null)
                    layers.add(new SelectionLayer(layer));
            }
            synchronized (this.layers){
                this.layers.addAll(layers);
            }
            break;
        }
       
        /*
         * The collection <code>layers</code> is a sorted TreeMap of <? extends Layer> objects:
         * Layer.compareTo() is used to sort and identify items for equality. Comparing is performed
         * by z-order. But this collection (<code>layers</code>) contains also
         * additional SelectionLayer objects and their z-order is artificial. This leads to
         * errors during removing by TreeMap.remove(..) methods.
         * The <code>layers</code> collection is re-created safely to fix deleting
         * layers from map with synchronization of this cache list of layers and selection layers with
         * map's list.
         */
       
        case Notification.REMOVE: {

            synchronized (layers) {
             
              Layer removedLayer = (Layer) event.getOldValue();

                for ( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if(removedLayer==l)
                        iter.remove();
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( removedLayer==sl.getWrappedLayer() )
                            iter.remove();
                    }
                }
               
            }
            break;
        }
        case Notification.REMOVE_MANY: {
         
            synchronized (layers) {
              Collection<Layer> removedLayers = (Collection<Layer>) event.getOldValue();

                for ( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if( removedLayers.contains(l))
                        iter.remove();
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( removedLayers.contains(sl.getWrappedLayer()) )
                            iter.remove();
                    }
              }
            }
            break;
        }
        case Notification.MOVE: {
            // this should be a layer accordint to the reverse engineered rules...
            // I like type safety better. or at least documentation :(
            Layer newV=(Layer) event.getNewValue();
           
            // remove then add the layers to fix ordering of layers.
            synchronized (layers) {
                SelectionLayer selectionLayer=null;
                for( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if(newV==l)
                        iter.remove();
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( newV==sl.getWrappedLayer() ){
                            iter.remove();
                            selectionLayer=sl;
                        }
                    }
                }
                layers.add(newV);
                if( selectionLayer!=null ){
                    layers.add(selectionLayer);
                }
            }
           
            break;
        }case Notification.SET:{
            Layer oldV=(Layer) event.getOldValue();
           
            Layer newV=(Layer) event.getNewValue();
            SelectionLayer selectionLayer=null;
            if( newV.hasResource(FeatureSource.class) )
                selectionLayer=new SelectionLayer(newV);

            // remove then add the layers to fix ordering of layers.
            synchronized (layers) {
                for( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if(oldV==l)
                        iter.remove();
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( oldV==sl.getWrappedLayer() ){
                            iter.remove();
                        }
                    }
                }
                layers.add(newV);
View Full Code Here


    if (getMapDisplay() == null || getRenderExecutor() == null) {
      return; // we are not set up to renderer yet!
    }
    getRendererCreator().reset();
    validateRendererConfiguration();
    final SelectionLayer selectionLayer = getRendererCreator()
        .findSelectionLayer(layer);

    final ReferencedEnvelope bbox = bounds == null
        || bounds instanceof ReferencedEnvelope ? (ReferencedEnvelope) bounds
        : new ReferencedEnvelope(bounds, getRenderExecutor()
View Full Code Here

                    layer.getStyleBlackboard().put(ProjectBlackboardConstants.LAYER__DATA_QUERY, selectionFilter);
                }
                break;
            case EXCLUSIVE_SELECTION:
                if( selectionFilter!=Filter.EXCLUDE){
                    SelectionLayer selectionLayer = new SelectionLayer(layer);
                    selectionLayer.getStyleBlackboard().put(ProjectBlackboardConstants.LAYER__DATA_QUERY, selectionFilter);
                    toRender.set(toRender.indexOf(layer), selectionLayer);
                }else
                    toRender.remove(layer);
                }
                break;
            case EXCLUSIVE_ALL_SELECTION:
                if( selectionFilter!=Filter.EXCLUDE){
                    SelectionLayer selectionLayer = new SelectionLayer(layer);
                    selectionLayer.getStyleBlackboard().put(ProjectBlackboardConstants.LAYER__DATA_QUERY, selectionFilter);
                    toRender.set(toRender.indexOf(layer), selectionLayer);
                }
                break;
            case OVERLAY:
                if( selectionFilter!=Filter.EXCLUDE){
                    toRender.add(0, new SelectionLayer(layer));
                }
                break;

            default:
                break;
View Full Code Here

        RendererCreatorImpl creator = MapTests.createRendererCreator(map);
       
        SortedSet<Layer> layers = creator.getLayers();
        layers.clear();
        layers.addAll(map.getLayersInternal());
        layers.add(new SelectionLayer(map.getLayersInternal().get(0)));
        layers.add(new SelectionLayer(map.getLayersInternal().get(1)));
       
        Iterator<Layer> iter = layers.iterator();
       
        Layer layer = iter.next();
        assertEquals( map.getLayersInternal().get(0),layer );
        layer = iter.next();
        assertEquals( map.getLayersInternal().get(1),layer );
        SelectionLayer sl = (SelectionLayer) iter.next();
        assertEquals( map.getLayersInternal().get(0),sl.getWrappedLayer() );
        sl = (SelectionLayer) iter.next();
        assertEquals( map.getLayersInternal().get(1),sl.getWrappedLayer() );
       
       
    }
View Full Code Here

        Iterator<Layer> iter = layers.iterator();
        boolean selectionLayerFound=false;
        while( iter.hasNext() ){
            Layer next = iter.next();
            if (next instanceof SelectionLayer) {
                SelectionLayer sl = (SelectionLayer) next;
                selectionLayerFound=true;
                assertEquals(layer,sl.getWrappedLayer());
            }else{
                assertEquals(layer, next);
            }
        }
        assertTrue( selectionLayerFound );
View Full Code Here

        RendererCreator creator=map.getRenderManagerInternal().getRendererCreator();
       
        SortedSet<Layer> layers = creator.getLayers();
        layers.clear();
        layers.addAll(map.getLayersInternal());
        layers.add(new SelectionLayer(map.getLayersInternal().get(0)));
        layers.add(new SelectionLayer(map.getLayersInternal().get(1)));
       
        creator.reset();
       
        renderer.getContext().addContexts(creator.getConfiguration());
       
        Collection<RenderExecutor> executors = renderer.getRenderExecutors();
       
        Iterator<RenderExecutor> iter = executors.iterator();

        RenderExecutor executor = iter.next();
        assertEquals( map.getLayersInternal().get(0),executor.getContext().getLayer() );
        executor = iter.next();
        assertEquals( map.getLayersInternal().get(1),executor.getContext().getLayer() );
        executor = iter.next();
        SelectionLayer sl = (SelectionLayer) executor.getContext().getLayer();
        assertEquals( map.getLayersInternal().get(0),sl.getWrappedLayer() );
        executor = iter.next();
        sl = (SelectionLayer) executor.getContext().getLayer();
        assertEquals( map.getLayersInternal().get(1),sl.getWrappedLayer() );
       
    }
View Full Code Here

        RendererCreator creator=map.getRenderManagerInternal().getRendererCreator();
       
        SortedSet<Layer> layers = creator.getLayers();
        layers.clear();
        layers.addAll(map.getLayersInternal());
        layers.add(new SelectionLayer(map.getLayersInternal().get(0)));
        layers.add(new SelectionLayer(map.getLayersInternal().get(1)));
       
        creator.reset();
       
        CompositeRenderContextImpl comp=new CompositeRenderContextImpl();
        comp.addContexts(creator.getConfiguration());
       
        Iterator iter = comp.getContexts().iterator()
       
        RenderContext executor = (RenderContext) iter.next();
        assertEquals( map.getLayersInternal().get(0),executor.getLayer() );
        executor = (RenderContext) iter.next();
        assertEquals( map.getLayersInternal().get(1),executor.getLayer() );
        executor = (RenderContext) iter.next();
        SelectionLayer sl = (SelectionLayer) executor.getLayer();
        assertEquals( map.getLayersInternal().get(0),sl.getWrappedLayer() );
        executor = (RenderContext) iter.next();
        sl = (SelectionLayer) executor.getLayer();
        assertEquals( map.getLayersInternal().get(1),sl.getWrappedLayer() );
    }
View Full Code Here

            //if selectable layer also add a selection layer
            Layer layer = (Layer) event.getNewValue();
            List<Layer> layers=new ArrayList<Layer>();
            layers.add(layer);
            if (layer.hasResource(FeatureSource.class))
                 layers.add(new SelectionLayer(layer));
            synchronized (this.layers){
                this.layers.addAll(layers);
            }
            break;
        }
        case Notification.ADD_MANY: {
            //multiple layer has been added need to add to layers list
            //if selectable layer also add a selection layer
            List<Layer> layers = new ArrayList<Layer>();
            for( Layer layer : (Collection< ? extends Layer>) event.getNewValue() ) {
                layers.add(layer);
                if (layer.hasResource(FeatureSource.class)
                        && findSelectionLayer(layer) == null)
                    layers.add(new SelectionLayer(layer));
            }
            synchronized (this.layers){
                this.layers.addAll(layers);
            }
            break;
        }
       
        /*
         * The collection <code>layers</code> is a sorted TreeMap of <? extends Layer> objects:
         * Layer.compareTo() is used to sort and identify items for equality. Comparing is performed
         * by z-order. But this collection (<code>layers</code>) contains also
         * additional SelectionLayer objects and their z-order is artificial. This leads to
         * errors during removing by TreeMap.remove(..) methods.
         * The <code>layers</code> collection is re-created safely to fix deleting
         * layers from map with synchronization of this cache list of layers and selection layers with
         * map's list.
         */
       
        case Notification.REMOVE: {
            //remove layer from layers list (both layer and selection layer)
            synchronized (layers) {
                Layer removedLayer = (Layer) event.getOldValue();
                for ( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if(removedLayer==l){
                        //remove layer
                        iter.remove();
                    }
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( removedLayer==sl.getWrappedLayer() ){
                            iter.remove();
                        }
                    }
                }
            }
            break;
        }
        case Notification.REMOVE_MANY: {
          //remove layers from layers list (both layer and selection layer)
            synchronized (layers) {
                Collection<Layer> removedLayers = (Collection<Layer>) event.getOldValue();

                for ( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if( removedLayers.contains(l)){
                        iter.remove();
                    }
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( removedLayers.contains(sl.getWrappedLayer()) ){
                            iter.remove();
                        }
                    }
                }
            }
            break;
        }
        case Notification.MOVE: {
            // moving a layer (getNewValue is expected to return a layer)
            // I like type safety better. or at least documentation :(
            Layer newV=(Layer) event.getNewValue();
           
            // remove then add the layers to fix ordering of layers (layers are stored in a sorted set that
            //is sorted by zorder
            synchronized (layers) {
                //remove layer and selection layer
                SelectionLayer selectionLayer=null;
                for( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if(newV==l)
                        iter.remove();
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( newV==sl.getWrappedLayer() ){
                            iter.remove();
                            selectionLayer=sl;
                        }
                    }
                }
                //add layers and selection layer
                layers.add(newV);
                if( selectionLayer!=null ){
                    layers.add(selectionLayer);
                }
            }
           
            break;
        }case Notification.SET:{
            //what is a SET event?
            Layer oldV=(Layer) event.getOldValue();
            Layer newV=(Layer) event.getNewValue();
            SelectionLayer selectionLayer=null;
            if( newV.hasResource(FeatureSource.class) )
                selectionLayer=new SelectionLayer(newV);

            // remove then add the layers to fix ordering of layers.
            synchronized (layers) {
                for( Iterator iter = layers.iterator(); iter.hasNext(); ) {
                    Layer l = (Layer) iter.next();
                    if(oldV==l)
                        iter.remove();
                    else if( l instanceof SelectionLayer ){
                        SelectionLayer sl=(SelectionLayer) l;
                        if( oldV==sl.getWrappedLayer() ){
                            iter.remove();
                        }
                    }
                }
                layers.add(newV);
View Full Code Here

        if (getMapDisplay() == null || getMapDisplay().getWidth() < 1 || getMapDisplay().getHeight() < 1) {
            return; // we are not set up to renderer yet!
        }
       
        final SelectionLayer selectionLayer = getRendererCreator().findSelectionLayer(layer);
       
        //get only the tile in the bounds in the area of interest
        ReferencedEnvelope areaOfInterest = null;
        if (bounds == null){
            areaOfInterest = getMap().getViewportModel().getBounds();
View Full Code Here

        if (getMapDisplay() == null || getMapDisplay().getWidth() < 1 || getMapDisplay().getHeight() < 1) {
            return; // we are not set up to renderer yet!
        }
       
        //find selection layer
        final SelectionLayer selectionLayer = getRendererCreator().findSelectionLayer(layer);
        if (selectionLayer == null) return;
               
        //redraw the ones we care about for now
        //determine area of interest
        ReferencedEnvelope areaOfInterest = null;
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.internal.render.SelectionLayer

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.