Package com.mxgraph.model

Examples of com.mxgraph.model.mxGeometry


    // position vertexes for group 1
    for (int i = 0; i < numVerticesGroup1; i++)
    {
      Object currVertex = vertices[i];
      mxGeometry geometry = model.getGeometry(currVertex);
      geometry.setX(0);
      geometry.setY(group1StartY + i * vertexSpacing);
    }

    // position vertexes for group 2
    for (int i = numVerticesGroup1; i < numVerticesGroup1 + numVerticesGroup2; i++)
    {
      Object currVertex = vertices[i];
      mxGeometry geometry = model.getGeometry(currVertex);
      geometry.setX(groupSpacing);
      geometry.setY(group2StartY + (i - numVerticesGroup1) * vertexSpacing);
    }
  };
 
View Full Code Here


    for (int i = 0; i < vertices.length; i++)
    {
      Object currVertex = vertices[i];

      mxGeometry geometry = model.getGeometry(currVertex);
      geometry.setX(0);
      geometry.setY(i * spacing);
    }
  };
 
View Full Code Here

      currRatio = currRatio * 2;
      currRatio = currRatio * (double) Math.PI;
      x = Math.round(centerX + Math.round(graphSize * Math.sin(currRatio) / 2));
      y = Math.round(centerY - Math.round(graphSize * Math.cos(currRatio) / 2));
      Object currVertex = vertices[i];
      mxGeometry geometry = model.getGeometry(currVertex);
      geometry.setX(x);
      geometry.setY(y);
    }

    mxGeometry geometry = model.getGeometry(vertices[vertexNum - 1]);
    geometry.setX(centerX);
    geometry.setY(centerY);
  };
View Full Code Here

        x = Math.round(centerX + Math.round(currSize * Math.sin(currRatio) / 2));
        y = Math.round(centerY - Math.round(currSize * Math.cos(currRatio) / 2));
        //shoot
        int currIndex = i * (numVerticesInBranch) + j;
        Object currVertex = vertices[currIndex];
        mxGeometry geometry = model.getGeometry(currVertex);
        geometry.setX(x);
        geometry.setY(y);
      }
    }

    //the center vertex is the last one
    Object currVertex = vertices[vertexNum - 1];
    mxGeometry geometry = model.getGeometry(currVertex);
    geometry.setX(centerX);
    geometry.setY(centerY);
  };
View Full Code Here

   * @see com.mxgraph.layout.mxIGraphLayout#execute(java.lang.Object)
   */
  public void execute(Object parent)
  {
    mxIGraphModel model = graph.getModel();
    mxGeometry pgeo = model.getGeometry(parent);

    // Handles special case where the parent is either a layer with no
    // geometry or the current root of the view in which case the size
    // of the graph's container will be used.
    if (pgeo == null && model.getParent(parent) == model.getRoot()
        || parent == graph.getView().getCurrentRoot())
    {
      mxRectangle tmp = getContainerSize();
      pgeo = new mxGeometry(0, 0, tmp.getWidth(), tmp.getHeight());
    }

    if (pgeo != null)
    {
      int childCount = model.getChildCount(parent);
      List<Object> children = new ArrayList<Object>(childCount);

      for (int i = 0; i < childCount; i++)
      {
        Object child = model.getChildAt(parent, i);

        if (!isVertexIgnored(child) && isVertexMovable(child))
        {
          children.add(child);
        }
      }

      int n = children.size();

      if (n > 0)
      {
        double x0 = border;
        double y0 = border;
        double other = (horizontal) ? pgeo.getHeight() : pgeo
            .getWidth();
        other -= 2 * border;

        mxRectangle size = graph.getStartSize(parent);

        other -= (horizontal) ? size.getHeight() : size.getWidth();
        x0 = x0 + size.getWidth();
        y0 = y0 + size.getHeight();

        double tmp = border + (n - 1) * spacing;
        double value = (horizontal) ? ((pgeo.getWidth() - x0 - tmp) / n)
            : ((pgeo.getHeight() - y0 - tmp) / n);

        // Avoids negative values, that is values where the sum of the
        // spacing plus the border is larger then the available space
        if (value > 0)
        {
          model.beginUpdate();
          try
          {
            for (int i = 0; i < n; i++)
            {
              Object child = children.get(i);
              mxGeometry geo = model.getGeometry(child);

              if (geo != null)
              {
                geo = (mxGeometry) geo.clone();
                geo.setX(x0);
                geo.setY(y0);

                if (horizontal)
                {
                  if (resizeVertices)
                  {
                    geo.setWidth(value);
                    geo.setHeight(other);
                  }

                  x0 += value + spacing;
                }
                else
                {
                  if (resizeVertices)
                  {
                    geo.setHeight(value);
                    geo.setWidth(other);
                  }

                  y0 += value + spacing;
                }

View Full Code Here

      else
      {
        dx = 0;
      }

      mxGeometry g = model.getGeometry(edge.getCell());

      if (g != null)
      {
        g = (mxGeometry) g.clone();

        if (g.getOffset() != null)
        {
          g.getOffset().setX(g.getOffset().getX() + dx);
          g.getOffset().setY(g.getOffset().getY() + dy);
        }
        else
        {
          g.setOffset(new mxPoint(dx, dy));
        }

        model.setGeometry(edge.getCell(), g);
      }
    }
View Full Code Here

      {
        Object child = model.getChildAt(parent, i);

        if (child != cell)
        {
          mxGeometry bounds = model.getGeometry(child);

          if (bounds != null)
          {
            double tmp = (horizontal) ? bounds.getX()
                + bounds.getWidth() / 2 : bounds.getY()
                + bounds.getHeight() / 2;

            if (last < value && tmp > value)
            {
              break;
            }
View Full Code Here

  {
    if (parent != null)
    {
      boolean horizontal = isHorizontal();
      mxIGraphModel model = graph.getModel();
      mxGeometry pgeo = model.getGeometry(parent);

      // Handles special case where the parent is either a layer with no
      // geometry or the current root of the view in which case the size
      // of the graph's container will be used.
      if (pgeo == null && model.getParent(parent) == model.getRoot()
          || parent == graph.getView().getCurrentRoot())
      {
        mxRectangle tmp = getContainerSize();
        pgeo = new mxGeometry(0, 0, tmp.getWidth(), tmp.getHeight());
      }

      double fillValue = 0;

      if (pgeo != null)
      {
        fillValue = (horizontal) ? pgeo.getHeight() : pgeo.getWidth();
      }

      fillValue -= 2 * spacing + 2 * border;

      // Handles swimlane start size
      mxRectangle size = graph.getStartSize(parent);
      fillValue -= (horizontal) ? size.getHeight() : size.getWidth();
      double x0 = this.x0 + size.getWidth() + border;
      double y0 = this.y0 + size.getHeight() + border;

      model.beginUpdate();
      try
      {
        double tmp = 0;
        mxGeometry last = null;
        int childCount = model.getChildCount(parent);

        for (int i = 0; i < childCount; i++)
        {
          Object child = model.getChildAt(parent, i);

          if (!isVertexIgnored(child) && isVertexMovable(child))
          {
            mxGeometry geo = model.getGeometry(child);

            if (geo != null)
            {
              geo = (mxGeometry) geo.clone();

              if (wrap != 0 && last != null)
              {

                if ((horizontal && last.getX()
                    + last.getWidth() + geo.getWidth() + 2
                    * spacing > wrap)
                    || (!horizontal && last.getY()
                        + last.getHeight()
                        + geo.getHeight() + 2 * spacing > wrap))
                {
                  last = null;

                  if (horizontal)
                  {
                    y0 += tmp + spacing;
                  }
                  else
                  {
                    x0 += tmp + spacing;
                  }

                  tmp = 0;
                }
              }

              tmp = Math.max(tmp, (horizontal) ? geo
                  .getHeight() : geo.getWidth());

              if (last != null)
              {
                if (horizontal)
                {
                  geo.setX(last.getX() + last.getWidth()
                      + spacing);
                }
                else
                {
                  geo.setY(last.getY() + last.getHeight()
                      + spacing);
                }
              }
              else
              {
                if (horizontal)
                {
                  geo.setX(x0);
                }
                else
                {
                  geo.setY(y0);
                }
              }

              if (horizontal)
              {
                geo.setY(y0);
              }
              else
              {
                geo.setX(x0);
              }

              if (fill && fillValue > 0)
              {
                if (horizontal)
                {
                  geo.setHeight(fillValue);
                }
                else
                {
                  geo.setWidth(fillValue);
                }
              }

              model.setGeometry(child, geo);
              last = geo;
View Full Code Here

   */
  protected void layout(List<Object> parallels)
  {
    Object edge = parallels.get(0);
    mxIGraphModel model = graph.getModel();
    mxGeometry src = model.getGeometry(model.getTerminal(edge, true));
    mxGeometry trg = model.getGeometry(model.getTerminal(edge, false));

    // Routes multiple loops
    if (src == trg)
    {
      double x0 = src.getX() + src.getWidth() + this.spacing;
      double y0 = src.getY() + src.getHeight() / 2;

      for (int i = 0; i < parallels.size(); i++)
      {
        route(parallels.get(i), x0, y0);
        x0 += spacing;
      }
    }
    else if (src != null && trg != null)
    {
      // Routes parallel edges
      double scx = src.getX() + src.getWidth() / 2;
      double scy = src.getY() + src.getHeight() / 2;

      double tcx = trg.getX() + trg.getWidth() / 2;
      double tcy = trg.getY() + trg.getHeight() / 2;

      double dx = tcx - scx;
      double dy = tcy - scy;

      double len = Math.sqrt(dx * dx + dy * dy);
 
View Full Code Here

      Double miny = null;

      for (int i = 0; i < vertexArray.length; i++)
      {
        Object vertex = vertexArray[i];
        mxGeometry geo = model.getGeometry(vertex);

        if (geo != null)
        {
          cellLocation[i][0] -= geo.getWidth() / 2.0;
          cellLocation[i][1] -= geo.getHeight() / 2.0;

          double x = graph.snap(cellLocation[i][0]);
          double y = graph.snap(cellLocation[i][1]);
          setVertexLocation(vertex, x, y);
View Full Code Here

TOP

Related Classes of com.mxgraph.model.mxGeometry

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.