mxGraph
|
XML codec for .NET object graphs. In order to resolve forward references when reading files the XML document that contains the data must be passed to the constructor. More...
Public Member Functions | |
mxCodec () | |
Constructs an XML encoder/decoder with a new owner document. More... | |
mxCodec (XmlDocument document) | |
Constructs an XML encoder/decoder for the specified owner document. The document is required to resolve forward ID references. This means if you parse a graphmodel that is represented in XML you must also pass the document that contains the XML to the constructor, otherwise forward references will not be resolved. More... | |
Object | PutObject (string id, Object obj) |
Assoiates the given object with the given ID. More... | |
Object | GetObject (string id) |
Returns the decoded object for the element with the specified ID in document. If the object is not known then lookup is used to find an object. If no object is found, then the element with the respective ID from the document is parsed using decode. More... | |
Object | Lookup (string id) |
Hook for subclassers to implement a custom lookup mechanism for cell IDs. This implementation always returns null. More... | |
XmlNode | GetElementById (string id) |
Returns the element with the given ID from the document. More... | |
XmlNode | GetElementById (string id, string attributeName) |
Returns the element with the given ID from document. The optional attr argument specifies the name of the ID attribute. Default is id. The XPath expression used to find the element is //*[@id='arg'] where id is the name of the ID attribute (attributeName) and arg is the given id. More... | |
string | GetId (Object obj) |
Returns the ID of the specified object. This implementation calls reference first and if that returns null handles the object as an mxCell by returning their IDs using mxCell.getId. If no ID exists for the given cell, then an on-the-fly ID is generated using mxCellPath.create. More... | |
string | Reference (Object obj) |
Hook for subclassers to implement a custom method for retrieving IDs from objects. This implementation always returns null. More... | |
XmlNode | Encode (Object obj) |
Encodes the specified object and returns the resulting XML node. More... | |
Object | Decode (XmlNode node) |
Decodes the given XML node using decode(XmlNode, Object). More... | |
Object | Decode (XmlNode node, Object into) |
Decodes the given XML node. The optional "into" argument specifies an existing object to be used. If no object is given, then a new instance is created using the constructor from the codec. The function returns the passed in object or the new instance if no object was given. More... | |
void | EncodeCell (mxICell cell, XmlNode node, bool includeChildren) |
Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg. mxModelCodec, mxChildChangeCodec and mxRootChangeCodec). This implementation writes the given cell and its children as a (flat) sequence into the given node. The children are not encoded if the optional includeChildren is false. The function is in charge of adding the result into the given node and has no return value. More... | |
mxICell | DecodeCell (XmlNode node, bool restoreStructures) |
Decodes cells that have been encoded using inversion, ie. where the user object is the enclosing node in the XML, and restores the group and graph structure in the cells. Returns a new mxCell instance that represents the given node. More... | |
void | InsertIntoGraph (mxICell cell) |
Inserts the given cell into its parent and terminal cells. More... | |
Static Public Member Functions | |
static void | SetAttribute (XmlNode node, string attribute, Object value) |
Sets the attribute on the specified node to value. This is a helper method that makes sure the attribute and value arguments are not null. More... | |
Protected Attributes | |
XmlDocument | document |
Holds the owner document of the codec. More... | |
Dictionary< string, object > | objects = new Dictionary<string, Object>() |
Maps from IDs to objects. More... | |
bool | encodeDefaults = false |
Specifies if default values should be encoded. Default is false. More... | |
Properties | |
XmlDocument | Document [get, set] |
Sets or returns the owner document of the codec. More... | |
bool | IsEncodeDefaults [get, set] |
Sets or returns if default values of member variables should be encoded. More... | |
Dictionary< string, object > | Objects [get] |
Returns the object lookup table. More... | |
XML codec for .NET object graphs. In order to resolve forward references when reading files the XML document that contains the data must be passed to the constructor.
|
inline |
Constructs an XML encoder/decoder with a new owner document.
|
inline |
Constructs an XML encoder/decoder for the specified owner document. The document is required to resolve forward ID references. This means if you parse a graphmodel that is represented in XML you must also pass the document that contains the XML to the constructor, otherwise forward references will not be resolved.
document | Optional XML document that contains the data. If no document is specified then a new document is created using mxUtils.createDocument |
References com.mxgraph.mxUtils.CreateDocument().
|
inline |
Decodes the given XML node using decode(XmlNode, Object).
node | XML node to be decoded. |
Referenced by com.mxgraph.mxObjectCodec.DecodeChild(), and com.mxgraph.mxObjectCodec.ProcessInclude().
|
inline |
Decodes the given XML node. The optional "into" argument specifies an existing object to be used. If no object is given, then a new instance is created using the constructor from the codec. The function returns the passed in object or the new instance if no object was given.
node | XML node to be decoded. |
into | Optional object to be decodec into. |
References com.mxgraph.mxObjectCodec.Decode(), and com.mxgraph.mxCodecRegistry.GetCodec().
|
inline |
Decodes cells that have been encoded using inversion, ie. where the user object is the enclosing node in the XML, and restores the group and graph structure in the cells. Returns a new mxCell instance that represents the given node.
node | XML node that contains the cell data. |
restoreStructures | Boolean indicating whether the graph structure should be restored by calling insert and insertEdge on the parent and terminals, respectively. |
References com.mxgraph.mxObjectCodec.Decode(), and com.mxgraph.mxCodecRegistry.GetCodec().
Referenced by com.mxgraph.mxModelCodec.BeforeDecode().
|
inline |
Encodes the specified object and returns the resulting XML node.
obj | Object to be encoded. |
References com.mxgraph.mxObjectCodec.Encode(), com.mxgraph.mxCodecRegistry.GetCodec(), and com.mxgraph.mxCodecRegistry.GetName().
Referenced by com.mxgraph.mxObjectCodec.WriteComplexAttribute().
|
inline |
Encoding of cell hierarchies is built-into the core, but is a higher-level function that needs to be explicitely used by the respective object encoders (eg. mxModelCodec, mxChildChangeCodec and mxRootChangeCodec). This implementation writes the given cell and its children as a (flat) sequence into the given node. The children are not encoded if the optional includeChildren is false. The function is in charge of adding the result into the given node and has no return value.
cell | mxCell to be encoded. |
node | Parent XML node to add the encoded cell into. |
includeChildren | Boolean indicating if the method should include all descendents |
References com.mxgraph.mxICell.ChildCount(), and com.mxgraph.mxICell.GetChildAt().
Referenced by com.mxgraph.mxModelCodec.EncodeObject().
|
inline |
Returns the element with the given ID from the document.
id | ID of the element to be returned. |
|
inline |
Returns the element with the given ID from document. The optional attr argument specifies the name of the ID attribute. Default is id. The XPath expression used to find the element is //*[@id='arg'] where id is the name of the ID attribute (attributeName) and arg is the given id.
id | ID of the element to be returned. |
attributeName | Optional string for the attributename. Default is id. |
References com.mxgraph.mxUtils.SelectSingleNode().
|
inline |
Returns the ID of the specified object. This implementation calls reference first and if that returns null handles the object as an mxCell by returning their IDs using mxCell.getId. If no ID exists for the given cell, then an on-the-fly ID is generated using mxCellPath.create.
obj | Object to return the ID for. |
References com.mxgraph.mxCellPath.Create().
Referenced by com.mxgraph.mxObjectCodec.EncodeObject(), and com.mxgraph.mxObjectCodec.EncodeValue().
|
inline |
Returns the decoded object for the element with the specified ID in document. If the object is not known then lookup is used to find an object. If no object is found, then the element with the respective ID from the document is parsed using decode.
id | ID of the object to be returned. |
Referenced by com.mxgraph.mxObjectCodec.DecodeAttribute().
|
inline |
Inserts the given cell into its parent and terminal cells.
cell |
References com.mxgraph.mxICell.GetTerminal(), com.mxgraph.mxICell.Insert(), com.mxgraph.mxICell.InsertEdge(), com.mxgraph.mxICell.Parent, and com.mxgraph.mxICell.SetTerminal().
|
inline |
Hook for subclassers to implement a custom lookup mechanism for cell IDs. This implementation always returns null.
id | ID of the object to be returned. |
|
inline |
Assoiates the given object with the given ID.
id | ID for the object to be associated with. |
obj | Object to be associated with the ID. |
Referenced by com.mxgraph.mxStylesheetCodec.Decode(), and com.mxgraph.mxObjectCodec.Decode().
|
inline |
Hook for subclassers to implement a custom method for retrieving IDs from objects. This implementation always returns null.
obj | Object whose ID should be returned. |
|
inlinestatic |
Sets the attribute on the specified node to value. This is a helper method that makes sure the attribute and value arguments are not null.
node | XML node to set the attribute for. |
attribute | Attributename to be set. |
value | New value of the attribute. |
Referenced by com.mxgraph.mxObjectCodec.EncodeObject(), com.mxgraph.mxObjectCodec.WriteComplexAttribute(), and com.mxgraph.mxObjectCodec.WritePrimitiveAttribute().
|
protected |
Holds the owner document of the codec.
|
protected |
Specifies if default values should be encoded. Default is false.
|
protected |
Maps from IDs to objects.
|
getset |
Sets or returns the owner document of the codec.
Referenced by com.mxgraph.mxStylesheetCodec.Encode(), com.mxgraph.mxObjectCodec.Encode(), com.mxgraph.mxModelCodec.EncodeObject(), and com.mxgraph.mxObjectCodec.WritePrimitiveAttribute().
|
getset |
Sets or returns if default values of member variables should be encoded.
Referenced by com.mxgraph.mxObjectCodec.EncodeValue().
|
get |
Returns the object lookup table.
Referenced by com.mxgraph.mxStylesheetCodec.Decode(), and com.mxgraph.mxObjectCodec.Decode().