/**
  * Override <mxObjectCodec.decode>.
  */
 function decode($dec, $node, $into = null)
 {
     $id = $node->getAttribute("id");
     $obj = in_array($id, $dec->objects) ? $dec->objects[$id] : null;
     if (!isset($obj)) {
         if (isset($into)) {
             $obj = $into;
         } else {
             $tmp = get_class($this->template);
             $obj = new $tmp();
         }
         if (isset($id)) {
             $dec->putObject($id, $obj);
         }
     }
     $node = $node->firstChild;
     while (isset($node)) {
         if (!$this->processInclude($dec, $node, $obj) && $node->nodeName == "add") {
             $as = $node->getAttribute("as");
             if (strlen($as) > 0) {
                 $extend = $node->getAttribute("extend");
                 $style = strlen($extend) > 0 && isset($obj->styles[$extend]) ? array_slice($obj->styles[$extend], 0) : null;
                 if (!isset($style)) {
                     $style = array();
                 }
                 $entry = $node->firstChild;
                 while (isset($entry)) {
                     if ($entry->nodeType == XML_ELEMENT_NODE) {
                         $key = $entry->getAttribute("as");
                         if ($entry->nodeName == "add") {
                             $text = $entry->textContent;
                             $value = null;
                             if (isset($text) && strlen($text) > 0) {
                                 $value = mxUtils::evaluate($text);
                             } else {
                                 $value = $entry->getAttribute("value");
                             }
                             if ($value != null) {
                                 $style[$key] = $value;
                             }
                         } else {
                             if ($entry->nodeName == "remove") {
                                 unset($style[$key]);
                             }
                         }
                     }
                     $entry = $entry->nextSibling;
                 }
                 $obj->putCellStyle($as, $style);
             }
         }
         $node = $node->nextSibling;
     }
     return $obj;
 }
Пример #2
0
 /**
  * Function: getPerimeterFunction
  * 
  * Returns the perimeter function for the given state.
  */
 function getPerimeterFunction($state)
 {
     $perimeter = mxUtils::getValue($state->style, mxConstants::$STYLE_PERIMETER);
     // Converts string values to objects
     if (is_string($perimeter)) {
         $tmp = mxStyleRegistry::getValue($perimeter);
         if ($tmp == null && strpos($perimeter, ".") !== false) {
             $tmp = mxUtils::evaluate($perimeter);
         }
         $perimeter = $tmp;
     }
     if ($perimeter instanceof mxPerimeterFunction) {
         return $perimeter;
     }
     return null;
 }