<commit_before>import {StructureViewObject} from "./structure-view-object";
import {StructureViewObjectListener} from "./structure-view-object-listener";
import {StructureViewNodeRow} from "./structure-view-row";
import {SelectionService} from "./selection-service";
import {Point} from "./point";
import {StructureViewModelNode} from "../../structure-view-model/structure-view-model-node";
import {StructureViewUtil} from "./structure-view-util";


export class StructureViewNode extends StructureViewObject implements StructureViewObjectListener {
    public static readonly OFFSET_X = 10;
    private static readonly DEFAULT_HEIGHT = 30;
    private static readonly PADDING_TOP = 40;
    private static readonly PADDING_BOTTOM = 30;
    private static readonly ICON_SIZE = 24;
    private static readonly ICON_PADDING = 5;
    private static readonly TEXT_PADDING = 10;

    canvas: JQuery;
    rect: JQuery;
    icon: JQuery;
    text: JQuery;
    model: StructureViewModelNode;
    parent: StructureViewNode;
    rows: Array<StructureViewNodeRow> = [];
    x: number = 0;
    y: number = 0;
    width: number = 0;
    height: number = 0;
    expanded: boolean = false;
    visible: boolean;
    selected: boolean;

    constructor(parent: StructureViewNode, model: StructureViewModelNode, canvas: JQuery) {
        super();

        this.parent = parent;
        this.model = model;
        this.canvas = canvas;

        this.createRect();
        this.createIcon();
        this.createText();
        this.updateSize();
    }

    private createRect() {
        this.rect = StructureViewUtil.createSVGElement("rect");
        this.rect.attr({
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0,
            "fill": "#5d5d5d"
        });
        this.rect.css({
            "stroke-width": 1.0
        });

        this.updateRectColors();
        this.rect.click(() => this.onClick());
        this.rect.dblclick(() => this.onDoubleClick());
        this.canvas.append(this.rect);
    }

    private updateRectColors(): void {
        this.rect.attr({
            "stroke": this.selected ? "#ddcb00" : "#7cbe00"
        });
        this.rect.css({
            "fill-opacity": this.expanded ? 1.0 : 0.0,
            "stroke-opacity": this.expanded || this.selected ? 1.0 : 0.0
        });
    }

    private createIcon() {
        let iconFile = this.model.isGroup
            ? "assets/ic_folder_black_24px.svg"
            : "assets/ic_insert_drive_file_black_24px.svg";
        this.icon = StructureViewUtil.createSVGElement("image");
        this.icon.attr({
            "href": iconFile,
            "preserveAspectRatio": "none",
            "x": 0,
            "y": 0,
            "width": StructureViewNode.ICON_SIZE,
            "height": StructureViewNode.ICON_SIZE
        });
        this.icon.click(() => this.onClick());
        this.icon.dblclick(() => this.onDoubleClick());
        this.canvas.append(this.icon);
    }

    private createText() {
        this.text = StructureViewUtil.createSVGElement("text");
        this.text.attr({
            "x": 0,
            "y": 0,
            "fill": "#bcbcbc",
        });
        this.text.css({<commit_msg>Icons not showing up in FireFox<commit_after>import {StructureViewObject} from "./structure-view-object";
import {StructureViewObjectListener} from "./structure-view-object-listener";
import {StructureViewNodeRow} from "./structure-view-row";
import {SelectionService} from "./selection-service";
import {Point} from "./point";
import {StructureViewModelNode} from "../../structure-view-model/structure-view-model-node";
import {StructureViewUtil} from "./structure-view-util";


export class StructureViewNode extends StructureViewObject implements StructureViewObjectListener {
    public static readonly OFFSET_X = 10;
    private static readonly DEFAULT_HEIGHT = 30;
    private static readonly PADDING_TOP = 40;
    private static readonly PADDING_BOTTOM = 30;
    private static readonly ICON_SIZE = 24;
    private static readonly ICON_PADDING = 5;
    private static readonly TEXT_PADDING = 10;

    canvas: JQuery;
    rect: JQuery;
    icon: JQuery;
    text: JQuery;
    model: StructureViewModelNode;
    parent: StructureViewNode;
    rows: Array<StructureViewNodeRow> = [];
    x: number = 0;
    y: number = 0;
    width: number = 0;
    height: number = 0;
    expanded: boolean = false;
    visible: boolean;
    selected: boolean;

    constructor(parent: StructureViewNode, model: StructureViewModelNode, canvas: JQuery) {
        super();

        this.parent = parent;
        this.model = model;
        this.canvas = canvas;

        this.createRect();
        this.createIcon();
        this.createText();
        this.updateSize();
    }

    private createRect() {
        this.rect = StructureViewUtil.createSVGElement("rect");
        this.rect.attr({
            "x": 0,
            "y": 0,
            "width": 0,
            "height": 0,
            "fill": "#5d5d5d"
        });
        this.rect.css({
            "stroke-width": 1.0
        });

        this.updateRectColors();
        this.rect.click(() => this.onClick());
        this.rect.dblclick(() => this.onDoubleClick());
        this.canvas.append(this.rect);
    }

    private updateRectColors(): void {
        this.rect.attr({
            "stroke": this.selected ? "#ddcb00" : "#7cbe00"
        });
        this.rect.css({
            "fill-opacity": this.expanded ? 1.0 : 0.0,
            "stroke-opacity": this.expanded || this.selected ? 1.0 : 0.0
        });
    }

    private createIcon() {
        let iconFile = this.model.isGroup
            ? "assets/ic_folder_black_24px.svg"
            : "assets/ic_insert_drive_file_black_24px.svg";
        this.icon = StructureViewUtil.createSVGElement("image");
        this.icon.attr({
            "preserveAspectRatio": "none",
            "x": 0,
            "y": 0,
            "width": StructureViewNode.ICON_SIZE,
            "height": StructureViewNode.ICON_SIZE
        });
        this.icon.get(0).setAttributeNS("http://www.w3.org/1999/xlink", "href", iconFile);
        this.icon.click(() => this.onClick());
        this.icon.dblclick(() => this.onDoubleClick());
        this.canvas.append(this.icon);
    }

    private createText() {
        this.text = StructureViewUtil.createSVGElement("text");
        this.text.attr({
            "x": 0,
            "y": 0,
            "fill": "#bcbcbc",
        });
        this.text.css({
{'fraction_non_alphanumeric': 0.13447057015521746, 'fraction_numerical': 0.015368065160596281, 'mean_word_length': 2.3102746693794507, 'pattern_counts': {'":': 35, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '7549350', 'n_tokens_mistral': 1999, 'n_tokens_neox': 1883, 'n_words': 407}