示例#1
0
 /**
  * Function: setCellStyleFlags
  * 
  * Sets or toggles the flag bit for the given key in the cell's styles.
  * If value is null then the flag is toggled.
  * 
  * Example:
  * 
  * (code)
  * var cells = graph.getSelectionCells();
  * mxUtils.setCellStyleFlags(graph.model,
  * 			cells,
  * 			mxConstants.STYLE_FONTSTYLE,
  * 			mxConstants.FONT_BOLD);
  * (end)
  * 
  * Toggles the bold font style.
  * 
  * Parameters:
  * 
  * model - <mxGraphModel> that contains the cells.
  * cells - Array of <mxCells> 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 function setCellStyleFlags($model, $cells, $key, $flag, $value)
 {
     if ($cells != null && sizeof($cells) > 0) {
         $model->beginUpdate();
         try {
             for ($i = 0; $i < sizeof($cells); $i++) {
                 if (isset($cells[$i])) {
                     $style = mxUtils::setStyleFlag($model->getStyle($cells[$i]), $key, $flag, $value);
                     $model->setStyle($cells[$i], $style);
                 }
             }
         } catch (Exception $e) {
             $model->endUpdate();
             throw $e;
         }
         $model->endUpdate();
     }
 }