mxGraph 1.10.1.0


com.mxgraph.util
Class mxStyleUtils

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

public class mxStyleUtils
extends Object

Contains various style helper methods for use with mxGraph.


Constructor Summary
mxStyleUtils()
           
 
Method Summary
static String addStylename(String style, String stylename)
          Adds the specified stylename to the given style if it does not already contain the stylename.
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.
static String removeAllStylenames(String style)
          Removes all stylenames from the given style and returns the updated style.
static String removeStylename(String style, String stylename)
          Removes all occurrences of the specified stylename in the given style and returns the updated 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.
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.
 
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 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 static String addStylename(String style,
                                  String stylename)
Adds the specified stylename to the given style if it does not already contain the stylename.


removeStylename

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

mxGraph 1.10.1.0


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.