diff --git a/goJS/goJS-tests.ts b/goJS/goJS-tests.ts
index dd6266dc7..4a84eb83c 100644
--- a/goJS/goJS-tests.ts
+++ b/goJS/goJS-tests.ts
@@ -1,10 +1,87 @@
// Test file for goJS.d.ts
-// This is taken from http://gojs.net/latest/samples/basic.html
+// This is taken and adapted from http://gojs.net/latest/samples/basic.html
-/* Copyright (C) 1998-2015 by Northwoods Software Corporation. */
+/* Copyright (C) 1998-2016 by Northwoods Software Corporation. */
///
+class CustomLink extends go.Link {
+ constructor() {
+ super();
+ this.routing = go.Link.Orthogonal;
+ }
+
+ hasCurviness(): boolean {
+ if (isNaN(this.curviness)) return true;
+ return super.hasCurviness();
+ }
+
+ computeCurviness(): number {
+ if (isNaN(this.curviness)) {
+ var links = this.fromNode.findLinksTo(this.toNode);
+ if (links.count < 2) return 0;
+ var i = 0;
+ while (links.next()) { if (links.value === this) break; i++; }
+ return 10 * (i - (links.count - 1) / 2);
+ }
+ return super.computeCurviness();
+ }
+}
+
+class CustomTreeLayout extends go.TreeLayout {
+ constructor() {
+ super();
+ this.extraProp = 3;
+ }
+
+ extraProp: number;
+
+ // override various methods
+
+ cloneProtected(copy: CustomTreeLayout): void {
+ super.cloneProtected(copy);
+ copy.extraProp = this.extraProp;
+ }
+
+ createNetwork(): CustomTreeNetwork {
+ return new CustomTreeNetwork();
+ }
+
+ assignTreeVertexValues(v: CustomTreeVertex): void {
+ super.assignTreeVertexValues(v);
+ v.someProp = Math.random() * 100;
+ }
+
+ commitNodes(): void {
+ super.commitNodes();
+ // ...
+ }
+
+ commitLinks(): void {
+ super.commitLinks();
+ this.network.edges.each(e => { e.link.path.strokeWidth = ((e)).anotherProp; });
+ }
+}
+
+class CustomTreeNetwork extends go.TreeNetwork {
+ createVertex(): CustomTreeVertex {
+ return new CustomTreeVertex();
+ }
+
+ createEdge(): CustomTreeEdge {
+ return new CustomTreeEdge();
+ }
+}
+
+class CustomTreeVertex extends go.TreeVertex {
+ someProp: number = 17;
+}
+
+class CustomTreeEdge extends go.TreeEdge {
+ anotherProp: number = 1;
+}
+
+
function init() {
var $ = go.GraphObject.make; // for conciseness in defining templates
@@ -20,6 +97,8 @@ function init() {
// allow Ctrl-G to call groupSelection()
"commandHandler.archetypeGroupData": { text: "Group", isGroup: true, color: "blue" },
+ layout: $(CustomTreeLayout, { angle: 90 }),
+
// enable undo & redo
"undoManager.isEnabled": true
});
@@ -30,19 +109,19 @@ function init() {
// To simplify this code we define a function for creating a context menu button:
function makeButton(text: string, action: (e: go.InputEvent, obj: go.GraphObject) => void, visiblePredicate?: (obj: go.GraphObject) => boolean) {
- if (visiblePredicate === undefined) visiblePredicate = function (o) { return true; };
+ if (visiblePredicate === undefined) visiblePredicate = o => true;
return $("ContextMenuButton",
- $(go.TextBlock, text),
- { click: action },
- // don't bother with binding GraphObject.visible if there's no predicate
- visiblePredicate ? new go.Binding("visible", "", visiblePredicate).ofObject() : {});
+ $(go.TextBlock, text),
+ { click: action },
+ // don't bother with binding GraphObject.visible if there's no predicate
+ visiblePredicate ? new go.Binding("visible", "", visiblePredicate).ofObject() : {});
}
// a context menu is an Adornment with a bunch of buttons in them
var partContextMenu =
$(go.Adornment, "Vertical",
makeButton("Properties",
- function (e, obj) { // the OBJ is this Button
+ (e, obj) => { // the OBJ is this Button
var contextmenu = obj.part; // the Button is in the context menu Adornment
var part = contextmenu.adornedPart; // the adornedPart is the Part that the context menu adorns
// now can do something with PART, or with its data, or with the Adornment (the context menu)
@@ -51,29 +130,29 @@ function init() {
else alert(nodeInfo(part.data));
}),
makeButton("Cut",
- function (e, obj) { e.diagram.commandHandler.cutSelection(); },
- function (o) { return o.diagram.commandHandler.canCutSelection(); }),
+ (e, obj) => e.diagram.commandHandler.cutSelection(),
+ o => o.diagram.commandHandler.canCutSelection()),
makeButton("Copy",
- function (e, obj) { e.diagram.commandHandler.copySelection(); },
- function (o) { return o.diagram.commandHandler.canCopySelection(); }),
+ (e, obj) => e.diagram.commandHandler.copySelection(),
+ o => o.diagram.commandHandler.canCopySelection()),
makeButton("Paste",
- function (e, obj) { e.diagram.commandHandler.pasteSelection(e.diagram.lastInput.documentPoint); },
- function (o) { return o.diagram.commandHandler.canPasteSelection(); }),
+ (e, obj) => e.diagram.commandHandler.pasteSelection(e.diagram.lastInput.documentPoint),
+ o => o.diagram.commandHandler.canPasteSelection()),
makeButton("Delete",
- function (e, obj) { e.diagram.commandHandler.deleteSelection(); },
- function (o) { return o.diagram.commandHandler.canDeleteSelection(); }),
+ (e, obj) => e.diagram.commandHandler.deleteSelection(),
+ o => o.diagram.commandHandler.canDeleteSelection()),
makeButton("Undo",
- function (e, obj) { e.diagram.commandHandler.undo(); },
- function (o) { return o.diagram.commandHandler.canUndo(); }),
+ (e, obj) => e.diagram.commandHandler.undo(),
+ o => o.diagram.commandHandler.canUndo()),
makeButton("Redo",
- function (e, obj) { e.diagram.commandHandler.redo(); },
- function (o) { return o.diagram.commandHandler.canRedo(); }),
+ (e, obj) => e.diagram.commandHandler.redo(),
+ o => o.diagram.commandHandler.canRedo()),
makeButton("Group",
- function (e, obj) { e.diagram.commandHandler.groupSelection(); },
- function (o) { return o.diagram.commandHandler.canGroupSelection(); }),
+ (e, obj) => e.diagram.commandHandler.groupSelection(),
+ o => o.diagram.commandHandler.canGroupSelection()),
makeButton("Ungroup",
- function (e, obj) { e.diagram.commandHandler.ungroupSelection(); },
- function (o) { return o.diagram.commandHandler.canUngroupSelection(); })
+ (e, obj) => e.diagram.commandHandler.ungroupSelection(),
+ o => o.diagram.commandHandler.canUngroupSelection())
);
function nodeInfo(d) { // Tooltip info for a node data object
@@ -120,7 +199,7 @@ function init() {
// this context menu Adornment is shared by all nodes
contextMenu: partContextMenu
}
- );
+ );
// Define the appearance and behavior for Links:
@@ -130,7 +209,7 @@ function init() {
// The link shape and arrowhead have their stroke brush data bound to the "color" property
myDiagram.linkTemplate =
- $(go.Link,
+ $(CustomLink,
{ relinkableFrom: true, relinkableTo: true }, // allow the user to relink existing links
$(go.Shape,
{ strokeWidth: 2 },
@@ -148,17 +227,14 @@ function init() {
// the same context menu Adornment is shared by all links
contextMenu: partContextMenu
}
- );
+ );
// Define the appearance and behavior for Groups:
function groupInfo(adornment: go.Adornment) { // takes the tooltip, not a group node data object
var g = adornment.adornedPart; // get the Group that the tooltip adorns
var mems = g.memberParts.count;
- var links = 0;
- g.memberParts.each(function (part) {
- if (part instanceof go.Link) links++;
- });
+ var links = g.memberParts.filter(p => p instanceof go.Link).count;
return "Group " + g.data.key + ": " + g.data.text + "\n" + mems + " members including " + links + " links";
}
@@ -168,7 +244,8 @@ function init() {
$(go.Group, "Vertical",
{
selectionObjectName: "PANEL", // selection handle goes around shape, not label
- ungroupable: true // enable Ctrl-Shift-G to ungroup a selected Group
+ ungroupable: true, // enable Ctrl-Shift-G to ungroup a selected Group
+ layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized
},
$(go.TextBlock,
{
@@ -195,7 +272,7 @@ function init() {
// the same context menu Adornment is shared by all groups
contextMenu: partContextMenu
}
- );
+ );
// Define the behavior for the Diagram background:
@@ -209,21 +286,21 @@ function init() {
$(go.Shape, { fill: "#FFFFCC" }),
$(go.TextBlock, { margin: 4 },
new go.Binding("text", "", diagramInfo))
- );
+ );
// provide a context menu for the background of the Diagram, when not over any Part
myDiagram.contextMenu =
$(go.Adornment, "Vertical",
makeButton("Paste",
- function (e, obj) { e.diagram.commandHandler.pasteSelection(e.diagram.lastInput.documentPoint); },
- function (o) { return o.diagram.commandHandler.canPasteSelection(); }),
+ (e, obj) => e.diagram.commandHandler.pasteSelection(e.diagram.lastInput.documentPoint),
+ o => o.diagram.commandHandler.canPasteSelection()),
makeButton("Undo",
- function (e, obj) { e.diagram.commandHandler.undo(); },
- function (o) { return o.diagram.commandHandler.canUndo(); }),
+ (e, obj) => e.diagram.commandHandler.undo(),
+ o => o.diagram.commandHandler.canUndo()),
makeButton("Redo",
- function (e, obj) { e.diagram.commandHandler.redo(); },
- function (o) { return o.diagram.commandHandler.canRedo(); })
- );
+ (e, obj) => e.diagram.commandHandler.redo(),
+ o => o.diagram.commandHandler.canRedo())
+ );
// Create the Diagram's Model:
var nodeDataArray = [
@@ -240,4 +317,8 @@ function init() {
{ from: 3, to: 1, color: "purple" }
];
myDiagram.model = new go.GraphLinksModel(nodeDataArray, linkDataArray);
+
+ var img = myDiagram.makeImageData({
+ scale: 0.4, position: new go.Point(-10, -10)
+ });
}
diff --git a/goJS/goJS.d.ts b/goJS/goJS.d.ts
index fb93bb6d2..f37c6bf46 100644
--- a/goJS/goJS.d.ts
+++ b/goJS/goJS.d.ts
@@ -1,12 +1,9 @@
-// Type definitions for GoJS v1.5.0
+// Type definitions for GoJS v1.6.0
// Project: http://gojs.net
// Definitions by: Northwoods Software
// Definitions: https://github.com/NorthwoodsSoftware/GoJS
-/* Copyright (C) 1998-2015 by Northwoods Software Corporation. */
-
-// This is for TypeScript 1.4
-// TODO: TypeScript 1.5 modules and destructuring
+/* Copyright (C) 1998-2016 by Northwoods Software Corporation. */
declare namespace go {
/** A number in place of a Margin object is treated as a uniform Margin with that thickness */
@@ -22,7 +19,7 @@ declare namespace go {
type PropertyAccessor = string | ((data: any, newval: any) => any);
/** A constructor */
- type Constructor = new (...args: any[]) => Object;
+ type Constructor = new (...args: Array) => Object;
/**
* An adornment is a special kind of Part that is associated with another Part,
@@ -63,6 +60,9 @@ declare namespace go {
/**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;
@@ -84,8 +84,8 @@ declare namespace go {
*/
constructor();
- /**Gets or sets a data object that is copied by .groupSelection when creating a new Group. The default value is null.*/
- archetypeGroupData: Object;
+ /**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;
@@ -105,6 +105,9 @@ declare namespace go {
/**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;
@@ -199,6 +202,16 @@ declare namespace go {
*/
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.
+ * @this {CommandHandler}
+ * @param {Part=} part This defaults to the first selected Part of Diagram.selection
+ * @return {boolean}
+ * 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.
*/
@@ -339,6 +352,21 @@ declare namespace go {
*/
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.
+ *
+ * This is normally invoked by the Space keyboard shortcut.
+ * If there is no argument and there is no highlighted or selected Part, this command does nothing.
+ * @expose
+ * @this {CommandHandler}
+ * @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.
*/
@@ -699,6 +727,12 @@ declare namespace go {
*/
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.
@@ -750,9 +784,9 @@ declare namespace go {
/**
* Commit the changes of the current transaction.
* This just calls UndoManager.commitTransaction.
- * @param {string} tname a descriptive name for the transaction.
+ * @param {string=} tname a descriptive name for the transaction.
*/
- commitTransaction(tname: string): boolean;
+ commitTransaction(tname?: string): boolean;
/**
* This is called during a Diagram update to determine a new value for .documentBounds.
@@ -945,43 +979,59 @@ declare namespace go {
* 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;
+ makeImage(properties?: {
+ size?: Size,
+ scale?: number,
+ maxSize?: Size,
+ position?: Point,
+ parts?: Iterable,
+ padding?: MarginLike,
+ background?: BrushLike,
+ showTemporary?: boolean,
+ showGrid?: boolean,
+ document?: Document,
+ type?: string,
+ details?: any
+ }): 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,
- document: Document,
- type: string,
- details: *
- }=} properties a JavaScript object detailing optional arguments for image creation, to be passed to makeImageData.
+ * @param {Object=} properties a JavaScript object detailing optional arguments for image creation, to be passed to makeImageData.
*/
- makeImageData(properties?: Object): string;
+ makeImageData(properties?: {
+ size?: Size,
+ scale?: number,
+ maxSize?: Size,
+ position?: Point,
+ parts?: Iterable,
+ padding?: MarginLike,
+ background?: BrushLike,
+ showTemporary?: boolean,
+ showGrid?: boolean,
+ document?: Document,
+ type?: string,
+ details?: any
+ }): 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 {{ size: Size,
- scale: number,
- maxSize: Size,
- position: Point,
- parts: Iterable,
- padding: (Margin|number),
- showTemporary: boolean,
- showGrid: boolean,
- document: Document,
- elementFinished: function(GraphObject, SVGElement),
- details: *
- }=} properties a JavaScript object detailing optional arguments for SVG creation.
+ * @param {Object=} properties a JavaScript object detailing optional arguments for SVG creation.
* @return {SVGElement}
*/
- makeSvg(properties?: Object): SVGElement;
+ makeSvg(properties?: {
+ size?: Size,
+ scale?: number,
+ maxSize?: Size,
+ position?: Point,
+ parts?: Iterable,
+ 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.
@@ -1015,6 +1065,12 @@ declare namespace go {
*/
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
@@ -1028,6 +1084,19 @@ declare namespace go {
*/
removeParts(coll: Iterable | Array, 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.
+ *
+ * @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.
@@ -1140,12 +1209,18 @@ declare namespace go {
/**This value for Diagram.scrollMode states that the viewport does not constrain scrolling to the Diagram document bounds.*/
static InfiniteScroll: EnumValue;
+ /** This value for Diagram.treeCollapsePolicy states that only the Node.findTreeParentNode's Node.isTreeExpanded property determines whether a "child" node is visible.*/
+ static TreeParentCollapsed: EnumValue; // undocumented
+
+ /** This value for Diagram.treeCollapsePolicy states that all of the Node.findNodesInto or Node.findNodesOutOf, depending on Diagram.isTreePathToChildren being true or false, need to be not Node.isTreeExpanded in order for a "child" node to be not visible.*/
+ static AllParentsCollapsed: EnumValue; // undocumented
+
+ treeCollapsePolicy: EnumValue; // undocumented
getRenderingHint(name: string): any; // undocumented
setRenderingHint(name: string, val: any): void; // undocumented
getInputOption(name: string): any; // undocumented
setInputOption(name: string, val: any): void; // undocumented
maybeUpdate(): void; // undocumented
- requestUpdate(): void; // undocumented
reset(): void; // undocumented
simulatedMouseMove(e: Event, modelpt: Point, overdiag?: Diagram): boolean; // undocumented
simulatedMouseUp(e: Event, other: Diagram, modelpt: Point, curdiag?: Diagram): boolean; // undocumented
@@ -1189,7 +1264,7 @@ declare namespace go {
/**
* This is the abstract base class for all graphical objects.
*/
- class GraphObject {
+ abstract class GraphObject {
/**
* This is an abstract class, so you should not use this constructor.
*/
@@ -1421,7 +1496,20 @@ declare namespace go {
* @param {string} name a capitalized name; must not be "" or "None"
* @param {function(Array<*>):Object} func
*/
- static defineBuilder(name: string, func: (args: any[]) => Object): void;
+ static defineBuilder(name: string, func: (args: Array) => Object): void;
+
+ /**
+ * This static function returns the first argument from the arguments array passed
+ * to a GraphObject.defineBuilder function by GraphObject.make.
+ * By default this requires the first argument to be a string,
+ * but you can provide a predicate to determine whether the argument is suitable.
+ * @param {Array} args
+ * @param {*=} defval the default value to return if the argument is optional and not present as the first argument
+ * @param {function(*):boolean|null=} pred a predicate to determine the acceptability of the argument;
+ * the default predicate checks whether the argument is a string
+ * @return {*}
+ */
+ static takeBuilderArgument(args: Array, defval?: any, pred?: (arg: any) => boolean): any;
/**
* Returns the effective angle that the object is drawn at, in document coordinates.
@@ -1479,7 +1567,7 @@ declare namespace go {
* is recognized to take that value,
* or a string that is used as the value of a commonly set property.
*/
- static make(type: Constructor | string, ...initializers: any[]): any;
+ static make(type: Constructor | string, ...initializers: Array): any;
/**GraphObjects with this as the value of GraphObject.stretch are stretched depending on the context they are used.*/
static Default: EnumValue;
@@ -1502,10 +1590,9 @@ declare namespace go {
/**GraphObjects with this as the value of GraphObject.stretch are scaled as much as possible in the y-axis*/
static Vertical: EnumValue;
+ spanAllocation: (obj: GraphObject, r: RowColumnDefinition, n: number) => number; // undocumented
protected cloneProtected(copy: GraphObject): void; // undocumented
- static fromSvg(svg: string): GraphObject; // undocumented
- static fromSvg(svg: Document): GraphObject; // undocumented
- static getBuilders(): Map Object>; // undocumented
+ static getBuilders(): Map) => Object>; // undocumented
}
/**
@@ -1636,9 +1723,12 @@ declare namespace go {
/**Gets or sets whether the underlying .event is prevented from bubbling up the hierarchy of HTML elements outside of the Diagram and whether any default action is canceled.*/
bubbles: boolean;
- /**Gets or sets the button that caused this event.*/
+ /**Gets or sets the mouse button that caused this event.*/
button: number;
+ /**Gets or sets the buttons flag, descibing the set of mouse buttons current being held down.*/
+ buttons: number;
+
/**Gets or sets whether this event represents a click or a double-click.*/
clickCount: number;
@@ -1709,6 +1799,8 @@ declare namespace go {
* Make a copy of this InputEvent.
*/
copy(): InputEvent;
+
+ isMac: boolean; // undocumented
}
/**
@@ -1967,6 +2059,88 @@ declare namespace go {
*/
canRelinkTo(): boolean;
+ /**
+ * Remove all of the points from this link's route; this may only be called within an override of computePoints.
+ */
+ protected clearPoints(): void;
+
+ /**
+ * Add a point at the end of the route; this may only be called within an override of computePoints.
+ * @param {Point} p The new point, which should not have infinite or NaN coordinate values, and which must not be modified afterwards.
+ */
+ protected addPoint(p: Point): void;
+
+ /**
+ * Insert a point at a particular position in the route, without replacing an existing point; this may only be called within an override of computePoints.
+ * @param {number} i int The zero-based index of the new point.
+ * @param {Point} p The new point, which should not have infinite or NaN coordinate values, and which must not be modified afterwards.
+ */
+ protected insertPoint(i: number, p: Point): void;
+
+ /**
+ * Remove a particular point from the route; this may only be called within an override of computePoints.
+ * @param {number} i int The zero-based index of the point to extract.
+ */
+ protected removePoint(i: number): void;
+
+ /**
+ * Sets a particular point of the route; this may only be called within an override of computePoints.
+ * @param {number} i int The zero-based index of the desired point.
+ * @param {Point} p The new point, which should not have infinite or NaN coordinate values, and which must not be modified afterwards.
+ */
+ protected setPoint(i: number, p: Point): void;
+
+ /**
+ * Returns the curve}, unless this link is supposed to pretend to be curved, as with reflexive links.
+ */
+ protected computeCurve(): EnumValue;
+
+ /**
+ * Returns the curviness, if it's a number,
+ * or else a computed value based on how many links connect this pair of nodes/ports.
+ */
+ protected computeCurviness(): number;
+
+ /**
+ * Get the length of the end segment, typically a short distance, in document units.
+ * For spot values that are Spot.isSide, this returns a computed value.
+ * Depending on the from argument, this will return fromEndSegmentLength or toEndSegmentLength.
+ * If the value is NaN, this will return the fromPort's GraphObject.fromEndSegmentLength
+ * or the toPort's GraphObject.toEndSegmentLength.
+ */
+ protected computeEndSegmentLength(node: Node, port: GraphObject, spot: Spot, from: boolean): number;
+
+ /**
+ * Find the approximate point of the other end of the link.
+ * This is useful when computing the connection point when there is no specific spot, to have an idea of which general direction the link should be going.
+ * By default this will return the center of the other port.
+ */
+ protected computeOtherPoint(othernode: Node, otherport: GraphObject): Point;
+
+ /**
+ * The code that constructs a new route by modifying the points.
+ * It is only called by updateRoute, when needed.
+ */
+ protected computePoints(): boolean;
+ /**
+ * Returns the expected spacing between this link and others that connect this link's fromPort and toPort.
+ * This calls computeThickness and also takes any "mid label"'s breadth into account.
+ */
+ protected computeSpacing(): number;
+ /**
+ * Get the Spot that describes how the end of the link should connect with the port.
+ * Depending on the from argument, this will return fromSpot or toSpot.
+ * If the value is Spot.isDefault, this will return the fromPort's GraphObject.fromSpot
+ * or the toPort's GraphObject.toSpot.
+ */
+ protected computeSpot(from: boolean): Spot;
+
+ /**
+ * Returns the thickness of this link.
+ * By default it uses the strokeWidth of the main element, assuming it's a Shape.
+ */
+ protected computeThickness(): number;
+
/**
* Find the index of the segment that is closest to a given point.
* @param {Point} p the Point, in document coordinates.
@@ -2030,12 +2204,36 @@ declare namespace go {
*/
getPoint(i: number): Point;
+ /**
+ * Returns true if an extra or a different point is needed based on curviness.
+ */
+ protected hasCurviness(): boolean;
+
+ /**
+ * Declare that the route (the points) of this Link need to be recomputed soon.
+ * This causes updateRoute to be called, which will call computePoints
+ * to perform the actual determination of the route.
+ */
+ invalidateRoute(): void;
+
+ /**
+ * Produce a Geometry given the points of this route,
+ * depending on the value of curve and corner and perhaps other properties.
+ */
+ protected makeGeometry(): Geometry;
+
/**
* Move this link to a new position.
* @param {Point} newpos
*/
move(newpos: Point): void;
+ /**
+ * This method recomputes the route if the route is invalid, to make sure the points are up-to-date.
+ * This method calls computePoints in order to calculate a new route.
+ */
+ updateRoute(): void;
+
/**Used as a value for Link.routing: each segment is horizontal or vertical, but the route tries to avoid crossing over nodes.*/
static AvoidsNodes: EnumValue;
@@ -2091,28 +2289,14 @@ declare namespace go {
static Stretch: EnumValue;
routeBounds: Rect; // undocumented
- protected computeEndSegmentLength(node: Node, port: GraphObject, spot: Spot, from: boolean): number; // undocumented
- protected computeSpot(from: boolean): Spot; // undocumented
- protected computeOtherPoint(othernode: Node, otherport: GraphObject): Point; // undocumented
- protected computeShortLength(from: boolean): number; // undocumented
- protected computeCurve(): EnumValue; // undocumented
protected computeCorner(): number; // undocumented
- protected computeCurviness(): number; // undocumented
- protected computeThickness(): number; // undocumented
- hasCurviness(): boolean; // undocumented
- invalidateRoute(): void; // undocumented
- updateRoute(): void; // undocumented
- protected computePoints(): boolean; // undocumented
- clearPoints(): void; // undocumented
- addPoint(p: Point): void; // undocumented
- addPointAt(x: number, y: number): void; // undocumented
- insertPoint(i: number, p: Point): void; // undocumented
- insertPointAt(i: number, x: number, y: number): void; // undocumented
- removePoint(i: number): void; // undocumented
- setPoint(i: number, p: Point): void; // undocumented
- setPointAt(i: number, x: number, y: number): void; // undocumented
+ protected computeShortLength(from: boolean): number; // undocumented
+ findMidLabel(): GraphObject; // undocumented
+ protected arrangeBundledLinks(links: Array, reroute: boolean): void; // undocumented
+ protected setPointAt(i: number, x: number, y: number): void; // undocumented
+ protected insertPointAt(i: number, x: number, y: number): void; // undocumented
+ protected addPointAt(x: number, y: number): void; // undocumented
invalidateGeometry(): void; // undocumented
- makeGeometry(): Geometry; // undocumented
}
/**
@@ -2310,6 +2494,12 @@ declare namespace go {
/**This value for Node.portSpreading indicates that links connecting with a port should be packed together based on the link's shape's width on the side(s) indicated by a Spot that is a "side" Spot.*/
static SpreadingPacked: EnumValue;
+
+ canAvoid(): boolean; // undocumented
+ findVisibleNode(): Node; // undocumented
+ getAvoidableRect(result: Rect): Rect; // undocumented
+ invalidateLinkBundle(other: Node, thisportid?: string, otherportid?: string): void; // undocumented
+ invalidateConnectedLinks(): void; // undocumented
}
/**
@@ -2482,6 +2672,12 @@ declare namespace go {
*/
findObject(name: string): GraphObject;
+ /**
+ * Return the Panel that was made for a particular data object in this panel's itemArray.
+ * If this returns a Panel, its data property will be the argument data object.
+ */
+ findItemPanelForData(data: Object): Panel;
+
/**
* Returns the row at a given y-coordinate in local coordinates.
* @param {number} y
@@ -2730,12 +2926,18 @@ declare namespace go {
/**Gets or sets the X and Y offset of this part's shadow.*/
shadowOffset: Point;
+ /**Gets or sets whether this GraphObject will be shadowed inside a Part that has Part.isShadowed set to true; default is null, meaning obey default shadow rules for Part.isShadowed.*/
+ shadowVisible: boolean;
+
/**Gets or sets a text string that is associated with this part.*/
text: string;
/**Gets or sets whether the user may do in-place text editing on TextBlocks in this part that have TextBlock.editable set to true.*/
textEditable: boolean;
+ /**Gets or sets the Z-ordering position of this Part within its Layer; default value is NaN which means "don't care".*/
+ zOrder: number;
+
/**
* Associate an Adornment with this Part, perhaps replacing any existing adornment.
* @param {string} category a string identifying the kind or role of the given adornment for this Part.
@@ -2798,6 +3000,14 @@ declare namespace go {
*/
clearAdornments(): void;
+ /**
+ * Measures if needed to make sure the GraphObject.measuredBounds and GraphObject.naturalBounds are all real numbers,
+ * primarily to get the actual width and height.
+ * GraphObject.actualBounds will get a real width and height, but the x and y values may continue to be NaN
+ * if they were that way beforehand.
+ */
+ ensureBounds(): void;
+
/**
* Find an Adornment of a given category associated with this Part.
* @param {string} category
@@ -2847,6 +3057,13 @@ declare namespace go {
*/
move(newpos: Point): void;
+ /**
+ * Move this part and any parts that are owned by this part to a new position.
+ * @param {number} x the new X position in document coordinates.
+ * @param {number} y the new Y position in document coordinates.
+ */
+ moveTo(x: number, y: number): void;
+
/**
* Remove any Adornment of the given category that may be associated with this Part.
* @param {string} category a string identifying the kind or role of the given adornment for this Part.
@@ -2898,9 +3115,6 @@ declare namespace go {
/**This is the default value for the Part.layoutConditions property: the Layout responsible for the Part is invalidated when the Part is added or removed from the Diagram or Group or when it changes visibility or size or when a Group's layout has been performed.*/
static LayoutStandard: number;
-
- ensureBounds(): void; // undocumented
- moveTo(x: number, y: number): void; // undocumented
}
/**
@@ -3229,6 +3443,8 @@ declare namespace go {
/**The TextBlock will wrap text, making the width of the TextBlock equal to the width of the longest line.*/
static WrapFit: EnumValue;
+ spacingAbove: number; // undocumented
+ spacingBelow: number; // undocumented
static isValidFont(font: string): boolean; // undocumented
static getEllipsis(): string; // undocumented
static setEllipsis(val: string): void; // undocumented
@@ -4787,10 +5003,11 @@ declare namespace go {
* is a link reference (either the "to" or the "from" of a link data) to a node key that does not yet exist in the model.
* The default value is null -- node data is not automatically copied and added to the model
* when there is an unresolved reference in a link data.
+ * The value must be an Object or null.
* When adding or modifying a link data if there is a "from" or "to" key value for which Model.findNodeDataForKey returns null,
* it will call Model.copyNodeData on this property value and Model.addNodeData on the result.
*/
- archetypeNodeData: Object;
+ archetypeNodeData: any;
/**
* Gets or sets a function that makes a copy of a link data object.
@@ -4833,6 +5050,9 @@ declare namespace go {
*/
linkFromPortIdProperty: PropertyAccessor;
+ /**Gets or sets the name of the data property that returns a unique id number or string for each link data object, or a function taking a link data object and returning the key value; the default value is '', which causes the model NOT to assign unique identifiers automatically.*/
+ linkKeyProperty: PropertyAccessor;
+
/**
* Gets or sets the name of the data property that returns
* an array of keys of node data that are labels on that link data,
@@ -4864,6 +5084,9 @@ declare namespace go {
*/
linkToPortIdProperty: PropertyAccessor;
+ /**Gets or sets a function that returns a unique id number or string for a link data object; the default value is null.*/
+ makeUniqueLinkKeyFunction: (model: Model, obj: Object) => Key;
+
/**
* Gets or sets the name of the property on node data that specifies
* the string or number key of the group data that "owns" that node data,
@@ -4926,6 +5149,17 @@ declare namespace go {
*/
copyLinkData(linkdata: Object): Object;
+ /**
+ * Given a number or string, find the link data object in this model
+ * that uses the given value as its unique key.
+ * Unless .linkKeyProperty is set to a non-empty string, this model
+ * will not automatically assign unique key values for link data objects,
+ * and thus this method will always return null.
+ * The return value will be an Object or null.
+ * @param {*} key a string or a number.
+ */
+ findLinkDataForKey(key: Key): any;
+
/**
* Find the category of a given link data, a string naming the link template
* that the Diagram should use to represent the link data.
@@ -4953,6 +5187,16 @@ declare namespace go {
*/
getGroupKeyForNodeData(nodedata: Object): Key;
+ /**
+ * Given a link data object return its unique key: a number or a string.
+ * This returns undefined if there is no key value.
+ * Unless .linkKeyProperty is set to a non-empty string, this model
+ * will not automatically assign unique key values for link data objects.
+ * It is possible to change the key for a link data object by calling .setKeyForLinkData.
+ * @param {Object} linkdata a JavaScript object representing a link.
+ */
+ getKeyForLinkData(linkdata: Object): Key;
+
/**
* Gets an Array of node key values that identify node data acting as labels on the given link data.
* This method only works if .linkLabelKeysProperty has been set to something other than an empty string.
@@ -4982,6 +5226,21 @@ declare namespace go {
*/
isGroupForNodeData(nodedata: Object): boolean;
+ /**
+ * This method is called when a link data object is added to the model to make sure that
+ * .getKeyForLinkData returns a unique key value.
+ * The key value should be unique within the set of data managed by this model:
+ * .linkDataArray.
+ * If the key is already in use, this will assign an unused number to the
+ * .linkKeyProperty property on the data.
+ * If you want to customize the way in which link data gets a unique key,
+ * you can set the .makeUniqueKeyFunction functional property.
+ * If the link data object is already in the model and you want to change its key value,
+ * call .setKeyForLinkData and give it a new unique key value.
+ * @param {Object} linkdata a JavaScript object representing a link.
+ */
+ makeLinkDataKeyUnique(linkdata: Object): void;
+
/**
* Removes a node key value that identifies a node data acting as a former label node on the given link data.
* Removing a reference to a node data from the collection of link label keys
@@ -5045,6 +5304,19 @@ declare namespace go {
*/
setGroupKeyForNodeData(nodedata: Object, key: Key): void;
+ /**
+ * Change the unique key of a given link data that is already in this model.
+ * The new key value must be unique -- i.e. not in use by another link data object.
+ * You can call .findLinkDataForKey to check if a proposed new key is already in use.
+ * If this is called when .linkKeyProperty is the empty string (i.e. its default value),
+ * this method has no effect.
+ * If this is called on a link data object that is not (yet) in this model,
+ * this unconditionally modifies the property to the new key value.
+ * @param {Object} linkdata a JavaScript object representing a link.
+ * @param {string|number|undefined} key
+ */
+ setKeyForLinkData(linkdata: Object, key: Key): void;
+
/**
* Replaces an Array of node key values that identify node data acting as labels on the given link data.
* This method only works if .linkLabelKeysProperty has been set to something other than an empty string.
@@ -5102,7 +5374,7 @@ declare namespace go {
/**Gets or sets a function that returns a unique id number or string for a node data object; the default value is null.*/
makeUniqueKeyFunction: (model: Model, obj: Object) => Key;
- /**Gets a JavaScript Object that can hold programmer-defined property values for the model as a whole, rather than just for one node or one link; by default this is an object with no properties.*/
+ /**Gets a JavaScript Object that can hold programmer-defined property values for the model as a whole, rather than just for one node or one link; by default this is an object with no properties. The value must be an Object.*/
modelData: any;
/**Gets or sets the name of this model; the initial name is an empty string.*/
@@ -5134,7 +5406,7 @@ declare namespace go {
addArrayItem(arr: Array, val: any): void;
/**
- * Register an event handler that is called when there is a ChangedEvent.
+ * Register an event handler that is called when there is a ChangedEvent for a modification of the Diagram, a Layer, or a GraphObject.
* This registration does not raise a ChangedEvent.
* @param {function(ChangedEvent)} listener a function that takes a ChangedEvent as its argument.
*/
@@ -5157,6 +5429,18 @@ declare namespace go {
*/
addNodeDataCollection(coll: Iterable