removed ts check comments which match and converted mxCell[] references to mxCellArray

development
mcyph 2021-06-05 17:24:20 +10:00
parent 40d5834b7c
commit 40d12f9745
15 changed files with 1607 additions and 1256 deletions

View File

@ -4,6 +4,7 @@ import mxLog from '../util/gui/mxLog';
import mxEvent from '../util/event/mxEvent';
import mxGraphSelectionModel from '../view/graph/mxGraphSelectionModel';
import mxCell from '../view/cell/mxCell';
import mxCellArray from "../view/cell/mxCellArray";
/**
* @class mxSelectionChange
@ -12,8 +13,8 @@ import mxCell from '../view/cell/mxCell';
class mxSelectionChange {
constructor(
selectionModel: mxGraphSelectionModel,
added: mxCell[] = [],
removed: mxCell[] = []
added: mxCellArray = new mxCellArray(),
removed: mxCellArray = new mxCellArray()
) {
this.selectionModel = selectionModel;
this.added = added.slice();
@ -22,9 +23,9 @@ class mxSelectionChange {
selectionModel: mxGraphSelectionModel;
added: mxCell[];
added: mxCellArray;
removed: mxCell[];
removed: mxCellArray;
/**
* Changes the current root of the view.

View File

@ -15,6 +15,7 @@ import {
import mxPerimeter from './mxPerimeter';
import mxUtils from '../../mxUtils';
import { clone } from '../../mxCloneUtils';
import StyleMap from "../../../view/graph/StyleMap";
/**
* @class mxStylesheet
@ -67,7 +68,7 @@ import { clone } from '../../mxCloneUtils';
*/
class mxStylesheet {
constructor() {
this.styles = {};
this.styles = new StyleMap();
this.putDefaultVertexStyle(this.createDefaultVertexStyle());
this.putDefaultEdgeStyle(this.createDefaultEdgeStyle());
@ -77,15 +78,13 @@ class mxStylesheet {
* Maps from names to cell styles. Each cell style is a map of key,
* value pairs.
*/
// styles: StyleMap;
styles;
styles: StyleMap;
/**
* Creates and returns the default vertex style.
*/
// createDefaultVertexStyle(): StyleMap;
createDefaultVertexStyle() {
const style = {};
createDefaultVertexStyle(): StyleMap {
const style = new StyleMap();
style.shape = SHAPE_RECTANGLE;
style.perimeter = mxPerimeter.RectanglePerimeter;
style.verticalAlign = ALIGN_MIDDLE;
@ -99,9 +98,8 @@ class mxStylesheet {
/**
* Creates and returns the default edge style.
*/
// createDefaultEdgeStyle(): StyleMap;
createDefaultEdgeStyle() {
const style = {};
createDefaultEdgeStyle(): StyleMap {
const style = new StyleMap();
style.shape = SHAPE_CONNECTOR;
style.endArrow = ARROW_CLASSIC;
style.verticalAlign = ALIGN_MIDDLE;
@ -116,33 +114,29 @@ class mxStylesheet {
* stylename.
* @param style Key, value pairs that define the style.
*/
// putDefaultVertexStyle(style: StyleMap): void;
putDefaultVertexStyle(style) {
putDefaultVertexStyle(style: StyleMap): void {
this.putCellStyle('defaultVertex', style);
}
/**
* Sets the default style for edges using defaultEdge as the stylename.
*/
// putDefaultEdgeStyle(style: StyleMap): void;
putDefaultEdgeStyle(style) {
putDefaultEdgeStyle(style: StyleMap): void {
this.putCellStyle('defaultEdge', style);
}
/**
* Returns the default style for vertices.
*/
// getDefaultVertexStyle(): StyleMap;
getDefaultVertexStyle() {
return this.styles.defaultVertex;
getDefaultVertexStyle(): StyleMap {
return <StyleMap>this.styles.defaultVertex;
}
/**
* Sets the default style for edges.
*/
// getDefaultEdgeStyle(): StyleMap;
getDefaultEdgeStyle() {
return this.styles.defaultEdge;
getDefaultEdgeStyle(): StyleMap {
return <StyleMap>this.styles.defaultEdge;
}
/**
@ -178,8 +172,7 @@ class mxStylesheet {
* @param name Name for the style to be stored.
* @param style Key, value pairs that define the style.
*/
// putCellStyle(name: string, style: StyleMap): void;
putCellStyle(name, style) {
putCellStyle(name: string, style: StyleMap): void {
this.styles[name] = style;
}
@ -190,8 +183,9 @@ class mxStylesheet {
* @param name String of the form [(stylename|key=value);] that represents the style.
* @param defaultStyle Default style to be returned if no style can be found.
*/
// getCellStyle(name: string, defaultStyle?: StyleMap): StyleMap;
getCellStyle(name, defaultStyle) {
getCellStyle(name: string,
defaultStyle: StyleMap=new StyleMap()): StyleMap {
let style = defaultStyle;
if (name != null && name.length > 0) {
@ -200,12 +194,11 @@ class mxStylesheet {
if (style != null && name.charAt(0) !== ';') {
style = clone(style);
} else {
style = {};
style = new StyleMap();
}
// Parses each key, value pair into the existing style
for (let i = 0; i < pairs.length; i += 1) {
const tmp = pairs[i];
for (const tmp of pairs) {
const pos = tmp.indexOf('=');
if (pos >= 0) {

View File

@ -5,9 +5,9 @@
* Type definitions from the typed-mxgraph project
*/
import mxCell from '../../view/cell/mxCell';
import mxGraph from '../../view/graph/mxGraph';
import mxGraphModel from "../../view/graph/mxGraphModel";
import mxCellArray from "../../view/cell/mxCellArray";
/**
* @class
@ -86,42 +86,36 @@ class mxClipboard {
* Defines the step size to offset the cells after each paste operation.
* Default is 10.
*/
// static STEPSIZE: number;
static STEPSIZE: number = 10;
/**
* Counts the number of times the clipboard data has been inserted.
*/
// static insertCount: number;
static insertCount: number = 1;
/**
* Holds the array of {@link mxCell} currently in the clipboard.
*/
// static cells: Array<mxCell>;
static cells: mxCell[] | null = null;
static cells: mxCellArray | null = null;
/**
* Sets the cells in the clipboard. Fires a {@link mxEvent.CHANGE} event.
*/
// static setCells(cells: Array<mxCell>): void;
static setCells(cells: mxCell[] | null) {
static setCells(cells: mxCellArray | null): void {
mxClipboard.cells = cells;
}
/**
* Returns the cells in the clipboard.
*/
// static getCells(): Array<mxCell>;
static getCells() {
static getCells(): mxCellArray | null {
return mxClipboard.cells;
}
/**
* Returns true if the clipboard currently has not data stored.
*/
// static isEmpty(): boolean;
static isEmpty() {
static isEmpty(): boolean {
return mxClipboard.getCells() == null;
}
@ -133,8 +127,7 @@ class mxClipboard {
* @param graph - {@link mxGraph} that contains the cells to be cut.
* @param cells - Optional array of {@link mxCell} to be cut.
*/
// static cut(graph: mxGraph, cells?: Array<mxCell>): Array<mxCell>;
static cut(graph: mxGraph, cells: mxCell[] | null) {
static cut(graph: mxGraph, cells?: mxCellArray | null): mxCellArray | null {
cells = mxClipboard.copy(graph, cells);
mxClipboard.insertCount = 0;
mxClipboard.removeCells(graph, cells);
@ -149,8 +142,7 @@ class mxClipboard {
* @param graph - {@link mxGraph} that contains the cells to be cut.
* @param cells - Array of {@link mxCell} to be cut.
*/
// static removeCells(graph: mxGraph, cells: Array<mxCell>): void;
static removeCells(graph: mxGraph, cells: mxCell[] | null) {
static removeCells(graph: mxGraph, cells: mxCellArray | null): void {
graph.removeCells(cells);
}
@ -162,12 +154,11 @@ class mxClipboard {
* @param graph - {@link mxGraph} that contains the cells to be copied.
* @param cells - Optional array of {@link mxCell} to be copied.
*/
// static copy(graph: mxGraph, cells?: Array<mxCell>): Array<mxCell>;
static copy(graph: mxGraph, cells: mxCell[] | null): mxCell[] | null {
static copy(graph: mxGraph, cells?: mxCellArray | null): mxCellArray | null {
cells = cells || graph.getSelectionCells();
const result = graph.getExportableCells((<mxGraphModel>graph.model).getTopmostCells(cells));
const result = (<mxCellArray>graph.getExportableCells(cells)).getTopmostCells();
mxClipboard.insertCount = 1;
mxClipboard.setCells(graph.cloneCells(<mxCell[]>result));
mxClipboard.setCells(graph.cloneCells(<mxCellArray>result));
return result;
}
@ -183,8 +174,7 @@ class mxClipboard {
*
* @param graph - {@link mxGraph} to paste the {@link cells} into.
*/
// static paste(graph: mxGraph): Array<mxCell>;
static paste(graph: mxGraph) {
static paste(graph: mxGraph): mxCellArray | null {
let cells = null;
if (!mxClipboard.isEmpty()) {
@ -196,7 +186,7 @@ class mxClipboard {
// Increments the counter and selects the inserted cells
mxClipboard.insertCount++;
graph.setSelectionCells(<mxCell[]>cells);
graph.setSelectionCells(<mxCellArray>cells);
}
return cells;

View File

@ -11,6 +11,7 @@ import mxCellOverlay from './mxCellOverlay';
import { clone } from '../../util/mxCloneUtils';
import mxPoint from '../../util/datatypes/mxPoint';
import mxCellPath from './mxCellPath';
import mxCellArray from "./mxCellArray";
/**
* Cells are the elements of the graph model. They represent the state
@ -73,8 +74,8 @@ class mxCell {
}
// TODO: Document me!!!
getChildren(): mxCell[] {
return this.children || [];
getChildren(): mxCellArray {
return this.children || new mxCellArray();
}
// TODO: Document me!
@ -89,87 +90,73 @@ class mxCell {
/**
* Holds the Id. Default is null.
*/
// id: string;
id: string | null = null;
/**
* Holds the user object. Default is null.
*/
// value: any;
value: any = null;
/**
* Holds the <mxGeometry>. Default is null.
*/
// geometry: mxGeometry;
geometry: mxGeometry | null = null;
/**
* Holds the style as a string of the form [(stylename|key=value);]. Default is
* null.
*/
// style: string;
style: string | null = null;
/**
* Specifies whether the cell is a vertex. Default is false.
*/
// vertex: boolean;
vertex: boolean = false;
/**
* Specifies whether the cell is an edge. Default is false.
*/
// edge: boolean;
edge: boolean = false;
/**
* Specifies whether the cell is connectable. Default is true.
*/
// connectable: boolean;
connectable: boolean = true;
/**
* Specifies whether the cell is visible. Default is true.
*/
// visible: boolean;
visible: boolean = true;
/**
* Specifies whether the cell is collapsed. Default is false.
*/
// collapsed: boolean;
collapsed: boolean = false;
/**
* Reference to the parent cell.
*/
// parent: mxCell;
parent: mxCell | null = null;
/**
* Reference to the source terminal.
*/
// source: mxCell;
source: mxCell | null = null;
/**
* Reference to the target terminal.
*/
// target: mxCell;
target: mxCell | null = null;
/**
* Holds the child cells.
*/
// children: Array<mxCell>;
children: mxCell[] | null = null;
children: mxCellArray | null = null;
/**
* Holds the edges.
*/
// edges: Array<mxCell>;
edges: mxCell[] | null = null;
edges: mxCellArray | null = null;
/**
* List of members that should not be cloned inside <clone>. This field is
@ -178,7 +165,6 @@ class mxCell {
* to mark transient fields since transient modifiers are not supported by
* the language.
*/
// mxTransient: Array<string>;
mxTransient: string[] = [
'id',
'value',
@ -192,7 +178,6 @@ class mxCell {
/**
* Returns the Id of the cell as a string.
*/
// getId(): string;
getId(): string | null {
return this.id;
}
@ -200,7 +185,6 @@ class mxCell {
/**
* Sets the Id of the cell to the given string.
*/
// setId(id: string): void;
setId(id: string): void {
this.id = id;
}
@ -209,7 +193,6 @@ class mxCell {
* Returns the user object of the cell. The user
* object is stored in <value>.
*/
// getValue(): any;
getValue(): any {
return this.value;
}
@ -218,7 +201,6 @@ class mxCell {
* Sets the user object of the cell. The user object
* is stored in <value>.
*/
// setValue(value: any): void;
setValue(value: number): void {
this.value = value;
}
@ -229,7 +211,6 @@ class mxCell {
* replaces the user object with the given value and
* returns the old user object.
*/
// valueChanged(newValue: any): any;
valueChanged(newValue: any): any {
const previous = this.getValue();
this.setValue(newValue);
@ -239,7 +220,6 @@ class mxCell {
/**
* Returns the <mxGeometry> that describes the <geometry>.
*/
// getGeometry(): mxGeometry;
getGeometry(): mxGeometry | null {
return this.geometry;
}
@ -247,7 +227,6 @@ class mxCell {
/**
* Sets the <mxGeometry> to be used as the <geometry>.
*/
// setGeometry(geometry: mxGeometry): void;
setGeometry(geometry: mxGeometry | null): void {
this.geometry = geometry;
}
@ -255,15 +234,13 @@ class mxCell {
/**
* Returns a string that describes the <style>.
*/
// getStyle(): string;
getStyle(): any {
getStyle(): string | null {
return this.style;
}
/**
* Sets the string to be used as the <style>.
*/
// setStyle(style: string): void;
setStyle(style: string | null): void {
this.style = style;
}
@ -271,7 +248,6 @@ class mxCell {
/**
* Returns true if the cell is a vertex.
*/
// isVertex(): boolean;
isVertex(): boolean {
return this.vertex;
}
@ -284,15 +260,13 @@ class mxCell {
*
* @param vertex Boolean that specifies if the cell is a vertex.
*/
// setVertex(vertex: boolean): void;
setVertex(vertex: boolean) {
setVertex(vertex: boolean): void {
this.vertex = vertex;
}
/**
* Returns true if the cell is an edge.
*/
// isEdge(): boolean;
isEdge(): boolean {
return this.edge;
}
@ -305,15 +279,13 @@ class mxCell {
*
* @param edge Boolean that specifies if the cell is an edge.
*/
// setEdge(edge: boolean): void;
setEdge(edge: boolean) {
setEdge(edge: boolean): void {
this.edge = edge;
}
/**
* Returns true if the cell is connectable.
*/
// isConnectable(): boolean;
isConnectable(): boolean {
return this.connectable;
}
@ -325,15 +297,13 @@ class mxCell {
*
* @param connectable Boolean that specifies the new connectable state.
*/
// setConnectable(connectable: boolean): void;
setConnectable(connectable: boolean) {
setConnectable(connectable: boolean): void {
this.connectable = connectable;
}
/**
* Returns true if the cell is visibile.
*/
// isVisible(): boolean;
isVisible(): boolean {
return this.visible;
}
@ -345,7 +315,6 @@ class mxCell {
*
* @param visible Boolean that specifies the new visible state.
*/
// setVisible(visible: boolean): void;
setVisible(visible: boolean): void {
this.visible = visible;
}
@ -353,7 +322,6 @@ class mxCell {
/**
* Returns true if the cell is collapsed.
*/
// isCollapsed(): boolean;
isCollapsed(): boolean {
return this.collapsed;
}
@ -365,7 +333,6 @@ class mxCell {
*
* @param collapsed Boolean that specifies the new collapsed state.
*/
// setCollapsed(collapsed: boolean): void;
setCollapsed(collapsed: boolean): void {
this.collapsed = collapsed;
}
@ -373,7 +340,6 @@ class mxCell {
/**
* Returns the cell's parent.
*/
// getParent(): mxCell;
getParent(): mxCell | null {
return this.parent;
}
@ -385,7 +351,6 @@ class mxCell {
*
* @param parent<mxCell> that represents the new parent.
*/
// setParent(parent: mxCell): void;
setParent(parent: mxCell | null): void {
this.parent = parent;
}
@ -398,7 +363,6 @@ class mxCell {
* @param source Boolean that specifies if the source terminal should be
* returned.
*/
// getTerminal(source: boolean): mxCell;
getTerminal(source: boolean = false): mxCell | null {
return source ? this.source : this.target;
}
@ -410,7 +374,6 @@ class mxCell {
* @param {boolean} isSource boolean that specifies if the source or target terminal
* should be set.
*/
// setTerminal(terminal: mxCell, isSource: boolean): mxCell;
setTerminal(terminal: mxCell | null, isSource: boolean): mxCell | null {
if (isSource) {
this.source = terminal;
@ -423,7 +386,6 @@ class mxCell {
/**
* Returns the number of child cells.
*/
// getChildCount(): number;
getChildCount(): number {
return this.children == null ? 0 : this.children.length;
}
@ -435,7 +397,6 @@ class mxCell {
*
* @param childChild whose index should be returned.
*/
// getIndex(child: mxCell): number;
getIndex(child: mxCell | null): number {
if (child === null || !this.children) return -1;
return this.children.indexOf(child);
@ -448,7 +409,6 @@ class mxCell {
*
* @param indexInteger that specifies the child to be returned.
*/
// getChildAt(index: number): mxCell;
getChildAt(index: number): mxCell | null {
return this.children == null ? null : this.children[index];
}
@ -465,26 +425,23 @@ class mxCell {
* @param indexOptional integer that specifies the index at which the child
* should be inserted into the child array.
*/
// insert(child: mxCell, index: number): mxCell;
insert(child: mxCell | null = null, index: number | null = null) {
if (child != null) {
if (index == null) {
index = this.getChildCount();
insert(child: mxCell, index: number | null = null): mxCell | null {
if (index == null) {
index = this.getChildCount();
if (child.getParent() === this) {
index--;
}
if (child.getParent() === this) {
index--;
}
}
child.removeFromParent();
child.setParent(this);
child.removeFromParent();
child.setParent(this);
if (this.children == null) {
this.children = [];
this.children.push(child);
} else {
this.children.splice(index, 0, child);
}
if (this.children == null) {
this.children = new mxCellArray();
this.children.push(child);
} else {
this.children.splice(index, 0, child);
}
return child;
}
@ -499,7 +456,6 @@ class mxCell {
* @param indexInteger that specifies the index of the child to be
* removed.
*/
// remove(index: number): mxCell;
remove(index: number): mxCell | null {
let child = null;
if (this.children != null && index >= 0) {
@ -515,7 +471,6 @@ class mxCell {
/**
* Removes the cell from its parent.
*/
// removeFromParent(): mxCell;
removeFromParent(): void {
if (this.parent != null) {
const index = this.parent.getIndex(this);
@ -526,7 +481,6 @@ class mxCell {
/**
* Returns the number of edges in the edge array.
*/
// getEdgeCount(): number;
getEdgeCount(): number {
return this.edges == null ? 0 : this.edges.length;
}
@ -538,7 +492,6 @@ class mxCell {
*
* @param edge<mxCell> whose index in <edges> should be returned.
*/
// getEdgeIndex(edge: mxCell): number;
getEdgeIndex(edge: mxCell): number {
if (!this.edges) return -1;
return this.edges.indexOf(edge);
@ -551,7 +504,6 @@ class mxCell {
*
* @param indexInteger that specifies the index of the edge to be returned.
*/
// getEdgeAt(index: number): mxCell;
getEdgeAt(index: number): mxCell | null {
return this.edges == null ? null : this.edges[index];
}
@ -565,7 +517,6 @@ class mxCell {
* @param edge <mxCell> to be inserted into the edge array.
* @param isOutgoing Boolean that specifies if the edge is outgoing.
*/
// insertEdge(edge: mxCell, isOutgoing: boolean): mxCell;
insertEdge(edge: mxCell | null, isOutgoing: boolean) {
if (edge != null) {
edge.removeFromTerminal(isOutgoing);
@ -577,7 +528,7 @@ class mxCell {
this.edges.indexOf(edge) < 0
) {
if (this.edges == null) {
this.edges = [];
this.edges = new mxCellArray();
}
this.edges.push(edge);
}
@ -594,7 +545,6 @@ class mxCell {
* @param edge<mxCell> to be removed from the edge array.
* @param isOutgoing Boolean that specifies if the edge is outgoing.
*/
// removeEdge(edge: mxCell, isOutgoing: boolean): mxCell;
removeEdge(edge: mxCell | null, isOutgoing: boolean = false): mxCell | null {
if (edge != null) {
if (edge.getTerminal(!isOutgoing) !== this && this.edges != null) {
@ -616,7 +566,6 @@ class mxCell {
*
* @param isSource Boolean that specifies if the edge should be removed from its source or target terminal.
*/
// removeFromTerminal(isSource: boolean): mxCell;
removeFromTerminal(isSource: boolean): void {
const terminal = this.getTerminal(isSource);
if (terminal != null) {
@ -632,7 +581,6 @@ class mxCell {
*
* @param nameName nameName of the attribute.
*/
// hasAttribute(name: string): boolean;
hasAttribute(name: string): boolean {
const userObject = this.getValue();
return (
@ -653,7 +601,6 @@ class mxCell {
* @param defaultValueOptional default value to use if the attribute has no
* value.
*/
// getAttribute(name: string, defaultValue: any): any;
getAttribute(name: string, defaultValue: any): any {
const userObject = this.getValue();
const val =
@ -671,7 +618,6 @@ class mxCell {
* @param nameName of the attribute whose value should be set.
* @param valueNew value of the attribute.
*/
// setAttribute(name: string, value: any): void;
setAttribute(name: string, value: any): void {
const userObject = this.getValue();
if (userObject != null && userObject.nodeType === NODETYPE_ELEMENT) {
@ -684,7 +630,6 @@ class mxCell {
* the user object. All fields in <mxTransient> are ignored
* during the cloning.
*/
// clone(): mxCell;
clone(): mxCell {
const c = clone(this, this.mxTransient);
c.setValue(this.cloneValue());
@ -694,7 +639,6 @@ class mxCell {
/**
* Returns a clone of the cell's user object.
*/
// cloneValue(): any;
cloneValue(): any {
let value = this.getValue();
if (value != null) {
@ -712,10 +656,9 @@ class mxCell {
*
* @param {mxCell} cell2 that specifies the second cell in the tree.
*/
// getNearestCommonAncestor(cell1: mxCell, cell2: mxCell): mxCell;
getNearestCommonAncestor(cell2: mxCell | null): mxCell | null {
getNearestCommonAncestor(cell2: mxCell): mxCell | null {
// Creates the cell path for the second cell
let path = mxCellPath.create(<mxCell>cell2);
let path = mxCellPath.create(cell2);
if (path != null && path.length > 0) {
// Bubbles through the ancestors of the first
@ -756,7 +699,6 @@ class mxCell {
*
* @param {mxCell} child that specifies the child.
*/
// isAncestor(parent: mxCell, child: mxCell): boolean;
isAncestor(child: mxCell | null): boolean {
while (child != null && child !== this) {
child = <mxCell>child.getParent();
@ -767,16 +709,14 @@ class mxCell {
/**
* Returns the child vertices of the given parent.
*/
// getChildVertices(parent: mxCell): Array<mxCell>;
getChildVertices() {
getChildVertices(): mxCellArray {
return this.getChildCells(true, false);
}
/**
* Returns the child edges of the given parent.
*/
// getChildEdges(parent: mxCell): Array<mxCell>;
getChildEdges(): mxCell[] {
getChildEdges(): mxCellArray {
return this.getChildCells(false, true);
}
@ -789,10 +729,9 @@ class mxCell {
* @param edges Boolean indicating if child edges should be returned.
* Default is false.
*/
// getChildCells(parent: mxCell, vertices: boolean, edges: boolean): Array<mxCell>;
getChildCells(vertices: boolean = false, edges: boolean = false): mxCell[] {
getChildCells(vertices: boolean = false, edges: boolean = false): mxCellArray {
const childCount = this.getChildCount();
const result = [];
const result = new mxCellArray();
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>this.getChildAt(i);
@ -816,7 +755,6 @@ class mxCell {
* incoming edges should be returned.
* @param {mxCell} ignoredEdge that represents an edge to be ignored.
*/
// getDirectedEdgeCount(cell: mxCell, outgoing: boolean, ignoredEdge: boolean): number;
getDirectedEdgeCount(
outgoing: boolean,
ignoredEdge: mxCell | null = null
@ -836,24 +774,21 @@ class mxCell {
/**
* Returns all edges of the given cell without loops.
*/
// getConnections(cell: mxCell): Array<mxCell>;
getConnections() {
getConnections(): mxCellArray {
return this.getEdges(true, true, false);
}
/**
* Returns the incoming edges of the given cell without loops.
*/
// getIncomingEdges(cell: mxCell): Array<mxCell>;
getIncomingEdges(): mxCell[] {
getIncomingEdges(): mxCellArray {
return this.getEdges(true, false, false);
}
/**
* Returns the outgoing edges of the given cell without loops.
*/
// getOutgoingEdges(cell: mxCell): Array<mxCell>;
getOutgoingEdges(): mxCell[] {
getOutgoingEdges(): mxCellArray {
return this.getEdges(false, true, false);
}
@ -870,14 +805,13 @@ class mxCell {
* @param includeLoops Optional boolean that specifies if loops should be returned.
* Default is true.
*/
// getEdges(cell: mxCell, incoming?: boolean, outgoing?: boolean, includeLoops?: boolean): Array<mxCell>;
getEdges(
incoming: boolean = true,
outgoing: boolean = true,
includeLoops: boolean = true
) {
): mxCellArray {
const edgeCount = this.getEdgeCount();
const result = [];
const result = new mxCellArray();
for (let i = 0; i < edgeCount; i += 1) {
const edge = <mxCell>this.getEdgeAt(i);
@ -924,8 +858,7 @@ class mxCell {
/**
* Returns all descendants of the given cell and the cell itself in an array.
*/
// getDescendants(parent: mxCell): Array<mxCell>;
getDescendants(): mxCell[] {
getDescendants(): mxCellArray {
return this.filterDescendants(null);
}
@ -948,12 +881,11 @@ class mxCell {
* @param filter JavaScript function that takes an {@link mxCell} as an argument
* and returns a boolean.
*/
// filterDescendants(filter: (...args: any) => boolean, parent?: mxCell): Array<mxCell>;
filterDescendants(filter: Function | null): mxCell[] {
filterDescendants(filter: Function | null): mxCellArray {
let parent = this;
// Creates a new array for storing the result
let result: mxCell[] = [];
let result = new mxCellArray();
// Recursion starts at the root of the model
parent = parent || this.getRoot();
@ -968,7 +900,7 @@ class mxCell {
const childCount = parent.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>parent.getChildAt(i);
result = result.concat(child.filterDescendants(filter));
result = new mxCellArray(...result.concat(child.filterDescendants(filter)));
}
return result;
@ -977,7 +909,6 @@ class mxCell {
/**
* Returns the root of the model or the topmost parent of the given cell.
*/
// getRoot(cell?: mxCell): mxCell;
getRoot(): mxCell {
let root: mxCell = this;
let cell: mxCell = this;

View File

@ -2,18 +2,43 @@ import mxCell from "./mxCell";
import mxDictionary from "../../util/datatypes/mxDictionary";
import mxObjectIdentity from "../../util/datatypes/mxObjectIdentity";
class mxCells extends Array<mxCell> {
constructor(...items: mxCell[]) {
class mxCellArray extends Array<mxCell> {
// @ts-ignore
constructor(...items: mxCell[] | mxCellArray) {
super(...items);
}
// @ts-ignore
concat(items: any): mxCellArray {
return new mxCellArray(...super.concat(items));
}
// @ts-ignore
splice(arg0: number, ...args: any): mxCellArray {
return new mxCellArray(...super.splice(arg0, ...args));
}
// @ts-ignore
slice(...args: any): mxCellArray {
return new mxCellArray(...super.slice(...args));
}
// @ts-ignore
map(arg0: any, ...args: any): mxCellArray {
return new mxCellArray(...<mxCell[]>super.map(arg0, ...args));
}
// @ts-ignore
filter(arg0: any, ...args: any): mxCellArray {
return new mxCellArray(...<mxCell[]>super.filter(arg0, ...args));
}
/**
* Returns the cells from the given array where the given filter function
* returns true.
*/
// filterCells(cells: Array<mxCell>, filter: (...args: any) => boolean): Array<mxCell>;
filterCells(filter: Function): mxCell[] {
let result = [];
filterCells(filter: Function): mxCellArray {
let result = new mxCellArray();
for (let i = 0; i < this.length; i += 1) {
if (filter(this[i])) {
@ -34,12 +59,11 @@ class mxCells extends Array<mxCell> {
* @param targets Boolean that specifies if target terminals should be contained
* in the result. Default is true.
*/
// getOpposites(edges: Array<mxCell>, terminal: mxCell, sources?: boolean, targets?: boolean): Array<mxCell>;
getOpposites(terminal: mxCell,
sources: boolean=true,
targets: boolean=true): mxCell[] {
targets: boolean=true): mxCellArray {
const terminals = [];
const terminals = new mxCellArray();
for (let i = 0; i < this.length; i += 1) {
const source = this[i].getTerminal(true);
@ -77,10 +101,9 @@ class mxCells extends Array<mxCell> {
* descendants for each {@link mxCell} that it contains. Duplicates should be
* removed in the cells array to improve performance.
*/
// getTopmostCells(cells: Array<mxCell>): Array<mxCell>;
getTopmostCells(): mxCell[] {
getTopmostCells(): mxCellArray {
const dict = new mxDictionary();
const tmp = [];
const tmp = new mxCellArray();
for (let i = 0; i < this.length; i += 1) {
dict.put(this[i], true);
@ -110,8 +133,7 @@ class mxCells extends Array<mxCell> {
* Returns an array that represents the set (no duplicates) of all parents
* for the given array of cells.
*/
// getParents(cells: Array<mxCell>): Array<mxCell>;
getParents() {
getParents(): mxCell[] {
const parents = [];
const dict = new mxDictionary();
@ -135,11 +157,10 @@ class mxCells extends Array<mxCell> {
* with all descendants.
* @param mapping Optional mapping for existing clones.
*/
// cloneCells(cells: Array<mxCell>, includeChildren?: boolean, mapping?: any): Array<mxCell>;
cloneCells(includeChildren: boolean=true,
mapping: any={}): mxCell[] {
mapping: any={}): mxCellArray {
const clones: mxCell[] = [];
const clones: mxCellArray = new mxCellArray();
for (const cell of this) {
clones.push(this.cloneCellImpl(cell, mapping, includeChildren));
@ -158,12 +179,11 @@ class mxCells extends Array<mxCell> {
*
* @private
*/
// cloneCellImpl(cell: mxCell, mapping?: any, includeChildren?: boolean): mxCell;
cloneCellImpl(cell: mxCell,
mapping: any={},
includeChildren: boolean): mxCell {
const ident = mxObjectIdentity.get(cell);
const ident = <string>mxObjectIdentity.get(cell);
let clone = mapping ? mapping[ident] : null;
if (clone == null) {
@ -192,7 +212,6 @@ class mxCells extends Array<mxCell> {
*
* @private
*/
// restoreClone(clone: mxCell, cell: mxCell, mapping?: any): void;
restoreClone(clone: mxCell,
cell: mxCell,
mapping: any): void {
@ -225,4 +244,4 @@ class mxCells extends Array<mxCell> {
}
}
export default mxCells;
export default mxCellArray;

View File

@ -7,6 +7,8 @@
import mxResources from '../../util/mxResources';
import { isNode } from '../../util/mxDomUtils';
import mxCell from "../cell/mxCell";
import mxGraph from "../graph/mxGraph";
/**
* @class mxMultiplicity
@ -30,16 +32,16 @@ import { isNode } from '../../util/mxDomUtils';
*/
class mxMultiplicity {
constructor(
source,
type,
attr,
value,
min,
max,
validNeighbors,
countError,
typeError,
validNeighborsAllowed
source: boolean,
type: string,
attr: string,
value: string,
min: number | null | undefined,
max: number | 'n' | null | undefined,
validNeighbors: string[],
countError: string,
typeError: string,
validNeighborsAllowed: boolean=true
) {
this.source = source;
this.type = type;
@ -50,8 +52,7 @@ class mxMultiplicity {
this.validNeighbors = validNeighbors;
this.countError = mxResources.get(countError) || countError;
this.typeError = mxResources.get(typeError) || typeError;
this.validNeighborsAllowed =
validNeighborsAllowed != null ? validNeighborsAllowed : true;
this.validNeighborsAllowed = validNeighborsAllowed;
}
/**
@ -59,75 +60,65 @@ class mxMultiplicity {
* passed to {@link mxUtils.isNode} together with the source or target vertex
* value as the first argument.
*/
// type: string;
type = null;
type: string;
/**
* Optional string that specifies the attributename to be passed to
* {@link mxUtils.isNode} to check if the rule applies to a cell.
*/
// attr: string;
attr = null;
attr: string;
/**
* Optional string that specifies the value of the attribute to be passed
* to {@link mxUtils.isNode} to check if the rule applies to a cell.
*/
// value: string;
value = null;
value: string;
/**
* Boolean that specifies if the rule is applied to the source or target
* terminal of an edge.
*/
// source: boolean;
source = null;
source: boolean;
/**
* Defines the minimum number of connections for which this rule applies.
*
* @default 0
*/
// min: number;
min = null;
min: number;
/**
* Defines the maximum number of connections for which this rule applies.
* A value of 'n' means unlimited times.
* @default 'n'
*/
// max: number | 'n';
max = null;
max: number | 'n';
/**
* Holds an array of strings that specify the type of neighbor for which
* this rule applies. The strings are used in {@link mxCell.is} on the opposite
* terminal to check if the rule applies to the connection.
*/
// validNeighbors: Array<string>;
validNeighbors = null;
validNeighbors: Array<string>;
/**
* Boolean indicating if the list of validNeighbors are those that are allowed
* for this rule or those that are not allowed for this rule.
*/
// validNeighborsAllowed: boolean;
validNeighborsAllowed = true;
validNeighborsAllowed: boolean = true;
/**
* Holds the localized error message to be displayed if the number of
* connections for which the rule applies is smaller than {@link min} or greater
* than {@link max}.
*/
// countError: string;
countError = null;
countError: string;
/**
* Holds the localized error message to be displayed if the type of the
* neighbor for a connection does not match the rule.
*/
// typeError: string;
typeError = null;
typeError: string;
/**
* Checks the multiplicity for the given arguments and returns the error
@ -140,8 +131,13 @@ class mxMultiplicity {
* @param sourceOut Number of outgoing edges from the source terminal.
* @param targetIn Number of incoming edges for the target terminal.
*/
// check(graph: mxGraph, edge: mxCell, source: mxCell, target: mxCell, sourceOut: number, targetIn: number): string;
check(graph, edge, source, target, sourceOut, targetIn) {
check(graph: mxGraph,
edge: mxCell,
source: mxCell,
target: mxCell,
sourceOut: number,
targetIn: number): string | null {
let error = '';
if (
@ -176,8 +172,11 @@ class mxMultiplicity {
* Checks if there are any valid neighbours in {@link validNeighbors}. This is only
* called if {@link validNeighbors} is a non-empty array.
*/
// checkNeighbors(graph: mxGraph, edge: mxCell, source: mxCell, target: mxCell): boolean;
checkNeighbors(graph, edge, source, target) {
checkNeighbors(graph: mxGraph,
edge: mxCell,
source: mxCell,
target: mxCell): boolean {
const sourceValue = source.getValue();
const targetValue = target.getValue();
let isValid = !this.validNeighborsAllowed;
@ -201,8 +200,9 @@ class mxMultiplicity {
* given cell is the source or target of the given edge, depending on
* {@link source}. This implementation uses {@link checkType} on the terminal's value.
*/
// checkTerminal(graph: mxGraph, terminal: mxCell, edge: mxCell): boolean;
checkTerminal(graph, terminal, edge) {
checkTerminal(graph: mxGraph,
edge: mxCell,
terminal: mxCell): boolean {
const value = terminal.getValue();
return this.checkType(graph, value, this.type, this.attr, this.value);
@ -211,10 +211,14 @@ class mxMultiplicity {
/**
* Checks the type of the given value.
*/
// checkType(graph: mxCell, value: string, type: string, attr: string, attrValue: any): boolean;
checkType(graph, value, type, attr, attrValue) {
checkType(graph: mxGraph,
value: string | Element | mxCell,
type: string,
attr?: string,
attrValue?: any): boolean {
if (value != null) {
if (!Number.isNaN(value.nodeType)) {
if (typeof value !== 'string' && 'nodeType' in value && !Number.isNaN(value.nodeType)) {
// Checks if value is a DOM node
return isNode(value, type, attr, attrValue);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@ import mxTerminalChange from '../../atomic_changes/mxTerminalChange';
import mxValueChange from '../../atomic_changes/mxValueChange';
import mxVisibleChange from '../../atomic_changes/mxVisibleChange';
import mxGeometry from "../../util/datatypes/mxGeometry";
import mxCells from "../cell/mxCells";
import mxCellArray from "../cell/mxCellArray";
/**
* Extends {@link mxEventSource} to implement a graph model. The graph model acts as
@ -337,24 +337,12 @@ class mxGraphModel extends mxEventSource {
return this.cells != null ? this.cells[id] : null;
}
filterCells(cells: mxCell[],
filter: Function): mxCell[] | null {
return new mxCells(...cells).filterCells(filter);
}
getDescendants(parent: mxCell): mxCell[] {
// SLATED FOR DELETION
return parent.getDescendants();
}
filterDescendants(filter: Function | null,
parent: mxCell): mxCell[] {
// SLATED FOR DELETION
return parent.filterDescendants(filter);
filterCells(cells: mxCellArray,
filter: Function): mxCellArray | null {
return new mxCellArray(...cells).filterCells(filter);
}
getRoot(cell: mxCell | null = null): mxCell | null {
// SLATED FOR DELETION
return cell ? cell.getRoot() : this.root;
}
@ -420,12 +408,6 @@ class mxGraphModel extends mxEventSource {
return this.isRoot(cell.getParent());
}
isAncestor(parent: mxCell | null,
child: mxCell | null): boolean {
// SLATED FOR DELETION
return parent?.isAncestor(child) || false;
}
/**
* Returns true if the model contains the given {@link mxCell}.
*
@ -433,18 +415,7 @@ class mxGraphModel extends mxEventSource {
*/
// contains(cell: mxCell): boolean;
contains(cell: mxCell): boolean {
return this.isAncestor(<mxCell>this.root, cell);
}
/**
* Returns the parent of the given cell.
*
* @param {mxCell} cell whose parent should be returned.
*/
// getParent(cell: mxCell): mxCell;
getParent(cell: mxCell): mxCell | null {
// SLATED FOR DELETION
return cell.getParent();
return (<mxCell>this.root).isAncestor(cell);
}
/**
@ -585,7 +556,7 @@ class mxGraphModel extends mxEventSource {
// Updates edge parent if edge and child have
// a common root node (does not need to be the
// model root node)
if (this.isAncestor(root, edge)) {
if (root.isAncestor(edge)) {
this.updateEdgeParent(edge, root);
}
}
@ -627,23 +598,23 @@ class mxGraphModel extends mxEventSource {
target = target.getParent();
}
if (this.isAncestor(root, source) && this.isAncestor(root, target)) {
if (root.isAncestor(source) && root.isAncestor(target)) {
if (source === target) {
cell = source ? source.getParent() : null;
} else if (source) {
cell = source.getNearestCommonAncestor(target);
cell = source.getNearestCommonAncestor(<mxCell>target);
}
if (
cell != null &&
(cell.getParent() !== this.root || this.isAncestor(cell, edge)) &&
(cell.getParent() !== this.root || cell.isAncestor(edge)) &&
edge && edge.getParent() !== cell
) {
let geo = edge.getGeometry();
if (geo != null) {
const origin1 = this.getOrigin(<mxCell>edge.getParent());
const origin2 = this.getOrigin(cell);
const origin1 = (<mxCell>edge.getParent()).getOrigin();
const origin2 = cell.getOrigin();
const dx = origin2.x - origin1.x;
const dy = origin2.y - origin1.y;
@ -658,17 +629,6 @@ class mxGraphModel extends mxEventSource {
}
}
getOrigin(cell: mxCell): mxPoint {
// SLATED FOR DELETION
return cell.getOrigin();
}
getNearestCommonAncestor(cell1: mxCell,
cell2: mxCell): mxCell | null {
// SLATED FOR DELETION
return cell1.getNearestCommonAncestor(cell2);
}
/**
* Removes the specified cell from the model using {@link mxChildChange} and adds
* the change to the current transaction. This operation will remove the
@ -746,73 +706,6 @@ class mxGraphModel extends mxEventSource {
return previous;
}
/**
* Returns the number of children in the given cell.
*
* @param {mxCell} cell whose number of children should be returned.
*/
// getChildCount(cell?: mxCell): number;
getChildCount(cell: mxCell) {
// SLATED FOR DELETION
return cell.getChildCount();
}
/**
* Returns the child of the given {@link mxCell} at the given index.
*
* @param {mxCell} cell that represents the parent.
* @param index Integer that specifies the index of the child to be returned.
*/
// getChildAt(cell: mxCell, index: number): mxCell;
getChildAt(cell: mxCell,
index: number): mxCell | null {
// SLATED FOR DELETION
return cell.getChildAt(index);
}
/**
* Returns all children of the given {@link mxCell} as an array of {@link mxCell}. The
* return value should be only be read.
*
* @param {mxCell} cell the represents the parent.
*/
// getChildren(cell: mxCell): Array<mxCell>;
getChildren(cell: mxCell): mxCell[] {
// SLATED FOR DELETION
return cell.children || [];
}
getChildVertices(parent: mxCell) {
// SLATED FOR DELETION
return parent.getChildVertices();
}
getChildEdges(parent: mxCell): mxCell[] {
// SLATED FOR DELETION
return parent.getChildEdges();
}
getChildCells(parent: mxCell,
vertices: boolean=false,
edges: boolean=false): mxCell[] {
// SLATED FOR DELETION
return parent.getChildCells(vertices, edges);
}
/**
* Returns the source or target {@link mxCell} of the given edge depending on the
* value of the boolean parameter.
*
* @param {mxCell} edge that specifies the edge.
* @param isSource Boolean indicating which end of the edge should be returned.
*/
// getTerminal(edge: mxCell, isSource: boolean): mxCell;
getTerminal(edge: mxCell,
isSource: boolean=false): mxCell | null {
// SLATED FOR DELETION
return edge.getTerminal(isSource);
}
/**
* Sets the source or target terminal of the given {@link mxCell} using
* {@link mxTerminalChange} and adds the change to the current transaction.
@ -883,61 +776,6 @@ class mxGraphModel extends mxEventSource {
return previous;
}
/**
* Returns the number of distinct edges connected to the given cell.
*
* @param {mxCell} cell that represents the vertex.
*/
// getEdgeCount(cell: mxCell): number;
getEdgeCount(cell: mxCell): number {
// SLATED FOR DELETION
return cell.getEdgeCount();
}
/**
* Returns the edge of cell at the given index.
*
* @param {mxCell} cell that specifies the vertex.
* @param index Integer that specifies the index of the edge
* to return.
*/
// getEdgeAt(cell: mxCell, index: number): mxCell;
getEdgeAt(cell: mxCell,
index: number): mxCell | null {
// SLATED FOR DELETION
return cell.getEdgeAt(index);
}
getDirectedEdgeCount(cell: mxCell,
outgoing: boolean,
ignoredEdge: mxCell | null=null): number {
// SLATED FOR DELETION
return cell.getDirectedEdgeCount(outgoing, ignoredEdge)
}
getConnections(cell: mxCell) {
// SLATED FOR DELETION
return cell.getConnections();
}
getIncomingEdges(cell: mxCell): mxCell[] {
// SLATED FOR DELETION
return cell.getIncomingEdges();
}
getOutgoingEdges(cell: mxCell): mxCell[] {
// SLATED FOR DELETION
return cell.getOutgoingEdges();
}
getEdges(cell: mxCell,
incoming: boolean=true,
outgoing: boolean=true,
includeLoops: boolean=true) {
// SLATED FOR DELETION
return cell.getEdges(incoming, outgoing, includeLoops);
}
/**
* Returns all edges between the given source and target pair. If directed
* is true, then only edges from the source to the target are returned,
@ -950,10 +788,9 @@ class mxGraphModel extends mxEventSource {
* @param directed Optional boolean that specifies if the direction of the
* edge should be taken into account. Default is false.
*/
// getEdgesBetween(source: mxCell, target: mxCell, directed?: boolean): Array<mxCell>;
getEdgesBetween(source: mxCell,
target: mxCell,
directed: boolean=false) {
directed: boolean=false): mxCellArray {
const tmp1 = source.getEdgeCount();
const tmp2 = target.getEdgeCount();
@ -969,7 +806,7 @@ class mxGraphModel extends mxEventSource {
terminal = target;
}
const result = [];
const result = new mxCellArray();
// Checks if the edge is connected to the correct
// cell and returns the first match
@ -987,65 +824,6 @@ class mxGraphModel extends mxEventSource {
return result;
}
getOpposites(edges: mxCell[],
terminal: mxCell,
sources: boolean=true,
targets: boolean=true): mxCell[] {
// SLATED FOR DELETION
return new mxCells(...edges).getOpposites(terminal, sources, targets);
}
getTopmostCells(cells: mxCell[]): mxCell[] {
// SLATED FOR DELETION
return new mxCells(...cells).getTopmostCells();
}
/**
* Returns true if the given cell is a vertex.
*
* @param {mxCell} cell that represents the possible vertex.
*/
// isVertex(cell: mxCell): boolean;
isVertex(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isVertex();
}
/**
* Returns true if the given cell is an edge.
*
* @param {mxCell} cell that represents the possible edge.
*/
// isEdge(cell: mxCell): boolean;
isEdge(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isEdge();
}
/**
* Returns true if the given {@link mxCell} is connectable. If {@link edgesConnectable}
* is false, then this function returns false for all edges else it returns
* the return value of <mxCell.isConnectable>.
*
* @param {mxCell} cell whose connectable state should be returned.
*/
// isConnectable(cell: mxCell): boolean;
isConnectable(cell: mxCell) {
// SLATED FOR DELECTION
return cell.isConnectable();
}
/**
* Returns the user object of the given {@link mxCell} using <mxCell.getValue>.
*
* @param {mxCell} cell whose user object should be returned.
*/
// getValue(cell: mxCell): any;
getValue(cell: mxCell) {
// SLATED FOR DELETION
return cell.getValue();
}
/**
* Sets the user object of then given {@link mxCell} using {@link mxValueChange}
* and adds the change to the current transaction.
@ -1053,7 +831,6 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose user object should be changed.
* @param value Object that defines the new user object.
*/
// setValue(cell: mxCell, value: any): any;
setValue(cell: mxCell,
value: any): any {
this.execute(new mxValueChange(this, cell, value));
@ -1078,23 +855,11 @@ class mxGraphModel extends mxEventSource {
* };
* ```
*/
// valueForCellChanged(cell: mxCell, value: any): any;
valueForCellChanged(cell: mxCell,
value: any): any {
return cell.valueChanged(value);
}
/**
* Returns the {@link mxGeometry} of the given {@link mxCell}.
*
* @param {mxCell} cell whose geometry should be returned.
*/
// getGeometry(cell: mxCell): mxGeometry;
getGeometry(cell: mxCell): mxGeometry | null {
// SLATED FOR DELETION
return cell.getGeometry();
}
/**
* Sets the {@link mxGeometry} of the given {@link mxCell}. The actual update
* of the cell is carried out in {@link geometryForCellChanged}. The
@ -1103,7 +868,6 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose geometry should be changed.
* @param {mxGeometry} geometry that defines the new geometry.
*/
// setGeometry(cell: mxCell, geometry: mxGeometry): mxGeometry;
setGeometry(cell: mxCell,
geometry: mxGeometry): mxGeometry {
@ -1117,7 +881,6 @@ class mxGraphModel extends mxEventSource {
* Inner callback to update the {@link mxGeometry} of the given {@link mxCell} using
* <mxCell.setGeometry> and return the previous {@link mxGeometry}.
*/
// geometryForCellChanged(cell: mxCell, geometry: mxGeometry): mxGeometry;
geometryForCellChanged(cell: mxCell,
geometry: mxGeometry): mxGeometry | null {
@ -1126,17 +889,6 @@ class mxGraphModel extends mxEventSource {
return previous;
}
/**
* Returns the style of the given {@link mxCell}.
*
* @param {mxCell} cell whose style should be returned.
*/
// getStyle(cell: mxCell): string | null;
getStyle(cell: mxCell | null): any {
// SLATED FOR DELETION
return cell != null ? cell.getStyle() : null;
}
/**
* Sets the style of the given {@link mxCell} using {@link mxStyleChange} and
* adds the change to the current transaction.
@ -1165,24 +917,13 @@ class mxGraphModel extends mxEventSource {
*/
// styleForCellChanged(cell: mxCell, style: string): string;
styleForCellChanged(cell: mxCell,
style: any): mxCell | null {
style: string): string | null {
const previous = cell.getStyle();
cell.setStyle(style);
return previous;
}
/**
* Returns true if the given {@link mxCell} is collapsed.
*
* @param {mxCell} cell whose collapsed state should be returned.
*/
// isCollapsed(cell: mxCell): boolean;
isCollapsed(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isCollapsed();
}
/**
* Sets the collapsed state of the given {@link mxCell} using {@link mxCollapseChange}
* and adds the change to the current transaction.
@ -1190,7 +931,6 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose collapsed state should be changed.
* @param collapsed Boolean that specifies the new collpased state.
*/
// setCollapsed(cell: mxCell, collapsed: boolean): boolean;
setCollapsed(cell: mxCell,
collapsed: boolean): boolean {
@ -1208,7 +948,6 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell that specifies the cell to be updated.
* @param collapsed Boolean that specifies the new collpased state.
*/
// collapsedStateForCellChanged(cell: mxCell, collapsed: boolean): boolean;
collapsedStateForCellChanged(cell: mxCell,
collapsed: boolean): boolean {
@ -1217,17 +956,6 @@ class mxGraphModel extends mxEventSource {
return previous;
}
/**
* Returns true if the given {@link mxCell} is visible.
*
* @param {mxCell} cell whose visible state should be returned.
*/
// isVisible(cell: mxCell): boolean;
isVisible(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isVisible();
}
/**
* Sets the visible state of the given {@link mxCell} using {@link mxVisibleChange} and
* adds the change to the current transaction.
@ -1496,11 +1224,6 @@ class mxGraphModel extends mxEventSource {
}
}
getParents(cells: mxCell[]): mxCell[] {
// SLATED FOR DELETION
return new mxCells(...cells).getParents();
}
//
// Cell Cloning
//
@ -1515,27 +1238,10 @@ class mxGraphModel extends mxEventSource {
cloneCell(cell: mxCell | null,
includeChildren: boolean): mxCell | null {
if (cell != null) {
return this.cloneCells([cell], includeChildren)[0];
return new mxCellArray(cell).cloneCells(includeChildren)[0];
}
return null;
}
cloneCells(cells: mxCell[],
includeChildren: boolean=true,
mapping: any={}): mxCell[] {
// SLATED FOR DELETION
return new mxCells(...cells).cloneCells(includeChildren, mapping)
}
/**
* Hook for cloning the cell. This returns cell.clone() or
* any possible exceptions.
*/
// cellCloned(cell: mxCell): mxCell;
cellCloned(cell: mxCell): mxCell {
// SLATED FOR DELETION
return cell.clone();
}
}
//

View File

@ -13,6 +13,7 @@ import mxSelectionChange from '../../atomic_changes/mxSelectionChange';
import mxEvent from '../../util/event/mxEvent';
import mxCell from '../cell/mxCell';
import mxGraph from './mxGraph';
import mxCellArray from "../cell/mxCellArray";
/**
* @class mxGraphSelectionModel
@ -51,18 +52,17 @@ class mxGraphSelectionModel extends mxEventSource {
super();
this.graph = graph;
this.cells = [];
this.cells = new mxCellArray();
}
// TODO: Document me!!
cells: mxCell[];
cells: mxCellArray;
/**
* Specifies the resource key for the status message after a long operation.
* If the resource for this key does not exist then the value is used as
* the status message. Default is 'done'.
*/
// doneResource: 'done' | '';
doneResource: string = mxClient.language !== 'none' ? 'done' : '';
/**
@ -70,27 +70,23 @@ class mxGraphSelectionModel extends mxEventSource {
* being updated. If the resource for this key does not exist then the
* value is used as the status message. Default is 'updatingSelection'.
*/
// updatingSelectionResource: 'updatingSelection' | '';
updatingSelectionResource: string =
mxClient.language !== 'none' ? 'updatingSelection' : '';
/**
* Reference to the enclosing {@link mxGraph}.
*/
// graph: mxGraph;
graph: mxGraph | null = null;
/**
* Specifies if only one selected item at a time is allowed.
* Default is false.
*/
// singleSelection: boolean;
singleSelection: boolean = false;
/**
* Returns {@link singleSelection} as a boolean.
*/
// isSingleSelection(): boolean;
isSingleSelection(): boolean {
return this.singleSelection;
}
@ -101,7 +97,6 @@ class mxGraphSelectionModel extends mxEventSource {
* @param {boolean} singleSelection Boolean that specifies the new value for
* {@link singleSelection}.
*/
// setSingleSelection(singleSelection: boolean): void;
setSingleSelection(singleSelection: boolean): void {
this.singleSelection = singleSelection;
}
@ -109,7 +104,6 @@ class mxGraphSelectionModel extends mxEventSource {
/**
* Returns true if the given {@link mxCell} is selected.
*/
// isSelected(cell: mxCell): boolean;
isSelected(cell: mxCell): boolean {
if (cell != null) {
return this.cells.indexOf(cell) >= 0;
@ -120,7 +114,6 @@ class mxGraphSelectionModel extends mxEventSource {
/**
* Returns true if no cells are currently selected.
*/
// isEmpty(): boolean;
isEmpty(): boolean {
return this.cells.length === 0;
}
@ -129,7 +122,6 @@ class mxGraphSelectionModel extends mxEventSource {
* Clears the selection and fires a {@link change} event if the selection was not
* empty.
*/
// clear(): void;
clear(): void {
this.changeSelection(null, this.cells);
}
@ -139,10 +131,9 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cell {@link mxCell} to be selected.
*/
// setCell(cell: mxCell): void;
setCell(cell: mxCell | null): void {
if (cell != null) {
this.setCells([cell]);
this.setCells(new mxCellArray(cell));
}
}
@ -151,14 +142,13 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cells Array of {@link mxCell} to be selected.
*/
// setCells(cells: Array<mxCell>): void;
setCells(cells: mxCell[]): void {
setCells(cells: mxCellArray): void {
if (cells != null) {
if (this.singleSelection) {
cells = [<mxCell>this.getFirstSelectableCell(cells)];
cells = new mxCellArray(<mxCell>this.getFirstSelectableCell(cells));
}
const tmp = [];
const tmp = new mxCellArray();
for (let i = 0; i < cells.length; i += 1) {
if ((<mxGraph>this.graph).isCellSelectable(cells[i])) {
tmp.push(cells[i]);
@ -171,8 +161,7 @@ class mxGraphSelectionModel extends mxEventSource {
/**
* Returns the first selectable cell in the given array of cells.
*/
// getFirstSelectableCell(cells: Array<mxCell>): mxCell;
getFirstSelectableCell(cells: mxCell[]): mxCell | null {
getFirstSelectableCell(cells: mxCellArray): mxCell | null {
if (cells != null) {
for (let i = 0; i < cells.length; i += 1) {
if ((<mxGraph>this.graph).isCellSelectable(cells[i])) {
@ -188,10 +177,9 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cell {@link mxCell} to add to the selection.
*/
// addCell(cell: mxCell): void;
addCell(cell: mxCell | null = null): void {
if (cell != null) {
this.addCells([cell]);
this.addCells(new mxCellArray(cell));
}
}
@ -201,16 +189,15 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cells Array of {@link mxCell} to add to the selection.
*/
// addCells(cells: Array<mxCell>): void;
addCells(cells: mxCell[]): void {
addCells(cells: mxCellArray): void {
if (cells != null) {
let remove = null;
if (this.singleSelection) {
remove = this.cells;
cells = [<mxCell>this.getFirstSelectableCell(cells)];
cells = new mxCellArray(<mxCell>this.getFirstSelectableCell(cells));
}
const tmp = [];
const tmp = new mxCellArray();
for (let i = 0; i < cells.length; i += 1) {
if (
!this.isSelected(cells[i]) &&
@ -230,10 +217,9 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cell {@link mxCell} to remove from the selection.
*/
// removeCell(cell: mxCell): void;
removeCell(cell: mxCell | null = null): void {
if (cell != null) {
this.removeCells([cell]);
this.removeCells(new mxCellArray(cell));
}
}
@ -241,12 +227,11 @@ class mxGraphSelectionModel extends mxEventSource {
* Removes the specified {@link mxCell} from the selection and fires a {@link select}
* event for the remaining cells.
*
* @param cell {@link mxCell} to remove from the selection.
* @param cells {@link mxCell}s to remove from the selection.
*/
// removeCells(cells: Array<mxCell>): void;
removeCells(cells: mxCell[] | null = null): void {
removeCells(cells: mxCellArray | null = null): void {
if (cells != null) {
const tmp = [];
const tmp = new mxCellArray();
for (let i = 0; i < cells.length; i += 1) {
if (this.isSelected(cells[i])) {
tmp.push(cells[i]);
@ -262,14 +247,13 @@ class mxGraphSelectionModel extends mxEventSource {
* @param added Array of {@link mxCell} to add to the selection.
* @param remove Array of {@link mxCell} to remove from the selection.
*/
// changeSelection(added: Array<mxCell>, removed: Array<mxCell>): void;
changeSelection(added: mxCell[] | null=null,
removed: mxCell[] | null=null): void {
changeSelection(added: mxCellArray | null=null,
removed: mxCellArray | null=null): void {
if (
(added != null && added.length > 0 && added[0] != null) ||
(removed != null && removed.length > 0 && removed[0] != null)
) {
const change = new mxSelectionChange(this, added || [], removed || []);
const change = new mxSelectionChange(this, added || new mxCellArray(), removed || new mxCellArray());
change.execute();
const edit = new mxUndoableEdit(this, false);
edit.add(change);
@ -285,7 +269,6 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cell {@link mxCell} to add to the selection.
*/
// cellAdded(cell: mxCell): void;
cellAdded(cell: mxCell): void {
if (cell != null && !this.isSelected(cell)) {
this.cells.push(cell);
@ -298,7 +281,6 @@ class mxGraphSelectionModel extends mxEventSource {
*
* @param cell {@link mxCell} to remove from the selection.
*/
// cellRemoved(cell: mxCell): void;
cellRemoved(cell: mxCell): void {
if (cell != null) {
const index = this.cells.indexOf(cell);

View File

@ -45,6 +45,7 @@ import {
isConsumed,
} from '../../util/mxEventUtils';
import { clone } from '../../util/mxCloneUtils';
import mxCellArray from "../cell/mxCellArray";
/**
* @class mxGraphView
@ -378,8 +379,8 @@ class mxGraphView extends mxEventSource {
*
* @param cells Array of {@link mxCell} whose bounds should be returned.
*/
// getBounds(cells: mxCell[]): mxRectangle;
getBounds(cells: mxCell[]): mxRectangle | null {
// getBounds(cells: mxCellArray): mxRectangle;
getBounds(cells: mxCellArray): mxRectangle | null {
let result = null;
if (cells != null && cells.length > 0) {
@ -1042,17 +1043,6 @@ class mxGraphView extends mxEventSource {
state.updateCachedBounds();
}
/**
* Returns true if the children of the given cell should not be visible in the
* view. This implementation uses {@link mxCell.isCellVisible} but it can be
* overidden to use a separate condition.
*/
// isCellCollapsed(cell: mxCell): boolean;
isCellCollapsed(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isCollapsed();
}
/**
* Validates the given cell state.
*/
@ -2189,8 +2179,8 @@ class mxGraphView extends mxEventSource {
* have less elements than the given array. If no argument is given, then
* this returns {@link states}.
*/
// getCellStates(cells: mxCell[]): mxCellState[];
getCellStates(cells: mxCell[] | null): mxCellState[] | mxDictionary | null {
// getCellStates(cells: mxCellArray): mxCellState[];
getCellStates(cells: mxCellArray | null): mxCellState[] | mxDictionary | null {
if (cells == null) {
return this.states;
}

View File

@ -20,6 +20,7 @@ import mxGraph from './mxGraph';
import mxRectangle from '../../util/datatypes/mxRectangle';
import mxMouseEvent from "../../util/event/mxMouseEvent";
import { getClientX, getClientY } from '../../util/mxEventUtils';
import mxCellArray from "../cell/mxCellArray";
/**
* @class mxLayoutManager
@ -81,7 +82,6 @@ class mxLayoutManager extends mxEventSource {
/**
* Reference to the enclosing {@link mxGraph}.
*/
// graph: mxGraph;
graph: mxGraph | null = null;
/**
@ -89,40 +89,34 @@ class mxLayoutManager extends mxEventSource {
* the cell hierarchy.
* @default true
*/
// bubbling: boolean;
bubbling: boolean = true;
/**
* Specifies if event handling is enabled.
* @default true
*/
// enabled: boolean;
enabled: boolean = true;
/**
* Holds the function that handles the endUpdate event.
*/
// undoHandler: Function;
undoHandler: Function | null = null;
undoHandler: Function;
/**
* Holds the function that handles the move event.
*/
// moveHandler: Function;
moveHandler: Function | null = null;
moveHandler: Function;
/**
* Holds the function that handles the resize event.
*/
// resizeHandler: Function;
resizeHandler: Function | null = null;
resizeHandler: Function;
/**
* Returns true if events are handled. This implementation
* returns {@link enabled}.
*/
// isEnabled(): boolean;
isEnabled() {
isEnabled(): boolean {
return this.enabled;
}
@ -132,8 +126,7 @@ class mxLayoutManager extends mxEventSource {
*
* @param enabled Boolean that specifies the new enabled state.
*/
// setEnabled(enabled: boolean): void;
setEnabled(enabled: boolean) {
setEnabled(enabled: boolean): void {
this.enabled = enabled;
}
@ -142,7 +135,6 @@ class mxLayoutManager extends mxEventSource {
* should be executed whenever a cell layout (layout of the children of
* a cell) has been executed. This implementation returns {@link bubbling}.
*/
// isBubbling(): boolean;
isBubbling(): boolean {
return this.bubbling;
}
@ -150,7 +142,6 @@ class mxLayoutManager extends mxEventSource {
/**
* Sets {@link bubbling}.
*/
// setBubbling(value: boolean): void;
setBubbling(value: boolean): void {
this.bubbling = value;
}
@ -158,7 +149,6 @@ class mxLayoutManager extends mxEventSource {
/**
* Returns the graph that this layout operates on.
*/
// getGraph(): mxGraph;
getGraph(): mxGraph | null {
return this.graph;
}
@ -218,7 +208,6 @@ class mxLayoutManager extends mxEventSource {
*
* TODO: what is undoableEdit type?
*/
// beforeUndo(undoableEdit: any): void;
beforeUndo(undoableEdit: any): void {
this.executeLayoutForCells(this.getCellsForChanges(undoableEdit.changes));
}
@ -230,7 +219,7 @@ class mxLayoutManager extends mxEventSource {
* @param evt Mouse event that represents the mousedown.
*/
// cellsMoved(cells: Array<mxCell>, evt: MouseEvent): void;
cellsMoved(cells: mxCell[],
cellsMoved(cells: mxCellArray,
evt: mxMouseEvent): void {
if (cells != null && evt != null) {
@ -262,9 +251,9 @@ class mxLayoutManager extends mxEventSource {
*/
// cellsResized(cells: Array<mxCell>, bounds: Array<mxRectangle>, prev: Array<any>): void;
cellsResized(
cells: mxCell[] | null = null,
cells: mxCellArray | null = null,
bounds: mxRectangle[] | null = null,
prev: mxCell[] | null = null
prev: mxCellArray | null = null
): void {
if (cells != null && bounds != null) {
const model = (<mxGraph>this.getGraph()).getModel();
@ -284,12 +273,11 @@ class mxLayoutManager extends mxEventSource {
/**
* Returns the cells for which a layout should be executed.
*/
// getCellsForChanges(changes: Array<any>): Array<mxCell>;
getCellsForChanges(changes: any[]): mxCell[] {
let result: mxCell[] = [];
getCellsForChanges(changes: any[]): mxCellArray {
let result: mxCellArray = new mxCellArray();
for (const change of changes) {
if (change instanceof mxRootChange) {
return [];
return new mxCellArray();
}
result = result.concat(this.getCellsForChange(change));
}
@ -301,8 +289,7 @@ class mxLayoutManager extends mxEventSource {
* changes.
* @param change mxChildChange|mxTerminalChange|mxVisibleChange|...
*/
// getCellsForChange(change: any): Array<mxCell>;
getCellsForChange(change: any): mxCell[] {
getCellsForChange(change: any): mxCellArray {
if (change instanceof mxChildChange) {
return this.addCellsWithLayout(
change.child,
@ -321,14 +308,14 @@ class mxLayoutManager extends mxEventSource {
return this.addCellsWithLayout(change.cell);
}
return [];
return new mxCellArray();
}
/**
* Adds all ancestors of the given cell that have a layout.
*/
// addCellsWithLayout(cell: mxCell, result: Array<mxCell>): Array<mxCell>;
addCellsWithLayout(cell: mxCell, result: mxCell[] = []): mxCell[] {
addCellsWithLayout(cell: mxCell,
result: mxCellArray = new mxCellArray()): mxCellArray {
return this.addDescendantsWithLayout(
cell,
this.addAncestorsWithLayout(cell, result)
@ -338,8 +325,7 @@ class mxLayoutManager extends mxEventSource {
/**
* Adds all ancestors of the given cell that have a layout.
*/
// addAncestorsWithLayout(cell: mxCell, result: Array<mxCell>): Array<mxCell>;
addAncestorsWithLayout(cell: mxCell, result: mxCell[] = []): mxCell[] {
addAncestorsWithLayout(cell: mxCell, result: mxCellArray = new mxCellArray()): mxCellArray {
if (cell != null) {
const layout = this.hasLayout(cell);
@ -358,8 +344,8 @@ class mxLayoutManager extends mxEventSource {
/**
* Adds all descendants of the given cell that have a layout.
*/
// addDescendantsWithLayout(cell: mxCell, result: Array<mxCell>): Array<mxCell>;
addDescendantsWithLayout(cell: mxCell, result: mxCell[] = []): mxCell[] {
addDescendantsWithLayout(cell: mxCell,
result: mxCellArray = new mxCellArray()): mxCellArray {
if (cell != null && this.hasLayout(cell)) {
const model = (<mxGraph>this.getGraph()).getModel();
@ -378,8 +364,7 @@ class mxLayoutManager extends mxEventSource {
/**
* Executes the given layout on the given parent.
*/
// executeLayoutForCells(cells: Array<mxCell>): void;
executeLayoutForCells(cells: mxCell[]): void {
executeLayoutForCells(cells: mxCellArray): void {
const sorted = mxUtils.sortCells(cells, false);
this.layoutCells(sorted, true);
this.layoutCells(sorted.reverse(), false);
@ -388,8 +373,9 @@ class mxLayoutManager extends mxEventSource {
/**
* Executes all layouts which have been scheduled during the changes.
*/
// layoutCells(cells: Array<mxCell>, bubble: string): void;
layoutCells(cells: mxCell[], bubble: boolean = false): void {
layoutCells(cells: mxCellArray,
bubble: boolean = false): void {
if (cells.length > 0) {
// Invokes the layouts while removing duplicates
const model = (<mxGraph>this.getGraph()).getModel();
@ -415,7 +401,6 @@ class mxLayoutManager extends mxEventSource {
/**
* Executes the given layout on the given parent.
*/
// executeLayout(cell: mxCell, bubble: string): void;
executeLayout(cell: mxCell,
bubble: boolean=false): void {
const layout = this.getLayout(
@ -430,7 +415,6 @@ class mxLayoutManager extends mxEventSource {
/**
* Removes all handlers from the {@link graph} and deletes the reference to it.
*/
// destroy(): void;
destroy(): void {
this.setGraph(null);
}

View File

@ -22,6 +22,7 @@ import mxUtils from '../../util/mxUtils';
import mxImage from '../../util/image/mxImage';
import mxEventObject from '../../util/event/mxEventObject';
import { getSource, isMouseEvent } from '../../util/mxEventUtils';
import mxEventSource from "../../util/event/mxEventSource";
/**
* @class mxOutline
@ -81,8 +82,7 @@ class mxOutline {
/**
* Initializes the outline inside the given container.
*/
// init(container: HTMLElement): void;
init(container: HTMLElement) {
init(container: HTMLElement): void {
this.outline = this.createGraph(container);
// Do not repaint when suspended
@ -224,55 +224,47 @@ class mxOutline {
/**
* Reference to the source {@link mxGraph}.
*/
// source: mxGraph;
source: mxGraph;
/**
* Reference to the {@link mxGraph} that renders the outline.
*/
// outline: mxGraph;
outline: mxGraph | null = null;
/**
* Renderhint to be used for the outline graph.
* @default faster
*/
// graphRenderHint: string;
graphRenderHint: string = 'exact';
/**
* Specifies if events are handled.
* @default true
*/
// enabled: boolean;
enabled: boolean = true;
/**
* Specifies a viewport rectangle should be shown.
* @default true
*/
// showViewport: boolean;
showViewport: boolean = true;
/**
* Border to be added at the bottom and right.
* @default 10
*/
// border: number;
border: number = 10;
/**
* Specifies the size of the sizer handler.
* @default 8
*/
// sizerSize: number;
sizerSize: number = 8;
/**
* Specifies if labels should be visible in the outline.
* @default false
*/
// labelsVisible: boolean;
labelsVisible: boolean = false;
/**
@ -280,21 +272,18 @@ class mxOutline {
* graph.
* @default false
*/
// updateOnPan: boolean;
updateOnPan: boolean = false;
/**
* Optional {@link mxImage} to be used for the sizer.
* @default null
*/
// sizerImage: mxImage;
sizerImage: mxImage | null = null;
/**
* Minimum scale to be used.
* @default 0.0001
*/
// minScale: number;
minScale: number = 0.0001;
/**
@ -320,7 +309,6 @@ class mxOutline {
/**
* Creates the {@link mxGraph} used in the outline.
*/
// createGraph(container: HTMLElement): mxGraph;
createGraph(container: HTMLElement): mxGraph {
const graph = new mxGraph(
container,
@ -337,7 +325,6 @@ class mxOutline {
* Returns true if events are handled. This implementation
* returns {@link enabled}.
*/
// isEnabled(): boolean;
isEnabled(): boolean {
return this.enabled;
}
@ -348,7 +335,6 @@ class mxOutline {
*
* @param value Boolean that specifies the new enabled state.
*/
// setEnabled(value: boolean): void;
setEnabled(value: boolean): void {
this.enabled = value;
}
@ -359,7 +345,6 @@ class mxOutline {
*
* @param value Boolean that specifies the new enabled state.
*/
// setZoomEnabled(value: boolean): void;
setZoomEnabled(value: boolean): void {
// @ts-ignore
this.sizer.node.style.visibility = value ? 'visible' : 'hidden';
@ -368,7 +353,6 @@ class mxOutline {
/**
* Invokes {@link update} and revalidate the outline. This method is deprecated.
*/
// refresh(): void;
refresh(): void {
this.update(true);
}
@ -400,8 +384,7 @@ class mxOutline {
/**
* Returns the size of the source container.
*/
// getSourceContainerSize(): mxRectangle;
getSourceContainerSize() {
getSourceContainerSize(): mxRectangle {
return new mxRectangle(
0,
0,
@ -413,8 +396,7 @@ class mxOutline {
/**
* Returns the offset for drawing the outline graph.
*/
// getOutlineOffset(scale?: number): mxPoint;
getOutlineOffset(scale: number): mxPoint | null {
getOutlineOffset(scale?: number): mxPoint | null {
// TODO: Should number -> mxPoint?
return null;
}
@ -422,16 +404,14 @@ class mxOutline {
/**
* Returns the offset for drawing the outline graph.
*/
// getSourceGraphBounds(): mxRectangle;
getSourceGraphBounds() {
getSourceGraphBounds(): mxRectangle {
return this.source.getGraphBounds();
}
/**
* Updates the outline.
*/
// update(revalidate: boolean): void;
update(revalidate: boolean = false) {
update(revalidate: boolean = false): void {
if (
this.source != null &&
this.source.container != null &&
@ -583,8 +563,7 @@ class mxOutline {
/**
* Handles the event by starting a translation or zoom.
*/
// mouseDown(sender: mxEventSource, me: mxMouseEvent): void;
mouseDown(sender: any, me: mxMouseEvent) {
mouseDown(sender: mxEventSource, me: mxMouseEvent): void {
if (this.enabled && this.showViewport) {
const tol = !isMouseEvent(me.getEvent()) ? this.source.tolerance : 0;
const hit =
@ -624,8 +603,7 @@ class mxOutline {
* Handles the event by previewing the viewrect in {@link graph} and updating the
* rectangle that represents the viewrect in the outline.
*/
// mouseMove(sender: mxEventSource, me: mxMouseEvent): void;
mouseMove(sender: any, me: mxMouseEvent) {
mouseMove(sender: mxEventSource, me: mxMouseEvent): void {
if (this.active) {
const myBounds = <mxRectangle>this.bounds;
const sizer = <mxRectangleShape>this.sizer;
@ -713,8 +691,7 @@ class mxOutline {
* };
* ```
*/
// getTranslateForEvent(me: mxMouseEvent): mxPoint;
getTranslateForEvent(me: mxMouseEvent) {
getTranslateForEvent(me: mxMouseEvent): mxPoint {
return new mxPoint(
me.getX() - <number>this.startX,
me.getY() - <number>this.startY
@ -724,8 +701,7 @@ class mxOutline {
/**
* Handles the event by applying the translation or zoom to {@link graph}.
*/
// mouseUp(sender: mxEventSource, me: mxMouseEvent): void;
mouseUp(sender: any, me: mxMouseEvent) {
mouseUp(sender: mxEventSource, me: mxMouseEvent): void {
if (this.active) {
const delta = this.getTranslateForEvent(me);
let dx = delta.x;
@ -771,8 +747,7 @@ class mxOutline {
/**
* Destroy this outline and removes all listeners from {@link source}.
*/
// destroy(): void;
destroy() {
destroy(): void {
if (this.source != null) {
this.source.removeListener(this.panHandler);
this.source.removeListener(this.refreshHandler);

View File

@ -13,6 +13,7 @@ import mxGraph from './mxGraph';
import mxEventObject from '../../util/event/mxEventObject';
import mxCell from '../cell/mxCell';
import mxGeometry from '../../util/datatypes/mxGeometry';
import mxCellArray from "../cell/mxCellArray";
/**
* @class mxSwimlaneManager
@ -54,21 +55,18 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Reference to the enclosing {@link mxGraph}.
*/
// graph: mxGraph;
graph: mxGraph | null = null;
/**
* Specifies if event handling is enabled.
* @default true
*/
// enabled: boolean;
enabled: boolean = true;
/**
* Specifies the orientation of the swimlanes.
* @default true
*/
// horizontal: boolean;
horizontal: boolean = true;
/**
@ -76,33 +74,28 @@ class mxSwimlaneManager extends mxEventSource {
* existing siblings.
* @default true
*/
// addEnabled: boolean;
addEnabled: boolean = true;
/**
* Specifies if resizing of swimlanes should be handled.
* @default true
*/
// resizeEnabled: boolean;
resizeEnabled: boolean = true;
/**
* Holds the function that handles the move event.
*/
// addHandler: Function;
addHandler: Function | null = null;
/**
* Holds the function that handles the move event.
*/
// resizeHandler: Function;
resizeHandler: Function | null = null;
/**
* Returns true if events are handled. This implementation
* returns {@link enabled}.
*/
// isEnabled(): boolean;
isEnabled(): boolean {
return this.enabled;
}
@ -113,7 +106,6 @@ class mxSwimlaneManager extends mxEventSource {
*
* @param enabled Boolean that specifies the new enabled state.
*/
// setEnabled(value: boolean): void;
setEnabled(value: boolean): void {
this.enabled = value;
}
@ -121,7 +113,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Returns {@link horizontal}.
*/
// isHorizontal(): boolean;
isHorizontal(): boolean {
return this.horizontal;
}
@ -129,7 +120,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Sets {@link horizontal}.
*/
// setHorizontal(value: boolean): void;
setHorizontal(value: boolean): void {
this.horizontal = value;
}
@ -137,7 +127,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Returns {@link addEnabled}.
*/
// isAddEnabled(): boolean;
isAddEnabled(): boolean {
return this.addEnabled;
}
@ -145,7 +134,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Sets {@link addEnabled}.
*/
// setAddEnabled(value: boolean): void;
setAddEnabled(value: boolean): void {
this.addEnabled = value;
}
@ -153,7 +141,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Returns {@link resizeEnabled}.
*/
// isResizeEnabled(): boolean;
isResizeEnabled(): boolean {
return this.resizeEnabled;
}
@ -161,7 +148,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Sets {@link resizeEnabled}.
*/
// setResizeEnabled(value: boolean): void;
setResizeEnabled(value: boolean): void {
this.resizeEnabled = value;
}
@ -169,7 +155,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Returns the graph that this manager operates on.
*/
// getGraph(): mxGraph;
getGraph(): mxGraph | null {
return this.graph;
}
@ -177,7 +162,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Sets the graph that the manager operates on.
*/
// setGraph(graph: mxGraph): void;
setGraph(graph: mxGraph | null): void {
if (this.graph != null) {
this.graph.removeListener(this.addHandler);
@ -195,7 +179,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Returns true if the given swimlane should be ignored.
*/
// isSwimlaneIgnored(swimlane: mxCell): boolean;
isSwimlaneIgnored(swimlane: mxCell): boolean {
return !(<mxGraph>this.getGraph()).isSwimlane(swimlane);
}
@ -204,7 +187,6 @@ class mxSwimlaneManager extends mxEventSource {
* Returns true if the given cell is horizontal. If the given cell is not a
* swimlane, then the global orientation is returned.
*/
// isCellHorizontal(cell: mxCell): boolean;
isCellHorizontal(cell: mxCell): boolean {
if ((<mxGraph>this.graph).isSwimlane(cell)) {
const style = (<mxGraph>this.graph).getCellStyle(cell);
@ -218,8 +200,7 @@ class mxSwimlaneManager extends mxEventSource {
*
* @param cell Array of {@link mxCell} that have been added.
*/
// cellsAdded(cells: Array<mxCell>): void;
cellsAdded(cells: mxCell[]): void {
cellsAdded(cells: mxCellArray): void {
if (cells != null) {
const model = (<mxGraph>this.graph).getModel();
@ -274,8 +255,7 @@ class mxSwimlaneManager extends mxEventSource {
*
* @param cells Array of {@link mxCell} whose size was changed.
*/
// cellsResized(cells: Array<mxCell>): void;
cellsResized(cells: mxCell[] | null): void {
cellsResized(cells: mxCellArray | null): void {
if (cells != null) {
const model = (<mxGraph>this.getGraph()).getModel();
@ -327,7 +307,6 @@ class mxSwimlaneManager extends mxEventSource {
*
* @param swimlane {@link mxCell} whose size has changed.
*/
// resizeSwimlane(swimlane: mxCell, w: number, h: number, parentHorizontal: boolean): void;
resizeSwimlane(
swimlane: mxCell,
w: number,
@ -381,7 +360,6 @@ class mxSwimlaneManager extends mxEventSource {
/**
* Removes all handlers from the {@link graph} and deletes the reference to it.
*/
// destroy(): void;
destroy(): void {
this.setGraph(null);
}