mxGraphHandler

Graph event handler that handles selection.  Individual cells are handled separately using mxVertexHandler or one of the edge handlers.  These handlers are created using mxGraph.createHandler in mxGraphSelectionModel.cellAdded.

To avoid the container to scroll a moved cell into view, set <scrollAfterMove> to false.

Summary
mxGraphHandlerGraph event handler that handles selection.
Functions
mxGraphHandlerConstructs an event handler that creates handles for the selection cells.
Variables
graphReference to the enclosing mxGraph.
maxCellsDefines the maximum number of cells to paint subhandles for.
enabledSpecifies if events are handled.
highlightEnabledSpecifies if drop targets under the mouse should be enabled.
cloneEnabledSpecifies if cloning by control-drag is enabled.
moveEnabledSpecifies if moving is enabled.
guidesEnabledSpecifies if other cells should be used for snapping the right, center or left side of the current selection.
guideHolds the mxGuide instance that is used for alignment.
currentDxStores the x-coordinate of the current mouse move.
currentDyStores the y-coordinate of the current mouse move.
updateCursorSpecifies if a move cursor should be shown if the mouse is over a movable cell.
selectEnabledSpecifies if selecting is enabled.
removeCellsFromParentSpecifies if cells may be moved out of their parents.
removeEmptyParentsIf empty parents should be removed from the model after all child cells have been moved out.
connectOnDropSpecifies if drop events are interpreted as new connections if no other drop action is defined.
scrollOnMoveSpecifies if the view should be scrolled so that a moved cell is visible.
minimumSizeSpecifies the minimum number of pixels for the width and height of a selection border.
previewColorSpecifies the color of the preview shape.
htmlPreviewSpecifies if the graph container should be used for preview.
shapeReference to the mxShape that represents the preview.
scaleGridSpecifies if the grid should be scaled.
rotationEnabledSpecifies if the bounding box should allow for rotation.
maxLivePreviewMaximum number of cells for which live preview should be used.
allowLivePreviewIf live preview is allowed on this system.
Functions
isEnabledReturns enabled.
setEnabledSets enabled.
isCloneEnabledReturns cloneEnabled.
setCloneEnabledSets cloneEnabled.
isMoveEnabledReturns moveEnabled.
setMoveEnabledSets moveEnabled.
isSelectEnabledReturns selectEnabled.
setSelectEnabledSets selectEnabled.
isRemoveCellsFromParentReturns removeCellsFromParent.
setRemoveCellsFromParentSets removeCellsFromParent.
getInitialCellForEventHook to return initial cell for the given event.
isDelayedSelectionHook to return true for delayed selections.
consumeMouseEventConsumes the given mouse event.
mouseDownHandles the event by selecing the given cell and creating a handle for it.
getGuideStatesCreates an array of cell states which should be used as guides.
getCellsReturns the cells to be modified by this handler.
getPreviewBoundsReturns the mxRectangle used as the preview bounds for moving the given cells.
getBoundingBoxReturns the union of the mxCellStates for the given array of mxCells.
createPreviewShapeCreates the shape used to draw the preview for the given bounds.
startStarts the handling of the mouse gesture.
addStatesAdds the states for the given cell recursively to the given dictionary.
isCellMovingReturns true if the given cell is currently being moved.
useGuidesForEventReturns true if the guides should be used for the given mxMouseEvent.
snapSnaps the given vector to the grid and returns the given mxPoint instance.
getDeltaReturns an mxPoint that represents the vector for moving the cells for the given mxMouseEvent.
updateHintHook for subclassers do show details while the handler is active.
removeHintHooks for subclassers to hide details when the handler gets inactive.
roundLengthHook for rounding the unscaled vector.
mouseMoveHandles the event by highlighting possible drop targets and updating the preview.
updatePreviewUpdates the bounds of the preview shape.
updatePreviewShapeUpdates the bounds of the preview shape.
updateLivePreviewUpdates the bounds of the preview shape.
redrawHandlesRedraws the preview shape for the given states array.
resetPreviewStatesResets the given preview states array.
suspendSuspends the livew preview.
resumeSuspends the livew preview.
resetLivePreviewResets the livew preview.
resetResets the state of this handler.
setHighlightColorSets the color of the rectangle used to highlight drop targets.
mouseUpHandles the event by applying the changes to the selection cells.
selectDelayedImplements the delayed selection for the given mouse event.
resetResets the state of this handler.
shouldRemoveCellsFromParentReturns true if the given cells should be removed from the parent for the specified mousereleased event.
moveCellsMoves the given cells by the specified amount.
shouldRemoveParentReturns true if the given parent should be removed after removal of child cells.
destroyShapesDestroy the preview and highlight shapes.
destroyDestroys the handler and all its resources and DOM nodes.

Functions

mxGraphHandler

function mxGraphHandler(graph)

Constructs an event handler that creates handles for the selection cells.

Parameters

graphReference to the enclosing mxGraph.

Variables

graph

mxGraphHandler.prototype.graph

Reference to the enclosing mxGraph.

maxCells

mxGraphHandler.prototype.maxCells

Defines the maximum number of cells to paint subhandles for.  Default is 50 for Firefox and 20 for IE.  Set this to 0 if you want an unlimited number of handles to be displayed.  This is only recommended if the number of cells in the graph is limited to a small number, eg.  500.

enabled

mxGraphHandler.prototype.enabled

Specifies if events are handled.  Default is true.

highlightEnabled

mxGraphHandler.prototype.highlightEnabled

Specifies if drop targets under the mouse should be enabled.  Default is true.

cloneEnabled

mxGraphHandler.prototype.cloneEnabled

Specifies if cloning by control-drag is enabled.  Default is true.

moveEnabled

mxGraphHandler.prototype.moveEnabled

Specifies if moving is enabled.  Default is true.

guidesEnabled

mxGraphHandler.prototype.guidesEnabled

Specifies if other cells should be used for snapping the right, center or left side of the current selection.  Default is false.

guide

mxGraphHandler.prototype.guide

Holds the mxGuide instance that is used for alignment.

currentDx

mxGraphHandler.prototype.currentDx

Stores the x-coordinate of the current mouse move.

currentDy

mxGraphHandler.prototype.currentDy

Stores the y-coordinate of the current mouse move.

updateCursor

mxGraphHandler.prototype.updateCursor

Specifies if a move cursor should be shown if the mouse is over a movable cell.  Default is true.

selectEnabled

mxGraphHandler.prototype.selectEnabled

Specifies if selecting is enabled.  Default is true.

removeCellsFromParent

mxGraphHandler.prototype.removeCellsFromParent

Specifies if cells may be moved out of their parents.  Default is true.

removeEmptyParents

mxGraphHandler.prototype.removeEmptyParents

If empty parents should be removed from the model after all child cells have been moved out.  Default is true.

connectOnDrop

mxGraphHandler.prototype.connectOnDrop

Specifies if drop events are interpreted as new connections if no other drop action is defined.  Default is false.

scrollOnMove

mxGraphHandler.prototype.scrollOnMove

Specifies if the view should be scrolled so that a moved cell is visible.  Default is true.

minimumSize

mxGraphHandler.prototype.minimumSize

Specifies the minimum number of pixels for the width and height of a selection border.  Default is 6.

previewColor

mxGraphHandler.prototype.previewColor

Specifies the color of the preview shape.  Default is black.

htmlPreview

mxGraphHandler.prototype.htmlPreview

Specifies if the graph container should be used for preview.  If this is used then drop target detection relies entirely on mxGraph.getCellAt because the HTML preview does not “let events through”.  Default is false.

shape

mxGraphHandler.prototype.shape

Reference to the mxShape that represents the preview.

scaleGrid

mxGraphHandler.prototype.scaleGrid

Specifies if the grid should be scaled.  Default is false.

rotationEnabled

mxGraphHandler.prototype.rotationEnabled

Specifies if the bounding box should allow for rotation.  Default is true.

maxLivePreview

mxGraphHandler.prototype.maxLivePreview

Maximum number of cells for which live preview should be used.  Default is 0 which means no live preview.

allowLivePreview

mxGraphHandler.prototype.allowLivePreview

If live preview is allowed on this system.  Default is true for systems with SVG support.

Functions

isEnabled

mxGraphHandler.prototype.isEnabled = function()

Returns enabled.

setEnabled

mxGraphHandler.prototype.setEnabled = function(value)

Sets enabled.

isCloneEnabled

mxGraphHandler.prototype.isCloneEnabled = function()

Returns cloneEnabled.

setCloneEnabled

mxGraphHandler.prototype.setCloneEnabled = function(value)

Sets cloneEnabled.

Parameters

valueBoolean that specifies the new clone enabled state.

isMoveEnabled

mxGraphHandler.prototype.isMoveEnabled = function()

Returns moveEnabled.

setMoveEnabled

mxGraphHandler.prototype.setMoveEnabled = function(value)

Sets moveEnabled.

isSelectEnabled

mxGraphHandler.prototype.isSelectEnabled = function()

Returns selectEnabled.

setSelectEnabled

mxGraphHandler.prototype.setSelectEnabled = function(value)

Sets selectEnabled.

isRemoveCellsFromParent

mxGraphHandler.prototype.isRemoveCellsFromParent = function()

Returns removeCellsFromParent.

setRemoveCellsFromParent

mxGraphHandler.prototype.setRemoveCellsFromParent = function(value)

Sets removeCellsFromParent.

getInitialCellForEvent

mxGraphHandler.prototype.getInitialCellForEvent = function(me)

Hook to return initial cell for the given event.

isDelayedSelection

mxGraphHandler.prototype.isDelayedSelection = function(cell,
me)

Hook to return true for delayed selections.

consumeMouseEvent

mxGraphHandler.prototype.consumeMouseEvent = function(evtName,
me)

Consumes the given mouse event.  NOTE: This may be used to enable click events for links in labels on iOS as follows as consuming the initial touchStart disables firing the subsequent click event on the link.

<code> mxGraphHandler.prototype.consumeMouseEvent = function(evtName, me) { var source = mxEvent.getSource(me.getEvent());

if (!mxEvent.isTouchEvent(me.getEvent()) || source.nodeName != ‘A’) { me.consume(); } } </code>

mouseDown

mxGraphHandler.prototype.mouseDown = function(sender,
me)

Handles the event by selecing the given cell and creating a handle for it.  By consuming the event all subsequent events of the gesture are redirected to this handler.

getGuideStates

mxGraphHandler.prototype.getGuideStates = function()

Creates an array of cell states which should be used as guides.

getCells

mxGraphHandler.prototype.getCells = function(initialCell)

Returns the cells to be modified by this handler.  This implementation returns all selection cells that are movable, or the given initial cell if the given cell is not selected and movable.  This handles the case of moving unselectable or unselected cells.

Parameters

initialCellmxCell that triggered this handler.

getPreviewBounds

mxGraphHandler.prototype.getPreviewBounds = function(cells)

Returns the mxRectangle used as the preview bounds for moving the given cells.

getBoundingBox

mxGraphHandler.prototype.getBoundingBox = function(cells)

Returns the union of the mxCellStates for the given array of mxCells.  For vertices, this method uses the bounding box of the corresponding shape if one exists.  The bounding box of the corresponding text label and all controls and overlays are ignored.  See also: mxGraphView.getBounds and mxGraph.getBoundingBox.

Parameters

cellsArray of mxCells whose bounding box should be returned.

createPreviewShape

mxGraphHandler.prototype.createPreviewShape = function(bounds)

Creates the shape used to draw the preview for the given bounds.

start

mxGraphHandler.prototype.start = function(cell,
x,
y,
cells)

Starts the handling of the mouse gesture.

addStates

mxGraphHandler.prototype.addStates = function(cell,
dict)

Adds the states for the given cell recursively to the given dictionary.

isCellMoving

mxGraphHandler.prototype.isCellMoving = function(cell)

Returns true if the given cell is currently being moved.

useGuidesForEvent

mxGraphHandler.prototype.useGuidesForEvent = function(me)

Returns true if the guides should be used for the given mxMouseEvent.  This implementation returns mxGuide.isEnabledForEvent.

snap

mxGraphHandler.prototype.snap = function(vector)

Snaps the given vector to the grid and returns the given mxPoint instance.

getDelta

mxGraphHandler.prototype.getDelta = function(me)

Returns an mxPoint that represents the vector for moving the cells for the given mxMouseEvent.

updateHint

mxGraphHandler.prototype.updateHint = function(me)

Hook for subclassers do show details while the handler is active.

removeHint

mxGraphHandler.prototype.removeHint = function()

Hooks for subclassers to hide details when the handler gets inactive.

roundLength

mxGraphHandler.prototype.roundLength = function(length)

Hook for rounding the unscaled vector.  Allows for half steps in the raster so numbers coming in should be rounded if no half steps are allowed (ie for non aligned standard moving where pixel steps should be preferred).

mouseMove

mxGraphHandler.prototype.mouseMove = function(sender,
me)

Handles the event by highlighting possible drop targets and updating the preview.

updatePreview

mxGraphHandler.prototype.updatePreview = function(remote)

Updates the bounds of the preview shape.

updatePreviewShape

mxGraphHandler.prototype.updatePreviewShape = function()

Updates the bounds of the preview shape.

updateLivePreview

mxGraphHandler.prototype.updateLivePreview = function(dx,
dy)

Updates the bounds of the preview shape.

redrawHandles

mxGraphHandler.prototype.redrawHandles = function(states)

Redraws the preview shape for the given states array.

resetPreviewStates

mxGraphHandler.prototype.resetPreviewStates = function(states)

Resets the given preview states array.

suspend

mxGraphHandler.prototype.suspend = function()

Suspends the livew preview.

resume

mxGraphHandler.prototype.resume = function()

Suspends the livew preview.

resetLivePreview

mxGraphHandler.prototype.resetLivePreview = function()

Resets the livew preview.

reset

Resets the state of this handler.

setHighlightColor

mxGraphHandler.prototype.setHighlightColor = function(color)

Sets the color of the rectangle used to highlight drop targets.

Parameters

colorString that represents the new highlight color.

mouseUp

mxGraphHandler.prototype.mouseUp = function(sender,
me)

Handles the event by applying the changes to the selection cells.

selectDelayed

mxGraphHandler.prototype.selectDelayed = function(me)

Implements the delayed selection for the given mouse event.

reset

mxGraphHandler.prototype.reset = function()

Resets the state of this handler.

shouldRemoveCellsFromParent

mxGraphHandler.prototype.shouldRemoveCellsFromParent = function(parent,
cells,
evt)

Returns true if the given cells should be removed from the parent for the specified mousereleased event.

moveCells

mxGraphHandler.prototype.moveCells = function(cells,
dx,
dy,
clone,
target,
evt)

Moves the given cells by the specified amount.

shouldRemoveParent

mxGraphHandler.prototype.shouldRemoveParent = function(parent)

Returns true if the given parent should be removed after removal of child cells.

destroyShapes

mxGraphHandler.prototype.destroyShapes = function()

Destroy the preview and highlight shapes.

destroy

mxGraphHandler.prototype.destroy = function()

Destroys the handler and all its resources and DOM nodes.

function mxGraphHandler(graph)
Constructs an event handler that creates handles for the selection cells.
mxGraphHandler.prototype.graph
Reference to the enclosing mxGraph.
Extends mxEventSource to implement a graph component for the browser.
mxGraphHandler.prototype.maxCells
Defines the maximum number of cells to paint subhandles for.
mxGraphHandler.prototype.enabled
Specifies if events are handled.
mxGraphHandler.prototype.highlightEnabled
Specifies if drop targets under the mouse should be enabled.
mxGraphHandler.prototype.cloneEnabled
Specifies if cloning by control-drag is enabled.
mxGraphHandler.prototype.moveEnabled
Specifies if moving is enabled.
mxGraphHandler.prototype.guidesEnabled
Specifies if other cells should be used for snapping the right, center or left side of the current selection.
mxGraphHandler.prototype.guide
Holds the mxGuide instance that is used for alignment.
Implements the alignment of selection cells to other cells in the graph.
mxGraphHandler.prototype.currentDx
Stores the x-coordinate of the current mouse move.
mxGraphHandler.prototype.currentDy
Stores the y-coordinate of the current mouse move.
mxGraphHandler.prototype.updateCursor
Specifies if a move cursor should be shown if the mouse is over a movable cell.
mxGraphHandler.prototype.selectEnabled
Specifies if selecting is enabled.
mxGraphHandler.prototype.removeCellsFromParent
Specifies if cells may be moved out of their parents.
mxGraphHandler.prototype.removeEmptyParents
If empty parents should be removed from the model after all child cells have been moved out.
mxGraphHandler.prototype.connectOnDrop
Specifies if drop events are interpreted as new connections if no other drop action is defined.
mxGraphHandler.prototype.scrollOnMove
Specifies if the view should be scrolled so that a moved cell is visible.
mxGraphHandler.prototype.minimumSize
Specifies the minimum number of pixels for the width and height of a selection border.
mxGraphHandler.prototype.previewColor
Specifies the color of the preview shape.
mxGraphHandler.prototype.htmlPreview
Specifies if the graph container should be used for preview.
mxGraphHandler.prototype.shape
Reference to the mxShape that represents the preview.
Base class for all shapes.
mxGraphHandler.prototype.scaleGrid
Specifies if the grid should be scaled.
mxGraphHandler.prototype.rotationEnabled
Specifies if the bounding box should allow for rotation.
mxGraphHandler.prototype.maxLivePreview
Maximum number of cells for which live preview should be used.
mxGraphHandler.prototype.allowLivePreview
If live preview is allowed on this system.
mxGraphHandler.prototype.isEnabled = function()
Returns enabled.
mxGraphHandler.prototype.setEnabled = function(value)
Sets enabled.
mxGraphHandler.prototype.isCloneEnabled = function()
Returns cloneEnabled.
mxGraphHandler.prototype.setCloneEnabled = function(value)
Sets cloneEnabled.
mxGraphHandler.prototype.isMoveEnabled = function()
Returns moveEnabled.
mxGraphHandler.prototype.setMoveEnabled = function(value)
Sets moveEnabled.
mxGraphHandler.prototype.isSelectEnabled = function()
Returns selectEnabled.
mxGraphHandler.prototype.setSelectEnabled = function(value)
Sets selectEnabled.
mxGraphHandler.prototype.isRemoveCellsFromParent = function()
Returns removeCellsFromParent.
mxGraphHandler.prototype.setRemoveCellsFromParent = function(value)
Sets removeCellsFromParent.
mxGraphHandler.prototype.getInitialCellForEvent = function(me)
Hook to return initial cell for the given event.
mxGraphHandler.prototype.isDelayedSelection = function(cell,
me)
Hook to return true for delayed selections.
mxGraphHandler.prototype.consumeMouseEvent = function(evtName,
me)
Consumes the given mouse event.
mxGraphHandler.prototype.mouseDown = function(sender,
me)
Handles the event by selecing the given cell and creating a handle for it.
mxGraphHandler.prototype.getGuideStates = function()
Creates an array of cell states which should be used as guides.
mxGraphHandler.prototype.getCells = function(initialCell)
Returns the cells to be modified by this handler.
mxGraphHandler.prototype.getPreviewBounds = function(cells)
Returns the mxRectangle used as the preview bounds for moving the given cells.
Extends mxPoint to implement a 2-dimensional rectangle with double precision coordinates.
mxGraphHandler.prototype.getBoundingBox = function(cells)
Returns the union of the mxCellStates for the given array of mxCells.
Represents the current state of a cell in a given mxGraphView.
Cells are the elements of the graph model.
mxGraphHandler.prototype.createPreviewShape = function(bounds)
Creates the shape used to draw the preview for the given bounds.
mxGraphHandler.prototype.start = function(cell,
x,
y,
cells)
Starts the handling of the mouse gesture.
mxGraphHandler.prototype.addStates = function(cell,
dict)
Adds the states for the given cell recursively to the given dictionary.
mxGraphHandler.prototype.isCellMoving = function(cell)
Returns true if the given cell is currently being moved.
mxGraphHandler.prototype.useGuidesForEvent = function(me)
Returns true if the guides should be used for the given mxMouseEvent.
Base class for all mouse events in mxGraph.
mxGraphHandler.prototype.snap = function(vector)
Snaps the given vector to the grid and returns the given mxPoint instance.
mxGraphHandler.prototype.getDelta = function(me)
Returns an mxPoint that represents the vector for moving the cells for the given mxMouseEvent.
Implements a 2-dimensional vector with double precision coordinates.
mxGraphHandler.prototype.updateHint = function(me)
Hook for subclassers do show details while the handler is active.
mxGraphHandler.prototype.removeHint = function()
Hooks for subclassers to hide details when the handler gets inactive.
mxGraphHandler.prototype.roundLength = function(length)
Hook for rounding the unscaled vector.
mxGraphHandler.prototype.mouseMove = function(sender,
me)
Handles the event by highlighting possible drop targets and updating the preview.
mxGraphHandler.prototype.updatePreview = function(remote)
Updates the bounds of the preview shape.
mxGraphHandler.prototype.updatePreviewShape = function()
Updates the bounds of the preview shape.
mxGraphHandler.prototype.updateLivePreview = function(dx,
dy)
Updates the bounds of the preview shape.
mxGraphHandler.prototype.redrawHandles = function(states)
Redraws the preview shape for the given states array.
mxGraphHandler.prototype.resetPreviewStates = function(states)
Resets the given preview states array.
mxGraphHandler.prototype.suspend = function()
Suspends the livew preview.
mxGraphHandler.prototype.resume = function()
Suspends the livew preview.
mxGraphHandler.prototype.resetLivePreview = function()
Resets the livew preview.
mxGraphHandler.prototype.setHighlightColor = function(color)
Sets the color of the rectangle used to highlight drop targets.
mxGraphHandler.prototype.mouseUp = function(sender,
me)
Handles the event by applying the changes to the selection cells.
mxGraphHandler.prototype.selectDelayed = function(me)
Implements the delayed selection for the given mouse event.
mxGraphHandler.prototype.reset = function()
Resets the state of this handler.
mxGraphHandler.prototype.shouldRemoveCellsFromParent = function(parent,
cells,
evt)
Returns true if the given cells should be removed from the parent for the specified mousereleased event.
mxGraphHandler.prototype.moveCells = function(cells,
dx,
dy,
clone,
target,
evt)
Moves the given cells by the specified amount.
mxGraphHandler.prototype.shouldRemoveParent = function(parent)
Returns true if the given parent should be removed after removal of child cells.
mxGraphHandler.prototype.destroyShapes = function()
Destroy the preview and highlight shapes.
mxGraphHandler.prototype.destroy = function()
Destroys the handler and all its resources and DOM nodes.
Event handler for resizing cells.
mxGraph.prototype.createHandler = function(state)
Creates a new handler for the given cell state.
mxGraphSelectionModel.prototype.cellAdded = function(cell)
Inner callback to add the specified mxCell to the selection.
mxGraph.prototype.getCellAt = function(x,
y,
parent,
vertices,
edges,
ignoreFn)
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.
mxGraphView.prototype.getBounds = function(cells)
Returns the union of all mxCellStates for the given array of mxCells.
mxGraph.prototype.getBoundingBox = function(cells)
Returns the bounding box for the given array of mxCells.
mxGuide.prototype.isEnabledForEvent = function(evt)
Returns true if the guide should be enabled for the given native event.
Close