<commit_before>/**
 * Node class.
 *
 * @copyright   copyright (c) 2015 by <NAME>
 * @author      <NAME> <<EMAIL>>
 */

;(function(flowdesigner) {
    var connector = flowdesigner.connector;

    var id = 0;

    /**
     * Constructor.
     *
     * @param   diagram         diagram             Diagram instance.
     * @param   object          data                Node configuration.
     */
    function node(dia, data)
    {
        this.diagram = dia;

        this.data = $.extend({
            x: 0,
            y: 0,
            label: ''
        }, data);
        this.node = null;
        this.label = null;

        this.registry = [];

        if (!('id' in this.data)) {
            this.data.id = 'node-' + (++id);
        }

        // register input connectors
        this.node_input.forEach(function(data, idx) {
            var cn = new connector('input', this, data);

            this.registry.push(this.diagram.wire.registerConnector(cn));
        }, this);

        // register output connectors
        this.node_output.forEach(function(data, idx) {
            var cn = new connector('output', this, data);

            this.registry.push(this.diagram.wire.registerConnector(cn));
        }, this);
    }

    /**
     * Input connectors.
     *
     * @type    array
     */
    node.prototype.node_input = [];

    /**
     * Output connectors.
     *
     * @type    array
     */
    node.prototype.node_output = [];

    /**
     * Width.
     *
     * @type    int
     */
    node.prototype.node_width = 250;

    /**
     * Default node height.
     *
     * @type    int
     */
    node.prototype.node_height = 40;

    /**
     * Whether node has a 'remove' button.
     *
     * @type    bool
     */
    node.prototype.node_can_remove = true;

    /**
     * Line height for title and connectors in node.
     *
     * @type    int
     */
    node.prototype.node_line_height = 15;

    /**
     * Default node border color.
     *
     * @type    string
     */
    node.prototype.node_border_color = 'black';

    /**
     * Default node background color.
     *
     * @type    string
     */
    node.prototype.node_color = '#000055';

    /**
     * Default node text color.
     *
     * @type    string
     */
    node.prototype.node_font_color = 'white';

    /**
     * Default font family.
     *
     * @type    string
     */
    node.prototype.node_font_family = 'Verdana, Arial, Helvetica, Sans-Serif';

    /**
     * Default font size.
     *
     * @type    int
     */
    node.prototype.node_font_size = 12;

    /**
     * Default node opacity.
     *
     * @type    string
     */
    node.prototype.node_opacity = 0.75;

    /**
     * Default connector radius.
     *
     * @type    int
     */
    node.prototype.connector_radius = 5;

    /**
     * Destroy node.
     */
    node.prototype.destroy = function()
    {
        this.registry = this.registry.filter(function(id) {
            this.diagram.wire.unregisterConnector(id);

            return false;
        }, this);

        this.node.remove();
    }

    /**
     * Return ID of node.
     *
     * @return  string                              ID of node.
     */
    node.prototype.getId = function()
    {
        return this.data.id;
    }

    /**
     * Return node data.
     *
     * @return  object                              Node data.
     */
    node.prototype.getData = function()
    {
        return $.extend({}, this.data);
    }

    /**
     * Return rectangle of node (x, y, width, height).
     *
     * @return  object                              Rectangle.
     */
    node.prototype.getRect = function()
    {
        var cn = Math.max(this.node_input.length, this.node_output.length);

        return {
            'x':      (isNaN(this.data.x) ? null : this.data.x),
            'y':      (isNaN(this.data.y) ? null : this.data.y),
            'width':  this.node_width,
            'height': this.node_height + cn * this.node_line_height
        };
    }

    /**
     * Render node.
     */
    node.prototype.render = function(pos)
    {
        // render node
        var layer = this.diagram.getLayer('nodes');

        var cn = Math.max(this.node_input.length, this.node_output.length);
        var me = this;
        var drag = false;
        var rect;
<commit_msg>added method to change label<commit_after>/**
 * Node class.
 *
 * @copyright   copyright (c) 2015 by <NAME>
 * @author      <NAME> <<EMAIL>>
 */

;(function(flowdesigner) {
    var connector = flowdesigner.connector;

    var id = 0;

    /**
     * Constructor.
     *
     * @param   diagram         diagram             Diagram instance.
     * @param   object          data                Node configuration.
     */
    function node(dia, data)
    {
        this.diagram = dia;

        this.data = $.extend({
            x: 0,
            y: 0,
            label: ''
        }, data);
        this.node = null;
        this.label = null;

        this.registry = [];

        if (!('id' in this.data)) {
            this.data.id = 'node-' + (++id);
        }

        // register input connectors
        this.node_input.forEach(function(data, idx) {
            var cn = new connector('input', this, data);

            this.registry.push(this.diagram.wire.registerConnector(cn));
        }, this);

        // register output connectors
        this.node_output.forEach(function(data, idx) {
            var cn = new connector('output', this, data);

            this.registry.push(this.diagram.wire.registerConnector(cn));
        }, this);
    }

    /**
     * Input connectors.
     *
     * @type    array
     */
    node.prototype.node_input = [];

    /**
     * Output connectors.
     *
     * @type    array
     */
    node.prototype.node_output = [];

    /**
     * Width.
     *
     * @type    int
     */
    node.prototype.node_width = 250;

    /**
     * Default node height.
     *
     * @type    int
     */
    node.prototype.node_height = 40;

    /**
     * Whether node has a 'remove' button.
     *
     * @type    bool
     */
    node.prototype.node_can_remove = true;

    /**
     * Line height for title and connectors in node.
     *
     * @type    int
     */
    node.prototype.node_line_height = 15;

    /**
     * Default node border color.
     *
     * @type    string
     */
    node.prototype.node_border_color = 'black';

    /**
     * Default node background color.
     *
     * @type    string
     */
    node.prototype.node_color = '#000055';

    /**
     * Default node text color.
     *
     * @type    string
     */
    node.prototype.node_font_color = 'white';

    /**
     * Default font family.
     *
     * @type    string
     */
    node.prototype.node_font_family = 'Verdana, Arial, Helvetica, Sans-Serif';

    /**
     * Default font size.
     *
     * @type    int
     */
    node.prototype.node_font_size = 12;

    /**
     * Default node opacity.
     *
     * @type    string
     */
    node.prototype.node_opacity = 0.75;

    /**
     * Default connector radius.
     *
     * @type    int
     */
    node.prototype.connector_radius = 5;

    /**
     * Destroy node.
     */
    node.prototype.destroy = function()
    {
        this.registry = this.registry.filter(function(id) {
            this.diagram.wire.unregisterConnector(id);

            return false;
        }, this);

        this.node.remove();
    }

    /**
     * Return ID of node.
     *
     * @return  string                              ID of node.
     */
    node.prototype.getId = function()
    {
        return this.data.id;
    }

    /**
     * Return node data.
     *
     * @return  object                              Node data.
     */
    node.prototype.getData = function()
    {
        return $.extend({}, this.data);
    }

    /**
     * Return rectangle of node (x, y, width, height).
     *
     * @return  object                              Rectangle.
     */
    node.prototype.getRect = function()
    {
        var cn = Math.max(this.node_input.length, this.node_output.length);

        return {
            'x':      (isNaN(this.data.x) ? null : this.data.x),
            'y':      (isNaN(this.data.y) ? null : this.data.y),
            'width':  this.node_width,
            'height': this.node_height + cn * this.node_line_height
        };
    }

    /**
     * Set/change label of node.
     *
     * @param   string              label           Label to set.
     */
    node.prototype.setLabel = function(label)
    {
        this.data.label = label;

        if (this.label != null) {
            this.label.content = label;
        }
    }

    /**
     * Render node.
     */
    node.prototype.render = function(pos)
    {
        // render node
        var layer = this.diagram.getLayer('nodes');

        var cn = Math.max(this.node_input.length, this.node_output.length);
        var me = this;
        var drag = false;
        var rect;

{'fraction_non_alphanumeric': 0.13110367892976588, 'fraction_numerical': 0.005797101449275362, 'mean_word_length': 1.3948211425520556, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '445367', 'n_tokens_mistral': 2823, 'n_tokens_neox': 2702, 'n_words': 561}