Event handler for resizing cells. This handler is automatically created in mxGraph.createHandler.
mxVertexHandler | Event handler for resizing cells. |
Functions | |
mxVertexHandler | Constructs an event handler that allows to resize vertices and groups. |
Variables | |
graph | Reference to the enclosing mxGraph. |
state | Reference to the mxCellState being modified. |
singleSizer | Specifies if only one sizer handle at the bottom, right corner should be used. |
index | Holds the index of the current handle. |
allowHandleBoundsCheck | Specifies if the bounds of handles should be used for hit-detection in IE or if tolerance > 0. |
handleImage | Optional mxImage to be used as handles. |
tolerance | Optional tolerance for hit-detection in getHandleForEvent. |
rotationEnabled | Specifies if a rotation handle should be visible. |
rotationRaster | Specifies if rotation steps should be “rasterized” depening on the distance to the handle. |
livePreview | Specifies if resize should change the cell in-place. |
manageSizers | Specifies if sizers should be hidden and spaced if the vertex is small. |
Functions | |
init | Initializes the shapes required for this vertex handler. |
getSelectionBounds | Returns the mxRectangle that defines the bounds of the selection border. |
createSelectionShape | Creates the shape used to draw the selection border. |
getSelectionColor | Returns mxConstants.VERTEX_SELECTION_COLOR. |
getSelectionStrokeWidth | Returns mxConstants.VERTEX_SELECTION_STROKEWIDTH. |
isSelectionDashed | Returns <mxConstants.VERTEX_SELECTION_DASHED>. |
createSizer | Creates a sizer handle for the specified cursor and index and returns the new mxRectangleShape that represents the handle. |
isSizerVisible | Returns true if the sizer for the given index is visible. |
createSizerShape | Creates the shape used for the sizer handle for the specified bounds and index. |
createBounds | Helper method to create an mxRectangle around the given centerpoint with a width and height of 2*s or 6, if no s is given. |
getHandleForEvent | Returns the index of the handle for the given event. |
mouseDown | Handles the event if a handle has been clicked. |
start | Starts the handling of the mouse gesture. |
hideSizers | Hides all sizers except. |
checkTolerance | Checks if the coordinates for the given event are within the mxGraph.tolerance. |
mouseMove | Handles the event by updating the preview. |
mouseUp | Handles the event by applying the changes to the geometry. |
rotateCell | Rotates the given cell to the given rotation. |
reset | Resets the state of this handler. |
resizeCell | Uses the given vector to change the bounds of the given cell in the graph using mxGraph.resizeCell. |
moveChildren | Moves the children of the given cell by the given vector. |
union | Returns the union of the given bounds and location for the specified handle index. |
redraw | Redraws the handles and the preview. |
redrawHandles | Redraws the handles. |
drawPreview | Redraws the preview. |
destroy | Destroys the handler and all its resources and DOM nodes. |
function mxVertexHandler( state )
Constructs an event handler that allows to resize vertices and groups.
state | mxCellState of the cell to be resized. |
mxVertexHandler.prototype.graph
Reference to the enclosing mxGraph.
mxVertexHandler.prototype.state
Reference to the mxCellState being modified.
mxVertexHandler.prototype.allowHandleBoundsCheck
Specifies if the bounds of handles should be used for hit-detection in IE or if tolerance > 0. Default is true.
mxVertexHandler.prototype.handleImage
Optional mxImage to be used as handles. Default is null.
mxVertexHandler.prototype.tolerance
Optional tolerance for hit-detection in getHandleForEvent. Default is 0.
mxVertexHandler.prototype.getSelectionColor = function()
Returns mxConstants.VERTEX_SELECTION_COLOR.
mxVertexHandler.prototype.createSizer = function( cursor, index, size, fillColor )
Creates a sizer handle for the specified cursor and index and returns the new mxRectangleShape that represents the handle.
Helper method to create an mxRectangle around the given centerpoint with a width and height of 2*s or 6, if no s is given.
mxVertexHandler.prototype.checkTolerance = function( me )
Checks if the coordinates for the given event are within the mxGraph.tolerance. If the event is a mouse event then the tolerance is ignored.
mxVertexHandler.prototype.resizeCell = function( cell, dx, dy, index, gridEnabled )
Uses the given vector to change the bounds of the given cell in the graph using mxGraph.resizeCell.
mxVertexHandler.prototype.union = function( bounds, dx, dy, index, gridEnabled, scale, tr )
Returns the union of the given bounds and location for the specified handle index.
To override this to limit the size of vertex via a minWidth/-Height style, the following code can be used.
var vertexHandlerUnion = mxVertexHandler.prototype.union; mxVertexHandler.prototype.union = function(bounds, dx, dy, index, gridEnabled, scale, tr) { var result = vertexHandlerUnion.apply(this, arguments); result.width = Math.max(result.width, mxUtils.getNumber(this.state.style, 'minWidth', 0)); result.height = Math.max(result.height, mxUtils.getNumber(this.state.style, 'minHeight', 0)); return result; };
graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30, 'minWidth=100;minHeight=100;');
To override this to update the height for a wrapped text if the width of a vertex is changed, the following can be used.
var mxVertexHandlerUnion = mxVertexHandler.prototype.union; mxVertexHandler.prototype.union = function(bounds, dx, dy, index, gridEnabled, scale, tr) { var result = mxVertexHandlerUnion.apply(this, arguments); var s = this.state; if (this.graph.isHtmlLabel(s.cell) && (index == 3 || index == 4) && s.text != null && s.style[mxConstants.STYLE_WHITE_SPACE] == 'wrap') { var label = this.graph.getLabel(s.cell); var fontSize = mxUtils.getNumber(s.style, mxConstants.STYLE_FONTSIZE, mxConstants.DEFAULT_FONTSIZE); var ww = result.width / s.view.scale - s.text.spacingRight - s.text.spacingLeft result.height = mxUtils.getSizeForString(label, fontSize, s.style[mxConstants.STYLE_FONTFAMILY], ww).height; } return result; };
mxVertexHandler.prototype.redrawHandles = function()
Redraws the handles. To hide certain handles the following code can be used.
mxVertexHandler.prototype.redrawHandles = function() { mxVertexHandlerRedrawHandles.apply(this, arguments); if (this.sizers != null && this.sizers.length > 7) { this.sizers[1].node.style.display = 'none'; this.sizers[6].node.style.display = 'none'; } };
Constructs an event handler that allows to resize vertices and groups.
function mxVertexHandler( state )
Reference to the enclosing mxGraph.
mxVertexHandler.prototype.graph
Reference to the mxCellState being modified.
mxVertexHandler.prototype.state
Specifies if only one sizer handle at the bottom, right corner should be used.
mxVertexHandler.prototype.singleSizer
Holds the index of the current handle.
mxVertexHandler.prototype.index
Specifies if the bounds of handles should be used for hit-detection in IE or if tolerance > 0.
mxVertexHandler.prototype.allowHandleBoundsCheck
Optional tolerance for hit-detection in getHandleForEvent.
mxVertexHandler.prototype.tolerance
Optional mxImage to be used as handles.
mxVertexHandler.prototype.handleImage
Returns the index of the handle for the given event.
mxVertexHandler.prototype.getHandleForEvent = function( me )
Specifies if a rotation handle should be visible.
mxVertexHandler.prototype.rotationEnabled
Specifies if rotation steps should be “rasterized” depening on the distance to the handle.
mxVertexHandler.prototype.rotationRaster
Specifies if resize should change the cell in-place.
mxVertexHandler.prototype.livePreview
Specifies if sizers should be hidden and spaced if the vertex is small.
mxVertexHandler.prototype.manageSizers
Initializes the shapes required for this vertex handler.
mxVertexHandler.prototype.init = function()
Returns the mxRectangle that defines the bounds of the selection border.
mxVertexHandler.prototype.getSelectionBounds = function( state )
Creates the shape used to draw the selection border.
mxVertexHandler.prototype.createSelectionShape = function( bounds )
Returns mxConstants.VERTEX_SELECTION_COLOR.
mxVertexHandler.prototype.getSelectionColor = function()
Returns mxConstants.VERTEX_SELECTION_STROKEWIDTH.
mxVertexHandler.prototype.getSelectionStrokeWidth = function()
Returns mxConstants.VERTEX_SELECTION_DASHED.
mxVertexHandler.prototype.isSelectionDashed = function()
Creates a sizer handle for the specified cursor and index and returns the new mxRectangleShape that represents the handle.
mxVertexHandler.prototype.createSizer = function( cursor, index, size, fillColor )
Returns true if the sizer for the given index is visible.
mxVertexHandler.prototype.isSizerVisible = function( index )
Creates the shape used for the sizer handle for the specified bounds and index.
mxVertexHandler.prototype.createSizerShape = function( bounds, index, fillColor )
Handles the event if a handle has been clicked.
mxVertexHandler.prototype.mouseDown = function( sender, me )
Starts the handling of the mouse gesture.
mxVertexHandler.prototype.start = function( x, y, index )
Hides all sizers except.
mxVertexHandler.prototype.hideSizers = function()
Checks if the coordinates for the given event are within the mxGraph.tolerance.
mxVertexHandler.prototype.checkTolerance = function( me )
Tolerance for a move to be handled as a single click.
mxGraph.prototype.tolerance
Handles the event by updating the preview.
mxVertexHandler.prototype.mouseMove = function( sender, me )
Handles the event by applying the changes to the geometry.
mxVertexHandler.prototype.mouseUp = function( sender, me )
Rotates the given cell to the given rotation.
mxVertexHandler.prototype.rotateCell = function( cell, delta )
Resets the state of this handler.
mxVertexHandler.prototype.reset = function()
Uses the given vector to change the bounds of the given cell in the graph using mxGraph.resizeCell.
mxVertexHandler.prototype.resizeCell = function( cell, dx, dy, index, gridEnabled )
Sets the bounds of the given cell using resizeCells.
mxGraph.prototype.resizeCell = function( cell, bounds )
Moves the children of the given cell by the given vector.
mxVertexHandler.prototype.moveChildren = function( cell, dx, dy )
Returns the union of the given bounds and location for the specified handle index.
mxVertexHandler.prototype.union = function( bounds, dx, dy, index, gridEnabled, scale, tr )
Redraws the handles and the preview.
mxVertexHandler.prototype.redraw = function()
Redraws the handles.
mxVertexHandler.prototype.redrawHandles = function()
Redraws the preview.
mxVertexHandler.prototype.drawPreview = function()
Destroys the handler and all its resources and DOM nodes.
mxVertexHandler.prototype.destroy = function()
Creates a new handler for the given cell state.
mxGraph.prototype.createHandler = function( state )