public org.jgraph.graph.CellView createView(GraphModel model, Object cell) {

    org.jgraph.graph.CellView view = null;
    if (model.isPort(cell)) view = new PortView(cell);
    else if (model.isEdge(cell)) view = createEdgeView(cell);
    else view = createVertexView(cell);
    return view;
  }
  /**
   * Converts a JGraph cell into an mxGraph with the specified mxGraph parent
   *
   * @param cell the JGraph cell
   * @param parent the mxGraph parent
   */
  protected void insertCell(Object cell, Object parent) {
    Object mxCell = null;
    GraphModel jModel = jgraph.getModel();
    Object value = jModel.getValue(cell);

    if (jModel.isEdge(cell)) {
      mxCell = graph.insertEdge(parent, null, value, null, null);

      if (edges == null) {
        edges = new Hashtable<Object, Object>();
      }

      edges.put(cell, mxCell);
    } else if (jModel.isPort(cell)) {
      // TODO
    } else {
      // A vertex
      Rectangle2D bounds = null;

      if (facade != null) {
        bounds = facade.getBounds(cell);
      } else {
        GraphLayoutCache cache = jgraph.getGraphLayoutCache();
        CellView cellView = cache.getMapping(cell, false);
        bounds = cellView.getBounds();
      }

      if (bounds != null) {
        mxCell =
            graph.insertVertex(
                parent,
                null,
                value,
                bounds.getX(),
                bounds.getY(),
                bounds.getWidth(),
                bounds.getHeight());
      } else {
        mxCell = graph.insertVertex(parent, null, value, 100, 100, 80, 30);
      }

      if (vertices == null) {
        vertices = new Hashtable<Object, Object>();
      }

      vertices.put(cell, mxCell);
    }

    // Process all the children of this cell
    int childCount = jModel.getChildCount(cell);

    if (mxCell != null) {
      for (int i = 0; i < childCount; i++) {
        Object childCell = jModel.getChild(cell, i);

        if (cell != null) {
          insertCell(childCell, mxCell);
        }
      }
    }
  }