A helper class to process mouse locations and highlight cells.
Helper class to highlight cells. To add a cell marker to an existing graph for highlighting all cells, the following code is used:
var marker = new mxCellMarker(graph); graph.addMouseListener({ mouseDown: function() {}, mouseMove: function(sender, me) { marker.process(me); }, mouseUp: function() {} });
mxCellMarker | A helper class to process mouse locations and highlight cells. |
Events | |
mxEvent.MARK | Fires after a cell has been marked or unmarked. |
Functions | |
mxCellMarker | Constructs a new cell marker. |
Variables | |
graph | Reference to the enclosing mxGraph. |
enabled | Specifies if the marker is enabled. |
hotspot | Specifies the portion of the width and height that should trigger a highlight. |
hotspotEnabled | Specifies if the hotspot is enabled. |
validColor | Holds the valid marker color. |
invalidColor | Holds the invalid marker color. |
currentColor | Holds the current marker color. |
validState | Holds the marked mxCellState if it is valid. |
markedState | Holds the marked mxCellState. |
Functions | |
setEnabled | Enables or disables event handling. |
isEnabled | Returns true if events are handled. |
setHotspot | Sets the hotspot. |
getHotspot | Returns the hotspot. |
setHotspotEnabled | Specifies whether the hotspot should be used in intersects. |
isHotspotEnabled | Returns true if hotspot is used in intersects. |
hasValidState | Returns true if validState is not null. |
getValidState | Returns the validState. |
getMarkedState | Returns the markedState. |
reset | Resets the state of the cell marker. |
process | Processes the given event and cell and marks the state returned by getState with the color returned by getMarkerColor. |
setCurrentState | Sets and marks the current valid state. |
markCell | Marks the given cell using the given color, or validColor if no color is specified. |
mark | Marks the markedState and fires a mark event. |
unmark | Hides the marker and fires a mark event. |
isValidState | Returns true if the given mxCellState is a valid state. |
getMarkerColor | Returns the valid- or invalidColor depending on the value of isValid. |
getState | Uses getCell, getStateToMark and intersects to return the mxCellState for the given mxMouseEvent. |
getCell | Returns the mxCell for the given event and cell. |
getStateToMark | Returns the mxCellState to be marked for the given mxCellState under the mouse. |
intersects | Returns true if the given coordinate pair intersects the given state. |
destroy | Destroys the handler and all its resources and DOM nodes. |
Fires after a cell has been marked or unmarked. The <code>state</code> property contains the marked mxCellState or null if no state is marked.
function mxCellMarker( graph, validColor, invalidColor, hotspot )
Constructs a new cell marker.
graph | Reference to the enclosing mxGraph. |
validColor | Optional marker color for valid states. Default is mxConstants.DEFAULT_VALID_COLOR. |
invalidColor | Optional marker color for invalid states. Default is mxConstants.DEFAULT_INVALID_COLOR. |
hotspot | Portion of the width and hight where a state intersects a given coordinate pair. A value of 0 means always highlight. Default is mxConstants.DEFAULT_HOTSPOT. |
mxCellMarker.prototype.graph
Reference to the enclosing mxGraph.
mxCellMarker.prototype.validState
Holds the marked mxCellState if it is valid.
mxCellMarker.prototype.markedState
Holds the marked mxCellState.
mxCellMarker.prototype.setEnabled = function( enabled )
Enables or disables event handling. This implementation updates enabled.
enabled | Boolean that specifies the new enabled state. |
mxCellMarker.prototype.isEnabled = function()
Returns true if events are handled. This implementation returns enabled.
mxCellMarker.prototype.setHotspot = function( hotspot )
Sets the hotspot.
mxCellMarker.prototype.getHotspot = function()
Returns the hotspot.
mxCellMarker.prototype.setHotspotEnabled = function( enabled )
Specifies whether the hotspot should be used in intersects.
mxCellMarker.prototype.isHotspotEnabled = function()
Returns true if hotspot is used in intersects.
mxCellMarker.prototype.hasValidState = function()
Returns true if validState is not null.
mxCellMarker.prototype.getValidState = function()
Returns the validState.
mxCellMarker.prototype.getMarkedState = function()
Returns the markedState.
mxCellMarker.prototype.process = function( me )
Processes the given event and cell and marks the state returned by getState with the color returned by getMarkerColor. If the markerColor is not null, then the state is stored in markedState. If isValidState returns true, then the state is stored in validState regardless of the marker color. The state is returned regardless of the marker color and valid state.
mxCellMarker.prototype.markCell = function( cell, color )
Marks the given cell using the given color, or validColor if no color is specified.
mxCellMarker.prototype.mark = function()
Marks the markedState and fires a mark event.
mxCellMarker.prototype.unmark = function()
Hides the marker and fires a mark event.
mxCellMarker.prototype.isValidState = function( state )
Returns true if the given mxCellState is a valid state. If this returns true, then the state is stored in validState. The return value of this method is used as the argument for getMarkerColor.
mxCellMarker.prototype.getMarkerColor = function( evt, state, isValid )
Returns the valid- or invalidColor depending on the value of isValid. The given mxCellState is ignored by this implementation.
mxCellMarker.prototype.getState = function( me )
Uses getCell, getStateToMark and intersects to return the mxCellState for the given mxMouseEvent.
mxCellMarker.prototype.getCell = function( me )
Returns the mxCell for the given event and cell. This returns the given cell.
mxCellMarker.prototype.getStateToMark = function( state )
Returns the mxCellState to be marked for the given mxCellState under the mouse. This returns the given state.
mxCellMarker.prototype.intersects = function( state, me )
Returns true if the given coordinate pair intersects the given state. This returns true if the hotspot is 0 or the coordinates are inside the hotspot for the given cell state.
Constructs a new cell marker.
function mxCellMarker( graph, validColor, invalidColor, hotspot )
Reference to the enclosing mxGraph.
mxCellMarker.prototype.graph
Specifies if the marker is enabled.
mxCellMarker.prototype.enabled
Specifies the portion of the width and height that should trigger a highlight.
mxCellMarker.prototype.hotspot
Specifies if the hotspot is enabled.
mxCellMarker.prototype.hotspotEnabled
Holds the valid marker color.
mxCellMarker.prototype.validColor
Holds the invalid marker color.
mxCellMarker.prototype.invalidColor
Holds the current marker color.
mxCellMarker.prototype.currentColor
Holds the marked mxCellState if it is valid.
mxCellMarker.prototype.validState
Holds the marked mxCellState.
mxCellMarker.prototype.markedState
Enables or disables event handling.
mxCellMarker.prototype.setEnabled = function( enabled )
Returns true if events are handled.
mxCellMarker.prototype.isEnabled = function()
Sets the hotspot.
mxCellMarker.prototype.setHotspot = function( hotspot )
Returns the hotspot.
mxCellMarker.prototype.getHotspot = function()
Specifies whether the hotspot should be used in intersects.
mxCellMarker.prototype.setHotspotEnabled = function( enabled )
Returns true if the given coordinate pair intersects the given state.
mxCellMarker.prototype.intersects = function( state, me )
Returns true if hotspot is used in intersects.
mxCellMarker.prototype.isHotspotEnabled = function()
Returns true if validState is not null.
mxCellMarker.prototype.hasValidState = function()
Returns the validState.
mxCellMarker.prototype.getValidState = function()
Returns the markedState.
mxCellMarker.prototype.getMarkedState = function()
Resets the state of the cell marker.
mxCellMarker.prototype.reset = function()
Processes the given event and cell and marks the state returned by getState with the color returned by getMarkerColor.
mxCellMarker.prototype.process = function( me )
Uses getCell, getStateToMark and intersects to return the mxCellState for the given mxMouseEvent.
mxCellMarker.prototype.getState = function( me )
Returns the valid- or invalidColor depending on the value of isValid.
mxCellMarker.prototype.getMarkerColor = function( evt, state, isValid )
Sets and marks the current valid state.
mxCellMarker.prototype.setCurrentState = function( state, me, color )
Marks the given cell using the given color, or validColor if no color is specified.
mxCellMarker.prototype.markCell = function( cell, color )
Marks the markedState and fires a mark event.
mxCellMarker.prototype.mark = function()
Hides the marker and fires a mark event.
mxCellMarker.prototype.unmark = function()
Returns true if the given mxCellState is a valid state.
mxCellMarker.prototype.isValidState = function( state )
Returns the mxCell for the given event and cell.
mxCellMarker.prototype.getCell = function( me )
Returns the mxCellState to be marked for the given mxCellState under the mouse.
mxCellMarker.prototype.getStateToMark = function( state )
Destroys the handler and all its resources and DOM nodes.
mxCellMarker.prototype.destroy = function()