Package com.mxgraph.view

Examples of com.mxgraph.view.mxGraphView


  /**
   *
   */
  protected String getEdgeId(Object edge)
  {
    mxGraphView view = graph.getView();
    Object src = view.getVisibleTerminal(edge, true);
    Object trg = view.getVisibleTerminal(edge, false);

    if (src instanceof mxICell && trg instanceof mxICell)
    {
      String srcId = mxCellPath.create((mxICell) src);
      String trgId = mxCellPath.create((mxICell) trg);
View Full Code Here


                invoke(sender, evt);
              }
            });
            return;
          }
          final mxGraphView view = graphComponent.getGraph().getView();
          double scale = view.getScale();
          if (scale > 100) {
            scale = 100;
            graphComponent.zoomTo(scale, true);
          }
          zoomCombo.setSelectedItem(Math.round(100 * scale) + "%");
View Full Code Here

    mxGraphControl graphControl = graphComponent.getGraphControl();
    graphControl.addMouseListener(this);
    graphControl.addMouseMotionListener(this);

    mxGraphView view = graphComponent.getGraph().getView();
    view.addListener(mxEvent.SCALE, resetHandler);
    view.addListener(mxEvent.TRANSLATE, resetHandler);
    view.addListener(mxEvent.SCALE_AND_TRANSLATE, resetHandler);

    mxIGraphModel model = graphComponent.getGraph().getModel();
    model.addListener(mxEvent.CHANGE, resetHandler);

    marker = new mxCellMarker(graphComponent)
View Full Code Here

    // Installs the update handler to sync the overlays and controls
    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

  /**
   *
   */
  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

  /**
   *
   */
  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

        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

      {
        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

        {
          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

    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);

      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

Related Classes of com.mxgraph.view.mxGraphView

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.