diff --git a/src/app/components/canvas/canvas.component.ts b/src/app/components/canvas/canvas.component.ts index 78836a4d3c8465d853a5c21c2d4d0d92312469b9..87f03401c937fbd34b0327fe9e225771d3db78e4 100644 --- a/src/app/components/canvas/canvas.component.ts +++ b/src/app/components/canvas/canvas.component.ts @@ -3,8 +3,8 @@ import { Component, Input, ViewChild, ElementRef, AfterViewInit } from "@angular @Component({ selector: "calc-canvas", template: `<canvas #canvas - [attr.width] = 'width' - [attr.height] = 'height'> + [attr.width]="width" + [attr.height]="height"> </canvas> ` }) @@ -19,19 +19,17 @@ export class CalcCanvasComponent implements AfterViewInit { @Input() public set width(w: number) { this._width = w; + this._calcCanvas.nativeElement.width = w; } public get height(): number { return this._calcCanvas.nativeElement.height; } - public get witdh() { - return this._width; - } - @Input() public set height(h: number) { this._height = h; + this._calcCanvas.nativeElement.height = h; } private _context2d: CanvasRenderingContext2D; @@ -49,7 +47,7 @@ export class CalcCanvasComponent implements AfterViewInit { } public clear() { - if (this._context2d != undefined) { + if (this._context2d) { this._context2d.clearRect(0, 0, this.width, this.height); } } @@ -69,7 +67,7 @@ export class CalcCanvasComponent implements AfterViewInit { } public fillText(s: string, x: number, y: number, align?: any) { - if (align != undefined) { + if (align) { this._context2d.textAlign = align; } this._context2d.fillText(s, x, y); diff --git a/src/app/components/section-canvas/section-canvas.component.ts b/src/app/components/section-canvas/section-canvas.component.ts index 5323ded5fbab3dc35b5b3967313e94fa4e71f8d0..68187ba48a23b14f8c1552c438c6ce2c5b91fdf7 100644 --- a/src/app/components/section-canvas/section-canvas.component.ts +++ b/src/app/components/section-canvas/section-canvas.component.ts @@ -10,8 +10,8 @@ import { CalcCanvasComponent } from "../canvas/canvas.component"; @Component({ selector: "section-canvas", template: `<calc-canvas #calcCanvas - [width] = 'size' - [height] = 'size'> + [width]="size" + [height]="size"> </calc-canvas> ` }) @@ -47,7 +47,7 @@ export class SectionCanvasComponent { public set section(s: acSection) { this._section = s; - if (this._section != undefined) { + if (this._section) { this.draw(); } } @@ -219,8 +219,8 @@ export class SectionCanvasComponent { return maxWidth; } catch (e) { - const r: Result = e as Result; - this.drawText("error : " + r.log.toString(), 0, 0); + const res: Result = e as Result; + this.drawText("error : " + res.log.toString(), 0, 0); } } @@ -281,7 +281,7 @@ export class SectionCanvasComponent { this._calcCanvas.drawEllipse(this.Xm2pix(x), this.Ym2pix(y), rX * this._scaleX, rY * this._scaleY, rot, start, end); } - private drawText(s: string, x: number, y: number, align: string = undefined) { + private drawText(s: string, x: number, y: number, align?: string) { this._calcCanvas.fillText(s, this.Xm2pix(x), this.Ym2pix(y), align); } diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts index 96854ef9b95638dbebd2a227580083c77446fdb7..965475284c1650dad9fa96c238afa8dfa6fed642 100644 --- a/src/app/components/section-results/section-results.component.ts +++ b/src/app/components/section-results/section-results.component.ts @@ -40,7 +40,7 @@ export class SectionResultsComponent implements DoCheck { this._resultElement = undefined; this._results = undefined; - if (rs != undefined) { + if (rs) { for (const r of rs) { if (r instanceof SectionResults) { this._results = r; @@ -52,7 +52,7 @@ export class SectionResultsComponent implements DoCheck { } public get hasResults(): boolean { - return this._results != undefined && this._results.hasResults; + return this._results && this._results.hasResults; } private get resultElement() { @@ -84,11 +84,11 @@ export class SectionResultsComponent implements DoCheck { private _sectionCanvas: SectionCanvasComponent; public updateView() { - if (this._sectionCanvas != undefined) { + if (this._sectionCanvas) { this._sectionCanvas.reset(); } - if (this._results != undefined) { + if (this._results) { this._doUpdate = this._results.hasResults; } }