Defines the appearance of the cells in a graph. See putCellStyle for an example of creating a style.
The stylesheet contains two built-om styles, which are used if no style is defined for a cell:
defaultVertex | Default style for vertices |
defaultEdge | Default style for edges |
mxStylesheet | Defines the appearance of the cells in a graph. |
Functions | |
styles | Maps from names to styles. |
mxStylesheet | Constructs a new stylesheet and assigns default styles. |
createDefaultVertexStyle | Creates and returns the default vertex style. |
createDefaultEdgeStyle | Creates and returns the default edge style. |
putDefaultVertexStyle | Sets the default style for vertices. |
putDefaultEdgeStyle | Sets the default style for edges. |
getDefaultVertexStyle | Returns the default style for vertices. |
getDefaultEdgeStyle | Sets the default style for edges. |
putCellStyle | Stores the specified style under the given name. |
getCellStyle | Returns the cell style for the specified cell or the given defaultStyle if no style can be found for the given stylename. |
function putCellStyle( $name, $style )
Stores the specified style under the given name.
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');
name | Name for the style to be stored. |
style | Key, value pairs that define the style. |
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.
name | String of the form [(stylename|key=value);] that represents the style. |
defaultStyle | Default style to be returned if no style can be found. |
Maps from names to styles.
var $styles = array()
Constructs a new stylesheet and assigns default styles.
function mxStylesheet()
Creates and returns the default vertex style.
function createDefaultVertexStyle()
Creates and returns the default edge style.
function createDefaultEdgeStyle()
Sets the default style for vertices.
function putDefaultVertexStyle( $style )
Sets the default style for edges.
function putDefaultEdgeStyle( $style )
Returns the default style for vertices.
function getDefaultVertexStyle()
Sets the default style for edges.
function getDefaultEdgeStyle()
Stores the specified style under the given name.
function putCellStyle( $name, $style )
Returns the cell style for the specified cell or the given defaultStyle if no style can be found for the given stylename.
function getCellStyle( $name, $defaultStyle = null )