Package com.mxgraph.io.vdx

Examples of com.mxgraph.io.vdx.PageShapeIDKey


    mxCell edge = null;

    //Retrieve edge Shape and Parent
    String shapeConnect = connect.getAttribute(mxVdxConstants.FROM_SHEET);

    mxVdxShape edgeShape = edgeShapeMap.get(new PageShapeIDKey(pageNumber,
        shapeConnect));
    edgeShapeMap.remove(new PageShapeIDKey(pageNumber, shapeConnect));

    if (edgeShape != null)
    {
      Object parent = parentsMap.get(new PageShapeIDKey(pageNumber,
          edgeShape.getId()));

      //Get Parent Height
      double parentHeight = pageHeight;

      mxCell parentCell = (mxCell) parent;

      if (parentCell != null)
      {
        mxGeometry parentGeometry = parentCell.getGeometry();

        if (parentGeometry != null)
        {
          parentHeight = parentGeometry.getHeight();
          parentHeight += pageHeight - actualPageHeight;
        }
      }

      //Get beginXY and endXY coordinates.
      mxPoint beginXY = edgeShape.getBeginXY(parentHeight);
      beginXY = calculateAbsolutePoint((mxCell) parent, graph, beginXY);

      mxPoint endXY = edgeShape.getEndXY(parentHeight);
      endXY = calculateAbsolutePoint((mxCell) parent, graph, endXY);

      //Declare variables.
      mxCell source = null;
      mxCell target = null;
      mxPoint fromConstraint = null;
      mxPoint toConstraint = null;

      //Defines text label
      String textLabel = edgeShape.getTextLabel();

      String from = connect.getAttribute(mxVdxConstants.TO_SHEET);
      mxVdxShape fromShape = vertexShapeMap.get(new PageShapeIDKey(
          pageNumber, from));

      //If the source is not defined.
      if (connect.getAttribute(mxVdxConstants.FROM_CELL).equals(
          mxVdxConstants.END_X)
          || fromShape == null)
      {
        //Only one side connected.
        source = (mxCell) graph.insertVertex(parent, null, null,
            beginXY.getX(), beginXY.getY(), 0, 0);
        fromConstraint = new mxPoint(0, 0);

        sigConnect = connect;
      }
      else
      {
        //Define Source vertex of the edge.
        source = vertexMap.get(new PageShapeIDKey(pageNumber, from));

        //Get dimentions of vertex
        mxPoint dimentionFrom = fromShape.getDimentions();

        //Get From shape origin and begin/end of edge in absolutes values.
        double height = pageHeight;

        if ((source.getParent() != null)
            && (source.getParent().getGeometry() != null))
        {
          height = source.getParent().getGeometry().getHeight();
          height += pageHeight - actualPageHeight;
        }

        mxPoint originFrom = fromShape.getOriginPoint(height);
        mxPoint absOriginFrom = calculateAbsolutePoint(
            (mxCell) source.getParent(), graph, originFrom);

        //Determines From Constraints (Connection point) of the edge.
        fromConstraint = new mxPoint(
            (beginXY.getX() - absOriginFrom.getX())
                / dimentionFrom.getX(),
            (beginXY.getY() - absOriginFrom.getY())
                / dimentionFrom.getY());

      }

      //If is connected in both sides.
      if (sigConnect != null)
      {
        String to = sigConnect.getAttribute(mxVdxConstants.TO_SHEET);
        mxVdxShape toShape = vertexShapeMap.get(new PageShapeIDKey(
            pageNumber, to));

        if (toShape != null)
        {

          target = vertexMap.get(new PageShapeIDKey(pageNumber, to));

          mxPoint dimentionTo = toShape.getDimentions();

          //Get To shape origin.
          double height = pageHeight;

          if ((target.getParent() != null)
              && (target.getParent().getGeometry() != null))
          {
            height = target.getParent().getGeometry().getHeight();
            height += pageHeight - actualPageHeight;
          }
          mxPoint originTo = toShape.getOriginPoint(height);

          mxPoint absOriginTo = calculateAbsolutePoint(
              (mxCell) target.getParent(), graph, originTo);

          //Determines To Constraints (Connection point) of the edge.
          toConstraint = new mxPoint(
              (endXY.getX() - absOriginTo.getX())
                  / dimentionTo.getX(),
              (endXY.getY() - absOriginTo.getY())
                  / dimentionTo.getY());

        }
        else
        {

          //Only one side connected.
          target = (mxCell) graph.insertVertex(parent, null, null,
              endXY.getX(), endXY.getY(), 0, 0);
          toConstraint = new mxPoint(0, 0);
        }
      }
      else
      {
        //Only one side connected.
        target = (mxCell) graph.insertVertex(parent, null, null,
            endXY.getX(), endXY.getY(), 0, 0);
        toConstraint = new mxPoint(0, 0);
      }

      //Adjust the constraints.
      fromConstraint = mxVdxUtils.adjustConstraint(fromConstraint);
      toConstraint = mxVdxUtils.adjustConstraint(toConstraint);

      //Defines the style of the edge.
      String style = edgeShape.getStyleFromEdgeShape(parentHeight);

      //Insert new edge and set constraints.
      edge = (mxCell) graph.insertEdge(parent, null, textLabel, source,
          target, style);
      graph.setConnectionConstraint(edge, source, true,
          new mxConnectionConstraint(fromConstraint, false));
      graph.setConnectionConstraint(edge, target, false,
          new mxConnectionConstraint(toConstraint, false));

      //Gets and sets routing points of the edge.
      mxGeometry edgeGeometry = edge.getGeometry();
      List<mxPoint> pointList = edgeShape.getRoutingPoints(parentHeight);
      edgeGeometry.setPoints(pointList);

      //Put cell in the map.
      cellsMap.put(new PageShapeIDKey(pageNumber, shapeConnect), edge);

    }
    return edge;
  }
View Full Code Here


    //Gets and sets routing points of the edge.
    mxGeometry edgeGeometry = edge.getGeometry();
    List<mxPoint> pointList = edgeShape.getRoutingPoints(height);
    edgeGeometry.setPoints(pointList);

    cellsMap.put(new PageShapeIDKey(pageNumber, edgeShape.getId()), edge);

    return edge;
  }
View Full Code Here

        for (int j = 0; j < shapeLength; j++)
        {
          Element shapeInside = shpList.get(j);
          //Get the master of the sub-shape
          String Id = shapeInside.getAttribute(mxVdxConstants.ID);
          parentsMap.put(new PageShapeIDKey(pageNumber, Id), parent);
          Object vertex = addShape(graph, parent, shapeInside,
              parentHeight);

          if (vertex != null)
          {
View Full Code Here

      Iterator<mxVdxShape> it = edgeShapeMap.values().iterator();

      while (it.hasNext())
      {
        mxVdxShape edgeShape = it.next();
        addNotConnectedEdge(graph, parentsMap.get(new PageShapeIDKey(
            pageNumber, edgeShape.getId())), edgeShape);

      }
    }
  }
View Full Code Here

        mxVdxConstants.TYPE_SHAPE)
        || shp.getAttribute(mxVdxConstants.TYPE).equals(
            mxVdxConstants.TYPE_GROUP))
    {
      String id = shape.getId();
      shapeIDList.add(new PageShapeIDKey(pageNumber, id));
      //If is a vertex shape
      if (shape.isVertexShape())
      {

        mxCell v1 = null;
        if (shape.isComplexShape())
        {
          v1 = shape.addComplexShapeToGraph(graph, parent,
              parentHeight);
        }
        else
        {

          v1 = shape.addSimpleShapeToGraph(graph, parent,
              parentHeight);
        }
        vertexMap.put(new PageShapeIDKey(pageNumber, id), v1);
        vertexShapeMap.put(new PageShapeIDKey(pageNumber, id), shape);
        cellsMap.put(new PageShapeIDKey(pageNumber, id), v1);
        return v1;

      }
      else
      {
        edgeShapeMap.put(new PageShapeIDKey(pageNumber, id), shape);
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of com.mxgraph.io.vdx.PageShapeIDKey

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.