Contains various helper methods for use with mxGraph. More...
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< mxPoint > | TranslatePoints (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. |
Contains various helper methods for use with mxGraph.
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.
style | ||
stylename |
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.
x0 | ||
y0 | ||
r1 | ||
r2 | ||
angle | ||
largeArcFlag | ||
sweepFlag | ||
x | ||
y |
static XmlDocument com::mxgraph::mxUtils::CreateDocument | ( | ) | [inline, static] |
Returns a new, empty DOM document.
static Image com::mxgraph::mxUtils::CreateImage | ( | int | width, | |
int | height, | |||
Color? | background | |||
) | [inline, static] |
Creates an image for the given parameters.
width | ||
height | ||
background |
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.
expression |
static void com::mxgraph::mxUtils::FillClippedRect | ( | Graphics | g, | |
Brush | brush, | |||
int | x, | |||
int | y, | |||
int | width, | |||
int | height | |||
) | [inline, static] |
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, | |||
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. | |
defaultValue | Default value to return if the key is undefined. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. | |
defaultValue | Default value to return if the key is undefined. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. | |
defaultValue | Default value to return if the key is undefined. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. |
static Font com::mxgraph::mxUtils::GetFont | ( | Dictionary< string, Object > | style, | |
double | scale | |||
) | [inline, static] |
style | ||
scale |
static Font com::mxgraph::mxUtils::GetFont | ( | Dictionary< string, Object > | style | ) | [inline, static] |
style |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. | |
defaultValue | Default value to return if the key is undefined. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. |
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.
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.
text | String whose Md5 hash should be returned. |
static string com::mxgraph::mxUtils::GetPrettyXml | ( | XmlNode | node | ) | [inline, static] |
Returns a pretty-printed XML string for the given node.
node | Node to return the XML for. |
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 mxPoint com::mxgraph::mxUtils::GetRotatedPoint | ( | mxPoint | pt, | |
double | cos, | |||
double | sin | |||
) | [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, | |||
int | width | |||
) | [inline, static] |
Returns an mxRectangle with the size (width and height in pixels) of the given text.
text | String whose size should be returned. | |
font | Specifies the font that should be used. | |
width | Specifies the width of the text block for word wrapping. |
static mxRectangle com::mxgraph::mxUtils::GetSizeForString | ( | String | text, | |
Font | font | |||
) | [inline, static] |
Returns the size of the given text.
text | String whose size should be returned. | |
font | Specifies the font that should be used. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. | |
defaultValue | Default value to return if the key is undefined. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. |
static StringFormat com::mxgraph::mxUtils::GetStringFormat | ( | Dictionary< string, Object > | style | ) | [inline, static] |
Creates a new StringFormat object for the given style.
style |
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.
style | String of the form stylename[;key=value]. |
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.
style | String of the form stylename[;stylename][;key=value]. |
static string com::mxgraph::mxUtils::GetXml | ( | XmlNode | node, | |
Formatting | formatting | |||
) | [inline, static] |
Returns a pretty-printed XML string for the given node.
node | Node to return the XML for. | |
formatting | Formatting of the string to be returned. |
static string com::mxgraph::mxUtils::GetXml | ( | XmlNode | node | ) | [inline, static] |
Returns a string that represents the given node.
node | Node to return the XML for. |
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.
text |
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.
style | ||
stylename |
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.
x0 | X-coordinate of the first line's startpoint. | |
y0 | Y-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 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.
value | Object that represents the value to be tested. | |
nodeName | String that specifies the node name. | |
attributeName | Optional attribute name to check. | |
attributeValue | Optional attribute value to check. |
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.
value | Object that represents the value to be tested. | |
nodeName | String that specifies the node name. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. | |
defaultValue | Default value to return if the key is undefined. |
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.
dict | Dictionary that contains the key, value pairs. | |
key | Key whose value should be returned. |
static XmlDocument com::mxgraph::mxUtils::LoadDocument | ( | string | uri | ) | [inline, static] |
Returns a new DOM document for the given URI.
uri | URI to parse into the document. |
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.
xml | String that contains the XML markup. |
static string com::mxgraph::mxUtils::ReadFile | ( | string | filename | ) | [inline, static] |
Reads the given filename into a string.
filename | Name of the file to be read. |
static String com::mxgraph::mxUtils::RemoveAllStylenames | ( | String | style | ) | [inline, static] |
Removes all stylenames from the given style and returns the updated style.
style |
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.
style | ||
stylename |
static XmlNode com::mxgraph::mxUtils::SelectSingleNode | ( | XmlDocument | doc, | |
string | expression | |||
) | [inline, static] |
Returns a single node that matches the given XPath expression.
doc | Document that contains the nodes. | |
expression | XPath expression to be matched. |
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.
model | Model that contains the cells. | |
cells | Array of cells 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 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.
model | Model to execute the transaction in. | |
cells | Array of cells to be updated. | |
key | Key of the style to be changed. | |
value | New 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.
style | String of the form stylename[;key=value]. | |
key | Key of the style to be changed. | |
value | New value for the given key. |
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.
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 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.
pts | ||
dx | ||
dy |