Package com.mxgraph.model

Examples of com.mxgraph.model.mxGraphModel$Filter


  /**
   * Constructs a new model codec.
   */
  public mxModelCodec()
  {
    this(new mxGraphModel());
  }
View Full Code Here


  protected void encodeObject(mxCodec enc, Object obj, Node node)
  {
    if (obj instanceof mxGraphModel)
    {
      Node rootNode = enc.document.createElement("root");
      mxGraphModel model = (mxGraphModel) obj;
      enc.encodeCell((mxICell) model.getRoot(), rootNode, true);
      node.appendChild(rootNode);
    }
  }
View Full Code Here

  public Node beforeDecode(mxCodec dec, Node node, Object into)
  {
    if (node instanceof Element)
    {
      Element elt = (Element) node;
      mxGraphModel model = null;

      if (into instanceof mxGraphModel)
      {
        model = (mxGraphModel) into;
      }
      else
      {
        model = new mxGraphModel();
      }

      // Reads the cells into the graph model. All cells
      // are children of the root element in the node.
      Node root = elt.getElementsByTagName("root").item(0);
      mxICell rootCell = null;

      if (root != null)
      {
        Node tmp = root.getFirstChild();

        while (tmp != null)
        {
          mxICell cell = dec.decodeCell(tmp, true);

          if (cell != null && cell.getParent() == null)
          {
            rootCell = cell;
          }

          tmp = tmp.getNextSibling();
        }

        root.getParentNode().removeChild(root);
      }

      // Sets the root on the model if one has been decoded
      if (rootCell != null)
      {
        model.setRoot(rootCell);
      }
    }

    return node;
  }
View Full Code Here

   * @param model Model that contains the graph data
   */
  public mxGraph(mxIGraphModel model, mxStylesheet stylesheet)
  {
    selectionModel = createSelectionModel();
    setModel((model != null) ? model : new mxGraphModel());
    setStylesheet((stylesheet != null) ? stylesheet : createStylesheet());
    setView(createGraphView());
  }
View Full Code Here

  /**
   * Constructs a new model codec.
   */
  public mxModelCodec()
  {
    this(new mxGraphModel());
  }
View Full Code Here

  {
    Node node = null;

    if (obj instanceof mxGraphModel)
    {
      mxGraphModel model = (mxGraphModel) obj;

      node = enc.document.createElement(getName());
      Node rootNode = enc.document.createElement("root");

      enc.encodeCell((mxICell) model.getRoot(), rootNode, true);
      node.appendChild(rootNode);
    }

    return node;
  }
View Full Code Here

  public Node beforeDecode(mxCodec dec, Node node, Object into)
  {
    if (node instanceof Element)
    {
      Element elt = (Element) node;
      mxGraphModel model = null;

      if (into instanceof mxGraphModel)
      {
        model = (mxGraphModel) into;
      }
      else
      {
        model = new mxGraphModel();
      }

      // Reads the cells into the graph model. All cells
      // are children of the root element in the node.
      Node root = elt.getElementsByTagName("root").item(0);
      mxICell rootCell = null;

      if (root != null)
      {
        Node tmp = root.getFirstChild();

        while (tmp != null)
        {
          mxICell cell = dec.decodeCell(tmp, true);

          if (cell != null && cell.getParent() == null)
          {
            rootCell = cell;
          }

          tmp = tmp.getNextSibling();
        }

        root.getParentNode().removeChild(root);
      }

      // Sets the root on the model if one has been decoded
      if (rootCell != null)
      {
        model.setRoot(rootCell);
      }
    }

    return node;
  }
View Full Code Here

TOP

Related Classes of com.mxgraph.model.mxGraphModel$Filter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.