Class mxModelCodec

java.lang.Object
com.mxgraph.io.mxObjectCodec
com.mxgraph.io.mxModelCodec

public class mxModelCodec extends mxObjectCodec
Codec for mxGraphModels. This class is created and registered dynamically at load time and used implicitly via mxCodec and the mxCodecRegistry.
  • Constructor Details

    • mxModelCodec

      public mxModelCodec()
      Constructs a new model codec.
    • mxModelCodec

      public mxModelCodec(Object template)
      Constructs a new model codec for the given template.
    • mxModelCodec

      public mxModelCodec(Object template, String[] exclude, String[] idrefs, Map<String,String> mapping)
      Constructs a new model codec for the given arguments.
  • Method Details

    • encodeObject

      protected void encodeObject(mxCodec enc, Object obj, Node node)
      Encodes the given mxGraphModel by writing a (flat) XML sequence of cell nodes as produced by the mxCellCodec. The sequence is wrapped-up in a node with the name root.
      Overrides:
      encodeObject in class mxObjectCodec
      Parameters:
      enc - Codec that controls the encoding process.
      obj - Object to be encoded.
      node - XML node that contains the encoded object.
    • beforeDecode

      public Node beforeDecode(mxCodec dec, Node node, Object into)
      Reads the cells into the graph model. All cells are children of the root element in the node.
      Overrides:
      beforeDecode in class mxObjectCodec
      Parameters:
      dec - Codec that controls the decoding process.
      node - XML node to be decoded.
      into - Object to encode the node into.
      Returns:
      Returns the node used for the default decoding.