From 4633efd90e8d95cbbbf32b331083380069ecedff Mon Sep 17 00:00:00 2001 From: grzhan Date: Tue, 16 Aug 2016 16:45:54 +0800 Subject: [PATCH] fix: create typescript declaration files --- src/Annotator.d.ts | 69 +++++++++++++++++++++++++++++++ src/lib/Draw.d.ts | 24 +++++++++++ src/lib/components/Label.d.ts | 18 ++++++++ src/lib/components/Line.d.ts | 7 ++++ src/lib/components/Paragraph.d.ts | 11 +++++ src/lib/util/EventBase.d.ts | 8 ++++ src/lib/util/TextSelector.d.ts | 26 ++++++++++++ src/lib/util/Util.d.ts | 6 +++ 8 files changed, 169 insertions(+) create mode 100644 src/Annotator.d.ts create mode 100644 src/lib/Draw.d.ts create mode 100644 src/lib/components/Label.d.ts create mode 100644 src/lib/components/Line.d.ts create mode 100644 src/lib/components/Paragraph.d.ts create mode 100644 src/lib/util/EventBase.d.ts create mode 100644 src/lib/util/TextSelector.d.ts create mode 100644 src/lib/util/Util.d.ts diff --git a/src/Annotator.d.ts b/src/Annotator.d.ts new file mode 100644 index 0000000..56565d7 --- /dev/null +++ b/src/Annotator.d.ts @@ -0,0 +1,69 @@ +/// +import { EventBase } from './lib/util/EventBase'; +export declare enum Categories { + 'sign&symptom' = 1, + 'diagnosis' = 2, + 'assessment' = 3, + 'treatment' = 4, + "index" = 5, + "drug" = 6, + "body location" = 7, + "frequency" = 8, + "value" = 9, + "change" = 10, + "modifier" = 11, + "time" = 12, +} +export declare class Annotator extends EventBase { + svg: any; + group: {}; + lines: {}; + category: { + id: number; + fill: string; + boader: string; + highlight: string; + text: string; + }[]; + lcategory: { + id: number; + text: string; + }[]; + labelsSVG: any[]; + linkable: boolean; + underscorable: boolean; + progress: number; + visible: { + 'relation': boolean; + 'highlight': boolean; + 'label': boolean; + }; + private state; + private style; + private puncLen; + private renderPerLines; + private draw; + private raw; + private label_line_map; + private labels; + private background; + private baseTop; + private baseLeft; + private maxWidth; + private selectionCallback; + constructor(container: any, width?: number, height?: number); + private init(); + private clear(); + import(raw: String, labels: any, relations: any): void; + stringify(): void; + enableSelection(): void; + disableSelection(): void; + setVisiblity(component: string, visible: boolean): void; + exportPNG(scale?: number): void; + resize(width: any, height: any): void; + private render(startAt); + private selectionEventHandler(); + private selectionParagraphEventHandler(); + private posInLine(x, y); + private requestAnimeFrame(callback); +} diff --git a/src/lib/Draw.d.ts b/src/lib/Draw.d.ts new file mode 100644 index 0000000..9d121e1 --- /dev/null +++ b/src/lib/Draw.d.ts @@ -0,0 +1,24 @@ +/// +export declare class Draw { + private board; + private margin; + private lineHeight; + private shoulder; + private needExtend; + private style_user_select_none; + constructor(board: any); + highlight(selector: any, color?: string): any; + textline(lineNo: any, content: any, left: any, top: any): any; + annotation(id: any, cid: any, selector: any): void; + label(id: any, cid: any, selector: any): void; + relation(srcId: any, dstId: any, text?: string): void; + underscore(paragraph: any): void; + bracket(cid: any, x1: any, y1: any, x2: any, y2: any, width: any, q?: number): any; + private moveLineRight(lineNo, padding); + private extendAnnotationLine(lineNo, type); + private underscoreLine(lineNo, start, end); + private calcAnnotationTop(text, selector); + private calcRelationTop(lineNo, width, height, top, left); + private isCollisionInLine(lineNo, width, height, left, top); + private isCollision(x1, y1, w1, h1, x2, y2, w2, h2); +} diff --git a/src/lib/components/Label.d.ts b/src/lib/components/Label.d.ts new file mode 100644 index 0000000..335d534 --- /dev/null +++ b/src/lib/components/Label.d.ts @@ -0,0 +1,18 @@ +export declare class Label { + id: any; + category: any; + pos: number[]; + lineNo: any; + constructor(id: any, category: any, pos: any); + isTruncate(pos: any): boolean; +} +export declare class LabelContainer { + private labels; + private lineMap; + create(id: any, category: any, pos: any): void; + push(label: Label): void; + get(id: any): any; + readonly length: number; + gen(label: any): any[]; + private insert(target); +} diff --git a/src/lib/components/Line.d.ts b/src/lib/components/Line.d.ts new file mode 100644 index 0000000..e21ebc2 --- /dev/null +++ b/src/lib/components/Line.d.ts @@ -0,0 +1,7 @@ +/// +export declare class Line { + svg: any; + constructor(id: any, width: any, height: any); + group(): void; + extend(lineNo: any): void; +} diff --git a/src/lib/components/Paragraph.d.ts b/src/lib/components/Paragraph.d.ts new file mode 100644 index 0000000..bff3847 --- /dev/null +++ b/src/lib/components/Paragraph.d.ts @@ -0,0 +1,11 @@ +export declare class Paragraph { + startLine: any; + endLine: any; + startOffset: any; + endOffset: any; + startPos: any; + endPos: any; + private context; + constructor(context: any, startLine: any, startOffset: any, endLine: any, endOffset: any); + calcPos(lineNo: any, offset: any): number; +} diff --git a/src/lib/util/EventBase.d.ts b/src/lib/util/EventBase.d.ts new file mode 100644 index 0000000..af36f36 --- /dev/null +++ b/src/lib/util/EventBase.d.ts @@ -0,0 +1,8 @@ +export declare class EventBase { + private listeners; + emit(event: string, args?: any): boolean; + on(event: string, listener: (target: EventBase, args?: any) => any): number; + private off(event); + offById(event: string, id: number): void; + offAll(): void; +} diff --git a/src/lib/util/TextSelector.d.ts b/src/lib/util/TextSelector.d.ts new file mode 100644 index 0000000..4f0a186 --- /dev/null +++ b/src/lib/util/TextSelector.d.ts @@ -0,0 +1,26 @@ +/// +export declare class TextSelector { + static rect(): { + width: number; + height: number; + left: number; + top: number; + }; + static lineNo(): number; + static init(): { + startOffset: number; + endOffset: number; + startNode: Node; + endNode: Node; + tspan: SVGTextContentElement; + }; + static paragraph(): { + startOffset: number; + endOffset: number; + startLineNo: number; + endLineNo: number; + }; +} +export declare class SelectorDummyException extends Error { + constructor(message: any); +} diff --git a/src/lib/util/Util.d.ts b/src/lib/util/Util.d.ts new file mode 100644 index 0000000..7089f20 --- /dev/null +++ b/src/lib/util/Util.d.ts @@ -0,0 +1,6 @@ +export declare class Util { + static height(node: any): any; + static width(node: any): any; + static top(node: any): any; + static left(node: any): any; +}