import { Point } from '../../util/canvas-util'; import { Side } from '../../util/svg-util'; import { CollabTimestamp } from '../collab/primitives'; import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig } from '../config/diagram-config'; import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from '../config/diagram-look-config'; import { PropertySet } from '../property/property'; import { ValueSet } from '../property/value'; import { DiagramConnection } from './diagram-connection'; import { DiagramDecorator } from './diagram-decorator'; import { DiagramElement, DiagramElementSet } from './diagram-element'; import { DiagramEntity, DiagramEntitySet } from './diagram-entity'; import { DiagramField, LabeledElement } from './diagram-field'; import { DiagramModel } from './diagram-model'; import { DiagramPort } from './diagram-port'; import { DiagramResizer } from './diagram-resizer'; import { DiagramSection, DiagramSectionGeometry, DiagramSectionGrid } from './diagram-section'; /** * Default values of the look of a diagram node. * @private * @see DIAGRAM_NODE_TYPE_DEFAULTS */ export declare const DIAGRAM_NODE_LOOK_DEFAULTS: ShapedLookConfig; /** * Default values of the parameters of a diagram node. * @private * @see DiagramNode */ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: { name: string; defaultWidth: number; defaultHeight: number; minWidth: number; minHeight: number; defaultZ: number; resizableX: boolean; resizableY: boolean; snapToGridOffset: [number, number, number, number]; padding: number; label: null; ports: never[]; decorators: never[]; sectionGrid: null; look: ShapedLookConfig; isUnique: boolean; canBeParentless: boolean; childrenTypes: never[]; priority: number; properties: never[]; }; export type DiagramNodeGeometry = { readonly coords: Point; readonly z: number; readonly width: number; readonly height: number; readonly sections: { [sectionId: string]: DiagramSectionGeometry; }; readonly children: { [childId: string]: DiagramNodeGeometry; }; }; /** * The types allowed for the look of a node. * @public * @see Look * @see DiagramNode */ export type NodeLook = ShapedLook | ImageLook | StretchableImageLook; /** * A node type, which holds properties that nodes of this type share in common. * @public * @see NodeTypeConfig */ export declare class DiagramNodeType implements DiagramEntity { readonly id: string; name: string; defaultWidth: number; defaultHeight: number; minWidth: number; minHeight: number; defaultZ: number; resizerX: DiagramResizer; resizerY: DiagramResizer; resizerXY: DiagramResizer; snapToGridOffset: [number, number, number, number]; bottomPadding: number; leftPadding: number; rightPadding: number; topPadding: number; label: FieldConfig | null; ports: PortConfig[]; decorators: DecoratorConfig[]; sectionGrid: DiagramSectionGrid | null; defaultLook: NodeLook; selectedLook: NodeLook; highlightedLook: NodeLook; selectedAndHighlightedLook: NodeLook; isUnique: boolean; canBeParentless: boolean; childrenTypes: string[]; priority: number; propertySet: PropertySet; constructor(options: NodeTypeConfig); } /** * A node, the most basic element of a diagram, which can have connections to other nodes through its ports or be divided into sections. * @public * @see DiagramConnection * @see DiagramPort * @see DiagramSection */ export declare class DiagramNode extends DiagramElement implements LabeledElement { #private; get type(): DiagramNodeType; set type(type: DiagramNodeType); get typeString(): string; set typeString(typeString: string); /** * Additional properties of this node. * @public */ valueSet: ValueSet; /** * Variable used to preserve the original data of a node when importing from a different format. * @public */ originalData: unknown; /** * Label of this node. * @public */ label?: DiagramField; /** * Parent of this node. * @public */ parent?: DiagramNode; /** * Nodes contained within this node. * @public */ children: DiagramNode[]; /** * Sections of this node. * @public */ sections: DiagramSection[]; /** * Ports of this node. * @public */ ports: DiagramPort[]; /** * Decorators of this node. * @public */ decorators: DiagramDecorator[]; /** * Coordinates of the top left corner of this node. * @public */ coords: Point; /** * Collaborative timestamp for MoveCollabAction, SetGeometryCollabAction and SetParentCollabAction. * @public */ geometryTimestamp: CollabTimestamp | null; /** * Dimension of this node along the x axis. * @public */ width: number; /** * Dimension of this node along the y axis. * @public */ height: number; /** * The relative z coordinate of this node. Used to render this node below nodes with a higher z coordinate. * @public */ z: number; /** * Name of this node. Alias for this node's label's text. * @public */ get name(): string; set name(name: string); private _lookConfig?; private _defaultLook?; private _selectedLook?; private _highlightedLook?; private _selectedAndHighlightedLook?; /** * Current look of this node. * @private */ get look(): NodeLook; /** * An alias for the `lookConfig` attribute. * @private */ set look(look: ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig | undefined); /** * Look configuration used to derive the current look of this node. * @private */ get lookConfig(): ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig | undefined; /** * Sets the look configuration of the look to override the one determined by the type. * `undefined` resets it to the one determined by the type. * @private */ set lookConfig(lookConfig: ShapedLookConfig | ImageLookConfig | StretchableImageLookConfig | undefined); constructor(model: DiagramModel, type: DiagramNodeType, coords: Point | undefined, id: string); get removed(): boolean; updateInView(): void; raise(): void; /** * Put this element above other elements in the view if they have a lower z coordinate. */ raiseWithZ(): void; getPriority(): number; /** * Returns the horizontal resizer of this node. * @public */ getResizerX(): DiagramResizer; /** * Returns the vertical resizer of this node. * @public */ getResizerY(): DiagramResizer; /** * Returns the diagonal resizer of this node. * @public */ getResizerXY(): DiagramResizer; /** * Returns whether this node can be resized horizontally. * @public */ getResizableX(): boolean; /** * Returns whether this node can be resized vertically. * @public */ getResizableY(): boolean; /** * Returns whether this node can be resized diagonally. * @public */ getResizableXY(): boolean; /** * Get the port of this node which is closest to the given coordinates. * @param coords A point in the diagram. * @returns The port of this node closest to the given coordinates, `undefined` if this node has no ports. */ getClosestPortToPoint(coords: Point): DiagramPort | undefined; /** * Get all incoming connections of all ports of this node, not including incoming connections of sections of this node. * @public * @returns A list of connections. */ getIncomingConnections(includeRemoved?: boolean): DiagramConnection[]; /** * Get all outgoing connections of all ports of this node, not including outgoing connections of sections of this node. * @public * @returns A list of connections. */ getOutgoingConnections(includeRemoved?: boolean): DiagramConnection[]; /** * Get all connections of all ports of this node, not including connections of sections of this node. * @public * @returns A list of connections. */ getConnections(includeRemoved?: boolean): DiagramConnection[]; /** * Get all nodes that have a direct connection to this node, not including nodes that have a direct connection to sections of this node. * @public * @returns A list of nodes. */ getAdjacentNodes(includeRemoved?: boolean): DiagramNode[]; /** * Return the ancestor of this node which has no ancestors. If this node has no ancestors, returns itself. * @returns The ancestor of this node which has no ancestors. */ getLastAncestor(): DiagramNode; /** * Return true if this node is among the ancestors of the given node. * @param child A node. * @returns `true` if this node is among the ancestors of the given node, `false` otherwise. */ isAncestorOf(child: DiagramNode): boolean; /** * Return true if the given node is among the ancestors of this node. * @param child A node. * @returns `true` if the given node is among the ancestors of this node, `false` otherwise. */ isDescendantOf(child: DiagramNode): boolean; addChild(child: DiagramNode): void; removeChild(child: DiagramNode): void; fitToChild(child: DiagramNode): void; /** * Change the coordinates of this node to the given coordinates and move its sections, ports and labels correspondingly. * @public * @param coords A point in the diagram. */ move(coords: Point): void; /** * Change the dimensions of this node in the given direction by the given amount without changing the dimensions of the sections of this node. * @public * @param direction A direction. * @param distance A distance. */ stretch(direction: Side, distance: number): void; /** * Change the dimensions of this node and its sections in the given direction by the given amount, with the sections of the given index being stretched. * @public * @param direction A direction. * @param distance A distance. * @param indexX A section index. * @param indexY A section index. */ stretchSections(direction: Side, distance: number, indexX: number, indexY: number): void; /** * Returns the current values of all geometric properties (coordinates and dimensions) of this node and its sections. * @public */ getGeometry(excludeId?: string): DiagramNodeGeometry; /** * Sets all geometric properties (coordinates and dimensions) of this node and its sections. * @public */ setGeometry(geometry: DiagramNodeGeometry): void; /** * Removes all sections with the given index along the x axis. * @public */ removeSectionColumn(columnIndex: number): void; /** * Removes all sections with the given index along the y axis. * @public */ removeSectionRow(rowIndex: number): void; /** * Creates a copy of all sections with the given index along the x axis. * @public */ copySectionColumn(columnIndex: number): void; /** * Creates a copy of all sections with the given index along the y axis. * @public */ copySectionRow(rowIndex: number): void; } export declare class DiagramNodeSet extends DiagramElementSet { #private; /** * Set of the possible types of node that the nodes of this set can have. * @public */ readonly types: DiagramEntitySet; /** * Instance a set of nodes for the given model. This method is used internally. * @private */ constructor(model: DiagramModel); /** * Instance a new node and add it to this set. * @public * @param type The type of the node given as either the type itself or the id of the type. * @param coords The coordinates of the top left corner of the node in the diagram. * @param id The id of the node. Cannot be an empty string. * @returns The instanced node. */ new(type: DiagramNodeType | string, coords: Point, id: string): DiagramNode; remove(id: string): void; /** * Gets all the nodes that overlap with the given coordinates. * @public * @param x A coordinate along the x axis. * @param y A coordinate along the y axis. * @returns All the nodes that overlap with the given coordinates. */ getAtCoordinates(x: number, y: number): DiagramNode[]; } /** * Removes any nodes from the given list which are a descendant of another node in the list. * @param nodes A list of nodes. * @returns The given list of nodes minus any node that is a descendant of another node in the list. */ export declare const filterByOnlyAncestors: (nodes: DiagramNode[]) => DiagramNode[]; /** * Removes any nodes from the given list which are an ancestor of another node in the list. * @param nodes A list of nodes. * @returns The given list of nodes minus any node that is an ancestor of another node in the list. */ export declare const filterByOnlyDescendants: (nodes: DiagramNode[]) => DiagramNode[]; export declare const getBottomPadding: (config?: NodeTypeConfig | null) => number; export declare const getLeftPadding: (config?: NodeTypeConfig | null) => number; export declare const getRightPadding: (config?: NodeTypeConfig | null) => number; export declare const getTopPadding: (config?: NodeTypeConfig | null) => number;