<commit_before>/* 
 * The MIT License
 *
 * Copyright 2017 sz2.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

import { RectangularProgressBar, RectangularProgressBarOptions } from 'lib/Graphics/PIXIGauge';
import { BitmapTextNumericIndicator } from 'lib/Graphics/PIXIGauge';
import { NumericIndicator } from 'lib/Graphics/PIXIGauge';

import * as PIXI from 'pixi.js';

require("./DigiTachoTexture.json");
require("./DigiTachoTexture.png");
//require("../fonts/font.css");
//require("../fonts/GNU-Freefonts/FreeSansBold.otf");
//require("../fonts/AudioWide/Audiowide-Regular.ttf");

require("./SpeedMeterFont.fnt");
require("./SpeedMeterFont_0.png");
require("./GearPosFont.fnt");
require("./GearPosFont_0.png");

export class DigiTachoPanel extends PIXI.Container {
    private tachoProgressBar: RectangularProgressBar;

    private speedLabel: NumericIndicator;
    private geasposLabel: PIXI.BitmapText;

    private speed = 0;
    private tacho = 0;
    private gearPos = "N";

    static get RequestedTexturePath(): string[] {
        return ["img/DigiTachoTexture.json", "img/GearPosFont.fnt", "img/SpeedMeterFont.fnt"];
    }

    static get RequestedFontFamily(): string[] {
        return [];
    }

    static get RequestedFontCSSURL(): string[] {
        return [];
    }

    get Speed(): number { return this.speed; }
    set Speed(speed: number) {
        this.speed = speed;
        this.speedLabel.Value = speed;
    }

    get Tacho(): number { return this.tacho }
    set Tacho(tacho: number) {
        this.tacho = tacho;
        this.tachoProgressBar.Value = tacho;
        this.tachoProgressBar.update();
    }

    get GearPos(): string { return this.gearPos }
    set GearPos(gearPos: string) {
        this.gearPos = gearPos;
        this.geasposLabel.text = gearPos;
    }

    constructor() {
        super();
        const gaugeset = this.create();
        this.tachoProgressBar = gaugeset.tachoProgressBar;
        this.speedLabel = gaugeset.speedLabel;
        this.geasposLabel = gaugeset.gearLabel;
    }

    private create(): { tachoProgressBar: RectangularProgressBar, speedLabel: BitmapTextNumericIndicator, gearLabel: PIXI.BitmapText } {
        const backTexture = PIXI.Texture.from("DigiTachoBack");
        const tachoProgressBarTexture = PIXI.Texture.from("DigiTachoBar");
<commit_msg>Implement static factory method to DigiTachoPanel.ts<commit_after>/* 
 * The MIT License
 *
 * Copyright 2017 sz2.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

import { RectangularProgressBar, RectangularProgressBarOptions } from 'lib/Graphics/PIXIGauge';
import { BitmapTextNumericIndicator } from 'lib/Graphics/PIXIGauge';
import { NumericIndicator } from 'lib/Graphics/PIXIGauge';

import * as PIXI from 'pixi.js';
import { Assets } from '@pixi/assets';

require("./DigiTachoTexture.json");
require("./DigiTachoTexture.png");

require("./SpeedMeterFont.fnt");
require("./SpeedMeterFont_0.png");
require("./GearPosFont.fnt");
require("./GearPosFont_0.png");

export class DigiTachoPanel extends PIXI.Container {
    private tachoProgressBar: RectangularProgressBar;

    private speedLabel: NumericIndicator;
    private geasposLabel: PIXI.BitmapText;

    private speed = 0;
    private tacho = 0;
    private gearPos = "N";

    get Speed(): number { return this.speed; }
    set Speed(speed: number) {
        this.speed = speed;
        this.speedLabel.Value = speed;
    }

    get Tacho(): number { return this.tacho }
    set Tacho(tacho: number) {
        this.tacho = tacho;
        this.tachoProgressBar.Value = tacho;
        this.tachoProgressBar.update();
    }

    get GearPos(): string { return this.gearPos }
    set GearPos(gearPos: string) {
        this.gearPos = gearPos;
        this.geasposLabel.text = gearPos;
    }

    public static async create() {
        await Assets.load(["img/DigiTachoTexture.json", "img/GearPosFont.fnt", "img/SpeedMeterFont.fnt"]);
        const instance = new DigiTachoPanel();
        return instance;
    }

    private constructor() {
        super();
        const gaugeset = this.buildGaugeSet();
        this.tachoProgressBar = gaugeset.tachoProgressBar;
        this.speedLabel = gaugeset.speedLabel;
        this.geasposLabel = gaugeset.gearLabel;
    }

    private buildGaugeSet(): { tachoProgressBar: RectangularProgressBar, speedLabel: BitmapTextNumericIndicator, gearLabel: PIXI.BitmapText } {
        const backTexture = PIXI.Texture.from("DigiTachoBack");
        const tachoProgressBarTexture = PIXI.Texture.from("DigiTachoBar");

{'fraction_non_alphanumeric': 0.09902942068547164, 'fraction_numerical': 0.00272975432211101, 'mean_word_length': 3.64109781843772, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2390349', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1878, 'n_words': 601}