Examples of mxVdxShape


Examples of com.mxgraph.io.vdx.mxVdxShape

   */
  private static mxCell addShape(mxGraph graph, Object parent, Element shp,
      double parentHeight)
  {
    //Create a wrapper for shape Element.
    mxVdxShape shape = new mxVdxShape(shp);

    //If is a Shape or a Group add the vertex to the graph.
    if (shp.getAttribute(mxVdxConstants.TYPE).equals(
        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);
View Full Code Here

Examples of com.mxgraph.io.vdx.mxVdxShape

    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.
View Full Code Here

Examples of com.mxgraph.io.vdx.mxVdxShape

   * @param parent Parent cell of the subShapes to be imported.
   */
  private static void decodeShape(Element shape, mxGraph graph, Object parent)
  {

    mxVdxShape shp = new mxVdxShape(shape);

    //If a shape is complex(formed by several shapes) its subshapes are not considered.
    //its subshapes have been considered already.
    if (!shp.isComplexShape())
    {
      NodeList childs = shape.getChildNodes();

      if (mxVdxUtils.nodeListHasTag(childs, mxVdxConstants.SHAPES))
      {
        Element shapes = mxVdxUtils.nodeListTag(childs,
            mxVdxConstants.SHAPES);
        NodeList shapeList = shapes.getChildNodes();

        List<Element> shpList = mxVdxUtils.nodeListTags(shapeList,
            mxVdxConstants.SHAPE);

        int shapeLength = shpList.size();

        //Get the masterShapes of shape
        double parentHeight = shp.getDimentions().getY();

        //Process the sub-shapes
        for (int j = 0; j < shapeLength; j++)
        {
          Element shapeInside = shpList.get(j);
View Full Code Here

Examples of com.mxgraph.io.vdx.mxVdxShape

      //Process not conected edges.
      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
TOP
Copyright © 2018 www.massapi.com. 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.