mxStylesheet

Defines the appearance of the cells in a graph.  See putCellStyle for an example of creating a style.

Default Styles

The stylesheet contains two built-om styles, which are used if no style is defined for a cell:

defaultVertexDefault style for vertices
defaultEdgeDefault style for edges
Summary
mxStylesheetDefines the appearance of the cells in a graph.
Functions
stylesMaps from names to styles.
mxStylesheetConstructs a new stylesheet and assigns default styles.
createDefaultVertexStyleCreates and returns the default vertex style.
createDefaultEdgeStyleCreates and returns the default edge style.
putDefaultVertexStyleSets the default style for vertices.
putDefaultEdgeStyleSets the default style for edges.
getDefaultVertexStyleReturns the default style for vertices.
getDefaultEdgeStyleSets the default style for edges.
putCellStyleStores the specified style under the given name.
getCellStyleReturns the cell style for the specified cell or the given defaultStyle if no style can be found for the given stylename.

Functions

styles

var $styles = array()

Maps from names to styles.

mxStylesheet

function mxStylesheet()

Constructs a new stylesheet and assigns default styles.

createDefaultVertexStyle

function createDefaultVertexStyle()

Creates and returns the default vertex style.

createDefaultEdgeStyle

function createDefaultEdgeStyle()

Creates and returns the default edge style.

putDefaultVertexStyle

function putDefaultVertexStyle($style)

Sets the default style for vertices.

putDefaultEdgeStyle

function putDefaultEdgeStyle($style)

Sets the default style for edges.

getDefaultVertexStyle

function getDefaultVertexStyle()

Returns the default style for vertices.

getDefaultEdgeStyle

function getDefaultEdgeStyle()

Sets the default style for edges.

putCellStyle

function putCellStyle($name,
$style)

Stores the specified style under the given name.

Example

The following example adds a new style (called ‘rounded’) into an existing stylesheet:

var style = new Array();
style[mxConstants.STYLE_SHAPE] = mxConstants.SHAPE_RECTANGLE;
style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RightAngleRectanglePerimeter;
style[mxConstants.STYLE_ROUNDED] = 'true';
graph.stylesheet.putCellStyle('rounded', style);

In the above example, the new style is an array.  The possible keys of the array are all the constants in mxConstants that start with STYLE and the values are either JavaScript objects, such as <mxPerimeter.RightAngleRectanglePerimeter> (which is in fact a function) or expressions, such as ‘true’.  Note that not all keys will be interpreted by all shapes (eg. the line shape ignores the fill color).  The final call to this method associates the style with a name in the stylesheet.  The style is used in a cell with the following code:

model.setStyle(cell, 'rounded');

Parameters

nameName for the style to be stored.
styleKey, value pairs that define the style.

getCellStyle

function getCellStyle($name,  
$defaultStyle =  null)

Returns the cell style for the specified cell or the given defaultStyle if no style can be found for the given stylename.

Parameters

nameString of the form [(stylename|key=value);] that represents the style.
defaultStyleDefault style to be returned if no style can be found.
var $styles = array()
Maps from names to styles.
function mxStylesheet()
Constructs a new stylesheet and assigns default styles.
function createDefaultVertexStyle()
Creates and returns the default vertex style.
function createDefaultEdgeStyle()
Creates and returns the default edge style.
function putDefaultVertexStyle($style)
Sets the default style for vertices.
function putDefaultEdgeStyle($style)
Sets the default style for edges.
function getDefaultVertexStyle()
Returns the default style for vertices.
function getDefaultEdgeStyle()
Sets the default style for edges.
function putCellStyle($name,
$style)
Stores the specified style under the given name.
function getCellStyle($name,  
$defaultStyle =  null)
Returns the cell style for the specified cell or the given defaultStyle if no style can be found for the given stylename.
Defines global constants.
Close