Examples of mxGraphView


Examples of com.mxgraph.view.mxGraphView

          .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

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

    Object[] vertices = aGraph.getChildVertices(aGraph.getGraph().getDefaultParent());

    int childNum = vertices.length;
    int vertexValue = 0;
    mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
    mxGraphView view = graph.getView();

    for (int i = 0; i < childNum; i++)
    {
      Object currVertex = vertices[i];
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

  public static boolean isCutEdge(mxAnalysisGraph aGraph, Object edge)
  {
    mxGraph graph = aGraph.getGraph();
    mxIGraphModel model = graph.getModel();
    mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
    mxGraphView view = graph.getView();

    int srcValue = (int) costFunction.getCost(new mxCellState(view, aGraph.getTerminal(edge, true), null));
    int destValue = (int) costFunction.getCost(new mxCellState(view, aGraph.getTerminal(edge, false), null));

    if (aGraph.getTerminal(edge, false) != null || aGraph.getTerminal(edge, true) != null)
    {
      Object[] cells = model.cloneCells(aGraph.getChildCells(graph.getDefaultParent(), true, true), true);
      mxGraphModel modelCopy = new mxGraphModel();
      mxGraph graphCopy = new mxGraph(modelCopy);
      graphCopy.addCells(cells);
      mxAnalysisGraph aGraphCopy = new mxAnalysisGraph();
      aGraphCopy.setGraph(graphCopy);
      aGraphCopy.setGenerator(aGraph.getGenerator());
      aGraphCopy.setProperties(aGraph.getProperties());

      Object[] edges = aGraphCopy.getChildEdges(aGraphCopy.getGraph().getDefaultParent());
      Object currEdge = edges[0];
      mxCostFunction costFunctionCopy = aGraphCopy.getGenerator().getCostFunction();
      mxGraphView viewCopy = graphCopy.getView();

      int currSrcValue = (int) costFunctionCopy.getCost(new mxCellState(viewCopy, aGraphCopy.getTerminal(currEdge, true), null));
      int currDestValue = (int) costFunctionCopy.getCost(new mxCellState(viewCopy, aGraphCopy.getTerminal(currEdge, false), null));
      int i = 0;
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

   * Implements <mxGraphLayout.execute>.
   */
  public void execute(Object parent)
  {
    mxIGraphModel model = graph.getModel();
    mxGraphView view = graph.getView();
    Object[] vertices = graph.getChildVertices(parent);
    HashSet<Object> vertexSet = new HashSet<Object>(Arrays.asList(vertices));

    HashSet<Object> validEdges = new HashSet<Object>();

    // Remove edges that do not have both source and target terminals visible
    for (int i = 0; i < vertices.length; i++)
    {
      Object[] edges = mxGraphModel.getEdges(model, vertices[i], false, true, false);

      for (int j = 0; j < edges.length; j++)
      {
        // Only deal with sources. To be valid in the layout, each edge must be attached
        // at both source and target to a vertex in the layout. Doing this avoids processing
        // each edge twice.
        if (view.getVisibleTerminal(edges[j], true) == vertices[i] && vertexSet.contains(view.getVisibleTerminal(edges[j], false)))
        {
          validEdges.add(edges[j]);
        }
      }

View Full Code Here

Examples of com.mxgraph.view.mxGraphView

      mxICostFunction cf, int steps, boolean directed)
  {
    // Sets up a pqueue and a hashtable to store the predecessor for each
    // cell in tha graph traversal. The pqueue is initialized
    // with the from element at prio 0.
    mxGraphView view = graph.getView();
    mxFibonacciHeap q = createPriorityQueue();
    Hashtable<Object, Object> pred = new Hashtable<Object, Object>();
    q.decreaseKey(q.getNode(from, true), 0); // Inserts automatically

    // The main loop of the dijkstra algorithm is based on the pqueue being
    // updated with the actual shortest distance to the source vertex.
    for (int j = 0; j < steps; j++)
    {
      mxFibonacciHeap.Node node = q.removeMin();
      double prio = node.getKey();
      Object obj = node.getUserObject();

      // Exits the loop if the target node or vertex has been reached
      if (obj == to)
      {
        break;
      }

      // Gets all outgoing edges of the closest cell to the source
      Object[] e = (directed) ? graph.getOutgoingEdges(obj) : graph
          .getConnections(obj);

      if (e != null)
      {
        for (int i = 0; i < e.length; i++)
        {
          Object[] opp = graph.getOpposites(new Object[] { e[i] },
              obj);

          if (opp != null && opp.length > 0)
          {
            Object neighbour = opp[0];

            // Updates the priority in the pqueue for the opposite node
            // to be the distance of this step plus the cost to
            // traverese the edge to the neighbour. Note that the
            // priority queue will make sure that in the next step the
            // node with the smallest prio will be traversed.
            if (neighbour != null && neighbour != obj
                && neighbour != from)
            {
              double newPrio = prio
                  + ((cf != null) ? cf.getCost(view
                      .getState(e[i])) : 1);
              node = q.getNode(neighbour, true);
              double oldPrio = node.getKey();

              if (newPrio < oldPrio)
              {
                pred.put(neighbour, e[i]);
                q.decreaseKey(node, newPrio);
              }
            }
          }
        }
      }

      if (q.isEmpty())
      {
        break;
      }
    }

    // Constructs a path array by walking backwards through the predessecor
    // map and filling up a list of edges, which is subsequently returned.
    ArrayList<Object> list = new ArrayList<Object>(2 * steps);
    Object obj = to;
    Object edge = pred.get(obj);

    if (edge != null)
    {
      list.add(obj);

      while (edge != null)
      {
        list.add(0, edge);

        mxCellState state = view.getState(edge);
        Object source = (state != null) ? state
            .getVisibleTerminal(true) : view.getVisibleTerminal(
            edge, true);
        boolean isSource = source == obj;
        obj = (state != null) ? state.getVisibleTerminal(!isSource)
            : view.getVisibleTerminal(edge, !isSource);
        list.add(0, obj);

        edge = pred.get(obj);
      }
    }
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

    // increasing length and tries adding to the MST. Only edges are added
    // that do not form cycles in the graph, that is, where the source
    // and target are in different sets in the union find structure.
    // Whenever an edge is added to the MST, the two different sets are
    // unified.
    mxGraphView view = graph.getView();
    mxUnionFind uf = createUnionFind(v);
    ArrayList<Object> result = new ArrayList<Object>(e.length);
    mxCellState[] edgeStates = sort(view.getCellStates(e), cf);

    for (int i = 0; i < edgeStates.length; i++)
    {
      Object source = edgeStates[i].getVisibleTerminal(true);
      Object target = edgeStates[i].getVisibleTerminal(false);
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

   * @see #createUnionFind(Object[])
   */
  public mxUnionFind getConnectionComponents(mxGraph graph, Object[] v,
      Object[] e)
  {
    mxGraphView view = graph.getView();
    mxUnionFind uf = createUnionFind(v);

    for (int i = 0; i < e.length; i++)
    {
      mxCellState state = view.getState(e[i]);
      Object source = (state != null) ? state.getVisibleTerminal(true)
          : view.getVisibleTerminal(e[i], true);
      Object target = (state != null) ? state.getVisibleTerminal(false)
          : view.getVisibleTerminal(e[i], false);

      uf.union(uf.find(uf.getNode(source)), uf.find(uf.getNode(target)));
    }

    return uf;
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

      vertexListStatic.add((Object) vertexes[i]);
    }

    distances[vertexListStatic.indexOf(startVertex)] = 0;
    mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
    mxGraphView view = aGraph.getGraph().getView();

    while (vertexList.size() > 0)
    {
      //find closest vertex
      double minDistance;
View Full Code Here

Examples of com.mxgraph.view.mxGraphView

    int vertexNum = vertices.length;
    int edgeNum = edges.length;
    Map<Object, Object> distanceMap = new HashMap<Object, Object>();
    Map<Object, Object> parentMap = new HashMap<Object, Object>();
    mxCostFunction costFunction = aGraph.getGenerator().getCostFunction();
    mxGraphView view = graph.getView();

    for (int i = 0; i < vertexNum; i++)
    {
      Object currVertex = vertices[i];
      distanceMap.put(currVertex, Double.MAX_VALUE);
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.