Examples of mxGraphView


Examples of com.mxgraph.view.mxGraphView

      String targetPort = "";
      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(
            edgeState, sourceState, true);
        if (scc != null)
        {
          sourceConstraint = scc.getPoint();
        }

        mxCellState targetState = view.getState(target);
        mxConnectionConstraint tcc = graph.getConnectionConstraint(
            edgeState, targetState, false);
        if (tcc != null)
        {
          targetConstraint = tcc.getPoint();
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

   * the given event.
   */
  protected mxCellState getState(MouseEvent e)
  {
    Object cell = getCell(e);
    mxGraphView view = graphComponent.getGraph().getView();
    mxCellState state = getStateToMark(view.getState(cell));

    return (state != null && intersects(state, e)) ? state : null;
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

        // computing the correct perimeter points and edge style.
        mxGeometry geometry = graphComponent.getGraph()
            .getCellGeometry(state.getCell());
        mxCellState clone = (mxCellState) state.clone();
        List<mxPoint> points = geometry.getPoints();
        mxGraphView view = clone.getView();

        if (isSource || isTarget)
        {
          marker.process(e);
          mxCellState currentState = marker.getValidState();

          target = view
              .getVisibleTerminal(state.getCell(), !isSource);

          if (currentState != null)
          {
            source = currentState.getCell();
          }
          else
          {
            mxPoint pt = new mxPoint(e.getPoint());

            if (gridEnabledEvent)
            {
              pt = graphComponent.snapScaledPoint(pt);
            }

            clone.setAbsoluteTerminalPoint(pt, isSource);
          }

          if (!isSource)
          {
            Object tmp = source;
            source = target;
            target = tmp;
          }
        }
        else
        {
          mxPoint point = convertPoint(new mxPoint(e.getPoint()),
              gridEnabledEvent);

          if (points == null)
          {
            points = Arrays.asList(new mxPoint[] { point });
          }
          else if (index - 1 < points.size())
          {
            points = new ArrayList<mxPoint>(points);
            points.set(index - 1, point);
          }

          source = view.getVisibleTerminal(state.getCell(), true);
          target = view.getVisibleTerminal(state.getCell(), false);
        }

        // Computes the points for the edge style and terminals
        mxCellState sourceState = view.getState(source);
        mxCellState targetState = view.getState(target);

        mxConnectionConstraint sourceConstraint = graphComponent
            .getGraph().getConnectionConstraint(clone, sourceState,
                true);
        mxConnectionConstraint targetConstraint = graphComponent
            .getGraph().getConnectionConstraint(clone, targetState,
                false);

        /* TODO: Implement mxConstraintHandler
        mxConnectionConstraint constraint = constraintHandler.currentConstraint;

        if (constraint == null)
        {
          constraint = new mxConnectionConstraint();
        }
       
        if (isSource)
        {
          sourceConstraint = constraint;
        }
        else if (isTarget)
        {
          targetConstraint = constraint;
        }
        */

        if (!isSource || sourceState != null)
        {
          view.updateFixedTerminalPoint(clone, sourceState, true,
              sourceConstraint);
        }

        if (!isTarget || targetState != null)
        {
          view.updateFixedTerminalPoint(clone, targetState, false,
              targetConstraint);
        }

        view.updatePoints(clone, points, sourceState, targetState);
        view.updateFloatingTerminalPoints(clone, sourceState,
            targetState);

        // Uses the updated points from the cloned state to draw the preview
        p = createPoints(clone);
        preview.setBounds(getPreviewBounds());
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

    graph.getModel().addListener(mxEvent.CHANGE, updateHandler);

    // Repaint after the following events is handled via
    // mxGraph.repaint-events
    // The respective handlers are installed in mxGraph.setView
    mxGraphView view = graph.getView();

    view.addListener(mxEvent.SCALE, updateHandler);
    view.addListener(mxEvent.TRANSLATE, updateHandler);
    view.addListener(mxEvent.SCALE_AND_TRANSLATE, updateHandler);
    view.addListener(mxEvent.UP, updateHandler);
    view.addListener(mxEvent.DOWN, updateHandler);

    graph.addPropertyChangeListener(viewChangeHandler);

    // Resets the zoom policy if the scale changes
    graph.getView().addListener(mxEvent.SCALE, scaleHandler);
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

  /**
   *
   */
  public void zoom(double factor)
  {
    mxGraphView view = graph.getView();
    double newScale = (double) ((int) (view.getScale() * 100 * factor)) / 100;

    if (newScale != view.getScale() && newScale > 0.01)
    {
      mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale)
          : new mxPoint();
      graph.getView().scaleAndTranslate(newScale, translate.getX(),
          translate.getY());

      if (keepSelectionVisibleOnZoom && !graph.isSelectionEmpty())
      {
        getGraphControl().scrollRectToVisible(
            view.getBoundingBox(graph.getSelectionCells())
                .getRectangle());
      }
      else
      {
        maintainScrollBar(true, factor, centerZoom);
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

  /**
   *
   */
  public void zoomTo(final double newScale, final boolean center)
  {
    mxGraphView view = graph.getView();
    final double scale = view.getScale();

    mxPoint translate = (pageVisible && centerPage) ? getPageTranslate(newScale)
        : new mxPoint();
    graph.getView().scaleAndTranslate(newScale, translate.getX(),
        translate.getY());
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

        final double newScale = (double) ((int) (Math.min(scaleX,
            scaleY) * 20)) / 20;

        if (newScale > 0)
        {
          mxGraphView graphView = graph.getView();
          final double scale = graphView.getScale();
          mxPoint translate = (centerPage) ? getPageTranslate(newScale)
              : new mxPoint();
          graphView.scaleAndTranslate(newScale, translate.getX(),
              translate.getY());

          // Causes two repaints, see zoomTo for more details
          final double factor = newScale / scale;

View Full Code Here

Examples of com.mxgraph.view.mxGraphView

      {
        canvas.setScale(graph.getView().getScale());
        canvas.setTranslate(0, 0);

        mxIGraphModel model = graph.getModel();
        mxGraphView view = graph.getView();

        Rectangle hit = new Rectangle(x, y, 1, 1);
        int childCount = model.getChildCount(parent);

        for (int i = childCount - 1; i >= 0; i--)
        {
          Object cell = model.getChildAt(parent, i);
          Object result = getCellAt(x, y, hitSwimlaneContent, cell);

          if (result != null)
          {
            return result;
          }
          else if (graph.isCellVisible(cell))
          {
            mxCellState state = view.getState(cell);

            if (state != null
                && canvas.intersects(this, hit, state)
                && (!graph.isSwimlane(cell)
                    || hitSwimlaneContent || (transparentSwimlaneContent && !canvas
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

        {
          canvas.setScale(graph.getView().getScale());
          canvas.setTranslate(0, 0);

          mxIGraphModel model = graph.getModel();
          mxGraphView view = graph.getView();

          int childCount = model.getChildCount(parent);

          for (int i = 0; i < childCount; i++)
          {
            Object cell = model.getChildAt(parent, i);
            mxCellState state = view.getState(cell);

            if (graph.isCellVisible(cell) && state != null)
            {
              if (canvas.contains(this, rect, state))
              {
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

    RepaintManager currentManager = RepaintManager
        .currentManager(mxGraphComponent.this);
    currentManager.setDoubleBufferingEnabled(false);

    // Gets the current state of the view
    mxGraphView view = graph.getView();

    // Stores the old state of the view
    boolean eventsEnabled = view.isEventsEnabled();
    mxPoint translate = view.getTranslate();

    // Disables firing of scale events so that there is no
    // repaint or update of the original graph while pages
    // are being printed
    view.setEventsEnabled(false);

    // Uses the view to create temporary cell states for each cell
    mxTemporaryCellStates tempStates = new mxTemporaryCellStates(view,
        1 / pageScale);

    try
    {
      view.setTranslate(new mxPoint(0, 0));

      mxGraphics2DCanvas canvas = createCanvas();
      canvas.setGraphics((Graphics2D) g);
      canvas.setScale(1 / pageScale);

      view.revalidate();

      mxRectangle graphBounds = graph.getGraphBounds();
      Dimension pSize = new Dimension((int) Math.ceil(graphBounds.getX()
          + graphBounds.getWidth()) + 1, (int) Math.ceil(graphBounds
          .getY() + graphBounds.getHeight()) + 1);

      int w = (int) (printFormat.getImageableWidth());
      int h = (int) (printFormat.getImageableHeight());
      int cols = (int) Math.max(
          Math.ceil((double) (pSize.width - 5) / (double) w), 1);
      int rows = (int) Math.max(
          Math.ceil((double) (pSize.height - 5) / (double) h), 1);

      if (page < cols * rows)
      {
        int dx = (int) ((page % cols) * printFormat.getImageableWidth());
        int dy = (int) (Math.floor(page / cols) * printFormat
            .getImageableHeight());

        g.translate(-dx + (int) printFormat.getImageableX(), -dy
            + (int) printFormat.getImageableY());
        g.setClip(dx, dy, (int) (dx + printFormat.getWidth()),
            (int) (dy + printFormat.getHeight()));

        graph.drawGraph(canvas);

        result = PAGE_EXISTS;
      }
    }
    finally
    {
      view.setTranslate(translate);

      tempStates.destroy();
      view.setEventsEnabled(eventsEnabled);

      // Enables double-buffering after printing
      currentManager.setDoubleBufferingEnabled(true);
    }

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.