<commit_before>/**
 * Canvas Module.
 * Todo. Go through the SVL library and remove all the unused public methods that are no longer used.
 * @param ribbon
 * @returns {{className: string}}
 * @constructor
 */
function Canvas(ribbon) {
    var self = {className: 'Canvas'};

    // Mouse status and mouse event callback functions
    var mouseStatus = {
        currX: 0,
        currY: 0,
        prevX: 0,
        prevY: 0,
        leftDownX: 0,
        leftDownY: 0,
        leftUpX: 0,
        leftUpY: 0,
        isLeftDown: false,
        prevMouseDownTime: 0,
        prevMouseUpTime: 0
    };
    // Properties
    var properties = {
        drawingMode: "point",
        evaluationMode: false,
        radiusThresh: 7,
        showDeleteMenuTimeOutToken: undefined,
        tempPointRadius: 5
    };

    var pointParameters = {
        'fillStyleInnerCircle': 'rgba(0,0,0,1)', // labelColor.fillStyle,
        'lineWidthOuterCircle': 2,
        'iconImagePath': undefined, // iconImagePath,
        'radiusInnerCircle': 5, //13,
        'radiusOuterCircle': 6, //14,
        'strokeStyleOuterCircle': 'rgba(255,255,255,1)',
        'storedInDatabase': false
    };

    var status = {
        currentLabel: null,
        disableLabelDelete: false,
        disableLabelEdit: false,
        disableLabeling: false,
        disableWalking: false,
        drawing: false,

        lockCurrentLabel: false,
        lockDisableLabelDelete: false,
        lockDisableLabelEdit: false,
        lockDisableLabeling: false,
        svImageCoordinatesAdjusted: false,
        totalLabelCount: 0,
        'visibilityMenu': 'hidden'
    };

    var lock = {
        showLabelTag: false
    };

    // Canvas context
    var canvasProperties = {'height': 0, 'width': 0};
    var ctx;

    var tempPath = [];

    // Right click menu
    var rightClickMenu = undefined;

    // Path elements
    var systemLabels = [];
    var labels = [];

    // Initialization
    function _init() {
        var el = document.getElementById("label-canvas");
        if (!el) {
            return false;
        }
        ctx = el.getContext('2d');
        canvasProperties.width = el.width;
        canvasProperties.height = el.height;

        // Attach listeners to dom elements
        if (svl.ui.canvas.drawingLayer) {
            svl.ui.canvas.drawingLayer.bind('mousedown', handleDrawingLayerMouseDown);
            svl.ui.canvas.drawingLayer.bind('mouseup', handleDrawingLayerMouseUp);
            svl.ui.canvas.drawingLayer.bind('mousemove', handleDrawingLayerMouseMove);
            $("#interaction-area-holder").on('mouseleave', handleDrawingLayerMouseOut);
        }
        if (svl.ui.canvas.deleteIcon) {
            svl.ui.canvas.deleteIcon.bind("click", labelDeleteIconClick);
        }

        // Point radius
        if (properties.drawingMode == 'path') {
            properties.pointInnerCircleRadius = 5;
            properties.pointOuterCircleRadius = 6;
        } else {
            properties.pointInnerCircleRadius = 13;
            properties.pointOuterCircleRadius = 14;
        }
    }

    /**
     * Finish up labeling.
     * Clean this method when I get a chance.....
     */
    function closeLabelPath() {

        var labelType = ribbon.getStatus('selectedLabelType');
        var labelColor = util.misc.getLabelColors()[labelType],
            labelDescription = util.misc.getLabelDescriptions(labelType),
            iconImagePath = util.misc.getIconImagePaths(labelDescription.id).iconImagePath;

        pointParameters.fillStyleInnerCircle = labelColor.fillStyle;
        pointParameters.iconImagePath = iconImagePath;
        pointParameters.radiusInnerCircle = properties.pointInnerCircleRadius;
        pointParameters.radiusOuterCircle = properties.pointOuterCircleRadius;

        var points = [], pov = svl.map.getPov();

        for (var i = 0, pathLen = tempPath.length; i < pathLen; i++) {
            points.push(new Point(svl, tempPath[i].x, tempPath[i].y, pov, pointParameters));
        }

        var path = new Path(svl, points, {});
        var latlng = svl.map.getPosition();
        var param = {
            canvasWidth: svl.canvasWidth,
            canvasHeight: svl.canvasHeight,
            canvasDistortionAlphaX: svl.alpha_x,
            canvasDistortionAlphaY: svl.alpha_y,
            //labelId: svl.getLabelCounter(),
            labelType: labelDescription.id,
            labelDescription: labelDescription.text,
            labelFillStyle: labelColor.fillStyle,
            panoId: svl.map.getPanoId(),
            panoramaLat: latlng.lat,
            panoramaLng: latlng.lng,
            panoramaHeading: pov.heading,
            panoramaPitch: pov.pitch,
            panoramaZoom: pov.zoom,
            svImageWidth: svl.svImageWidth,
            svImageHeight: svl.svImageHeight,
            svMode: 'html4'
        };
        if (("panorama" in svl) && ("getPhotographerPov" in svl.panorama)) {
            var photographerPov = svl.panorama.getPhotographerPov();
            param.photographerHeading = photographerPov.heading;
            param.photographerPitch = photographerPov.pitch;
        }

        status.currentLabel = svl.labelFactory.create(path, param);
        labels.push(status.currentLabel);  // Todo. Delete this. I think this is not necessary.
        svl.labelContainer.push(status.currentLabel);


        // Todo. Instead of calling the contextMenu show, throw an Canvas:closeLabelPath event.
        if ('contextMenu' in svl) {
            svl.contextMenu.show(tempPath[0].x, tempPath[0].y, {
                targetLabel: status.currentLabel,
                targetLabelColor: labelColor.fillStyle
            });
            if(labelType === "Other"){
              //no tooltips for other
              $('#severity-one').tooltip('destroy');
              $('#severity-three').tooltip('destroy');
              $('#severity-five').tooltip('destroy');
            }else{
              //update tooltips
              $('#severity-one').tooltip('destroy').tooltip({html: true, delay: { "show": 500, "hide": 100 }, container: "#severity-one", title:"Severity Level 1 Example<br/><img src='/assets/javascripts/SVLabel/img/severity_popups/" + labelType + "_Severity1.png' height='110' alt='CRseverity 1'/><br/><i>Press Keys 1-5 for Severity</i>"});
              $('#severity-three').tooltip('destroy').tooltip({html: true, delay: { "show": 500, "hide": 100 }, container: "#severity-three", title:"Severity Level 3 Example<br/><img src='/assets/javascripts/SVLabel/img/severity_popups/" + labelType + "_Severity3.png' height='110' alt='CRseverity 3'/><br/><i>Press Keys 1-5 for Severity</i>"});
              $('#severity-five').tooltip('destroy').tooltip({html: true, delay: { "show": 500, "hide": 100 }, container: "#severity-five", title:"Severity Level 5 Example<br/><img src='/assets/javascripts/SVLabel/img/severity_popups/" + labelType + "_Severity5.png' height='110' alt='CRseverity 5'/><br/><i>Press Keys 1-5 for Severity</i>"});
            }
          }

        // Todo. Again, thrown an event (e.g., Canvas:closeLabelPath) instead of svl.onboarding.pushOnboardingLabel invocation.
        if ('onboarding' in svl && svl.onboarding && svl.onboarding.isOnboarding()) {
            svl.onboarding.pushOnboardingLabel(status.currentLabel);
        }

        svl.tracker.push('LabelingCanvas_FinishLabeling', {
            labelType: labelDescription.id,
            canvasX: tempPath[0].x,
            canvasY: tempPath[0].y
        }, {
            temporaryLabelId: status.currentLabel.getProperty('temporary_label_id')
        });
        svl.actionStack.push('addLabel', status.currentLabel);

        // Sound effect
        if ('audioEffect' in svl) {
            svl.audioEffect.play('drip');
        }

        // Initialize the tempPath
        tempPath = [];
        ribbon.backToWalk();

    }<commit_msg>fixed filepaths for severity images<commit_after>/**
 * Canvas Module.
 * Todo. Go through the SVL library and remove all the unused public methods that are no longer used.
 * @param ribbon
 * @returns {{className: string}}
 * @constructor
 */
function Canvas(ribbon) {
    var self = {className: 'Canvas'};

    // Mouse status and mouse event callback functions
    var mouseStatus = {
        currX: 0,
        currY: 0,
        prevX: 0,
        prevY: 0,
        leftDownX: 0,
        leftDownY: 0,
        leftUpX: 0,
        leftUpY: 0,
        isLeftDown: false,
        prevMouseDownTime: 0,
        prevMouseUpTime: 0
    };
    // Properties
    var properties = {
        drawingMode: "point",
        evaluationMode: false,
        radiusThresh: 7,
        showDeleteMenuTimeOutToken: undefined,
        tempPointRadius: 5
    };

    var pointParameters = {
        'fillStyleInnerCircle': 'rgba(0,0,0,1)', // labelColor.fillStyle,
        'lineWidthOuterCircle': 2,
        'iconImagePath': undefined, // iconImagePath,
        'radiusInnerCircle': 5, //13,
        'radiusOuterCircle': 6, //14,
        'strokeStyleOuterCircle': 'rgba(255,255,255,1)',
        'storedInDatabase': false
    };

    var status = {
        currentLabel: null,
        disableLabelDelete: false,
        disableLabelEdit: false,
        disableLabeling: false,
        disableWalking: false,
        drawing: false,

        lockCurrentLabel: false,
        lockDisableLabelDelete: false,
        lockDisableLabelEdit: false,
        lockDisableLabeling: false,
        svImageCoordinatesAdjusted: false,
        totalLabelCount: 0,
        'visibilityMenu': 'hidden'
    };

    var lock = {
        showLabelTag: false
    };

    // Canvas context
    var canvasProperties = {'height': 0, 'width': 0};
    var ctx;

    var tempPath = [];

    // Right click menu
    var rightClickMenu = undefined;

    // Path elements
    var systemLabels = [];
    var labels = [];

    // Initialization
    function _init() {
        var el = document.getElementById("label-canvas");
        if (!el) {
            return false;
        }
        ctx = el.getContext('2d');
        canvasProperties.width = el.width;
        canvasProperties.height = el.height;

        // Attach listeners to dom elements
        if (svl.ui.canvas.drawingLayer) {
            svl.ui.canvas.drawingLayer.bind('mousedown', handleDrawingLayerMouseDown);
            svl.ui.canvas.drawingLayer.bind('mouseup', handleDrawingLayerMouseUp);
            svl.ui.canvas.drawingLayer.bind('mousemove', handleDrawingLayerMouseMove);
            $("#interaction-area-holder").on('mouseleave', handleDrawingLayerMouseOut);
        }
        if (svl.ui.canvas.deleteIcon) {
            svl.ui.canvas.deleteIcon.bind("click", labelDeleteIconClick);
        }

        // Point radius
        if (properties.drawingMode == 'path') {
            properties.pointInnerCircleRadius = 5;
            properties.pointOuterCircleRadius = 6;
        } else {
            properties.pointInnerCircleRadius = 13;
            properties.pointOuterCircleRadius = 14;
        }
    }

    /**
     * Finish up labeling.
     * Clean this method when I get a chance.....
     */
    function closeLabelPath() {

        var labelType = ribbon.getStatus('selectedLabelType');
        var labelColor = util.misc.getLabelColors()[labelType],
            labelDescription = util.misc.getLabelDescriptions(labelType),
            iconImagePath = util.misc.getIconImagePaths(labelDescription.id).iconImagePath;

        pointParameters.fillStyleInnerCircle = labelColor.fillStyle;
        pointParameters.iconImagePath = iconImagePath;
        pointParameters.radiusInnerCircle = properties.pointInnerCircleRadius;
        pointParameters.radiusOuterCircle = properties.pointOuterCircleRadius;

        var points = [], pov = svl.map.getPov();

        for (var i = 0, pathLen = tempPath.length; i < pathLen; i++) {
            points.push(new Point(svl, tempPath[i].x, tempPath[i].y, pov, pointParameters));
        }

        var path = new Path(svl, points, {});
        var latlng = svl.map.getPosition();
        var param = {
            canvasWidth: svl.canvasWidth,
            canvasHeight: svl.canvasHeight,
            canvasDistortionAlphaX: svl.alpha_x,
            canvasDistortionAlphaY: svl.alpha_y,
            //labelId: svl.getLabelCounter(),
            labelType: labelDescription.id,
            labelDescription: labelDescription.text,
            labelFillStyle: labelColor.fillStyle,
            panoId: svl.map.getPanoId(),
            panoramaLat: latlng.lat,
            panoramaLng: latlng.lng,
            panoramaHeading: pov.heading,
            panoramaPitch: pov.pitch,
            panoramaZoom: pov.zoom,
            svImageWidth: svl.svImageWidth,
            svImageHeight: svl.svImageHeight,
            svMode: 'html4'
        };
        if (("panorama" in svl) && ("getPhotographerPov" in svl.panorama)) {
            var photographerPov = svl.panorama.getPhotographerPov();
            param.photographerHeading = photographerPov.heading;
            param.photographerPitch = photographerPov.pitch;
        }

        status.currentLabel = svl.labelFactory.create(path, param);
        labels.push(status.currentLabel);  // Todo. Delete this. I think this is not necessary.
        svl.labelContainer.push(status.currentLabel);


        // Todo. Instead of calling the contextMenu show, throw an Canvas:closeLabelPath event.
        if ('contextMenu' in svl) {
            svl.contextMenu.show(tempPath[0].x, tempPath[0].y, {
                targetLabel: status.currentLabel,
                targetLabelColor: labelColor.fillStyle
            });
            if(labelType === "Other"){
              //no tooltips for other
              $('#severity-one').tooltip('destroy');
              $('#severity-three').tooltip('destroy');
              $('#severity-five').tooltip('destroy');
            }else{
              //update tooltips
              $('#severity-one').tooltip('destroy').tooltip({html: true, delay: { "show": 500, "hide": 100 }, container: "#severity-one", title:"Severity Level 1 Example<br/><img src='/assets/javascripts/SVLabel/img/severity_popups/" + labelType + "_Severity1.PNG' height='110' alt='CRseverity 1'/><br/><i>Press Keys 1-5 for Severity</i>"});
              $('#severity-three').tooltip('destroy').tooltip({html: true, delay: { "show": 500, "hide": 100 }, container: "#severity-three", title:"Severity Level 3 Example<br/><img src='/assets/javascripts/SVLabel/img/severity_popups/" + labelType + "_Severity3.PNG' height='110' alt='CRseverity 3'/><br/><i>Press Keys 1-5 for Severity</i>"});
              $('#severity-five').tooltip('destroy').tooltip({html: true, delay: { "show": 500, "hide": 100 }, container: "#severity-five", title:"Severity Level 5 Example<br/><img src='/assets/javascripts/SVLabel/img/severity_popups/" + labelType + "_Severity5.PNG' height='110' alt='CRseverity 5'/><br/><i>Press Keys 1-5 for Severity</i>"});
            }
          }

        // Todo. Again, thrown an event (e.g., Canvas:closeLabelPath) instead of svl.onboarding.pushOnboardingLabel invocation.
        if ('onboarding' in svl && svl.onboarding && svl.onboarding.isOnboarding()) {
            svl.onboarding.pushOnboardingLabel(status.currentLabel);
        }

        svl.tracker.push('LabelingCanvas_FinishLabeling', {
            labelType: labelDescription.id,
            canvasX: tempPath[0].x,
            canvasY: tempPath[0].y
        }, {
            temporaryLabelId: status.currentLabel.getProperty('temporary_label_id')
        });
        svl.actionStack.push('addLabel', status.currentLabel);

        // Sound effect
        if ('audioEffect' in svl) {
            svl.audioEffect.play('drip');
        }

        // Initialize the tempPath
        tempPath = [];
        ribbon.backToWalk();

    }
{'fraction_non_alphanumeric': 0.1234521101844832, 'fraction_numerical': 0.011498610058124843, 'mean_word_length': 2.3543123543123543, 'pattern_counts': {'":': 12, '<': 35, '<?xml version=': 0, '>': 33, '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': '5559783', 'n_tokens_mistral': 4798, 'n_tokens_neox': 4555, 'n_words': 938}