Package com.mxgraph.util

Examples of com.mxgraph.util.mxPoint


    double top = clip.getY();
    double right = left + clip.getWidth();
    double bottom = top + clip.getHeight();

    // Fetches some global display state information
    mxPoint trans = graph.getView().getTranslate();
    double scale = graph.getView().getScale();
    double tx = trans.getX() * scale;
    double ty = trans.getY() * scale;

    // Sets the distance of the grid lines in pixels
    double stepping = increment;

    if (stepping < tickDistance)
View Full Code Here


   */
  public void addEdgeTemplate(final String name, ImageIcon icon,
      String style, int width, int height, Object value)
  {
    mxGeometry geometry = new mxGeometry(0, 0, width, height);
    geometry.setTerminalPoint(new mxPoint(0, height), true);
    geometry.setTerminalPoint(new mxPoint(width, 0), false);
    geometry.setRelative(true);

    mxCell cell = new mxCell(value, geometry, style);
    cell.setEdge(true);

View Full Code Here

    double y = -sceneRect.getY()
        + (preferredSize.getHeight() - sceneRect.getHeight()) / 2.0;

    //TODO at this point the view should center on the traffic light - using the given center point
    graphView.setEventsEnabled(false);
    mxPoint translate = null;
    translate = new mxPoint(x, y);
    logger.info("TRANSLATE TO "+translate.getX()+"; "+translate.getY()+ " TEST");
//    translate = new mxPoint(p.getX() + x, p.getY() + y);
//    logger.info("TRANSLATE TO "+translate.getX()+"; "+translate.getY());
   
    graphView.setTranslate(translate);
    graphView.revalidate();
View Full Code Here

      mxGraphView graphView = getGraph().getView();
      final Dimension preferredSize = new Dimension(Math.max(
          (int) sceneRect.getWidth(), viewportSize.width), Math.max(
          (int) sceneRect.getHeight(), viewportSize.height));

      mxPoint p = graphView.getTranslate();
      double x = -sceneRect.getX()
          + (preferredSize.getWidth() - sceneRect.getWidth()) / 2.0;
      double y = -sceneRect.getY()
          + (preferredSize.getHeight() - sceneRect.getHeight()) / 2.0;

      /**
       * Workaround for the StackOverflow Exception
       */
      graphView.setEventsEnabled(false);
      graphView.setTranslate(new mxPoint(p.getX() + x, p.getY() + y));
      graphView.revalidate();
      graphView.setEventsEnabled(true);

      return preferredSize;
    }
View Full Code Here

            });
          }
          else
          {
            // Resets the translation of the view
            mxPoint tr = graphComponent.getGraph().getView()
                .getTranslate();

            if (tr.getX() != 0 || tr.getY() != 0)
            {
              graphComponent.getGraph().getView().setTranslate(
                  new mxPoint());
            }
          }
        }
      }
    });
View Full Code Here

    double top = clip.getY();
    double right = left + clip.getWidth();
    double bottom = top + clip.getHeight();

    // Fetches some global display state information
    mxPoint trans = graph.getView().getTranslate();
    double scale = graph.getView().getScale();
    double tx = trans.getX() * scale;
    double ty = trans.getY() * scale;

    // Sets the distance of the grid lines in pixels
    double stepping = increment;

    if (stepping < tickDistance)
View Full Code Here

   */
  public void addEdgeTemplate(final String name, ImageIcon icon,
      String style, int width, int height, Object value)
  {
    mxGeometry geometry = new mxGeometry(0, 0, width, height);
    geometry.setTerminalPoint(new mxPoint(0, height), true);
    geometry.setTerminalPoint(new mxPoint(width, 0), false);
    geometry.setRelative(true);

    mxCell cell = new mxCell(value, geometry, style);
    cell.setEdge(true);

View Full Code Here

   */
  private void translatePoint(List<mxPoint> points, int index, mxPoint offset)
  {
    if (offset != null)
    {
      mxPoint pt = (mxPoint) points.get(index).clone();
      pt.setX(pt.getX() + offset.getX());
      pt.setY(pt.getY() + offset.getY());
      points.set(index, pt);
    }
  }
View Full Code Here

    double absSize = size * canvas.getScale();

    List<mxPoint> points = state.getAbsolutePoints();
    mxLine markerVector = getMarkerVector(points, source, absSize);
    mxPoint p0 = new mxPoint(markerVector.getX(), markerVector.getY());
    mxPoint pe = markerVector.getEndPoint();

    mxPoint offset = null;

    // Computes the norm and the inverse norm
    double dx = pe.getX() - p0.getX();
    double dy = pe.getY() - p0.getY();

    double dist = Math.max(1, Math.sqrt(dx * dx + dy * dy));
    double unitX = dx / dist;
    double unitY = dy / dist;
    double nx = unitX * absSize;
    double ny = unitY * absSize;

    // Allow for stroke width in the end point used and the
    // orthogonal vectors describing the direction of the
    // marker
    double strokeX = unitX * strokeWidth;
    double strokeY = unitY * strokeWidth;
    pe = (mxPoint) pe.clone();
    pe.setX(pe.getX() - strokeX / 2.0);
    pe.setY(pe.getY() - strokeY / 2.0);
   
    mxIMarker marker = mxMarkerRegistry.getMarker(type);
   
    if (marker != null)
    {
      offset = marker.paintMarker(canvas, state, type, pe, nx, ny, absSize, source);
     
      if (offset != null)
      {
        offset.setX(offset.getX() - strokeX / 2.0);
        offset.setY(offset.getY() - strokeY / 2.0);
      }
    }
    else
    {
      // Offset for the strokewidth
      nx = dx * strokeWidth / dist;
      ny = dy * strokeWidth / dist;

      offset = new mxPoint(-strokeX / 2.0, -strokeY / 2.0);
    }

    return offset;
  }
View Full Code Here

   */
  protected mxLine getMarkerVector(List<mxPoint> points, boolean source,
      double markerSize)
  {
    int n = points.size();
    mxPoint p0 = (source) ? points.get(1) : points.get(n - 2);
    mxPoint pe = (source) ? points.get(0) : points.get(n - 1);
    int count = 1;
   
    // Uses next non-overlapping point
    while (count < n - 1 && Math.round(p0.getX() - pe.getX()) == 0 && Math.round(p0.getY() - pe.getY()) == 0)
    {
      p0 = (source) ? points.get(1 + count) : points.get(n - 2 - count);
      count++;
    }
   
View Full Code Here

TOP

Related Classes of com.mxgraph.util.mxPoint

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.