/** * Font size settings. */ interface FontSize { /** * Number of {@link units}. */ value: number; /** * Units the {@link value} represents. */ units: string; /** * Value increment/decrement step for controls cycling through the size values. */ step: number; } /** * Color type marks the kind of color property a color is referring to. */ declare type ColorType = 'text' | 'stroke' | 'fill' | 'background'; /** * Diagram settings represent a collection of core and custom settings * for a diagram. */ declare class DiagramSettings { /** * Stores arbitrary string settings grouped by context (eg. some module, stencil type, etc.). */ protected _contextStrings: Map>; /** * Returns an arbitrary string setting for provided context and setting name. * @param context type or module name (or other context collection) * @param name setting name * @returns string setting for context-name pair or undefined, if not found. * * @example * ```ts * dashhArray = settings.getContextString('DiamondStencil', 'strokeDashArray'); * ``` */ getContextString(context: string, name: string): string | undefined; /** * Sets an arbitrary string setting for some context (type or module name) and setting name. * @param context type or module name (or some other context) * @param name setting name * @param value setting value */ setContextString(context: string, name: string, value: string): void; /** * Default color. */ defaultColor: string; /** * Default text (font) color. */ defaultTextColor: string; /** * Default stroke (line) color. */ defaultStrokeColor: string; /** * Default fill color. */ defaultFillColor: string; /** * Default background color. */ defaultBackgroundColor: string; /** * Stores a collection of color settings grouped by context (type or module name). */ protected _colors: Map>; /** * Returns a color setting by provided context and type of color. * @param context type or module name * @param type color kind (text, fill, stroke, etc.) * @returns CSS color string for the context-type pair or the default color for the type. */ getColor(context: string, type: ColorType): string; /** * Sets contextual color setting value. * @param context setting group (stencil or connector type, etc.) * @param type type of color (text, stroke, fill, etc.) * @param color string color value. */ setContextColor(context: string, type: ColorType, color: string): void; /** * Default stroke dash array. * * @see MDN [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) * docs for details. */ defaultStrokeDasharray: string; /** * Gets the stroke dash array setting for the provided type (context) or the default stroke dash array, if not found. * @param context type or module name (or other context) * @returns stroke dash array for the context or the {@link defaultStrokeDasharray}. */ getDashArray(context: string): string; /** * Sets custom dash array for the provided context (type or module name). * @param context type or module name * @param value dash array value */ setContextDashArray(context: string, value: string): void; /** * Default stroke width. */ defaultStrokeWidth: string; /** * Returns stroke width for the specified context (type or module name) or the default stroke width. * @param context type or module name * @returns stroke width for the context or {@link defaultStrokeWidth} */ getStrokeWidth(context: string): string; /** * Sets custom stroke width for the provided context (type or module name). * @param context type or module name * @param value stroke width value */ setContextStrokeWidth(context: string, value: string): void; /** * Default font family. */ defaultFontFamily: string; /** * A collection of font family settings for different contexts (type or module names). */ protected _fontFamily: Map; /** * Returns special font family for the provided context or the default font family. * @param context type or module name (or other context) * @returns custom font family for the context or {@link defaultFontFamily} */ getFontFamily(context: string): string; /** * Sets custom font family for the specified context. * @param context type or module name * @param value font family string */ setContextFontFamily(context: string, value: string): void; /** * Default font size. */ defaultFontSize: FontSize; /** * A collection of contextual font sizes. */ private _fontSizes; /** * Returns a custom font size for the specified context or the default font size. * @param context type or module name * @returns custom font size or {@link defaultFontSize} */ getFontSize(context: string): FontSize; /** * Sets custom font size for the supplied context. * @param context type or module name * @param value font size value */ setContextFontSize(context: string, value: FontSize): void; } /** * Describes point objects used internally */ interface IPoint { /** * Horizontal (X) coordinate. */ x: number; /** * Vertical (Y) coordinate. */ y: number; } /** * Represents a location of a port on a rectangular stencil frame. */ declare type PortLocation = 'topleft' | 'topcenter' | 'topright' | 'leftcenter' | 'rightcenter' | 'bottomleft' | 'bottomcenter' | 'bottomright'; /** * Port is where connectors connects to a stencil. */ declare class Port { /** * Location of the port on the stencils frame. */ location: PortLocation; /** * Is this port enabled. When set to false the port will not be visible in the connection mode * in the {@link editor!DiagramEditor}. */ enabled: boolean; /** * Connecrtors connected to the port. */ connectors: ConnectorBase[]; /** * Horizontal coordinate of the port within the stencil. */ x: number; /** * Vertical coordinate of the port within the stencil. */ y: number; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(location: PortLocation); /** * Removes the supplied connector from the port. * @param connector connector to remove */ removeConnector(connector: ConnectorBase): void; } /** * Describes a size */ interface ISize { width: number; height: number; } /** * Represents state (configuration) of a stencil. * Used to save and restore stencils as well as for undo/redo operations. */ interface StencilBaseState { /** * String representation of the stencil's type name. */ typeName: string; /** * Internal stencil id. Used to refer to the stencil in connectors, etc. */ iid: number; /** * Arbitrary string data that can be saved along with the stencil's state. */ notes?: string; /** * Horizontal coordinate of the stencil. */ left: number; /** * Vertical coordinate of the stencil. */ top: number; /** * Stencil's width. */ width?: number; /** * Stencil's height. */ height?: number; /** * Fill color. */ fillColor?: string; /** * Stroke color. */ strokeColor?: string; /** * Stroke width in pixels. */ strokeWidth?: number; /** * Stroke dash array. * @see MDN [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) * docs for details. */ strokeDasharray?: string; } /** * The `StencilBase` class is the base class for all stencil types in MJS Diagram. * * It covers the basic functionality and APIs for all other stencil types. */ declare class StencilBase { /** * A string representation of the type used * in diagram configuration (state) JSON. */ static typeName: string; /** * A string representation of the type used * in diagram configuration (state) JSON. * * @remarks * Instance accessor returning the value of static {@link typeName}. */ get typeName(): string; /** * Default name of the stencil. */ static title: string; /** * Returns the main SVG path of the stencil's visual. * It is used in thumbnails in the editor and, potentially, other places. * @param width target width * @param height target height * @returns SVG path string */ protected static getPathD(width: number, height: number): string; private _iid; /** * Internal stencil identifier used in state/configuration JSON * as reference to this stencil. */ get IId(): number; /** * Top level SVG container (group) encapsulating all the visual elements of this stencil. */ protected _container: SVGGElement; /** * {@inheritDoc _container} */ get container(): SVGGElement; private _settings; /** * Settings for the whole diagram. */ protected get settings(): DiagramSettings; /** * Store any arbitrary string information associated with this stencil in this field. */ notes?: string; /** * Fired when the stencil creation is completed. * @group Events */ onStencilCreated?: (stencil: StencilBase) => void; /** * Default size of the stencil when created. * * @remarks * Override in the descendant stencils to set a size that makes sense for the stencil type. */ protected _defaultSize: ISize; /** * Returns the default size of the stencil. */ get defaultSize(): ISize; /** * Sets the default and updates the current stencil size. */ set defaultSize(value: ISize); /** * Left (x) coordinate of the stencil. */ left: number; /** * Top (y) coordinate of the stencil. */ top: number; /** * Stencil width. */ width: number; /** * Stencil height. */ height: number; /** * Returns the right edge (x) coordinate (calculated). */ get right(): number; /** * Returns the bottom edge (y) coordinate (calculated) */ get bottom(): number; /** * Returns the stencil center X coordinate (calculated). */ protected get centerX(): number; /** * Returns the stencil center Y coordinate (calculated). */ protected get centerY(): number; /** * Stencil's frame path for selection. Usually an extended (wider) version of the {@link _frame}. */ protected _selectorFrame?: SVGElement; /** * Stencil's frame path. Usually the main stencil visual. */ protected _frame?: SVGElement; private _visual; /** * Returns the SVG group holding the stencil's visual. */ protected get visual(): SVGGraphicsElement; /** * Sets the stencil's visual. */ protected set visual(value: SVGGraphicsElement); /** * Stencil's fill color. */ protected _fillColor: string; /** * Returns stencil's fill color. */ get fillColor(): string; /** * Stencil's outline (stroke) color. */ protected _strokeColor: string; /** * Returns stencil's outline (stroke) color. */ get strokeColor(): string; /** * Stencil's outline (stroke) width in pixels. */ protected _strokeWidth: number; /** * Returns stencil's outline (stroke) width in pixels. */ get strokeWidth(): number; /** * Stencil's outline dash array. * * @see MDN [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) * docs for details. */ protected _strokeDasharray: string; /** * Returns stencil's outline dash array. * * @see MDN [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) * docs for details. */ get strokeDasharray(): string; /** * Holds a collection of connector ports for this stencil. */ ports: Map; /** * Specifies whether stencil's fill can be changed by the user. */ fillEditable: boolean; /** * Specifies whether stencil's stroke properties can be changed by the user. */ strokeEditable: boolean; /** * Creates a stencil object. * @param iid internal stencil identifier * @param container SVG container for all the stencil's visuals * @param settings settings for the whole diagram */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); /** * Returns the base thumbnail SVG image scaffolding (SVG image element). * @param width image width * @param height image height * @returns SVG image element */ protected static getThumbnailSVG(width: number, height: number): SVGSVGElement; /** * Returns a simplified thumbnail representation of the stencil as an SVG image. * It is used by the editor and can potentially be used in other places. * @param width image width * @param height image height * @returns thumbnail as an SVG image */ static getThumbnail(width: number, height: number): SVGSVGElement; /** * Returns true if supplied element is a part of this stencil. * @param el target element * @returns `true` if the element if part of this stencil, `false` otherwise. */ ownsTarget(el: EventTarget): boolean; dispose(): void; /** * Scales the stencil according to supplied scale factors. * @param scaleX horizontal scale factor * @param scaleY vertical scale factor */ scale(scaleX: number, scaleY: number): void; /** * Disables connector ports in specified locations * @remarks * By default all ports are enabled. Depending on the stencil type it makes * sense to disable some (or even all) of the ports. * * For example {@link core!DiamondStencil} has all the corner ports disabled * as the stencil visual has no visible parts there. * @param portLocations locations of the ports to disable. */ disablePorts(...portLocations: PortLocation[]): void; /** * Instance method for getting the stencil path. Calls the static {@link getPathD}. * @param width bounding width * @param height bounding height * @returns stencil's SVG path string */ protected getPathD(width: number, height: number): string; /** * Gets stencil's SVG path for the purpose of reacting to pointer and other events. * * @remarks * Some stencil types may have a visual that is very narrow or otherwise hard * to hit with a pointer. This method provides a way to get an alternative invisible * path that is easier to hit resulting in better user experience. * * By default it returns the same path as the {@link core!StencilBase#getPathD | main stencil path} though. * @param width target width * @param height target height * @returns SVG path string */ getSelectorPathD(width: number, height: number): string; /** * Creates an invisible visual that acts as a more pronounced hit target * that is easier to hit with a pointer. */ protected createSelector(): void; /** * Creates the main stencil's visual. */ createVisual(): void; /** * Inserts the supplied element as the first child of the container. * @param element SVG element to insert */ protected addVisualToContainer(element: SVGElement): void; /** * Moves the stencil visual to the specified coordinates. * @param point new stencil coordinates */ moveVisual(point: IPoint): void; /** * Adjusts selector visual based on current stencil dimensions. */ protected adjustSelector(): void; /** * Adjusts stencil visual based on current dimensions. */ protected adjustVisual(): void; /** * Adjusts the stencil to current size and location. */ setSize(): void; /** * Sets the stencil's outline (stroke) color. * @param color new color */ setStrokeColor(color: string): void; /** * Sets the stencil's fill color. * @param color new color */ setFillColor(color: string): void; /** * Sets the stencil's outline (stroke) width in pixels * @param width new width */ setStrokeWidth(width: number | string): void; /** * Sets the stencil outline's dash array. * * @param dashes new dash array * @see MDN [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) * docs for details. */ setStrokeDasharray(dashes: string): void; /** * Returns coordinates for the port in specified location * @param location port location * @returns port center coordinates */ getPortPosition(location: PortLocation): IPoint; /** * Positions all ports in their respective locations. */ positionPorts(): void; /** * Positions the supplied port in specified location. * @param port port to position * @param x horizontal position * @param y vertical position */ private positionPort; /** * Returns stencil state (configuration) used to save the whole diagram for future use * as well as for undo/redo operations. * @returns stencil state object */ getState(): StencilBaseState; /** * Restores stencil configuration (settings) from a previously saved state. * @param state previously saved state object. */ restoreState(state: StencilBaseState): void; } /** * TextBlock represents a block of text used across all text-based stencils and connector labels. */ declare class TextBlock { /** * Fired when text size changes. * * @group Events */ onTextSizeChanged?: (textBlock: TextBlock) => void; private _text; /** * Returns the text block's text */ get text(): string; /** * Sets the text block's text. */ set text(value: string); /** * Text block's horizontal offset from the automatically calculated position. */ offsetX: number; /** * Text block's vertical offset from the automatically calculated position. */ offsetY: number; private _boundingBox; /** * Returns the bounding box where text should fit and/or be anchored. */ get boundingBox(): DOMRect; /** * Sets the bounding box where text should fit and/or be anchored. */ set boundingBox(value: DOMRect); private _labelBackground; /** * Returns the background rectangle (behind the text). */ get labelBackground(): SVGRectElement; private _textElement; /** * Returns the text block's text element. */ get textElement(): SVGTextElement; private _color; /** * Sets the text color. */ set color(value: string); /** * Returns the text color. */ get color(): string; private _fontFamily; /** * Returns the text's font family. */ get fontFamily(): string; /** * Sets the text's font family. */ set fontFamily(value: string); private _fontSize; /** * Returns the text's font size. */ get fontSize(): FontSize; /** * Sets the text's font size. */ set fontSize(value: FontSize); /** * Creates a text block * @param text initial text */ constructor(text?: string); /** * Returns true if the text block contains the supplied element. * @param el element to test. * @returns true if the element belongs to the text block, false otherwise. */ ownsTarget(el: EventTarget): boolean; private setupTextElement; /** * Renders text within the text block according to its settings. */ renderText(): void; private applyFontStyles; private _textSize?; /** * Returns the size of the rectangle containing the text block's text. */ get textSize(): DOMRect | undefined; /** * Positions the text within the text block. * @param textBlock */ positionText(textBlock?: TextBlock): void; /** * Makes the text block content visible. */ show(): void; /** * Hides the text block content. */ hide(): void; /** * Shows the text block's dashed outline. */ showControlBox(): void; /** * Hides the text block's dashed outline. */ hideControlBox(): void; } /** * Defines location of arrows on a connector. * * - `both` - arrows displayed on both ends of a connector. * - `start` - arrow displayend on the start side of a connector. * - `end` - arrow displayed on the end side of a connector. * - `none` - no arrows are displayed. */ declare type ArrowType = 'both' | 'start' | 'end' | 'none'; /** * Represents the base type for all connectors in MJS Diagram. */ declare class ConnectorBase { /** * A string representation of the type used * in diagram configuration (state) JSON. */ static typeName: string; /** * A string representation of the type used * in diagram configuration (state) JSON. * * @remarks * Instance accessor returning the value of static {@link typeName}. */ get typeName(): string; private _iid; /** * Internal connector identifier used in state/configuration JSON * as reference to this connector. */ get IId(): number; /** * SVG group containing all the SVG elements for this connector. */ container: SVGGElement; /** * Reference to the stencil at the start tip of this connector. */ startStencil?: StencilBase; /** * Reference to the stencil connector port and the start tip of this connector. */ startPort?: Port; /** * Reference to the stencil at the end tip of this connector. */ endStencil?: StencilBase; /** * Reference to the stencil connector port and the end tip of this connector. */ endPort?: Port; /** * X coordinate of the start tip. */ x1: number; /** * Y coordinate of the start tip. */ y1: number; /** * X coordinate of the end tip. */ x2: number; /** * Y coordinate of the end tip. */ y2: number; /** * The top level SVG element (group) of the connector's visual. */ visual: SVGGraphicsElement; /** * Visible connector line. */ visibleLine: SVGLineElement | SVGPathElement; /** * Invisible wider connector line used to improve selection accuracy. */ selectorLine: SVGLineElement | SVGPathElement; /** * Connector line color. */ strokeColor: string; /** * Connector line width. */ strokeWidth: number; /** * Connector line dash array. */ strokeDasharray: string; _labelText: string; /** * Gets label text for the connector. */ get labelText(): string; /** * Sets label text for the connector. */ set labelText(value: string); /** * Text block displaying the connector label. */ textBlock: TextBlock; /** * Bounding box for the label text. */ textBoundingBox: DOMRect; /** * SVG polygon for the start tip arrow. */ protected arrow1: SVGPolygonElement; /** * SVG polygon for the end tip arrow. */ protected arrow2: SVGPolygonElement; /** * {@inheritDoc core!ArrowType} */ arrowType: ArrowType; /** * Arrow height. */ protected arrowBaseHeight: number; /** * Arrow width. */ protected arrowBaseWidth: number; /** * Returns connector thumbnail used to define the shape of the connector in the {@link editor!DiagramEditor}. * @param width - thumbnail image width * @param height - thumbnail image height * @returns SVG image of the thumbnail. */ static getThumbnail(width: number, height: number): SVGSVGElement; private _settings; /** * {@link core!DiagramSettings} of the whole diagram. */ protected get settings(): DiagramSettings; /** * Creates a connector. * @param iid - connector identifier. * @param container - SVG container to contain all the connector visuals. * @param settings - whole diagram settings. */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); /** * Returns true if manipulation target belongs to this connector. */ ownsTarget(el: EventTarget): boolean; /** * Creates visual elements of the connector. */ createVisual(): void; /** * Creates the main visual of the connector. */ createCoreVisual(): void; /** * Adds an element to the connector's container. * The elements are inserted in the beggining (lowest layer) of the stack. * @param element - element to add. */ addVisualToContainer(element: SVGElement): void; private getArrowPoints; private createTips; /** * Adjusts layout of the connector. */ adjust(): void; /** * Adjusts connector's end pointis. */ adjustPoints(): void; /** * Gets coordinates of connector's line ending depending on the * arrow types and other factors. * @param baseEnding - base connector ending (as if there were no arrows, etc.) * @param port - port to which the connector is connected. * @returns - adjusted coordinates of connector line ending. */ protected getEnding(baseEnding: IPoint, port?: Port): IPoint; /** * Gets coordinates of connector line endings adjusted based on arrow types * and other factors * @returns connector ending coordinates. */ protected getEndings(): [IPoint, IPoint]; /** * Adjusts connector visual based on updated position and other * circumnstances. */ adjustVisual(): void; /** * Adjust connector tips (arrows). */ adjustTips(): void; /** * Rotates arrows based on the connector tip position, connected ports, etc. */ protected rotateArrows(): void; /** * Sets start tip position to supplied coordinates. * @param point new tip position. */ setStartPosition(point: IPoint): void; /** * Sets end tip position to supplied coordinates. * @param point new tip position. */ setEndPosition(point: IPoint): void; /** * Moves label to supplied offset coordinates. * @param offsetX horizontal offset from the auto-calculated position * @param offsetY vertical offset from the auto-calculated position. */ moveLabel(offsetX?: number, offsetY?: number): void; /** * Calculates and sets the bounding box for the connector's label. */ protected setTextBoundingBox(): void; /** * Sets the color of the connector's visual * @param color CSS compatible color. */ setStrokeColor(color: string): void; /** * Sets the dash array of the connector's visual * @param dashes stroke dash array values. */ setStrokeDasharray(dashes: string): void; /** * Sets the stroke width of the connector's visual * @param width stroke (line) width. */ setStrokeWidth(width: number | string): void; /** * Sets connector's arrow type. * @param arrowType arrow type. */ setArrowType(arrowType: ArrowType): void; /** * Scales the connector based on supplied scale factors. * @param scaleX horizontal scale factor. * @param scaleY vertical scale factor. */ scale(scaleX: number, scaleY: number): void; /** * Returns connector's state (configuration) used for storing the diagram * and for undo/redo operations. * @returns connector state object. */ getState(): ConnectorBaseState; /** * Restores connector settings from a previously saved state (configuration). * @param state previously saved or created state. * @param endPoints stencils and ports the connector is connecting. */ restoreState(state: ConnectorBaseState, endPoints: ConnectorEndPoints): void; } /** * Represents a state (configuration) of a connector. * Used when storing and restoring connector state externally and for undo/redo operations. */ interface ConnectorBaseState { /** * Text representation of connector's type name. */ typeName: string; /** * Internal connector identifier. */ iid: number; /** * Identifier of the stencil at the start tip of the connector. */ startStencilId?: number; /** * Location of the stencil connector port on the start tip of the connector. */ startPortLocation?: PortLocation; /** * Identifier of the stencil at the end tip of the connector. */ endStencilId?: number; /** * Location of the stencil connector port on the end tip of the connector. */ endPortLocation?: PortLocation; /** * Horizontal offset of the connector's text label (as measured from the automatic position). */ labelOffsetX?: number; /** * Vertical offset of the connector's text label (as measured from the automatic position). */ labelOffsetY?: number; /** * Color of the connector line. */ strokeColor?: string; /** * Width of the connector line (in pixels). */ strokeWidth?: number; /** * Dash array for the connector line. * * @see MDN [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray) * docs for details. */ strokeDasharray?: string; /** * Describes which tips of the connector end in arrows. */ arrowType?: ArrowType; /** * Text of the connector's label. */ labelText?: string; } /** * Describes connector's end point properties. */ interface ConnectorEndPoints { /** * Stencil at the start tip of the connector. */ startStencil: StencilBase; /** * Port at the start tip of the connector. */ startPort: Port; /** * Stencil at the end tip of the connector. */ endStencil: StencilBase; /** * Port at the end tip of the connector. */ endPort: Port; } /** * Represents diagram's state (configuration) used to save and restore * diagrams. It can also be used to construct diagrams from code. */ interface DiagramState { /** * Diagram document width. */ width?: number; /** * Diagram document height. */ height?: number; /** * Page background color. */ backgroundColor?: string; /** * A collection of stencils. */ stencils?: StencilBaseState[]; /** * A collection of connectors. */ connectors?: ConnectorBaseState[]; } /** * Represents configuration (state) of stencils extending the {@link core!TextStencil}. */ interface TextStencilState extends StencilBaseState { /** * Text color. */ color?: string; /** * Font family string. */ fontFamily?: string; /** * Font size. */ fontSize?: FontSize; /** * Text pading. */ padding?: number; /** * Text content. */ text?: string; } /** * TextStencil is the base type for all stencils with text in them. */ declare class TextStencil extends StencilBase { static typeName: string; static title: string; /** * Default text for the newly created stencil. */ protected static DEFAULT_TEXT: string; private _color; /** * Returns stencil's text color. */ get color(): string; /** * Sets the stencil's text color. */ set color(value: string); private _fontFamily; /** * Returns the stencil's font family. */ get fontFamily(): string; /** * Sets the stencil's font family. */ set fontFamily(value: string); private _fontSize; /** * Returns the stencil's font size. */ get fontSize(): FontSize; /** * Sets the stencil's font size. */ set fontSize(value: FontSize); /** * Returns the default text for the stencil type. * @returns stencil type's default text. */ protected getDefaultText(): string; private _text; /** * Returns the stencil's text. */ get text(): string; /** * Sets the stencil's text. */ set text(value: string); /** * Text padding from the bounding box. */ protected padding: number; /** * Text's bounding box where text should fit and/or be anchored to. */ textBoundingBox: DOMRect; /** * Text block handling the text rendering. */ textBlock: TextBlock; /** * {@inheritDoc core!StencilBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); static getThumbnail(width: number, height: number): SVGSVGElement; ownsTarget(el: EventTarget): boolean; /** * Adds the text element to the stencil's visual. */ protected addTextElement(): void; createVisual(): void; /** * Sets (adjusts) the text bounding box for the stencil. */ protected setTextBoundingBox(): void; /** * Sets (adjusts) the stencil's size. */ setSize(): void; /** * Sets the text color. * @param color text color */ setColor(color: string): void; /** * Sets the font family. * @param font font family string */ setFont(font: string): void; /** * Sets the font size. * @param fontSize font size */ setFontSize(fontSize: FontSize): void; getState(): TextStencilState; restoreState(state: TextStencilState): void; scale(scaleX: number, scaleY: number): void; } /** * Rectangle text stencil is a common stencil type displaying a text string inside a rectangle. */ declare class RectangleTextStencil extends TextStencil { static typeName: string; static title: string; protected static getPathD(width: number, height: number): string; static getThumbnail(width: number, height: number): SVGSVGElement; } /** * Ellipse stencil represents a generic ellipse (or a circle) that * can be used and extended in various diagram types. */ declare class EllipseStencil extends RectangleTextStencil { static typeName: string; static title: string; protected static getPathD(width: number, height: number): string; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); protected setTextBoundingBox(): void; } /** * Diamond (or rhombus) stencil is a common shape used in many diagram types. * For example, it represents a decision stencil in a Flowchart. */ declare class DiamondStencil extends RectangleTextStencil { static typeName: string; static title: string; protected static getPathD(width: number, height: number): string; /** * {@inheritDoc core!StencilBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); protected setTextBoundingBox(): void; } declare type ImageType = 'svg' | 'bitmap'; declare type TextLabelLocation = 'top' | 'right' | 'bottom' | 'left' | 'hidden'; interface ImageStencilState extends TextStencilState { imageType?: ImageType; imageSrc?: string; labelLocation?: TextLabelLocation; } /** * Base stencil type for stencils defined by a drawing or a raster image. */ declare class ImageStencil extends TextStencil { static typeName: string; static title: string; protected static DEFAULT_TEXT: string; /** * Inner SVG string content of an SVG image (w/o the SVG tags). */ protected static svgString?: string; static getThumbnail(width: number, height: number): SVGSVGElement; /** * Main SVG or image element of the stencil. */ protected SVGImage?: SVGSVGElement | SVGImageElement; protected imageType: ImageType; protected _imageSrc?: string; get imageSrc(): string | undefined; set imageSrc(value: string | undefined); private _isImageSet; /** * Natural (real) width of the image. */ protected naturalWidth: number; /** * Natural (real) height of the image. */ protected naturalHeight: number; labelLocation: TextLabelLocation; /** * {@inheritDoc core!StencilBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); private _textBlockChangeProcessed; private textSizeChanged; protected setTextBoundingBox(): void; getSelectorPathD(width: number, height: number): string; ownsTarget(el: EventTarget): boolean; protected createImage(): void; createVisual(): void; adjustImage(): void; setStrokeColor(color: string): void; setFillColor(color: string): void; setStrokeWidth(width: number | string): void; setStrokeDasharray(dashes: string): void; setLabelLocation(location: TextLabelLocation): void; private toggleLabelVisibility; getState(): ImageStencilState; restoreState(state: ImageStencilState): void; } /** * Lightbulb icon stencil is an icon stencil displaying a lightbulb. * It's main purpose is to serve as a sample for creating icon/clipart * stencils by extending the {@link core!ImageStencil}. */ declare class LightbulbIconStencil extends ImageStencil { static typeName: string; static title: string; protected static DEFAULT_TEXT: string; protected static svgString: string; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); } /** * Label stencil is a simple text stencil with no outline or background. */ declare class LabelStencil extends TextStencil { static typeName: string; static title: string; protected static DEFAULT_TEXT: string; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); } declare class CustomImageStencil extends ImageStencil { static typeName: string; static title: string; protected static DEFAULT_TEXT: string; protected static getPathD(width: number, height: number): string; static getThumbnail(width: number, height: number): SVGSVGElement; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); setImageSrc(imageSrc?: string): void; } declare class BitmapImageStencil extends CustomImageStencil { static typeName: string; static title: string; constructor(iid: number, container: SVGGElement, settings: DiagramSettings); } /** * Represents a curved connector. */ declare class CurvedConnector extends ConnectorBase { static typeName: string; static getThumbnail(width: number, height: number): SVGSVGElement; /** * When set to `true` the last segment connected to the corner ports is drawn * at a 45 degree angle. */ protected andgledCorners: boolean; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); private getPathD; protected rotateArrows(): void; protected getEnding(baseEnding: IPoint, port?: Port): IPoint; createCoreVisual(): void; adjustVisual(): void; } /** * Angled connector is a type of connector comprised of vertical and horizontal lines only. */ declare class AngledConnector extends ConnectorBase { static typeName: string; static getThumbnail(width: number, height: number): SVGSVGElement; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); private startLineDir; private endLineDir; private stepPoints; private getPathD; protected rotateArrows(): void; protected getEnding(baseEnding: IPoint, port?: Port): IPoint; createCoreVisual(): void; adjustVisual(): void; protected setTextBoundingBox(): void; } /** * Arrow connector is a type of simple straight connector with an arrow pre-enabled on the end tip. */ declare class ArrowConnector extends ConnectorBase { static typeName: string; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); } /** * Represents a curved connector with an arrow pre-enabled on the end tip. */ declare class CurvedArrowConnector extends CurvedConnector { static typeName: string; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); } /** * Represents an angled connector with an arrow pointer pre-set. */ declare class AngledArrowConnector extends AngledConnector { static typeName: string; /** * {@inheritDoc core!ConnectorBase.constructor} */ constructor(iid: number, container: SVGGElement, settings: DiagramSettings); } /** * Stencil type descriptor containing stencil type and its display name. */ interface IStencilProperties { /** * Stencil type. */ stencilType: typeof StencilBase; /** * Stencil type's display name (if different from the original/default). */ displayName?: string; } /** * Connector type descriptor. */ interface IConnectorProperties { /** * Connector type. */ connectorType: typeof ConnectorBase; /** * Contextual connector type display name (if different from the original/default). */ displayName?: string; } /** * Stencil set descriptor. */ interface IStencilSet { /** * Stencil set identifier */ id: string; /** * Stencil set display name */ displayName: string; /** * Stencil types available in the stencil set. */ stencilTypes: IStencilProperties[]; /** * Connector types available in the stencil set. */ connectorTypes: IConnectorProperties[]; /** * Returns contextual properties for the supplied stencil type within a stencil set. * @param stencilType stencil type */ getStencilProperties(stencilType: typeof StencilBase | string): IStencilProperties | undefined; /** * Returns contextual connector type properties for the supplied connecter type within a stencil set. * @param connectorType connector type */ getConnectorProperties(connectorType: typeof ConnectorBase | string): IConnectorProperties | undefined; } /** * Represents a collection of stencils and connectors defining a particular diagram type. * * To define some diagram type you would create a `StencilSet` containing stencil and connector types * that make sense in the context of a particular diagram type. */ declare class StencilSet implements IStencilSet { id: string; displayName: string; stencilTypes: IStencilProperties[]; connectorTypes: IConnectorProperties[]; /** * Creates a new `StencilSet`. */ constructor(id: string, displayName?: string); getStencilProperties(stencilType: typeof StencilBase | string): IStencilProperties | undefined; getConnectorProperties(connectorType: typeof ConnectorBase | string): IConnectorProperties | undefined; } /** * Basic stencil set includes all the core stencils and connectors * available in MJS Diagram that are not special to any particular * diagram type. */ declare const basicStencilSet: StencilSet; /** * Utility class to simplify SVG operations. */ declare class SvgHelper { /** * Creates SVG "defs". */ static createDefs(): SVGDefsElement; /** * Sets attributes on an arbitrary SVG element * @param el - target SVG element. * @param attributes - set of name-value attribute pairs. */ static setAttributes(el: SVGElement, attributes: Array<[string, string]>): void; /** * Creates an SVG rectangle with the specified width and height. * @param width * @param height * @param attributes - additional attributes. */ static createRect(width: number | string, height: number | string, attributes?: Array<[string, string]>): SVGRectElement; /** * Creates an SVG line with specified end-point coordinates. * @param x1 * @param y1 * @param x2 * @param y2 * @param attributes - additional attributes. */ static createLine(x1: number | string, y1: number | string, x2: number | string, y2: number | string, attributes?: Array<[string, string]>): SVGLineElement; /** * Creates an SVG polygon with specified points. * @param points - points as string. * @param attributes - additional attributes. */ static createPolygon(points: string, attributes?: Array<[string, string]>): SVGPolygonElement; /** * Creates an SVG circle with the specified radius. * @param radius * @param attributes - additional attributes. */ static createCircle(radius: number, attributes?: Array<[string, string]>): SVGCircleElement; /** * Creates an SVG ellipse with the specified horizontal and vertical radii. * @param rx * @param ry * @param attributes - additional attributes. */ static createEllipse(rx: number, ry: number, attributes?: Array<[string, string]>): SVGEllipseElement; /** * Creates an SVG group. * @param attributes - additional attributes. */ static createGroup(attributes?: Array<[string, string]>): SVGGElement; /** * Creates an SVG transform. */ static createTransform(): SVGTransform; /** * Creates an SVG marker. * @param id * @param orient * @param markerWidth * @param markerHeight * @param refX * @param refY * @param markerElement */ static createMarker(id: string, orient: string, markerWidth: number | string, markerHeight: number | string, refX: number | string, refY: number | string, markerElement: SVGGraphicsElement): SVGMarkerElement; /** * Creaes an SVG text element. * @param attributes - additional attributes. */ static createText(attributes?: Array<[string, string]>): SVGTextElement; /** * Creates an SVG TSpan. * @param text - inner text. * @param attributes - additional attributes. */ static createTSpan(text: string, attributes?: Array<[string, string]>): SVGTSpanElement; /** * Creates an SVG image element. * @param attributes - additional attributes. */ static createImage(attributes?: Array<[string, string]>): SVGImageElement; /** * Creates an SVG point with the specified coordinates. * @param x * @param y */ static createPoint(x: number, y: number): SVGPoint; /** * Creates an SVG path with the specified shape (d). * @param d - path shape * @param attributes - additional attributes. */ static createPath(d: string, attributes?: Array<[string, string]>): SVGPathElement; /** * Creaes an SVG text element. * @param attributes - additional attributes. */ static createForeignObject(attributes?: Array<[string, string]>): SVGForeignObjectElement; /** * Returns local coordinates relative to the provided `localRoot` of a client (screen) point. * @param localRoot relative coordinate root * @param x horizontal client coordinate * @param y vertical client coordinate * @param zoomLevel zoom level * @returns local coordinates relative to `localRoot` */ static clientToLocalCoordinates(localRoot: SVGElement | undefined, x: number, y: number, zoomLevel?: number): IPoint; /** * Creates an SVG image element from a supplied inner SVG markup string. * @param stringSvg SVG markup (without the root svg tags) * @returns SVG image element */ static createSvgFromString(stringSvg: string): SVGSVGElement; } /** * Manages commercial licenses. * @ignore */ declare class Activator { private static keys; private static keyAddListeners; /** * Add a license key * @param product product identifier. * @param key license key sent to you after purchase. */ static addKey(product: string, key: string): void; /** * Add a function to be called when license key is added. * @param listener */ static addKeyAddListener(listener: () => void): void; /** * Remove a function called when key is added. * @param listener */ static removeKeyAddListener(listener: () => void): void; /** * Returns true if the product is commercially licensed. * @param product product identifier. */ static isLicensed(product: string): boolean; } export { Activator, AngledArrowConnector, AngledConnector, ArrowConnector, ArrowType, BitmapImageStencil, ColorType, ConnectorBase, ConnectorBaseState, ConnectorEndPoints, CurvedArrowConnector, CurvedConnector, CustomImageStencil, DiagramSettings, DiagramState, DiamondStencil, EllipseStencil, FontSize, IConnectorProperties, IPoint, ISize, IStencilProperties, IStencilSet, ImageStencil, ImageStencilState, ImageType, LabelStencil, LightbulbIconStencil, Port, PortLocation, RectangleTextStencil, StencilBase, StencilBaseState, StencilSet, SvgHelper, TextBlock, TextLabelLocation, TextStencil, TextStencilState, basicStencilSet };