Package com.mxgraph.model

Examples of com.mxgraph.model.mxCell


    currentGraph.getModel().beginUpdate();
    for (Object cell : cells) {
      if (((mxCell) cell).isVertex()) {
        for (StorableVertex v : vertexes) {
          if (((mxCell) cell).getId().equals("v" + v.getStorableId())) {
            mxCell c = (mxCell) cell;

            mxCell c2 = (mxCell) currentGraph.insertVertex(parent, c.getId(), c.getValue(), c.getGeometry().getX(), c
                .getGeometry().getY(), c.getGeometry().getWidth(), c.getGeometry().getHeight(), c.getStyle());

            id2vert.put(c.getId(), c2);
            if (view.subgraphsid.get(c) != null) {
              this.subgraphsid.put((mxCell) c2, view.subgraphsid.get(c));
            }
            HashMap<StorableAttribute, Boolean> m = view.vertexAttributes.get(c);
            HashMap<StorableAttribute, Boolean> m2 = new HashMap<StorableAttribute, Boolean>();
            for (StorableAttribute s : m.keySet()) {
              m2.put(s, m.get(s));
            }
            vertexAttributes.put(c2, m2);
            break;
          }

        }
      }
    }

    cells = view.currentGraph.getAllEdges(cells);
    for (StorableEdge edge : this.subGraph.getEdges()) {
      for (Object cell : cells) {
        mxCell c = (mxCell) cell;
        mxCell source = (mxCell) c.getSource();
        mxCell target = (mxCell) c.getTarget();
        if (source == null || target == null)
          continue;
        if (!source.getId().equals("v" + edge.getStorableSource().getStorableId())
            || !target.getId().equals("v" + edge.getStorableTarget().getStorableId()))
          continue;
        Object source2 = id2vert.get(source.getId());
        Object target2 = id2vert.get(target.getId());
        if (source2 != null && target2 != null) {
          mxCell c2 = (mxCell) currentGraph.insertEdge(parent, c.getId(), c.getValue(), source2, target2, c.getStyle());
          c2.setGeometry(c.getGeometry());
          HashMap<StorableAttribute, Boolean> m = view.edgeAttributes.get(c);
          HashMap<StorableAttribute, Boolean> m2 = new HashMap<StorableAttribute, Boolean>();
          for (StorableAttribute s : m.keySet()) {
            m2.put(s, m.get(s));
          }
View Full Code Here


    paralLay.execute(currentGraph.getDefaultParent());
    // sometimes layout can put vertex out of minimap, that should fix it
    double x = 0, y = 0;
    boolean init = false;
    for (Object o : currentGraph.getChildCells(currentGraph.getDefaultParent())) {
      mxCell cell = (mxCell) o;
      if (cell.isVertex()) {
        if (cell.getGeometry().getX() < x || !init)
          x = cell.getGeometry().getX();
        if (cell.getGeometry().getY() < y || !init)
          y = cell.getGeometry().getY();
      } else if (cell.getGeometry().getPoints() != null)
        for (mxPoint point : cell.getGeometry().getPoints()) {
          if (point.getX() < x || !init)
            x = point.getX();
          if (point.getY() < y || !init)
            y = point.getY();
        }
View Full Code Here

    ArrayList<Object> visiblecells = new ArrayList<Object>();
    ArrayList<Object> invisiblecells = new ArrayList<Object>();
    for (Object cell : cells) {
      if (cell instanceof mxCell) {
        boolean inv = false;
        mxCell c = (mxCell) cell;
        for (StorableEdge e : subGraph.getEdges()) {
          if (c.getId().equals("e" + e.getStorableId()) && edgeIds.contains(Integer.valueOf(e.getStorableId()))) {
            invisiblecells.add(c);
            inv = true;
            break;
          }
        }
View Full Code Here

    ArrayList<Object> visiblecells = new ArrayList<Object>();
    ArrayList<Object> invisiblecells = new ArrayList<Object>();
    for (Object cell : cells) {
      if (cell instanceof mxCell) {
        boolean inv = false;
        mxCell c = (mxCell) cell;
        for (StorableVertex v : subGraph.getVertices()) {
          if (c.getId().equals("v" + v.getStorableId()) && vertexIds.contains(v.getStorableId())) {
            invisiblecells.add(c);
            inv = true;
            break;
          }
        }
View Full Code Here

      VisualGraph.windowMessage.infoMessage("Cicle was not found with vertex " + vertex.getId(), "Cicle messsage");
    }
  }

  public void showCriticalPath(final StorableVertex source, final StorableVertex target, final boolean maximum, final String attrName) {
    mxCell from = null;
    mxCell to = null;
    Object parent = currentGraph.getDefaultParent();
    Object[] cells = currentGraph.getChildVertices(parent);
    for (Object c : cells) {
      if (c instanceof mxCell) {
        mxCell cell = (mxCell) c;
        if (cell.getId().equals("v" + source.getStorableId())) {
          from = cell;
        }

        if (cell.getId().equals("v" + target.getStorableId())) {
          to = cell;
        }
      }

    }
View Full Code Here

  /**
   * Constructs a new cell codec.
   */
  public mxCellCodec()
  {
    this(new mxCell(), null, new String[] { "parent", "source", "target" },
        null);
  }
View Full Code Here

   */
  public Node afterEncode(mxCodec enc, Object obj, Node node)
  {
    if (obj instanceof mxCell)
    {
      mxCell cell = (mxCell) obj;

      if (cell.getValue() instanceof Node)
      {
        // Wraps the graphical annotation up in the
        // user object (inversion) by putting the
        // result of the default encoding into
        // a clone of the user object (node type 1)
        // and returning this cloned user object.
        Element tmp = (Element) node;
        node = enc.getDocument().importNode((Node) cell.getValue(),
            true);
        node.appendChild(tmp);

        // Moves the id attribute to the outermost
        // XML node, namely the node which denotes
View Full Code Here

  {
    Element inner = (Element) node;

    if (obj instanceof mxCell)
    {
      mxCell cell = (mxCell) obj;
      String classname = getName();

      if (!node.getNodeName().equals(classname))
      {
        // Passes the inner graphical annotation node to the
        // object codec for further processing of the cell.
        Node tmp = inner.getElementsByTagName(classname).item(0);

        if (tmp != null && tmp.getParentNode() == node)
        {
          inner = (Element) tmp;

          // Removes annotation and whitespace from node
          Node tmp2 = tmp.getPreviousSibling();

          while (tmp2 != null && tmp2.getNodeType() == Node.TEXT_NODE)
          {
            Node tmp3 = tmp2.getPreviousSibling();

            if (tmp2.getTextContent().trim().length() == 0)
            {
              tmp2.getParentNode().removeChild(tmp2);
            }

            tmp2 = tmp3;
          }

          // Removes more whitespace
          tmp2 = tmp.getNextSibling();

          while (tmp2 != null && tmp2.getNodeType() == Node.TEXT_NODE)
          {
            Node tmp3 = tmp2.getPreviousSibling();

            if (tmp2.getTextContent().trim().length() == 0)
            {
              tmp2.getParentNode().removeChild(tmp2);
            }

            tmp2 = tmp3;
          }

          tmp.getParentNode().removeChild(tmp);
        }
        else
        {
          inner = null;
        }

        // Creates the user object out of the XML node
        Element value = (Element) node.cloneNode(true);
        cell.setValue(value);
        String id = value.getAttribute("id");

        if (id != null)
        {
          cell.setId(id);
          value.removeAttribute("id");
        }
      }
      else
      {
        cell.setId(((Element) node).getAttribute("id"));
      }

      // Preprocesses and removes all Id-references
      // in order to use the correct encoder (this)
      // for the known references to cells (all).
View Full Code Here

    ArrayList<Object> selection = new ArrayList<Object>();
    Object parent = currentGraph.getDefaultParent();
    if (lvsids != null) {
      for (Object ob : currentGraph.getChildVertices(parent)) {
        if (ob instanceof mxCell) {
          mxCell cell = (mxCell) ob;
          int sid = Integer.parseInt(cell.getId().substring(1));
          for (Integer i : lvsids) {
            if (i.equals(sid)) {
              selection.add(cell);
              break;
            }
          }
        }
      }
    }
    if (lesids != null) {
      for (Object ob : currentGraph.getChildEdges(parent)) {
        if (ob instanceof mxCell) {
          mxCell cell = (mxCell) ob;
          int sid = Integer.parseInt(cell.getId().substring(1));
          for (Integer i : lesids) {
            if (i.equals(sid)) {
              selection.add(cell);
              break;
            }
View Full Code Here

    }
    this.title = "Unknown";
  }

  private ArrayList<Object> findPath(final StorableVertex source, final StorableVertex target) {
    mxCell from = null;
    mxCell to = null;
    Object parent = currentGraph.getDefaultParent();
    Object[] cells = currentGraph.getChildVertices(parent);
    for (Object c : cells) {
      if (c instanceof mxCell) {
        mxCell cell = (mxCell) c;
        if (cell.getId().equals("v" + source.getStorableId())) {
          from = cell;
        }

        if (cell.getId().equals("v" + target.getStorableId())) {
          to = cell;
        }
      }

    }
View Full Code Here

TOP

Related Classes of com.mxgraph.model.mxCell

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.