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. |
parentHighlightEnabled | Specifies if the parent should be highlighted if a child cell is selected. |
rotationRaster | Specifies if rotation steps should be “rasterized” depening on the distance to the handle. |
rotationCursor | Specifies the cursor for the rotation 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. |
constrainGroupByChildren | Specifies if the size of groups should be constrained by the children. |
rotationHandleVSpacing | Vertical spacing for rotation icon. |
horizontalOffset | The horizontal offset for the handles. |
verticalOffset | The horizontal offset for the handles. |
Functions | |
init | Initializes the shapes required for this vertex handler. |
isRotationHandleVisible | Returns true if the rotation handle should be showing. |
isConstrainedEvent | Returns true if the aspect ratio if the cell should be maintained. |
isCenteredEvent | Returns true if the center of the vertex should be maintained during the resize. |
createCustomHandles | Returns an array of custom handles. |
updateMinBounds | Initializes the shapes required for this vertex handler. |
getSelectionBounds | Returns the mxRectangle that defines the bounds of the selection border. |
createParentHighlightShape | Creates the shape used to draw 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 an 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. |
isCustomHandleEvent | Returns true if the given event allows custom handles to be changed. |
mouseDown | Handles the event if a handle has been clicked. |
isLivePreviewBorder | Called if livePreview is enabled to check if a border should be painted. |
start | Starts the handling of the mouse gesture. |
hideHandles | Shortcut to hideSizers. |
hideSizers | Hides all sizers except. |
checkTolerance | Checks if the coordinates for the given event are within the mxGraph.tolerance. |
updateHint | Hook for subclassers do show details while the handler is active. |
removeHint | Hooks for subclassers to hide details when the handler gets inactive. |
roundAngle | Hook for rounding the angle. |
roundLength | Hook for rounding the unscaled width or height. |
mouseMove | Handles the event by updating the preview. |
rotateVertex | Rotates the vertex. |
rotateVertex | Rotates the vertex. |
rotateVertex | Rotates the vertex. |
updateLivePreview | Repaints the live preview. |
mouseUp | Handles the event by applying the changes to the geometry. |
rotateCell | Rotates the given cell to the given rotation. |
rotateClick | Hook for subclassers to implement a single click on the rotation handle. |
rotateCell | Rotates the given cell and its children by the given angle in degrees. |
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. |
getRotationHandlePosition | Returns an mxPoint that defines the rotation handle position. |
updateParentHighlight | Updates the highlight of the parent if parentHighlightEnabled is true. |
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.horizontalOffset
The horizontal offset for the handles. This is updated in redrawHandles if manageSizers is true and the sizers are offset horizontally.
mxVertexHandler.prototype.verticalOffset
The horizontal offset for the handles. This is updated in redrawHandles if manageSizers is true and the sizers are offset vertically.
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.isLivePreviewBorder = function()
Called if livePreview is enabled to check if a border should be painted. This implementation returns true if the shape is transparent.
Shortcut to hideSizers.
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.rotateCell = function( cell, angle, parent )
Rotates the given cell and its children by the given angle in degrees.
cell | mxCell to be rotated. |
angle | Angle in degrees. |
mxVertexHandler.prototype.resizeCell = function( cell, dx, dy, index, gridEnabled, constrained, recurse )
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, constrained, centered )
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, constrained) { 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, constrained) { 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'; } };
mxVertexHandler.prototype.getRotationHandlePosition = function()
Returns an mxPoint that defines the rotation handle position.
mxVertexHandler.prototype.updateParentHighlight = function()
Updates the highlight of the parent if parentHighlightEnabled is true.
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 the parent should be highlighted if a child cell is selected.
mxVertexHandler.prototype.parentHighlightEnabled
Specifies if rotation steps should be “rasterized” depening on the distance to the handle.
mxVertexHandler.prototype.rotationRaster
Specifies the cursor for the rotation handle.
mxVertexHandler.prototype.rotationCursor
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
Specifies if the size of groups should be constrained by the children.
mxVertexHandler.prototype.constrainGroupByChildren
Vertical spacing for rotation icon.
mxVertexHandler.prototype.rotationHandleVSpacing
The horizontal offset for the handles.
mxVertexHandler.prototype.horizontalOffset
The horizontal offset for the handles.
mxVertexHandler.prototype.verticalOffset
Initializes the shapes required for this vertex handler.
mxVertexHandler.prototype.init = function()
Returns true if the rotation handle should be showing.
mxVertexHandler.prototype.isRotationHandleVisible = function()
Returns true if the aspect ratio if the cell should be maintained.
mxVertexHandler.prototype.isConstrainedEvent = function( me )
Returns true if the center of the vertex should be maintained during the resize.
mxVertexHandler.prototype.isCenteredEvent = function( state, me )
Returns an array of custom handles.
mxVertexHandler.prototype.createCustomHandles = function()
Initializes the shapes required for this vertex handler.
mxVertexHandler.prototype.updateMinBounds = 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.createParentHighlightShape = function( bounds )
Creates the shape used to draw the selection border.
mxVertexHandler.prototype.createSelectionShape = function( bounds )
Returns mxConstants.VERTEX_SELECTION_COLOR.
mxVertexHandler.prototype.getSelectionColor = function()
Defines the color to be used for the selection border of vertices.
VERTEX_SELECTION_COLOR: '#00FF00'
Returns mxConstants.VERTEX_SELECTION_STROKEWIDTH.
mxVertexHandler.prototype.getSelectionStrokeWidth = function()
Defines the strokewidth to be used for vertex selections.
VERTEX_SELECTION_STROKEWIDTH: 1
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 an index.
mxVertexHandler.prototype.createSizerShape = function( bounds, index, fillColor )
Returns true if the given event allows custom handles to be changed.
mxVertexHandler.prototype.isCustomHandleEvent = function( me )
Handles the event if a handle has been clicked.
mxVertexHandler.prototype.mouseDown = function( sender, me )
Called if livePreview is enabled to check if a border should be painted.
mxVertexHandler.prototype.isLivePreviewBorder = function()
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
Hook for subclassers do show details while the handler is active.
mxVertexHandler.prototype.updateHint = function( me )
Hooks for subclassers to hide details when the handler gets inactive.
mxVertexHandler.prototype.removeHint = function()
Hook for rounding the angle.
mxVertexHandler.prototype.roundAngle = function( angle )
Hook for rounding the unscaled width or height.
mxVertexHandler.prototype.roundLength = function( length )
Handles the event by updating the preview.
mxVertexHandler.prototype.mouseMove = function( sender, me )
Rotates the vertex.
mxVertexHandler.prototype.rotateVertex = function( me )
Repaints the live preview.
mxVertexHandler.prototype.updateLivePreview = function( me )
Handles the event by applying the changes to the geometry.
mxVertexHandler.prototype.mouseUp = function( sender, me )
Hook for subclassers to implement a single click on the rotation handle.
mxVertexHandler.prototype.rotateClick = function()
Rotates the given cell and its children by the given angle in degrees.
mxVertexHandler.prototype.rotateCell = function( cell, angle, parent )
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, constrained, recurse )
Sets the bounds of the given cell using resizeCells.
mxGraph.prototype.resizeCell = function( cell, bounds, recurse )
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, constrained, centered )
Redraws the handles and the preview.
mxVertexHandler.prototype.redraw = function()
Redraws the handles.
mxVertexHandler.prototype.redrawHandles = function()
Returns an mxPoint that defines the rotation handle position.
mxVertexHandler.prototype.getRotationHandlePosition = function()
Updates the highlight of the parent if parentHighlightEnabled is true.
mxVertexHandler.prototype.updateParentHighlight = 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 )