<commit_before>/** The FlamingLayer Class **/

/**  
 * @constructor
 * @augments Layer
 * @description The superclass for all flamingolayers 
 * @param id The id of the layer
 * @param options The options to be given to the layer
 * @param flamingoObject The flamingo object of the layer
 * 
 */

Ext.define("viewer.viewercontroller.flamingo.FlamingoLayer",{
    enabledEvents: null,
    type: null,
    constructor :function (config){
        if (config.id){
            config.id=""+config.id;
            if((config.id).indexOf(":") != -1){
                config.id = (config.id).replace(/:/g,'_');
            }
        }
        this.enabledEvents=new Object();
        return this;
    },
    /**
     * Get's the frameworklayer: the viewer specific layer.
     */
    getFrameworkLayer : function(){
        if (this.map==null){
            return null;
        }
        return this.map.getFrameworkMap();
    },
    
    toXML : function(){
        Ext.Error.raise({msg: "FlamingoLayer.toXML(): .toXML() must be made!"});
    },

    getTagName : function(){
        Ext.Error.raise({msg: "FlamingoLayer.getTagName: .getTagName() must be made!"});
    },
    setOption : function(optionKey,optionValue){
        this.options[optionKey]=optionValue;
    },
    getId : function(){
        return this.id;
    },
    getFrameworkId: function(){
        return this.map.getId()+"_"+this.getId();
    },
    setAlpha : function (alpha){
        this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"setAlpha",alpha)
    },
    getAlpha : function (){
        return this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"getAlpha");
    },
    /**
     * Get the last getMap request array
     * @see viewer.viewerController.controller.Layer#getLastMapRequest
     */
    getLastMapRequest: function(){
        var request=this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"getLastGetMapRequest");
        if (request==null){
            return null;
        }
        return [request];
    },
    /**
     * Returns the type of the layer.
     */
    getType: function(){
        return this.type;
    },
    /**
     * reloads the framework map
     */
    reload: function(){
        return this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"update");
    },
    /**
     * Overwrites the addListener function. Add's the event to allowexternalinterface of flamingo
     * so flamingo is allowed to broadcast the event.
     */
    addListener : function(event,handler,scope){
        //enable flamingo event broadcasting
        var flamEvent=this.map.mapComponent.eventList[event];
        if (flamEvent!=undefined){
            //if not enabled yet, add it
            if (this.enabledEvents[flamEvent]==undefined){
               this.map.getFrameworkMap().callMethod(this.map.mapComponent.getId(),"addAllowExternalInterface",this.getFrameworkId()+"."+flamEvent);
               this.enabledEvents[flamEvent]=true;
            }
        }
        /* fix for infinite loop:
         * If this is called from a layer that extends the FlamingoArcLayer the superclass is
         * that FlamingoArcLayer and this function is called again when this.superclass.function is called
         **/
        if (this.superclass.$className == "viewer.viewercontroller.flamingo.FlamingoArcLayer"){
            this.superclass.superclass.addListener.call(this,event,handler,scope);
        }else{
            this.superclass.addListener.call(this,event,handler,scope);
        }
        //viewer.viewercontroller.controller.Layer.superclass.addListener.call(this,event,handler,scope);
    },
    setVisible : function (visible){        
        if (this.map !=null){
            this.map.getFrameworkMap().callMethod(this.map.id + "_" + this.id, "setVisible", visible);
        }
        this.visible = visible;
        
        if (this.options!=null)
            this.options["visible"] = visible;
    },
    /**
     * Get the visibility
     */
    getVisible : function (){
        if (this.map !=null){
            this.visible = this.map.getFrameworkMap().callMethod(this.map.id + "_" + this.id, "getVisible");
        }
        if (this.options!=null)
            this.options["visible"] = this.visible;
        return this.visible;
    },
    /**
     * Overwrite destroy, clear Listeners and forward to super.destroy
     */
    destroy: function(){        
        /* fix for infinite loop:
         * If this is called from a layer that extends the FlamingoArcLayer the superclass is
         * that FlamingoArcLayer and this function is called again when this.superclass.function is called
         **/
        if (this.superclass.$className == "viewer.viewercontroller.flamingo.FlamingoArcLayer"){
            this.superclass.superclass.destroy.call(this);
        }else{
            this.superclass.destroy.call(this);
        }
    }
    
});<commit_msg>First set the state, then raise event<commit_after>/** The FlamingLayer Class **/

/**  
 * @constructor
 * @augments Layer
 * @description The superclass for all flamingolayers 
 * @param id The id of the layer
 * @param options The options to be given to the layer
 * @param flamingoObject The flamingo object of the layer
 * 
 */

Ext.define("viewer.viewercontroller.flamingo.FlamingoLayer",{
    enabledEvents: null,
    type: null,
    constructor :function (config){
        if (config.id){
            config.id=""+config.id;
            if((config.id).indexOf(":") != -1){
                config.id = (config.id).replace(/:/g,'_');
            }
        }
        this.enabledEvents=new Object();
        return this;
    },
    /**
     * Get's the frameworklayer: the viewer specific layer.
     */
    getFrameworkLayer : function(){
        if (this.map==null){
            return null;
        }
        return this.map.getFrameworkMap();
    },
    
    toXML : function(){
        Ext.Error.raise({msg: "FlamingoLayer.toXML(): .toXML() must be made!"});
    },

    getTagName : function(){
        Ext.Error.raise({msg: "FlamingoLayer.getTagName: .getTagName() must be made!"});
    },
    setOption : function(optionKey,optionValue){
        this.options[optionKey]=optionValue;
    },
    getId : function(){
        return this.id;
    },
    getFrameworkId: function(){
        return this.map.getId()+"_"+this.getId();
    },
    setAlpha : function (alpha){
        this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"setAlpha",alpha)
    },
    getAlpha : function (){
        return this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"getAlpha");
    },
    /**
     * Get the last getMap request array
     * @see viewer.viewerController.controller.Layer#getLastMapRequest
     */
    getLastMapRequest: function(){
        var request=this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"getLastGetMapRequest");
        if (request==null){
            return null;
        }
        return [request];
    },
    /**
     * Returns the type of the layer.
     */
    getType: function(){
        return this.type;
    },
    /**
     * reloads the framework map
     */
    reload: function(){
        return this.map.getFrameworkMap().callMethod(this.getFrameworkId(),"update");
    },
    /**
     * Overwrites the addListener function. Add's the event to allowexternalinterface of flamingo
     * so flamingo is allowed to broadcast the event.
     */
    addListener : function(event,handler,scope){
        //enable flamingo event broadcasting
        var flamEvent=this.map.mapComponent.eventList[event];
        if (flamEvent!=undefined){
            //if not enabled yet, add it
            if (this.enabledEvents[flamEvent]==undefined){
               this.map.getFrameworkMap().callMethod(this.map.mapComponent.getId(),"addAllowExternalInterface",this.getFrameworkId()+"."+flamEvent);
               this.enabledEvents[flamEvent]=true;
            }
        }
        /* fix for infinite loop:
         * If this is called from a layer that extends the FlamingoArcLayer the superclass is
         * that FlamingoArcLayer and this function is called again when this.superclass.function is called
         **/
        if (this.superclass.$className == "viewer.viewercontroller.flamingo.FlamingoArcLayer"){
            this.superclass.superclass.addListener.call(this,event,handler,scope);
        }else{
            this.superclass.addListener.call(this,event,handler,scope);
        }
        //viewer.viewercontroller.controller.Layer.superclass.addListener.call(this,event,handler,scope);
    },
    setVisible : function (visible){  
        this.visible = visible;
        
        if (this.options!=null){
            this.options["visible"] = visible;
        }
              
        if (this.map !=null){
            this.map.getFrameworkMap().callMethod(this.map.id + "_" + this.id, "setVisible", visible);
        }
    },
    /**
     * Get the visibility
     */
    getVisible : function (){
        if (this.map !=null){
            this.visible = this.map.getFrameworkMap().callMethod(this.map.id + "_" + this.id, "getVisible");
        }
        if (this.options!=null)
            this.options["visible"] = this.visible;
        return this.visible;
    },
    /**
     * Overwrite destroy, clear Listeners and forward to super.destroy
     */
    destroy: function(){        
        /* fix for infinite loop:
         * If this is called from a layer that extends the FlamingoArcLayer the superclass is
         * that FlamingoArcLayer and this function is called again when this.superclass.function is called
         **/
        if (this.superclass.$className == "viewer.viewercontroller.flamingo.FlamingoArcLayer"){
            this.superclass.superclass.destroy.call(this);
        }else{
            this.superclass.destroy.call(this);
        }
    }
    
});
{'fraction_non_alphanumeric': 0.12295081967213115, 'fraction_numerical': 0.00019751135690302193, 'mean_word_length': 2.138208862720793, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4257456', 'n_tokens_mistral': 2856, 'n_tokens_neox': 2762, 'n_words': 604}