import { Link } from '../../renderables/Link'; import { LinkStyle } from '../../styles/LinkStyle'; import { Renderer } from '../Renderer'; abstract class LinkRenderer extends Renderer { // Links to render protected _links: Link[]; // Styling stroke: string; strokeDash: number[] | null; strokeWidth: number | null; protected constructor (style?: LinkStyle) { super(); this._links = []; this.stroke = '#333333'; this.strokeDash = null; this.strokeWidth = null; if (style) { if (style.stroke) this.stroke = style.stroke; if (style.strokeDash) this.strokeDash = style.strokeDash; if (style.strokeWidth) this.strokeWidth = style.strokeWidth; } } links (): Link[]; links (links: Link[]): this; links (links?: Link[]): Link[] | this { return arguments.length ? (this._links = links!, this) : this._links; } protected _doFill (context: CanvasRenderingContext2D) { if (this.stroke) context.fillStyle = this.stroke; context.fill(); } protected _doStroke (context: CanvasRenderingContext2D) { if (this.strokeDash) context.setLineDash(this.strokeDash); if (this.strokeWidth) context.lineWidth = this.strokeWidth; context.strokeStyle = this.stroke; context.stroke(); } } export { LinkRenderer }