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 ove a movable cell.
selectEnabledSpecifies if selecting is enabled.
removeCellsFromParentSpecifies if cells may be moved out of their parents.
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.
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.
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 mxRectangle that represents the bounding box for the given cells.
createPreviewShapeCreates the shape used to draw the preview for the given bounds.
startStarts the handling of the mouse gesture.
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.
mouseMoveHandles the event by highlighting possible drop targets and updating the preview.
updatePreviewShapeUpdates the bounds of the preview shape.
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.
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 ove 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.

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.

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)

Hook to return true for delayed selections.

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 mxRectangle that represents the bounding box for the given cells.  If bbox is true then the paint bounding box is 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)

Starts the handling of the mouse gesture.

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.

mouseMove

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

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

updatePreviewShape

mxGraphHandler.prototype.updatePreviewShape = function()

Updates the bounds of the preview shape.

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.

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 ove 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.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.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)
Hook to return true for delayed selections.
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 mxRectangle that represents the bounding box for the given cells.
mxGraphHandler.prototype.createPreviewShape = function(bounds)
Creates the shape used to draw the preview for the given bounds.
mxGraphHandler.prototype.start = function(cell,
x,
y)
Starts the handling of the mouse gesture.
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.mouseMove = function(sender,
me)
Handles the event by highlighting possible drop targets and updating the preview.
mxGraphHandler.prototype.updatePreviewShape = function()
Updates the bounds of the preview shape.
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.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)
Returns the bottom-most cell that intersects the given point (x, y) in the cell hierarchy starting at the given parent.
Cells are the elements of the graph model.
mxGuide.prototype.isEnabledForEvent = function(evt)
Returns true if the guide should be enabled for the given native event.
Close