markgojs
Version:
Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams
1,125 lines (897 loc) • 430 kB
TypeScript
// Type definitions for GoJS v1.8
// Project: https://gojs.net
// Definitions by: Northwoods Software <https://github.com/NorthwoodsSoftware>
// Definitions: https://github.com/NorthwoodsSoftware/GoJS
/* Copyright (C) 1998-2019 by Northwoods Software Corporation. */
declare namespace go {
/** A number in place of a Margin object is treated as a uniform Margin with that thickness */
export type MarginLike = Margin | number;
/** A string in place of a Brush object is treated as a Solid Brush of that color. */
export type BrushLike = Brush | string;
/** A Key is the type of the unique identifier managed by Models for each node data object. */
export type Key = string | number;
/** Either name a property or get/set the value of a property of an object. */
export type PropertyAccessor = string | ((data: any, newval: any) => any);
/** A constructor */
export type Constructor = new (...args: Array<any>) => Object;
/**
* An adornment is a special kind of Part that is associated with another Part,
* the Adornment.adornedPart.
* Adornments are normally associated with a particular GraphObject in the adorned part --
* that is the value of .adornedObject.
* However, the .adornedObject may be null, in which case the .adornedPart will also be null.
*/
export class Adornment extends Part {
/**
* @param {EnumValue=} type if not supplied, the default Panel type is Panel.Position.
*/
constructor(type?: EnumValue);
/**Gets or sets the GraphObject that is adorned.*/
adornedObject: GraphObject;
/**This read-only property returns the Part that contains the adorned object.*/
adornedPart: Part;
/**This read-only property returns a Placeholder that this Adornment may contain in its visual tree.*/
placeholder: Placeholder;
}
/**
* This class handles animations in a Diagram. Each Diagram has one, the Diagram.animationManager.
*/
export class AnimationManager {
/**You do not normally need to create an instance of this class because one already exists as the Diagram.animationManager, which you can modify.*/
constructor();
/**Gets or sets the duration for animations, in milliseconds. The default value is 600 milliseconds.*/
duration: number;
/**This read-only property is true when the AnimationManager is currently animating.*/
isAnimating: boolean;
/**Gets or sets whether this AnimationManager operates. The default value is true.*/
isEnabled: boolean;
/** Gets or sets whether an animation is performed on an initial layout. The default value is true.*/
isInitial: boolean;
/**This read-only property is true when the animation manager is in the middle of an animation tick.*/
isTicking: boolean;
/**
* Stops any running animation and updates the Diagram to its final state.
*/
stopAnimation(): void;
}
/**
* The Diagram.commandHandler implements various
* commands such as CommandHandler.deleteSelection or CommandHandler.redo.
* The CommandHandler includes keyboard event handling to interpret
* key presses as commands.
*/
export class CommandHandler {
/**
* The constructor produces a CommandHandler with the default key bindings.
*/
constructor();
/**Gets or sets a data object that is copied by .groupSelection when creating a new Group. The default value is null. The value must be an Object or null.*/
archetypeGroupData: any;
/**Gets or sets whether copySelection should also copy Links that connect with selected Nodes.*/
copiesConnectedLinks: boolean;
/**Gets or sets whether copySelection and copyToClipboard copy the node data property whose value is the containing group data's key. The default value is false.*/
copiesGroupKey: boolean;
/**Gets or sets whether copySelection and copyToClipboard copy the node data property whose value is the tree-parent node data's key. The default value is false.*/
copiesParentKey: boolean;
/**Gets or sets whether .copySelection should also copy subtrees. The default value is false.*/
copiesTree: boolean;
/**Gets or sets the Diagram.scale set by resetZoom. The default value is 1.0.*/
defaultScale: number;
/**Gets or sets whether .deleteSelection should also delete subtrees. The default value is false.*/
deletesTree: boolean;
/**Gets or sets whether .deleteSelection should also delete links that are connected with deleted nodes. The default value is true.*/
deletesConnectedLinks: boolean;
/**This read-only property returns the Diagram that is using this CommandHandler.*/
diagram: Diagram;
/**Gets or sets the predicate that determines whether or not a node may become a member of a group. The default predicate is null, which is equivalent to simply returning true.*/
memberValidation: (g: Group, p: Part) => boolean;
/**Gets or sets the amount by which .decreaseZoom and .increaseZoom change the Diagram.scale. The default value is 1.05 (5%).*/
zoomFactor: number;
/**
* Make sure all of the unnested Parts in the given collection are removed from any containing Groups.
* @param {Iterable<Part>} coll a collection of Parts.
* @param {boolean=} check whether to call .isValidMember to confirm that changing the Part to be a top-level Part is valid.
*/
addTopLevelParts(coll: Iterable<Part>, check?: boolean): boolean;
/**
* This predicate controls whether the user can collapse expanded Groups.
* @param {Group=} group if supplied, ignore the selection and consider collapsing this particular Group.
*/
canCollapseSubGraph(group?: Group): boolean;
/**
* This predicate controls whether the user can collapse expanded subtrees of Nodes.
* @param {Node=} node if supplied, ignore the selection and consider collapsing this particular Node.
*/
canCollapseTree(node?: Node): boolean;
/**
* This predicate controls whether or not the user can invoke the .copySelection command.
*/
canCopySelection(): boolean;
/**
* This predicate controls whether or not the user can invoke the .cutSelection command.
*/
canCutSelection(): boolean;
/**
* This predicate controls whether or not the user can invoke the .decreaseZoom command.
* @param {number=} factor This defaults to 1/.zoomFactor. The value should be less than one.
*/
canDecreaseZoom(factor?: number): boolean;
/**
* This predicate controls whether or not the user can invoke the .deleteSelection command.
*/
canDeleteSelection(): boolean;
/**
* This predicate controls whether or not the user can invoke the .editTextBlock command.
* @param {TextBlock=} textblock the TextBlock to consider editing.
*/
canEditTextBlock(textblock?: TextBlock): boolean;
/**
* This predicate controls whether the user can expand collapsed Groups.
* @param {Group=} group if supplied, ignore the selection and consider expanding this particular Group.
*/
canExpandSubGraph(group?: Group): boolean;
/**
* This predicate controls whether the user can expand collapsed subtrees of Nodes.
* @param {Node=} node if supplied, ignore the selection and consider expanding this particular Node.
*/
canExpandTree(node?: Node): boolean;
/**
* This predicate controls whether or not the user can invoke the .groupSelection command.
*/
canGroupSelection(): boolean;
/**
* This predicate controls whether or not the user can invoke the .increaseZoom command.
* @param {number=} factor This defaults to .zoomFactor. The value should be greater than one.
*/
canIncreaseZoom(factor?: number): boolean;
/**
* This predicate controls whether or not the user can invoke the .pasteSelection command.
*/
canPasteSelection(): boolean;
/**
* This predicate controls whether or not the user can invoke the .redo command.
*/
canRedo(): boolean;
/**
* This predicate controls whether or not the user can invoke the .resetZoom command.
* @param {number=} newscale This defaults to 1. The value should be greater than zero.
*/
canResetZoom(newscale?: number): boolean;
/**
* This predicate controls whether or not the user can invoke the scrollToPart command.
* This returns false if there is no argument Part and there are no selected Parts.
* @param {Part=} part This defaults to the first selected Part of Diagram.selection
* This returns true if Diagram.allowHorizontalScroll and Diagram.allowVerticalScroll are true.
*/
canScrollToPart(part?: Part): boolean;
/**
* This predicate controls whether or not the user can invoke the .selectAll command.
*/
canSelectAll(): boolean;
/**
* This predicate controls whether or not the user can invoke the .showContextMenu command.
* @param {GraphObject|Diagram=} obj a GraphObject or Diagram with a contextMenu defined.
* If none is given, this method will use the first selected object, or else the Diagram.
*/
canShowContextMenu(obj?: GraphObject | Diagram): boolean;
/**
* This predicate controls whether the user may stop the current tool.
*/
canStopCommand(): boolean;
/**
* This predicate controls whether or not the user can invoke the .undo command.
*/
canUndo(): boolean;
/**
* This predicate controls whether or not the user can invoke the .ungroupSelection command.
* @param {Group=} group if supplied, ignore the selection and consider ungrouping this particular Group.
*/
canUngroupSelection(group?: Group): boolean;
/**
* This predicate controls whether or not the user can invoke the .zoomToFit command.
*/
canZoomToFit(): boolean;
/**
* Collapse all expanded selected Groups.
* @param {Group=} group if supplied, ignore the selection and collapse this particular Group.
*/
collapseSubGraph(group?: Group): void;
/**
* Collapse all expanded selected Nodes.
* @param {Node=} node if supplied, ignore the selection and collapse this particular Node subtree.
*/
collapseTree(node?: Node): void;
/**
* Copy the currently selected parts, Diagram.selection, from the Diagram into the clipboard.
*/
copySelection(): void;
/**
* This makes a copy of the given collection of Parts and stores it in a static variable acting as the clipboard.
* @param {Iterable<Part>} coll A collection of Parts.
*/
copyToClipboard(coll: Iterable<Part>): void;
/**
* Execute a .copySelection followed by a .deleteSelection.
*/
cutSelection(): void;
/**
* Decrease the Diagram.scale by a given factor.
* @param {number=} factor This defaults to 1/.zoomFactor. The value should be less than one.
*/
decreaseZoom(factor?: number): void;
/**
* Delete the currently selected parts from the diagram.
*/
deleteSelection(): void;
/**
* This is called by tools to handle keyboard commands.
*/
doKeyDown(): void;
/**
* This is called by tools to handle keyboard commands.
*/
doKeyUp(): void;
/**
* Start in-place editing of a TextBlock in the selected Part.
* @param {TextBlock=} textblock the TextBlock to start editing.
*/
editTextBlock(textblock?: TextBlock): void;
/**
* Expand all collapsed selected Groups.
* @param {Group=} group if supplied, ignore the selection and expand this particular Group.
*/
expandSubGraph(group?: Group): void;
/**
* Expand all collapsed selected Nodes.
* @param {Node=} node if supplied, ignore the selection and collapse this particular Node subtree.
*/
expandTree(node?: Node): void;
/**
* Add a copy of .archetypeGroupData and add it to the diagram's model to create a new Group and then add the selected Parts to that new group.
*/
groupSelection(): void;
/**
* Increase the Diagram.scale by a given factor.
* @param {number=} factor This defaults to .zoomFactor. The value should be greater than one.
*/
increaseZoom(factor?: Number): void;
/**
* This predicate is called to determine whether a Node may be added as a member of a Group.
* @param {Group} group this may be null if the node is being added as a top-level node.
* @param {Part} part a Part, usually a Node, possibly another Group, but not a Link or an Adornment.
*/
isValidMember(group: Group, part: Part): boolean;
/**
* If the clipboard holds a collection of Parts, and if the Model.dataFormat matches that stored in the clipboard, this makes a copy of the clipboard's parts and adds the copies to this Diagram.
*/
pasteFromClipboard(): Set<Part>;
/**
* Copy the contents of the clipboard into this diagram, and make those new parts the new selection.
* @param {Point=} pos Point at which to center the newly pasted parts; if not present the parts are not moved.
*/
pasteSelection(pos?: Point): void;
/**
* Call UndoManager.redo.
*/
redo(): void;
/**
* Set the Diagram.scale to a new scale value, by default 1.
* @param {number=} newscale This defaults to 1. The value should be greater than zero.
*/
resetZoom(newscale?: number): void;
/**
* This command scrolls the diagram to make a highlighted or selected Part visible in the viewport.
* Call this command repeatedly to cycle through the Diagram.highlighteds collection,
* if there are any Parts in that collection, or else in the Diagram.selection collection,
* scrolling to each one in turn.
* <p>
* This is normally invoked by the <code>Space</code> keyboard shortcut.
* If there is no argument and there is no highlighted or selected Part, this command does nothing.
* @param {Part=} part This defaults to the first highlighted Part of Diagram.highlighteds,
* or, if there are no highlighted Parts, the first selected Part.
*/
scrollToPart(part?: Part): void;
/**
* Select all of the selectable Parts in the diagram.
*/
selectAll(): void;
/**
* Open the context menu of a given GraphObject.
* The given GraphObject must have a GraphObject.contextMenu
* defined in order to show anything.
* @param {GraphObject|Diagram=} obj a GraphObject or Diagram with a contextMenu defined.
* If none is given, this method will use the first selected object, or else the Diagram.
*/
showContextMenu(obj?: GraphObject | Diagram): void;
/**
* Cancel the operation of the current tool.
*/
stopCommand(): void;
/**
* Call UndoManager.undo.
*/
undo(): void;
/**
* Remove the group from the diagram without removing its members from the diagram.
* @param {Group=} group if supplied, ignore the selection and consider ungrouping this particular Group.
*/
ungroupSelection(group?: Group): void;
/**
* Change the Diagram.scale so that the Diagram.documentBounds fits within the viewport.
*/
zoomToFit(): void;
}
/**
* A Diagram is associated with an HTML DIV element. Constructing a Diagram creates
* an HTML Canvas element which it places inside of the given DIV element, in addition to several helper divs.
* GoJS will manage the contents of this DIV, and the contents should not be modified otherwise,
* though the given DIV may be styled (background, border, etc) and positioned as needed.
*/
export class Diagram {
/**
* Construct an empty Diagram for a particular DIV HTML element.
* @param {HTMLDivElement} div A reference to a DIV HTML element in the DOM.
* If no DIV is supplied one will be created in memory. The Diagram's Diagram.div property
* can then be set later on.
*/
constructor(div: HTMLDivElement);
/**
* Construct an empty Diagram for a particular DIV HTML element.
* @param {string=} div The ID of a DIV element in the DOM.
* If no DIV identifier is supplied one will be created in memory. The Diagram's Diagram.div property
* can then be set later on.
*/
constructor(div?: string);
/**Gets or sets whether the user may copy to or paste parts from the internal clipboard.*/
allowClipboard: boolean;
/**Gets or sets whether the user may copy objects.*/
allowCopy: boolean;
/**Gets or sets whether the user may delete objects from the Diagram.*/
allowDelete: boolean;
/**Gets or sets whether the user may start a drag-and-drop in this Diagram, possibly dropping in a different element.*/
allowDragOut: boolean;
/**Gets or sets whether the user may end a drag-and-drop operation in this Diagram.*/
allowDrop: boolean;
/**Gets or sets whether the user may group parts together.*/
allowGroup: boolean;
/**Gets or sets whether the user is allowed to use the horizontal scrollbar.*/
allowHorizontalScroll: boolean;
/**Gets or sets whether the user may add parts to the Diagram.*/
allowInsert: boolean;
/**Gets or sets whether the user may draw new links.*/
allowLink: boolean;
/**Gets or sets whether the user may move objects.*/
allowMove: boolean;
/**Gets or sets whether the user may reconnect existing links.*/
allowRelink: boolean;
/**Gets or sets whether the user may reshape parts.*/
allowReshape: boolean;
/**Gets or sets whether the user may resize parts.*/
allowResize: boolean;
/**Gets or sets whether the user may rotate parts.*/
allowRotate: boolean;
/**Gets or sets whether the user may select objects.*/
allowSelect: boolean;
/**Gets or sets whether the user may do in-place text editing.*/
allowTextEdit: boolean;
/**Gets or sets whether the user may undo or redo any changes.*/
allowUndo: boolean;
/**Gets or sets whether the user may ungroup existing groups.*/
allowUngroup: boolean;
/**Gets or sets whether the user is allowed to use the vertical scrollbar.*/
allowVerticalScroll: boolean;
/**Gets or sets whether the user may zoom into or out of the Diagram.*/
allowZoom: boolean;
/**This read-only property returns the AnimationManager for this Diagram.*/
animationManager: AnimationManager;
/**Gets or sets the autoScale of the Diagram, controlling whether or not the Diagram's bounds automatically scale to fit the view.*/
autoScale: EnumValue;
/**Gets or sets the Margin (or number for a uniform Margin) that describes the Diagram's autoScrollRegion.*/
autoScrollRegion: MarginLike;
/**Gets or sets the function to execute when the user single-primary-clicks on the background of the Diagram.*/
click: (e: InputEvent) => void;
/**Gets or sets the CommandHandler for this Diagram.*/
commandHandler: CommandHandler;
/**Gets or sets the content alignment Spot of this Diagram, to be used in determining how parts are positioned when the .viewportBounds width or height is smaller than the .documentBounds.*/
contentAlignment: Spot;
/**Gets or sets the function to execute when the user single-secondary-clicks on the background of the Diagram.*/
contextClick: (e: InputEvent) => void;
/**This Adornment or HTMLInfo is shown when the use context clicks in the background.*/
contextMenu: Adornment | HTMLInfo;
/**Gets or sets the current cursor for the Diagram, overriding the .defaultCursor.*/
currentCursor: string;
/**Gets or sets the current tool for this Diagram that handles all input events.*/
currentTool: Tool;
/**Gets or sets the cursor to be used for the Diagram when no GraphObject specifies a different cursor.*/
defaultCursor: string;
/**Gets or sets the default tool for this Diagram that becomes the current tool when the current tool stops.*/
defaultTool: Tool;
/**Gets or sets the Diagram's HTMLDivElement, via an HTML Element ID.*/
div: HTMLDivElement;
/**This read-only property returns the model-coordinate bounds of the Diagram.*/
documentBounds: Rect;
/**Gets or sets the function to execute when the user double-primary-clicks on the background of the Diagram.*/
doubleClick: (e: InputEvent) => void;
/**Gets or sets the most recent mouse-down InputEvent that occurred.*/
firstInput: InputEvent;
/**Gets or sets a fixed bounding rectangle to be returned by .documentBounds and .computeBounds.*/
fixedBounds: Rect;
/**Gets or sets the scrollMode of the Diagram.*/
scrollMode: EnumValue;
/**Gets or sets the Margin (or number for a uniform Margin) that describes a scrollable area that surrounds the document bounds, allowing the user to scroll into empty space.*/
scrollMargin: MarginLike;
/**Gets or sets whether the page may be scrolled when the diagram receives focus.*/
scrollsPageOnFocus: boolean;
/**Gets or sets the function used to determine the position that this Diagram can be scrolled or moved to.*/
positionComputation: (d: Diagram, p: Point) => Point;
/**Gets or sets the function used to determine the scale that this Diagram can be set to.*/
scaleComputation: (d: Diagram, s: number) => number;
/**Gets or sets a Panel of type Panel.Grid acting as the background grid extending across the whole viewport of this diagram.*/
grid: Panel;
/**Gets or sets the default selection Adornment template, used to adorn selected Groups.*/
groupSelectionAdornmentTemplate: Adornment;
/**Gets or sets the default Group template used as the archetype for group data that is added to the .model.*/
groupTemplate: Group;
/**Gets or sets a Map mapping template names to Groups.*/
groupTemplateMap: Map<string,Group>;
/**Gets or sets whether the Diagram has a horizontal Scrollbar.*/
hasHorizontalScrollbar: boolean;
/**Gets or sets whether the Diagram has a vertical Scrollbar.*/
hasVerticalScrollbar: boolean;
/**This read-only property returns the read-only collection of highlighted Parts.*/
highlighteds: Set<Part>;
/**Gets or sets the initialAutoScale of the Diagram.*/
initialAutoScale: EnumValue;
/**Gets or sets the initial content alignment Spot of this Diagram, to be used in determining how parts are positioned initially relative to the viewport.*/
initialContentAlignment: Spot;
/**Gets or sets the spot in the document's area that should be coincident with the .initialViewportSpot of the viewport when the document is first initialized.*/
initialDocumentSpot: Spot;
/**Gets or sets the initial coordinates of this Diagram in the viewport, eventually setting the .position.*/
initialPosition: Point;
/**Gets or sets the initial scale of this Diagram in the viewport, eventually setting the .scale.*/
initialScale: number;
/**Gets or sets the spot in the viewport that should be coincident with the .initialDocumentSpot of the document when the document is first initialized.*/
initialViewportSpot: Spot;
/**Gets or sets whether the user may interact with the Diagram.*/
isEnabled: boolean;
/**Gets or sets whether the Diagram's Diagram.model is Model.isReadOnly.*/
isModelReadOnly: boolean;
/**Gets or sets whether this Diagram's state has been modified.*/
isModified: boolean;
/**Gets or sets whether mouse events initiated within the Diagram will be captured.*/
isMouseCaptured: boolean;
/**Gets or sets whether the Diagram may be modified by the user, while still allowing the user to scroll, zoom, and select.*/
isReadOnly: boolean;
/**Gets or sets whether the Diagram tree structure is defined by links going from the parent node to their children, or vice-versa.*/
isTreePathToChildren: boolean;
/**Gets or sets the last InputEvent that occurred.*/
lastInput: InputEvent;
/**Gets an iterator for this Diagram's Layers.*/
layers: Iterator<Layer>;
/**Gets or sets the Layout used to position all of the top-level nodes and links in this Diagram.*/
layout: Layout;
/**Returns an iterator of all Links in the Diagram.*/
links: Iterator<Link>;
/**Gets or sets the default selection Adornment template, used to adorn selected Links.*/
linkSelectionAdornmentTemplate: Adornment;
/**Gets or sets the default Link template used as the archetype for link data that is added to the .model.*/
linkTemplate: Link;
/**Gets or sets a Map mapping template names to Links.*/
linkTemplateMap: Map<string,Link>;
/**Gets or sets the largest value that .scale may take.*/
maxScale: number;
/**Gets or sets the maximum number of selected objects.*/
maxSelectionCount: number;
/**Gets or sets the smallest value greater than zero that .scale may take.*/
minScale: number;
/**Gets or sets the Model holding data corresponding to the data-bound nodes and links of this Diagram.*/
model: Model;
/**Gets or sets the function to execute when the user is dragging the selection in the background of the Diagram during a DraggingTool drag-and-drop, not over any GraphObjects.*/
mouseDragOver: (e: InputEvent) => void;
/**Gets or sets the function to execute when the user drops the selection in the background of the Diagram at the end of a DraggingTool drag-and-drop, not onto any GraphObjects.*/
mouseDrop: (e: InputEvent) => void;
/**Gets or sets the function to execute when the user holds the mouse stationary in the background of the Diagram while holding down a button, not over any GraphObjects.*/
mouseHold: (e: InputEvent) => void;
/**Gets or sets the function to execute when the user holds the mouse stationary in the background of the Diagram without holding down any buttons, not over any GraphObjects.*/
mouseHover: (e: InputEvent) => void;
/**Gets or sets the function to execute when the user moves the mouse in the background of the Diagram without holding down any buttons, not over any GraphObjects.*/
mouseOver: (e: InputEvent) => void;
/**Returns an iterator of all Nodes and Groups in the Diagram.*/
nodes: Iterator<Node>;
/**Gets or sets the default selection Adornment template, used to adorn selected Parts other than Groups or Links.*/
nodeSelectionAdornmentTemplate: Adornment;
/**Gets or sets the default Node template used as the archetype for node data that is added to the .model.*/
nodeTemplate: Part;
/**Gets or sets a Map mapping template names to Parts.*/
nodeTemplateMap: Map<string,Part>;
/**Gets or sets the Margin (or number for a uniform Margin) that describes the Diagram's padding, which controls how much extra space there is around the area occupied by the document.*/
padding: MarginLike;
/**Returns an iterator of all Parts in the Diagram that are not Nodes or Links or Adornments.*/
parts: Iterator<Part>;
/**Gets or sets the coordinates of this Diagram in the viewport.*/
position: Point;
/**Gets or sets the scale transform of this Diagram.*/
scale: number;
/**Gets or sets the distance in screen pixels that the horizontal scrollbar will scroll when scrolling by a line.*/
scrollHorizontalLineChange: number;
/**Gets or sets the distance in screen pixels that the vertical scrollbar will scroll when scrolling by a line.*/
scrollVerticalLineChange: number;
/**This read-only property returns the read-only collection of selected Parts.*/
selection: Set<Part>;
/**Gets or sets whether ChangedEvents are not recorded by the UndoManager.*/
skipsUndoManager: boolean;
/**This read-only property returns the ToolManager for this Diagram.*/
toolManager: ToolManager;
/**This Adornment or HTMLInfo is shown when the mouse stays motionless in the background.*/
toolTip: Adornment | HTMLInfo;
/**This read-only property returns the UndoManager for this Diagram, which actually belongs to the .model.*/
undoManager: UndoManager;
/**Gets or sets what kinds of graphs this diagram allows the user to draw.*/
validCycle: EnumValue;
/**This read-only property returns the bounds of the portion of the Diagram that is viewable from its HTML Canvas.*/
viewportBounds: Rect;
/**Gets or sets the point, in viewport coordinates, where changes to the .scale will keep the focus in the document.*/
zoomPoint: Point;
/**
* Adds a Part to the Layer that matches the Part's Part.layerName, or else to the default layer, which is named with the empty string.
* @param {Part} part
*/
add(part: Part): void;
/**
* Register an event handler that is called when there is a ChangedEvent.
* @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument.
*/
addChangedListener(listener: (e: ChangedEvent) => void ): void;
/**
* Register an event handler that is called when there is a DiagramEvent of a given name.
* @param {string} name the name is normally capitalized, but this method uses case-insensitive comparison.
* @param {function(DiagramEvent)} listener a function that takes a DiagramEvent as its argument.
*/
addDiagramListener(name: string, listener: (e: DiagramEvent) => void ): void;
/**
* Register an event handler that is called when there is a ChangedEvent for the Diagram's Model.
* @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument.
*/
addModelChangedListener(listener: (e: ChangedEvent) => void ): void;
/**
* Adds a Layer to the list of layers.
* @param {Layer} layer The Layer to add.
*/
addLayer(layer: Layer): void;
/**
* Adds a layer to the list of layers after a specified layer.
* @param {Layer} layer The Layer to add.
* @param {Layer} existingLayer The layer to insert after.
*/
addLayerAfter(layer: Layer, existingLayer: Layer): void;
/**
* Adds a layer to the list of layers before a specified layer.
* @param {Layer} layer The Layer to add.
* @param {Layer} existingLayer The layer to insert before.
*/
addLayerBefore(layer: Layer, existingLayer: Layer): void;
/**
* Aligns the Diagram's .position based on a desired document Spot and viewport Spot.
* @param {Spot} documentspot
* @param {Spot} viewportspot
*/
alignDocument(documentspot: Spot, viewportspot: Spot): void;
/**
* Modifies the .position to show a given Rect of the Diagram by centering the viewport on that Rect.
* @param {Rect} r
*/
centerRect(r: Rect): void;
/**
* Removes all Parts from the Diagram, including unbound Parts and the background grid, and also clears out the Model and UndoManager.
*/
clear(): void;
/**
* Remove highlights from all Parts.
*/
clearHighlighteds(): void;
/**
* Deselect all selected Parts.
*/
clearSelection(): void;
/**
* Starts a new transaction, calls the provided function, and commits the transaction.
* Code is called within a try-finally loop.
* If the function does not return normally, this rolls back the transaction rather than committing it.
* Example usage:
* <pre>
* diagram.commit(d => d.model.addNodeData({ counter: myCounter++ }), "Added Node");
* </pre>
* @param {function(Diagram)} func
* @param {(string|null)=} tname a descriptive name for the transaction, or null to temporarily set {@link #skipsUndoManager} to true;
* if no string transaction name is given, an empty string is used as the transaction name
*/
commit(func: (d: Diagram) => void, tname?: string|null): void;
/**
* Commit the changes of the current transaction.
* This just calls UndoManager.commitTransaction.
* @param {string=} tname a descriptive name for the transaction.
*/
commitTransaction(tname?: string): boolean;
/**
* This is called during a Diagram update to determine a new value for .documentBounds.
*/
computeBounds(): Rect;
/**
* Find the union of the GraphObject.actualBounds of all of the Parts in the given collection.
* @param {Iterable<Part>} coll a collection of Parts.
* @param {boolean=} includeLinks, defaults to false
*/
computePartsBounds(coll: Iterable<Part>, includesLinks?: boolean): Rect;
/**
* Make a copy of a collection of Parts and return them in a Map mapping each original Part to its copy.
* @param {Iterable<Part>} coll A List or a Set or Iterator of Parts.
* @param {Diagram} diagram The destination diagram; if null, the copied parts are not added to this diagram.
* @param {boolean} check Whether to check Part.canCopy on each part.
*/
copyParts(coll: Iterable<Part>, diagram: Diagram, check: boolean): Map<Part, Part>;
/**
* Updates the diagram immediately, then resets initialization flags so that actions taken in the argument function will be considered part of Diagram initialization, and will participate in initial layouts, .initialAutoScale, .initialContentAlignment, etc.
* @param {function()|null=} func an optional function of actions to perform as part of another diagram initialization.
*/
delayInitialization(func?: () => void ): void;
/**
* Finds a layer with a given name.
* @param {string} name
*/
findLayer(name: string): Layer;
/**
* Look for a Link corresponding to a GraphLinksModel's link data object.
* @param {Object} linkdata
*/
findLinkForData(linkdata: Object): Link;
/**
* Return a collection of Links that are bound to data whose properties have values
* that match those specified by the given example data.
* @param {...Object} examples
*/
findLinksByExample(...examples: Array<Object>): Iterator<Link>;
/**
* Look for a Node or Group corresponding to a model's node data object.
* @param {Object} nodedata
*/
findNodeForData(nodedata: Object): Node;
/**
* Look for a Node or Group corresponding to a model's node data object's unique key.
* @param {*} key a string or number.
*/
findNodeForKey(key: Key): Node;
/**
* Return a collection of Nodes and Groups that are bound to data whose properties have values
* that match those specified by the given example data.
* @param {...Object} examples
*/
findNodesByExample(...examples: Array<Object>): Iterator<Node>;
/**
* Find the front-most GraphObject at the given point in document coordinates.
* @param {Point} p A Point in document coordinates.
* @param {function(GraphObject):GraphObject | null=} navig A function taking a GraphObject and
* returning a GraphObject, defaulting to the identity.
* @param {function(GraphObject):boolean | null=} pred A function taking the GraphObject
* returned by navig and returning true if that object should be returned,
* defaulting to a predicate that always returns true.
*/
findObjectAt(p: Point, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean): GraphObject;
/**
* Return a collection of the GraphObjects at the given point in document coordinates.
* @param {Point} p A Point in document coordinates.
* @param {function(GraphObject):GraphObject | null=} navig A function taking a GraphObject and
* returning a GraphObject, defaulting to the identity.
* If this function returns null, the given GraphObject will not be included in the results.
* @param {function(GraphObject):boolean | null=} pred A function taking the GraphObject
* returned by navig and returning true if that object should be returned,
* defaulting to a predicate that always returns true.
* @param {List|Set=} coll An optional collection (List or Set) to add the results to.
*/
findObjectsAt(p: Point, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, coll?: List<GraphObject>): List<GraphObject>;
findObjectsAt(p: Point, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, coll?: Set<GraphObject>): Set<GraphObject>;
/**
* Returns a collection of all GraphObjects that are inside or that intersect a given Rect in document coordinates.
* @param {Rect} r A Rect in document coordinates.
* @param {function(GraphObject):GraphObject | null=} navig A function taking a GraphObject and
* returning a GraphObject, defaulting to the identity.
* If this function returns null, the given GraphObject will not be included in the results.
* @param {function(GraphObject):boolean | null=} pred A function taking the GraphObject
* returned by navig and returning true if that object should be returned,
* defaulting to a predicate that always returns true.
* @param {boolean=} partialInclusion Whether an object can match if it merely intersects the rectangular area (true) or
* if it must be entirely inside the rectangular area (false). The default value is false.
* @param {List|Set=} coll An optional collection (List or Set) to add the results to.
*/
findObjectsIn(r: Rect, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, partialInclusion?: boolean, coll?: List<GraphObject>): List<GraphObject>;
findObjectsIn(r: Rect, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, partialInclusion?: boolean, coll?: Set<GraphObject>): Set<GraphObject>;
/**
* Returns a collection of all GraphObjects that are within a certain distance of a given point in document coordinates.
* @param {Point} p A Point in document coordinates.
* @param {number} dist The distance from the point.
* @param {function(GraphObject):GraphObject | null=} navig A function taking a GraphObject and
* returning a GraphObject, defaulting to the identity.
* If this function returns null, the given GraphObject will not be included in the results.
* @param {function(GraphObject):boolean | null=} pred A function taking the GraphObject
* returned by navig and returning true if that object should be returned,
* defaulting to a predicate that always returns true.
* @param {boolean=} partialInclusion Whether an object can match if it merely intersects the circular area (true) or
* if it must be entirely inside the circular area (false). The default value is true.
* The default is true.
* @param {List|Set=} coll An optional collection (List or Set) to add the results to.
*/
findObjectsNear(p: Point, dist: number, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, partialInclusion?: boolean, coll?: List<GraphObject>): List<GraphObject>;
findObjectsNear(p: Point, dist: number, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, partialInclusion?: boolean, coll?: Set<GraphObject>): Set<GraphObject>;
/**
* This convenience function finds the front-most Part that is at a given point and that might be selectable.
* @param {Point} p a Point in document coordinates.
* @param {boolean} selectable Whether to only consider parts that are Part.selectable.
*/
findPartAt(p: Point, selectable: boolean): Part;
/**
* Look for a Part, Node, Group, or Link corresponding to a Model's data object.
* @param {Object} data
*/
findPartForData(data: Object): Part;
/**
* Look for a Part or Node or Group corresponding to a model's data object's unique key.
* May return a Link if the GraphLinksModel is maintaining keys for link data.
* @param {*} key a string or number.
*/
findPartForKey(key: Key): Part;
/**
* Returns an iterator of all Groups that are at top-level, in other words that are not themselves inside other Groups.
*/
findTopLevelGroups(): Iterator<Group>;
/**
* Returns an iterator of all top-level Nodes that have no tree parents.
*/
findTreeRoots(): Iterator<Node>;
/**
* Explicitly bring focus to the Diagram's canvas.
*/
focus(): void;
/**
* This static function gets the Diagram that is attached to an HTML DIV element.
* @param {HTMLDivElement} div
*/
static fromDiv(div: HTMLDivElement): Diagram;
/**
* Make the given part the only highlighted part.
* @param {Part} part
*/
highlight(part: Part): void;
/**
* Highlight all of the Parts supplied in the given collection, and clear all other highlighted Parts.
* @param {Iterable<Part>|Array<Part>} coll an Iterable of Parts
*/
highlightCollection(coll: Iterable<Part> | Array<Part>): void;
/**
* This static function declares that a class (constructor function) derives from another class -- but please note that most classes do not support inheritance.
* @param {Function} derivedclass
* @param {Function} baseclass
*/
static inherit(derivedclass: Constructor, baseclass: Constructor): void;
/**
* Perform all invalid layouts.
* @param {boolean=} invalidateAll If true, this will explicitly set Layout.isValidLayout to false on each Layout in the diagram.
*/
layoutDiagram(invalidateAll?: boolean): void;
/**
* Create an HTMLImageElement that contains a bitmap of the current Diagram.
* @param {Object=} properties For details see the argument description of .makeImageData.
*/
makeImage(properties?: {
size?: Size,
scale?: number,
maxSize?: Size,
position?: Point,
parts?: Iterable<Part>,
padding?: MarginLike,
background?: BrushLike,
showTemporary?: boolean,
showGrid?: boolean,
document?: Document,
type?: string,
details?: any
}): HTMLImageElement;
/**
* Create a bitmap of the current Diagram encoded as an ImageData, or a base64-encoded string describing the image.
* @param {Object=} properties a JavaScript object detailing optional arguments for image creation, to be passed to makeImageData.
*/
makeImageData(properties?: {
size?: Size,
scale?: number,
maxSize?: Size,
position?: Point,
parts?: Iterable<Part>,
padding?: MarginLike,
background?: BrushLike,
showTemporary?: boolean,
showGrid?: boolean,
document?: Document,
returnType?: string,
callback?: void,
type?: string,
details?: any
}): ImageData | string;
/**
* Create an SVGElement that contains a SVG rendering of the current Diagram.
* By default this method returns a snapshot of the visible diagram, but optional arguments give more options.
* @param {Object=} properties a JavaScript object detailing optional arguments for SVG creation.
*/
makeSvg(properties?: {
size?: Size,
scale?: number,
maxSize?: Size,
position?: Point,
parts?: Iterable<Part>,
padding?: MarginLike,
background?: BrushLike,
showTemporary?: boolean,
showGrid?: boolean,
document?: Document,
elementFinished?: (obj: GraphObject, elt: SVGElement) => void
}): SVGElement;
/**
* Move a collection of Parts in this Diagram by a given offset.
* @param {Iterable<Part>} coll A List or a Set or Iterator of Parts.
* @param {Point} offset the X and Y change to be made to each Part, in document coordinates.
* @param {boolean} check Whether to check Part.canMove on each part.
*/
moveParts(coll: Iterable<Part>, offset: Point, check: boolean): void;
/**
* Remove all of the Parts created from model data and then create them again.
*/
rebuildParts(): void;
/**
* Removes a Part from its Layer, provided the Layer is in this Diagram.
* @param {Part} part
*/
remove(part: Part): void;
/**
* Unregister an event handler listener.
* @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument.
*/
removeChangedListener(listener: (e: ChangedEvent) => void ): void;
/**
* Unregister a DiagramEvent handler.
* @param {string} name the name is normally capitalized, but this method uses case-insensitive comparison.
* @param {function(DiagramEvent)} listener a function that takes a DiagramEvent as its argument.
*/
removeDiagramListener(name: string, listener: (e: DiagramEvent) => void ): void;
/**
* Unregister an event handler listener for the Diagram's Model.
* @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument.
*/
removeModelChangedListener(listener: (e: ChangedEvent) => void ): void;
/**
* Removes the given layer from the list of layers.
* @param {Layer} layer
*/
removeLayer(layer: Layer): void;
/**
* This method removes from this Diagram all of the Parts in a collection.
* @param {Iterable<Part>|Array<Part>} coll A List or Set or Iterator of Parts.
* @param {boolean} check Whether to check Part.canDelete on each part.
*/
removeParts(coll: Iterable<Part> | Array<Part>, check: boolean): void;
/**
* Requests that in the near-future the diagram makes sure all GraphObjects are arranged,
* recomputes the document bounds, updates the scrollbars, and redraws the viewport.
* Usage of this method is uncommon and may affect performance --
* for efficiency do not call this method unless you have a well-defined need.
* Normally, GoJS updates the diagram automatically, and completeing a transaction ensures an immediate update.
* <p>
* @param {boolean=} alwaysQueueUpdate If true the Diagram will queue another update,
* even if an update is already occurring. The default value is false.
* Side effects in an "InitialLayoutCompleted" DiagramEvent listener might necessitate setting this parameter.
*/
requestUpdate(alwaysQueueUpdate?: boolean): void;
/**
* Rollback the current transaction, undoing any recorded changes.
* This just calls UndoManager.rollbackTransaction.
*/
rollbackTransaction(): boolean;
/**
* Scrolling function used by primarily by .commandHandler's CommandHandler.doKeyDown.
* @param {string} unit A string representing the unit of the scroll operation. Can be 'pixel', 'line', or 'page'.