<commit_before>function Label(name, topleft, specArgs) {
    if (arguments.length) {
        this.getready(name, topleft, specArgs);
    }
}

//inherit from the Element prototype
Label.prototype = new Element();
//put the correct constructor reference back (not essential)
Label.prototype.constructor = Label;

Label.prototype.getready = function (name, topleft, specArgs) {
    //Reference the getready method from the parent class
    this.tempReady = Element.prototype.getready;
    //and run it as if it were part of this object
    this.tempReady(name, topleft);

    this.values = {"labelvalue" : 0};

    //By default, a label always draws itself when value is set.
    this.drawItself = true;
    
    this.width = specArgs.wh[0];
    this.height = specArgs.wh[1];

    this.completed = true;

};

// This methods returns true if the point given belongs to this element.
Label.prototype.isInROI = function (x, y) {
    if ((x > this.xOrigin) && (y > this.yOrigin)) {
        if ((x < (this.xOrigin + this.width)) && (y < (this.yOrigin + this.height))) {
            //console.log(this.name, "point ", x, y, " is in ROI ", this.xOrigin, this.yOrigin, this.xOrigin + this.width, this.yOrigin + this.height);
            return true;
        }
        //console.log(this.name, " ROI Handler: ", x, y, " is NOT in ROI ", this.xOrigin, this.yOrigin, this.xOrigin + this.width, this.yOrigin + this.height);
    }
    return false;
};

Label.prototype.onROI = function (start_x, start_y, curr_x, curr_y) {
    var ret = {"slot" : "labelvalue", "value" : this.values.labelvalue};
    return ret;
};

// Text filter automatically parses and translates the value.
// This one does nothing but round value. TODO this should be overridden
// and definitely NOT here.
Label.prototype.textFilter = function (value) {
    return value.toFixed(3);
};

Label.prototype.getDefaultValue = function () {
    return this.values.labelvalue;
};

Label.prototype.getFont = function (font) {
    return this.font;
};

// Setters
Label.prototype.setValue = function (slot, value) {

    if (this.textfilter !== undefined) {
        var temp_value = this.textFilter(value);
    }

    this.tempsetValue = Element.prototype.setValue;
    this.tempsetValue(slot, temp_value);
};
 
Label.prototype.refresh = function () {
        var text;
        if (this.drawClass === undefined) {
            throw new Error("Error: drawClass is undefined!");
        }
        else {
            // Maybe the filtering should be done here?
            text = this.values.labelvalue;
            // Draw yourself! This is per-class behaviour.
            //console.log (this.name, "'s drawClass is drawing itself!");
            this.drawClass.draw(text, this.xOrigin, this.yOrigin, this.width, this.height);
        }
    };<commit_msg>Label working with the new enhanced events modifications in UI.<commit_after>function Label(name, topleft, specArgs) {
    if (arguments.length) {
        this.getready(name, topleft, specArgs);
    }
}

//inherit from the Element prototype
Label.prototype = new Element();
//put the correct constructor reference back (not essential)
Label.prototype.constructor = Label;

Label.prototype.getready = function (name, topleft, specArgs) {
    //Reference the getready method from the parent class
    this.tempReady = Element.prototype.getready;
    //and run it as if it were part of this object
    this.tempReady(name, topleft);

    this.values = {"labelvalue" : 0};

    //By default, a label always draws itself when value is set.
    this.drawItself = true;
    
    this.width = specArgs.wh[0];
    this.height = specArgs.wh[1];

    this.completed = true;

};

// This methods returns true if the point given belongs to this element.
Label.prototype.isInROI = function (x, y) {
    if ((x > this.xOrigin) && (y > this.yOrigin)) {
        if ((x < (this.xOrigin + this.width)) && (y < (this.yOrigin + this.height))) {
            //console.log(this.name, "point ", x, y, " is in ROI ", this.xOrigin, this.yOrigin, this.xOrigin + this.width, this.yOrigin + this.height);
            return true;
        }
        //console.log(this.name, " ROI Handler: ", x, y, " is NOT in ROI ", this.xOrigin, this.yOrigin, this.xOrigin + this.width, this.yOrigin + this.height);
    }
    return false;
};

// Text filter automatically parses and translates the value.
// This one does nothing but round value. TODO this should be overridden
// and definitely NOT here.
Label.prototype.textFilter = function (value) {
    return value.toFixed(3);
};

Label.prototype.getDefaultValue = function () {
    return this.values.labelvalue;
};

// Setters
Label.prototype.setValue = function (slot, value) {

    if (this.textFilter !== undefined) {
        var temp_value = this.textFilter(value);
    }

    this.tempsetValue = Element.prototype.setValue;
    this.tempsetValue(slot, temp_value);
};
 
Label.prototype.refresh = function () {
    var text;
    if (this.drawClass === undefined) {
        throw new Error("Error: drawClass is undefined!");
    }
    else {
        // Maybe the filtering should be done here?
        text = this.values.labelvalue;
        // Draw yourself! This is per-class behaviour.
        //console.log (this.name, "'s drawClass is drawing itself!");
        this.drawClass.draw(text, this.xOrigin, this.yOrigin, this.width, this.height);
    }
};
{'fraction_non_alphanumeric': 0.1273031825795645, 'fraction_numerical': 0.00148892611204169, 'mean_word_length': 2.8661870503597124, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1327714', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1599, 'n_words': 480}