Skip to content
Snippets Groups Projects
Commit 37449f00 authored by mathias.chouet's avatar mathias.chouet
Browse files

Résolution bug de taille du canvas (courbes de résultats)

parent d7c54502
No related branches found
No related tags found
1 merge request!30Resolve "Mettre à jour proprement vers Angular 7"
...@@ -3,8 +3,8 @@ import { Component, Input, ViewChild, ElementRef, AfterViewInit } from "@angular ...@@ -3,8 +3,8 @@ import { Component, Input, ViewChild, ElementRef, AfterViewInit } from "@angular
@Component({ @Component({
selector: "calc-canvas", selector: "calc-canvas",
template: `<canvas #canvas template: `<canvas #canvas
[attr.width] = 'width' [attr.width]="width"
[attr.height] = 'height'> [attr.height]="height">
</canvas> </canvas>
` `
}) })
...@@ -19,19 +19,17 @@ export class CalcCanvasComponent implements AfterViewInit { ...@@ -19,19 +19,17 @@ export class CalcCanvasComponent implements AfterViewInit {
@Input() @Input()
public set width(w: number) { public set width(w: number) {
this._width = w; this._width = w;
this._calcCanvas.nativeElement.width = w;
} }
public get height(): number { public get height(): number {
return this._calcCanvas.nativeElement.height; return this._calcCanvas.nativeElement.height;
} }
public get witdh() {
return this._width;
}
@Input() @Input()
public set height(h: number) { public set height(h: number) {
this._height = h; this._height = h;
this._calcCanvas.nativeElement.height = h;
} }
private _context2d: CanvasRenderingContext2D; private _context2d: CanvasRenderingContext2D;
...@@ -49,7 +47,7 @@ export class CalcCanvasComponent implements AfterViewInit { ...@@ -49,7 +47,7 @@ export class CalcCanvasComponent implements AfterViewInit {
} }
public clear() { public clear() {
if (this._context2d != undefined) { if (this._context2d) {
this._context2d.clearRect(0, 0, this.width, this.height); this._context2d.clearRect(0, 0, this.width, this.height);
} }
} }
...@@ -69,7 +67,7 @@ export class CalcCanvasComponent implements AfterViewInit { ...@@ -69,7 +67,7 @@ export class CalcCanvasComponent implements AfterViewInit {
} }
public fillText(s: string, x: number, y: number, align?: any) { public fillText(s: string, x: number, y: number, align?: any) {
if (align != undefined) { if (align) {
this._context2d.textAlign = align; this._context2d.textAlign = align;
} }
this._context2d.fillText(s, x, y); this._context2d.fillText(s, x, y);
......
...@@ -10,8 +10,8 @@ import { CalcCanvasComponent } from "../canvas/canvas.component"; ...@@ -10,8 +10,8 @@ import { CalcCanvasComponent } from "../canvas/canvas.component";
@Component({ @Component({
selector: "section-canvas", selector: "section-canvas",
template: `<calc-canvas #calcCanvas template: `<calc-canvas #calcCanvas
[width] = 'size' [width]="size"
[height] = 'size'> [height]="size">
</calc-canvas> </calc-canvas>
` `
}) })
...@@ -47,7 +47,7 @@ export class SectionCanvasComponent { ...@@ -47,7 +47,7 @@ export class SectionCanvasComponent {
public set section(s: acSection) { public set section(s: acSection) {
this._section = s; this._section = s;
if (this._section != undefined) { if (this._section) {
this.draw(); this.draw();
} }
} }
...@@ -219,8 +219,8 @@ export class SectionCanvasComponent { ...@@ -219,8 +219,8 @@ export class SectionCanvasComponent {
return maxWidth; return maxWidth;
} catch (e) { } catch (e) {
const r: Result = e as Result; const res: Result = e as Result;
this.drawText("error : " + r.log.toString(), 0, 0); this.drawText("error : " + res.log.toString(), 0, 0);
} }
} }
...@@ -281,7 +281,7 @@ export class SectionCanvasComponent { ...@@ -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); 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); this._calcCanvas.fillText(s, this.Xm2pix(x), this.Ym2pix(y), align);
} }
......
...@@ -40,7 +40,7 @@ export class SectionResultsComponent implements DoCheck { ...@@ -40,7 +40,7 @@ export class SectionResultsComponent implements DoCheck {
this._resultElement = undefined; this._resultElement = undefined;
this._results = undefined; this._results = undefined;
if (rs != undefined) { if (rs) {
for (const r of rs) { for (const r of rs) {
if (r instanceof SectionResults) { if (r instanceof SectionResults) {
this._results = r; this._results = r;
...@@ -52,7 +52,7 @@ export class SectionResultsComponent implements DoCheck { ...@@ -52,7 +52,7 @@ export class SectionResultsComponent implements DoCheck {
} }
public get hasResults(): boolean { public get hasResults(): boolean {
return this._results != undefined && this._results.hasResults; return this._results && this._results.hasResults;
} }
private get resultElement() { private get resultElement() {
...@@ -84,11 +84,11 @@ export class SectionResultsComponent implements DoCheck { ...@@ -84,11 +84,11 @@ export class SectionResultsComponent implements DoCheck {
private _sectionCanvas: SectionCanvasComponent; private _sectionCanvas: SectionCanvasComponent;
public updateView() { public updateView() {
if (this._sectionCanvas != undefined) { if (this._sectionCanvas) {
this._sectionCanvas.reset(); this._sectionCanvas.reset();
} }
if (this._results != undefined) { if (this._results) {
this._doUpdate = this._results.hasResults; this._doUpdate = this._results.hasResults;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment