mxCellMarker

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() {}
});
Summary
mxCellMarkerA helper class to process mouse locations and highlight cells.
Events
mxEvent.MARKFires after a cell has been marked or unmarked.
Functions
mxCellMarkerConstructs a new cell marker.
Variables
graphReference to the enclosing mxGraph.
enabledSpecifies if the marker is enabled.
hotspotSpecifies the portion of the width and height that should trigger a highlight.
hotspotEnabledSpecifies if the hotspot is enabled.
validColorHolds the valid marker color.
invalidColorHolds the invalid marker color.
currentColorHolds the current marker color.
validStateHolds the marked mxCellState if it is valid.
markedStateHolds the marked mxCellState.
Functions
setEnabledEnables or disables event handling.
isEnabledReturns true if events are handled.
setHotspotSets the hotspot.
getHotspotReturns the hotspot.
setHotspotEnabledSpecifies whether the hotspot should be used in intersects.
isHotspotEnabledReturns true if hotspot is used in intersects.
hasValidStateReturns true if validState is not null.
getValidStateReturns the validState.
getMarkedStateReturns the markedState.
resetResets the state of the cell marker.
processProcesses the given event and cell and marks the state returned by getState with the color returned by getMarkerColor.
setCurrentStateSets and marks the current valid state.
markCellMarks the given cell using the given color, or validColor if no color is specified.
markMarks the markedState and fires a mark event.
unmarkHides the marker and fires a mark event.
isValidStateReturns true if the given mxCellState is a valid state.
getMarkerColorReturns the valid- or invalidColor depending on the value of isValid.
getStateUses getCell, getStateToMark and intersects to return the mxCellState for the given mxMouseEvent.
getCellReturns the mxCell for the given event and cell.
getStateToMarkReturns the mxCellState to be marked for the given mxCellState under the mouse.
intersectsReturns true if the given coordinate pair intersects the given state.
destroyDestroys the handler and all its resources and DOM nodes.

Events

mxEvent.MARK

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.

Functions

mxCellMarker

function mxCellMarker(graph,
validColor,
invalidColor,
hotspot)

Constructs a new cell marker.

Parameters

graphReference to the enclosing mxGraph.
validColorOptional marker color for valid states.  Default is mxConstants.DEFAULT_VALID_COLOR.
invalidColorOptional marker color for invalid states.  Default is mxConstants.DEFAULT_INVALID_COLOR.
hotspotPortion 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.

Variables

graph

mxCellMarker.prototype.graph

Reference to the enclosing mxGraph.

enabled

mxCellMarker.prototype.enabled

Specifies if the marker is enabled.  Default is true.

hotspot

mxCellMarker.prototype.hotspot

Specifies the portion of the width and height that should trigger a highlight.  The area around the center of the cell to be marked is used as the hotspot.  Possible values are between 0 and 1.  Default is mxConstants.DEFAULT_HOTSPOT.

hotspotEnabled

mxCellMarker.prototype.hotspotEnabled

Specifies if the hotspot is enabled.  Default is false.

validColor

mxCellMarker.prototype.validColor

Holds the valid marker color.

invalidColor

mxCellMarker.prototype.invalidColor

Holds the invalid marker color.

currentColor

mxCellMarker.prototype.currentColor

Holds the current marker color.

validState

mxCellMarker.prototype.validState

Holds the marked mxCellState if it is valid.

markedState

mxCellMarker.prototype.markedState

Holds the marked mxCellState.

Functions

setEnabled

mxCellMarker.prototype.setEnabled = function(enabled)

Enables or disables event handling.  This implementation updates enabled.

Parameters

enabledBoolean that specifies the new enabled state.

isEnabled

mxCellMarker.prototype.isEnabled = function()

Returns true if events are handled.  This implementation returns enabled.

setHotspot

mxCellMarker.prototype.setHotspot = function(hotspot)

Sets the hotspot.

getHotspot

mxCellMarker.prototype.getHotspot = function()

Returns the hotspot.

setHotspotEnabled

mxCellMarker.prototype.setHotspotEnabled = function(enabled)

Specifies whether the hotspot should be used in intersects.

isHotspotEnabled

mxCellMarker.prototype.isHotspotEnabled = function()

Returns true if hotspot is used in intersects.

hasValidState

mxCellMarker.prototype.hasValidState = function()

Returns true if validState is not null.

getValidState

mxCellMarker.prototype.getValidState = function()

Returns the validState.

getMarkedState

mxCellMarker.prototype.getMarkedState = function()

Returns the markedState.

reset

mxCellMarker.prototype.reset = function()

Resets the state of the cell marker.

process

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.

setCurrentState

mxCellMarker.prototype.setCurrentState = function(state,
me,
color)

Sets and marks the current valid state.

markCell

mxCellMarker.prototype.markCell = function(cell,
color)

Marks the given cell using the given color, or validColor if no color is specified.

mark

mxCellMarker.prototype.mark = function()

Marks the markedState and fires a mark event.

unmark

mxCellMarker.prototype.unmark = function()

Hides the marker and fires a mark event.

isValidState

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.

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.

getState

mxCellMarker.prototype.getState = function(me)

Uses getCell, getStateToMark and intersects to return the mxCellState for the given mxMouseEvent.

getCell

mxCellMarker.prototype.getCell = function(me)

Returns the mxCell for the given event and cell.  This returns the given cell.

getStateToMark

mxCellMarker.prototype.getStateToMark = function(state)

Returns the mxCellState to be marked for the given mxCellState under the mouse.  This returns the given state.

intersects

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.

destroy

mxCellMarker.prototype.destroy = function()

Destroys the handler and all its resources and DOM nodes.

function mxCellMarker(graph,
validColor,
invalidColor,
hotspot)
Constructs a new cell marker.
mxCellMarker.prototype.graph
Reference to the enclosing mxGraph.
Extends mxEventSource to implement a graph component for the browser.
mxCellMarker.prototype.enabled
Specifies if the marker is enabled.
mxCellMarker.prototype.hotspot
Specifies the portion of the width and height that should trigger a highlight.
mxCellMarker.prototype.hotspotEnabled
Specifies if the hotspot is enabled.
mxCellMarker.prototype.validColor
Holds the valid marker color.
mxCellMarker.prototype.invalidColor
Holds the invalid marker color.
mxCellMarker.prototype.currentColor
Holds the current marker color.
mxCellMarker.prototype.validState
Holds the marked mxCellState if it is valid.
Represents the current state of a cell in a given mxGraphView.
mxCellMarker.prototype.markedState
Holds the marked mxCellState.
mxCellMarker.prototype.setEnabled = function(enabled)
Enables or disables event handling.
mxCellMarker.prototype.isEnabled = function()
Returns true if events are handled.
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.intersects = function(state,
me)
Returns true if the given coordinate pair intersects the given state.
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.reset = function()
Resets the state of the cell marker.
mxCellMarker.prototype.process = function(me)
Processes the given event and cell and marks the state returned by getState with the color returned by getMarkerColor.
mxCellMarker.prototype.getState = function(me)
Uses getCell, getStateToMark and intersects to return the mxCellState for the given mxMouseEvent.
mxCellMarker.prototype.getMarkerColor = function(evt,
state,
isValid)
Returns the valid- or invalidColor depending on the value of isValid.
mxCellMarker.prototype.setCurrentState = function(state,
me,
color)
Sets and marks the current 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.
mxCellMarker.prototype.getCell = function(me)
Returns the mxCell for the given event and cell.
mxCellMarker.prototype.getStateToMark = function(state)
Returns the mxCellState to be marked for the given mxCellState under the mouse.
Base class for all mouse events in mxGraph.
Cells are the elements of the graph model.
mxCellMarker.prototype.destroy = function()
Destroys the handler and all its resources and DOM nodes.
DEFAULT_VALID_COLOR: '#00FF00'
Specifies the default valid color.
DEFAULT_INVALID_COLOR: '#FF0000'
Specifies the default invalid color.
DEFAULT_HOTSPOT: 0.3
Defines the portion of the cell which is to be used as a connectable region.
Close