mxGraphSelectionModel

Implements the selection model for a graph.  Here is a listener that handles all removed selection cells.

graph.getSelectionModel().addListener(mxEvent.CHANGE, function(sender, evt)
{
  var cells = evt.getProperty('added');

  for (var i = 0; i < cells.length; i++)
  {
    // Handle cells[i]...
  }
});
Summary
mxGraphSelectionModelImplements the selection model for a graph.
Events
mxEvent.UNDOFires after the selection was changed in changeSelection.
mxEvent.CHANGEFires after the selection changes by executing an mxSelectionChange.
Functions
mxGraphSelectionModelConstructs a new graph selection model for the given mxGraph.
Variables
doneResourceSpecifies the resource key for the status message after a long operation.
updatingSelectionResourceSpecifies the resource key for the status message while the selection is being updated.
graphReference to the enclosing mxGraph.
singleSelectionSpecifies if only one selected item at a time is allowed.
Functions
isSingleSelectionReturns singleSelection as a boolean.
setSingleSelectionSets the singleSelection flag.
isSelectedReturns true if the given mxCell is selected.
isEmptyReturns true if no cells are currently selected.
clearClears the selection and fires a <change> event if the selection was not empty.
setCellSelects the specified mxCell using setCells.
setCellsSelects the given array of mxCells and fires a <change> event.
getFirstSelectableCellReturns the first selectable cell in the given array of cells.
addCellAdds the given mxCell to the selection and fires a <select> event.
addCellsAdds the given array of mxCells to the selection and fires a <select> event.
removeCellRemoves the specified mxCell from the selection and fires a <select> event for the remaining cells.
removeCells
changeSelectionAdds/removes the specified arrays of mxCell to/from the selection.
cellAddedInner callback to add the specified mxCell to the selection.
cellRemovedInner callback to remove the specified mxCell from the selection.
mxSelectionChangeAction to change the current root in a view.
Functions
mxCurrentRootChangeConstructs a change of the current root in the given view.
executeChanges the current root of the view.

Events

mxEvent.UNDO

Fires after the selection was changed in changeSelection.  The <code>edit</code> property contains the mxUndoableEdit which contains the mxSelectionChange.

mxEvent.CHANGE

Fires after the selection changes by executing an mxSelectionChange.  The <code>added</code> and <code>removed</code> properties contain arrays of cells that have been added to or removed from the selection, respectively.  The names are inverted due to historic reasons.  This cannot be changed.

Functions

mxGraphSelectionModel

function mxGraphSelectionModel(graph)

Constructs a new graph selection model for the given mxGraph.

Parameters

graphReference to the enclosing mxGraph.

Variables

doneResource

mxGraphSelectionModel.prototype.doneResource

Specifies the resource key for the status message after a long operation.  If the resource for this key does not exist then the value is used as the status message.  Default is ‘done’.

updatingSelectionResource

mxGraphSelectionModel.prototype.updatingSelectionResource

Specifies the resource key for the status message while the selection is being updated.  If the resource for this key does not exist then the value is used as the status message.  Default is ‘updatingSelection’.

graph

mxGraphSelectionModel.prototype.graph

Reference to the enclosing mxGraph.

singleSelection

mxGraphSelectionModel.prototype.singleSelection

Specifies if only one selected item at a time is allowed.  Default is false.

Functions

isSingleSelection

mxGraphSelectionModel.prototype.isSingleSelection = function()

Returns singleSelection as a boolean.

setSingleSelection

mxGraphSelectionModel.prototype.setSingleSelection = function(singleSelection)

Sets the singleSelection flag.

Parameters

singleSelectionBoolean that specifies the new value for singleSelection.

isSelected

mxGraphSelectionModel.prototype.isSelected = function(cell)

Returns true if the given mxCell is selected.

isEmpty

mxGraphSelectionModel.prototype.isEmpty = function()

Returns true if no cells are currently selected.

clear

mxGraphSelectionModel.prototype.clear = function()

Clears the selection and fires a <change> event if the selection was not empty.

setCell

mxGraphSelectionModel.prototype.setCell = function(cell)

Selects the specified mxCell using setCells.

Parameters

cellmxCell to be selected.

setCells

mxGraphSelectionModel.prototype.setCells = function(cells)

Selects the given array of mxCells and fires a <change> event.

Parameters

cellsArray of mxCells to be selected.

getFirstSelectableCell

mxGraphSelectionModel.prototype.getFirstSelectableCell = function(cells)

Returns the first selectable cell in the given array of cells.

addCell

mxGraphSelectionModel.prototype.addCell = function(cell)

Adds the given mxCell to the selection and fires a <select> event.

Parameters

cellmxCell to add to the selection.

addCells

mxGraphSelectionModel.prototype.addCells = function(cells)

Adds the given array of mxCells to the selection and fires a <select> event.

Parameters

cellsArray of mxCells to add to the selection.

removeCell

mxGraphSelectionModel.prototype.removeCell = function(cell)

Removes the specified mxCell from the selection and fires a <select> event for the remaining cells.

Parameters

cellmxCell to remove from the selection.

removeCells

mxGraphSelectionModel.prototype.removeCells = function(cells)

changeSelection

mxGraphSelectionModel.prototype.changeSelection = function(added,
removed)

Adds/removes the specified arrays of mxCell to/from the selection.

Parameters

addedArray of mxCell to add to the selection.
removeArray of mxCell to remove from the selection.

cellAdded

mxGraphSelectionModel.prototype.cellAdded = function(cell)

Inner callback to add the specified mxCell to the selection.  No event is fired in this implementation.

Paramters

cellmxCell to add to the selection.

cellRemoved

mxGraphSelectionModel.prototype.cellRemoved = function(cell)

Inner callback to remove the specified mxCell from the selection.  No event is fired in this implementation.

Parameters

cellmxCell to remove from the selection.

mxSelectionChange

Action to change the current root in a view.

Summary
Functions
mxCurrentRootChangeConstructs a change of the current root in the given view.
executeChanges the current root of the view.

Functions

mxCurrentRootChange

Constructs a change of the current root in the given view.

execute

mxSelectionChange.prototype.execute = function()

Changes the current root of the view.

mxGraphSelectionModel.prototype.changeSelection = function(added,
removed)
Adds/removes the specified arrays of mxCell to/from the selection.
Action to change the current root in a view.
function mxGraphSelectionModel(graph)
Constructs a new graph selection model for the given mxGraph.
Extends mxEventSource to implement a graph component for the browser.
mxGraphSelectionModel.prototype.doneResource
Specifies the resource key for the status message after a long operation.
mxGraphSelectionModel.prototype.updatingSelectionResource
Specifies the resource key for the status message while the selection is being updated.
mxGraphSelectionModel.prototype.graph
Reference to the enclosing mxGraph.
mxGraphSelectionModel.prototype.singleSelection
Specifies if only one selected item at a time is allowed.
mxGraphSelectionModel.prototype.isSingleSelection = function()
Returns singleSelection as a boolean.
mxGraphSelectionModel.prototype.setSingleSelection = function(singleSelection)
Sets the singleSelection flag.
mxGraphSelectionModel.prototype.isSelected = function(cell)
Returns true if the given mxCell is selected.
Cells are the elements of the graph model.
mxGraphSelectionModel.prototype.isEmpty = function()
Returns true if no cells are currently selected.
mxGraphSelectionModel.prototype.clear = function()
Clears the selection and fires a change event if the selection was not empty.
mxGraphSelectionModel.prototype.setCell = function(cell)
Selects the specified mxCell using setCells.
mxGraphSelectionModel.prototype.setCells = function(cells)
Selects the given array of mxCells and fires a change event.
mxGraphSelectionModel.prototype.getFirstSelectableCell = function(cells)
Returns the first selectable cell in the given array of cells.
mxGraphSelectionModel.prototype.addCell = function(cell)
Adds the given mxCell to the selection and fires a select event.
mxGraphSelectionModel.prototype.addCells = function(cells)
Adds the given array of mxCells to the selection and fires a select event.
mxGraphSelectionModel.prototype.removeCell = function(cell)
Removes the specified mxCell from the selection and fires a select event for the remaining cells.
mxGraphSelectionModel.prototype.removeCells = function(cells)
mxGraphSelectionModel.prototype.cellAdded = function(cell)
Inner callback to add the specified mxCell to the selection.
mxGraphSelectionModel.prototype.cellRemoved = function(cell)
Inner callback to remove the specified mxCell from the selection.
mxSelectionChange.prototype.execute = function()
Changes the current root of the view.
Implements a composite undoable edit.
Close