Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JGraph X 1.4.0.9
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mxgraph.util
Class mxUtils

    java.lang.Object
      com.mxgraph.util.mxUtils

    public class mxUtils

extends Object

Contains various helper methods for use with mxGraph.

Field Summary
`protected static Graphics` | `fontGraphics` Static Graphics used for Font Metrics.

Constructor Summary
`mxUtils()`

Method Summary
`String` | `addStylename(String style, String stylename)` Adds the specified stylename to the given style if it does not already contain the stylename.
`static void` | `clearRect(Graphics2D g, Rectangle rect, Color background)` Clears the given area of the specified graphics object with the given color or makes the region transparent.
`static boolean` | `contains(Object[] array, Object obj)` Returns true if the given array contains the given object.
`static BufferedImage` | `createBufferedImage(int w, int h, Color background)` Creates a buffered image for the given parameters.
`static Document` | `createDocument()` Returns a new, empty DOM document.
`static Document` | `createHtmlDocument()` Returns a document with a HTML node containing a HEAD and BODY node.
`static String` | `createHtmlDocument(Map<String,Object> style, String text)` Returns a new, empty DOM document.
`static String` | `createHtmlDocument(Map<String,Object> style, String text, double scale)` Returns a new, empty DOM document.
`static HTMLDocument` | `createHtmlDocumentObject(Map<String,Object> style, double scale)` Returns a new, empty DOM document.
`static Document` | `createSvgDocument(int width, int height)` Creates a new SVG document for the given width and height.
`static Element` | `createTable(Document document, String text, int x, int y, int w, int h, double scale, Map<String,Object> style)` Creates a table for the given text using the given document to create the DOM nodes.
`static Document` | `createVmlDocument()`
`static void` | `drawImageClip(Graphics g, BufferedImage image, ImageObserver observer)` Draws the image inside the clip bounds to the given graphics object.
`static Object` | `eval(String expression)` Evaluates a Java expression as a class member using mxCodecRegistry.
`static void` | `fillClippedRect(Graphics g, int x, int y, int width, int height)`
`static int` | `findNearestSegment(mxCellState state, double x, double y)` Finds the index of the nearest segment on the given cell state for the specified coordinate pair.
`static Node` | `findNode(Node node, String attr, String value)` Returns the first node where attr equals value.
`static String` | `getBodyMarkup(String markup, boolean replaceLinefeeds)` Returns the body part of the given HTML markup.
`static mxRectangle` | `getBoundingBox(mxRectangle rect, double rotation)` Returns the bounding box for the rotated rectangle.
`static Color` | `getColor(Map<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(Map<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 double` | `getDouble(Map<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(Map<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 float` | `getFloat(Map<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(Map<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 float[]` | `getFloatArray(Map<String,Object> dict, String key, float[] defaultValue)` Returns the value for key in dictionary as a float array or the given default value if no value is defined for the key.
`static Font` | `getFont(Map<String,Object> style)`
`static Font` | `getFont(Map<String,Object> style, double scale)`
`static String` | `getHexColorString(Color color)` Returns a hex representation for the given color.
`static int` | `getInt(Map<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(Map<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 mxRectangle` | `getLabelPaintBounds(String label, Map<String,Object> style, boolean isHtml, mxPoint offset, mxRectangle vertexBounds, double scale)` Returns the paint bounds for the given label.
`static mxRectangle` | `getLabelSize(String label, Map<String,Object> style, boolean isHtml, int width)` Returns the size for the given label.
`static String` | `getMd5Hash(String text)` Returns the Md5 hash for the given text.
`static String` | `getPrettyXml(Node node)` Returns a pretty-printed XML string for the given node.
`static String` | `getPrettyXml(Node node, String tab, String indent)` Returns a pretty-printed XML string for the given node.
`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 mxRectangle` | `getScaledLabelBounds(double x, double y, mxRectangle size, double outerWidth, double outerHeight, Map<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.
`static mxRectangle` | `getSizeForHtml(String markup, Map<String,Object> style)` Returns an mxRectangle with the size (width and height in pixels) of the given HTML markup.
`static mxRectangle` | `getSizeForString(String text, Font font, int width)` Returns an with the size (width and height in pixels) of the given string.
`static String` | `getString(Map<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(Map<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 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 String` | `getXml(Node node)` Returns a string that represents the given node.
`static String` | `hexString(Color color)`
`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 int` | `indexOf(Object[] array, Object obj)` Returns the index of the given object in the given array of -1 if the object is not contained in the array.
`static int` | `indexOfStylename(String style, String stylename)` Returns the index of the given stylename in the given style.
`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 boolean` | `intersectsHotspot(mxCellState state, int x, int y, double hotspot)`
`static boolean` | `intersectsHotspot(mxCellState state, int x, int y, double hotspot, int min, int max)` Returns true if the given coordinate pair intersects the hotspot of the given state.
`static boolean` | `isNode(Object value, String nodeName)` 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 boolean` | `isNode(Object value, String nodeName, String attributeName, String attributeValue)` Returns true if the given value is an XML node with the node name and if the optional attribute has the specified value.
`static boolean` | `isTrue(Map<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 boolean` | `isTrue(Map<String,Object> dict, String key, boolean 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 Document` | `loadDocument(String uri)` Returns a new DOM document for the given URI.
`static Image` | `loadImage(String url)`
`static Color` | `parseColor(String colorString)` Convert a string representing a 24/32bit hex color value into a Color object.
`static Document` | `parseXml(String xml)` Returns a new document for the given XML string.
`static String` | `readFile(String filename)` Reads the given filename into a string.
`static String` | `removeAllStylenames(String style)` Removes all stylenames from the given style and returns the updated style.
`String` | `removeStylename(String style, String stylename)` Removes all occurrences of the specified stylename in the given style and returns the updated style.
`static Node` | `selectSingleNode(Document doc, String expression)` Returns a single node that matches the given XPath expression.
`static void` | `setAntiAlias(Graphics2D g, boolean antiAlias, boolean textAntiAlias)`
`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.
`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.
`static String` | `setStyleFlag(String style, String key, int flag, Boolean value)` Sets or removes the given key from the specified style and returns the new style.
`static Collection<Object>` | `sortCells(Collection<Object> cells, boolean ascending)` Sorts the given cells according to the order in the cell hierarchy.
`static Object[]` | `sortCells(Object[] cells, boolean ascending)` Sorts the given cells according to the order in the cell hierarchy.
`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.
`static String[]` | `wordWrap(String text, FontMetrics metrics, int width)` Returns the specified text in lines that fit within the specified width when the specified font metrics are applied to the text
`static void` | `writeFile(String contents, String filename)` Writes the given string into the given file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### fontGraphics

    protected static transient Graphics fontGraphics

  Static Graphics used for Font Metrics.

Constructor Detail

### mxUtils

    public mxUtils()

Method Detail

### getLabelSize

    public static mxRectangle getLabelSize(String label,
                                           Map<String,Object> style,
                                           boolean isHtml,
                                           int width)

  Returns the size for the given label. If isHtml is true then any HTML markup in the label is computed as HTML and all newlines inside the HTML body are converted into linebreaks.

### getBodyMarkup

    public static String getBodyMarkup(String markup,
                                       boolean replaceLinefeeds)

  Returns the body part of the given HTML markup.

### getLabelPaintBounds

    public static mxRectangle getLabelPaintBounds(String label,
                                                  Map<String,Object> style,
                                                  boolean isHtml,
                                                  mxPoint offset,
                                                  mxRectangle vertexBounds,
                                                  double scale)

  Returns the paint bounds for the given label.

### getScaledLabelBounds

    public static mxRectangle getScaledLabelBounds(double x,
                                                   double y,
                                                   mxRectangle size,
                                                   double outerWidth,
                                                   double outerHeight,
                                                   Map<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.

### getSizeForString

    public static mxRectangle getSizeForString(String text,
                                               Font font,
                                               int width)

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

  Parameters:
    `text` - String whose size should be returned.
    `font` - Font to be used for the computation.

### wordWrap

    public static String[] wordWrap(String text,
                                    FontMetrics metrics,
                                    int width)

  Returns the specified text in lines that fit within the specified width when the specified font metrics are applied to the text

  Parameters:
    `text` - the text to wrap
    `metrics` - the font metrics to calculate the text size for
    `width` - the width that the text must fit within
  Returns:
    the input text split in lines that fit the specified width

### getSizeForHtml

    public static mxRectangle getSizeForHtml(String markup,
                                             Map<String,Object> style)

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

  Parameters:
    `markup` - HTML markup whose size should be returned.

### getBoundingBox

    public static mxRectangle getBoundingBox(mxRectangle rect,
                                             double rotation)

  Returns the bounding box for the rotated rectangle.

### getRotatedPoint

    public static mxPoint getRotatedPoint(mxPoint pt,
                                          double cos,
                                          double sin)

  Rotates the given point by the given cos and sin.

### findNearestSegment

    public static int findNearestSegment(mxCellState state,
                                         double x,
                                         double y)

  Finds the index of the nearest segment on the given cell state for the specified coordinate pair.

### getRotatedPoint

    public static mxPoint getRotatedPoint(mxPoint pt,
                                          double cos,
                                          double sin,
                                          mxPoint c)

  Rotates the given point by the given cos and sin.

### drawImageClip

    public static void drawImageClip(Graphics g,
                                     BufferedImage image,
                                     ImageObserver observer)

  Draws the image inside the clip bounds to the given graphics object.

### fillClippedRect

    public static void fillClippedRect(Graphics g,
                                       int x,
                                       int y,
                                       int width,
                                       int height)

### translatePoints

    public 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.

### intersection

    public 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.

  Parameters:
    `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.
  Returns:
    Returns the intersection between the two lines.

### sortCells

    public static Object[] sortCells(Object[] cells,
                                     boolean ascending)

  Sorts the given cells according to the order in the cell hierarchy.

### sortCells

    public static Collection<Object> sortCells(Collection<Object> cells,
                                               boolean ascending)

  Sorts the given cells according to the order in the cell hierarchy.

### contains

    public static boolean contains(Object[] array,
                                   Object obj)

  Returns true if the given array contains the given object.

### indexOf

    public static int indexOf(Object[] array,
                              Object obj)

  Returns the index of the given object in the given array of -1 if the object is not contained in the array.

### getStylename

    public 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.

  Parameters:
    `style` - String of the form stylename[;key=value].
  Returns:
    Returns the stylename from the given formatted string.

### getStylenames

    public 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.

  Parameters:
    `style` - String of the form stylename[;stylename][;key=value].
  Returns:
    Returns the stylename from the given formatted string.

### indexOfStylename

    public 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.

### addStylename

    public String addStylename(String style,
                               String stylename)

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

### removeStylename

    public String removeStylename(String style,
                                  String stylename)

  Removes all occurrences of the specified stylename in the given style and returns the updated style. Trailing semicolons are preserved.

### removeAllStylenames

    public static String removeAllStylenames(String style)

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

### setCellStyles

    public 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.

  Parameters:
    `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.

### setStyle

    public 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.

  Parameters:
    `style` - String of the form `stylename[;key=value]`.
    `key` - Key of the style to be changed.
    `value` - New value for the given key.
  Returns:
    Returns the new style.

### setCellStyleFlags

    public 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. `mxUtils.setCellStyleFlags(graph.getModel(), cells, mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_BOLD, null);` Toggles the bold font style.

  Parameters:
    `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.

### setStyleFlag

    public static String setStyleFlag(String style,
                                      String key,
                                      int flag,
                                      Boolean 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.

  Parameters:
    `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.

### intersectsHotspot

    public static boolean intersectsHotspot(mxCellState state,
                                            int x,
                                            int y,
                                            double hotspot)

### intersectsHotspot

    public static boolean intersectsHotspot(mxCellState state,
                                            int x,
                                            int y,
                                            double hotspot,
                                            int min,
                                            int max)

  Returns true if the given coordinate pair intersects the hotspot of the given state.

### isTrue

    public static boolean isTrue(Map<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.

  Parameters:
    `dict` - Dictionary that contains the key, value pairs.
    `key` - Key whose value should be returned.
  Returns:
    Returns the boolean value for key in dict.

### isTrue

    public static boolean isTrue(Map<String,Object> dict,
                                 String key,
                                 boolean 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.

  Parameters:
    `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.
  Returns:
    Returns the boolean value for key in dict.

### getInt

    public static int getInt(Map<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.

  Parameters:
    `dict` - Dictionary that contains the key, value pairs.
    `key` - Key whose value should be returned.
  Returns:
    Returns the integer value for key in dict.

### getInt

    public static int getInt(Map<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.

  Parameters:
    `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.
  Returns:
    Returns the integer value for key in dict.

### getFloat

    public static float getFloat(Map<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.

  Parameters:
    `dict` - Dictionary that contains the key, value pairs.
    `key` - Key whose value should be returned.
  Returns:
    Returns the float value for key in dict.

### getFloat

    public static float getFloat(Map<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.

  Parameters:
    `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.
  Returns:
    Returns the float value for key in dict.

### getFloatArray

    public static float[] getFloatArray(Map<String,Object> dict,
                                        String key,
                                        float[] defaultValue)

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

  Parameters:
    `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.
  Returns:
    Returns the float array value for key in dict.

### getDouble

    public static double getDouble(Map<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.

  Parameters:
    `dict` - Dictionary that contains the key, value pairs.
    `key` - Key whose value should be returned.
  Returns:
    Returns the double value for key in dict.

### getDouble

    public static double getDouble(Map<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.

  Parameters:
    `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.
  Returns:
    Returns the double value for key in dict.

### getString

    public static String getString(Map<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.

  Parameters:
    `dict` - Dictionary that contains the key, value pairs.
    `key` - Key whose value should be returned.
  Returns:
    Returns the string value for key in dict.

### getString

    public static String getString(Map<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.

  Parameters:
    `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.
  Returns:
    Returns the string value for key in dict.

### getColor

    public static Color getColor(Map<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.

  Parameters:
    `dict` - Dictionary that contains the key, value pairs.
    `key` - Key whose value should be returned.
  Returns:
    Returns the color value for key in dict.

### getColor

    public static Color getColor(Map<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.

  Parameters:
    `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.
  Returns:
    Returns the color value for key in dict.

### getFont

    public static Font getFont(Map<String,Object> style)

### getFont

    public static Font getFont(Map<String,Object> style,
                               double scale)

### hexString

    public static String hexString(Color color)

### parseColor

    public static Color parseColor(String colorString)
                            throws NumberFormatException

  Convert a string representing a 24/32bit hex color value into a Color object. The following color names are also supported: white, black, red, green, blue, orange, yellow, pink, turquoise, gray and none (null). Examples of possible hex color values are: #C3D9FF, #6482B9 and #774400.

  Parameters:
    `colorString` - the 24/32bit hex string value (ARGB)
  Returns:
    java.awt.Color (24bit RGB on JDK 1.1, 24/32bit ARGB on JDK1.2)
  Throws:
    `NumberFormatException` - if the specified string cannot be interpreted as a hexidecimal integer

### getHexColorString

    public static String getHexColorString(Color color)

  Returns a hex representation for the given color.

  Parameters:
    `color` - Color to return the hex string for.
  Returns:
    Returns a hex string for the given color.

### readFile

    public static String readFile(String filename)
                           throws IOException

  Reads the given filename into a string.

  Parameters:
    `filename` - Name of the file to be read.
  Returns:
    Returns a string representing the file contents.
  Throws:
    `IOException`

### writeFile

    public static void writeFile(String contents,
                                 String filename)
                          throws IOException

  Writes the given string into the given file.

  Parameters:
    `contents` - String representing the file contents.
    `filename` - Name of the file to be written.
  Throws:
    `IOException`

### getMd5Hash

    public static String getMd5Hash(String text)

  Returns the Md5 hash for the given text.

  Parameters:
    `text` - String whose Md5 hash should be returned.
  Returns:
    Returns the Md5 hash for the given text.

### isNode

    public static boolean isNode(Object value,
                                 String nodeName)

  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:
    `value` - Object that should be examined as a node.
    `nodeName` - String that specifies the node name.
  Returns:
    Returns true if the node name of the user object is equal to the given type.

### isNode

    public static boolean isNode(Object value,
                                 String nodeName,
                                 String attributeName,
                                 String attributeValue)

  Returns true if the given value is an XML node with the node name and if the optional attribute has the specified value.

  Parameters:
    `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:
    Returns true if the value matches the given conditions.

### setAntiAlias

    public static void setAntiAlias(Graphics2D g,
                                    boolean antiAlias,
                                    boolean textAntiAlias)

  Parameters:
    `g` -
    `antiAlias` -
    `textAntiAlias` -

### clearRect

    public static void clearRect(Graphics2D g,
                                 Rectangle rect,
                                 Color background)

  Clears the given area of the specified graphics object with the given color or makes the region transparent.

### createBufferedImage

    public static BufferedImage createBufferedImage(int w,
                                                    int h,
                                                    Color background)
                                             throws OutOfMemoryError

  Creates a buffered image for the given parameters. If there is not enough memory to create the image then a OutOfMemoryError is thrown.

  Throws:
    `OutOfMemoryError`

### createDocument

    public static Document createDocument()

  Returns a new, empty DOM document.

  Returns:
    Returns a new DOM document.

### createSvgDocument

    public static Document createSvgDocument(int width,
                                             int height)

  Creates a new SVG document for the given width and height.

### createVmlDocument

    public static Document createVmlDocument()

### createHtmlDocument

    public static Document createHtmlDocument()

  Returns a document with a HTML node containing a HEAD and BODY node.

### createHtmlDocument

    public static String createHtmlDocument(Map<String,Object> style,
                                            String text)

  Returns a new, empty DOM document.

  Returns:
    Returns a new DOM document.

### createHtmlDocument

    public static String createHtmlDocument(Map<String,Object> style,
                                            String text,
                                            double scale)

  Returns a new, empty DOM document.

  Returns:
    Returns a new DOM document.

### createHtmlDocumentObject

    public static HTMLDocument createHtmlDocumentObject(Map<String,Object> style,
                                                        double scale)

  Returns a new, empty DOM document.

  Returns:
    Returns a new DOM document.

### createTable

    public static Element createTable(Document document,
                                      String text,
                                      int x,
                                      int y,
                                      int w,
                                      int h,
                                      double scale,
                                      Map<String,Object> style)

  Creates a table for the given text using the given document to create the DOM nodes. Returns the outermost table node.

### loadImage

    public static Image loadImage(String url)

### loadDocument

    public static Document loadDocument(String uri)

  Returns a new DOM document for the given URI.

  Parameters:
    `uri` - URI to parse into the document.
  Returns:
    Returns a new DOM document for the given URI.

### parseXml

    public static Document parseXml(String xml)

  Returns a new document for the given XML string.

  Parameters:
    `xml` - String that represents the XML data.
  Returns:
    Returns a new XML document.

### eval

    public static Object eval(String expression)

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

### findNode

    public static Node findNode(Node node,
                                String attr,
                                String value)

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

### selectSingleNode

    public static Node selectSingleNode(Document doc,
                                        String expression)

  Returns a single node that matches the given XPath expression.

  Parameters:
    `doc` - Document that contains the nodes.
    `expression` - XPath expression to be matched.
  Returns:
    Returns a single node matching the given expression.

### htmlEntities

    public 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.

### getXml

    public static String getXml(Node node)

  Returns a string that represents the given node.

  Parameters:
    `node` - Node to return the XML for.
  Returns:
    Returns an XML string.

### getPrettyXml

    public static String getPrettyXml(Node node)

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

  Parameters:
    `node` - Node to return the XML for.
  Returns:
    Returns a formatted XML string.

### getPrettyXml

    public static String getPrettyXml(Node node,
                                      String tab,
                                      String indent)

  Returns a pretty-printed XML string for the given node. Note that this string should only be used for humans to read (eg. debug output) but not for further processing as it does not use built-in mechanisms.

  Parameters:
    `node` - Node to return the XML for.
    `tab` - String to be used for indentation of inner nodes.
    `indent` - Current indentation for the node.
  Returns:
    Returns a formatted XML string.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JGraph X 1.4.0.9
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2010 Gaudenz Alder. All rights reserved.