GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — Editor | @maxgraph/core

  • Editor

Class Editor

Extends EventSource to implement an application wrapper for a graph that adds actions, I/O using Codec, auto-layout using LayoutManager, command history using undoManager, and standard dialogs and widgets, e.g. properties, help, outline, toolbar, and popupmenu. It also adds templates to be used as cells in toolbars, auto-validation using the installChangeHandler flag, attribute cycling using cycleAttributeValues, higher-level events such as root, and backend integration using and urlImage.

Actions

Actions are functions stored in the array under their names. The functions take the Editor as the first, and an optional Cell as the second argument and are invoked using . Any additional arguments passed to execute are passed on to the action as-is.

A list of built-in actions is available in the description.

Read/write Diagrams

To read a diagram from an XML string, for example from a text field within the page, the following code is used:

const doc = xmlUtils.parseXML(xmlString);
const node = doc.documentElement;
editor.readGraphModel(node);

For reading a diagram from a remote location, use the open method.

To save diagrams in XML on a server, you can set the urlPost variable. This variable will be used in getUrlPost to construct a URL for the post request that is issued in the save method. The post request contains the XML representation of the diagram as returned by writeGraphModel in the xml parameter.

On the server side, the post request is processed using standard technologies such as Java Servlets, CGI, .NET or ASP.

Here are some examples of processing a post request in various languages.

  • Java: URLDecoder.decode(request.getParameter("xml"), "UTF-8").replace(" ", " ")

Note that the linefeed should only be replaced if the XML is processed in Java, for example when creating an image, but not if the XML is passed back to the client-side.

  • .NET: HttpUtility.UrlDecode(context.Request.Params["xml"])
  • PHP: urldecode($_POST["xml"])

Creating images

A backend (Java, PHP or C#) is required for creating images. The distribution contains an example for each backend (ImageHandler.java, ImageHandler.cs and graph.php). More information about using a backend to create images can be found in the readme.html files. Note that the preview is implemented using VML/SVG in the browser and does not require a backend. The backend is only required to creates images (bitmaps).

Special characters

Note There are five characters that should always appear in XML content as escapes, so that they do not interact with the syntax of the markup. These are part of the language for all documents based on XML and for HTML.

  • < (<)
  • > (>)
  • & (&)
  • " (")
  • ' (')

Although it is part of the XML language, ' is not defined in HTML. For this reason the XHTML specification recommends instead the use of ' if text may be passed to an HTML user agent.

If you are having problems with special characters on the server-side then you may want to try the escapePostData flag.

For converting decimal escape sequences inside strings, a user has provided us with the following function:

function html2js(text) {
const entitySearch = /&#[0-9]+;/;
let entity;

while (entity = entitySearch.exec(text)) {
const charCode = entity[0].substring(2, entity[0].length -1);
text = text.substring(0, entity.index)
+ String.fromCharCode(charCode)
+ text.substring(entity.index + entity[0].length);
}

return text;
}

Otherwise, try using hex escape sequences and the built-in unescape function for converting such strings.

Local Files

For saving and opening local files, no standardized method exists that works across all browsers. The recommended way of dealing with local files is to create a backend that streams the XML data back to the browser (echo) as an attachment so that a Save-dialog is displayed on the client-side and the file can be saved to the local disk.

For example, in PHP the code that does this looks as follows.

$xml = stripslashes($_POST["xml"]);
header("Content-Disposition: attachment; filename=\"diagram.xml\"");
echo($xml);

To open a local file, the file should be uploaded via a form in the browser and then opened from the server in the editor.

Cell Properties

The properties displayed in the properties dialog are the attributes and values of the cell's user object, which is an XML node. The XML node is defined in the templates section of the config file.

The templates are stored in Editor.templates and contain cells which are cloned at insertion time to create new vertices by use of drag and drop from the toolbar. Each entry in the toolbar for adding a new vertex must refer to an existing template.

In the following example, the task node is a business object and only the Cell node and its Geometry child contain graph information:

<Task label="Task" description="">
<Cell vertex="true">
<Geometry as="geometry" width="72" height="32"/>
</Cell>
</Task>

The idea is that the XML representation is inverse from the in-memory representation: The outer XML node is the user object and the inner node is the cell. This means the user object of the cell is the Task node with no children for the above example:

<Task label="Task" description=""/>

The Task node can have any tag name, attributes and child nodes. The Codec will use the XML hierarchy as the user object, while removing the "known annotations", such as the Cell node. At save-time the cell data will be "merged" back into the user object. The user object is only modified via the properties dialog during the lifecycle of the cell.

In the default implementation of createProperties, the user object's attributes are put into a form for editing. Attributes are changed using the CellAttributeChange action in the model. The dialog can be replaced by overriding the createProperties hook or by replacing the showProperties action in action. Alternatively, the entry in the config file's popupmenu section can be modified to invoke a different action.

If you want to display the properties dialog on a double click, you can set Editor.dblClickAction to showProperties as follows:

editor.dblClickAction = 'showProperties';

Popupmenu and Toolbar

The toolbar and popupmenu are typically configured using the respective sections in the config file, that is, the popupmenu is defined as follows:

<Editor>
<EditorPopupMenu as="popupHandler">
<add as="cut" action="cut" icon="images/cut.gif"/>
...

New entries can be added to the toolbar by inserting an add-node into the above configuration. Existing entries may be removed and changed by modifying or removing the respective entries in the configuration. The configuration is read by the EditorPopupMenuCodec, the format of the configuration is explained in EditorPopupMenu.decode.

The toolbar is defined in the EditorToolbar section. Items can be added and removed in this section.

<Editor>
<EditorToolbar>
<add as="save" action="save" icon="images/save.gif"/>
<add as="Swimlane" template="swimlane" icon="images/swimlane.gif"/>
...

The format of the configuration is described in EditorToolbarCodec.decode.

Ids:

For the IDs, there is an implicit behaviour in Codec: It moves the Id from the cell to the user object at encoding time and vice versa at decoding time. For example, if the Task node from above has an id attribute, then the Cell.id of the corresponding cell will have this value. If there is no Id collision in the model, then the cell may be retrieved using this Id with the GraphDataModel.getCell function. If there is a collision, a new Id will be created for the cell using GraphDataModel.createId. At encoding time, this new Id will replace the value previously stored under the id attribute in the Task node.

See EditorCodec, EditorToolbarCodec and EditorPopupMenuCodec for information about configuring the editor and user interface.

Programmatically inserting cells

For inserting a new cell, say, by clicking a button in the document, the following code can be used. This requires an reference to the editor.

const userObject = new Object();
const model = editor.graph.model;
model.beginUpdate();
try {
editor.graph.insertVertex({value: userObject, position: [20, 20], size: [80, 30]});
} finally
model.endUpdate();
}

If a template cell from the config file should be inserted, then a clone of the template can be created as follows. The clone is then inserted using the add function instead of addVertex.

const template = editor.templates['task'];
cont clone = cloneCell(template);

Translations

resources/editor - Language resources for Editor

To load the resources for the Editor, the following code should be used:

// Load maxGraph builtin resources
Translations.loadResources();
// Load resources for the Editor
Translations.add(`${Client.basePath}/resources/editor`);

Callback: onInit

Called from within the constructor. In the callback, "this" refers to the editor instance.

Cookie: mxgraph=seen

Set when the editor is started. Never expires. Use resetFirstTime to reset this cookie. This cookie only exists if onInit is implemented.

Events

Event: mxEvent.OPEN

Fires after a file was opened in open. The filename property contains the filename that was used. The same value is also available in filename.

Event: mxEvent.SAVE

Fires after the current file was saved in save. The url property contains the URL that was used for saving.

Event: mxEvent.POST

Fires if a successful response was received in postDiagram. The request property contains the , the url and data properties contain the URL and the data that were used in the post request.

Event: mxEvent.ROOT

Fires when the current root has changed, or when the title of the current root has changed. This event has no properties.

Event: mxEvent.BEFORE_ADD_VERTEX

Fires before a vertex is added in addVertex. The vertex property contains the new vertex and the parent property contains its parent.

Event: mxEvent.ADD_VERTEX

Fires between begin- and endUpdate in . The vertex property contains the vertex that is being inserted.

Event: mxEvent.AFTER_ADD_VERTEX

Fires after a vertex was inserted and selected in . The vertex property contains the new vertex.

Example

For starting an in-place edit after a new vertex has been added to the graph, the following code can be used.

editor.addListener(mxEvent.AFTER_ADD_VERTEX, function(sender, evt) {
const vertex = evt.getProperty('vertex');
if (editor.graph.isCellEditable(vertex)) {
editor.graph.startEditingAtCell(vertex);
}
});

Event: mxEvent.ESCAPE

Fires when the escape key is pressed. The event property contains the key event.

Hierarchy (View Summary)

  • EventSource
    • Editor
  • Defined in editor/Editor.ts:391
Index

Constructors

constructor

Properties

actions askZoomResource currentFileResource cycleAttributeIndex cycleAttributeName cycleAttributeValues dblClickAction defaultEdge defaultEdgeStyle defaultGroup destroyed diagramLayout disableContextMenu escapePostData eventListeners eventsEnabled eventSource filename forcedInserting graph graphRenderHint groupBorderSize help helpHeight helpResource helpWidth helpWindowImage horizontalFlow ignoredChanges insertFunction isActive keyHandler lastSavedResource lastSnapshot layoutDiagram layoutSwimlanes linefeed maintainSwimlanes modified movePropertiesDialog onInit outline outlineResource popupHandler postParameterName properties propertiesHeight propertiesResource propertiesWidth rubberband status swimlaneLayout swimlaneRequired swimlaneSpacing tasks tasksResource tasksTop tasksWindowImage templates toolbar undoManager urlHelp urlImage urlPost validating

Methods

addAction addActions addListener addTemplate addVertex configure consumeCycleAttribute createDiagramLayout createEdge createGraph createGroup createLayoutManager createPopupMenu createProperties createSwimlaneLayout createSwimlaneManager createTasks createToolbar cycleAttribute destroy execute fireEvent getEdgeStyle getEventSource getRootTitle getTemplate getTitle getUrlImage getUrlPost groupCells hideProperties installChangeHandler installDblClickHandler installDrillHandler installInsertHandler installUndoHandler isEventsEnabled isModified isPropertiesVisible open postDiagram readGraphModel redo refreshTasks removeListener resetFirstTime resetHistory save setEventsEnabled setEventSource setGraphContainer setMode setModified setStatus setStatusContainer setTitleContainer setToolbarContainer showHelp showOutline showProperties showTasks swapStyles treeLayout undo writeGraphModel

Constructors

constructor

  • new Editor(config: Element): Editor

    Constructs a new editor. This function invokes the onInit callback upon completion.

    const config = load('config/diagram-editor.xml').getDocumentElement();
    const editor = new Editor(config);

    Parameters

    • config: Element

      The configuration element that contains the editor configuration.

    Returns Editor

    Overrides EventSource.constructor

    • Defined in editor/Editor.ts:402

Properties

actions

actions: { [key: string]: Function } = {}

Maps from actionnames to actions, which are functions taking the editor and the cell as arguments. Use addAction to add or replace an action and execute to execute an action by name, passing the cell to be operated upon as the second argument.

  • Defined in editor/Editor.ts:556

askZoomResource

askZoomResource: string = ...

Specifies the resource key for the zoom dialog. If the resource for this key does not exist then the value is used as the error message. Default is 'askZoom'.

Default

'askZoom'
  • Defined in editor/Editor.ts:450

currentFileResource

currentFileResource: string = ...

Specifies the resource key for the current file info. If the resource for this key does not exist then the value is used as the error message. Default is 'currentFile'.

Default

'currentFile'
  • Defined in editor/Editor.ts:468

cycleAttributeIndex

cycleAttributeIndex: number = 0

Index of the last consumed attribute index. If a new swimlane is inserted, then the cycleAttributeValues at this index will be used as the value for cycleAttributeName.

Default

0
  • Defined in editor/Editor.ts:756

cycleAttributeName

cycleAttributeName: (keyof CellStateStyle) | string & Record<never, never> = 'fillColor'

Name of the attribute to be assigned a cycleAttributeValues when inserting new swimlanes.

Default

'fillColor'
  • Defined in editor/Editor.ts:762

cycleAttributeValues

cycleAttributeValues: any[] = []

Specifies the attribute values to be cycled when inserting new swimlanes.

Default

[]
  • Defined in editor/Editor.ts:745

dblClickAction

dblClickAction: string = 'edit'

Specifies the name of the action to be executed when a cell is double-clicked. Default is 'edit'.

To handle a single-click, use the following code.

Example

editor.graph.addListener(mxEvent.CLICK, function(sender, evt) {
const e = evt.getProperty('event');
const cell = evt.getProperty('cell');

if (cell && !e.isConsumed()) {
// Do something useful with cell...
e.consume();
}
});

Default

'edit'
  • Defined in editor/Editor.ts:582

defaultEdge

defaultEdge: any = null

Prototype edge cell that is used for creating new edges.

  • Defined in editor/Editor.ts:629

defaultEdgeStyle

defaultEdgeStyle: any = null

Specifies the edge style to be returned in getEdgeStyle.

Default

null
  • Defined in editor/Editor.ts:635

defaultGroup

defaultGroup: any = null

Prototype group cell that is used for creating new groups.

  • Defined in editor/Editor.ts:640

destroyed

destroyed: boolean = false
  • Defined in editor/Editor.ts:443

diagramLayout

diagramLayout: any
  • Defined in editor/Editor.ts:439

disableContextMenu

disableContextMenu: boolean = true

Specifies if the context menu should be disabled in the graph container.

Default

true
  • Defined in editor/Editor.ts:597

escapePostData

escapePostData: boolean = true

Specifies if the data in the post request for saving a diagram should be converted using encodeURIComponent.

Default

true
  • Defined in editor/Editor.ts:674

eventListeners

eventListeners: EventListenerObject[] = []

Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.

Inherited from EventSource.eventListeners

  • Defined in view/event/EventSource.ts:58

eventsEnabled

eventsEnabled: boolean = true

Specifies if events can be fired. Default is true.

Inherited from EventSource.eventsEnabled

  • Defined in view/event/EventSource.ts:63

eventSource

eventSource: EventTarget | null = null

Optional source for events.

Default

null

Inherited from EventSource.eventSource

  • Defined in view/event/EventSource.ts:69

filename

filename: string | null = null

Contains the URL of the last opened file as a string.

Default

null
  • Defined in editor/Editor.ts:652

forcedInserting

forcedInserting: boolean = false

Specifies if a new cell should be inserted on a single click even using insertFunction if there is a cell under the mouse pointer, otherwise the cell under the mouse pointer is selected. Default is false.

Default

false
  • Defined in editor/Editor.ts:617

graph

graph: AbstractGraph

Holds a AbstractGraph for displaying the diagram. The graph is created in setGraphContainer.

  • Defined in editor/Editor.ts:513

graphRenderHint

graphRenderHint: any = null

Holds the render hint used for creating the graph in setGraphContainer.

Default

null
  • Defined in editor/Editor.ts:519

groupBorderSize

groupBorderSize: number | null = null

Default size for the border of new groups. If null, then AbstractGraph.gridSize is used.

Default

null
  • Defined in editor/Editor.ts:646

help

help: any = null

Holds the MaxWindow created in showHelp

  • Defined in editor/Editor.ts:788

helpHeight

helpHeight: number = 260

Specifies the height of the help window in pixels. Default is 260.

Default

260
  • Defined in editor/Editor.ts:814

helpResource

helpResource: string = ...

Specifies the resource key for the help window title. If the resource for this key does not exist then the value is used as the error message. Default is 'help'.

Default

'help'
  • Defined in editor/Editor.ts:492

helpWidth

helpWidth: number = 300

Specifies the width of the help window in pixels. Default is 300.

Default

300
  • Defined in editor/Editor.ts:807

helpWindowImage

helpWindowImage: any = null

Icon for the help window.

  • Defined in editor/Editor.ts:793

horizontalFlow

horizontalFlow: boolean = false

Specifies the direction of the flow in the diagram. This is used in the layout algorithms. Default is vertical flow.

Default

false
  • Defined in editor/Editor.ts:693

ignoredChanges

ignoredChanges: number | null = null
  • Defined in editor/Editor.ts:437

insertFunction

insertFunction: Function | null = null

Specifies the function to be used for inserting new cells into the graph. This is assigned from the EditorToolbar if a vertex-tool is clicked.

  • Defined in editor/Editor.ts:604

isActive

isActive: boolean | null = null
  • Defined in editor/Editor.ts:441

keyHandler

keyHandler: EditorKeyHandler | null = null

Holds a EditorKeyHandler for handling keyboard events. The handler is created in setGraphContainer.

  • Defined in editor/Editor.ts:547

lastSavedResource

lastSavedResource: string = ...

Specifies the resource key for the last saved info. If the resource for this key does not exist then the value is used as the error message. Default is 'lastSaved'.

Default

'lastSaved'.
  • Defined in editor/Editor.ts:461

lastSnapshot

lastSnapshot: number | null = null
  • Defined in editor/Editor.ts:436

layoutDiagram

layoutDiagram: boolean = false

Specifies if the top-level elements in the diagram should be layed out using a vertical or horizontal stack depending on the setting of horizontalFlow. The spacing between the swimlanes is specified by swimlaneSpacing. Default is false.

If the top-level elements are swimlanes, then the intra-swimlane layout is activated by the layoutSwimlanes switch.

Default

false
  • Defined in editor/Editor.ts:712

layoutSwimlanes

layoutSwimlanes: boolean = false

Specifies if the children of swimlanes should be layed out, either vertically or horizontally depending on horizontalFlow.

Default

false
  • Defined in editor/Editor.ts:739

linefeed

linefeed: string = '&#xa;'

Character to be used for encoding linefeed in save.

Default

'&#xa;'
  • Defined in editor/Editor.ts:662

maintainSwimlanes

maintainSwimlanes: boolean = false

Specifies if the swimlanes should be kept at the same width or height depending on the setting of horizontalFlow. Default is false.

For horizontal flows, all swimlanes have the same height and for vertical flows, all swimlanes have the same width. Furthermore, the swimlanes are automatically "stacked" if layoutDiagram is true.

Default

false
  • Defined in editor/Editor.ts:733

modified

modified: boolean = false

True if the graph has been modified since it was last saved.

  • Defined in editor/Editor.ts:849

movePropertiesDialog

movePropertiesDialog: boolean = false

Specifies if the properties dialog should be automatically moved near the cell it is displayed for, otherwise the dialog is not moved. This value is only taken into account if the dialog is already visible. Default is false.

Default

false
  • Defined in editor/Editor.ts:837

onInit

onInit: Function | null = null
  • Defined in editor/Editor.ts:435

outline

outline: any = null

Reference to the MaxWindow that contains the outline. The outline is stored in outline.outline.

  • Defined in editor/Editor.ts:507

outlineResource

outlineResource: string = ...

Specifies the resource key for the outline window title. If the resource for this key does not exist then the value is used as the error message. Default is 'outline'.

Default

'outline'
  • Defined in editor/Editor.ts:500

popupHandler

popupHandler: EditorPopupMenu | null = null

Holds a EditorPopupMenu for displaying popupmenus.

  • Defined in editor/Editor.ts:536

postParameterName

postParameterName: string = 'xml'

Specifies if the name of the post parameter that contains the diagram data in a post request to the server.

Default

'xml'
  • Defined in editor/Editor.ts:668

properties

properties: any
  • Defined in editor/Editor.ts:442

propertiesHeight

propertiesHeight: number | null = null

Specifies the height of the properties window in pixels. If no height is specified then the window will be automatically sized to fit its contents. Default is null.

Default

null
  • Defined in editor/Editor.ts:828

propertiesResource

propertiesResource: string = ...

Specifies the resource key for the properties window title. If the resource for this key does not exist then the value is used as the error message. Default is 'properties'.

Default

'properties'
  • Defined in editor/Editor.ts:476

propertiesWidth

propertiesWidth: number = 240

Specifies the width of the properties window in pixels. Default is 240.

Default

240
  • Defined in editor/Editor.ts:820

rubberband

rubberband: RubberBandHandler | null = null
  • Defined in editor/Editor.ts:440

status

status: HTMLElement | null = null

DOM container that holds the statusbar. Use setStatusContainer to set this value.

  • Defined in editor/Editor.ts:531

swimlaneLayout

swimlaneLayout: any
  • Defined in editor/Editor.ts:438

swimlaneRequired

swimlaneRequired: boolean = false

Specifies if new cells must be inserted into an existing swimlane. Otherwise, cells that are not swimlanes can be inserted as top-level cells.

Default

false
  • Defined in editor/Editor.ts:591

swimlaneSpacing

swimlaneSpacing: number = 0

Specifies the spacing between swimlanes if automatic layout is turned on in layoutDiagram. Default is 0.

Default

0
  • Defined in editor/Editor.ts:720

tasks

tasks: any = null

Holds the MaxWindow created in showTasks.

  • Defined in editor/Editor.ts:768

tasksResource

tasksResource: string = ...

Specifies the resource key for the tasks window title. If the resource for this key does not exist then the value is used as the error message. Default is 'tasks'.

Default

'tasks'
  • Defined in editor/Editor.ts:484

tasksTop

tasksTop: number = 20

Specifies the top coordinate of the tasks window in pixels. Default is 20.

Default

20
  • Defined in editor/Editor.ts:783

tasksWindowImage

tasksWindowImage: any = null

Icon for the tasks window.

  • Defined in editor/Editor.ts:777

templates

templates: any = null

Maps from names to prototype cells to be used in the toolbar for inserting new cells into the diagram.

  • Defined in editor/Editor.ts:624

toolbar

toolbar: EditorToolbar | null = null

Holds a EditorToolbar for displaying the toolbar. The toolbar is created in setToolbarContainer.

  • Defined in editor/Editor.ts:525

undoManager

undoManager: UndoManager | null = null

Holds an UndoManager for the command history.

  • Defined in editor/Editor.ts:541

urlHelp

urlHelp: string | null = null

Specifies the URL to be used for the contents of the Online Help window. This is usually specified in the resources file under urlHelp for language-specific online help support.

  • Defined in editor/Editor.ts:801

urlImage

urlImage: string | null = null

Specifies the URL to be used for creating a bitmap of the graph in the image action.

Default

null
  • Defined in editor/Editor.ts:686

urlPost

urlPost: string | null = null

Specifies the URL to be used for posting the diagram to a backend in save.

Default

null
  • Defined in editor/Editor.ts:680

validating

validating: boolean = false

Specifies if AbstractGraph.validateGraph should automatically be invoked after each change. Default is false.

Default

false
  • Defined in editor/Editor.ts:844

Methods

addAction

  • addAction(actionname: string, funct: Function): void

    Binds the specified actionname to the specified function.

    Parameters

    • actionname: string

      String that specifies the name of the action to be added.

    • funct: Function

      Function that implements the new action. The first argument of the function is the editor it is used with, the second argument is the cell it operates upon.

    Returns void

    Example

    editor.addAction('test', function(editor: Editor, cell: Cell)
    {
    mxUtils.alert("test "+cell);
    });
    • Defined in editor/Editor.ts:1325

addActions

  • addActions(): void

    Adds the built-in actions to the editor instance. save - Saves the graph using . print - Shows the graph in a new print preview window. show - Shows the graph in a new window. exportImage - Shows the graph as a bitmap image using . refresh - Refreshes the graph's display. cut - Copies the current selection into the clipboard and removes it from the graph. copy - Copies the current selection into the clipboard. paste - Pastes the clipboard into the graph. delete - Removes the current selection from the graph. group - Puts the current selection into a new group. ungroup - Removes the selected groups and selects the children. undo - Undoes the last change on the graph model. redo - Redoes the last change on the graph model. zoom - Sets the zoom via a dialog. zoomIn - Zooms into the graph. zoomOut - Zooms out of the graph actualSize - Resets the scale and translation on the graph. fit - Changes the scale so that the graph fits into the window. showProperties - Shows the properties dialog. selectAll - Selects all cells. selectNone - Clears the selection. selectVertices - Selects all vertices. selectEdges = Selects all edges. edit - Starts editing the current selection cell. enterGroup - Drills down into the current selection cell. exitGroup - Moves up in the drilling hierachy home - Moves to the topmost parent in the drilling hierarchy selectPrevious - Selects the previous cell. selectNext - Selects the next cell. selectParent - Selects the parent of the selection cell. selectChild - Selects the first child of the selection cell. collapse - Collapses the currently selected cells. expand - Expands the currently selected cells. bold - Toggle bold text style. italic - Toggle italic text style. underline - Toggle underline text style. alignCellsLeft - Aligns the selection cells at the left. alignCellsCenter - Aligns the selection cells in the center. alignCellsRight - Aligns the selection cells at the right. alignCellsTop - Aligns the selection cells at the top. alignCellsMiddle - Aligns the selection cells in the middle. alignCellsBottom - Aligns the selection cells at the bottom. alignFontLeft - Sets the horizontal text alignment to left. alignFontCenter - Sets the horizontal text alignment to center. alignFontRight - Sets the horizontal text alignment to right. alignFontTop - Sets the vertical text alignment to top. alignFontMiddle - Sets the vertical text alignment to middle. alignFontBottom - Sets the vertical text alignment to bottom. toggleTasks - Shows or hides the tasks window. toggleHelp - Shows or hides the help window. toggleOutline - Shows or hides the outline window. toggleConsole - Shows or hides the console window.

    Returns void

    • Defined in editor/Editor.ts:922

addListener

  • addListener(name: string, funct: Function): void

    Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.

    The parameters of the listener are the sender and an EventObject.

    Parameters

    • name: string
    • funct: Function

    Returns void

    Inherited from EventSource.addListener

    • Defined in view/event/EventSource.ts:105

addTemplate

  • addTemplate(name: string, template: any): void

    Adds the specified template under the given name in templates.

    Parameters

    • name: string
    • template: any

    Returns void

    • Defined in editor/Editor.ts:1371

addVertex

  • addVertex(parent: Cell | null, vertex: Cell, x: number, y: number): any

    Adds the given vertex as a child of parent at the specified x and y coordinate and fires an addVertex event.

    Parameters

    • parent: Cell | null
    • vertex: Cell
    • x: number
    • y: number

    Returns any

    • Defined in editor/Editor.ts:2492

configure

  • configure(node: Element): void

    Configures the editor using the specified node. To load the configuration from a given URL the following code can be used to obtain the XML node.

    Parameters

    • node: Element

      XML node that contains the configuration.

    Returns void

    Example

    var node = mxUtils.load(url).getDocumentElement();
    
    • Defined in editor/Editor.ts:1280

consumeCycleAttribute

  • consumeCycleAttribute(cell: Cell): any

    Returns the next attribute in cycleAttributeValues or null, if not attribute should be used in the specified cell.

    Parameters

    • cell: Cell

    Returns any

    • Defined in editor/Editor.ts:2457

createDiagramLayout

  • createDiagramLayout(): StackLayout

    Creates the layout instance used to layout the swimlanes in the diagram.

    Returns StackLayout

    StackLayout instance

    • Defined in editor/Editor.ts:1660

createEdge

  • createEdge(source: Cell | null, target: Cell | null): Cell

    Uses defaultEdge as the prototype for creating new edges in the connection handler of the graph. The style of the edge will be overridden with the value returned by getEdgeStyle.

    Parameters

    • source: Cell | null
    • target: Cell | null

    Returns Cell

    • Defined in editor/Editor.ts:2419

createGraph

  • createGraph(): AbstractGraph

    Creates the AbstractGraph for the editor.

    The AbstractGraph is created with no container and is initialized from setGraphContainer.

    Returns AbstractGraph

    the AbstractGraph instance used by the Editor

    • Defined in editor/Editor.ts:1390

createGroup

  • createGroup(): Cell

    Creates and returns a clone of defaultGroup to be used as a new group cell in group.

    Returns Cell

    Cell

    • Defined in editor/Editor.ts:1824

createLayoutManager

  • createLayoutManager(graph: AbstractGraph): LayoutManager

    Creates a layout manager for the swimlane and diagram layouts, that is, the locally defined inter and intra swimlane layouts.

    Parameters

    • graph: AbstractGraph

    Returns LayoutManager

    LayoutManager instance

    • Defined in editor/Editor.ts:1467

createPopupMenu

  • createPopupMenu(menu: MaxPopupMenu, cell: Cell | null, evt: any): void

    Uses popupHandler to create the menu in the graph's panning handler. The redirection is setup in setToolbarContainer.

    Parameters

    • menu: MaxPopupMenu
    • cell: Cell | null
    • evt: any

    Returns void

    • Defined in editor/Editor.ts:2408

createProperties

  • createProperties(cell: Cell): HTMLTableElement | null

    Creates and returns the DOM node that represents the contents of the properties dialog for the given cell. This implementation works for user objects that are XML nodes and display all the node attributes in a form.

    Parameters

    • cell: Cell

    Returns HTMLTableElement | null

    • Defined in editor/Editor.ts:2063

createSwimlaneLayout

  • createSwimlaneLayout(): CompactTreeLayout

    Creates the layout instance used to layout the children of each swimlane.

    Returns CompactTreeLayout

    CompactTreeLayout instance

    • Defined in editor/Editor.ts:1682

createSwimlaneManager

  • createSwimlaneManager(graph: AbstractGraph): SwimlaneManager

    Sets the graph's container using AbstractGraph.init.

    Parameters

    • graph: AbstractGraph

    Returns SwimlaneManager

    SwimlaneManager instance

    • Defined in editor/Editor.ts:1447

createTasks

  • createTasks(div: Element): void

    Updates the contents of the given DOM node to display the tasks associated with the current editor state. This is invoked whenever there is a possible change of state in the editor. Default implementation is empty.

    Parameters

    • div: Element

    Returns void

    • Defined in editor/Editor.ts:2266

createToolbar

  • createToolbar(): EditorToolbar

    Creates the toolbar with no container.

    Returns EditorToolbar

    EditorToolbar instance

    • Defined in editor/Editor.ts:1690

cycleAttribute

  • cycleAttribute(cell: Cell): void

    Uses the returned value from consumeCycleAttribute as the value for the cycleAttributeName key in the given cell's style.

    Parameters

    • cell: Cell

    Returns void

    • Defined in editor/Editor.ts:2472

destroy

  • destroy(): void

    Removes the editor and all its associated resources. This does not normally need to be called, it is called automatically when the window unloads.

    Returns void

    Overrides EventSource.destroy

    • Defined in editor/Editor.ts:2582

execute

  • execute(actionname: string, cell?: Cell | null, evt?: Event | null): void

    Executes the function with the given name in actions passing the editor instance and given cell as the first and second argument. All additional arguments are passed to the action as well. This method contains a try-catch block and displays an error message if an action causes an exception. The exception is re-thrown after the error message was displayed.

    Parameters

    • actionname: string
    • cell: Cell | null = null
    • evt: Event | null = null

    Returns void

    Example

    editor.execute("showProperties", cell);
    
    • Defined in editor/Editor.ts:1345

fireEvent

  • fireEvent(evt: EventObject, sender?: EventTarget | null): void

    Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation.

    Example:

    fireEvent(new EventObject("eventName", key1, val1, .., keyN, valN))
    

    Parameters

    • evt: EventObject

      EventObject that represents the event.

    • sender: EventTarget | null = null

      Optional sender to be passed to the listener. Default value is the return value of getEventSource.

    Returns void

    Inherited from EventSource.fireEvent

    • Defined in view/event/EventSource.ts:139

getEdgeStyle

  • getEdgeStyle(): any

    Returns a string identifying the style of new edges. The function is used in createEdge when new edges are created in the graph.

    Returns any

    • Defined in editor/Editor.ts:2448

getEventSource

  • getEventSource(): EventTarget | null

    Returns eventSource.

    Returns EventTarget | null

    Inherited from EventSource.getEventSource

    • Defined in view/event/EventSource.ts:88

getRootTitle

  • getRootTitle(): string

    Returns the string value of the root cell in AbstractGraph.model.

    Returns string

    • Defined in editor/Editor.ts:1791

getTemplate

  • getTemplate(name: string): any

    Returns the template for the given name.

    Parameters

    • name: string

    Returns any

    • Defined in editor/Editor.ts:1379

getTitle

  • getTitle(): string

    Returns the string value for the current root of the diagram.

    Returns string

    • Defined in editor/Editor.ts:1769

getUrlImage

  • getUrlImage(): string | null

    Returns the URL to create the image width. This is typically the URL of a backend which accepts an XML representation of a graph view to create an image. The function is used in the image action to create an image. This implementation returns urlImage.

    Returns string | null

    • Defined in editor/Editor.ts:1959

getUrlPost

  • getUrlPost(): string | null

    Returns the URL to post the diagram to. This is used in save. The default implementation returns urlPost, adding ?draft=true.

    Returns string | null

    • Defined in editor/Editor.ts:1948

groupCells

  • groupCells(): any

    Invokes createGroup to create a new group cell and the invokes AbstractGraph.groupCells, using the grid size of the graph as the spacing in the group's content area.

    Returns any

    • Defined in editor/Editor.ts:1815

hideProperties

  • hideProperties(): void

    Hides the properties dialog.

    Returns void

    • Defined in editor/Editor.ts:2176

installChangeHandler

  • installChangeHandler(graph: AbstractGraph): void

    Installs the listeners required to automatically validate the graph. On each change of the root, this implementation fires a root event.

    Parameters

    • graph: AbstractGraph

    Returns void

    • Defined in editor/Editor.ts:1589

installDblClickHandler

  • installDblClickHandler(graph: AbstractGraph): void

    Overrides AbstractGraph.dblClick to invoke dblClickAction on a cell and reset the selection tool in the toolbar.

    Parameters

    • graph: AbstractGraph

    Returns void

    • Defined in editor/Editor.ts:1535

installDrillHandler

  • installDrillHandler(graph: AbstractGraph): void

    Installs listeners for dispatching the root event.

    Parameters

    • graph: AbstractGraph

    Returns void

    • Defined in editor/Editor.ts:1574

installInsertHandler

  • installInsertHandler(graph: AbstractGraph): void

    Installs the handler for invoking insertFunction if one is defined.

    Parameters

    • graph: AbstractGraph

    Returns void

    • Defined in editor/Editor.ts:1622

installUndoHandler

  • installUndoHandler(graph: AbstractGraph): void

    Adds the undoManager to the graph model and the view.

    Parameters

    • graph: AbstractGraph

    Returns void

    • Defined in editor/Editor.ts:1551

isEventsEnabled

  • isEventsEnabled(): boolean

    Returns eventsEnabled.

    Returns boolean

    Inherited from EventSource.isEventsEnabled

    • Defined in view/event/EventSource.ts:74

isModified

  • isModified(): boolean

    Returns modified.

    Returns boolean

    • Defined in editor/Editor.ts:854

isPropertiesVisible

  • isPropertiesVisible(): boolean

    Returns true if the properties dialog is currently visible.

    Returns boolean

    • Defined in editor/Editor.ts:2053

open

  • open(filename: string): void

    Opens the specified file synchronously and parses it using readGraphModel. It updates filename and fires an -event after the file has been opened.

    Exceptions should be handled as follows:

    try {
    editor.open(filename);
    } catch (e) {
    GlobalConfig.logger.error(`Cannot open ${filename}: ${e.message}`);
    }

    Parameters

    • filename: string

      URL of the file to be opened.

    Returns void

    • Defined in editor/Editor.ts:1844

postDiagram

  • postDiagram(url: any, data: any): void

    Hook for subclassers to override the posting of a diagram represented by the given node to the given URL. This fires an asynchronous post event if the diagram has been posted.

    Example:

    To replace the diagram with the diagram in the response, use the following code.

    Parameters

    • url: any
    • data: any

    Returns void

    Example

    editor.addListener(mxEvent.POST, function(sender, evt)
    {
    // Process response (replace diagram)
    var req = evt.getProperty('request');
    var root = req.getDocumentElement();
    editor.graph.readGraphModel(root)
    });
    • Defined in editor/Editor.ts:1922

readGraphModel

  • readGraphModel(node: Element): void

    Reads the specified XML node into the existing graph model and resets the command history and modified state.

    Parameters

    • node: Element

      the XML node to be read into the graph model.

    Returns void

    • Defined in editor/Editor.ts:1858

redo

  • redo(): void

    Redo the last change in graph.

    Returns void

    • Defined in editor/Editor.ts:1806

refreshTasks

  • refreshTasks(div: Element): void

    Updates the contents of the tasks window using createTasks.

    Parameters

    • div: Element

    Returns void

    • Defined in editor/Editor.ts:2249

removeListener

  • removeListener(funct: Function): void

    Removes all occurrences of the given listener from eventListeners.

    Parameters

    • funct: Function

    Returns void

    Inherited from EventSource.removeListener

    • Defined in view/event/EventSource.ts:112

resetFirstTime

  • resetFirstTime(): void

    Resets the cookie that is used to remember if the editor has already been used.

    Returns void

    • Defined in editor/Editor.ts:1296

resetHistory

  • resetHistory(): void

    Resets the command history, modified state and counters.

    Returns void

    • Defined in editor/Editor.ts:1303

save

  • save(url?: string | null, linefeed?: string): void

    Posts the string returned by writeGraphModel to the given URL or the URL returned by getUrlPost.

    The actual posting is carried out by postDiagram. If the URL is null then the resulting XML will be displayed using popup.

    Exceptions should be handled as follows:

    try {
    editor.open(filename);
    } catch (e) {
    GlobalConfig.logger.error(`Cannot save: ${e.message}`);
    }

    Parameters

    • url: string | null = null
    • linefeed: string = ...

    Returns void

    • Defined in editor/Editor.ts:1882

setEventsEnabled

  • setEventsEnabled(value: boolean): void

    Sets eventsEnabled.

    Parameters

    • value: boolean

    Returns void

    Inherited from EventSource.setEventsEnabled

    • Defined in view/event/EventSource.ts:81

setEventSource

  • setEventSource(value: EventTarget | null): void

    Sets eventSource.

    Parameters

    • value: EventTarget | null

    Returns void

    Inherited from EventSource.setEventSource

    • Defined in view/event/EventSource.ts:95

setGraphContainer

  • setGraphContainer(container?: HTMLElement | null): void

    Sets the graph's container using AbstractGraph.init.

    Parameters

    • Optionalcontainer: HTMLElement | null

    Returns void

    • Defined in editor/Editor.ts:1511

setMode

  • setMode(modename: any): void

    Puts the graph into the specified mode. The following mode names are supported:

    • select - Selects using the left mouse button, new connections are disabled.
    • connect - Selects using the left mouse button or creates new connections if mouse over cell hotspot. See ConnectionHandler.
    • pan - Pans using the left mouse button, new connections are disabled.

    Parameters

    • modename: any

    Returns void

    • Defined in editor/Editor.ts:2379

setModified

  • setModified(value: boolean): void

    Sets modified to the specified boolean value.

    Parameters

    • value: boolean

    Returns void

    • Defined in editor/Editor.ts:862

setStatus

  • setStatus(message: string): void

    Display the specified message in the status bar.

    Parameters

    • message: string

      String the specified the message to be displayed.

    Returns void

    • Defined in editor/Editor.ts:1734

setStatusContainer

  • setStatusContainer(container: HTMLElement | null): void

    Creates the status using the specified container. This implementation adds listeners in the editor to display the last saved time and the current filename in the status bar.

    Parameters

    • container: HTMLElement | null

      DOM node that will contain the statusbar.

    Returns void

    • Defined in editor/Editor.ts:1707

setTitleContainer

  • setTitleContainer(container: any): void

    Creates a listener to update the inner HTML of the specified DOM node with the value of getTitle.

    Parameters

    • container: any

      DOM node that will contain the title.

    Returns void

    • Defined in editor/Editor.ts:1745

setToolbarContainer

  • setToolbarContainer(container: any): void

    Initializes the toolbar for the given container.

    Parameters

    • container: any

    Returns void

    • Defined in editor/Editor.ts:1698

showHelp

  • showHelp(tasks?: any): void

    Shows the help window. If the help window does not exist then it is created using an iframe pointing to the resource for the urlHelp key or urlHelp if the resource is undefined.

    Parameters

    • tasks: any = null

    Returns void

    • Defined in editor/Editor.ts:2277

showOutline

  • showOutline(): void

    Shows the outline window. If the window does not exist, then it is created using an outline.

    Returns void

    • Defined in editor/Editor.ts:2330

showProperties

  • showProperties(cell?: Cell | null): void

    Creates and shows the properties dialog for the given cell. The content area of the dialog is created using createProperties.

    Parameters

    • cell: Cell | null = null

    Returns void

    • Defined in editor/Editor.ts:1988

showTasks

  • showTasks(): void

    Shows the tasks window. The tasks window is created using createTasks. The default width of the window is 200 pixels, the y-coordinate of the location can be specified in tasksTop and the x-coordinate is right aligned with a 20 pixel offset from the right border. To change the location of the tasks window, the following code can be used:

    Returns void

    Example

    var oldShowTasks = Editor.prototype.showTasks;
    Editor.prototype.showTasks = function()
    {
    oldShowTasks.apply(this, arguments); // "supercall"

    if (this.tasks != null)
    {
    this.tasks.setLocation(10, 10);
    }
    };
    • Defined in editor/Editor.ts:2204

swapStyles

  • swapStyles(first: string, second: string): void

    Swaps the styles for the given names in the graph's stylesheet and refreshes the graph.

    Parameters

    • first: string

      the name of the first style to swap

    • second: string

      the name of the second style to swap

    Returns void

    • Defined in editor/Editor.ts:1968

treeLayout

  • treeLayout(cell: Cell, horizontal: boolean): void

    Executes a vertical or horizontal compact tree layout using the specified cell as an argument. The cell may either be a group or the root of a tree.

    Parameters

    • cell: Cell

      Cell to use in the compact tree layout.

    • horizontal: boolean

      Optional boolean to specify the tree's orientation. Default is true.

    Returns void

    • Defined in editor/Editor.ts:1759

undo

  • undo(): void

    Undo the last change in graph.

    Returns void

    • Defined in editor/Editor.ts:1799

writeGraphModel

  • writeGraphModel(linefeed?: string): string

    Hook to create the string representation of the diagram.

    The default implementation uses ModelXmlSerializer to encode the graph model.

    Parameters

    • Optionallinefeed: string

      Optional character to be used as the linefeed. Default is linefeed.

    Returns string

    • Defined in editor/Editor.ts:1939

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

ActionsRead/write DiagramsCreating imagesSpecial charactersLocal FilesCell PropertiesPopupmenu and ToolbarProgrammatically inserting cellsTranslationsCallback: onInitCookie: mxgraph=seenEvents
  • Event: mxEvent.OPEN
  • Event: mxEvent.SAVE
  • Event: mxEvent.POST
  • Event: mxEvent.ROOT
  • Event: mxEvent.BEFORE_ADD_VERTEX
  • Event: mxEvent.ADD_VERTEX
  • Event: mxEvent.AFTER_ADD_VERTEX
  • Event: mxEvent.ESCAPE
Constructors
constructor
Properties
actionsaskZoomResourcecurrentFileResourcecycleAttributeIndexcycleAttributeNamecycleAttributeValuesdblClickActiondefaultEdgedefaultEdgeStyledefaultGroupdestroyeddiagramLayoutdisableContextMenuescapePostDataeventListenerseventsEnabledeventSourcefilenameforcedInsertinggraphgraphRenderHintgroupBorderSizehelphelpHeighthelpResourcehelpWidthhelpWindowImagehorizontalFlowignoredChangesinsertFunctionisActivekeyHandlerlastSavedResourcelastSnapshotlayoutDiagramlayoutSwimlaneslinefeedmaintainSwimlanesmodifiedmovePropertiesDialogonInitoutlineoutlineResourcepopupHandlerpostParameterNamepropertiespropertiesHeightpropertiesResourcepropertiesWidthrubberbandstatusswimlaneLayoutswimlaneRequiredswimlaneSpacingtaskstasksResourcetasksToptasksWindowImagetemplatestoolbarundoManagerurlHelpurlImageurlPostvalidating
Methods
addActionaddActionsaddListeneraddTemplateaddVertexconfigureconsumeCycleAttributecreateDiagramLayoutcreateEdgecreateGraphcreateGroupcreateLayoutManagercreatePopupMenucreatePropertiescreateSwimlaneLayoutcreateSwimlaneManagercreateTaskscreateToolbarcycleAttributedestroyexecutefireEventgetEdgeStylegetEventSourcegetRootTitlegetTemplategetTitlegetUrlImagegetUrlPostgroupCellshidePropertiesinstallChangeHandlerinstallDblClickHandlerinstallDrillHandlerinstallInsertHandlerinstallUndoHandlerisEventsEnabledisModifiedisPropertiesVisibleopenpostDiagram
      • Example:
readGraphModelredorefreshTasksremoveListenerresetFirstTimeresetHistorysavesetEventsEnabledsetEventSourcesetGraphContainersetModesetModifiedsetStatussetStatusContainersetTitleContainersetToolbarContainershowHelpshowOutlineshowPropertiesshowTasksswapStylestreeLayoutundowriteGraphModel
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.