Examples of mxGraphView


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

Examples of com.mxgraph.view.mxGraphView

   *            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

Examples of com.mxgraph.view.mxGraphView

    if (geometry != null)
    {
      result = new mxRectangle(x, y, geometry.getWidth(),
          geometry.getHeight());

      mxGraphView graphView = graph.getView();

      // Checks for oversize labels and offset the result
      if (useBoundingBox)
      {
        mxCellState state = graphView.getState(vertex);

        if (state != null)
        {
          double scale = graph.getView().getScale();
          mxRectangle box = state.getBoundingBox();
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

   * (non-Javadoc)
   * @see com.mxgraph.layout.mxIGraphLayout#execute(java.lang.Object)
   */
  public void execute(Object parent)
  {
    mxGraphView view = graph.getView();
    mxIGraphModel model = graph.getModel();

    // Gets all vertices and edges inside the parent
    List<Object> edges = new ArrayList<Object>();
    List<Object> vertices = new ArrayList<Object>();
    int childCount = model.getChildCount(parent);

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

      if (state != null)
      {
        if (!isVertexIgnored(cell))
        {
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

  /**
   *
   */
  protected String getEdgeId(Object edge)
  {
    mxGraphView view = graph.getView();
    mxCellState state = view.getState(edge);
    Object src = (state != null) ? state.getVisibleTerminal(true) : view
        .getVisibleTerminal(edge, true);
    Object trg = (state != null) ? state.getVisibleTerminal(false) : view
        .getVisibleTerminal(edge, false);

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

Examples of com.mxgraph.view.mxGraphView

          else
          {
            sy = 0;
          }

          mxGraphView view = graphComponent.getGraph().getView();
          double scale = view.getScale();
          double newScale = scale - (dx * scale) / w;
          double factor = newScale / scale;
          view.setScale(newScale);

          if (hs != null)
          {
            hs.setValue((int) (sx * hs.getMaximum() * factor));
          }
 
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

    Object oldMove = vertices[startVertexValue];
    currCoords = getVertexGridCoords(xDim, yDim, startVertexValue);
    resultPath.add(oldMove);
    Object nextMove = getNextKnightMove(aGraph, xDim, yDim, currCoords[0], currCoords[1], resultPath);
    mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
    mxGraphView view = graph.getView();
   
    //the main loop
    while (nextMove != null)
    {
      // connect current with the possible move that has minimum number of its (possible moves)
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

    //get the position with minimum possible moves
    int minMoveNum = 9;
    float biggestDistance = 0;
    Object currVertex = null;
    mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
    mxGraphView view = aGraph.getGraph().getView();
   
    for (int i = 0; i < possibleMoves.length; i++)
    {
      int currValue = (int) costFunction.getCost(new mxCellState(view, possibleMoves[i], null));
      int[] currCoords = getVertexGridCoords(xDim, yDim, currValue);
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

  protected void addGraphListeners(mxGraph graph)
  {
    // LATER: Install change listener for graph model, view
    if (graph != null)
    {
      mxGraphView view = graph.getView();
      view.addListener(mxEvent.SCALE, resetHandler);
      view.addListener(mxEvent.TRANSLATE, resetHandler);
      view.addListener(mxEvent.SCALE_AND_TRANSLATE, resetHandler);

      graph.getModel().addListener(mxEvent.CHANGE, resetHandler);
    }
  }
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

   */
  protected void removeGraphListeners(mxGraph graph)
  {
    if (graph != null)
    {
      mxGraphView view = graph.getView();
      view.removeListener(resetHandler, mxEvent.SCALE);
      view.removeListener(resetHandler, mxEvent.TRANSLATE);
      view.removeListener(resetHandler, mxEvent.SCALE_AND_TRANSLATE);

      graph.getModel().removeListener(resetHandler, mxEvent.CHANGE);
    }
  }
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.