|
JGraph X 1.4.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mxgraph.util.mxUtils
public class mxUtils
Contains various helper methods for use with mxGraph.
Field Summary | |
---|---|
protected static java.awt.Graphics |
fontGraphics
Static Graphics used for Font Metrics. |
Constructor Summary | |
---|---|
mxUtils()
|
Method Summary | |
---|---|
java.lang.String |
addStylename(java.lang.String style,
java.lang.String stylename)
Adds the specified stylename to the given style if it does not already contain the stylename. |
static void |
clearRect(java.awt.Graphics2D g,
java.awt.Rectangle rect,
java.awt.Color background)
Clears the given area of the specified graphics object with the given color or makes the region transparent. |
static boolean |
contains(java.lang.Object[] array,
java.lang.Object obj)
Returns true if the given array contains the given object. |
static java.awt.image.BufferedImage |
createBufferedImage(int w,
int h,
java.awt.Color background)
Creates a buffered image for the given parameters. |
static org.w3c.dom.Document |
createDocument()
Returns a new, empty DOM document. |
static org.w3c.dom.Document |
createHtmlDocument()
Returns a document with a HTML node containing a HEAD and BODY node. |
static java.lang.String |
createHtmlDocument(java.util.Map<java.lang.String,java.lang.Object> style,
java.lang.String text)
Returns a new, empty DOM document. |
static java.lang.String |
createHtmlDocument(java.util.Map<java.lang.String,java.lang.Object> style,
java.lang.String text,
double scale)
Returns a new, empty DOM document. |
static javax.swing.text.html.HTMLDocument |
createHtmlDocumentObject(java.util.Map<java.lang.String,java.lang.Object> style,
double scale)
Returns a new, empty DOM document. |
static org.w3c.dom.Document |
createSvgDocument(int width,
int height)
Creates a new SVG document for the given width and height. |
static org.w3c.dom.Element |
createTable(org.w3c.dom.Document document,
java.lang.String text,
int x,
int y,
int w,
int h,
double scale,
java.util.Map<java.lang.String,java.lang.Object> style)
Creates a table for the given text using the given document to create the DOM nodes. |
static org.w3c.dom.Document |
createVmlDocument()
|
static void |
drawImageClip(java.awt.Graphics g,
java.awt.image.BufferedImage image,
java.awt.image.ImageObserver observer)
Draws the image inside the clip bounds to the given graphics object. |
static java.lang.Object |
eval(java.lang.String expression)
Evaluates a Java expression as a class member using mxCodecRegistry. |
static void |
fillClippedRect(java.awt.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 org.w3c.dom.Node |
findNode(org.w3c.dom.Node node,
java.lang.String attr,
java.lang.String value)
Returns the first node where attr equals value. |
static java.lang.String |
getBodyMarkup(java.lang.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 java.awt.Color |
getColor(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.String key)
Returns the value for key in dictionary as a color or null if no value is defined for the key. |
static java.awt.Color |
getColor(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.String key,
java.awt.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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 java.awt.Font |
getFont(java.util.Map<java.lang.String,java.lang.Object> style)
|
static java.awt.Font |
getFont(java.util.Map<java.lang.String,java.lang.Object> style,
double scale)
|
static java.lang.String |
getHexColorString(java.awt.Color color)
Returns a hex representation for the given color. |
static int |
getInt(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.lang.String label,
java.util.Map<java.lang.String,java.lang.Object> style,
boolean isHtml,
mxPoint offset,
mxRectangle vertexBounds,
double scale)
Returns the paint bounds for the given label. |
static mxRectangle |
getLabelSize(java.lang.String label,
java.util.Map<java.lang.String,java.lang.Object> style,
boolean isHtml,
int width)
Returns the size for the given label. |
static java.lang.String |
getMd5Hash(java.lang.String text)
Returns the Md5 hash for the given text. |
static java.lang.String |
getPrettyXml(org.w3c.dom.Node node)
Returns a pretty-printed XML string for the given node. |
static java.lang.String |
getPrettyXml(org.w3c.dom.Node node,
java.lang.String tab,
java.lang.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,
java.util.Map<java.lang.String,java.lang.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(java.lang.String markup,
java.util.Map<java.lang.String,java.lang.Object> style)
Returns an mxRectangle with the size (width and height in pixels) of the given HTML markup. |
static mxRectangle |
getSizeForString(java.lang.String text,
java.awt.Font font,
int width)
Returns an |
static java.lang.String |
getString(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.String key)
Returns the value for key in dictionary as a string or null if no value is defined for the key. |
static java.lang.String |
getString(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.String key,
java.lang.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 java.lang.String |
getStylename(java.lang.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 java.lang.String[] |
getStylenames(java.lang.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 java.lang.String |
getXml(org.w3c.dom.Node node)
Returns a string that represents the given node. |
static java.lang.String |
hexString(java.awt.Color color)
|
static java.lang.String |
htmlEntities(java.lang.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(java.lang.Object[] array,
java.lang.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(java.lang.String style,
java.lang.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(java.lang.Object value,
java.lang.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(java.lang.Object value,
java.lang.String nodeName,
java.lang.String attributeName,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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(java.util.Map<java.lang.String,java.lang.Object> dict,
java.lang.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 org.w3c.dom.Document |
loadDocument(java.lang.String uri)
Returns a new DOM document for the given URI. |
static java.awt.Image |
loadImage(java.lang.String url)
|
static org.w3c.dom.Document |
parse(java.lang.String xml)
Deprecated. as of 31.08.2010. Use parseXML(String xml) instead |
static java.awt.Color |
parseColor(java.lang.String colorString)
Convert a string representing a 24/32bit hex color value into a Color object. |
static org.w3c.dom.Document |
parseXml(java.lang.String xml)
Returns a new document for the given XML string. |
static java.lang.String |
readFile(java.lang.String filename)
Reads the given filename into a string. |
static java.lang.String |
removeAllStylenames(java.lang.String style)
Removes all stylenames from the given style and returns the updated style. |
java.lang.String |
removeStylename(java.lang.String style,
java.lang.String stylename)
Removes all occurrences of the specified stylename in the given style and returns the updated style. |
static org.w3c.dom.Node |
selectSingleNode(org.w3c.dom.Document doc,
java.lang.String expression)
Returns a single node that matches the given XPath expression. |
static void |
setAntiAlias(java.awt.Graphics2D g,
boolean antiAlias,
boolean textAntiAlias)
|
static void |
setCellStyleFlags(mxIGraphModel model,
java.lang.Object[] cells,
java.lang.String key,
int flag,
java.lang.Boolean value)
Sets or toggles the flag bit for the given key in the cell's styles. |
static void |
setCellStyles(mxIGraphModel model,
java.lang.Object[] cells,
java.lang.String key,
java.lang.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 java.lang.String |
setStyle(java.lang.String style,
java.lang.String key,
java.lang.String value)
Adds or removes the given key, value pair to the style and returns the new style. |
static java.lang.String |
setStyleFlag(java.lang.String style,
java.lang.String key,
int flag,
java.lang.Boolean value)
Sets or removes the given key from the specified style and returns the new style. |
static java.util.Collection<java.lang.Object> |
sortCells(java.util.Collection<java.lang.Object> cells,
boolean ascending)
Sorts the given cells according to the order in the cell hierarchy. |
static java.lang.Object[] |
sortCells(java.lang.Object[] cells,
boolean ascending)
Sorts the given cells according to the order in the cell hierarchy. |
static java.util.List<mxPoint> |
translatePoints(java.util.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 java.lang.String[] |
wordWrap(java.lang.String text,
java.awt.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(java.lang.String contents,
java.lang.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 |
---|
protected static transient java.awt.Graphics fontGraphics
Constructor Detail |
---|
public mxUtils()
Method Detail |
---|
public static mxRectangle getLabelSize(java.lang.String label, java.util.Map<java.lang.String,java.lang.Object> style, boolean isHtml, int width)
public static java.lang.String getBodyMarkup(java.lang.String markup, boolean replaceLinefeeds)
public static mxRectangle getLabelPaintBounds(java.lang.String label, java.util.Map<java.lang.String,java.lang.Object> style, boolean isHtml, mxPoint offset, mxRectangle vertexBounds, double scale)
public static mxRectangle getScaledLabelBounds(double x, double y, mxRectangle size, double outerWidth, double outerHeight, java.util.Map<java.lang.String,java.lang.Object> style, double scale)
public static mxRectangle getSizeForString(java.lang.String text, java.awt.Font font, int width)
text
- String whose size should be returned.font
- Font to be used for the computation.public static java.lang.String[] wordWrap(java.lang.String text, java.awt.FontMetrics metrics, int width)
text
- the text to wrapmetrics
- the font metrics to calculate the text size forwidth
- the width that the text must fit within
public static mxRectangle getSizeForHtml(java.lang.String markup, java.util.Map<java.lang.String,java.lang.Object> style)
markup
- HTML markup whose size should be returned.public static mxRectangle getBoundingBox(mxRectangle rect, double rotation)
public static mxPoint getRotatedPoint(mxPoint pt, double cos, double sin)
public static int findNearestSegment(mxCellState state, double x, double y)
public static mxPoint getRotatedPoint(mxPoint pt, double cos, double sin, mxPoint c)
public static void drawImageClip(java.awt.Graphics g, java.awt.image.BufferedImage image, java.awt.image.ImageObserver observer)
public static void fillClippedRect(java.awt.Graphics g, int x, int y, int width, int height)
public static java.util.List<mxPoint> translatePoints(java.util.List<mxPoint> pts, double dx, double dy)
public static mxPoint intersection(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3)
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.
public static java.lang.Object[] sortCells(java.lang.Object[] cells, boolean ascending)
public static java.util.Collection<java.lang.Object> sortCells(java.util.Collection<java.lang.Object> cells, boolean ascending)
public static boolean contains(java.lang.Object[] array, java.lang.Object obj)
public static int indexOf(java.lang.Object[] array, java.lang.Object obj)
public static java.lang.String getStylename(java.lang.String style)
style
- String of the form stylename[;key=value].
public static java.lang.String[] getStylenames(java.lang.String style)
style
- String of the form stylename[;stylename][;key=value].
public static int indexOfStylename(java.lang.String style, java.lang.String stylename)
public java.lang.String addStylename(java.lang.String style, java.lang.String stylename)
public java.lang.String removeStylename(java.lang.String style, java.lang.String stylename)
public static java.lang.String removeAllStylenames(java.lang.String style)
public static void setCellStyles(mxIGraphModel model, java.lang.Object[] cells, java.lang.String key, java.lang.String value)
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.public static java.lang.String setStyle(java.lang.String style, java.lang.String key, java.lang.String value)
style
- String of the form stylename[;key=value]
.key
- Key of the style to be changed.value
- New value for the given key.
public static void setCellStyleFlags(mxIGraphModel model, java.lang.Object[] cells, java.lang.String key, int flag, java.lang.Boolean value)
mxUtils.setCellStyleFlags(graph.getModel(),
cells,
mxConstants.STYLE_FONTSTYLE,
mxConstants.FONT_BOLD, null);
Toggles the bold font style.
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.public static java.lang.String setStyleFlag(java.lang.String style, java.lang.String key, int flag, java.lang.Boolean value)
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.public static boolean intersectsHotspot(mxCellState state, int x, int y, double hotspot)
public static boolean intersectsHotspot(mxCellState state, int x, int y, double hotspot, int min, int max)
public static boolean isTrue(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key)
dict
- Dictionary that contains the key, value pairs.key
- Key whose value should be returned.
public static boolean isTrue(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, boolean defaultValue)
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.
public static int getInt(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key)
dict
- Dictionary that contains the key, value pairs.key
- Key whose value should be returned.
public static int getInt(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, int defaultValue)
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.
public static float getFloat(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key)
dict
- Dictionary that contains the key, value pairs.key
- Key whose value should be returned.
public static float getFloat(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, float defaultValue)
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.
public static float[] getFloatArray(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, float[] defaultValue)
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.
public static double getDouble(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key)
dict
- Dictionary that contains the key, value pairs.key
- Key whose value should be returned.
public static double getDouble(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, double defaultValue)
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.
public static java.lang.String getString(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key)
dict
- Dictionary that contains the key, value pairs.key
- Key whose value should be returned.
public static java.lang.String getString(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, java.lang.String defaultValue)
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.
public static java.awt.Color getColor(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key)
dict
- Dictionary that contains the key, value pairs.key
- Key whose value should be returned.
public static java.awt.Color getColor(java.util.Map<java.lang.String,java.lang.Object> dict, java.lang.String key, java.awt.Color defaultValue)
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.
public static java.awt.Font getFont(java.util.Map<java.lang.String,java.lang.Object> style)
public static java.awt.Font getFont(java.util.Map<java.lang.String,java.lang.Object> style, double scale)
public static java.lang.String hexString(java.awt.Color color)
public static java.awt.Color parseColor(java.lang.String colorString) throws java.lang.NumberFormatException
colorString
- the 24/32bit hex string value (ARGB)
java.lang.NumberFormatException
- if the specified string cannot be interpreted as a
hexidecimal integerpublic static java.lang.String getHexColorString(java.awt.Color color)
color
- Color to return the hex string for.
public static java.lang.String readFile(java.lang.String filename) throws java.io.IOException
filename
- Name of the file to be read.
java.io.IOException
public static void writeFile(java.lang.String contents, java.lang.String filename) throws java.io.IOException
contents
- String representing the file contents.filename
- Name of the file to be written.
java.io.IOException
public static java.lang.String getMd5Hash(java.lang.String text)
text
- String whose Md5 hash should be returned.
public static boolean isNode(java.lang.Object value, java.lang.String nodeName)
value
- Object that should be examined as a node.nodeName
- String that specifies the node name.
public static boolean isNode(java.lang.Object value, java.lang.String nodeName, java.lang.String attributeName, java.lang.String attributeValue)
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.
public static void setAntiAlias(java.awt.Graphics2D g, boolean antiAlias, boolean textAntiAlias)
g
- antiAlias
- textAntiAlias
- public static void clearRect(java.awt.Graphics2D g, java.awt.Rectangle rect, java.awt.Color background)
public static java.awt.image.BufferedImage createBufferedImage(int w, int h, java.awt.Color background) throws java.lang.OutOfMemoryError
java.lang.OutOfMemoryError
public static org.w3c.dom.Document createDocument()
public static org.w3c.dom.Document createSvgDocument(int width, int height)
public static org.w3c.dom.Document createVmlDocument()
public static org.w3c.dom.Document createHtmlDocument()
public static java.lang.String createHtmlDocument(java.util.Map<java.lang.String,java.lang.Object> style, java.lang.String text)
public static java.lang.String createHtmlDocument(java.util.Map<java.lang.String,java.lang.Object> style, java.lang.String text, double scale)
public static javax.swing.text.html.HTMLDocument createHtmlDocumentObject(java.util.Map<java.lang.String,java.lang.Object> style, double scale)
public static org.w3c.dom.Element createTable(org.w3c.dom.Document document, java.lang.String text, int x, int y, int w, int h, double scale, java.util.Map<java.lang.String,java.lang.Object> style)
public static java.awt.Image loadImage(java.lang.String url)
public static org.w3c.dom.Document loadDocument(java.lang.String uri)
uri
- URI to parse into the document.
public static org.w3c.dom.Document parse(java.lang.String xml)
xml
- String that represents the XML data.
public static org.w3c.dom.Document parseXml(java.lang.String xml)
xml
- String that represents the XML data.
public static java.lang.Object eval(java.lang.String expression)
public static org.w3c.dom.Node findNode(org.w3c.dom.Node node, java.lang.String attr, java.lang.String value)
public static org.w3c.dom.Node selectSingleNode(org.w3c.dom.Document doc, java.lang.String expression)
doc
- Document that contains the nodes.expression
- XPath expression to be matched.
public static java.lang.String htmlEntities(java.lang.String text)
public static java.lang.String getXml(org.w3c.dom.Node node)
node
- Node to return the XML for.
public static java.lang.String getPrettyXml(org.w3c.dom.Node node)
node
- Node to return the XML for.
public static java.lang.String getPrettyXml(org.w3c.dom.Node node, java.lang.String tab, java.lang.String indent)
node
- Node to return the XML for.tab
- String to be used for indentation of inner nodes.indent
- Current indentation for the node.
|
JGraph X 1.4.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |