refactor: run eslint and prettier on codebase

development
Anatoliy Mayorov 2022-10-29 22:53:09 +03:00
parent 41c5e468ed
commit 2ad1395aab
112 changed files with 1113 additions and 1024 deletions

View File

@ -147,15 +147,13 @@ class Client {
* True if the current browser is Safari.
*/
static IS_SF =
typeof window !== 'undefined' &&
/Apple Computer, Inc/.test(navigator.vendor);
typeof window !== 'undefined' && /Apple Computer, Inc/.test(navigator.vendor);
/**
* Returns true if the user agent contains Android.
*/
static IS_ANDROID =
typeof window !== 'undefined' &&
navigator.appVersion.indexOf('Android') >= 0;
typeof window !== 'undefined' && navigator.appVersion.indexOf('Android') >= 0;
/**
* Returns true if the user agent is an iPad, iPhone or iPod.
@ -217,10 +215,9 @@ class Client {
static NO_FO =
typeof window !== 'undefined' &&
(!document.createElementNS ||
document.createElementNS(
'http://www.w3.org/2000/svg',
'foreignObject'
).toString() !== '[object SVGForeignObjectElement]' ||
document
.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')
.toString() !== '[object SVGForeignObjectElement]' ||
navigator.userAgent.indexOf('Opera/') >= 0);
/**
@ -280,7 +277,6 @@ class Client {
static isBrowserSupported = () => {
return Client.IS_SVG;
};
}
export default Client;

View File

@ -454,7 +454,7 @@ export class Editor extends EventSource {
rubberband: RubberBandHandler | null = null;
isActive: boolean | null = null;
properties: any;
destroyed: boolean = false;
destroyed = false;
/**
* Specifies the resource key for the zoom dialog. If the resource for this
@ -604,14 +604,14 @@ export class Editor extends EventSource {
* top-level cells. Default is false.
* @default false
*/
swimlaneRequired: boolean = false;
swimlaneRequired = false;
/**
* Specifies if the context menu should be disabled in the graph container.
* Default is true.
* @default true
*/
disableContextMenu: boolean = true;
disableContextMenu = true;
/**
* Specifies the function to be used for inserting new
@ -630,7 +630,7 @@ export class Editor extends EventSource {
* mousepointer is selected. Default is false.
* @default false
*/
forcedInserting: boolean = false;
forcedInserting = false;
/**
* Maps from names to protoype cells to be used
@ -689,7 +689,7 @@ export class Editor extends EventSource {
* should be converted using encodeURIComponent. Default is true.
* @default true
*/
escapePostData: boolean = true;
escapePostData = true;
/**
* Specifies the URL to be used for posting the diagram
@ -712,7 +712,7 @@ export class Editor extends EventSource {
* ie. vertical flow.
* @default false
*/
horizontalFlow: boolean = false;
horizontalFlow = false;
/**
* Group: Autolayout
@ -730,7 +730,7 @@ export class Editor extends EventSource {
* the {@link layoutSwimlanes} switch.
* @default false
*/
layoutDiagram: boolean = false;
layoutDiagram = false;
/**
* Specifies the spacing between swimlanes if
@ -738,7 +738,7 @@ export class Editor extends EventSource {
* {@link layoutDiagram}. Default is 0.
* @default 0
*/
swimlaneSpacing: number = 0;
swimlaneSpacing = 0;
/**
* Specifies if the swimlanes should be kept at the same
@ -751,7 +751,7 @@ export class Editor extends EventSource {
* automatically "stacked" if {@link layoutDiagram} is true.
* @default false
*/
maintainSwimlanes: boolean = false;
maintainSwimlanes = false;
/**
* Specifies if the children of swimlanes should
@ -759,7 +759,7 @@ export class Editor extends EventSource {
* depending on {@link horizontalFlow}. Default is false.
* @default false
*/
layoutSwimlanes: boolean = false;
layoutSwimlanes = false;
/**
* Specifies the attribute values to be cycled when inserting new swimlanes.
@ -778,7 +778,7 @@ export class Editor extends EventSource {
* {@link cycleAttributeName}. Default is 0.
* @default 0
*/
cycleAttributeIndex: number = 0;
cycleAttributeIndex = 0;
/**
* Name of the attribute to be assigned a {@link cycleAttributeValues}
@ -805,7 +805,7 @@ export class Editor extends EventSource {
* Specifies the top coordinate of the tasks window in pixels. Default is 20.
* @default 20
*/
tasksTop: number = 20;
tasksTop = 20;
/**
* Holds the {@link MaxWindow} created in {@link showHelp}
@ -829,20 +829,20 @@ export class Editor extends EventSource {
* Specifies the width of the help window in pixels. Default is 300.
* @default 300
*/
helpWidth: number = 300;
helpWidth = 300;
/**
* Specifies the height of the help window in pixels. Default is 260.
* @default 260
*/
// helpHeight: number;
helpHeight: number = 260;
helpHeight = 260;
/**
* Specifies the width of the properties window in pixels. Default is 240.
* @default 240
*/
propertiesWidth: number = 240;
propertiesWidth = 240;
/**
* Specifies the height of the properties window in pixels.
@ -859,19 +859,19 @@ export class Editor extends EventSource {
* account if the dialog is already visible. Default is false.
* @default false
*/
movePropertiesDialog: boolean = false;
movePropertiesDialog = false;
/**
* Specifies if <{@link xGraph.validateGraph} should automatically be invoked after
* each change. Default is false.
* @default false
*/
validating: boolean = false;
validating = false;
/**
* True if the graph has been modified since it was last saved.
*/
modified: boolean = false;
modified = false;
/**
* Returns {@link modified}.

View File

@ -42,10 +42,10 @@ import Codec from '../serialization/Codec';
* An {@link InternalEvent.ESCAPE} event is fired via the editor if the escape key is pressed.
*/
export class EditorKeyHandler {
constructor(editor: Editor | null=null) {
constructor(editor: Editor | null = null) {
if (editor != null) {
this.editor = editor;
const handler = this.handler = new KeyHandler(editor.graph);
const handler = (this.handler = new KeyHandler(editor.graph));
// Extends the escape function of the internal key
// handle to hide the properties dialog and fire

View File

@ -35,7 +35,7 @@ import { PopupMenuItem } from '../types';
* This class uses the {@link DefaultPopupMenuCodec} to read configuration data into an existing instance, however, the actual parsing is done by this class during program execution, so the format is described below.
*/
export class EditorPopupMenu {
constructor(config: Element | null=null) {
constructor(config: Element | null = null) {
this.config = config;
}
@ -147,7 +147,12 @@ export class EditorPopupMenu {
* @param cell - Optional {@link mxCell} which is under the mousepointer.
* @param evt - Optional mouse event which triggered the menu.
*/
createMenu(editor: Editor, menu: MaxPopupMenu, cell: Cell | null=null, evt: MouseEvent | null=null) {
createMenu(
editor: Editor,
menu: MaxPopupMenu,
cell: Cell | null = null,
evt: MouseEvent | null = null
) {
if (this.config != null) {
const conditions = this.createConditions(editor, cell, evt);
const item = <Element>this.config.firstChild;
@ -169,11 +174,11 @@ export class EditorPopupMenu {
addItems(
editor: Editor,
menu: MaxPopupMenu,
cell: Cell | null=null,
evt: MouseEvent | null=null,
cell: Cell | null = null,
evt: MouseEvent | null = null,
conditions: any,
item: Element,
parent: PopupMenuItem | null=null
parent: PopupMenuItem | null = null
) {
let addSeparator = false;
@ -184,7 +189,7 @@ export class EditorPopupMenu {
if (condition == null || conditions[condition]) {
let as = <string>item.getAttribute('as');
as = Translations.get(as) || as;
const funct = eval(getTextContent(<Text><unknown>item));
const funct = eval(getTextContent(<Text>(<unknown>item)));
const action = item.getAttribute('action');
let icon = item.getAttribute('icon');
const iconCls = item.getAttribute('iconCls');
@ -253,13 +258,13 @@ export class EditorPopupMenu {
menu: MaxPopupMenu,
editor: Editor,
lab: string,
icon: string | null=null,
funct: Function | null=null,
action: string | null=null,
cell: Cell | null=null,
parent: PopupMenuItem | null=null,
iconCls: string | null=null,
enabled: boolean=true
icon: string | null = null,
funct: Function | null = null,
action: string | null = null,
cell: Cell | null = null,
parent: PopupMenuItem | null = null,
iconCls: string | null = null,
enabled = true
) {
const clickHandler = (evt: MouseEvent) => {
if (typeof funct === 'function') {
@ -279,7 +284,11 @@ export class EditorPopupMenu {
* @param cell
* @param evt
*/
createConditions(editor: Editor, cell: Cell | null=null, evt: MouseEvent | null=null): void {
createConditions(
editor: Editor,
cell: Cell | null = null,
evt: MouseEvent | null = null
): void {
// Creates array with conditions
const model = editor.graph.getDataModel();
const childCount = cell ? cell.getChildCount() : 0;
@ -288,8 +297,7 @@ export class EditorPopupMenu {
const conditions: any = {};
conditions.nocell = cell == null;
conditions.ncells = editor.graph.getSelectionCount() > 1;
conditions.notRoot =
model.getRoot() !== editor.graph.getDefaultParent().getParent();
conditions.notRoot = model.getRoot() !== editor.graph.getDefaultParent().getParent();
conditions.cell = cell != null;
const isCell = cell != null && editor.graph.getSelectionCount() === 1;
@ -304,7 +312,7 @@ export class EditorPopupMenu {
const condNodes = (<Element>this.config).getElementsByTagName('condition');
for (let i = 0; i < condNodes.length; i += 1) {
const funct = eval(getTextContent(<Text><unknown>condNodes[i]));
const funct = eval(getTextContent(<Text>(<unknown>condNodes[i])));
const name = condNodes[i].getAttribute('name');
if (name != null && typeof funct === 'function') {

View File

@ -89,14 +89,14 @@ export class EditorToolbar {
*
* @Default is 4
*/
spacing: number = 4;
spacing = 4;
/**
* Specifies if elements should be connected if new cells are dropped onto connectable elements.
*
* @Default is false.
*/
connectOnDrop: boolean = false;
connectOnDrop = false;
/**
* Constructs the {@link toolbar} for the given container and installs a listener that updates the {@link Editor.insertFunction} on {@link editor} if an item is selected in the toolbar. This assumes that {@link editor} is not null.
@ -268,7 +268,7 @@ export class EditorToolbar {
me: MouseEvent,
cellUnderMousePointer?: Cell | null
) => void,
toggle: boolean = true
toggle = true
): HTMLImageElement | HTMLButtonElement {
// Creates a wrapper function that is in charge of constructing
// the new cell instance to be inserted into the graph

View File

@ -18,8 +18,8 @@ limitations under the License.
import Client from '../Client';
import InternalEvent from '../view/event/InternalEvent';
import { write, writeln } from "../util/domUtils";
import Translations from "../util/Translations";
import { write, writeln } from '../util/domUtils';
import Translations from '../util/Translations';
/**
* A simple class for creating HTML forms.
@ -88,7 +88,7 @@ class MaxForm {
/**
* Adds an input for the given name, type and value and returns it.
*/
addText(name: string, value: any, type: string='text'): HTMLInputElement {
addText(name: string, value: any, type = 'text'): HTMLInputElement {
const input = document.createElement('input');
input.setAttribute('type', type);
input.value = value;

View File

@ -160,7 +160,10 @@ class MaxLog {
const elt = MaxLog.window.getElement();
const resizeHandler = (sender: any, evt: MouseEvent) => {
(<HTMLTextAreaElement>MaxLog.textarea).style.height = `${Math.max(0, elt.offsetHeight - 70)}px`;
(<HTMLTextAreaElement>MaxLog.textarea).style.height = `${Math.max(
0,
elt.offsetHeight - 70
)}px`;
};
MaxLog.window.addListener(InternalEvent.RESIZE_END, resizeHandler);

View File

@ -393,7 +393,7 @@ class MaxPopupMenu extends EventSource implements Partial<PopupMenuItem> {
* @param parent Optional item returned by <addItem>.
* @param force Optional boolean to ignore <smartSeparators>. Default is false.
*/
addSeparator(parent: PopupMenuItem | null=null, force = false) {
addSeparator(parent: PopupMenuItem | null = null, force = false) {
// Defaults to this instance if no parent (submenu) specified, but
// all the necessary DOM elements are present as in PopupMenuItem
parent = <PopupMenuItem>(parent || this);

View File

@ -28,12 +28,12 @@ import { KeyboardEventListener, MouseEventListener, PopupMenuItem } from '../typ
interface HTMLSelectOptionWithFunct extends HTMLOptionElement {
funct?: (evt: any) => void;
};
}
interface HTMLImageElementWithProps extends HTMLImageElement {
initialClassName?: any;
altIcon?: any;
};
}
/**
* Creates a toolbar inside a given DOM node. The toolbar may contain icons,
@ -67,7 +67,7 @@ class MaxToolbar extends EventSource {
/**
* Specifies if events are handled. Default is true.
*/
enabled: boolean = true;
enabled = true;
/**
* Specifies if <resetMode> requires a forced flag of true for resetting
@ -75,7 +75,7 @@ class MaxToolbar extends EventSource {
* if the toolbar item is double clicked to avoid a reset after a single
* use of the item.
*/
noReset: boolean = false;
noReset = false;
/**
* Boolean indicating if the default mode should be the last selected
@ -86,7 +86,7 @@ class MaxToolbar extends EventSource {
* of what was last selected. Otherwise, the selected item after a reset is
* the previously selected item.
*/
updateDefaultMode: boolean = true;
updateDefaultMode = true;
/**
* Adds the given function as an image with the specified title and icon
@ -103,13 +103,15 @@ class MaxToolbar extends EventSource {
* (menu, evt, cell)=> { menu.addItem('Hello, World!'); }
*/
addItem(
title: string | null=null,
icon: string | null=null,
funct: MouseEventListener | KeyboardEventListener | null=null,
pressedIcon: string | null=null,
style: string | null=null,
factoryMethod: ((handler: PopupMenuItem, cell: Cell | null, me: MouseEvent) => void) | null=null)
{
title: string | null = null,
icon: string | null = null,
funct: MouseEventListener | KeyboardEventListener | null = null,
pressedIcon: string | null = null,
style: string | null = null,
factoryMethod:
| ((handler: PopupMenuItem, cell: Cell | null, me: MouseEvent) => void)
| null = null
) {
const img = document.createElement(icon != null ? 'img' : 'button');
const initialClassName =
style || (factoryMethod != null ? 'mxToolbarMode' : 'mxToolbarItem');
@ -254,7 +256,11 @@ class MaxToolbar extends EventSource {
* @param title - String that specifies the title of the option.
* @param value - Specifies the value associated with this option.
*/
addOption(combo: HTMLSelectElement, title: string, value: string | ((evt: any) => void) | null = null): HTMLOptionElement {
addOption(
combo: HTMLSelectElement,
title: string,
value: string | ((evt: any) => void) | null = null
): HTMLOptionElement {
const option = <HTMLSelectOptionWithFunct>document.createElement('option');
writeln(option, title);
@ -274,10 +280,11 @@ class MaxToolbar extends EventSource {
* after a reset of the toolbar.
*/
addSwitchMode(
title: string,
icon: string, funct: () => void,
pressedIcon: string | null=null,
style: string='mxToolbarMode'
title: string,
icon: string,
funct: () => void,
pressedIcon: string | null = null,
style = 'mxToolbarMode'
) {
const img = <HTMLImageElementWithProps>document.createElement('img');
img.initialClassName = style;
@ -341,15 +348,17 @@ class MaxToolbar extends EventSource {
* evt is the native mouse event and cell is the cell under the mouse.
*/
addMode(
title: string | null=null,
icon: string | null=null,
title: string | null = null,
icon: string | null = null,
funct: Function,
pressedIcon: string,
style: string | null=null,
toggle: boolean=false
style: string | null = null,
toggle = false
) {
toggle = toggle != null ? toggle : true;
const img = <HTMLImageElementWithProps>document.createElement(icon != null ? 'img' : 'button');
const img = <HTMLImageElementWithProps>(
document.createElement(icon != null ? 'img' : 'button')
);
img.initialClassName = style || 'mxToolbarMode';
img.className = img.initialClassName;
@ -389,7 +398,7 @@ class MaxToolbar extends EventSource {
* DOM node as selected. This function fires a select event with the given
* function as a parameter.
*/
selectMode(domNode: HTMLImageElement, funct: Function | null=null): void {
selectMode(domNode: HTMLImageElement, funct: Function | null = null): void {
if (this.selectedMode != domNode) {
if (this.selectedMode != null) {
const tmp = this.selectedMode.altIcon;
@ -420,7 +429,7 @@ class MaxToolbar extends EventSource {
* Selects the default mode and resets the state of the previously selected
* mode.
*/
resetMode(forced: boolean=false): void {
resetMode(forced = false): void {
if ((forced || !this.noReset) && this.selectedMode != this.defaultMode) {
// The last selected switch mode will be activated
// so the function was already executed and is

View File

@ -183,12 +183,12 @@ class MaxWindow extends EventSource {
content: HTMLElement | null,
x: number,
y: number,
width: number | null=null,
height: number | null=null,
minimizable: boolean=true,
movable: boolean=true,
replaceNode: HTMLElement | null=null,
style: string=''
width: number | null = null,
height: number | null = null,
minimizable = true,
movable = true,
replaceNode: HTMLElement | null = null,
style = ''
) {
super();
@ -231,7 +231,13 @@ class MaxWindow extends EventSource {
/**
* Initializes the DOM tree that represents the window.
*/
init(x: number, y: number, width: number | null=null, height: number | null=null, style: string='MaxWindow'): void {
init(
x: number,
y: number,
width: number | null = null,
height: number | null = null,
style = 'MaxWindow'
): void {
this.div = document.createElement('div');
this.div.className = style;
@ -335,7 +341,7 @@ class MaxWindow extends EventSource {
/**
* Boolean flag that represents the visible state of the window.
*/
visible: boolean = false;
visible = false;
/**
* {@link Rectangle} that specifies the minimum width and height of the window.
@ -347,7 +353,7 @@ class MaxWindow extends EventSource {
* Specifies if the window should be destroyed when it is closed. If this
* is false then the window is hidden using <setVisible>. Default is true.
*/
destroyOnClose: boolean = true;
destroyOnClose = true;
/**
* Reference to the DOM node (TD) that contains the title.
@ -489,7 +495,7 @@ class MaxWindow extends EventSource {
// Adds a temporary pair of listeners to intercept
// the gesture event in the document
let dragHandler = (evt: MouseEvent) => {
const dragHandler = (evt: MouseEvent) => {
if (startX != null && startY != null) {
const dx = getClientX(evt) - startX;
const dy = getClientY(evt) - startY;
@ -503,7 +509,7 @@ class MaxWindow extends EventSource {
}
};
let dropHandler = (evt: MouseEvent) => {
const dropHandler = (evt: MouseEvent) => {
if (startX != null && startY != null) {
startX = null;
startY = null;
@ -618,7 +624,7 @@ class MaxWindow extends EventSource {
this.minimize.setAttribute('src', this.minimizeImage);
this.minimize.setAttribute('title', 'Minimize');
this.contentWrapper.style.display = ''; // default
if (maxDisplay != null && height != null) {
this.maximize.style.display = maxDisplay;
this.div.style.height = height;
@ -707,8 +713,7 @@ class MaxWindow extends EventSource {
if (style.overflow === 'auto' || this.resize != null) {
this.contentWrapper.style.height = `${
this.div.offsetHeight -
this.title.offsetHeight
this.div.offsetHeight - this.title.offsetHeight
}px`;
}
@ -736,8 +741,7 @@ class MaxWindow extends EventSource {
if (style.overflow === 'auto' || this.resize != null) {
this.contentWrapper.style.height = `${
this.div.offsetHeight -
this.title.offsetHeight
this.div.offsetHeight - this.title.offsetHeight
}px`;
}
@ -964,7 +968,7 @@ class MaxWindow extends EventSource {
* @param isInternalWindow Optional boolean indicating if an MaxWindow should be
* used instead of a new browser window. Default is false.
*/
export const popup = (content: string, isInternalWindow: boolean=false) => {
export const popup = (content: string, isInternalWindow = false) => {
if (isInternalWindow) {
const div = document.createElement('div');
@ -1031,7 +1035,12 @@ export const popup = (content: string, isInternalWindow: boolean=false) => {
* @param close Optional boolean indicating whether to add a close button.
* @param icon Optional icon for the window decoration.
*/
export const error = (message: string, width: number, close: boolean, icon: string | null=null) => {
export const error = (
message: string,
width: number,
close: boolean,
icon: string | null = null
) => {
const div = document.createElement('div');
div.style.padding = '20px';

View File

@ -128,7 +128,7 @@ const createXmlDocument = () => {
* @class Codec
*/
class Codec {
constructor(document: XMLDocument=createXmlDocument()) {
constructor(document: XMLDocument = createXmlDocument()) {
this.document = document;
this.objects = {};
}
@ -146,12 +146,12 @@ class Codec {
/**
* Lookup table for resolving IDs to elements.
*/
elements: any = null; // { [key: string]: Element } | null
elements: any = null; // { [key: string]: Element } | null
/**
* Specifies if default values should be encoded. Default is false.
*/
encodeDefaults: boolean = false;
encodeDefaults = false;
/**
* Assoiates the given object with the given ID and returns the given object.
@ -329,9 +329,7 @@ class Codec {
} else if (isNode(obj)) {
node = importNode(this.document, obj, true);
} else {
MaxLog.warn(
`Codec.encode: No codec for ${getFunctionName(obj.constructor)}`
);
MaxLog.warn(`Codec.encode: No codec for ${getFunctionName(obj.constructor)}`);
}
}
return node;
@ -355,7 +353,7 @@ class Codec {
if (node != null && node.nodeType === NODETYPE.ELEMENT) {
const dec = CodecRegistry.getCodecByName(node.nodeName);
if (dec != null) {
obj = dec.decode(this, node, into);
} else {

View File

@ -200,10 +200,10 @@ import Codec from './Codec';
*/
class ObjectCodec {
constructor(
template: any,
exclude: string[]=[],
idrefs: string[]=[],
mapping: { [key: string]: string }={}
template: any,
exclude: string[] = [],
idrefs: string[] = [],
mapping: { [key: string]: string } = {}
) {
this.template = template;
@ -223,7 +223,7 @@ class ObjectCodec {
* Default is false. NOTE: Enabling this carries a possible security risk.
* @static
*/
static allowEval: boolean = false;
static allowEval = false;
/**
* Holds the template object associated with this codec.
@ -419,16 +419,20 @@ class ObjectCodec {
* @param value Value of the property to be encoded.
* @param node XML node that contains the encoded object.
*/
encodeValue(enc: Codec, obj: any, name: string | null, value: any, node: Element): void {
encodeValue(
enc: Codec,
obj: any,
name: string | null,
value: any,
node: Element
): void {
if (value != null) {
// TODO: What is the case where `name` can be `null`? =========================================================================
if (name != null && this.isReference(obj, name, value, true)) {
const tmp = enc.getId(value);
if (tmp == null) {
MaxLog.warn(
`ObjectCodec.encode: No ID for ${this.getName()}.${name}=${value}`
);
MaxLog.warn(`ObjectCodec.encode: No ID for ${this.getName()}.${name}=${value}`);
return; // exit
}
@ -448,7 +452,13 @@ class ObjectCodec {
* Writes the given value into node using {@link writePrimitiveAttribute}
* or {@link writeComplexAttribute} depending on the type of the value.
*/
writeAttribute(enc: Codec, obj: any, name: string | null, value: any, node: Element): void {
writeAttribute(
enc: Codec,
obj: any,
name: string | null,
value: any,
node: Element
): void {
if (typeof value !== 'object' /* primitive type */) {
this.writePrimitiveAttribute(enc, obj, name, value, node);
} /* complex type */ else {
@ -460,14 +470,14 @@ class ObjectCodec {
* Writes the given value as an attribute of the given node.
*/
writePrimitiveAttribute(
enc: Codec,
obj: any,
name: string | null,
value: any,
enc: Codec,
obj: any,
name: string | null,
value: any,
node: Element
): void {
value = this.convertAttributeToXml(enc, obj, name, value, node); // TODO: params don't seem to match - is this a bug? ===================================
value = this.convertAttributeToXml(enc, obj, name, value, node); // TODO: params don't seem to match - is this a bug? ===================================
if (name == null) {
const child = enc.document.createElement('add');
@ -486,7 +496,13 @@ class ObjectCodec {
/**
* Writes the given value as a child node of the given node.
*/
writeComplexAttribute(enc: Codec, obj: any, name: string | null, value: any, node: Element): void {
writeComplexAttribute(
enc: Codec,
obj: any,
name: string | null,
value: any,
node: Element
): void {
const child = enc.encode(value);
if (child != null) {
@ -509,7 +525,13 @@ class ObjectCodec {
* @param name Name of the attribute to be converted.
* @param value Value to be converted.
*/
convertAttributeToXml(enc: Codec, obj: any, name: string | null, value: any, node: Element): any {
convertAttributeToXml(
enc: Codec,
obj: any,
name: string | null,
value: any,
node: Element
): any {
// Makes sure to encode boolean values as numeric values
if (this.isBooleanAttribute(enc, obj, name, value)) {
// Checks if the value is true (do not use the value as is, because
@ -665,7 +687,7 @@ class ObjectCodec {
}
}
let _node = this.beforeDecode(dec, node, obj);
const _node = this.beforeDecode(dec, node, obj);
this.decodeNode(dec, _node, obj);
return this.afterDecode(dec, _node, obj);
}
@ -760,7 +782,7 @@ class ObjectCodec {
*/
decodeChildren(dec: Codec, node: Element, obj?: any): void {
let child = <Element>node.firstChild;
while (child != null) {
const tmp = <Element>child.nextSibling;
@ -790,7 +812,7 @@ class ObjectCodec {
value = child.getAttribute('value');
if (value == null && ObjectCodec.allowEval) {
value = eval(getTextContent(<Text><unknown>child));
value = eval(getTextContent(<Text>(<unknown>child)));
}
} else {
value = dec.decode(child, template);

View File

@ -42,10 +42,10 @@ export const MAX_HOTSPOT_SIZE = 0;
* Defines the fastest rendering hint.
*/
export const enum RENDERING_HINT {
EXACT = 'exact',
FASTER = 'faster',
FASTEST = 'fastest',
};
EXACT = 'exact',
FASTER = 'faster',
FASTEST = 'fastest',
}
/**
* - DIALECT.SVG: Defines the SVG display dialect name.
@ -57,11 +57,11 @@ export const enum RENDERING_HINT {
* - DIALECT.STRICTHTML: Defines the strict HTML display dialect.
*/
export const enum DIALECT {
SVG = 'svg',
MIXEDHTML = 'mixedHtml',
PREFERHTML = 'preferHtml',
STRICTHTML = 'strictHtml',
};
SVG = 'svg',
MIXEDHTML = 'mixedHtml',
PREFERHTML = 'preferHtml',
STRICTHTML = 'strictHtml',
}
/**
* Name of the field to be used to store the object ID. Default is
@ -101,18 +101,18 @@ export const SHADOW_OFFSET_Y = 3;
export const SHADOW_OPACITY = 1;
export const enum NODETYPE {
ELEMENT = 1,
ATTRIBUTE = 2,
TEXT = 3,
CDATA = 4,
ENTITY_REFERENCE = 5,
ENTITY = 6,
PROCESSING_INSTRUCTION = 7,
COMMENT = 8,
DOCUMENT = 9,
DOCUMENTTYPE = 10,
DOCUMENT_FRAGMENT = 11,
NOTATION = 12,
ELEMENT = 1,
ATTRIBUTE = 2,
TEXT = 3,
CDATA = 4,
ENTITY_REFERENCE = 5,
ENTITY = 6,
PROCESSING_INSTRUCTION = 7,
COMMENT = 8,
DOCUMENT = 9,
DOCUMENTTYPE = 10,
DOCUMENT_FRAGMENT = 11,
NOTATION = 12,
}
/**
@ -176,14 +176,14 @@ export const HIGHLIGHT_OPACITY = 100;
* - CURSOR_CONNECT: Defines the cursor for a connectable state. Default is 'pointer'.
*/
export const enum CURSOR {
MOVABLE_VERTEX = 'move',
MOVABLE_EDGE = 'move',
LABEL_HANDLE = 'default',
TERMINAL_HANDLE = 'pointer',
BEND_HANDLE = 'crosshair',
VIRTUAL_BEND_HANDLE = 'crosshair',
CONNECT = 'pointer',
};
MOVABLE_VERTEX = 'move',
MOVABLE_EDGE = 'move',
LABEL_HANDLE = 'default',
TERMINAL_HANDLE = 'pointer',
BEND_HANDLE = 'crosshair',
VIRTUAL_BEND_HANDLE = 'crosshair',
CONNECT = 'pointer',
}
/**
* Defines the color to be used for the cell highlighting.
@ -470,11 +470,11 @@ export const NONE = 'none';
* - FONT_STRIKETHROUGH: Constant for strikthrough fonts. Default is 8.
*/
export const enum FONT {
BOLD = 1,
ITALIC = 2,
UNDERLINE = 4,
STRIKETHROUGH = 8,
};
BOLD = 1,
ITALIC = 2,
UNDERLINE = 4,
STRIKETHROUGH = 8,
}
/**
* - ARROW_CLASSIC: Constant for classic arrow markers.
@ -496,16 +496,16 @@ export const enum FONT {
* - ARROW_DIAMOND_THIN: Constant for thin diamond arrow markers.
*/
export const enum ARROW {
CLASSIC = 'classic',
CLASSIC_THIN = 'classicThin',
BLOCK = 'block',
BLOCK_THIN = 'blockThin',
OPEN = 'open',
OPEN_THIN = 'openThin',
OVAL = 'oval',
DIAMOND = 'diamond',
DIAMOND_THIN = 'diamondThin',
};
CLASSIC = 'classic',
CLASSIC_THIN = 'classicThin',
BLOCK = 'block',
BLOCK_THIN = 'blockThin',
OPEN = 'open',
OPEN_THIN = 'openThin',
OVAL = 'oval',
DIAMOND = 'diamond',
DIAMOND_THIN = 'diamondThin',
}
/**
* - ALIGN_LEFT: Constant for left horizontal alignment. Default is left.
@ -521,19 +521,19 @@ export const enum ARROW {
* - ALIGN_BOTTOM: Constant for bottom vertical alignment. Default is bottom.
*/
export const enum ALIGN {
LEFT = 'left',
CENTER = 'center',
RIGHT = 'right',
TOP = 'top',
MIDDLE = 'middle',
BOTTOM = 'bottom',
};
LEFT = 'left',
CENTER = 'center',
RIGHT = 'right',
TOP = 'top',
MIDDLE = 'middle',
BOTTOM = 'bottom',
}
export const enum DIRECTION {
NORTH = 'north',
SOUTH = 'south',
EAST = 'east',
WEST = 'west',
NORTH = 'north',
SOUTH = 'south',
EAST = 'east',
WEST = 'west',
}
/**
@ -542,7 +542,7 @@ export const enum DIRECTION {
*
* Constant for text direction automatic. Default is auto. Use this value
* to find the direction for a given text with {@link Text#getAutoDirection}.
*
*
* Constant for text direction left to right. Default is ltr. Use this
* value for left to right text direction.
*
@ -550,11 +550,11 @@ export const enum DIRECTION {
* value for right to left text direction.
*/
export const enum TEXT_DIRECTION {
DEFAULT = '',
AUTO = 'auto',
LTR = 'ltr',
RTL = 'rtl',
};
DEFAULT = '',
AUTO = 'auto',
LTR = 'ltr',
RTL = 'rtl',
}
/**
* - DIRECTION_MASK_NONE: Constant for no direction.
@ -570,140 +570,140 @@ export const enum TEXT_DIRECTION {
* - DIRECTION_MASK_ALL: Bitwise mask for all directions.
*/
export const DIRECTION_MASK = {
NONE: 0,
WEST: 1,
NORTH: 2,
SOUTH: 4,
EAST: 8,
ALL: 15,
NONE: 0,
WEST: 1,
NORTH: 2,
SOUTH: 4,
EAST: 8,
ALL: 15,
};
/**
* Default is horizontal.
*/
export const enum ELBOW {
VERTICAL = 'vertical',
HORIZONTAL = 'horizontal',
};
VERTICAL = 'vertical',
HORIZONTAL = 'horizontal',
}
/**
* Can be used as a string value for the STYLE_EDGE style.
*/
export const enum EDGESTYLE {
ELBOW = 'elbowEdgeStyle',
ENTITY_RELATION = 'entityRelationEdgeStyle',
LOOP = 'loopEdgeStyle',
SIDETOSIDE = 'sideToSideEdgeStyle',
TOPTOBOTTOM = 'topToBottomEdgeStyle',
ORTHOGONAL = 'orthogonalEdgeStyle',
SEGMENT = 'segmentEdgeStyle',
};
ELBOW = 'elbowEdgeStyle',
ENTITY_RELATION = 'entityRelationEdgeStyle',
LOOP = 'loopEdgeStyle',
SIDETOSIDE = 'sideToSideEdgeStyle',
TOPTOBOTTOM = 'topToBottomEdgeStyle',
ORTHOGONAL = 'orthogonalEdgeStyle',
SEGMENT = 'segmentEdgeStyle',
}
/**
* Can be used as a string value for the STYLE_PERIMETER style.
*/
export const enum PERIMETER {
ELLIPSE = 'ellipsePerimeter',
RECTANGLE = 'rectanglePerimeter',
RHOMBUS = 'rhombusPerimeter',
HEXAGON = 'hexagonPerimeter',
TRIANGLE = 'trianglePerimeter'
};
ELLIPSE = 'ellipsePerimeter',
RECTANGLE = 'rectanglePerimeter',
RHOMBUS = 'rhombusPerimeter',
HEXAGON = 'hexagonPerimeter',
TRIANGLE = 'trianglePerimeter',
}
export const enum SHAPE {
/**
* Name under which {@link RectangleShape} is registered in {@link CellRenderer}.
* Default is rectangle.
*/
RECTANGLE = 'rectangle',
/**
* Name under which {@link RectangleShape} is registered in {@link CellRenderer}.
* Default is rectangle.
*/
RECTANGLE = 'rectangle',
/**
* Name under which {@link Ellipse} is registered in {@link CellRenderer}.
* Default is ellipse.
*/
ELLIPSE = 'ellipse',
/**
* Name under which {@link Ellipse} is registered in {@link CellRenderer}.
* Default is ellipse.
*/
ELLIPSE = 'ellipse',
/**
* Name under which {@link DoubleEllipse} is registered in {@link CellRenderer}.
* Default is doubleEllipse.
*/
DOUBLE_ELLIPSE = 'doubleEllipse',
/**
* Name under which {@link DoubleEllipse} is registered in {@link CellRenderer}.
* Default is doubleEllipse.
*/
DOUBLE_ELLIPSE = 'doubleEllipse',
/**
* Name under which {@link Rhombus} is registered in {@link CellRenderer}.
* Default is rhombus.
*/
RHOMBUS = 'rhombus',
/**
* Name under which {@link Rhombus} is registered in {@link CellRenderer}.
* Default is rhombus.
*/
RHOMBUS = 'rhombus',
/**
* Name under which {@link Line} is registered in {@link CellRenderer}.
* Default is line.
*/
LINE = 'line',
/**
* Name under which {@link Line} is registered in {@link CellRenderer}.
* Default is line.
*/
LINE = 'line',
/**
* Name under which {@link ImageShape} is registered in {@link CellRenderer}.
* Default is image.
*/
IMAGE = 'image',
/**
* Name under which {@link ImageShape} is registered in {@link CellRenderer}.
* Default is image.
*/
IMAGE = 'image',
/**
* Name under which {@link Arrow} is registered in {@link CellRenderer}.
* Default is arrow.
*/
ARROW = 'arrow',
/**
* Name under which {@link Arrow} is registered in {@link CellRenderer}.
* Default is arrow.
*/
ARROW = 'arrow',
/**
* Name under which {@link ArrowConnector} is registered in {@link CellRenderer}.
* Default is arrowConnector.
*/
ARROW_CONNECTOR = 'arrowConnector',
/**
* Name under which {@link ArrowConnector} is registered in {@link CellRenderer}.
* Default is arrowConnector.
*/
ARROW_CONNECTOR = 'arrowConnector',
/**
* Name under which {@link Label} is registered in {@link CellRenderer}.
* Default is label.
*/
LABEL = 'label',
/**
* Name under which {@link Label} is registered in {@link CellRenderer}.
* Default is label.
*/
LABEL = 'label',
/**
* Name under which {@link Cylinder} is registered in {@link CellRenderer}.
* Default is cylinder.
*/
CYLINDER = 'cylinder',
/**
* Name under which {@link Cylinder} is registered in {@link CellRenderer}.
* Default is cylinder.
*/
CYLINDER = 'cylinder',
/**
* Name under which {@link Swimlane} is registered in {@link CellRenderer}.
* Default is swimlane.
*/
SWIMLANE = 'swimlane',
/**
* Name under which {@link Swimlane} is registered in {@link CellRenderer}.
* Default is swimlane.
*/
SWIMLANE = 'swimlane',
/**
* Name under which {@link Connector} is registered in {@link CellRenderer}.
* Default is connector.
*/
CONNECTOR = 'connector',
/**
* Name under which {@link Connector} is registered in {@link CellRenderer}.
* Default is connector.
*/
CONNECTOR = 'connector',
/**
* Name under which {@link Actor} is registered in {@link CellRenderer}.
* Default is actor.
*/
ACTOR = 'actor',
/**
* Name under which {@link Actor} is registered in {@link CellRenderer}.
* Default is actor.
*/
ACTOR = 'actor',
/**
* Name under which {@link Cloud} is registered in {@link CellRenderer}.
* Default is cloud.
*/
CLOUD = 'cloud',
/**
* Name under which {@link Cloud} is registered in {@link CellRenderer}.
* Default is cloud.
*/
CLOUD = 'cloud',
/**
* Name under which {@link Triangle} is registered in {@link CellRenderer}.
* Default is triangle.
*/
TRIANGLE = 'triangle',
/**
* Name under which {@link Triangle} is registered in {@link CellRenderer}.
* Default is triangle.
*/
TRIANGLE = 'triangle',
/**
* Name under which {@link Hexagon} is registered in {@link CellRenderer}.
* Default is hexagon.
*/
HEXAGON = 'hexagon',
};
/**
* Name under which {@link Hexagon} is registered in {@link CellRenderer}.
* Default is hexagon.
*/
HEXAGON = 'hexagon',
}

View File

@ -85,11 +85,11 @@ import { write } from './domUtils';
class MaxXmlRequest {
constructor(
url: string,
params: string | null=null,
method: 'GET' | 'POST'='POST',
async: boolean=true,
username: string | null=null,
password: string | null=null
params: string | null = null,
method: 'GET' | 'POST' = 'POST',
async = true,
username: string | null = null,
password: string | null = null
) {
this.url = url;
this.params = params;
@ -127,14 +127,14 @@ class MaxXmlRequest {
*
* @default false
*/
binary: boolean = false;
binary = false;
/**
* Specifies if withCredentials should be used in HTML5-compliant browsers. Default is false.
*
* @default false
*/
withCredentials: boolean = false;
withCredentials = false;
/**
* Specifies the username to be used for authentication.
@ -156,7 +156,7 @@ class MaxXmlRequest {
* textarea value in {@link simulate}. Defaults to false for backwards compatibility,
* to avoid another decode on the server this should be set to true.
*/
decodeSimulateValues: boolean = false;
decodeSimulateValues = false;
/**
* Returns {@link binary}.
@ -251,10 +251,10 @@ class MaxXmlRequest {
* @param ontimeout Optional function to execute on timeout.
*/
send(
onload: Function | null=null,
onerror: Function | null=null,
timeout: number | null=null,
ontimeout: Function | null=null
onload: Function | null = null,
onerror: Function | null = null,
timeout: number | null = null,
ontimeout: Function | null = null
): void {
this.request = this.create();
@ -268,24 +268,14 @@ class MaxXmlRequest {
};
}
this.request.open(
this.method,
this.url,
this.async,
this.username,
this.password
);
this.request.open(this.method, this.url, this.async, this.username, this.password);
this.setRequestHeaders(this.request, this.params);
if (window.XMLHttpRequest && this.withCredentials) {
this.request.withCredentials = 'true';
}
if (
window.XMLHttpRequest &&
timeout != null &&
ontimeout != null
) {
if (window.XMLHttpRequest && timeout != null && ontimeout != null) {
this.request.timeout = timeout;
this.request.ontimeout = ontimeout;
}
@ -320,10 +310,7 @@ class MaxXmlRequest {
*/
setRequestHeaders(request: any, params: any): void {
if (params != null) {
request.setRequestHeader(
'Content-Type',
'application/x-www-form-urlencoded'
);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
}
}
@ -334,7 +321,7 @@ class MaxXmlRequest {
* @param doc Document that contains the form element.
* @param target Target to send the form result to.
*/
simulate(doc: any, target: string | null=null): void {
simulate(doc: any, target: string | null = null): void {
doc = doc || document;
let old = null;
@ -416,7 +403,7 @@ export const load = (url: string) => {
const req = new MaxXmlRequest(url, null, 'GET', false);
req.send();
return req;
}
};
/**
* Loads the specified URL *asynchronously* and invokes the given functions
@ -457,12 +444,12 @@ export const load = (url: string) => {
*/
export const get = (
url: string,
onload: Function | null=null,
onerror: Function | null=null,
binary: boolean=false,
timeout: number | null=null,
ontimeout: Function | null=null,
headers: { [key: string]: string } | null=null
onload: Function | null = null,
onerror: Function | null = null,
binary = false,
timeout: number | null = null,
ontimeout: Function | null = null,
headers: { [key: string]: string } | null = null
) => {
const req = new MaxXmlRequest(url, null, 'GET');
const { setRequestHeaders } = req;
@ -482,7 +469,7 @@ export const get = (
req.send(onload, onerror, timeout, ontimeout);
return req;
}
};
/**
* Loads the URLs in the given array *asynchronously* and invokes the given function
@ -534,7 +521,7 @@ export const getAll = (
if (remain == 0) {
onload(result);
}
}
};
/**
* Posts the specified params to the given URL *asynchronously* and invokes
@ -560,12 +547,12 @@ export const getAll = (
*/
export const post = (
url: string,
params: string | null=null,
params: string | null = null,
onload: Function,
onerror: Function | null=null
onerror: Function | null = null
) => {
return new MaxXmlRequest(url, params).send(onload, onerror);
}
};
/**
* Submits the given parameters to the specified URL using

View File

@ -20,7 +20,6 @@ import { IdentityFunction, IdentityObject } from '../types';
import { IDENTITY_FIELD_NAME } from './Constants';
import { getFunctionName } from './StringUtils';
/**
* @class
*

View File

@ -14,10 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {
NODETYPE,
NONE,
} from './Constants';
import { NODETYPE, NONE } from './Constants';
import { getTextContent } from './domUtils';
import type { Properties } from '../types';
@ -33,7 +30,7 @@ import type { Properties } from '../types';
* - "\0" (ASCII 0 (0x00)), the NUL-byte
* - "\x0B" (ASCII 11 (0x0B)), a vertical tab
*/
export const ltrim = (str: string | null, chars: string = '\\s'): string | null =>
export const ltrim = (str: string | null, chars = '\\s'): string | null =>
str != null ? str.replace(new RegExp(`^[${chars}]+`, 'g'), '') : null;
/**
@ -47,7 +44,7 @@ export const ltrim = (str: string | null, chars: string = '\\s'): string | null
* - "\0" (ASCII 0 (0x00)), the NUL-byte
* - "\x0B" (ASCII 11 (0x0B)), a vertical tab
*/
export const rtrim = (str: string | null, chars: string = '\\s'): string | null =>
export const rtrim = (str: string | null, chars = '\\s'): string | null =>
str != null ? str.replace(new RegExp(`[${chars}]+$`, 'g'), '') : null;
/**
@ -138,7 +135,7 @@ export const removeWhitespace = (node: HTMLElement, before: boolean) => {
* @param {string} s String that contains the characters to be converted.
* @param {boolean} newline If newlines should be replaced. Default is true.
*/
export const htmlEntities = (s: string, newline: boolean=true): string => {
export const htmlEntities = (s: string, newline = true): string => {
s = String(s || '');
s = s.replace(/&/g, '&amp;'); // 38 26
@ -208,7 +205,7 @@ export const getColor = (array: any, key: string, defaultValue: any) => {
*
* @param obj Object to return the string representation for.
*/
export const toString = (obj: Properties) => {
export const toString = (obj: Properties) => {
let output = '';
for (const i in obj) {
@ -230,4 +227,3 @@ export const getColor = (array: any, key: string, defaultValue: any) => {
return output;
};

View File

@ -123,10 +123,7 @@ class Translations {
* @param lan The current language.
*/
static getDefaultBundle = (basename: string, lan: string): string | null => {
if (
Translations.loadDefaultBundle ||
!Translations.isLanguageSupported(lan)
) {
if (Translations.loadDefaultBundle || !Translations.isLanguageSupported(lan)) {
return basename + Translations.extension;
}
return null;
@ -185,13 +182,13 @@ class Translations {
* @param lan The language for which the file should be loaded.
* @param callback Optional callback for asynchronous loading.
*/
static add = (basename: string, lan: string | null=null, callback: Function | null=null): void => {
static add = (
basename: string,
lan: string | null = null,
callback: Function | null = null
): void => {
lan =
lan != null
? lan
: Client.language != null
? Client.language.toLowerCase()
: NONE;
lan != null ? lan : Client.language != null ? Client.language.toLowerCase() : NONE;
if (lan !== NONE) {
const defaultBundle = Translations.getDefaultBundle(basename, lan);
@ -315,7 +312,11 @@ class Translations {
* to be replaced with in the resulting string.
* @param defaultValue Optional string that specifies the default return value.
*/
static get = (key: string, params: any[] | null=null, defaultValue: string | null=null): string | null => {
static get = (
key: string,
params: any[] | null = null,
defaultValue: string | null = null
): string | null => {
let value: string | null = Translations.resources[key];
// Applies the default value if no resource was found
@ -375,6 +376,6 @@ class Translations {
Translations.add(`${Client.basePath}/resources/graph`, null, callback);
});
};
};
}
export default Translations;

View File

@ -80,7 +80,7 @@ export const mixInto = (dest: any) => (mixin: any) => {
* @param defaultValue Value to be returned if the value for the given
* key is null.
*/
export const getValue = (array: any, key: string, defaultValue?: any) => {
export const getValue = (array: any, key: string, defaultValue?: any) => {
let value = array != null ? array[key] : null;
if (value == null) {
value = defaultValue;
@ -94,33 +94,36 @@ export const copyTextToClipboard = (text: string): void => {
fallbackCopyTextToClipboard(text);
return;
}
navigator.clipboard.writeText(text).then(function() {
console.log('Async: Copying to clipboard was successful!');
}, function(err) {
console.error('Async: Could not copy text: ', err);
});
}
navigator.clipboard.writeText(text).then(
function () {
console.log('Async: Copying to clipboard was successful!');
},
function (err) {
console.error('Async: Could not copy text: ', err);
}
);
};
const fallbackCopyTextToClipboard = (text: string):void => {
var textArea = document.createElement("textarea");
const fallbackCopyTextToClipboard = (text: string): void => {
const textArea = document.createElement('textarea');
textArea.value = text;
// Avoid scrolling to bottom
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
textArea.style.top = '0';
textArea.style.left = '0';
textArea.style.position = 'fixed';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
const successful = document.execCommand('copy');
const msg = successful ? 'successful' : 'unsuccessful';
console.log('Fallback: Copying text command was ' + msg);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
};

View File

@ -16,10 +16,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import Point from '../view/geometry/Point';
import Dictionary from './Dictionary';
import type { Properties } from '../types';
import Point from '../view/geometry/Point';
import Dictionary from './Dictionary';
import type { Properties } from '../types';
/**
* Removes all occurrences of the given object in the given array or
@ -34,7 +34,7 @@ limitations under the License.
* @param obj Object to find in the given array.
* @param array Array to check for the given obj.
*/
export const remove = (obj: object, array: object[]) => {
export const remove = (obj: object, array: object[]) => {
let result = null;
if (typeof array === 'object') {

View File

@ -7,7 +7,7 @@ import ObjectIdentity from './ObjectIdentity';
* returns true.
*/
export const filterCells = (filter: Function) => (cells: Cell[]) => {
let result = [] as Cell[];
const result = [] as Cell[];
for (let i = 0; i < cells.length; i += 1) {
if (filter(cells[i])) {
@ -30,7 +30,7 @@ export const filterCells = (filter: Function) => (cells: Cell[]) => {
* in the result. Default is true.
*/
export const getOpposites =
(terminal: Cell, sources: boolean = true, targets: boolean = true) =>
(terminal: Cell, sources = true, targets = true) =>
(edges: Cell[]) => {
const terminals = [] as Cell[];
@ -142,11 +142,7 @@ export const cloneCells =
*
* @private
*/
const cloneCellImpl = (
cell: Cell,
mapping: any = {},
includeChildren: boolean = false
): Cell => {
const cloneCellImpl = (cell: Cell, mapping: any = {}, includeChildren = false): Cell => {
const ident = <string>ObjectIdentity.get(cell);
let clone = mapping ? mapping[ident] : null;

View File

@ -29,7 +29,11 @@ import ObjectIdentity from './ObjectIdentity';
* in other words, one where only atomic (strings, numbers) values are
* cloned. Default is false.
*/
export const clone = function _clone(obj: any, transients: string[] | null=null, shallow: boolean=false) {
export const clone = function _clone(
obj: any,
transients: string[] | null = null,
shallow = false
) {
shallow = shallow != null ? shallow : false;
let clone = null;

View File

@ -16,8 +16,8 @@ limitations under the License.
import Editor from '../editor/Editor';
import { KeyboardEventListener, MouseEventListener } from '../types';
import InternalEvent from "../view/event/InternalEvent";
import { write } from "./domUtils";
import InternalEvent from '../view/event/InternalEvent';
import { write } from './domUtils';
/**
* Adds a hyperlink to the specified parent that invokes action on the
@ -29,7 +29,13 @@ import { write } from "./domUtils";
* @param action String that defines the name of the action to be executed.
* @param pad Optional left-padding for the link. Default is 0.
*/
export const linkAction = (parent: HTMLElement, text: string, editor: Editor, action: string, pad: number=0) => {
export const linkAction = (
parent: HTMLElement,
text: string,
editor: Editor,
action: string,
pad = 0
) => {
return link(
parent,
text,
@ -53,7 +59,14 @@ export const linkAction = (parent: HTMLElement, text: string, editor: Editor, ac
* @param arg Object that represents the argument to the function.
* @param pad Optional left-padding for the link. Default is 0.
*/
export const linkInvoke = (parent: Element, text: string, editor: Editor, functName: string, arg: any, pad: number=0) => {
export const linkInvoke = (
parent: Element,
text: string,
editor: Editor,
functName: string,
arg: any,
pad = 0
) => {
return link(
parent,
text,
@ -74,7 +87,12 @@ export const linkInvoke = (parent: Element, text: string, editor: Editor, functN
* @param funct Function to execute when the link is clicked.
* @param pad Optional left-padding for the link. Default is 0.
*/
export const link = (parent: Element, text: string, funct: MouseEventListener | KeyboardEventListener, pad: number=0) => {
export const link = (
parent: Element,
text: string,
funct: MouseEventListener | KeyboardEventListener,
pad = 0
) => {
const a = document.createElement('span');
a.style.color = 'blue';
@ -108,7 +126,11 @@ export const link = (parent: Element, text: string, funct: MouseEventListener |
* @param doc Optional document to be used for creating the button. Default is the
* current document.
*/
export const button = (label: string, funct: (evt: MouseEvent) => void, doc: Document | null=null): HTMLButtonElement => {
export const button = (
label: string,
funct: (evt: MouseEvent) => void,
doc: Document | null = null
): HTMLButtonElement => {
doc = doc != null ? doc : document;
const button = doc.createElement('button');

View File

@ -42,10 +42,7 @@ export const extractTextWithWhitespace = (elems: Element[]): string => {
function doExtract(elts: Element[]) {
// Single break should be ignored
if (
elts.length == 1 &&
(elts[0].nodeName == 'BR' || elts[0].innerHTML == '\n')
) {
if (elts.length == 1 && (elts[0].nodeName == 'BR' || elts[0].innerHTML == '\n')) {
return;
}
@ -88,7 +85,7 @@ export const extractTextWithWhitespace = (elems: Element[]): string => {
* @param node DOM node to return the text content for.
*/
export const getTextContent = (node: Text | null): string => {
return (node != null && node.textContent) ? node.textContent : '';
return node != null && node.textContent ? node.textContent : '';
};
/**
@ -179,7 +176,7 @@ export const writeln = (parent: Element, text: string) => {
*
* @param parent DOM node to append the linebreak to.
*/
export const br = (parent: Element, count: number=1) => {
export const br = (parent: Element, count = 1) => {
let br = null;
for (let i = 0; i < count; i += 1) {
@ -223,16 +220,18 @@ export const para = (parent: Element, text: string) => {
* @param attributeName Optional attribute name to check.
* @param attributeValue Optional attribute value to check.
*/
export const isNode = (value: any, nodeName: string | null=null, attributeName?: string, attributeValue?: string) => {
export const isNode = (
value: any,
nodeName: string | null = null,
attributeName?: string,
attributeValue?: string
) => {
if (
value != null &&
!isNaN(value.nodeType) &&
(nodeName == null || value.nodeName.toLowerCase() == nodeName.toLowerCase())
) {
return (
attributeName == null ||
value.getAttribute(attributeName) == attributeValue
);
return attributeName == null || value.getAttribute(attributeName) == attributeValue;
}
return false;
@ -266,7 +265,10 @@ export const isAncestorNode = (ancestor: Element, child: Element | null) => {
* @param nodeType Optional node type to return. Default is
* {@link Constants#NODETYPE_ELEMENT}.
*/
export const getChildNodes = (node: Element, nodeType: number=NODETYPE.ELEMENT): ChildNode[] => {
export const getChildNodes = (
node: Element,
nodeType: number = NODETYPE.ELEMENT
): ChildNode[] => {
nodeType = nodeType || NODETYPE.ELEMENT;
const children = [];
@ -302,7 +304,11 @@ export const importNode = (doc: Document, node: Element, allChildren: boolean) =
* @param node Node to be imported.
* @param allChildren If all children should be imported.
*/
export const importNodeImplementation = (doc: Document, node: Element, allChildren: boolean) => {
export const importNodeImplementation = (
doc: Document,
node: Element,
allChildren: boolean
) => {
switch (node.nodeType) {
case 1 /* element */: {
const newNode = doc.createElement(node.nodeName);
@ -358,7 +364,7 @@ export const clearSelection = () => {
*
* @param src URL that points to the image to be displayed.
*/
export const createImage = (src: string) => {
export const createImage = (src: string) => {
let imageNode = null;
imageNode = document.createElement('img');
imageNode.setAttribute('src', src);
@ -379,8 +385,8 @@ export const clearSelection = () => {
export const addLinkToHead = (
rel: string,
href: string,
doc: Document | null=null,
id: string | null=null
doc: Document | null = null,
id: string | null = null
) => {
doc = doc || document;

View File

@ -89,12 +89,14 @@ export const makeDraggable = (
graphF: Graph | Function,
funct: DropHandler,
dragElement: Element,
dx: number | null=null,
dy: number | null=null,
autoscroll: boolean | null=null,
scalePreview: boolean=false,
highlightDropTargets: boolean=true,
getDropTarget: ((graph: Graph, x: number, y: number, evt: MouseEvent) => Cell) | null=null
dx: number | null = null,
dy: number | null = null,
autoscroll: boolean | null = null,
scalePreview = false,
highlightDropTargets = true,
getDropTarget:
| ((graph: Graph, x: number, y: number, evt: MouseEvent) => Cell)
| null = null
) => {
const dragSource = new DragSource(element, funct);
dragSource.dragOffset = new Point(

View File

@ -122,7 +122,7 @@ export const arcToCurves = (
let x3 = 0;
let y3 = 0;
let result = [];
const result = [];
for (let n = 0; n < seg; ++n) {
s1 += segr;

View File

@ -35,7 +35,7 @@ import { removeCursors } from './styleUtils';
* Default is <mxConstants.PAGE_FORMAT_A4_PORTRAIT>.
* @param border The border along each side of every page.
*/
export const getScaleForPageCount = (
export const getScaleForPageCount = (
pageCount: number,
graph: Graph,
pageFormat?: Rectangle,
@ -171,11 +171,11 @@ import { removeCursors } from './styleUtils';
*/
export const show = (
graph: Graph,
doc: Document | null=null,
doc: Document | null = null,
x0 = 0,
y0 = 0,
w: number | null=null,
h: number | null=null
w: number | null = null,
h: number | null = null
) => {
x0 = x0 != null ? x0 : 0;
y0 = y0 != null ? y0 : 0;
@ -303,4 +303,3 @@ export const printScreen = (graph: Graph) => {
print();
}
};

View File

@ -38,8 +38,8 @@ import { Graph } from '../view/Graph';
export function findTreeRoots(
graph: Graph,
parent: Cell,
isolate: boolean = false,
invert: boolean = false
isolate = false,
invert = false
) {
const roots: Cell[] = [];
@ -117,11 +117,11 @@ export function findTreeRoots(
*/
export function traverse(
vertex: Cell | null = null,
directed: boolean = true,
directed = true,
func: Function | null = null,
edge: Cell | null = null,
visited: Dictionary<Cell, boolean> | null = null,
inverse: boolean = false
inverse = false
) {
if (func != null && vertex != null) {
directed = directed != null ? directed : true;

View File

@ -40,10 +40,10 @@ export const parseXml = (xmlString: string): Document => {
export const getViewXml = (
graph: Graph,
scale: number = 1,
scale = 1,
cells: Cell[] | null = null,
x0: number = 0,
y0: number = 0
x0 = 0,
y0 = 0
) => {
if (cells == null) {
const model = graph.getDataModel();
@ -111,7 +111,7 @@ export const getViewXml = (
* @param linefeed Optional string that linefeeds are converted into. Default is
* &#xa;
*/
export const getXml = (node: Element, linefeed: string = '&#xa;'): string => {
export const getXml = (node: Element, linefeed = '&#xa;'): string => {
const xmlSerializer = new XMLSerializer();
let xml = xmlSerializer.serializeToString(node);

View File

@ -90,12 +90,12 @@ export const defaultPlugins: GraphPluginConstructor[] = [
class Graph extends EventSource {
container: HTMLElement;
destroyed: boolean = false;
destroyed = false;
graphModelChangeListener: Function | null = null;
paintBackground: Function | null = null;
foldingEnabled: null | boolean = null;
isConstrainedMoving: boolean = false;
isConstrainedMoving = false;
/*****************************************************************************
* Group: Variables (that maybe should be in the mixins, but need to be created for each new class instance)
@ -171,7 +171,7 @@ class Graph extends EventSource {
* {@link isConstrainChild} returns `true`. The value specifies the
* portion of the child which is allowed to overlap the parent.
*/
defaultOverlap: number = 0.5;
defaultOverlap = 0.5;
/**
* Specifies the default parent to be used to insert new cells.
@ -320,7 +320,7 @@ class Graph extends EventSource {
* being resized after the graph has been changed.
* @default 0
*/
border: number = 0;
border = 0;
/**
* Specifies if edges should appear in the foreground regardless of their order
@ -328,7 +328,7 @@ class Graph extends EventSource {
* both `true` then the normal order is applied.
* @default false
*/
keepEdgesInForeground: boolean = false;
keepEdgesInForeground = false;
/**
* Specifies if edges should appear in the background regardless of their order
@ -336,26 +336,26 @@ class Graph extends EventSource {
* both `true` then the normal order is applied.
* @default false
*/
keepEdgesInBackground: boolean = false;
keepEdgesInBackground = false;
/**
* Specifies the return value for {@link isRecursiveResize}.
* @default false (for backwards compatibility)
*/
recursiveResize: boolean = false;
recursiveResize = false;
/**
* Specifies if the scale and translate should be reset if the root changes in
* the model.
* @default true
*/
resetViewOnRootChange: boolean = true;
resetViewOnRootChange = true;
/**
* Specifies if loops (aka self-references) are allowed.
* @default false
*/
allowLoops: boolean = false;
allowLoops = false;
/**
* {@link EdgeStyle} to be used for loops. This is a fallback for loops if the
@ -369,19 +369,19 @@ class Graph extends EventSource {
* vertices are allowed.
* @default true
*/
multigraph: boolean = true;
multigraph = true;
/**
* Specifies the minimum scale to be applied in {@link fit}. Set this to `null` to allow any value.
* @default 0.1
*/
minFitScale: number = 0.1;
minFitScale = 0.1;
/**
* Specifies the maximum scale to be applied in {@link fit}. Set this to `null` to allow any value.
* @default 8
*/
maxFitScale: number = 8;
maxFitScale = 8;
/**
* Specifies the {@link Image} for the image to be used to display a warning
@ -654,12 +654,7 @@ class Graph extends EventSource {
* Scrolls the graph to the given point, extending the graph container if
* specified.
*/
scrollPointToVisible(
x: number,
y: number,
extend: boolean = false,
border: number = 20
) {
scrollPointToVisible(x: number, y: number, extend = false, border = 20) {
const panningHandler = this.getPlugin('PanningHandler') as PanningHandler;
if (
@ -823,11 +818,11 @@ class Graph extends EventSource {
*/
fit(
border: number = this.getBorder(),
keepOrigin: boolean = false,
margin: number = 0,
enabled: boolean = true,
ignoreWidth: boolean = false,
ignoreHeight: boolean = false,
keepOrigin = false,
margin = 0,
enabled = true,
ignoreWidth = false,
ignoreHeight = false,
maxHeight: number | null = null
): number {
if (this.container != null) {
@ -1151,12 +1146,7 @@ class Graph extends EventSource {
* @param cx Optional float that specifies the horizontal center. Default is `0.5`.
* @param cy Optional float that specifies the vertical center. Default is `0.5`.
*/
center(
horizontal: boolean = true,
vertical: boolean = true,
cx: number = 0.5,
cy: number = 0.5
): void {
center(horizontal = true, vertical = true, cx = 0.5, cy = 0.5): void {
const container = <HTMLElement>this.container;
const _hasScrollbars = hasScrollbars(this.container);
const padding = 2 * this.getBorder();

View File

@ -230,41 +230,41 @@ export class GraphDataModel extends EventSource {
/**
* Maps from Ids to cells.
*/
cells: {[key: string]: Cell} | null = {};
cells: { [key: string]: Cell } | null = {};
/**
* Specifies if edges should automatically be moved into the nearest common
* ancestor of their terminals. Default is true.
*/
maintainEdgeParent: boolean = true;
maintainEdgeParent = true;
/**
* Specifies if relative edge parents should be ignored for finding the nearest
* common ancestors of an edge's terminals. Default is true.
*/
ignoreRelativeEdgeParent: boolean = true;
ignoreRelativeEdgeParent = true;
/**
* Specifies if the model should automatically create Ids for new cells.
* Default is true.
*/
createIds: boolean = true;
createIds = true;
/**
* Defines the prefix of new Ids. Default is an empty string.
*/
prefix: string = '';
prefix = '';
/**
* Defines the postfix of new Ids. Default is an empty string.
*/
postfix: string = '';
postfix = '';
/**
* Specifies the next Id to be created. Initial value is 0.
*/
// nextId: number | string;
nextId: number = 0;
nextId = 0;
/**
* Holds the changes for the current transaction. If the transaction is
@ -279,12 +279,12 @@ export class GraphDataModel extends EventSource {
* it. When the counter reaches 0, the transaction is closed and the
* respective events are fired. Initial value is 0.
*/
updateLevel: number = 0;
updateLevel = 0;
/**
* True if the program flow is currently inside endUpdate.
*/
endingUpdate: boolean = false;
endingUpdate = false;
constructor(root: Cell | null = null) {
super();
@ -493,7 +493,7 @@ export class GraphDataModel extends EventSource {
}
// Recursively processes child cells
for (let child of cell.getChildren()) {
for (const child of cell.getChildren()) {
this.cellAdded(child);
}
}
@ -736,7 +736,7 @@ export class GraphDataModel extends EventSource {
terminalForCellChanged(
edge: Cell,
terminal: Cell | null,
isSource: boolean = false
isSource = false
): Cell | null {
const previous = edge.getTerminal(isSource);
if (terminal != null) {
@ -759,7 +759,7 @@ export class GraphDataModel extends EventSource {
* @param directed Optional boolean that specifies if the direction of the
* edge should be taken into account. Default is false.
*/
getEdgesBetween(source: Cell, target: Cell, directed: boolean = false): Cell[] {
getEdgesBetween(source: Cell, target: Cell, directed = false): Cell[] {
const tmp1 = source.getEdgeCount();
const tmp2 = target.getEdgeCount();
@ -1051,7 +1051,7 @@ export class GraphDataModel extends EventSource {
* @param significant Optional boolean that specifies if the edit to be created is
* significant. Default is true.
*/
createUndoableEdit(significant: boolean = true): UndoableEdit {
createUndoableEdit(significant = true): UndoableEdit {
const edit = new UndoableEdit(this, significant);
edit.notify = () => {
@ -1078,7 +1078,7 @@ export class GraphDataModel extends EventSource {
* source edges.
*/
// mergeChildren(from: Transactions, to: Transactions, cloneAllEdges?: boolean): void;
mergeChildren(from: Cell, to: Cell, cloneAllEdges: boolean = true): void {
mergeChildren(from: Cell, to: Cell, cloneAllEdges = true): void {
this.beginUpdate();
try {
const mapping: any = {};
@ -1167,7 +1167,7 @@ export class GraphDataModel extends EventSource {
*
* @param {Cell} cell to be cloned.
*/
cloneCell(cell: Cell | null = null, includeChildren: boolean = true): Cell | null {
cloneCell(cell: Cell | null = null, includeChildren = true): Cell | null {
if (cell != null) {
return cloneCells(includeChildren)([cell])[0];
}

View File

@ -1263,11 +1263,7 @@ export class GraphView extends EventSource {
/**
* Transforms the given control point to an absolute point.
*/
transformControlPoint(
state: CellState,
pt: Point,
ignoreScale: boolean = false
): Point | null {
transformControlPoint(state: CellState, pt: Point, ignoreScale = false): Point | null {
if (state && pt) {
const orig = <Point>state.origin;
const scale = ignoreScale ? 1 : this.scale;
@ -1437,7 +1433,7 @@ export class GraphView extends EventSource {
* @param terminal {@link CellState} that represents the terminal.
* @param source Boolean indicating if the given terminal is the source terminal.
*/
getTerminalPort(state: CellState, terminal: CellState, source: boolean = false) {
getTerminalPort(state: CellState, terminal: CellState, source = false) {
const key = source ? 'sourcePort' : 'targetPort';
const id = state.style[key];
@ -1578,10 +1574,7 @@ export class GraphView extends EventSource {
* @param {CellState} terminal CellState that represents the terminal.
* @param {number} border Number that adds a border between the shape and the perimeter.
*/
getPerimeterBounds(
terminal: CellState | null = null,
border: number = 0
): Rectangle | null {
getPerimeterBounds(terminal: CellState | null = null, border = 0): Rectangle | null {
if (terminal) {
border += terminal.style.perimeterSpacing ?? 0;
}
@ -1814,7 +1807,7 @@ export class GraphView extends EventSource {
if (geometry.relative && pointCount > 1) {
const totalLength = edgeState.length;
let { segments } = edgeState;
const { segments } = edgeState;
// Works out which line segment the point of the label is closest to
let p0 = absolutePoints[0] as Point;
@ -1995,7 +1988,7 @@ export class GraphView extends EventSource {
* @param cell {@link mxCell} for which the {@link CellState} should be removed.
*/
removeState(cell: Cell) {
let state: CellState | null = this.states.remove(cell);
const state: CellState | null = this.states.remove(cell);
if (state) {
this.graph.cellRenderer.destroy(state);
@ -2266,7 +2259,7 @@ export class GraphView extends EventSource {
* Creates the DOM nodes for the HTML display.
*/
createHtml() {
var container = this.graph.container;
const container = this.graph.container;
if (container != null) {
this.canvas = this.createHtmlPane('100%', '100%');
@ -2297,8 +2290,8 @@ export class GraphView extends EventSource {
*/
updateHtmlCanvasSize(width: number, height: number) {
if (this.graph.container != null) {
var ow = this.graph.container.offsetWidth;
var oh = this.graph.container.offsetHeight;
const ow = this.graph.container.offsetWidth;
const oh = this.graph.container.offsetHeight;
if (ow < width) {
this.canvas.style.width = width + 'px';
@ -2320,7 +2313,7 @@ export class GraphView extends EventSource {
* Creates and returns a drawing pane in HTML (DIV).
*/
createHtmlPane(width: string, height: string) {
var pane = document.createElement('DIV');
const pane = document.createElement('DIV');
if (width != null && height != null) {
pane.style.position = 'absolute';

View File

@ -27,7 +27,7 @@ import InternalEvent from '../event/InternalEvent';
* @extends {EventSource}
*/
class Animation extends EventSource {
constructor(delay: number=20) {
constructor(delay = 20) {
super();
this.delay = delay;
}

View File

@ -120,7 +120,7 @@ class Effects {
}
};
let delay = 30;
const delay = 30;
animate();
}
@ -162,7 +162,14 @@ class Effects {
/**
* Asynchronous fade-out operation.
*/
static fadeOut(node: HTMLElement, from: number, remove: boolean, step: number, delay: number, isEnabled: boolean): void {
static fadeOut(
node: HTMLElement,
from: number,
remove: boolean,
step: number,
delay: number,
isEnabled: boolean
): void {
step = step || 40;
delay = delay || 30;

View File

@ -56,7 +56,7 @@ import { Graph } from '../Graph';
* @param delay Optional delay between the animation steps. Passed to <Animation>.
*/
class Morphing extends Animation {
constructor(graph: Graph, steps: number = 6, ease: number = 1.5, delay: number) {
constructor(graph: Graph, steps = 6, ease = 1.5, delay: number) {
super(delay);
this.graph = graph;
this.steps = steps;
@ -76,7 +76,7 @@ class Morphing extends Animation {
/**
* Contains the current step.
*/
step: number = 0;
step = 0;
/**
* Ease-off for movement towards the given vector. Larger values are
@ -100,7 +100,7 @@ class Morphing extends Animation {
if (this.cells != null) {
// Animates the given cells individually without recursion
for (let cell of this.cells) {
for (const cell of this.cells) {
this.animateCell(cell, move, false);
}
} else {
@ -126,7 +126,7 @@ class Morphing extends Animation {
/**
* Animates the given cell state using <CellStatePreview.moveState>.
*/
animateCell(cell: Cell, move: CellStatePreview, recurse: boolean = false) {
animateCell(cell: Cell, move: CellStatePreview, recurse = false) {
const state = this.graph.getView().getState(cell);
let delta = null;

View File

@ -308,7 +308,7 @@ class AbstractCanvas2D {
h: number,
direction: DirectionValue,
alpha1 = 1,
alpha2: number = 1
alpha2 = 1
) {
const s = this.state;
s.fillColor = color1;

View File

@ -72,13 +72,13 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
* Specifies if text output should be enabled.
* @default true
*/
textEnabled: boolean = true;
textEnabled = true;
/**
* Specifies if the output should be compressed by removing redundant calls.
* @default true
*/
compressed: boolean = true;
compressed = true;
/**
* Writes the rendering defaults to {@link root}:
@ -257,7 +257,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
*
* @param value Hexadecimal representation of the color or 'none'.
*/
setFillColor(value: string | null=null): void {
setFillColor(value: string | null = null): void {
if (value === NONE) {
value = null;
}
@ -298,8 +298,8 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
w: number,
h: number,
direction: DirectionValue,
alpha1: number=1.0,
alpha2: number=1.0
alpha1 = 1.0,
alpha2 = 1.0
) {
if (color1 != null && color2 != null) {
super.setGradient(color1, color2, x, y, w, h, direction, alpha1, alpha2);
@ -334,7 +334,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
*
* @param value Hexadecimal representation of the color or 'none'.
*/
setStrokeColor(value: string | null=null): void {
setStrokeColor(value: string | null = null): void {
if (value === NONE) {
value = null;
}
@ -482,7 +482,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
*
* @param value Hexadecimal representation of the color or 'none'.
*/
setFontColor(value: string | null=null): void {
setFontColor(value: string | null = null): void {
if (this.textEnabled) {
if (value === NONE) {
value = null;
@ -506,7 +506,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
*
* @param value Hexadecimal representation of the color or 'none'.
*/
setFontBackgroundColor(value: string | null=null): void {
setFontBackgroundColor(value: string | null = null): void {
if (this.textEnabled) {
if (value === NONE) {
value = null;
@ -530,7 +530,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
*
* @param value Hexadecimal representation of the color or 'none'.
*/
setFontBorderColor(value: string | null=null): void {
setFontBorderColor(value: string | null = null): void {
if (this.textEnabled) {
if (value === NONE) {
value = null;
@ -598,7 +598,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
* @param value Numeric representation of the font family. This is the sum of the
* font styles from {@link mxConstants}.
*/
setFontStyle(value: number | null=0): void {
setFontStyle(value: number | null = 0): void {
if (this.textEnabled) {
if (value == null) {
value = 0;
@ -641,7 +641,7 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
*
* @param value Hexadecimal representation of the color or 'none'.
*/
setShadowColor(value: string | null=null): void {
setShadowColor(value: string | null = null): void {
if (this.compressed) {
if (value === NONE) {
value = null;
@ -904,14 +904,14 @@ class mxXmlCanvas2D extends AbstractCanvas2D {
w: number,
h: number,
str: string | HTMLElement,
align: string | null=null,
valign: string | null=null,
wrap: boolean | null=null,
format: string | null=null,
overflow: string | null=null,
clip: boolean | null=null,
rotation: number | null=null,
dir: TextDirectionValue | null=null
align: string | null = null,
valign: string | null = null,
wrap: boolean | null = null,
format: string | null = null,
overflow: string | null = null,
clip: boolean | null = null,
rotation: number | null = null,
dir: TextDirectionValue | null = null
): void {
if (this.textEnabled && str != null) {
if (isNode(str)) {

View File

@ -95,7 +95,7 @@ export class Cell implements IdentityObject {
// TODO: Document me!
// used by invalidate() of mxGraphView
invalidating: boolean = false;
invalidating = false;
onInit: (() => void) | null = null;
@ -126,27 +126,27 @@ export class Cell implements IdentityObject {
/**
* Specifies whether the cell is a vertex. Default is false.
*/
vertex: boolean = false;
vertex = false;
/**
* Specifies whether the cell is an edge. Default is false.
*/
edge: boolean = false;
edge = false;
/**
* Specifies whether the cell is connectable. Default is true.
*/
connectable: boolean = true;
connectable = true;
/**
* Specifies whether the cell is visible. Default is true.
*/
visible: boolean = true;
visible = true;
/**
* Specifies whether the cell is collapsed. Default is false.
*/
collapsed: boolean = false;
collapsed = false;
/**
* Reference to the parent cell.
@ -364,7 +364,7 @@ export class Cell implements IdentityObject {
* @param source Boolean that specifies if the source terminal should be
* returned.
*/
getTerminal(source: boolean = false) {
getTerminal(source = false) {
return source ? this.source : this.target;
}
@ -502,7 +502,7 @@ export class Cell implements IdentityObject {
* @param edge <Cell> to be inserted into the edge array.
* @param isOutgoing Boolean that specifies if the edge is outgoing.
*/
insertEdge(edge: Cell, isOutgoing: boolean = false) {
insertEdge(edge: Cell, isOutgoing = false) {
edge.removeFromTerminal(isOutgoing);
edge.setTerminal(this, isOutgoing);
@ -524,7 +524,7 @@ export class Cell implements IdentityObject {
* @param edge<Cell> to be removed from the edge array.
* @param isOutgoing Boolean that specifies if the edge is outgoing.
*/
removeEdge(edge: Cell | null, isOutgoing: boolean = false): Cell | null {
removeEdge(edge: Cell | null, isOutgoing = false): Cell | null {
if (edge != null) {
if (edge.getTerminal(!isOutgoing) !== this && this.edges != null) {
const index = this.getEdgeIndex(edge);
@ -702,7 +702,7 @@ export class Cell implements IdentityObject {
* @param edges Boolean indicating if child edges should be returned.
* Default is false.
*/
getChildCells(vertices: boolean = false, edges: boolean = false) {
getChildCells(vertices = false, edges = false) {
const childCount = this.getChildCount();
const result = [];
@ -777,11 +777,7 @@ export class Cell implements IdentityObject {
* @param includeLoops Optional boolean that specifies if loops should be returned.
* Default is true.
*/
getEdges(
incoming: boolean = true,
outgoing: boolean = true,
includeLoops: boolean = true
) {
getEdges(incoming = true, outgoing = true, includeLoops = true) {
const edgeCount = this.getEdgeCount();
const result = [];

View File

@ -42,7 +42,7 @@ class CellHighlight {
// TODO: Document me!!
highlightColor: ColorValue;
strokeWidth: number = 0;
strokeWidth = 0;
dashed = false;

View File

@ -77,10 +77,10 @@ class CellOverlay extends EventSource implements ObjectIdentity {
constructor(
image: ImageBox,
tooltip: string | null = null,
align: string = 'right',
verticalAlign: string = 'bottom',
align = 'right',
verticalAlign = 'bottom',
offset: Point = new Point(),
cursor: string = 'help'
cursor = 'help'
) {
super();

View File

@ -1107,7 +1107,7 @@ class CellRenderer {
*
* @param state <CellState> whose overlays should be redrawn.
*/
redrawCellOverlays(state: CellState, forced: boolean = false): void {
redrawCellOverlays(state: CellState, forced = false): void {
this.createCellOverlays(state);
if (state.overlays != null) {
@ -1158,7 +1158,7 @@ class CellRenderer {
*
* @param state <CellState> whose control should be redrawn.
*/
redrawControl(state: CellState, forced: boolean = false): void {
redrawControl(state: CellState, forced = false): void {
const image = (<Graph>state.view.graph).getFoldingImage(state);
if (state.control != null && image != null) {
@ -1347,7 +1347,7 @@ class CellRenderer {
* be drawn into the DOM. If this is false then redraw and/or reconfigure
* will not be called on the shape.
*/
redraw(state: CellState, force: boolean = false, rendering: boolean = true): void {
redraw(state: CellState, force = false, rendering = true): void {
const shapeChanged = this.redrawShape(state, force, rendering);
if (state.shape != null && rendering) {
@ -1362,11 +1362,7 @@ class CellRenderer {
*
* @param state <CellState> whose label should be redrawn.
*/
redrawShape(
state: CellState,
force: boolean = false,
rendering: boolean = true
): boolean {
redrawShape(state: CellState, force = false, rendering = true): boolean {
let shapeChanged = false;
const graph = <Graph>state.view.graph;

View File

@ -190,7 +190,7 @@ class CellState extends Rectangle {
* @param bounds Optional {@link Rectangle} to be used as the initial bounds.
*/
getPerimeterBounds(
border: number = 0,
border = 0,
bounds: Rectangle = new Rectangle(this.x, this.y, this.width, this.height)
) {
if (this.shape?.stencil?.aspect === 'fixed') {

View File

@ -47,7 +47,7 @@ class CellStatePreview {
/**
* Contains the number of entries in the map.
*/
count: number = 0;
count = 0;
/**
* Returns true if this contains no entries.
@ -57,7 +57,7 @@ class CellStatePreview {
}
/**
*
*
* @param {CellState} state
* @param {number} dx
* @param {number} dy
@ -70,8 +70,8 @@ class CellStatePreview {
state: CellState,
dx: number,
dy: number,
add: boolean = true,
includeEdges: boolean = true
add = true,
includeEdges = true
): Point {
let delta = this.deltas.get(state.cell);
@ -95,7 +95,7 @@ class CellStatePreview {
}
/**
*
*
* @param {Function} visitor
* @memberof mxCellStatePreview
*/
@ -110,7 +110,7 @@ class CellStatePreview {
}
/**
*
*
* @param {CellState} state
* @param {number} dx
* @param {number} dy
@ -142,7 +142,7 @@ class CellStatePreview {
}
/**
*
*
* @param {CellState} state
* @param {number} dx
* @param {number} dy
@ -189,7 +189,7 @@ class CellStatePreview {
}
/**
*
*
* @param {CellState} state
* @memberof mxCellStatePreview
*/

View File

@ -51,7 +51,7 @@ class TemporaryCellStates {
constructor(
view: GraphView,
scale: number = 1,
scale = 1,
cells: Cell[],
isCellVisibleFn: Function | null = null,
getLinkForCellState: Function | null = null

View File

@ -67,7 +67,7 @@ class VertexHandle implements CellHandle {
constructor(
state: CellState,
cursor: string = 'default',
cursor = 'default',
image: ImageBox | null = null,
shape: Shape | null = null
) {

View File

@ -72,7 +72,7 @@ class EventObject {
/**
* Holds the consumed state. Default is false.
*/
consumed: boolean = false;
consumed = false;
/**
* Returns <name>.

View File

@ -460,11 +460,7 @@ class InternalEvent {
* @param {boolean} [stopPropagation=true] Option boolean to stop event propagation. Default is
* true.
*/
static consume(
evt: Event,
preventDefault: boolean = true,
stopPropagation: boolean = true
) {
static consume(evt: Event, preventDefault = true, stopPropagation = true) {
if (preventDefault) {
if (evt.preventDefault) {
if (stopPropagation) {

View File

@ -49,7 +49,7 @@ class ActorShape extends Shape {
bounds: Rectangle | null = null,
fill: ColorValue = NONE,
stroke: ColorValue = NONE,
strokeWidth: number = 1
strokeWidth = 1
) {
super();
this.bounds = bounds;

View File

@ -25,7 +25,7 @@ limitations under the License.
* coordinates are given, then the default values for <x> and <y> are used.
*/
class Point {
constructor(x: number = 0, y: number = 0) {
constructor(x = 0, y = 0) {
this.x = x;
this.y = y;
}

View File

@ -28,12 +28,7 @@ import Point from './Point';
* are given then the respective default values are used.
*/
class Rectangle extends Point {
constructor(
x: number = 0,
y: number = 0,
width: number = 0,
height: number = 0
) {
constructor(x = 0, y = 0, width = 0, height = 0) {
super(x, y);
// replace super of mxPoint

View File

@ -804,11 +804,11 @@ class Shape {
addPoints(
c: AbstractCanvas2D,
pts: Point[],
rounded: boolean = false,
rounded = false,
arcSize: number,
close: boolean = false,
close = false,
exclude: number[] = [],
initialMove: boolean = true
initialMove = true
) {
if (pts.length > 0) {
const pe = pts[pts.length - 1];

View File

@ -83,8 +83,8 @@ class ArrowConnectorShape extends Shape {
super.apply(state);
if (this.style && this.style.startSize != null && this.style.endSize != null) {
this.startSize = (<number>this.style.startSize) * 3;
this.endSize = (<number>this.style.endSize) * 3;
this.startSize = <number>this.style.startSize * 3;
this.endSize = <number>this.style.endSize * 3;
}
}

View File

@ -80,7 +80,8 @@ class ConnectorShape extends PolylineShape {
let result = null;
const n = pts.length;
const type: ArrowType | typeof NONE = (source ? this.style.startArrow : this.style.endArrow) || NONE;
const type: ArrowType | typeof NONE =
(source ? this.style.startArrow : this.style.endArrow) || NONE;
let p0 = source ? pts[1] : pts[n - 2];
const pe = source ? pts[0] : pts[n - 1];

View File

@ -79,7 +79,7 @@ class CylinderShape extends Shape {
y: number,
w: number,
h: number,
isForeground: boolean = false
isForeground = false
): void {
const dy = this.getCylinderSize(x, y, w, h);

View File

@ -37,7 +37,7 @@ class ImageShape extends RectangleShape {
imageSrc: string,
fill: ColorValue = '#FFFFFF',
stroke: ColorValue = '#000000',
strokeWidth: number = 1
strokeWidth = 1
) {
super(bounds, fill, stroke, strokeWidth);

View File

@ -17,11 +17,7 @@ limitations under the License.
*/
import Rectangle from '../Rectangle';
import {
ALIGN,
DEFAULT_IMAGESIZE,
NONE,
} from '../../../util/Constants';
import { ALIGN, DEFAULT_IMAGESIZE, NONE } from '../../../util/Constants';
import RectangleShape from './RectangleShape';
import { ColorValue } from '../../../types';
import AbstractCanvas2D from '../../canvas/AbstractCanvas2D';

View File

@ -16,11 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {
LINE_ARCSIZE,
NONE,
RECTANGLE_ROUNDING_FACTOR,
} from '../../../util/Constants';
import { LINE_ARCSIZE, NONE, RECTANGLE_ROUNDING_FACTOR } from '../../../util/Constants';
import Shape from '../Shape';
import AbstractCanvas2D from '../../canvas/AbstractCanvas2D';
import Rectangle from '../Rectangle';
@ -33,12 +29,7 @@ import { ColorValue } from '../../../types';
* @extends {Shape}
*/
class RectangleShape extends Shape {
constructor(
bounds: Rectangle,
fill: ColorValue,
stroke: ColorValue,
strokeWidth: number = 1
) {
constructor(bounds: Rectangle, fill: ColorValue, stroke: ColorValue, strokeWidth = 1) {
super();
this.bounds = bounds;
this.fill = fill;

View File

@ -29,7 +29,7 @@ import AbstractCanvas2D from '../../canvas/AbstractCanvas2D';
* @extends {Shape}
*/
class RhombusShape extends Shape {
constructor(bounds: Rectangle, fill: string, stroke: string, strokewidth: number = 1) {
constructor(bounds: Rectangle, fill: string, stroke: string, strokewidth = 1) {
super();
this.bounds = bounds;
this.fill = fill;

View File

@ -184,7 +184,7 @@ class StencilShape extends Shape {
let result = node.getAttribute(attribute);
if (!result) {
const text = getTextContent(<Text><unknown>node);
const text = getTextContent(<Text>(<unknown>node));
if (text && StencilShape.allowEval) {
const funct = eval(text);

View File

@ -51,7 +51,7 @@ class SwimlaneShape extends Shape {
}
/**
* Default imagewidth and imageheight if an image but no imagewidth
* Default imagewidth and imageheight if an image but no imagewidth
* and imageheight are defined in the style. Value is 16.
* @type {number}
* @default 16

View File

@ -38,11 +38,7 @@ import AbstractCanvas2D from '../../canvas/AbstractCanvas2D';
import Shape from '../Shape';
import Rectangle from '../Rectangle';
import CellState from '../../cell/CellState';
import {
htmlEntities,
replaceTrailingNewlines,
trim,
} from '../../../util/StringUtils';
import { htmlEntities, replaceTrailingNewlines, trim } from '../../../util/StringUtils';
import { isNode } from '../../../util/domUtils';
import {
AlignValue,
@ -407,9 +403,10 @@ class TextShape extends Shape {
*/
getAutoDirection() {
// Looks for strong (directional) characters
const tmp = /[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(
String(this.value)
);
const tmp =
/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(
String(this.value)
);
// Returns the direction defined by the character
return tmp && tmp.length > 0 && tmp[0] > 'z'

View File

@ -189,7 +189,7 @@ class CellEditorHandler implements GraphPlugin {
zoomHandler: () => void;
clearOnChange: boolean = false;
clearOnChange = false;
bounds: Rectangle | null = null;
@ -224,21 +224,21 @@ class CellEditorHandler implements GraphPlugin {
* Specifies if the label has been modified.
*/
// modified: boolean;
modified: boolean = false;
modified = false;
/**
* Specifies if the textarea should be resized while the text is being edited.
* Default is true.
*/
// autoSize: boolean;
autoSize: boolean = true;
autoSize = true;
/**
* Specifies if the text should be selected when editing starts. Default is
* true.
*/
// selectText: boolean;
selectText: boolean = true;
selectText = true;
/**
* Text to be displayed for empty labels. Default is '' or '<br>' in Firefox as
@ -256,7 +256,7 @@ class CellEditorHandler implements GraphPlugin {
* editing on Shift+Escape instead. Default is true.
*/
// escapeCancelsEditing: boolean;
escapeCancelsEditing: boolean = true;
escapeCancelsEditing = true;
/**
* Reference to the label DOM node that has been hidden.
@ -268,7 +268,7 @@ class CellEditorHandler implements GraphPlugin {
* Specifies the zIndex for the textarea. Default is 5.
*/
// zIndex: number;
zIndex: number = 5;
zIndex = 5;
/**
* Defines the minimum width and height to be used in <resize>. Default is 0x20px.
@ -281,13 +281,13 @@ class CellEditorHandler implements GraphPlugin {
* 11 and 1 in all other browsers and modes.
*/
// wordWrapPadding: 2 | 1 | 0;
wordWrapPadding: number = 0;
wordWrapPadding = 0;
/**
* If <focusLost> should be called if <textarea> loses the focus. Default is false.
*/
// blurEnabled: boolean;
blurEnabled: boolean = false;
blurEnabled = false;
/**
* Holds the initial editing value to check if the current value was modified.
@ -852,7 +852,7 @@ class CellEditorHandler implements GraphPlugin {
/**
* Stops the editor and applies the value if cancel is false.
*/
stopEditing(cancel: boolean = false) {
stopEditing(cancel = false) {
if (this.editingCell) {
if (this.textNode) {
this.textNode.style.visibility = 'visible';

View File

@ -1412,7 +1412,7 @@ class ConnectionHandler extends EventSource implements GraphPlugin {
}
// Scales and translates the waypoints to the model
let realPoints = [];
const realPoints = [];
for (let i = 0; i < this.waypoints.length; i += 1) {
const pt = this.waypoints[i].clone();

View File

@ -91,10 +91,7 @@ class ConstraintHandler {
// Adds a graph model listener to update the current focus on changes
this.resetHandler = () => {
if (
this.currentFocus &&
!this.graph.view.getState(this.currentFocus.cell)
) {
if (this.currentFocus && !this.graph.view.getState(this.currentFocus.cell)) {
this.reset();
} else {
this.redraw();
@ -221,11 +218,7 @@ class ConstraintHandler {
let cell = me.getCell();
// Gets cell under actual point if different from event location
if (
!cell &&
point &&
(me.getGraphX() !== point.x || me.getGraphY() !== point.y)
) {
if (!cell && point && (me.getGraphX() !== point.x || me.getGraphY() !== point.y)) {
cell = this.graph.getCellAt(point.x, point.y);
}
@ -257,7 +250,7 @@ class ConstraintHandler {
) {
if (this.isEnabled() && !this.isEventIgnored(me)) {
// Lazy installation of mouseleave handler
if (!this.mouseleaveHandler && this.graph.container ) {
if (!this.mouseleaveHandler && this.graph.container) {
this.mouseleaveHandler = () => {
this.reset();
};
@ -266,7 +259,7 @@ class ConstraintHandler {
}
const tol = this.getTolerance(me);
const x = point ? point.x : me.getGraphX();
const x = point ? point.x : me.getGraphX();
const y = point ? point.y : me.getGraphY();
const grid = new Rectangle(x - tol, y - tol, 2 * tol, 2 * tol);
const mouse = new Rectangle(
@ -282,7 +275,7 @@ class ConstraintHandler {
if (
!this.isKeepFocusEvent(me) &&
(!this.currentFocusArea ||
!this.currentFocus ||
!this.currentFocus ||
state ||
!this.currentFocus.cell.isVertex() ||
!intersects(this.currentFocusArea, mouse)) &&
@ -301,8 +294,8 @@ class ConstraintHandler {
if (
this.focusIcons.length > 0 &&
this.constraints &&
(!state || this.currentFocus === state)
this.constraints &&
(!state || this.currentFocus === state)
) {
const cx = mouse.getCenterX();
const cy = mouse.getCenterY();
@ -314,7 +307,7 @@ class ConstraintHandler {
if (
(this.intersects(this.focusIcons[i], mouse, source, existingEdge) ||
(point &&
(point &&
this.intersects(this.focusIcons[i], grid, source, existingEdge))) &&
(minDistSq === null || tmp < minDistSq)
) {
@ -336,7 +329,7 @@ class ConstraintHandler {
this.focusHighlight = hl;
const getState = () => {
return this.currentFocus ? this.currentFocus : state;
return this.currentFocus ? this.currentFocus : state;
};
InternalEvent.redirectMouseEvents(hl.node, this.graph, getState);
@ -364,11 +357,7 @@ class ConstraintHandler {
* are ignored.
*/
redraw() {
if (
this.currentFocus &&
this.constraints &&
this.focusIcons.length > 0
) {
if (this.currentFocus && this.constraints && this.focusIcons.length > 0) {
const state = this.graph.view.getState(this.currentFocus.cell) as CellState;
this.currentFocus = state;
this.currentFocusArea = new Rectangle(state.x, state.y, state.width, state.height);
@ -439,7 +428,7 @@ class ConstraintHandler {
}
const getState = () => {
return this.currentFocus ? this.currentFocus : state;
return this.currentFocus ? this.currentFocus : state;
};
icon.redraw();

View File

@ -43,11 +43,7 @@ import {
intersects,
ptSegDistSq,
} from '../../util/mathUtils';
import {
convertPoint,
getOffset,
setOpacity,
} from '../../util/styleUtils';
import { convertPoint, getOffset, setOpacity } from '../../util/styleUtils';
import ImageShape from '../geometry/node/ImageShape';
import RectangleShape from '../geometry/node/RectangleShape';
import ConnectionConstraint from '../other/ConnectionConstraint';
@ -241,9 +237,9 @@ class EdgeHandler {
index: number | null = null;
isSource: boolean = false;
isSource = false;
isTarget: boolean = false;
isTarget = false;
label: Point;
@ -970,12 +966,12 @@ class EdgeHandler {
* Hook for subclassers do show details while the handler is active.
*/
updateHint(me: InternalMouseEvent, point: Point) { }
updateHint(me: InternalMouseEvent, point: Point) {}
/**
* Hooks for subclassers to hide details when the handler gets inactive.
*/
removeHint() { }
removeHint() {}
/**
* Hook for rounding the unscaled width or height. This uses Math.round.
@ -1515,7 +1511,7 @@ class EdgeHandler {
// Ignores event if mouse has not been moved
if (me.getX() !== this.startX || me.getY() !== this.startY) {
let clone =
const clone =
!this.graph.isIgnoreTerminalEvent(me.getEvent()) &&
this.graph.isCloneEvent(me.getEvent()) &&
this.cloneEnabled &&
@ -2105,7 +2101,9 @@ class EdgeHandler {
* Returns true if the given custom handle is visible.
*/
isCustomHandleVisible(handle: CellHandle) {
return !this.graph.isEditing() && (<Graph>this.state.view.graph).getSelectionCount() === 1;
return (
!this.graph.isEditing() && (<Graph>this.state.view.graph).getSelectionCount() === 1
);
}
/**

View File

@ -17,12 +17,7 @@ limitations under the License.
*/
import EdgeHandler from './EdgeHandler';
import {
CURSOR,
EDGESTYLE,
ELBOW,
HANDLE_SIZE,
} from '../../util/Constants';
import { CURSOR, EDGESTYLE, ELBOW, HANDLE_SIZE } from '../../util/Constants';
import InternalEvent from '../event/InternalEvent';
import Point from '../geometry/Point';
import Translations from '../../util/Translations';
@ -191,9 +186,9 @@ class ElbowEdgeHandler extends EdgeHandler {
} else {
pt = new Point(
this.graph.getView().scale *
(pt.x + this.graph.getView().translate.x + this.state.origin.x),
(pt.x + this.graph.getView().translate.x + this.state.origin.x),
this.graph.getView().scale *
(pt.y + this.graph.getView().translate.y + this.state.origin.y)
(pt.y + this.graph.getView().translate.y + this.state.origin.y)
);
}

View File

@ -19,7 +19,13 @@ limitations under the License.
import { Graph } from '../Graph';
import InternalEvent from '../event/InternalEvent';
import { isAncestorNode } from '../../util/domUtils';
import { getSource, isAltDown, isConsumed, isControlDown as _isControlDown, isShiftDown } from '../../util/EventUtils';
import {
getSource,
isAltDown,
isConsumed,
isControlDown as _isControlDown,
isShiftDown,
} from '../../util/EventUtils';
import CellEditorHandler from './CellEditorHandler';
/**
@ -80,12 +86,12 @@ import CellEditorHandler from './CellEditorHandler';
* event listener is installed.
*/
class KeyHandler {
constructor(graph: Graph, target: Element | null=null) {
constructor(graph: Graph, target: Element | null = null) {
if (graph != null) {
this.graph = graph;
this.target = target || document.documentElement;
this.keydownHandler = evt => {
this.keydownHandler = (evt) => {
this.keyDown(evt);
};
@ -238,12 +244,13 @@ class KeyHandler {
// Accepts events from the target object or
// in-place editing inside graph
const cellEditor = this.graph?.getPlugin('CellEditorHandler') as CellEditorHandler | null;
const cellEditor = this.graph?.getPlugin(
'CellEditorHandler'
) as CellEditorHandler | null;
if (
source === this.target ||
source.parentNode === this.target ||
cellEditor != null &&
cellEditor.isEventSource(evt)
(cellEditor != null && cellEditor.isEventSource(evt))
) {
return true;
}

View File

@ -86,7 +86,7 @@ class RubberBandHandler implements GraphPlugin {
gestureHandler: Function;
graph: Graph;
first: Point | null = null;
destroyed: boolean = false;
destroyed = false;
dragHandler: ((evt: MouseEvent) => void) | null = null;
dropHandler: ((evt: MouseEvent) => void) | null = null;
@ -98,7 +98,7 @@ class RubberBandHandler implements GraphPlugin {
/**
* Specifies the default opacity to be used for the rubberband div. Default is 20.
*/
defaultOpacity: number = 20;
defaultOpacity = 20;
/**
* Specifies if events are handled. Default is true.

View File

@ -83,7 +83,7 @@ class VertexHandler {
* Specifies if only one sizer handle at the bottom, right corner should be
* used. Default is false.
*/
singleSizer: boolean = false;
singleSizer = false;
/**
* Holds the index of the current handle.
@ -94,7 +94,7 @@ class VertexHandler {
* Specifies if the bounds of handles should be used for hit-detection in IE or
* if <tolerance> > 0. Default is true.
*/
allowHandleBoundsCheck: boolean = true;
allowHandleBoundsCheck = true;
/**
* Optional {@link Image} to be used as handles. Default is null.
@ -109,69 +109,69 @@ class VertexHandler {
/**
* Optional tolerance for hit-detection in <getHandleForEvent>. Default is 0.
*/
tolerance: number = 0;
tolerance = 0;
/**
* Specifies if a rotation handle should be visible. Default is false.
*/
rotationEnabled: boolean = false;
rotationEnabled = false;
/**
* Specifies if the parent should be highlighted if a child cell is selected.
* Default is false.
*/
parentHighlightEnabled: boolean = false;
parentHighlightEnabled = false;
/**
* Specifies if rotation steps should be "rasterized" depening on the distance
* to the handle. Default is true.
*/
rotationRaster: boolean = true;
rotationRaster = true;
/**
* Specifies the cursor for the rotation handle. Default is 'crosshair'.
*/
rotationCursor: string = 'crosshair';
rotationCursor = 'crosshair';
/**
* Specifies if resize should change the cell in-place. This is an experimental
* feature for non-touch devices. Default is false.
*/
livePreview: boolean = false;
livePreview = false;
/**
* Specifies if the live preview should be moved to the front.
*/
movePreviewToFront: boolean = false;
movePreviewToFront = false;
/**
* Specifies if sizers should be hidden and spaced if the vertex is small.
* Default is false.
*/
manageSizers: boolean = false;
manageSizers = false;
/**
* Specifies if the size of groups should be constrained by the children.
* Default is false.
*/
constrainGroupByChildren: boolean = false;
constrainGroupByChildren = false;
/**
* Vertical spacing for rotation icon. Default is -16.
*/
rotationHandleVSpacing: number = -16;
rotationHandleVSpacing = -16;
/**
* The horizontal offset for the handles. This is updated in <redrawHandles>
* if {@link anageSizers} is true and the sizers are offset horizontally.
*/
horizontalOffset: number = 0;
horizontalOffset = 0;
/**
* The horizontal offset for the handles. This is updated in <redrawHandles>
* if {@link anageSizers} is true and the sizers are offset vertically.
*/
verticalOffset: number = 0;
verticalOffset = 0;
minBounds: Rectangle | null = null;

View File

@ -41,7 +41,7 @@ import Cell from '../cell/Cell';
* radius - Optional radius as an int. Default is 100.
*/
class CircleLayout extends GraphLayout {
constructor(graph: Graph, radius: number = 100) {
constructor(graph: Graph, radius = 100) {
super(graph);
// mxGraphLayout.call(this, graph);
this.radius = radius;
@ -56,31 +56,31 @@ class CircleLayout extends GraphLayout {
* Boolean specifying if the circle should be moved to the top,
* left corner specified by <x0> and <y0>. Default is false.
*/
moveCircle: boolean = false;
moveCircle = false;
/**
* Integer specifying the left coordinate of the circle.
* Default is 0.
*/
x0: number = 0;
x0 = 0;
/**
* Integer specifying the top coordinate of the circle.
* Default is 0.
*/
y0: number = 0;
y0 = 0;
/**
* Specifies if all edge points of traversed edges should be removed.
* Default is true.
*/
resetEdges: boolean = true;
resetEdges = true;
/**
* Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are
* modified by the result. Default is true.
*/
disableEdgeStyle: boolean = true;
disableEdgeStyle = true;
/**
* Implements {@link GraphLayout#execute}.

View File

@ -70,7 +70,7 @@ export interface _mxCompactTreeLayoutLine {
* ```
*/
export class CompactTreeLayout extends GraphLayout {
constructor(graph: Graph, horizontal: boolean = true, invert: boolean = false) {
constructor(graph: Graph, horizontal = true, invert = false) {
super(graph);
this.horizontal = horizontal;
this.invert = invert;
@ -84,20 +84,20 @@ export class CompactTreeLayout extends GraphLayout {
* Specifies the orientation of the layout.
* @default true
*/
horizontal: boolean = true;
horizontal = true;
/**
* Specifies if edge directions should be inverted.
* @default false.
*/
invert: boolean = false;
invert = false;
/**
* If the parents should be resized to match the width/height of the
* children. Default is true.
* @default true
*/
resizeParent: boolean = true;
resizeParent = true;
/**
* Specifies if the parent location should be maintained, so that the
@ -105,37 +105,37 @@ export class CompactTreeLayout extends GraphLayout {
* the layout. Default is false for backwards compatibility.
* @default false
*/
maintainParentLocation: boolean = false;
maintainParentLocation = false;
/**
* Padding added to resized parents.
* @default 10
*/
groupPadding: number = 10;
groupPadding = 10;
/**
* Top padding added to resized parents.
* @default 0
*/
groupPaddingTop: number = 0;
groupPaddingTop = 0;
/**
* Right padding added to resized parents.
* @default 0
*/
groupPaddingRight: number = 0;
groupPaddingRight = 0;
/**
* Bottom padding added to resized parents.
* @default 0
*/
groupPaddingBottom: number = 0;
groupPaddingBottom = 0;
/**
* Left padding added to resized parents.
* @default 0
*/
groupPaddingLeft: number = 0;
groupPaddingLeft = 0;
/**
* A set of the parents that need updating based on children
@ -148,64 +148,64 @@ export class CompactTreeLayout extends GraphLayout {
* if it is inside a top-level layer.
* @default false
*/
moveTree: boolean = false;
moveTree = false;
/**
* Holds the levelDistance.
* @default 10
*/
levelDistance: number = 10;
levelDistance = 10;
/**
* Holds the nodeDistance.
* @default 20
*/
nodeDistance: number = 20;
nodeDistance = 20;
/**
* Specifies if all edge points of traversed edges should be removed.
*
* @default true
*/
resetEdges: boolean = true;
resetEdges = true;
/**
* The preferred horizontal distance between edges exiting a vertex.
*/
prefHozEdgeSep: number = 5;
prefHozEdgeSep = 5;
/**
* The preferred vertical offset between edges exiting a vertex.
*/
prefVertEdgeOff: number = 4;
prefVertEdgeOff = 4;
/**
* The minimum distance for an edge jetty from a vertex.
*/
minEdgeJetty: number = 8;
minEdgeJetty = 8;
/**
* The size of the vertical buffer in the center of inter-rank channels
* where edge control points should not be placed.
*/
channelBuffer: number = 4;
channelBuffer = 4;
/**
* Whether or not to apply the internal tree edge routing.
*/
edgeRouting: boolean = true;
edgeRouting = true;
/**
* Specifies if edges should be sorted according to the order of their
* opposite terminal cell in the model.
*/
sortEdges: boolean = false;
sortEdges = false;
/**
* Whether or not the tops of cells in each rank should be aligned
* across the rank
*/
alignRanks: boolean = false;
alignRanks = false;
/**
* An array of the maximum height of cells (relative to the layout direction)
@ -869,7 +869,7 @@ export class CompactTreeLayout extends GraphLayout {
* at the given node.
*/
createLine(dx: number, dy: number, next: any = null): _mxCompactTreeLayoutLine {
let line: _mxCompactTreeLayoutLine = {
const line: _mxCompactTreeLayoutLine = {
dx,
dy,
next,

View File

@ -44,22 +44,22 @@ class MxFastOrganicLayout extends GraphLayout {
/**
* Specifies if the top left corner of the input cells should be the origin of the layout result. Default is true.
*/
useInputOrigin: boolean = true;
useInputOrigin = true;
/**
* Specifies if all edge points of traversed edges should be removed. Default is true.
*/
resetEdges: boolean = true;
resetEdges = true;
/**
* Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are modified by the result. Default is true.
*/
disableEdgeStyle: boolean = true;
disableEdgeStyle = true;
/**
* The force constant by which the attractive forces are divided and the replusive forces are multiple by the square of. The value equates to the average radius there is of free space around each node. Default is 50.
*/
forceConstant: number = 50;
forceConstant = 50;
/**
* Cache of <forceConstant>^2 for performance.
@ -69,38 +69,38 @@ class MxFastOrganicLayout extends GraphLayout {
/**
* Minimal distance limit. Default is 2. Prevents of dividing by zero.
*/
minDistanceLimit: number = 2;
minDistanceLimit = 2;
/**
* Maximal distance limit. Default is 500. Prevents of
* dividing by zero.
*/
maxDistanceLimit: number = 500;
maxDistanceLimit = 500;
/**
* Cached version of minDistanceLimit squared.
*/
minDistanceLimitSquared: number = 4;
minDistanceLimitSquared = 4;
/**
* Start value of temperature. Default is 200.
*/
initialTemp: number = 200;
initialTemp = 200;
/**
* Temperature to limit displacement at later stages of layout.
*/
temperature: number = 0;
temperature = 0;
/**
* Total number of iterations to run the layout though.
*/
maxIterations: number = 0;
maxIterations = 0;
/**
* Current iteration count.
*/
iteration: number = 0;
iteration = 0;
/**
* An array of all vertices to be laid out.

View File

@ -51,7 +51,7 @@ class GraphLayout {
* Boolean indicating if the bounding box of the label should be used if
* its available. Default is true.
*/
useBoundingBox: boolean = true;
useBoundingBox = true;
/**
* The parent cell of the layout, if any
@ -142,7 +142,7 @@ class GraphLayout {
* null for the first step of the traversal.
* @param visited Optional {@link Dictionary} of cell paths for the visited cells.
*/
traverse({vertex, directed, func, edge, visited}: GraphLayoutTraverseArgs): void {
traverse({ vertex, directed, func, edge, visited }: GraphLayoutTraverseArgs): void {
if (func != null && vertex != null) {
directed = directed != null ? directed : true;
visited = visited || new Dictionary();
@ -166,7 +166,7 @@ class GraphLayout {
directed,
func,
edge: e,
visited
visited,
});
}
}

View File

@ -48,7 +48,7 @@ class HierarchicalLayout extends GraphLayout {
constructor(
graph: Graph,
orientation: DIRECTION = DIRECTION.NORTH,
deterministic: boolean = true
deterministic = true
) {
super(graph);
this.orientation = orientation;
@ -68,47 +68,47 @@ class HierarchicalLayout extends GraphLayout {
* Specifies if the parent should be resized after the layout so that it
* contains all the child cells. Default is false. See also <parentBorder>.
*/
resizeParent: boolean = false;
resizeParent = false;
/**
* Specifies if the parent location should be maintained, so that the
* top, left corner stays the same before and after execution of
* the layout. Default is false for backwards compatibility.
*/
maintainParentLocation: boolean = false;
maintainParentLocation = false;
/**
* Specifies if the parent should be moved if <resizeParent> is enabled.
* Default is false.
*/
moveParent: boolean = false;
moveParent = false;
/**
* The border to be added around the children if the parent is to be
* resized using <resizeParent>. Default is 0.
*/
parentBorder: number = 0;
parentBorder = 0;
/**
* The spacing buffer added between cells on the same layer. Default is 30.
*/
intraCellSpacing: number = 30;
intraCellSpacing = 30;
/**
* The spacing buffer added between cell on adjacent layers. Default is 100.
*/
interRankCellSpacing: number = 100;
interRankCellSpacing = 100;
/**
* The spacing buffer between unconnected hierarchies. Default is 60.
*/
interHierarchySpacing: number = 60;
interHierarchySpacing = 60;
/**
* The distance between each parallel edge on each ranks for long edges.
* Default is 10.
*/
parallelEdgeSpacing: number = 10;
parallelEdgeSpacing = 10;
/**
* The position of the root node(s) relative to the laid out graph in.
@ -120,19 +120,19 @@ class HierarchicalLayout extends GraphLayout {
* Whether or not to perform local optimisations and iterate multiple times
* through the algorithm. Default is true.
*/
fineTuning: boolean = true;
fineTuning = true;
/**
* Whether or not to tighten the assigned ranks of vertices up towards
* the source cells. Default is true.
*/
tightenToSource: boolean = true;
tightenToSource = true;
/**
* Specifies if the STYLE_NOEDGESTYLE flag should be set on edges that are
* modified by the result. Default is true.
*/
disableEdgeStyle: boolean = true;
disableEdgeStyle = true;
/**
* Whether or not to drill into child cells and layout in reverse
@ -140,7 +140,7 @@ class HierarchicalLayout extends GraphLayout {
* terminal vertices have different parents but are in the same
* ancestry chain. Default is true.
*/
traverseAncestors: boolean = true;
traverseAncestors = true;
/**
* The internal <GraphHierarchyModel> formed of the layout.
@ -453,7 +453,7 @@ class HierarchicalLayout extends GraphLayout {
hierarchyVertices: hierarchyVertices,
filledVertexSet: filledVertexSet,
func: null,
visited: null
visited: null,
});
}
@ -488,7 +488,7 @@ class HierarchicalLayout extends GraphLayout {
hierarchyVertices: hierarchyVertices,
filledVertexSet: null,
func: null,
visited: null
visited: null,
});
}
}
@ -610,7 +610,7 @@ class HierarchicalLayout extends GraphLayout {
allVertices,
currentComp,
hierarchyVertices,
filledVertexSet
filledVertexSet,
}: HierarchicalGraphLayoutTraverseArgs) {
if (vertex != null && allVertices != null) {
// Has this vertex been seen before in any traversal
@ -677,7 +677,7 @@ class HierarchicalLayout extends GraphLayout {
hierarchyVertices,
filledVertexSet,
func: null,
visited: null
visited: null,
});
}
}

View File

@ -356,7 +356,7 @@ class LayoutManager extends EventSource {
/**
* Executes all layouts which have been scheduled during the changes.
*/
layoutCells(cells: Cell[], bubble: boolean = false) {
layoutCells(cells: Cell[], bubble = false) {
if (cells.length > 0) {
// Invokes the layouts while removing duplicates
const model = this.getGraph().getDataModel();
@ -382,7 +382,7 @@ class LayoutManager extends EventSource {
/**
* Executes the given layout on the given parent.
*/
executeLayout(cell: Cell, bubble: boolean = false) {
executeLayout(cell: Cell, bubble = false) {
const layout = this.getLayout(
cell,
bubble ? InternalEvent.BEGIN_UPDATE : InternalEvent.END_UPDATE

View File

@ -72,13 +72,13 @@ class ParallelEdgeLayout extends GraphLayout {
/**
* Defines the spacing between the parallels. Default is 20.
*/
spacing: number = 20;
spacing = 20;
/**
* Specifies if only overlapping edges should be considered
* parallel. Default is false.
*/
checkOverlap: boolean = false;
checkOverlap = false;
/**
* Implements {@link GraphLayout#execute}.

View File

@ -38,12 +38,7 @@ import Cell from '../cell/Cell';
* @class
*/
class PartitionLayout extends GraphLayout {
constructor(
graph: Graph,
horizontal: boolean = true,
spacing: number = 0,
border: number = 0
) {
constructor(graph: Graph, horizontal = true, spacing = 0, border = 0) {
super(graph);
this.horizontal = horizontal != null ? horizontal : true;
this.spacing = spacing || 0;
@ -71,7 +66,7 @@ class PartitionLayout extends GraphLayout {
/**
* Boolean that specifies if vertices should be resized. Default is true.
*/
resizeVertices: boolean = true;
resizeVertices = true;
/**
* Returns <horizontal>.

View File

@ -19,7 +19,7 @@ limitations under the License.
import {
CompactTreeLayout,
_mxCompactTreeLayoutLine,
_mxCompactTreeLayoutNode
_mxCompactTreeLayoutNode,
} from './CompactTreeLayout';
import Cell from '../cell/Cell';
import { Graph } from '../Graph';
@ -46,44 +46,44 @@ class RadialTreeLayout extends CompactTreeLayout {
* The initial offset to compute the angle position.
* @default 0.5
*/
angleOffset: number = 0.5;
angleOffset = 0.5;
/**
* The X co-ordinate of the root cell
* @default 0
*/
rootx: number = 0;
rootx = 0;
/**
* The Y co-ordinate of the root cell
* @default 0
*/
rooty: number = 0;
rooty = 0;
/**
* Holds the levelDistance.
* @default 120
*/
levelDistance: number = 120;
levelDistance = 120;
/**
* Holds the nodeDistance.
* @default 10
*/
nodeDistance: number = 10;
nodeDistance = 10;
/**
* Specifies if the radios should be computed automatically
* @default false
*/
autoRadius: boolean = false;
autoRadius = false;
/**
* Specifies if edges should be sorted according to the order of their
* opposite terminal cell in the model.
* @default false
*/
sortEdges: boolean = false;
sortEdges = false;
/**
* Array of leftmost x coordinate of each row
@ -230,8 +230,12 @@ class RadialTreeLayout extends CompactTreeLayout {
const vertexBounds = this.getVertexBounds(<Cell>node.cell);
this.setVertexLocation(
<Cell>node.cell,
this.centerX - vertexBounds.width / 2 + this.rowRadi[i] * Math.cos(<number>node.theta),
this.centerY - vertexBounds.height / 2 + this.rowRadi[i] * Math.sin(<number>node.theta)
this.centerX -
vertexBounds.width / 2 +
this.rowRadi[i] * Math.cos(<number>node.theta),
this.centerY -
vertexBounds.height / 2 +
this.rowRadi[i] * Math.sin(<number>node.theta)
);
}
}

View File

@ -82,52 +82,52 @@ class StackLayout extends GraphLayout {
/**
* Border to be added if fill is true.
*/
border: number = 0;
border = 0;
/**
* Top margin for the child area.
*/
marginTop: number = 0;
marginTop = 0;
/**
* Top margin for the child area.
*/
marginLeft: number = 0;
marginLeft = 0;
/**
* Top margin for the child area.
*/
marginRight: number = 0;
marginRight = 0;
/**
* Top margin for the child area.
*/
marginBottom: number = 0;
marginBottom = 0;
/**
* Boolean indicating if the location of the first cell should be kept, that is, it will not be moved to x0 or y0.
*/
keepFirstLocation: boolean = false;
keepFirstLocation = false;
/**
* Boolean indicating if dimension should be changed to fill out the parent cell.
*/
fill: boolean = false;
fill = false;
/**
* If the parent should be resized to match the width/height of the stack.
*/
resizeParent: boolean = false;
resizeParent = false;
/**
* Use maximum of existing value and new value for resize of parent.
*/
resizeParentMax: boolean = false;
resizeParentMax = false;
/**
* If the last element should be resized to fill out the parent.
*/
resizeLast: boolean = false;
resizeLast = false;
/**
* Value at which a new column or row should be created.
@ -137,17 +137,17 @@ class StackLayout extends GraphLayout {
/**
* If the strokeWidth should be ignored.
*/
borderCollapse: boolean = true;
borderCollapse = true;
/**
* If gaps should be allowed in the stack.
*/
allowGaps: boolean = false;
allowGaps = false;
/**
* Grid size for alignment of position and size.
*/
gridSize: number = 0;
gridSize = 0;
/**
* Returns horizontal.

View File

@ -47,11 +47,7 @@ import { SwimlaneGraphLayoutTraverseArgs } from './types';
* deterministic. Default is true.
*/
class SwimlaneLayout extends GraphLayout {
constructor(
graph: Graph,
orientation: DIRECTION | null,
deterministic: boolean = true
) {
constructor(graph: Graph, orientation: DIRECTION | null, deterministic = true) {
super(graph);
this.orientation = orientation != null ? orientation : DIRECTION.NORTH;
this.deterministic = deterministic != null ? deterministic : true;
@ -589,7 +585,7 @@ class SwimlaneLayout extends GraphLayout {
filledVertexSet,
swimlaneIndex: laneCounter,
func: null,
visited: null
visited: null,
});
}
@ -624,7 +620,7 @@ class SwimlaneLayout extends GraphLayout {
filledVertexSet: null,
swimlaneIndex: i,
func: null,
visited: null
visited: null,
}); // CHECK THIS PARAM!! ====================
}
}
@ -700,7 +696,7 @@ class SwimlaneLayout extends GraphLayout {
* target -
* directed -
*/
getEdgesBetween(source: Cell, target: Cell, directed: boolean = false) {
getEdgesBetween(source: Cell, target: Cell, directed = false) {
const edges = this.getEdges(source);
const result = [];
@ -742,7 +738,7 @@ class SwimlaneLayout extends GraphLayout {
currentComp,
hierarchyVertices,
filledVertexSet,
swimlaneIndex
swimlaneIndex,
}: SwimlaneGraphLayoutTraverseArgs) {
if (vertex != null && allVertices != null) {
// Has this vertex been seen before in any traversal
@ -805,7 +801,7 @@ class SwimlaneLayout extends GraphLayout {
filledVertexSet,
swimlaneIndex: otherIndex,
func: null,
visited: null
visited: null,
});
}
}

View File

@ -33,12 +33,7 @@ import Cell from '../cell/Cell';
* {@link bubbling} is true.
*/
class SwimlaneManager extends EventSource {
constructor(
graph: Graph,
horizontal: boolean = true,
addEnabled: boolean = true,
resizeEnabled: boolean = true
) {
constructor(graph: Graph, horizontal = true, addEnabled = true, resizeEnabled = true) {
super();
this.horizontal = horizontal;

View File

@ -59,7 +59,8 @@ class GraphAbstractHierarchyCell extends Cell {
/**
* A cached version of the cells this cell connects to on the next layer down
*/
previousLayerConnectedCells: { [key: number]: GraphAbstractHierarchyCell[] } | null = null;
previousLayerConnectedCells: { [key: number]: GraphAbstractHierarchyCell[] } | null =
null;
/**
* Temporary variable for general use. Generally, try to avoid

View File

@ -47,7 +47,7 @@ class GraphHierarchyEdge extends GraphAbstractHierarchyCell {
* Whether or not the direction of this edge has been reversed
* internally to create a DAG for the hierarchical layout
*/
isReversed: boolean = false;
isReversed = false;
/**
* Class: mxGraphHierarchyEdge

View File

@ -53,11 +53,11 @@ import SwimlaneLayout from '../SwimlaneLayout';
class CoordinateAssignment extends HierarchicalLayoutStage {
constructor(
layout: HierarchicalLayout | SwimlaneLayout,
intraCellSpacing: number=30,
interRankCellSpacing: number=100,
intraCellSpacing = 30,
interRankCellSpacing = 100,
orientation: DIRECTION,
initialX: number,
parallelEdgeSpacing: number=10
parallelEdgeSpacing = 10
) {
super();
@ -293,7 +293,8 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const nodeList: WeightedCellSorter[] = [];
// Need to be able to map from cell to cellWrapper
const map: Dictionary<GraphAbstractHierarchyCell, WeightedCellSorter> = new Dictionary();
const map: Dictionary<GraphAbstractHierarchyCell, WeightedCellSorter> =
new Dictionary();
const rank = [];
for (let i = 0; i <= model.maxRank; i += 1) {
@ -322,26 +323,38 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
while (nodeList.length > 0 && count <= maxTries) {
const cellWrapper = <WeightedCellSorter>nodeList.shift();
const cell: GraphAbstractHierarchyCell = <GraphAbstractHierarchyCell>cellWrapper.cell;
const cell: GraphAbstractHierarchyCell = <GraphAbstractHierarchyCell>(
cellWrapper.cell
);
const rankValue = cellWrapper.weightedValue;
const rankIndex = parseInt(String(cellWrapper.rankIndex));
const nextLayerConnectedCells = <GraphAbstractHierarchyCell[]>cell.getNextLayerConnectedCells(rankValue);
const previousLayerConnectedCells = <GraphAbstractHierarchyCell[]>cell.getPreviousLayerConnectedCells(rankValue);
const nextLayerConnectedCells = <GraphAbstractHierarchyCell[]>(
cell.getNextLayerConnectedCells(rankValue)
);
const previousLayerConnectedCells = <GraphAbstractHierarchyCell[]>(
cell.getPreviousLayerConnectedCells(rankValue)
);
const numNextLayerConnected = nextLayerConnectedCells.length;
const numPreviousLayerConnected = previousLayerConnectedCells.length;
const medianNextLevel = this.medianXValue(nextLayerConnectedCells, rankValue + 1);
const medianPreviousLevel = this.medianXValue(previousLayerConnectedCells, rankValue - 1);
const medianPreviousLevel = this.medianXValue(
previousLayerConnectedCells,
rankValue - 1
);
const numConnectedNeighbours = numNextLayerConnected + numPreviousLayerConnected;
const currentPosition = <number>cell.getGeneralPurposeVariable(rankValue);
let cellMedian = <number>currentPosition;
if (numConnectedNeighbours > 0) {
cellMedian = (medianNextLevel * numNextLayerConnected + medianPreviousLevel * numPreviousLayerConnected) / numConnectedNeighbours;
cellMedian =
(medianNextLevel * numNextLayerConnected +
medianPreviousLevel * numPreviousLayerConnected) /
numConnectedNeighbours;
}
// Flag storing whether or not position has changed
@ -354,12 +367,16 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
} else {
const leftCell = rank[rankValue][rankIndex - 1];
let leftLimit = <number>leftCell.getGeneralPurposeVariable(rankValue);
leftLimit = leftLimit + leftCell.width / 2 + this.intraCellSpacing + cell.width / 2;
leftLimit =
leftLimit + leftCell.width / 2 + this.intraCellSpacing + cell.width / 2;
if (leftLimit < cellMedian) {
cell.setGeneralPurposeVariable(rankValue, cellMedian);
positionChanged = true;
} else if (leftLimit < <number>cell.getGeneralPurposeVariable(rankValue) - tolerance) {
} else if (
leftLimit <
<number>cell.getGeneralPurposeVariable(rankValue) - tolerance
) {
cell.setGeneralPurposeVariable(rankValue, leftLimit);
positionChanged = true;
}
@ -373,12 +390,16 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
} else {
const rightCell = rank[rankValue][rankIndex + 1];
let rightLimit = <number>rightCell.getGeneralPurposeVariable(rankValue);
rightLimit = rightLimit - rightCell.width / 2 - this.intraCellSpacing - cell.width / 2;
rightLimit =
rightLimit - rightCell.width / 2 - this.intraCellSpacing - cell.width / 2;
if (rightLimit > cellMedian) {
cell.setGeneralPurposeVariable(rankValue, cellMedian);
positionChanged = true;
} else if (rightLimit > <number>cell.getGeneralPurposeVariable(rankValue) + tolerance) {
} else if (
rightLimit >
<number>cell.getGeneralPurposeVariable(rankValue) + tolerance
) {
cell.setGeneralPurposeVariable(rankValue, rightLimit);
positionChanged = true;
}
@ -477,7 +498,8 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
// Calculate the weighing based on this node type and those this
// node is connected to on the next layer
weightedValues[i].weightedValue = this.calculatedWeightedValue(
currentCell, <GraphAbstractHierarchyCell[]>nextLayerConnectedCells
currentCell,
<GraphAbstractHierarchyCell[]>nextLayerConnectedCells
);
}
weightedValues.sort(WeightedCellSorter.compare);
@ -487,28 +509,21 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
for (let i = 0; i < weightedValues.length; i += 1) {
let numConnectionsNextLevel = 0;
const cell = <GraphHierarchyNode><unknown>weightedValues[i].cell;
const cell = <GraphHierarchyNode>(<unknown>weightedValues[i].cell);
let nextLayerConnectedCells = null;
let medianNextLevel = 0;
if (nextRankValue < rankValue) {
nextLayerConnectedCells = cell
.getPreviousLayerConnectedCells(rankValue)
.slice();
nextLayerConnectedCells = cell.getPreviousLayerConnectedCells(rankValue).slice();
} else {
nextLayerConnectedCells = cell
.getNextLayerConnectedCells(rankValue)
.slice();
nextLayerConnectedCells = cell.getNextLayerConnectedCells(rankValue).slice();
}
if (nextLayerConnectedCells != null) {
numConnectionsNextLevel = nextLayerConnectedCells.length;
if (numConnectionsNextLevel > 0) {
medianNextLevel = this.medianXValue(
nextLayerConnectedCells,
nextRankValue
);
medianNextLevel = this.medianXValue(nextLayerConnectedCells, nextRankValue);
} else {
// For case of no connections on the next level set the
// median to be the current position and try to be
@ -524,7 +539,7 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const weightedValue = cellMap[<string>rank[j].id];
if (weightedValue != null) {
const leftCell = <GraphHierarchyNode><unknown>weightedValue.cell;
const leftCell = <GraphHierarchyNode>(<unknown>weightedValue.cell);
if (weightedValue.visited) {
// The left limit is the right hand limit of that
@ -547,15 +562,11 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
let rightBuffer = 0.0;
let rightLimit = 100000000.0;
for (
let j = <number>weightedValues[i].rankIndex + 1;
j < weightedValues.length;
) {
for (let j = <number>weightedValues[i].rankIndex + 1; j < weightedValues.length; ) {
const weightedValue = cellMap[<string>rank[j].id];
if (weightedValue != null) {
const rightCell = <GraphHierarchyNode><unknown>weightedValue.cell;
const rightCell = <GraphHierarchyNode>(<unknown>weightedValue.cell);
if (weightedValue.visited) {
// The left limit is the right hand limit of that
@ -685,7 +696,8 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const rank = ranks[rankValue];
let maxY = 0.0;
let localX =
this.initialX + (<number>this.widestRankValue - (<number[]>this.rankWidths)[rankValue]) / 2;
this.initialX +
(<number>this.widestRankValue - (<number[]>this.rankWidths)[rankValue]) / 2;
// Store whether or not any of the cells' bounds were unavailable so
// to only issue the warning once for all cells
@ -825,15 +837,10 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
this.rankY[rankValue] = y;
const distanceToNextRank =
maxCellHeight / 2.0 +
lastRankMaxCellHeight / 2.0 +
this.interRankCellSpacing;
maxCellHeight / 2.0 + lastRankMaxCellHeight / 2.0 + this.interRankCellSpacing;
lastRankMaxCellHeight = maxCellHeight;
if (
this.orientation === DIRECTION.NORTH ||
this.orientation === DIRECTION.WEST
) {
if (this.orientation === DIRECTION.NORTH || this.orientation === DIRECTION.WEST) {
y += distanceToNextRank;
} else {
y -= distanceToNextRank;
@ -964,7 +971,12 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
* @param rank the layer of the cell
* @param position the x position being sought
*/
repositionValid(model: GraphHierarchyModel, cell: GraphHierarchyEdge | GraphHierarchyNode, rank: number, position: number) {
repositionValid(
model: GraphHierarchyModel,
cell: GraphHierarchyEdge | GraphHierarchyNode,
rank: number,
position: number
) {
const ranks = <GraphAbstractHierarchyCell[][]>model.ranks;
const rankArray = ranks[rank];
let rankIndex = -1;
@ -991,8 +1003,7 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const leftCell = rankArray[rankIndex - 1];
let leftLimit = <number>leftCell.getGeneralPurposeVariable(rank);
leftLimit =
leftLimit + leftCell.width / 2 + this.intraCellSpacing + cell.width / 2;
leftLimit = leftLimit + leftCell.width / 2 + this.intraCellSpacing + cell.width / 2;
return leftLimit <= position;
}
@ -1005,7 +1016,8 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const rightCell = rankArray[rankIndex + 1];
let rightLimit = <number>rightCell.getGeneralPurposeVariable(rank);
rightLimit = rightLimit - rightCell.width / 2 - this.intraCellSpacing - cell.width / 2;
rightLimit =
rightLimit - rightCell.width / 2 - this.intraCellSpacing - cell.width / 2;
return rightLimit >= position;
}
return true;
@ -1138,8 +1150,7 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
}
}
const requiredWidth =
(connectedEdgeCount + 1) * this.prefHozEdgeSep;
const requiredWidth = (connectedEdgeCount + 1) * this.prefHozEdgeSep;
// Add a buffer on the edges of the vertex if the edge count allows
if (cell.width > requiredWidth + 2 * this.prefHozEdgeSep) {
@ -1212,11 +1223,12 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const jettyPositions = <{ [key: string]: number[] }>this.jettyPositions;
const jettys = jettyPositions[cell.ids[0]];
const source = cell.isReversed ? (<GraphHierarchyNode>cell.target).cell : (<GraphHierarchyNode>cell.source).cell;
const source = cell.isReversed
? (<GraphHierarchyNode>cell.target).cell
: (<GraphHierarchyNode>cell.source).cell;
const { graph } = this.layout;
const layoutReversed =
this.orientation === DIRECTION.EAST ||
this.orientation === DIRECTION.SOUTH;
this.orientation === DIRECTION.EAST || this.orientation === DIRECTION.SOUTH;
for (let i = 0; i < cell.edges.length; i += 1) {
const realEdge = cell.edges[i];
@ -1268,16 +1280,21 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
if (state != null) {
x = state.x;
} else {
x = (<Geometry>(<Cell>realSource).geometry).x + (<GraphHierarchyNode>cell.source).width * (<Geometry>modelSource.geometry).x;
x =
(<Geometry>(<Cell>realSource).geometry).x +
(<GraphHierarchyNode>cell.source).width *
(<Geometry>modelSource.geometry).x;
}
}
if (this.orientation === DIRECTION.NORTH || this.orientation === DIRECTION.SOUTH) {
if (
this.orientation === DIRECTION.NORTH ||
this.orientation === DIRECTION.SOUTH
) {
newPoints.push(new Point(x, y));
if (this.layout.edgeStyle === HierarchicalEdgeStyle.CURVE) {
newPoints.push(new Point(x, y + jetty));
}
} else {
newPoints.push(new Point(y, x));
if (this.layout.edgeStyle === HierarchicalEdgeStyle.CURVE) {
@ -1316,7 +1333,8 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const rankBottomY = <number[]>this.rankBottomY;
let topChannelY = (rankTopY[currentRank] + rankBottomY[currentRank + 1]) / 2.0;
let bottomChannelY = (rankTopY[currentRank - 1] + rankBottomY[currentRank]) / 2.0;
let bottomChannelY =
(rankTopY[currentRank - 1] + rankBottomY[currentRank]) / 2.0;
if (reversed) {
const tmp = topChannelY;
@ -1363,17 +1381,15 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const modelTarget = <Cell>realEdge.getTerminal(false);
const realTarget = <Cell>this.layout.getVisibleTerminal(realEdge, false);
if (
this.layout.isPort(modelTarget) &&
modelTarget.getParent() === realTarget
) {
if (this.layout.isPort(modelTarget) && modelTarget.getParent() === realTarget) {
const state = graph.view.getState(modelTarget);
if (state != null) {
x = state.x;
} else {
x =
(<Geometry>realTarget.geometry).x +
(<GraphHierarchyNode>cell.target).width * (<Geometry>modelTarget.geometry).x;
(<GraphHierarchyNode>cell.target).width *
(<Geometry>modelTarget.geometry).x;
}
}
@ -1385,7 +1401,6 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
newPoints.push(new Point(x, y - jetty));
}
newPoints.push(new Point(x, y));
} else {
if (this.layout.edgeStyle === HierarchicalEdgeStyle.CURVE) {
newPoints.push(new Point(y - jetty, x));
@ -1429,12 +1444,12 @@ class CoordinateAssignment extends HierarchicalLayoutStage {
const rankBottomY = <number[]>this.rankBottomY;
rankTopY[cell.minRank] = Math.min(rankTopY[cell.minRank], positionY);
rankBottomY[cell.minRank] = Math.max(rankBottomY[cell.minRank], positionY + cell.height);
rankBottomY[cell.minRank] = Math.max(
rankBottomY[cell.minRank],
positionY + cell.height
);
if (
this.orientation === DIRECTION.NORTH ||
this.orientation === DIRECTION.SOUTH
) {
if (this.orientation === DIRECTION.NORTH || this.orientation === DIRECTION.SOUTH) {
this.layout.setVertexLocation(realCell, positionX, positionY);
} else {
this.layout.setVertexLocation(realCell, positionY, positionX);

View File

@ -155,18 +155,18 @@ class GraphHierarchyModel {
/**
* Count of the number of times the ancestor dfs has been used.
*/
dfsCount: number = 0;
dfsCount = 0;
/**
* High value to start source layering scan rank value from.
*/
SOURCESCANSTARTRANK: number = 100000000;
SOURCESCANSTARTRANK = 100000000;
/**
* Whether or not to tighten the assigned ranks of vertices up towards
* the source cells.
*/
tightenToSource: boolean = false;
tightenToSource = false;
/**
* Creates all edges in the internal model

View File

@ -195,12 +195,16 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
for (let j = 0; j < rank.length; j += 1) {
const node = rank[j];
const rankPosition = <number>node.getGeneralPurposeVariable(i);
const connectedCells = <GraphAbstractHierarchyCell[]>node.getPreviousLayerConnectedCells(i);
const connectedCells = <GraphAbstractHierarchyCell[]>(
node.getPreviousLayerConnectedCells(i)
);
const nodeIndices = [];
for (let k = 0; k < connectedCells.length; k += 1) {
const connectedNode = connectedCells[k];
const otherCellRankPosition = <number>connectedNode.getGeneralPurposeVariable(i - 1);
const otherCellRankPosition = <number>(
connectedNode.getGeneralPurposeVariable(i - 1)
);
nodeIndices.push(otherCellRankPosition);
}
@ -303,17 +307,25 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
// right cell on the new left cell
if (j === 0) {
leftCell = orderedCells[j];
leftCellAboveConnections = <GraphAbstractHierarchyCell[]>leftCell.getNextLayerConnectedCells(i);
leftCellBelowConnections = <GraphAbstractHierarchyCell[]>leftCell.getPreviousLayerConnectedCells(i);
leftCellAboveConnections = <GraphAbstractHierarchyCell[]>(
leftCell.getNextLayerConnectedCells(i)
);
leftCellBelowConnections = <GraphAbstractHierarchyCell[]>(
leftCell.getPreviousLayerConnectedCells(i)
);
leftAbovePositions = [];
leftBelowPositions = [];
for (let k = 0; k < leftCellAboveConnections.length; k++) {
leftAbovePositions[k] = <number>leftCellAboveConnections[k].getGeneralPurposeVariable(i + 1);
leftAbovePositions[k] = <number>(
leftCellAboveConnections[k].getGeneralPurposeVariable(i + 1)
);
}
for (let k = 0; k < leftCellBelowConnections.length; k++) {
leftBelowPositions[k] = <number>leftCellBelowConnections[k].getGeneralPurposeVariable(i - 1);
leftBelowPositions[k] = <number>(
leftCellBelowConnections[k].getGeneralPurposeVariable(i - 1)
);
}
} else {
leftCellAboveConnections = rightCellAboveConnections;
@ -324,20 +336,26 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
}
rightCell = orderedCells[j + 1];
rightCellAboveConnections = <GraphAbstractHierarchyCell[]>rightCell.getNextLayerConnectedCells(i);
rightCellBelowConnections = <GraphAbstractHierarchyCell[]>rightCell.getPreviousLayerConnectedCells(
i
rightCellAboveConnections = <GraphAbstractHierarchyCell[]>(
rightCell.getNextLayerConnectedCells(i)
);
rightCellBelowConnections = <GraphAbstractHierarchyCell[]>(
rightCell.getPreviousLayerConnectedCells(i)
);
rightAbovePositions = [];
rightBelowPositions = [];
for (let k = 0; k < rightCellAboveConnections.length; k++) {
rightAbovePositions[k] = <number>rightCellAboveConnections[k].getGeneralPurposeVariable(i + 1);
rightAbovePositions[k] = <number>(
rightCellAboveConnections[k].getGeneralPurposeVariable(i + 1)
);
}
for (let k = 0; k < rightCellBelowConnections.length; k++) {
rightBelowPositions[k] = <number>rightCellBelowConnections[k].getGeneralPurposeVariable(i - 1);
rightBelowPositions[k] = <number>(
rightCellBelowConnections[k].getGeneralPurposeVariable(i - 1)
);
}
let totalCurrentCrossings = 0;
@ -371,8 +389,13 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
totalSwitchedCrossings < totalCurrentCrossings ||
(totalSwitchedCrossings === totalCurrentCrossings && nudge)
) {
const temp = <number>(<GraphAbstractHierarchyCell>leftCell).getGeneralPurposeVariable(i);
(<GraphAbstractHierarchyCell>leftCell).setGeneralPurposeVariable(i, <number>rightCell.getGeneralPurposeVariable(i));
const temp = <number>(
(<GraphAbstractHierarchyCell>leftCell).getGeneralPurposeVariable(i)
);
(<GraphAbstractHierarchyCell>leftCell).setGeneralPurposeVariable(
i,
<number>rightCell.getGeneralPurposeVariable(i)
);
rightCell.setGeneralPurposeVariable(i, temp);
// With this pair exchanged we have to switch all of
@ -426,7 +449,9 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
* @param downwardSweep whether or not this is a downward sweep through the graph
*/
medianRank(rankValue: number, downwardSweep: boolean) {
const nestedBestRanks = <{ [key: number]: GraphAbstractHierarchyCell[] }>this.nestedBestRanks;
const nestedBestRanks = <{ [key: number]: GraphAbstractHierarchyCell[] }>(
this.nestedBestRanks
);
const numCellsForRank = nestedBestRanks[rankValue].length;
const medianValues = [];
const reservedPositions: { [key: number]: boolean } = {};
@ -445,9 +470,7 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
if (downwardSweep) {
nextLevelConnectedCells = cell.getNextLayerConnectedCells(rankValue);
} else {
nextLevelConnectedCells = cell.getPreviousLayerConnectedCells(
rankValue
);
nextLevelConnectedCells = cell.getPreviousLayerConnectedCells(rankValue);
}
var nextRankValue;
@ -458,10 +481,7 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
nextRankValue = rankValue - 1;
}
if (
nextLevelConnectedCells != null &&
nextLevelConnectedCells.length !== 0
) {
if (nextLevelConnectedCells != null && nextLevelConnectedCells.length !== 0) {
sorterEntry.medianValue = this.medianValue(
nextLevelConnectedCells,
nextRankValue
@ -480,7 +500,9 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
// its temp variable
for (let i = 0; i < numCellsForRank; i += 1) {
if (reservedPositions[i] == null) {
const cell = <GraphAbstractHierarchyCell>(<MedianCellSorter>medianValues.shift()).cell;
const cell = <GraphAbstractHierarchyCell>(
(<MedianCellSorter>medianValues.shift()).cell
);
cell.setGeneralPurposeVariable(rankValue, i);
}
}
@ -519,8 +541,7 @@ class MedianHybridCrossingReduction extends HierarchicalLayoutStage {
}
const medianPoint = arrayCount / 2;
const leftMedian = medianValues[medianPoint - 1] - medianValues[0];
const rightMedian =
medianValues[arrayCount - 1] - medianValues[medianPoint];
const rightMedian = medianValues[arrayCount - 1] - medianValues[medianPoint];
return (
(medianValues[medianPoint - 1] * rightMedian +

View File

@ -73,7 +73,13 @@ class MinimumCycleRemover extends HierarchicalLayoutStage {
}
model.visit(
(parent: GraphHierarchyNode, node: GraphHierarchyNode, connectingEdge: GraphHierarchyEdge, layer: any, seen: any) => {
(
parent: GraphHierarchyNode,
node: GraphHierarchyNode,
connectingEdge: GraphHierarchyEdge,
layer: any,
seen: any
) => {
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
@ -100,7 +106,13 @@ class MinimumCycleRemover extends HierarchicalLayoutStage {
// Pick a random cell and dfs from it
model.visit(
(parent: GraphHierarchyNode, node: GraphHierarchyNode, connectingEdge: GraphHierarchyEdge, layer: any, seen: any) => {
(
parent: GraphHierarchyNode,
node: GraphHierarchyNode,
connectingEdge: GraphHierarchyEdge,
layer: any,
seen: any
) => {
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell

View File

@ -156,18 +156,18 @@ class SwimlaneModel {
/**
* Count of the number of times the ancestor dfs has been used.
*/
dfsCount: number = 0;
dfsCount = 0;
/**
* High value to start source layering scan rank value from.
*/
SOURCESCANSTARTRANK: number = 100000000;
SOURCESCANSTARTRANK = 100000000;
/**
* Whether or not to tighten the assigned ranks of vertices up towards
* the source cells.
*/
tightenToSource: boolean = false;
tightenToSource = false;
/**
* An array of the number of ranks within each swimlane

View File

@ -70,7 +70,13 @@ class SwimlaneOrdering extends HierarchicalLayoutStage {
}
model.visit(
(parent: GraphHierarchyNode, node: GraphHierarchyNode, connectingEdge: GraphHierarchyEdge, layer: any, seen: any) => {
(
parent: GraphHierarchyNode,
node: GraphHierarchyNode,
connectingEdge: GraphHierarchyEdge,
layer: any,
seen: any
) => {
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell

View File

@ -33,6 +33,7 @@ export interface HierarchicalGraphLayoutTraverseArgs extends GraphLayoutTraverse
filledVertexSet: { [key: string]: Cell } | null;
}
export interface SwimlaneGraphLayoutTraverseArgs extends HierarchicalGraphLayoutTraverseArgs {
export interface SwimlaneGraphLayoutTraverseArgs
extends HierarchicalGraphLayoutTraverseArgs {
swimlaneIndex: number;
}

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import GraphAbstractHierarchyCell from "../datatypes/GraphAbstractHierarchyCell";
import GraphAbstractHierarchyCell from '../datatypes/GraphAbstractHierarchyCell';
/**
* Class: MedianCellSorter
@ -34,7 +34,7 @@ class MedianCellSorter {
/**
* The weighted value of the cell stored.
*/
medianValue: number = 0;
medianValue = 0;
/**
* The cell whose median value is being calculated

View File

@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { _mxCompactTreeLayoutNode } from "../CompactTreeLayout";
import GraphAbstractHierarchyCell from "../datatypes/GraphAbstractHierarchyCell";
import { _mxCompactTreeLayoutNode } from '../CompactTreeLayout';
import GraphAbstractHierarchyCell from '../datatypes/GraphAbstractHierarchyCell';
/**
* @class WeightedCellSorter
@ -26,7 +26,10 @@ import GraphAbstractHierarchyCell from "../datatypes/GraphAbstractHierarchyCell"
*
*/
class WeightedCellSorter {
constructor(cell: _mxCompactTreeLayoutNode | GraphAbstractHierarchyCell, weightedValue: number=0) {
constructor(
cell: _mxCompactTreeLayoutNode | GraphAbstractHierarchyCell,
weightedValue = 0
) {
this.cell = cell;
this.weightedValue = weightedValue;
}
@ -34,17 +37,17 @@ class WeightedCellSorter {
/**
* The weighted value of the cell stored.
*/
weightedValue: number = 0;
weightedValue = 0;
/**
* Whether or not to flip equal weight values.
*/
nudge: boolean = false;
nudge = false;
/**
* Whether or not this cell has been visited in the current assignment.
*/
visited: boolean = false;
visited = false;
/**
* The index this cell is in the model rank.

View File

@ -1378,7 +1378,7 @@ export const CellsMixin: PartialType = {
if (this.isSwimlane(cell)) {
const style = this.getCellStyle(cell);
let cellStyle = cell.getStyle();
const cellStyle = cell.getStyle();
if (style.horizontal ?? true) {
cellStyle.startSize = size.height + 8;

View File

@ -415,7 +415,7 @@ const EdgeMixin: PartialType = {
*/
insertEdge(...args) {
let parent: Cell;
let id: string = '';
let id = '';
let value: any; // note me - can be a string or a class instance!!!
let source: Cell;
let target: Cell;

View File

@ -235,7 +235,9 @@ const EditingMixin: PartialType = {
*/
isCellEditable(cell): boolean {
const style = this.getCurrentCellStyle(cell);
return this.isCellsEditable() && !this.isCellLocked(cell) && (style.editable || false);
return (
this.isCellsEditable() && !this.isCellLocked(cell) && (style.editable || false)
);
},
/**

View File

@ -576,7 +576,10 @@ const EventsMixin: PartialType = {
*/
tapAndHold(me) {
const evt = me.getEvent();
const mxe = new EventObject(InternalEvent.TAP_AND_HOLD, { event: evt, cell: me.getCell() });
const mxe = new EventObject(InternalEvent.TAP_AND_HOLD, {
event: evt,
cell: me.getCell(),
});
const panningHandler = this.getPlugin('PanningHandler') as PanningHandler;
const connectionHandler = this.getPlugin('ConnectionHandler') as ConnectionHandler;
@ -889,8 +892,9 @@ const EventsMixin: PartialType = {
// detect which mouseup(s) are part of the first click, ie we do not know when the first click ends.
if (
(!this.nativeDblClickEnabled && !isPopupTrigger(me.getEvent())) ||
(this.doubleTapEnabled && Client.IS_TOUCH && (isTouchEvent(me.getEvent()) ||
isPenEvent(me.getEvent())))
(this.doubleTapEnabled &&
Client.IS_TOUCH &&
(isTouchEvent(me.getEvent()) || isPenEvent(me.getEvent())))
) {
const currentTime = new Date().getTime();
@ -942,9 +946,10 @@ const EventsMixin: PartialType = {
this.isMouseDown = false;
// Workaround for Chrome/Safari not firing native double click events for double touch on background
const valid = cell ||
((isTouchEvent(me.getEvent()) || isPenEvent(me.getEvent())) &&
(Client.IS_GC || Client.IS_SF));
const valid =
cell ||
((isTouchEvent(me.getEvent()) || isPenEvent(me.getEvent())) &&
(Client.IS_GC || Client.IS_SF));
if (
valid &&
@ -968,11 +973,7 @@ const EventsMixin: PartialType = {
new EventObject(InternalEvent.FIRE_MOUSE_EVENT, { eventName: evtName, event: me })
);
if (
Client.IS_SF ||
Client.IS_GC ||
me.getEvent().target !== this.getContainer()
) {
if (Client.IS_SF || Client.IS_GC || me.getEvent().target !== this.getContainer()) {
const container = this.getContainer();
if (

View File

@ -83,9 +83,7 @@ const OverlaysMixin: PartialType = {
this.getCellRenderer().redraw(state);
}
this.fireEvent(
new EventObject(InternalEvent.ADD_OVERLAY, { cell, overlay })
);
this.fireEvent(new EventObject(InternalEvent.ADD_OVERLAY, { cell, overlay }));
return overlay;
},

View File

@ -129,7 +129,11 @@ const ValidationMixin: PartialType = {
* @param source {@link mxCell} that represents the source terminal.
* @param target {@link mxCell} that represents the target terminal.
*/
getEdgeValidationError(edge: Cell | null=null, source: Cell | null=null, target: Cell | null=null) {
getEdgeValidationError(
edge: Cell | null = null,
source: Cell | null = null,
target: Cell | null = null
) {
if (edge && !this.isAllowDanglingEdges() && (!source || !target)) {
return '';
}
@ -206,7 +210,11 @@ const ValidationMixin: PartialType = {
* @param source {@link mxCell} that represents the source terminal.
* @param target {@link mxCell} that represents the target terminal.
*/
validateEdge(edge: Cell | null=null, source: Cell | null=null, target: Cell | null=null) {
validateEdge(
edge: Cell | null = null,
source: Cell | null = null,
target: Cell | null = null
) {
return null;
},
@ -224,7 +232,7 @@ const ValidationMixin: PartialType = {
* the graph root.
* @param context Object that represents the global validation state.
*/
validateGraph(cell: Cell | null=null, context) {
validateGraph(cell: Cell | null = null, context) {
cell = cell ?? this.getDataModel().getRoot();
if (!cell) {

View File

@ -60,7 +60,7 @@ class AutoSaveManager extends EventSource {
* value of 1 (s) means the graph is not stored more than once per second.
* Default is 10.
*/
autoSaveDelay: number = 10;
autoSaveDelay = 10;
/**
* Minimum amount of seconds between two consecutive autosaves triggered by
@ -69,29 +69,29 @@ class AutoSaveManager extends EventSource {
* stored more than once per second even if there are more than
* <autoSaveThreshold> changes within that timespan. Default is 2.
*/
autoSaveThrottle: number = 2;
autoSaveThrottle = 2;
/**
* Minimum amount of ignored changes before an autosave. Eg. a value of 2
* means after 2 change of the graph model the autosave will trigger if the
* condition below is true. Default is 5.
*/
autoSaveThreshold: number = 5;
autoSaveThreshold = 5;
/**
* Counter for ignored changes in autosave.
*/
ignoredChanges: number = 0;
ignoredChanges = 0;
/**
* Used for autosaving. See <autosave>.
*/
lastSnapshot: number = 0;
lastSnapshot = 0;
/**
* Specifies if event handling is enabled. Default is true.
*/
enabled: boolean = true;
enabled = true;
/**
* Holds the function that handles graph model changes.

View File

@ -51,7 +51,7 @@ class Multiplicity {
validNeighbors: string[],
countError: string,
typeError: string,
validNeighborsAllowed: boolean = true
validNeighborsAllowed = true
) {
this.source = source;
this.type = type;
@ -115,7 +115,7 @@ class Multiplicity {
* 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 = true;
validNeighborsAllowed = true;
/**
* Holds the localized error message to be displayed if the number of

View File

@ -219,7 +219,7 @@ class Outline {
bounds: Rectangle | null = null;
zoom: boolean = false;
zoom = false;
startX: number | null = null;
@ -245,44 +245,44 @@ class Outline {
* Renderhint to be used for the outline graph.
* @default faster
*/
graphRenderHint: string = 'exact';
graphRenderHint = 'exact';
/**
* Specifies if events are handled.
* @default true
*/
enabled: boolean = true;
enabled = true;
/**
* Specifies a viewport rectangle should be shown.
* @default true
*/
showViewport: boolean = true;
showViewport = true;
/**
* Border to be added at the bottom and right.
* @default 10
*/
border: number = 10;
border = 10;
/**
* Specifies the size of the sizer handler.
* @default 8
*/
sizerSize: number = 8;
sizerSize = 8;
/**
* Specifies if labels should be visible in the outline.
* @default false
*/
labelsVisible: boolean = false;
labelsVisible = false;
/**
* Specifies if {@link update} should be called for {@link InternalEvent.PAN} in the source
* graph.
* @default false
*/
updateOnPan: boolean = false;
updateOnPan = false;
/**
* Optional {@link Image} to be used for the sizer.
@ -294,7 +294,7 @@ class Outline {
* Minimum scale to be used.
* @default 0.0001
*/
minScale: number = 0.0001;
minScale = 0.0001;
/**
* Optional boolean flag to suspend updates. This flag will
@ -313,7 +313,7 @@ class Outline {
* }
* ```
*/
suspended: boolean = false;
suspended = false;
/**
* Creates the {@link graph} used in the outline.
@ -420,7 +420,7 @@ class Outline {
/**
* Updates the outline.
*/
update(revalidate: boolean = false): void {
update(revalidate = false): void {
if (
this.source != null &&
this.source.container != null &&

Some files were not shown because too many files have changed in this diff Show More