mxGraph
Public Member Functions | Static Public Member Functions
com.mxgraph.mxUtils Class Reference

Contains various helper methods for use with mxGraph. More...

List of all members.

Public Member Functions

String AddStylename (String style, String stylename)
 Adds the specified stylename to the given style if it does not already contain the stylename.
String RemoveStylename (String style, String stylename)
 Removes all occurrences of the specified stylename in the given style and returns the updated style.

Static Public Member Functions

static mxRectangle GetLabelSize (string label, Dictionary< string, Object > style, int width)
 Returns the size of the given label.
static mxRectangle GetLabelPaintBounds (String label, Dictionary< string, Object > style, bool isHtml, mxPoint offset, mxRectangle vertexBounds, double scale)
 Returns the paint bounds for the given label.
static mxRectangle GetScaledLabelBounds (double x, double y, mxRectangle size, double outerWidth, double outerHeight, Dictionary< string, Object > style, double 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 mxRectangle GetSizeForString (String text, Font font)
 Returns the size of the given text.
static mxRectangle GetSizeForString (String text, Font font, int width)
 Returns an mxRectangle with the size (width and height in pixels) of the given text.
static double ToRadians (double deg)
 Converts the given degree to radians.
static double[] ArcToCurves (double x0, double y0, double r1, double r2, double angle, double largeArcFlag, double sweepFlag, double x, double y)
 Converts the given arc to a series of curves.
static mxRectangle GetBoundingBox (mxRectangle rect, double rotation)
 Returns the bounding box of the rotated rectangle.
static mxPoint GetRotatedPoint (mxPoint pt, double cos, double sin)
 Rotates the given point by the given cos and sin.
static mxPoint GetRotatedPoint (mxPoint pt, double cos, double sin, mxPoint c)
 Rotates the given point by the given cos and sin.
static void FillClippedRect (Graphics g, Brush brush, int x, int y, int width, int height)
static Image CreateImage (int width, int height, Color?background)
 Creates an image for the given parameters.
static List< mxPointTranslatePoints (List< mxPoint > pts, double dx, double dy)
 Creates a new list of new points obtained by translating the points in the given list by the given vector. Elements that are not mxPoints are added to the result as-is.
static mxPoint Intersection (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
 Returns the intersection of two lines as an mxPoint.
static String GetStylename (String style)
 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 String[] GetStylenames (String 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 int IndexOfStylename (String style, String stylename)
 Returns the index of the given stylename in the given style. This returns -1 if the given stylename does not occur (as a stylename) in the given style, otherwise it returns the index of the first character.
static String RemoveAllStylenames (String style)
 Removes all stylenames from the given style and returns the updated style.
static void SetCellStyles (mxIGraphModel model, Object[] cells, String key, String 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.
static String SetStyle (String style, String key, String 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.
static void SetCellStyleFlags (mxIGraphModel model, Object[] cells, String key, int flag, Boolean 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.
static String SetStyleFlag (String style, String key, int flag, bool?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.
static bool IsTrue (Dictionary< string, Object > dict, string key)
 Returns true if the dictionary contains true for the given key or false if no value is defined for the key.
static bool IsTrue (Dictionary< string, Object > dict, string key, bool defaultValue)
 Returns true if the dictionary contains true for the given key or the given default value if no value is defined for the key.
static int GetInt (Dictionary< string, Object > dict, string key)
 Returns the value for key in dictionary as an int or 0 if no value is defined for the key.
static int GetInt (Dictionary< string, Object > dict, string key, int defaultValue)
 Returns the value for key in dictionary as an int or the given default value if no value is defined for the key.
static float GetFloat (Dictionary< string, Object > dict, string key)
 Returns the value for key in dictionary as a float or 0 if no value is defined for the key.
static float GetFloat (Dictionary< string, Object > dict, string key, float defaultValue)
 Returns the value for key in dictionary as a float or the given default value if no value is defined for the key.
static double GetDouble (Dictionary< string, Object > dict, string key)
 Returns the value for key in dictionary as a double or 0 if no value is defined for the key.
static double GetDouble (Dictionary< string, Object > dict, string key, double defaultValue)
 Returns the value for key in dictionary as a double or the given default value if no value is defined for the key.
static string GetString (Dictionary< string, Object > dict, string key)
 Returns the value for key in dictionary as a string or null if no value is defined for the key.
static string GetString (Dictionary< string, Object > dict, string key, string defaultValue)
 Returns the value for key in dictionary as a string or the given default value if no value is defined for the key.
static Color GetColor (Dictionary< string, Object > dict, string key)
 Returns the value for key in dictionary as a color or null if no value is defined for the key.
static Color GetColor (Dictionary< string, Object > dict, string key, Color?defaultValue)
 Returns the value for key in dictionary as a color or the given default value if no value is defined for the key.
static Font GetFont (Dictionary< string, Object > style)
static Font GetFont (Dictionary< string, Object > style, double scale)
static StringFormat GetStringFormat (Dictionary< string, Object > style)
 Creates a new StringFormat object for the given style.
static string ReadFile (string filename)
 Reads the given filename into a string.
static string GetMd5Hash (string text)
 Returns the Md5 hash for the given text.
static bool IsNode (Object value, String nodeName)
 Returns true if the given value is an XML node with the specified nodename. specified.
static bool IsNode (Object value, String nodeName, String attributeName, String attributeValue)
 Returns true if the user object is an XML node with the specified type and and the optional attribute has the specified value or is not specified.
static Image LoadImage (String url)
 Loads an image from the local filesystem, a data URI or any other URL.
static XmlDocument CreateDocument ()
 Returns a new, empty DOM document.
static XmlDocument LoadDocument (string uri)
 Returns a new DOM document for the given URI.
static XmlDocument ParseXml (string xml)
 Returns a document that represents the given XML string.
static XmlNode FindNode (XmlNode node, String attr, String value)
 Returns the first node where attr equals value. This implementation does not use XPath.
static XmlNode SelectSingleNode (XmlDocument doc, string expression)
 Returns a single node that matches the given XPath expression.
static Object Eval (string expression)
 Evaluates a Java expression to a class member using mxCodecRegistry. The range of supported expressions is limited to static class members such as mxEdgeStyle.ElbowConnector.
static String HtmlEntities (String text)
 Converts the ampersand, quote, prime, less-than and greater-than characters to their corresponding HTML entities in the given string.
static string GetXml (XmlNode node)
 Returns a string that represents the given node.
static string GetPrettyXml (XmlNode node)
 Returns a pretty-printed XML string for the given node.
static string GetXml (XmlNode node, Formatting formatting)
 Returns a pretty-printed XML string for the given node.

Detailed Description

Contains various helper methods for use with mxGraph.


Member Function Documentation

String com.mxgraph.mxUtils.AddStylename ( String  style,
String  stylename 
) [inline]

Adds the specified stylename to the given style if it does not already contain the stylename.

Parameters:
style
stylename
Returns:
static double [] com.mxgraph.mxUtils.ArcToCurves ( double  x0,
double  y0,
double  r1,
double  r2,
double  angle,
double  largeArcFlag,
double  sweepFlag,
double  x,
double  y 
) [inline, static]

Converts the given arc to a series of curves.

Parameters:
x0
y0
r1
r2
angle
largeArcFlag
sweepFlag
x
y
Returns:
static XmlDocument com.mxgraph.mxUtils.CreateDocument ( ) [inline, static]

Returns a new, empty DOM document.

Returns:
Returns a new DOM document.
static Image com.mxgraph.mxUtils.CreateImage ( int  width,
int  height,
Color?  background 
) [inline, static]

Creates an image for the given parameters.

Parameters:
width
height
background
Returns:
static Object com.mxgraph.mxUtils.Eval ( string  expression) [inline, static]

Evaluates a Java expression to a class member using mxCodecRegistry. The range of supported expressions is limited to static class members such as mxEdgeStyle.ElbowConnector.

Parameters:
expression
Returns:
static void com.mxgraph.mxUtils.FillClippedRect ( Graphics  g,
Brush  brush,
int  x,
int  y,
int  width,
int  height 
) [inline, static]
Parameters:
g
brush
x
y
width
height
static XmlNode com.mxgraph.mxUtils.FindNode ( XmlNode  node,
String  attr,
String  value 
) [inline, static]

Returns the first node where attr equals value. This implementation does not use XPath.

static mxRectangle com.mxgraph.mxUtils.GetBoundingBox ( mxRectangle  rect,
double  rotation 
) [inline, static]

Returns the bounding box of the rotated rectangle.

static Color com.mxgraph.mxUtils.GetColor ( Dictionary< string, Object >  dict,
string  key 
) [inline, static]

Returns the value for key in dictionary as a color or null if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
Returns:
Returns the color value for key in dict.
static Color com.mxgraph.mxUtils.GetColor ( Dictionary< string, Object >  dict,
string  key,
Color?  defaultValue 
) [inline, static]

Returns the value for key in dictionary as a color or the given default value if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
defaultValueDefault value to return if the key is undefined.
Returns:
Returns the color value for key in dict.
static double com.mxgraph.mxUtils.GetDouble ( Dictionary< string, Object >  dict,
string  key 
) [inline, static]

Returns the value for key in dictionary as a double or 0 if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
Returns:
Returns the double value for key in dict.
static double com.mxgraph.mxUtils.GetDouble ( Dictionary< string, Object >  dict,
string  key,
double  defaultValue 
) [inline, static]

Returns the value for key in dictionary as a double or the given default value if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
defaultValueDefault value to return if the key is undefined.
Returns:
Returns the double value for key in dict.
static float com.mxgraph.mxUtils.GetFloat ( Dictionary< string, Object >  dict,
string  key 
) [inline, static]

Returns the value for key in dictionary as a float or 0 if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
Returns:
Returns the float value for key in dict.
static float com.mxgraph.mxUtils.GetFloat ( Dictionary< string, Object >  dict,
string  key,
float  defaultValue 
) [inline, static]

Returns the value for key in dictionary as a float or the given default value if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
defaultValueDefault value to return if the key is undefined.
Returns:
Returns the float value for key in dict.
static Font com.mxgraph.mxUtils.GetFont ( Dictionary< string, Object >  style) [inline, static]
Parameters:
style
Returns:
static Font com.mxgraph.mxUtils.GetFont ( Dictionary< string, Object >  style,
double  scale 
) [inline, static]
Parameters:
style
scale
Returns:
static int com.mxgraph.mxUtils.GetInt ( Dictionary< string, Object >  dict,
string  key 
) [inline, static]

Returns the value for key in dictionary as an int or 0 if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
Returns:
Returns the integer value for key in dict.
static int com.mxgraph.mxUtils.GetInt ( Dictionary< string, Object >  dict,
string  key,
int  defaultValue 
) [inline, static]

Returns the value for key in dictionary as an int or the given default value if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
defaultValueDefault value to return if the key is undefined.
Returns:
Returns the integer value for key in dict.
static mxRectangle com.mxgraph.mxUtils.GetLabelPaintBounds ( String  label,
Dictionary< string, Object >  style,
bool  isHtml,
mxPoint  offset,
mxRectangle  vertexBounds,
double  scale 
) [inline, static]

Returns the paint bounds for the given label.

Returns:
static mxRectangle com.mxgraph.mxUtils.GetLabelSize ( string  label,
Dictionary< string, Object >  style,
int  width 
) [inline, static]

Returns the size of the given label.

static string com.mxgraph.mxUtils.GetMd5Hash ( string  text) [inline, static]

Returns the Md5 hash for the given text.

Parameters:
textString whose Md5 hash should be returned.
Returns:
Returns the Md5 hash for the given text.
static string com.mxgraph.mxUtils.GetPrettyXml ( XmlNode  node) [inline, static]

Returns a pretty-printed XML string for the given node.

Parameters:
nodeNode to return the XML for.
Returns:
Returns a formatted XML string.
static mxPoint com.mxgraph.mxUtils.GetRotatedPoint ( mxPoint  pt,
double  cos,
double  sin 
) [inline, static]

Rotates the given point by the given cos and sin.

static mxPoint com.mxgraph.mxUtils.GetRotatedPoint ( mxPoint  pt,
double  cos,
double  sin,
mxPoint  c 
) [inline, static]

Rotates the given point by the given cos and sin.

static mxRectangle com.mxgraph.mxUtils.GetScaledLabelBounds ( double  x,
double  y,
mxRectangle  size,
double  outerWidth,
double  outerHeight,
Dictionary< string, Object >  style,
double  scale 
) [inline, static]

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 mxRectangle com.mxgraph.mxUtils.GetSizeForString ( String  text,
Font  font 
) [inline, static]

Returns the size of the given text.

Parameters:
textString whose size should be returned.
fontSpecifies the font that should be used.
Returns:
Returns the size of the given text.
static mxRectangle com.mxgraph.mxUtils.GetSizeForString ( String  text,
Font  font,
int  width 
) [inline, static]

Returns an mxRectangle with the size (width and height in pixels) of the given text.

Parameters:
textString whose size should be returned.
fontSpecifies the font that should be used.
widthSpecifies the width of the text block for word wrapping.
Returns:
Returns the size of the given text.
static string com.mxgraph.mxUtils.GetString ( Dictionary< string, Object >  dict,
string  key 
) [inline, static]

Returns the value for key in dictionary as a string or null if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
Returns:
Returns the string value for key in dict.
static string com.mxgraph.mxUtils.GetString ( Dictionary< string, Object >  dict,
string  key,
string  defaultValue 
) [inline, static]

Returns the value for key in dictionary as a string or the given default value if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
defaultValueDefault value to return if the key is undefined.
Returns:
Returns the string value for key in dict.
static StringFormat com.mxgraph.mxUtils.GetStringFormat ( Dictionary< string, Object >  style) [inline, static]

Creates a new StringFormat object for the given style.

Parameters:
style
Returns:
static String com.mxgraph.mxUtils.GetStylename ( String  style) [inline, static]

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.

Parameters:
styleString of the form stylename[;key=value].
Returns:
Returns the stylename from the given formatted string.
static String [] com.mxgraph.mxUtils.GetStylenames ( String  style) [inline, static]

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.

Parameters:
styleString of the form stylename[;stylename][;key=value].
Returns:
Returns the stylename from the given formatted string.
static string com.mxgraph.mxUtils.GetXml ( XmlNode  node) [inline, static]

Returns a string that represents the given node.

Parameters:
nodeNode to return the XML for.
Returns:
Returns an XML string.
static string com.mxgraph.mxUtils.GetXml ( XmlNode  node,
Formatting  formatting 
) [inline, static]

Returns a pretty-printed XML string for the given node.

Parameters:
nodeNode to return the XML for.
formattingFormatting of the string to be returned.
Returns:
Returns a formatted XML string.
static String com.mxgraph.mxUtils.HtmlEntities ( String  text) [inline, static]

Converts the ampersand, quote, prime, less-than and greater-than characters to their corresponding HTML entities in the given string.

Parameters:
text
Returns:
static int com.mxgraph.mxUtils.IndexOfStylename ( String  style,
String  stylename 
) [inline, static]

Returns the index of the given stylename in the given style. This returns -1 if the given stylename does not occur (as a stylename) in the given style, otherwise it returns the index of the first character.

Parameters:
style
stylename
Returns:
static mxPoint com.mxgraph.mxUtils.Intersection ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
) [inline, static]

Returns the intersection of two lines as an mxPoint.

Parameters:
x0X-coordinate of the first line's startpoint.
y0Y-coordinate of the first line's startpoint.
x1X-coordinate of the first line's endpoint.
y1Y-coordinate of the first line's endpoint.
x2X-coordinate of the second line's startpoint.
y2Y-coordinate of the second line's startpoint.
x3X-coordinate of the second line's endpoint.
y3Y-coordinate of the second line's endpoint.
Returns:
static bool com.mxgraph.mxUtils.IsNode ( Object  value,
String  nodeName 
) [inline, static]

Returns true if the given value is an XML node with the specified nodename. specified.

Parameters:
valueObject that represents the value to be tested.
nodeNameString that specifies the node name.
Returns:
Returns true if the node name of the user object is equal to the given type.
static bool com.mxgraph.mxUtils.IsNode ( Object  value,
String  nodeName,
String  attributeName,
String  attributeValue 
) [inline, static]

Returns true if the user object is an XML node with the specified type and and the optional attribute has the specified value or is not specified.

Parameters:
valueObject that represents the value to be tested.
nodeNameString that specifies the node name.
attributeNameOptional attribute name to check.
attributeValueOptional attribute value to check.
Returns:
Returns true if the cell matches the given conditions.
static bool com.mxgraph.mxUtils.IsTrue ( Dictionary< string, Object >  dict,
string  key 
) [inline, static]

Returns true if the dictionary contains true for the given key or false if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
Returns:
Returns the boolean value for key in dict.
static bool com.mxgraph.mxUtils.IsTrue ( Dictionary< string, Object >  dict,
string  key,
bool  defaultValue 
) [inline, static]

Returns true if the dictionary contains true for the given key or the given default value if no value is defined for the key.

Parameters:
dictDictionary that contains the key, value pairs.
keyKey whose value should be returned.
defaultValueDefault value to return if the key is undefined.
Returns:
Returns the boolean value for key in dict.
static XmlDocument com.mxgraph.mxUtils.LoadDocument ( string  uri) [inline, static]

Returns a new DOM document for the given URI.

Parameters:
uriURI to parse into the document.
Returns:
Returns a new DOM document for the given URI.
static Image com.mxgraph.mxUtils.LoadImage ( String  url) [inline, static]

Loads an image from the local filesystem, a data URI or any other URL.

static XmlDocument com.mxgraph.mxUtils.ParseXml ( string  xml) [inline, static]

Returns a document that represents the given XML string.

Parameters:
xmlString that contains the XML markup.
Returns:
Returns an XML document.
static string com.mxgraph.mxUtils.ReadFile ( string  filename) [inline, static]

Reads the given filename into a string.

Parameters:
filenameName of the file to be read.
Returns:
Returns a string representing the file contents.
static String com.mxgraph.mxUtils.RemoveAllStylenames ( String  style) [inline, static]

Removes all stylenames from the given style and returns the updated style.

Parameters:
style
Returns:
String com.mxgraph.mxUtils.RemoveStylename ( String  style,
String  stylename 
) [inline]

Removes all occurrences of the specified stylename in the given style and returns the updated style.

Parameters:
style
stylename
Returns:
static XmlNode com.mxgraph.mxUtils.SelectSingleNode ( XmlDocument  doc,
string  expression 
) [inline, static]

Returns a single node that matches the given XPath expression.

Parameters:
docDocument that contains the nodes.
expressionXPath expression to be matched.
Returns:
Returns a single node matching the given expression.
static void com.mxgraph.mxUtils.SetCellStyleFlags ( mxIGraphModel  model,
Object[]  cells,
String  key,
int  flag,
Boolean  value 
) [inline, static]

Sets or toggles the flag bit for the given key in the cell's styles. If value is null then the flag is toggled.

Parameters:
modelModel that contains the cells.
cellsArray of cells to change the style for.
keyKey of the style to be changed.
flagInteger for the bit to be changed.
valueOptional boolean value for the flag.
static void com.mxgraph.mxUtils.SetCellStyles ( mxIGraphModel  model,
Object[]  cells,
String  key,
String  value 
) [inline, static]

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.

Parameters:
modelModel to execute the transaction in.
cellsArray of cells to be updated.
keyKey of the style to be changed.
valueNew value for the given key.
static String com.mxgraph.mxUtils.SetStyle ( String  style,
String  key,
String  value 
) [inline, static]

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.

Parameters:
styleString of the form stylename[;key=value].
keyKey of the style to be changed.
valueNew value for the given key.
Returns:
Returns the new style.
static String com.mxgraph.mxUtils.SetStyleFlag ( String  style,
String  key,
int  flag,
bool?  value 
) [inline, static]

Sets or removes the given key from the specified style and returns the new style. If value is null then the flag is toggled.

Parameters:
styleString of the form stylename[;key=value].
keyKey of the style to be changed.
flagInteger for the bit to be changed.
valueOptional boolean value for the given flag.
Returns:
Returns the new style.
static double com.mxgraph.mxUtils.ToRadians ( double  deg) [inline, static]

Converts the given degree to radians.

static List<mxPoint> com.mxgraph.mxUtils.TranslatePoints ( List< mxPoint pts,
double  dx,
double  dy 
) [inline, static]

Creates a new list of new points obtained by translating the points in the given list by the given vector. Elements that are not mxPoints are added to the result as-is.

Parameters:
pts
dx
dy
Returns:

The documentation for this class was generated from the following file: