typescript-closure-tools
Version:
Command-line tools to convert closure-style JSDoc annotations to typescript, and to convert typescript sources to closure externs files
1,143 lines (886 loc) • 343 kB
TypeScript
// Type definitions for GoJS 1.2
// Project: http://gojs.net
// Definitions by: Barbara Duckworth <https://github.com/barbara42/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* Copyright (C) 1998-2013 by Northwoods Software Corporation. */
// A number of types have been declared "any" because they would best be described by a union of specific types,
// not as truly "any" type, and TypeScript does not support union types. Most of the cases are due to:
// - a property of type Margin whose setter also accepts a number, for a uniform Margin of that thickness
// - a property of type Brush whose setter also accepts a string, a CSS color string for a solid color Brush
// - a boolean property that may also be null (tri-state)
// - a key type, which may be a string or a number, uniquely identifying a node data within a Model
// - a property that is string that names a property or that is a function that gets or sets a value, on an Object in a Model
declare module go {
/**
* 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.
*/
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;
/**Gets the Part that contains the adorned object.*/
adornedPart: Part;
/**Gets a Placeholder that this Adornment may contain in its visual tree.*/
placeholder: Placeholder;
}
/**
* 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.
*/
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.*/
archetypeGroupData: Object;
/**Gets or sets whether #copySelection should also copy subtrees.*/
copiesTree: boolean;
/**Gets or sets whether #deleteSelection should also delete subtrees.*/
deletesTree: boolean;
/**Gets 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.*/
memberValidation: (g: Group, p: Part) => boolean;
/**Gets or sets the amount by which #decreaseZoom and #increaseZoom change the Diagram#scale; default is 1.05.*/
zoomFactor: number;
/**
* Make sure all of the unnested Parts in the given collection are removed from any containing Groups.
* @param {Iterable} 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, 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 #selectAll command.
*/
canSelectAll(): 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);
/**
* Collapse all expanded selected Nodes.
* @param {Node=} node if supplied, ignore the selection and collapse this particular Node subtree.
*/
collapseTree(node?: Node);
/**
* Copy the currently selected parts, Diagram#selection, from the Diagram into the clipboard.
*/
copySelection();
/**
* This makes a copy of the given collection of Parts and stores it in a static variable acting as the clipboard.
* @param {Iterable} coll A collection of Parts.
*/
copyToClipboard(coll: Iterable);
/**
* Execute a #copySelection followed by a #deleteSelection.
*/
cutSelection();
/**
* 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);
/**
* Delete the currently selected parts from the diagram.
*/
deleteSelection();
/**
* This is called by tools to handle keyboard commands.
*/
doKeyDown();
/**
* This is called by tools to handle keyboard commands.
*/
doKeyUp();
/**
* Start in-place editing of a TextBlock in the selected Part.
* @param {TextBlock=} textblock the TextBlock to start editing.
*/
editTextBlock(textblock?: TextBlock);
/**
* Expand all collapsed selected Groups.
* @param {Group=} group if supplied, ignore the selection and expand this particular Group.
*/
expandSubGraph(group?: Group);
/**
* Expand all collapsed selected Nodes.
* @param {Node=} node if supplied, ignore the selection and collapse this particular Node subtree.
*/
expandTree(node?: Node);
/**
* 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();
/**
* 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);
/**
* 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;
/**
* 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);
/**
* Call UndoManager#redo.
*/
redo();
/**
* 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);
/**
* Select all of the selectable Parts in the diagram.
*/
selectAll();
/**
* Cancel the operation of the current tool.
*/
stopCommand();
/**
* Call UndoManager#undo.
*/
undo();
/**
* 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);
/**
* Change the Diagram#scale so that the Diagram#documentBounds fits within the viewport.
*/
zoomToFit();
}
/**
* 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.
*/
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;
/**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: any;
/**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 is shown when the use context clicks in the background.*/
contextMenu: Adornment;
/**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;
/**Gets 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 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;
/**Gets or sets whether the Diagram has a horizontal Scrollbar.*/
hasHorizontalScrollbar: boolean;
/**Gets or sets whether the Diagram has a vertical Scrollbar.*/
hasVerticalScrollbar: boolean;
/**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;
/**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;
/**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;
/**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;
/**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;
/**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: any;
/**Returns an iterator of all Parts in the Diagram that are not Nodes or Links or Adornments.*/
parts: Iterator;
/**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;
/**Gets the read-only collection of selected objects.*/
selection: Set;
/**Gets or sets whether ChangedEvents are not recorded by the UndoManager.*/
skipsUndoManager: boolean;
/**Gets the UndoManager for this Diagram, which actually belongs to the #model.*/
toolManager: ToolManager;
/**This Adornment is shown when the mouse stays motionless in the background.*/
toolTip: Adornment;
/**Gets 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;
/**Gets 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);
/**
* 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);
/**
* 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);
/**
* Adds a Layer to the list of layers.
* @param {Layer} layer The Layer to add.
*/
addLayer(layer: Layer);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* Modifies the #position to show a given Rect of the Diagram by centering the viewport on that Rect.
* @param {Rect} r
*/
centerRect(r: Rect);
/**
* Removes all Parts from the Diagram, including unbound Parts and the background grid, and also clears out the Model and UndoManager.
*/
clear();
/**
* Deselect all selected Parts.
*/
clearSelection();
/**
* Commit the changes of the current transaction.
* @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} coll a collection of Parts.
*/
computePartsBounds(coll: Iterable): Rect;
/**
* 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);
/**
* 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;
/**
* 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: any): 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): Iterable;
findObjectsAt(p: Point, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, coll?: Set): Iterable;
/**
* 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): Iterable;
findObjectsIn(r: Rect, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, partialInclusion?: boolean, coll?: Set): Iterable;
/**
* 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): Iterable;
findObjectsNear(p: Point, dist: number, navig?: (obj: GraphObject) => GraphObject, pred?: (obj: GraphObject) => boolean, partialInclusion?: boolean, coll?: Set): Iterable;
/**
* 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.
* @param {*} key a string or number.
*/
findPartForKey(key: any): Part;
/**
* Returns an iterator of all Groups that are at top-level, in other words that are not themselves inside other Groups.
*/
findTopLevelGroups(): Iterator;
/**
* Returns an iterator of all top-level Nodes that have no tree parents.
*/
findTreeRoots(): Iterator;
/**
* Explicitly bring focus to the Diagram's canvas.
*/
focus();
/**
* This static method gets the Diagram that is attached to an HTML DIV element.
* @param {HTMLDivElement} div
*/
static fromDiv(div: HTMLDivElement): Diagram;
/**
* 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: new(...args: any[]) => Object, baseclass: new(...args: any[]) => Object);
/**
* 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);
/**
* Create an HTMLImageElement that contains a bitmap of the current Diagram.
* @param {Object=} properties For details see the argument description of #makeImageData.
*/
makeImage(properties?: Object): HTMLImageElement;
/**
* Create a bitmap of the current Diagram encoded as a base64 string.
* @param {{ size: Size,
scale: number,
maxSize: Size,
position: Point,
parts: Iterable,
padding: (Margin|number),
showTemporary: boolean,
showGrid: boolean,
type: string,
details: Object}=} properties a JavaScript object detailing optional arguments for image creation, to be passed to makeImageData.
*/
makeImageData(properties?: Object): string;
/**
* Remove all of the Parts created from model data and then create them again.
*/
rebuildParts();
/**
* Removes a Part from its Layer, provided the Layer is in this Diagram.
* @param {Part} part
*/
remove(part: Part);
/**
* Unregister an event handler listener.
* @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument.
*/
removeChangedListener(listener: (e: ChangedEvent) => 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);
/**
* Removes the given layer from the list of layers.
* @param {Layer} layer
*/
removeLayer(layer: Layer);
/**
* Rollback the current transaction, undoing any recorded changes.
*/
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'.
* @param {string} dir The direction of the scroll operation. Can be 'up', 'down', 'left', or 'right'.
* @param {number=} dist An optional distance multiplier, for multiple pixels, lines, or pages. Default is 1.
*/
scroll(unit: string, dir: string, dist?: number);
/**
* Modifies the #position to show a given Rect of the Diagram by centering the viewport on that Rect.
* @param {Rect} r
*/
scrollToRect(r: Rect);
/**
* Make the given object the only selected object.
* @param {GraphObject} part a GraphObject that is already in a layer of this Diagram.
* If the value is null, this does nothing.
*/
select(part: Part);
/**
* Select all of the Parts supplied in the given collection.
* @param {Iterable} coll a List or Set of Parts to be selected.
*/
selectCollection(coll: Iterable);
/**
* Begin a transaction, where the changes are held by a Transaction object in the UndoManager.
* @param {string=} tname a descriptive name for the transaction.
*/
startTransaction(tname?: string): boolean;
/**
* Given a Point in document coordinates, return a new Point in viewport coordinates.
* @param {Point} p
*/
transformDocToView(p: Point): Point;
/**
* Given a point in viewport coordinates, return a new point in document coordinates.
* @param {Point} p
*/
transformViewToDoc(p: Point): Point;
/**
* Update all of the data-bound properties of Nodes and Links in this diagram.
*/
updateAllTargetBindings();
/**
* Scales the Diagram to uniformly fit into the viewport.
*/
zoomToFit();
/**
* Modifies the #scale and #position of the Diagram so that the viewport displays a given document-coordinates rectangle.
* @param {Rect} r rectangular bounds in document coordinates.
* @param {EnumValue=} scaling an optional value of either #Uniform (the default) or #UniformToFill.
*/
zoomToRect(r: Rect, scaling?: EnumValue);
/**This value for Diagram#validCycle states that there are no restrictions on making cycles of links.*/
static CycleAll: EnumValue;
/**This value for Diagram#validCycle states that any number of destination links may go out of a node, but at most one source link may come into a node, and there are no directed cycles.*/
static CycleDestinationTree: EnumValue;
/**This value for Diagram#validCycle states that a valid link from a node will not produce a directed cycle in the graph.*/
static CycleNotDirected: EnumValue;
/**This value for Diagram#validCycle states that a valid link from a node will not produce an undirected cycle in the graph.*/
static CycleNotUndirected: EnumValue;
/**This value for Diagram#validCycle states that any number of source links may come into a node, but at most one destination link may go out of a node, and there are no directed cycles.*/
static CycleSourceTree: EnumValue;
/**The default autoScale type, used as the value of Diagram#autoScale: The Diagram does not attempt to scale its bounds to fit the view.*/
static None: EnumValue;
/**Diagrams with this autoScale type, used as the value of Diagram#autoScale, are scaled uniformly until the documentBounds fits in the view.*/
static Uniform: EnumValue;
/**Diagrams with this autoScale type, used as the value of Diagram#autoScale, are scaled uniformly until the documentBounds fits in the view.*/
static UniformToFill: EnumValue;
maybeUpdate(); // undocumented
requestUpdate(); // undocumented
}
/**
* A DiagramEvent represents a more abstract event than an InputEvent.
* They are raised on the Diagram class.
* One can receive such events by registering a DiagramEvent listener on a Diagram
* by calling Diagram#addDiagramListener.
* Some DiagramEvents such as "ObjectSingleClicked" are normally
* associated with InputEvents.
* Some DiagramEvents such as "SelectionMoved" or "PartRotated" are associated with the
* results of Tool-handled gestures or CommandHandler actions.
* Some DiagramEvents are not necessarily associated with any input events at all,
* such as "ViewportBoundsChanged", which can happen due to programmatic
* changes to the Diagram#position and Diagram#scale properties.
*/
class DiagramEvent {
/**
* The DiagramEvent class constructor produces an empty DiagramEvent.
*/
constructor();
/**Gets or sets whether any default actions associated with this diagram event should be avoided or cancelled.*/
cancel: boolean;
/**Gets the diagram associated with the event.*/
diagram: Diagram;
/**Gets or sets the name of the kind of diagram event that this represents.*/
name: string;
/**Gets or sets an optional object that describes the change to the subject of the diagram event.*/
parameter: any;
/**Gets or sets an optional object that is the subject of the diagram event.*/
subject: Object;
}
/**
* This is the abstract base class for all graphical objects.
*/
class GraphObject {
/**
* This is an abstract class, so you should not use this constructor.
*/
constructor();
/**Gets or sets the function to execute when the ActionTool is cancelled and this GraphObject's #isActionable is set to true.*/
actionCancel: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the function to execute on a mouse-down event when this GraphObject's #isActionable is set to true.*/
actionDown: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the function to execute on a mouse-move event when this GraphObject's #isActionable is set to true.*/
actionMove: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the function to execute on a mouse-up event when this GraphObject's #isActionable is set to true.*/
actionUp: (e: InputEvent, obj: GraphObject) => void;
/**Gets the bounds of this GraphObject in container coordinates.*/
actualBounds: Rect;
/**Gets or sets the alignment Spot of this GraphObject used in Panel layouts, to determine where in the area allocated by the panel this object should be placed.*/
alignment: Spot;
/**Gets or sets the spot on this GraphObject to be used as the alignment point in Spot and Fixed Panels.*/
alignmentFocus: Spot;
/**Gets or sets the angle transform, in degrees, of this GraphObject.*/
angle: number;
/**Gets or sets the areaBackground Brush (or CSS color string) of this GraphObject.*/
areaBackground: any;
/**Gets or sets the background Brush (or CSS color string) of this GraphObject, filling the rectangle of this object's local coordinate space.*/
background: any;
/**Gets or sets the function to execute when the user single-primary-clicks on this object.*/
click: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the column of this GraphObject if it is in a Table Panel.*/
column: number;
/**Gets or sets the number of columns spanned by this GraphObject if it is in a Table Panel.*/
columnSpan: number;
/**Gets or sets the function to execute when the user single-secondary-clicks on this object.*/
contextClick: (e: InputEvent, obj: GraphObject) => void;
/**This Adornment is shown upon a context click on this object.*/
contextMenu: Adornment;
/**Gets or sets the mouse cursor to use when the mouse is over this object with no mouse buttons pressed.*/
cursor: string;
/**Gets or sets the desired size of this GraphObject in local coordinates.*/
desiredSize: Size;
/**Gets the Diagram that this GraphObject is in, if it is.*/
diagram: Diagram;
/**Gets or sets the function to execute when the user double-primary-clicks on this object.*/
doubleClick: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets how the direction of the last segment of a link coming from this port is computed when the node is rotated.*/
fromEndSegmentDirection: EnumValue;
/**Gets or sets the length of the last segment of a link coming from this port.*/
fromEndSegmentLength: number;
/**Gets or sets whether the user may draw Links from this port.*/
fromLinkable: any;
/**Gets or sets whether the user may draw duplicate Links from this port.*/
fromLinkableDuplicates: boolean;
/**Gets or sets whether the user may draw Links that connect from this port's Node.*/
fromLinkableSelfNode: boolean;
/**Gets or sets the maximum number of links that may come out of this port.*/
fromMaxLinks: number;
/**Gets or sets how far the end segment of a link coming from this port stops short of the actual port.*/
fromShortLength: number;
/**Gets or sets where a link should connect from this port.*/
fromSpot: Spot;
/**Gets or sets the desired height of this GraphObject in local coordinates.*/
height: number;
/**This property determines whether or not this GraphObject's events occur before all other events, including selection.*/
isActionable: boolean;
/**Gets or sets whether a GraphObject is the "main" object for some types of Panel.*/
isPanelMain: boolean;
/**Gets the GraphObject's containing Layer, if there is any.*/
layer: Layer;
/**Gets or sets the size of empty area around this GraphObject, as a Margin (or number for a uniform Margin), in the containing Panel coordinates.*/
margin: any;
/**Gets or sets the maximum size of this GraphObject in container coordinates (either a Panel or the document).*/
maxSize: Size;
/**Gets the measuredBounds of the GraphObject in container coordinates (either a Panel or the document).*/
measuredBounds: Rect;
/**Gets or sets the minimum size of this GraphObject in container coordinates (either a Panel or the document).*/
minSize: Size;
/**Gets or sets the function to execute when the user moves the mouse into this stationary object during a DraggingTool drag.*/
mouseDragEnter: (e: InputEvent, obj: GraphObject, prev: GraphObject) => void;
/**Gets or sets the function to execute when the user moves the mouse out of this stationary object during a DraggingTool drag.*/
mouseDragLeave: (e: InputEvent, obj: GraphObject, prev: GraphObject) => void;
/**Gets or sets the function to execute when a user drops the selection on this object at the end of a DraggingTool drag.*/
mouseDrop: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the function to execute when the user moves the mouse into this object without holding down any buttons.*/
mouseEnter: (e: InputEvent, obj: GraphObject, prev: GraphObject) => 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 over this object.*/
mouseHold: (e: InputEvent, obj: GraphObject) => 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 over this object.*/
mouseHover: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the function to execute when the user moves the mouse into this object without holding down any buttons.*/
mouseLeave: (e: InputEvent, obj: GraphObject, prev: GraphObject) => void;
/**Gets or sets the function to execute when the user moves the mouse over this object without holding down any buttons.*/
mouseOver: (e: InputEvent, obj: GraphObject) => void;
/**Gets or sets the name for this object