Examples of mxPoint


Examples of com.mxgraph.util.mxPoint

                double x = Double.valueOf(items[1]);
                double y = Double.valueOf(items[2]);
                double width = Double.valueOf(items[3]);
                double height = Double.valueOf(items[4]);
                mxGdNode node = new mxGdNode(items[0],
                    new mxPoint(x, y), new mxPoint(width,
                        height));
                nodes.add(node);
              }
            }
            break;
View Full Code Here

Examples of com.mxgraph.util.mxPoint

      sourceName = source != null ? source.getId() : "";
      targetName = target != null ? target.getId() : "";

      //Get the graph view that contains the states
      mxGraphView view = graph.getView();
      mxPoint sourceConstraint = null;
      mxPoint targetConstraint = null;
      if (view != null)
      {
        mxCellState edgeState = view.getState(edge);
        mxCellState sourceState = view.getState(source);
        mxConnectionConstraint scc = graph.getConnectionConstraint(
View Full Code Here

Examples of com.mxgraph.util.mxPoint

        mxGraph graph = graphComponent.getGraph();
        double scale = graph.getView().getScale();
        Point pt = SwingUtilities.convertPoint(graphComponent,
            e.getLocation(), graphComponent.getGraphControl());

        pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint();
        handler.setLocation(new Point(pt));

        int dx = 0;
        int dy = 0;
View Full Code Here

Examples of com.mxgraph.util.mxPoint

    if (first != null && cellBounds != null)
    {
      mxGraph graph = graphComponent.getGraph();
      double scale = graph.getView().getScale();
      mxPoint trans = graph.getView().getTranslate();

      // LATER: Drag image _size_ depends on the initial position and may sometimes
      // not align with the grid when dragging. This is because the rounding of the width
      // and height at the initial position may be different than that at the current
      // position as the left and bottom side of the shape must align to the grid lines.
      // Only fix is a full repaint of the drag cells at each new mouse location.
      double dx = e.getX() - first.x;
      double dy = e.getY() - first.y;

      double dxg = ((cellBounds.getX() + dx) / scale) - trans.getX();
      double dyg = ((cellBounds.getY() + dy) / scale) - trans.getY();

      if (gridEnabled)
      {
        dxg = graph.snap(dxg);
        dyg = graph.snap(dyg);
      }

      x = (int) Math.round((dxg + trans.getX()) * scale)
          + (int) Math.round(bbox.getX())
          - (int) Math.round(cellBounds.getX());
      y = (int) Math.round((dyg + trans.getY()) * scale)
          + (int) Math.round(bbox.getY())
          - (int) Math.round(cellBounds.getY());
    }

    return new Point(x, y);
View Full Code Here

Examples of com.mxgraph.util.mxPoint

      double dy = 0;

      if (first != null && (cellBounds != null || movePreview.isActive()))
      {
        double scale = graph.getView().getScale();
        mxPoint trans = graph.getView().getTranslate();

        // TODO: Simplify math below, this was copy pasted from
        // getPreviewLocation with the rounding removed
        dx = e.getX() - first.x;
        dy = e.getY() - first.y;

        if (cellBounds != null)
        {
          double dxg = ((cellBounds.getX() + dx) / scale)
              - trans.getX();
          double dyg = ((cellBounds.getY() + dy) / scale)
              - trans.getY();

          if (gridEnabledEvent)
          {
            dxg = graph.snap(dxg);
            dyg = graph.snap(dyg);
          }

          double x = ((dxg + trans.getX()) * scale) + (bbox.getX())
              - (cellBounds.getX());
          double y = ((dyg + trans.getY()) * scale) + (bbox.getY())
              - (cellBounds.getY());

          dx = Math.round((x - bbox.getX()) / scale);
          dy = Math.round((y - bbox.getY()) / scale);
        }
View Full Code Here

Examples of com.mxgraph.util.mxPoint

      model.beginUpdate();
      try
      {
        mxCellState parentState = (absolute) ? view.getState(parent)
            : null;
        mxPoint o1 = (parentState != null) ? parentState.getOrigin()
            : null;
        mxPoint zero = new mxPoint(0, 0);

        for (int i = 0; i < cells.length; i++)
        {
          Object previous = model.getParent(cells[i]);

          // Keeps the cell at its absolute location
          if (o1 != null && cells[i] != parent && parent != previous)
          {
            mxCellState oldState = view.getState(previous);
            mxPoint o2 = (oldState != null) ? oldState.getOrigin()
                : zero;
            mxGeometry geo = model.getGeometry(cells[i]);

            if (geo != null)
            {
              double dx = o2.getX() - o1.getX();
              double dy = o2.getY() - o1.getY();

              geo = (mxGeometry) geo.clone();
              geo.translate(dx, dy);

              if (!geo.isRelative() && model.isVertex(cells[i])
View Full Code Here

Examples of com.mxgraph.util.mxPoint

  public void cellsRemoved(Object[] cells)
  {
    if (cells != null && cells.length > 0)
    {
      double scale = view.getScale();
      mxPoint tr = view.getTranslate();

      model.beginUpdate();
      try
      {
        for (int i = 0; i < cells.length; i++)
        {
          // Disconnects edges which are not in cells
          Collection<Object> cellSet = new HashSet<Object>();
          cellSet.addAll(Arrays.asList(cells));
          Object[] edges = getConnections(cells[i]);

          for (int j = 0; j < edges.length; j++)
          {
            if (!cellSet.contains(edges[j]))
            {
              mxGeometry geo = model.getGeometry(edges[j]);

              if (geo != null)
              {
                mxCellState state = view.getState(edges[j]);

                if (state != null)
                {
                  geo = (mxGeometry) geo.clone();
                  boolean source = view.getVisibleTerminal(
                      edges[j], true) == cells[i];
                  int n = (source) ? 0 : state
                      .getAbsolutePointCount() - 1;
                  mxPoint pt = state.getAbsolutePoint(n);

                  geo.setTerminalPoint(new mxPoint(pt.getX()
                      / scale - tr.getX(), pt.getY()
                      / scale - tr.getY()), source);
                  model.setTerminal(edges[j], null, source);
                  model.setGeometry(edges[j], geo);
                }
              }
View Full Code Here

Examples of com.mxgraph.util.mxPoint

            mxRectangle bounds = view.getBounds(mxGraphModel
                .getChildren(model, cell));

            if (bounds != null)
            {
              mxPoint tr = view.getTranslate();
              double scale = view.getScale();

              double width = (bounds.getX() + bounds.getWidth())
                  / scale - geo.getX() - tr.getX();
              double height = (bounds.getY() + bounds.getHeight())
                  / scale - geo.getY() - tr.getY();

              geo.setWidth(Math.max(geo.getWidth(), width));
              geo.setHeight(Math.max(geo.getHeight(), height));
            }
          }
View Full Code Here

Examples of com.mxgraph.util.mxPoint

          {
            geo = (mxGeometry) geo.clone();

            if (geo.isRelative())
            {
              mxPoint offset = geo.getOffset();

              if (offset != null)
              {
                offset.setX(offset.getX() + tmp.getX());
                offset.setY(offset.getY() + tmp.getY());
              }
            }
            else
            {
              geo.setX(tmp.getX());
View Full Code Here

Examples of com.mxgraph.util.mxPoint

      if (geo.isRelative() && !model.isEdge(cell))
      {
        if (geo.getOffset() == null)
        {
          geo.setOffset(new mxPoint(dx, dy));
        }
        else
        {
          mxPoint offset = geo.getOffset();

          offset.setX(offset.getX() + dx);
          offset.setY(offset.getY() + dy);
        }
      }

      model.setGeometry(cell, geo);
    }
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.