Package com.mxgraph.view

Examples of com.mxgraph.view.mxGraphView$mxCurrentRootChange


   * @param context Object that represents the global validation state.
   */
  public String validateGraph(Object cell, Hashtable<Object, Object> context)
  {
    mxIGraphModel model = graph.getModel();
    mxGraphView view = graph.getView();
    boolean isValid = true;
    int childCount = model.getChildCount(cell);

    for (int i = 0; i < childCount; i++)
    {
      Object tmp = model.getChildAt(cell, i);
      Hashtable<Object, Object> ctx = context;

      if (graph.isValidRoot(tmp))
      {
        ctx = new Hashtable<Object, Object>();
      }

      String warn = validateGraph(tmp, ctx);

      if (warn != null)
      {
        String html = warn.replaceAll("\n", "<br>");
        int len = html.length();
        setCellWarning(tmp, html.substring(0, Math.max(0, len - 4)));
      }
      else
      {
        setCellWarning(tmp, null);
      }

      isValid = isValid && warn == null;
    }

    StringBuffer warning = new StringBuffer();

    // Adds error for invalid children if collapsed (children invisible)
    if (graph.isCellCollapsed(cell) && !isValid)
    {
      warning.append(mxResources.get("containsValidationErrors",
          "Contains Validation Errors") + "\n");
    }

    // Checks edges and cells using the defined multiplicities
    if (model.isEdge(cell))
    {
      String tmp = graph.getEdgeValidationError(cell,
          model.getTerminal(cell, true),
          model.getTerminal(cell, false));

      if (tmp != null)
      {
        warning.append(tmp);
      }
    }
    else
    {
      String tmp = graph.getCellValidationError(cell);

      if (tmp != null)
      {
        warning.append(tmp);
      }
    }

    // Checks custom validation rules
    String err = graph.validateCell(cell, context);

    if (err != null)
    {
      warning.append(err);
    }

    // Updates the display with the warning icons before any potential
    // alerts are displayed
    if (model.getParent(cell) == null)
    {
      view.validate();
    }

    return (warning.length() > 0 || !isValid) ? warning.toString() : null;
  }
View Full Code Here


      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

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

          .round((pe.getX() - p0.getX()) / 2)), (int) (Math.round(p0
          .getY()) + Math.round((pe.getY() - p0.getY()) / 2)));
    }
    else
    {
      mxGraphView view = graphComponent.getGraph().getView();
      pt = view.transformControlPoint(state, points.get(0))
          .getPoint();
    }

    // Create the green middle handle
    h[1] = createHandle(pt);
View Full Code Here

    {
      cells = new Object[] { graph.getModel().getRoot() };
    }

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

    // Keeps the existing translation as the cells might
    // be aligned to the grid in a different way in a graph
    // that has a translation other than zero
    boolean eventsEnabled = view.isEventsEnabled();

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

    // Uses the view to create temporary cell states for each cell
    mxTemporaryCellStates temp = new mxTemporaryCellStates(view, scale,
        cells);

    try
    {
      if (clip == null)
      {
        clip = graph.getPaintBounds(cells);
      }

      if (clip != null && clip.getWidth() > 0 && clip.getHeight() > 0)
      {
        Rectangle rect = clip.getRectangle();
        canvas = factory.createCanvas(rect.width + 1, rect.height + 1);

        if (canvas != null)
        {
          double previousScale = canvas.getScale();
          Point previousTranslate = canvas.getTranslate();

          try
          {
            canvas.setTranslate(-rect.x, -rect.y);
            canvas.setScale(view.getScale());

            for (int i = 0; i < cells.length; i++)
            {
              graph.drawCell(canvas, cells[i]);
            }
          }
          finally
          {
            canvas.setScale(previousScale);
            canvas.setTranslate(previousTranslate.x,
                previousTranslate.y);
          }
        }
      }
    }
    finally
    {
      temp.destroy();
      view.setEventsEnabled(eventsEnabled);
    }

    return canvas;
  }
View Full Code Here

TOP

Related Classes of com.mxgraph.view.mxGraphView$mxCurrentRootChange

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.