Пример #1
0
 /**
  * Function: getCodec
  *
  * Returns a codec that handles objects that are constructed
  * using the given ctor.
  *
  * Parameters:
  *
  * ctor - JavaScript constructor function. 
  */
 static function getCodec($name)
 {
     $codec = null;
     if (isset($name)) {
         if (isset(mxCodecRegistry::$aliases[$name])) {
             $tmp = mxCodecRegistry::$aliases[$name];
             if (strlen($tmp) > 0) {
                 $name = $tmp;
             }
         }
         $codec = isset(mxCodecRegistry::$codecs[$name]) ? mxCodecRegistry::$codecs[$name] : null;
         // Registers a new default codec for the given constructor
         // if no codec has been previously defined.
         if (!isset($codec)) {
             try {
                 $obj = mxCodecRegistry::getInstanceForName($name);
                 if (isset($obj)) {
                     $codec = new mxObjectCodec($obj);
                     mxCodecRegistry::register($codec);
                 }
             } catch (Exception $e) {
                 // ignore
             }
         }
     }
     return $codec;
 }
                        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;
    }
}
mxCodecRegistry::register(new mxStylesheetCodec(new mxStylesheet()));
Пример #3
0
     * Parameters:
     *
     * dec - <mxCodec> that controls the decoding process.
     * node - XML node to be decoded.
     * obj - Object to encode the node into.
     */
    function beforeDecode($dec, $node, &$obj)
    {
        return $node;
    }
    /**
     * Function: afterDecode
     *
     * Hook for subclassers to post-process the object after
     * decoding. This implementation returns the given object
     * without any changes. The return value of this method
     * is returned to the decoder from <decode>.
     *
     * Parameters:
     *
     * enc - <mxCodec> that controls the encoding process.
     * node - XML node to be decoded.
     * obj - Object that represents the default decoding.
     */
    function afterDecode($dec, $node, &$obj)
    {
        return $obj;
    }
}
mxCodecRegistry::register(new mxObjectCodec(array()));
Пример #4
0
     */
    function decodeChild($dec, $child, $obj)
    {
        if ($child->nodeName == "root") {
            $this->decodeRoot($dec, $child, $obj);
        } else {
            parent::decodeChild($dec, $child, $obj);
        }
    }
    /**
     * Override <mxObjectCodec.decodeRoot>.
     */
    function decodeRoot($dec, $root, $model)
    {
        $rootCell = null;
        $tmp = $root->firstChild;
        while ($tmp != null) {
            $cell = $dec->decodeCell($tmp);
            if ($cell != null && $cell->getParent() == null) {
                $rootCell = $cell;
            }
            $tmp = $tmp->nextSibling;
        }
        // Sets the root on the model if one has been decoded
        if ($rootCell != null) {
            $model->setRoot($rootCell);
        }
    }
}
mxCodecRegistry::register(new mxModelCodec(new mxGraphModel()));
Пример #5
0
        // for the known references to cells (all).
        if (isset($inner)) {
            for ($i = 0; $i < sizeof($this->idrefs); $i++) {
                $attr = $this->idrefs[$i];
                $ref = $inner->getAttribute($attr);
                if (strlen($ref) > 0) {
                    $inner->removeAttribute($attr);
                    $object = isset($dec->objects[$ref]) ? $dec->objects[$ref] : null;
                    if (!isset($object)) {
                        $object = $dec->lookup($ref);
                    }
                    if (!isset($object)) {
                        // Needs to decode forward reference
                        $element = $dec->getElementById($ref);
                        if (isset($element)) {
                            $decoder = mxCodecRegistry::$codecs[$element->nodeName];
                            if (!isset($decoder)) {
                                $decoder = $this;
                            }
                            $object = $decoder->decode($dec, $element);
                        }
                    }
                    $obj->{$attr} = $object;
                }
            }
        }
        return $inner;
    }
}
mxCodecRegistry::register(new mxCellCodec(new mxCell()));