mxEdgeHandler

Graph event handler that reconnects edges and modifies control points and the edge label location.  Uses <mxTerminalMarker> for finding and highlighting new source and target vertices.  This handler is automatically created in mxGraph.createHandler for each selected edge.

To enable adding/removing control points, the following code can be used

mxEdgeHandler.prototype.addEnabled = true;
mxEdgeHandler.prototype.removeEnabled = true;

Note: This experimental feature is not recommended for production use.

Summary
mxEdgeHandlerGraph event handler that reconnects edges and modifies control points and the edge label location.
Functions
mxEdgeHandlerConstructs an edge handler for the specified mxCellState.
Variables
graphReference to the enclosing mxGraph.
stateReference to the mxCellState being modified.
markerHolds the <mxTerminalMarker> which is used for highlighting terminals.
constraintHandlerHolds the mxConstraintHandler used for drawing and highlighting constraints.
errorHolds the current validation error while a connection is being changed.
shapeHolds the mxShape that represents the preview edge.
bendsHolds the mxShapes that represent the points.
labelShapeHolds the mxShape that represents the label position.
cloneEnabledSpecifies if cloning by control-drag is enabled.
addEnabledSpecifies if adding bends by shift-click is enabled.
removeEnabledSpecifies if removing bends by shift-click is enabled.
preferHtmlSpecifies if bends should be added to the graph container.
allowHandleBoundsCheckSpecifies if the bounds of handles should be used for hit-detection in IE Default is true.
snapToTerminalsSpecifies if waypoints should snap to the routing centers of terminals.
handleImageOptional mxImage to be used as handles.
toleranceOptional tolerance for hit-detection in getHandleForEvent.
Functions
initInitializes the shapes required for this edge handler.
isAddPointEventReturns true if the given event is a trigger to add a new point.
isRemovePointEventReturns true if the given event is a trigger to remove a point.
getSelectionPointsReturns the list of points that defines the selection stroke.
createSelectionShapeCreates the shape used to draw the selection border.
getSelectionColorReturns mxConstants.EDGE_SELECTION_COLOR.
getSelectionStrokeWidthReturns mxConstants.EDGE_SELECTION_STROKEWIDTH.
isSelectionDashedReturns <mxConstants.EDGE_SELECTION_DASHED>.
isConnectableCellReturns true if the given cell is connectable.
createMarkerCreates and returns the mxCellMarker used in marker.
validateConnectionReturns the error message or an empty string if the connection for the given source, target pair is not valid.
createBendsCreates and returns the bends used for modifying the edge.
isHandleEnabledCreates the shape used to display the given bend.
isHandleVisibleReturns true if the handle at the given index is visible.
createHandleShapeCreates the shape used to display the given bend.
initBendHelper method to initialize the given bend.
getHandleForEventReturns the index of the handle for the given event.
mouseDownHandles the event by checking if a special element of the handler was clicked, in which case the index parameter is non-null.
startStarts the handling of the mouse gesture.
clonePreviewStateReturns a clone of the current preview state for the given point and terminal.
getSnapToTerminalToleranceReturns the tolerance for the guides.
getPointForEventReturns the point for the given event.
getPreviewTerminalStateUpdates the given preview state taking into account the state of the constraint handler.
getPreviewPointsUpdates the given preview state taking into account the state of the constraint handler.
updatePreviewStateUpdates the given preview state taking into account the state of the constraint handler.
mouseMoveHandles the event by updating the preview.
mouseUpHandles the event to applying the previewed changes on the edge by using moveLabel, connect or changePoints.
resetResets the state of this handler.
setPreviewColorSets the color of the preview to the given value.
convertPointConverts the given point in-place from screen to unscaled, untranslated graph coordinates and applies the grid.
moveLabelChanges the coordinates for the label of the given edge.
connectChanges the terminal or terminal point of the given edge in the graph model.
changeTerminalPointChanges the terminal point of the given edge.
changePointsChanges the control points of the given edge in the graph model.
addPointAdds a control point for the given state and event.
addPointAtAdds a control point at the given point.
removePointRemoves the control point at the given index from the given state.
getHandleFillColorReturns the fillcolor for the handle at the given index.
redrawRedraws the preview, and the bends- and label control points.
redrawHandlesRedraws the handles.
redrawInnerBendsUpdates and redraws the inner bends.
drawPreviewRedraws the preview.
destroyDestroys the handler and all its resources and DOM nodes.

Functions

mxEdgeHandler

function mxEdgeHandler(state)

Constructs an edge handler for the specified mxCellState.

Parameters

statemxCellState of the cell to be handled.

Variables

graph

mxEdgeHandler.prototype.graph

Reference to the enclosing mxGraph.

state

mxEdgeHandler.prototype.state

Reference to the mxCellState being modified.

marker

mxEdgeHandler.prototype.marker

Holds the <mxTerminalMarker> which is used for highlighting terminals.

constraintHandler

mxEdgeHandler.prototype.constraintHandler

Holds the mxConstraintHandler used for drawing and highlighting constraints.

error

mxEdgeHandler.prototype.error

Holds the current validation error while a connection is being changed.

shape

mxEdgeHandler.prototype.shape

Holds the mxShape that represents the preview edge.

bends

mxEdgeHandler.prototype.bends

Holds the mxShapes that represent the points.

labelShape

mxEdgeHandler.prototype.labelShape

Holds the mxShape that represents the label position.

cloneEnabled

mxEdgeHandler.prototype.cloneEnabled

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

addEnabled

mxEdgeHandler.prototype.addEnabled

Specifies if adding bends by shift-click is enabled.  Default is false.  Note: This experimental feature is not recommended for production use.

removeEnabled

mxEdgeHandler.prototype.removeEnabled

Specifies if removing bends by shift-click is enabled.  Default is false.  Note: This experimental feature is not recommended for production use.

preferHtml

mxEdgeHandler.prototype.preferHtml

Specifies if bends should be added to the graph container.  This is updated in init based on whether the edge or one of its terminals has an HTML label in the container.

allowHandleBoundsCheck

mxEdgeHandler.prototype.allowHandleBoundsCheck

Specifies if the bounds of handles should be used for hit-detection in IE Default is true.

snapToTerminals

mxEdgeHandler.prototype.snapToTerminals

Specifies if waypoints should snap to the routing centers of terminals.  Default is false.

handleImage

mxEdgeHandler.prototype.handleImage

Optional mxImage to be used as handles.  Default is null.

tolerance

mxEdgeHandler.prototype.tolerance

Optional tolerance for hit-detection in getHandleForEvent.  Default is 0.

Functions

init

mxEdgeHandler.prototype.init = function()

Initializes the shapes required for this edge handler.

isAddPointEvent

mxEdgeHandler.prototype.isAddPointEvent = function(evt)

Returns true if the given event is a trigger to add a new point.  This implementation returns true if shift is pressed.

isRemovePointEvent

mxEdgeHandler.prototype.isRemovePointEvent = function(evt)

Returns true if the given event is a trigger to remove a point.  This implementation returns true if shift is pressed.

getSelectionPoints

mxEdgeHandler.prototype.getSelectionPoints = function(state)

Returns the list of points that defines the selection stroke.

createSelectionShape

mxEdgeHandler.prototype.createSelectionShape = function(points)

Creates the shape used to draw the selection border.

getSelectionColor

mxEdgeHandler.prototype.getSelectionColor = function()

Returns mxConstants.EDGE_SELECTION_COLOR.

getSelectionStrokeWidth

mxEdgeHandler.prototype.getSelectionStrokeWidth = function()

Returns mxConstants.EDGE_SELECTION_STROKEWIDTH.

isSelectionDashed

mxEdgeHandler.prototype.isSelectionDashed = function()

Returns <mxConstants.EDGE_SELECTION_DASHED>.

isConnectableCell

mxEdgeHandler.prototype.isConnectableCell = function(cell)

Returns true if the given cell is connectable.  This is a hook to disable floating connections.  This implementation returns true.

createMarker

mxEdgeHandler.prototype.createMarker = function()

Creates and returns the mxCellMarker used in marker.

validateConnection

mxEdgeHandler.prototype.validateConnection = function(source,
target)

Returns the error message or an empty string if the connection for the given source, target pair is not valid.  Otherwise it returns null.  This implementation uses mxGraph.getEdgeValidationError.

Parameters

sourcemxCell that represents the source terminal.
targetmxCell that represents the target terminal.

createBends

mxEdgeHandler.prototype.createBends = function()

Creates and returns the bends used for modifying the edge.  This is typically an array of mxRectangleShapes.

isHandleEnabled

mxEdgeHandler.prototype.isHandleEnabled = function(index)

Creates the shape used to display the given bend.

isHandleVisible

mxEdgeHandler.prototype.isHandleVisible = function(index)

Returns true if the handle at the given index is visible.

createHandleShape

mxEdgeHandler.prototype.createHandleShape = function(index)

Creates the shape used to display the given bend.  Note that the index may be null for special cases, such as when called from mxElbowEdgeHandler.createVirtualBend.  Only images and rectangles should be returned if support for HTML labels with not foreign objects is required.

initBend

mxEdgeHandler.prototype.initBend = function(bend)

Helper method to initialize the given bend.

Parameters

bendmxShape that represents the bend to be initialized.

getHandleForEvent

mxEdgeHandler.prototype.getHandleForEvent = function(me)

Returns the index of the handle for the given event.

mouseDown

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

Handles the event by checking if a special element of the handler was clicked, in which case the index parameter is non-null.  The indices may be one of <LABEL_HANDLE> or the number of the respective control point.  The source and target points are used for reconnecting the edge.

start

mxEdgeHandler.prototype.start = function(x,
y,
index)

Starts the handling of the mouse gesture.

clonePreviewState

mxEdgeHandler.prototype.clonePreviewState = function(point,
terminal)

Returns a clone of the current preview state for the given point and terminal.

getSnapToTerminalTolerance

mxEdgeHandler.prototype.getSnapToTerminalTolerance = function()

Returns the tolerance for the guides.  Default value is gridSize * scale / 2.

getPointForEvent

mxEdgeHandler.prototype.getPointForEvent = function(me)

Returns the point for the given event.

getPreviewTerminalState

mxEdgeHandler.prototype.getPreviewTerminalState = function(me)

Updates the given preview state taking into account the state of the constraint handler.

getPreviewPoints

mxEdgeHandler.prototype.getPreviewPoints = function(point)

Updates the given preview state taking into account the state of the constraint handler.

updatePreviewState

mxEdgeHandler.prototype.updatePreviewState = function(edge,
point,
terminalState)

Updates the given preview state taking into account the state of the constraint handler.

mouseMove

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

Handles the event by updating the preview.

mouseUp

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

Handles the event to applying the previewed changes on the edge by using moveLabel, connect or changePoints.

reset

mxEdgeHandler.prototype.reset = function()

Resets the state of this handler.

setPreviewColor

mxEdgeHandler.prototype.setPreviewColor = function(color)

Sets the color of the preview to the given value.

convertPoint

mxEdgeHandler.prototype.convertPoint = function(point,
gridEnabled)

Converts the given point in-place from screen to unscaled, untranslated graph coordinates and applies the grid.  Returns the given, modified point instance.

Parameters

pointmxPoint to be converted.
gridEnabledBoolean that specifies if the grid should be applied.

moveLabel

mxEdgeHandler.prototype.moveLabel = function(edgeState,
x,
y)

Changes the coordinates for the label of the given edge.

Parameters

edgemxCell that represents the edge.
xInteger that specifies the x-coordinate of the new location.
yInteger that specifies the y-coordinate of the new location.

connect

mxEdgeHandler.prototype.connect = function(edge,
terminal,
isSource,
isClone,
me)

Changes the terminal or terminal point of the given edge in the graph model.

Parameters

edgemxCell that represents the edge to be reconnected.
terminalmxCell that represents the new terminal.
isSourceBoolean indicating if the new terminal is the source or target terminal.
isCloneBoolean indicating if the new connection should be a clone of the old edge.
memxMouseEvent that contains the mouse up event.

changeTerminalPoint

mxEdgeHandler.prototype.changeTerminalPoint = function(edge,
point,
isSource)

Changes the terminal point of the given edge.

changePoints

mxEdgeHandler.prototype.changePoints = function(edge,
points)

Changes the control points of the given edge in the graph model.

addPoint

mxEdgeHandler.prototype.addPoint = function(state,
evt)

Adds a control point for the given state and event.

addPointAt

mxEdgeHandler.prototype.addPointAt = function(state,
x,
y)

Adds a control point at the given point.

removePoint

mxEdgeHandler.prototype.removePoint = function(state,
index)

Removes the control point at the given index from the given state.

getHandleFillColor

mxEdgeHandler.prototype.getHandleFillColor = function(index)

Returns the fillcolor for the handle at the given index.

redraw

mxEdgeHandler.prototype.redraw = function()

Redraws the preview, and the bends- and label control points.

redrawHandles

mxEdgeHandler.prototype.redrawHandles = function()

Redraws the handles.

redrawInnerBends

mxEdgeHandler.prototype.redrawInnerBends = function(p0,
pe)

Updates and redraws the inner bends.

Parameters

p0mxPoint that represents the location of the first point.
pemxPoint that represents the location of the last point.

drawPreview

mxEdgeHandler.prototype.drawPreview = function()

Redraws the preview.

destroy

mxEdgeHandler.prototype.destroy = function()

Destroys the handler and all its resources and DOM nodes.  This does normally not need to be called as handlers are destroyed automatically when the corresponding cell is deselected.

function mxEdgeHandler(state)
Constructs an edge handler for the specified mxCellState.
Represents the current state of a cell in a given mxGraphView.
mxEdgeHandler.prototype.graph
Reference to the enclosing mxGraph.
Extends mxEventSource to implement a graph component for the browser.
mxEdgeHandler.prototype.state
Reference to the mxCellState being modified.
mxEdgeHandler.prototype.marker
Holds the mxTerminalMarker which is used for highlighting terminals.
mxEdgeHandler.prototype.constraintHandler
Holds the mxConstraintHandler used for drawing and highlighting constraints.
Handles constraints on connection targets.
mxEdgeHandler.prototype.error
Holds the current validation error while a connection is being changed.
mxEdgeHandler.prototype.shape
Holds the mxShape that represents the preview edge.
Base class for all shapes.
mxEdgeHandler.prototype.bends
Holds the mxShapes that represent the points.
mxEdgeHandler.prototype.labelShape
Holds the mxShape that represents the label position.
mxEdgeHandler.prototype.cloneEnabled
Specifies if cloning by control-drag is enabled.
mxEdgeHandler.prototype.addEnabled
Specifies if adding bends by shift-click is enabled.
mxEdgeHandler.prototype.removeEnabled
Specifies if removing bends by shift-click is enabled.
mxEdgeHandler.prototype.preferHtml
Specifies if bends should be added to the graph container.
mxEdgeHandler.prototype.allowHandleBoundsCheck
Specifies if the bounds of handles should be used for hit-detection in IE Default is true.
mxEdgeHandler.prototype.snapToTerminals
Specifies if waypoints should snap to the routing centers of terminals.
mxEdgeHandler.prototype.handleImage
Optional mxImage to be used as handles.
Encapsulates the URL, width and height of an image.
mxEdgeHandler.prototype.tolerance
Optional tolerance for hit-detection in getHandleForEvent.
mxEdgeHandler.prototype.getHandleForEvent = function(me)
Returns the index of the handle for the given event.
mxEdgeHandler.prototype.init = function()
Initializes the shapes required for this edge handler.
mxEdgeHandler.prototype.isAddPointEvent = function(evt)
Returns true if the given event is a trigger to add a new point.
mxEdgeHandler.prototype.isRemovePointEvent = function(evt)
Returns true if the given event is a trigger to remove a point.
mxEdgeHandler.prototype.getSelectionPoints = function(state)
Returns the list of points that defines the selection stroke.
mxEdgeHandler.prototype.createSelectionShape = function(points)
Creates the shape used to draw the selection border.
mxEdgeHandler.prototype.getSelectionColor = function()
Returns mxConstants.EDGE_SELECTION_COLOR.
Defines the color to be used for the selection border of edges.
mxEdgeHandler.prototype.getSelectionStrokeWidth = function()
Returns mxConstants.EDGE_SELECTION_STROKEWIDTH.
Defines the strokewidth to be used for edge selections.
mxEdgeHandler.prototype.isSelectionDashed = function()
Returns mxConstants.EDGE_SELECTION_DASHED.
mxEdgeHandler.prototype.isConnectableCell = function(cell)
Returns true if the given cell is connectable.
mxEdgeHandler.prototype.createMarker = function()
Creates and returns the mxCellMarker used in marker.
A helper class to process mouse locations and highlight cells.
mxEdgeHandler.prototype.validateConnection = function(source,
target)
Returns the error message or an empty string if the connection for the given source, target pair is not valid.
mxEdgeHandler.prototype.createBends = function()
Creates and returns the bends used for modifying the edge.
mxEdgeHandler.prototype.isHandleEnabled = function(index)
Creates the shape used to display the given bend.
mxEdgeHandler.prototype.isHandleVisible = function(index)
Returns true if the handle at the given index is visible.
mxEdgeHandler.prototype.createHandleShape = function(index)
Creates the shape used to display the given bend.
mxEdgeHandler.prototype.initBend = function(bend)
Helper method to initialize the given bend.
mxEdgeHandler.prototype.mouseDown = function(sender,
me)
Handles the event by checking if a special element of the handler was clicked, in which case the index parameter is non-null.
mxEdgeHandler.prototype.start = function(x,
y,
index)
Starts the handling of the mouse gesture.
mxEdgeHandler.prototype.clonePreviewState = function(point,
terminal)
Returns a clone of the current preview state for the given point and terminal.
mxEdgeHandler.prototype.getSnapToTerminalTolerance = function()
Returns the tolerance for the guides.
mxEdgeHandler.prototype.getPointForEvent = function(me)
Returns the point for the given event.
mxEdgeHandler.prototype.getPreviewTerminalState = function(me)
Updates the given preview state taking into account the state of the constraint handler.
mxEdgeHandler.prototype.getPreviewPoints = function(point)
Updates the given preview state taking into account the state of the constraint handler.
mxEdgeHandler.prototype.updatePreviewState = function(edge,
point,
terminalState)
Updates the given preview state taking into account the state of the constraint handler.
mxEdgeHandler.prototype.mouseMove = function(sender,
me)
Handles the event by updating the preview.
mxEdgeHandler.prototype.mouseUp = function(sender,
me)
Handles the event to applying the previewed changes on the edge by using moveLabel, connect or changePoints.
mxEdgeHandler.prototype.moveLabel = function(edgeState,
x,
y)
Changes the coordinates for the label of the given edge.
mxEdgeHandler.prototype.connect = function(edge,
terminal,
isSource,
isClone,
me)
Changes the terminal or terminal point of the given edge in the graph model.
mxEdgeHandler.prototype.changePoints = function(edge,
points)
Changes the control points of the given edge in the graph model.
mxEdgeHandler.prototype.reset = function()
Resets the state of this handler.
mxEdgeHandler.prototype.setPreviewColor = function(color)
Sets the color of the preview to the given value.
mxEdgeHandler.prototype.convertPoint = function(point,
gridEnabled)
Converts the given point in-place from screen to unscaled, untranslated graph coordinates and applies the grid.
mxEdgeHandler.prototype.changeTerminalPoint = function(edge,
point,
isSource)
Changes the terminal point of the given edge.
mxEdgeHandler.prototype.addPoint = function(state,
evt)
Adds a control point for the given state and event.
mxEdgeHandler.prototype.addPointAt = function(state,
x,
y)
Adds a control point at the given point.
mxEdgeHandler.prototype.removePoint = function(state,
index)
Removes the control point at the given index from the given state.
mxEdgeHandler.prototype.getHandleFillColor = function(index)
Returns the fillcolor for the handle at the given index.
mxEdgeHandler.prototype.redraw = function()
Redraws the preview, and the bends- and label control points.
mxEdgeHandler.prototype.redrawHandles = function()
Redraws the handles.
mxEdgeHandler.prototype.redrawInnerBends = function(p0,
pe)
Updates and redraws the inner bends.
mxEdgeHandler.prototype.drawPreview = function()
Redraws the preview.
mxEdgeHandler.prototype.destroy = function()
Destroys the handler and all its resources and DOM nodes.
mxGraph.prototype.createHandler = function(state)
Creates a new handler for the given cell state.
mxGraph.prototype.getEdgeValidationError = function(edge,
source,
target)
Returns the validation error message to be displayed when inserting or changing an edges’ connectivity.
Cells are the elements of the graph model.
Extends mxShape to implement a rectangle shape.
mxElbowEdgeHandler.prototype.createVirtualBend = function()
Creates a virtual bend that supports double clicking and calls mxGraph.flipEdge.
Implements a 2-dimensional vector with double precision coordinates.
Base class for all mouse events in mxGraph.
Close