<commit_before>import { Component, OnInit, Input } from '@angular/core';
import { IAddFigComponent } from '../IAddFigComponent';
import { Line } from '../../../../shapes/models/line';
import { Point } from '../../../../shapes/models/point';

interface ILineContainer {
    top: number;
    left: number;
    width: number;
    height: number;
    zIndex: number;
}

@Component({
    selector: 'de-line',
    templateUrl: './line.component.html',
    styleUrls: ['./line.component.scss']
})
// I don't know what is better so I choosed drawing svg with sizes like diagram area size.
// After a line have drawed svg container change size to line sizes
export class LineComponent implements OnInit, IAddFigComponent {
    @Input() data: any;

    lineContainer: ILineContainer;
    line: Line;

    ngOnInit() {
        const areaSize = this.data.areaSize;
        this.lineContainer = {
            width: areaSize.width,
            height: areaSize.height,
            top: 0,
            left: 0,
            zIndex: 100
        };

        let subscription = this.data.mousePos
            .subscribe(event => {
                const x = event.offsetX;
                const y = event.offsetY;

                switch (event.type) {
                    case 'mouseup':
                        this.line.endCoords = new Point(x, y);
                        this.lineContainer.zIndex = 1;
                        subscription.unsubscribe();
                        break;
                    case 'mousemove':
                        this.line.endCoords = new Point(x, y);
                        break;
                    case 'mousedown':
                        const currPoint = new Point(x, y);
                        this.line = new Line(currPoint, currPoint);
                        break;
                    default:
                        break;
                }
            });
    }
}<commit_msg>z index chaged to 0 because line must be under other elements<commit_after>import { Component, OnInit, Input } from '@angular/core';
import { IAddFigComponent } from '../IAddFigComponent';
import { Line } from '../../../../shapes/models/line';
import { Point } from '../../../../shapes/models/point';

interface ILineContainer {
    top: number;
    left: number;
    width: number;
    height: number;
    zIndex: number;
}

@Component({
    selector: 'de-line',
    templateUrl: './line.component.html',
    styleUrls: ['./line.component.scss']
})
// I don't know what is better so I choosed drawing svg with sizes like diagram area size.
// After a line have drawed svg container change size to line sizes
export class LineComponent implements OnInit, IAddFigComponent {
    @Input() data: any;

    lineContainer: ILineContainer;
    line: Line;

    ngOnInit() {
        const areaSize = this.data.areaSize;
        this.lineContainer = {
            width: areaSize.width,
            height: areaSize.height,
            top: 0,
            left: 0,
            zIndex: 100
        };

        let subscription = this.data.mousePos
            .subscribe(event => {
                const x = event.offsetX;
                const y = event.offsetY;

                switch (event.type) {
                    case 'mouseup':
                        this.line.endCoords = new Point(x, y);
                        this.lineContainer.zIndex = 0;
                        subscription.unsubscribe();
                        break;
                    case 'mousemove':
                        this.line.endCoords = new Point(x, y);
                        break;
                    case 'mousedown':
                        const currPoint = new Point(x, y);
                        this.line = new Line(currPoint, currPoint);
                        break;
                    default:
                        break;
                }
            });
    }
}
{'fraction_non_alphanumeric': 0.10743801652892562, 'fraction_numerical': 0.0033574380165289257, 'mean_word_length': 1.4236545682102628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4889427', 'n_tokens_mistral': 1028, 'n_tokens_neox': 977, 'n_words': 285}