Helper methods.
mxUtils | Helper methods. |
Functions | |
getLabelSize | Returns the size of the given label. |
getLabelPaintBounds | Returns the paint bounds for the given label. |
getScaledLabelBounds | Returns the bounds for a label for the given location and size, taking into account the alignment and spacing in the specified style, as well as the width and height of the rectangle that contains the label. |
getSizeForString | Returns an mxRectangle with the size (width and height in pixels) of the given string. |
flipImage | Flips the given image horizontally and/or vertically and returns a new image instance. |
toRadians | Converts the given degree to radians. |
getBoundingBox | Returns the bounding box for the rotated rectangle. |
getRotatedPoint | Rotates the given point by the given cos and sin. |
translatePoints | Creates a new list of new points obtained by translating the points in the given list by the given vector. |
contains | Returns true if the specified point (x, y) is contained in the given rectangle. |
intersection | Returns the intersection of two lines as an mxPoint. |
encodeImage | Encodes the given image using the GD image encoding routines. |
getStylename | Returns the stylename in a style of the form [stylename;|key=value;] or an empty string if the given style does not contain a stylename. |
getStylenames | Returns the stylenames in a style of the form [stylename;|key=value;] or an empty array if the given style does not contain any stylenames. |
indexOfStylename | Returns the index of the given stylename in the given style. |
addStylename | Adds the specified stylename to the given style if it does not already contain the stylename. |
removeStylename | Removes all occurrences of the specified stylename in the given style and returns the updated style. |
removeAllStylenames | Removes all stylenames from the given style and returns the updated style. |
setCellStyles | Assigns the value for the given key in the styles of the given cells, or removes the key from the styles if the value is null. |
setStyle | Adds or removes the given key, value pair to the style and returns the new style. |
setCellStyleFlags | Sets or toggles the flag bit for the given key in the cell’s styles. |
setStyleFlag | Sets or removes the given key from the specified style and returns the new style. |
getValue | Returns the value for key in dictionary or the given default value if no value is defined for the key. |
getNumber | Returns the value for key in dictionary or 0 if no value is defined for the key. |
indexOf | Returns the index of obj in array or -1 if the array does not contains the given object. |
readFile | Reads the given filename into a string. |
isNode | Returns true if the given value is an XML node with the node name and if the optional attribute has the specified value. |
loadImage | Loads an image from the local filesystem, a data URI or any other URL. |
createXmlDocument | Returns a new, empty XML document. |
loadXmlDocument | Returns a new DOM document for the given URI. |
parseXml | Returns a new DOM document for the given XML string. |
evaluate | Evaluates an expression to a class member. |
findNode | Returns the first node where attr equals value. |
getTrueTypeFont | Returns the truetype font to be used to draw the text with the given style. |
getTrueTypeFontSize | Returns the truetype font size to be used to draw the text with the given style. |
getFixedFontSize | Returns the fixed font size for GD (1 t0 5) for the given font properties |
stackTrace | Prints a simple stack trace in the error log. |
static function getScaledLabelBounds( $x, $y, $size, $outerWidth, $outerHeight, $style, $scale )
Returns the bounds for a label for the given location and size, taking into account the alignment and spacing in the specified style, as well as the width and height of the rectangle that contains the label. (For edge labels this width and height is 0.) The scale is used to scale the given size and the spacings in the specified style.
static function getSizeForString( $text, $fontSize = 0, $fontFamily = null )
Returns an mxRectangle with the size (width and height in pixels) of the given string. The string may contain HTML markup. Newlines should be converted to <br> before calling this method.
text | String whose size should be returned. |
fontSize | Integer that specifies the font size in pixels. Default is mxConstants.DEFAULT_FONTSIZE. |
fontFamily | String that specifies the name of the font famil.y Default is mxConstants.DEFAULT_FONTFAMILY. |
static function contains( $state, $x, $y )
Returns true if the specified point (x, y) is contained in the given rectangle.
bounds | mxRectangle that represents the area. |
x | X-coordinate of the point. |
y | Y-coordinate of the point. |
static function intersection( $x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3 )
Returns the intersection of two lines as an mxPoint.
x0 | X-coordinate of the first line’s startpoint. |
y0 | X-coordinate of the first line’s startpoint. |
x1 | X-coordinate of the first line’s endpoint. |
y1 | Y-coordinate of the first line’s endpoint. |
x2 | X-coordinate of the second line’s startpoint. |
y2 | Y-coordinate of the second line’s startpoint. |
x3 | X-coordinate of the second line’s endpoint. |
y3 | Y-coordinate of the second line’s endpoint. |
static function setCellStyles( $model, $cells, $key, $value )
Assigns the value for the given key in the styles of the given cells, or removes the key from the styles if the value is null.
model | mxGraphModel to execute the transaction in. |
cells | Array of mxCells to be updated. |
key | Key of the style to be changed. |
value | New value for the given key. |
static function setStyle( $style, $key, $value )
Adds or removes the given key, value pair to the style and returns the new style. If value is null or zero length then the key is removed from the style.
style | String of the form stylename[;key=value] |
key | Key of the style to be changed. |
value | New value for the given key. |
static function setCellStyleFlags( $model, $cells, $key, $flag, $value )
Sets or toggles the flag bit for the given key in the cell’s styles. If value is null then the flag is toggled.
var cells = graph.getSelectionCells(); mxUtils.setCellStyleFlags(graph.model, cells, mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_BOLD);
Toggles the bold font style.
model | mxGraphModel that contains the cells. |
cells | Array of mxCells to change the style for. |
key | Key of the style to be changed. |
flag | Integer for the bit to be changed. |
value | Optional boolean value for the flag. |
static function setStyleFlag( $style, $key, $flag, $value )
Sets or removes the given key from the specified style and returns the new style. If value is null then the flag is toggled.
style | String of the form stylename[;key=value]. |
key | Key of the style to be changed. |
flag | Integer for the bit to be changed. |
value | Optional boolean value for the given flag. |
static function getValue( $dict, $key, $default = null )
Returns the value for key in dictionary or the given default value if no value is defined for the key.
dict | Dictionary that contains the key, value pairs. |
key | Key whose value should be returned. |
default | Default value to return if the key is undefined. Default is null. |
static function getNumber( $dict, $key, $default = )
Returns the value for key in dictionary or 0 if no value is defined for the key.
dict | Dictionary that contains the key, value pairs. |
key | Key whose value should be returned. |
default | Optional default value to return if no value is defined for the given key. Default is 0. |
static function isNode( $value, $nodeName = null, $attributeName = null, $attributeValue = null )
Returns true if the given value is an XML node with the node name and if the optional attribute has the specified value.
This implementation assumes that the given value is a DOM node if the nodeName property is not null.
value | Object that should be examined as a node. |
nodeName | String that specifies the node name. |
attributeName | Optional attribute name to check. |
attributeValue | Optional attribute value to check. |
Returns the size of the given label.
static function getLabelSize( $label, $style )
Returns the paint bounds for the given label.
static function getLabelPaintBounds( $label, $style, $isHtml, $offset, $vertexBounds, $scale )
Returns the bounds for a label for the given location and size, taking into account the alignment and spacing in the specified style, as well as the width and height of the rectangle that contains the label.
static function getScaledLabelBounds( $x, $y, $size, $outerWidth, $outerHeight, $style, $scale )
Returns an mxRectangle with the size (width and height in pixels) of the given string.
static function getSizeForString( $text, $fontSize = 0, $fontFamily = null )
Flips the given image horizontally and/or vertically and returns a new image instance.
static function flipImage( $img, $flipH, $flipV )
Converts the given degree to radians.
static function toRadians( $deg )
Returns the bounding box for the rotated rectangle.
static function getBoundingBox( $rect, $rotation )
Rotates the given point by the given cos and sin.
static function getRotatedPoint( $pt, $cos, $sin, $cx = null )
Creates a new list of new points obtained by translating the points in the given list by the given vector.
static function translatePoints( $pts, $dx, $dy )
Returns true if the specified point (x, y) is contained in the given rectangle.
static function contains( $state, $x, $y )
Returns the intersection of two lines as an mxPoint.
static function intersection( $x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3 )
Encodes the given image using the GD image encoding routines.
static function encodeImage( $image, $format = null )
Returns the stylename in a style of the form [stylename;|key=value;] or an empty string if the given style does not contain a stylename.
static function getStylename( $style )
Returns the stylenames in a style of the form [stylename;|key=value;] or an empty array if the given style does not contain any stylenames.
static function getStylenames( $style )
Returns the index of the given stylename in the given style.
static function indexOfStylename( $style, $stylename )
Adds the specified stylename to the given style if it does not already contain the stylename.
static function addStylename( $style, $stylename )
Removes all occurrences of the specified stylename in the given style and returns the updated style.
static function removeStylename( $style, $stylename )
Removes all stylenames from the given style and returns the updated style.
static function removeAllStylenames( $style )
Assigns the value for the given key in the styles of the given cells, or removes the key from the styles if the value is null.
static function setCellStyles( $model, $cells, $key, $value )
Adds or removes the given key, value pair to the style and returns the new style.
static function setStyle( $style, $key, $value )
Sets or toggles the flag bit for the given key in the cell’s styles.
static function setCellStyleFlags( $model, $cells, $key, $flag, $value )
Sets or removes the given key from the specified style and returns the new style.
static function setStyleFlag( $style, $key, $flag, $value )
Returns the value for key in dictionary or the given default value if no value is defined for the key.
static function getValue( $dict, $key, $default = null )
Returns the value for key in dictionary or 0 if no value is defined for the key.
static function getNumber( $dict, $key, $default = )
Returns the index of obj in array or -1 if the array does not contains the given object.
static function indexOf( $array, $object )
Reads the given filename into a string.
static function readFile( $filename )
Returns true if the given value is an XML node with the node name and if the optional attribute has the specified value.
static function isNode( $value, $nodeName = null, $attributeName = null, $attributeValue = null )
Loads an image from the local filesystem, a data URI or any other URL.
static function loadImage( $url )
Returns a new, empty XML document.
static function createXmlDocument()
Returns a new DOM document for the given URI.
static function loadXmlDocument( $uri )
Returns a new DOM document for the given XML string.
static function parseXml( $xml )
Evaluates an expression to a class member.
static function evaluate( $expression )
Returns the first node where attr equals value.
static function findNode( $node, $attr, $value )
Returns the truetype font to be used to draw the text with the given style.
static function getTrueTypeFont( $style )
Returns the truetype font size to be used to draw the text with the given style.
static function getTrueTypeFontSize( $size )
Returns the fixed font size for GD (1 t0 5) for the given font properties
static function getFixedFontSize( $fontSize, $fontFamily, $fontStyle = null )
Prints a simple stack trace in the error log.
static function stackTrace()
Defines the default size for all fonts in points.
public static $DEFAULT_FONTSIZE
Defines the default family for all truetype fonts.
public static $DEFAULT_FONTFAMILY