mxGraph

Implements a graph component.

Summary
mxGraphImplements a graph component.
Variables
modelHolds the mxGraphModel.
stylesheetHolds the mxStylesheet.
viewHolds the mxGraphView.
gridSizeSpecifies the grid size.
labelsVisibleSpecifies if labels should be visible.
defaultLoopStylemxEdgeStyle to be used for loops.
imageBundlesHolds the list of image bundles.
Functions
mxGraphModelConstructs a new graph model using the specified root cell.
createStylesheetCreates a new mxStylesheet to be used in this graph.
createGraphViewCreates a new mxGraphView to be used in this graph.
getModelReturns the mxGraphModel that contains the cells.
getStylesheetReturns the mxStylesheet that defines the style.
getViewReturns the mxGraphView that contains the mxCellStates.
getDefaultParentReturns the first child child of mxGraphModel.root.
convertValueToStringReturns the textual representation for the given cell.
getLabelReturns a string or DOM node that represents the label for the given cell.
getChildOffsetForCellReturns the offset to be used for the cells inside the given cell.
isOrthogonalReturns true if perimeter points should be computed such that the resulting edge has only horizontal or vertical segments.
isCellVisibleReturns true if the given cell is visible.
isCellCollapsedReturns true if the given cell is collapsed.
isCellCollapsedReturns true if the given cell is connectable.
getCellGeometryReturns the mxGeometry for the given mxCell.
getCellStyle
postProcessCellStyleTries to resolve the value for the image style in the image bundles and turns short data URIs as defined in mxImageBundle to data URIs as defined in RFC 2397 of the IETF.
setCellStylesSets the key to value in the styles of the given cells.
addBundleAdds the specified mxImageBundle.
removeImageBundleRemoves the specified mxImageBundle.
getImageFromBundlesSearches all imageBundles for the specified key and returns the value for the first match or null if the key is not found.
getImageBundlesReturns the imageBundles.
setImageBundlesSets the imageBundles.
insertVertexAdds a new vertex into the given parent mxCell using value as the user object and the given coordinates as the mxGeometry of the new vertex.
createVertexCreates the vertex to be used in insertVertex.
insertEdgeAdds a new edge into the given parent mxCell using value as the user object and the given source and target as the terminals of the new edge.
createEdgeCreates the edge to be used in insertEdge.
getGraphBoundsReturns the bounds of the visible graph.
getBoundingBoxReturns the bounding box of the given cell including all connected edges if includeEdge is true.
getPaintBoundsReturns the bounding box of the given cells and their descendants.
getBoundsForCellsReturns the bounds for the given cells.
getCellBoundsReturns the bounds of the given cell including all connected edges if includeEdge is true.
getConnectionConstraintReturns an mxConnectionConstraint that describes the given connection point.
getConnectionPointReturns the nearest point in the list of absolute points or the center of the opposite terminal.
findTreeRootsReturns all children in the given parent which do not have incoming edges.
createImage
drawGraphDraws the given cell onto the specified canvas.
paintCellDraws the given cell onto the specified canvas.
paintStateDraws the given cell and label onto the specified canvas.
graphModelChangedCalled when the graph model has changed.

Variables

model

var $model

Holds the mxGraphModel.

stylesheet

var $stylesheet

Holds the mxStylesheet.

view

var $view

Holds the mxGraphView.

gridSize

var $gridSize

Specifies the grid size.  Default is 10.

labelsVisible

var $labelsVisible

Specifies if labels should be visible.  This is used in getLabel.  Default is true.

defaultLoopStyle

var $defaultLoopStyle

mxEdgeStyle to be used for loops.  This is a fallback for loops if the mxConstants.STYLE_LOOP is undefined.  Default is mxEdgeStyle.Loop.

imageBundles

protected $imageBundles

Holds the list of image bundles.

Functions

mxGraphModel

Constructs a new graph model using the specified root cell.

createStylesheet

function createStylesheet()

Creates a new mxStylesheet to be used in this graph.

createGraphView

function createGraphView()

Creates a new mxGraphView to be used in this graph.

getModel

function getModel()

Returns the mxGraphModel that contains the cells.

getStylesheet

function getStylesheet()

Returns the mxStylesheet that defines the style.

getView

function getView()

Returns the mxGraphView that contains the mxCellStates.

getDefaultParent

function getDefaultParent()

Returns the first child child of mxGraphModel.root.  The value returned by this function should be used as the parent for new cells (aka default layer).

convertValueToString

function convertValueToString($cell)

Returns the textual representation for the given cell.  This implementation returns the nodename or string-representation of the user object.

getLabel

function getLabel($cell)

Returns a string or DOM node that represents the label for the given cell.  This implementation uses convertValueToString if labelsVisible is true.  Otherwise it returns an empty string.

getChildOffsetForCell

function getChildOffsetForCell($cell)

Returns the offset to be used for the cells inside the given cell.  The root and layer cells may be identified using <mxGraphModel.isRoot> and <mxGraphModel.isLayer>.  For all other current roots, the <mxGraphView.currentRoot> field points to the respective cell, so that the following holds: cell == this.view.currentRoot.  This implementation returns null.

Parameters

cellmxCell whose offset should be returned.

isOrthogonal

function isOrthogonal($edge)

Returns true if perimeter points should be computed such that the resulting edge has only horizontal or vertical segments.

Parameters

edgemxCellState that represents the edge.

isCellVisible

function isCellVisible($cell)

Returns true if the given cell is visible.

isCellCollapsed

function isCellCollapsed($cell)

Returns true if the given cell is collapsed.

isCellCollapsed

Returns true if the given cell is connectable.

getCellGeometry

function getCellGeometry($cell)

Returns the mxGeometry for the given mxCell.

getCellStyle

function getCellStyle($cell)

postProcessCellStyle

function postProcessCellStyle($style)

Tries to resolve the value for the image style in the image bundles and turns short data URIs as defined in mxImageBundle to data URIs as defined in RFC 2397 of the IETF.

setCellStyles

function setCellStyles($key,
$value,
$cells)

Sets the key to value in the styles of the given cells.  This will modify the existing cell styles in-place and override any existing assignment for the given key.  If no cells are specified, then the selection cells are changed.  If no value is specified, then the respective key is removed from the styles.

Parameters

keyString representing the key to be assigned.
valueString representing the new value for the key.
cellsArray of mxCells to change the style for.

addBundle

Adds the specified mxImageBundle.

removeImageBundle

function removeImageBundle($bundle)

Removes the specified mxImageBundle.

getImageFromBundles

function getImageFromBundles($key)

Searches all imageBundles for the specified key and returns the value for the first match or null if the key is not found.

getImageBundles

function getImageBundles()

Returns the imageBundles.

setImageBundles

function setImageBundles($value)

Sets the imageBundles.

insertVertex

function insertVertex($parent,  
$id =  null,
$value =  null,
$x =  0,
$y =  0,
$width =  1,
$height =  1,
$style =  null,
$relative =  false)

Adds a new vertex into the given parent mxCell using value as the user object and the given coordinates as the mxGeometry of the new vertex.  The id and style are used for the respective properties of the new mxCell, which is returned.

Parameters

parentmxCell that specifies the parent of the new vertex.
idOptional string that defines the Id of the new vertex.
valueObject to be used as the user object.
xInteger that defines the x coordinate of the vertex.
yInteger that defines the y coordinate of the vertex.
widthInteger that defines the width of the vertex.
heightInteger that defines the height of the vertex.
styleOptional string that defines the cell style.
relativeOptional boolean that specifies if the geometry is relative.  Default is false.

createVertex

function createVertex($parent,  
$id =  null,
$value =  null,
$x =  0,
$y =  0,
$width =  1,
$height =  1,
$style =  null,
$relative =  false)

Creates the vertex to be used in insertVertex.

insertEdge

function insertEdge($parent,  
$id =  null,
$value =  null,
$source =  null,
$target =  null,
$style =  null)

Adds a new edge into the given parent mxCell using value as the user object and the given source and target as the terminals of the new edge.  The id and style are used for the respective properties of the new mxCell, which is returned.

Parameters

parentmxCell that specifies the parent of the new edge.
idOptional string that defines the Id of the new edge.
valueJavaScript object to be used as the user object.
sourcemxCell that defines the source of the edge.
targetmxCell that defines the target of the edge.
styleOptional string that defines the cell style.

createEdge

function createEdge($parent,  
$id =  null,
$value =  null,
$source =  null,
$target =  null,
$style =  null)

Creates the edge to be used in insertEdge.  This implementation does not set the source and target of the edge, these are set when the edge is added to the model.

getGraphBounds

function getGraphBounds()

Returns the bounds of the visible graph.  Shortcut to mxGraphView.getGraphBounds.

getBoundingBox

function getBoundingBox($cell,  
$includeEdges =  false,
$includeDescendants =  false)

Returns the bounding box of the given cell including all connected edges if includeEdge is true.

getPaintBounds

function getPaintBounds($cells)

Returns the bounding box of the given cells and their descendants.

getBoundsForCells

function getBoundsForCells($cells,  
$includeEdges =  false,
$includeDescendants =  false,
$boundingBox =  false)

Returns the bounds for the given cells.

getCellBounds

function getCellBounds($cell,  
$includeEdges =  false,
$includeDescendants =  false,
$boundingBox =  false)

Returns the bounds of the given cell including all connected edges if includeEdge is true.

getConnectionConstraint

function getConnectionConstraint($edge,
$terminal,
$source)

Returns an mxConnectionConstraint that describes the given connection point.  This result can then be passed to getConnectionPoint.

Parameters

edgemxCellState that represents the edge.
terminalmxCellState that represents the terminal.
sourceBoolean indicating if the terminal is the source or target.

getConnectionPoint

function getConnectionPoint($vertex,
$constraint)

Returns the nearest point in the list of absolute points or the center of the opposite terminal.

Parameters

vertexmxCellState that represents the vertex.
constraintmxConnectionConstraint that represents the connection point constraint as returned by getConnectionConstraint.

findTreeRoots

function findTreeRoots($parent,  
$isolate =  false,
$invert =  false)

Returns all children in the given parent which do not have incoming edges.  If the result is empty then the with the greatest difference between incoming and outgoing edges is returned.

Parameters

parentmxCell whose children should be checked.
isolateOptional boolean that specifies if edges should be ignored if the opposite end is not a child of the given parent cell.  Default is false.
invertOptional boolean that specifies if outgoing or incoming edges should be counted for a tree root.  If false then outgoing edges will be counted.  Default is false.

createImage

function createImage($clip =  null,
$background =  null)

drawGraph

function drawGraph($canvas)

Draws the given cell onto the specified canvas.

paintCell

Draws the given cell onto the specified canvas.

paintState

Draws the given cell and label onto the specified canvas.  No children or descendants are painted.

graphModelChanged

function graphModelChanged($event)

Called when the graph model has changed.

var $model
Holds the mxGraphModel.
Constructs a new graph model using the specified root cell.
var $stylesheet
Holds the mxStylesheet.
Defines the appearance of the cells in a graph.
var $view
Holds the mxGraphView.
Implements a view for the graph.
var $gridSize
Specifies the grid size.
var $labelsVisible
Specifies if labels should be visible.
var $defaultLoopStyle
mxEdgeStyle to be used for loops.
Provides various edge styles to be used as the values for mxConstants.STYLE_EDGE in a cell style.
protected $imageBundles
Holds the list of image bundles.
function createStylesheet()
Creates a new mxStylesheet to be used in this graph.
function createGraphView()
Creates a new mxGraphView to be used in this graph.
function getModel()
Returns the mxGraphModel that contains the cells.
function getStylesheet()
Returns the mxStylesheet that defines the style.
function getView()
Returns the mxGraphView that contains the mxCellStates.
Represents the current state of a cell in a given mxGraphView.
function getDefaultParent()
Returns the first child child of mxGraphModel.root.
var $root
Holds the root cell, which in turn contains the cells that represent the layers of the diagram as child cells.
function convertValueToString($cell)
Returns the textual representation for the given cell.
function getLabel($cell)
Returns a string or DOM node that represents the label for the given cell.
function getChildOffsetForCell($cell)
Returns the offset to be used for the cells inside the given cell.
function isOrthogonal($edge)
Returns true if perimeter points should be computed such that the resulting edge has only horizontal or vertical segments.
function isCellVisible($cell)
Returns true if the given cell is visible.
function isCellCollapsed($cell)
Returns true if the given cell is collapsed.
function getCellGeometry($cell)
Returns the mxGeometry for the given mxCell.
Represents the geometry of a cell.
Cells are the elements of the graph model.
function getCellStyle($cell)
function postProcessCellStyle($style)
Tries to resolve the value for the image style in the image bundles and turns short data URIs as defined in mxImageBundle to data URIs as defined in RFC 2397 of the IETF.
function setCellStyles($key,
$value,
$cells)
Sets the key to value in the styles of the given cells.
Maps from keys to base64 encoded images or file locations.
function removeImageBundle($bundle)
Removes the specified mxImageBundle.
function getImageFromBundles($key)
Searches all imageBundles for the specified key and returns the value for the first match or null if the key is not found.
function getImageBundles()
Returns the imageBundles.
function setImageBundles($value)
Sets the imageBundles.
function insertVertex($parent,  
$id =  null,
$value =  null,
$x =  0,
$y =  0,
$width =  1,
$height =  1,
$style =  null,
$relative =  false)
Adds a new vertex into the given parent mxCell using value as the user object and the given coordinates as the mxGeometry of the new vertex.
function createVertex($parent,  
$id =  null,
$value =  null,
$x =  0,
$y =  0,
$width =  1,
$height =  1,
$style =  null,
$relative =  false)
Creates the vertex to be used in insertVertex.
function insertEdge($parent,  
$id =  null,
$value =  null,
$source =  null,
$target =  null,
$style =  null)
Adds a new edge into the given parent mxCell using value as the user object and the given source and target as the terminals of the new edge.
function createEdge($parent,  
$id =  null,
$value =  null,
$source =  null,
$target =  null,
$style =  null)
Creates the edge to be used in insertEdge.
function getGraphBounds()
Returns the bounds of the visible graph.
function getBoundingBox($cell,  
$includeEdges =  false,
$includeDescendants =  false)
Returns the bounding box of the given cell including all connected edges if includeEdge is true.
function getPaintBounds($cells)
Returns the bounding box of the given cells and their descendants.
function getBoundsForCells($cells,  
$includeEdges =  false,
$includeDescendants =  false,
$boundingBox =  false)
Returns the bounds for the given cells.
function getCellBounds($cell,  
$includeEdges =  false,
$includeDescendants =  false,
$boundingBox =  false)
Returns the bounds of the given cell including all connected edges if includeEdge is true.
function getConnectionConstraint($edge,
$terminal,
$source)
Returns an mxConnectionConstraint that describes the given connection point.
Defines an object that contains the constraints about how to connect one side of an edge to its terminal.
function getConnectionPoint($vertex,
$constraint)
Returns the nearest point in the list of absolute points or the center of the opposite terminal.
function findTreeRoots($parent,  
$isolate =  false,
$invert =  false)
Returns all children in the given parent which do not have incoming edges.
function createImage($clip =  null,
$background =  null)
function drawGraph($canvas)
Draws the given cell onto the specified canvas.
function graphModelChanged($event)
Called when the graph model has changed.
public static $STYLE_LOOP
Defines the key for the loop style.
public static $Loop
Provides a self-reference, aka.
function getGraphBounds()
Returns graphBounds.
Close