JGraph X 1.9.2.5


com.mxgraph.util
Class mxStyleUtils

java.lang.Object
  extended by com.mxgraph.util.mxStyleUtils

public class mxStyleUtils
extends java.lang.Object

Contains various style helper methods for use with mxGraph.


Constructor Summary
mxStyleUtils()
           
 
Method Summary
static 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 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 int indexOfStylename(java.lang.String style, java.lang.String stylename)
          Returns the index of the given stylename in the given style.
static java.lang.String removeAllStylenames(java.lang.String style)
          Removes all stylenames from the given style and returns the updated style.
static 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

mxStyleUtils

public mxStyleUtils()
Method Detail

getStylename

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

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

getStylenames

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

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

indexOfStylename

public static int indexOfStylename(java.lang.String style,
                                   java.lang.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 static 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.


removeStylename

public static 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. Trailing semicolons are preserved.


removeAllStylenames

public static java.lang.String removeAllStylenames(java.lang.String style)
Removes all stylenames from the given style and returns the updated style.


setCellStyles

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

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

JGraph X 1.9.2.5


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