Examples of mxGraphAbstractHierarchyCell


Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

    int totalWeight = 0;
    Iterator<mxGraphAbstractHierarchyCell> iter = collection.iterator();

    while (iter.hasNext())
    {
      mxGraphAbstractHierarchyCell cell = iter.next();

      if (currentCell.isVertex() && cell.isVertex())
      {
        totalWeight++;
      }
      else if (currentCell.isEdge() && cell.isEdge())
      {
        totalWeight += 8;
      }
      else
      {
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

      boolean boundsWarning = false;
      Iterator<mxGraphAbstractHierarchyCell> iter = rank.iterator();

      while (iter.hasNext())
      {
        mxGraphAbstractHierarchyCell cell = iter.next();

        if (cell.isVertex())
        {
          mxGraphHierarchyNode node = (mxGraphHierarchyNode) cell;
          mxRectangle bounds = layout.getVertexBounds(node.cell);

          if (bounds != null)
          {
            if (orientation == SwingConstants.NORTH
                || orientation == SwingConstants.SOUTH)
            {
              cell.width = bounds.getWidth();
              cell.height = bounds.getHeight();
            }
            else
            {
              cell.width = bounds.getHeight();
              cell.height = bounds.getWidth();
            }
          }
          else
          {
            boundsWarning = true;
          }

          maxCellHeight = Math.max(maxCellHeight, cell.height);
        }
        else if (cell.isEdge())
        {
          mxGraphHierarchyEdge edge = (mxGraphHierarchyEdge) cell;
          // The width is the number of additional parallel edges
          // time the parallel edge spacing
          int numEdges = 1;

          if (edge.edges != null)
          {
            numEdges = edge.edges.size();
          }
          else
          {
            logger.info("edge.edges is null");
          }

          cell.width = (numEdges - 1) * parallelEdgeSpacing;
        }

        // Set the initial x-value as being the best result so far
        localX += cell.width / 2.0;
        cell.setX(rankValue, localX);
        cell.setGeneralPurposeVariable(rankValue, (int) localX);
        localX += cell.width / 2.0;
        localX += intraCellSpacing;

        if (localX > widestRankValue)
        {
          widestRankValue = localX;
          widestRank = rankValue;
        }

        rankWidths[rankValue] = localX;
      }

      if (boundsWarning == true)
      {
        logger.info("At least one cell has no bounds");
      }

      rankY[rankValue] = y;
      double distanceToNextRank = maxCellHeight / 2.0
          + lastRankMaxCellHeight / 2.0 + interRankCellSpacing;
      lastRankMaxCellHeight = maxCellHeight;

      if (orientation == SwingConstants.NORTH
          || orientation == SwingConstants.WEST)
      {
        y += distanceToNextRank;
      }
      else
      {
        y -= distanceToNextRank;
      }

      iter = rank.iterator();

      while (iter.hasNext())
      {
        mxGraphAbstractHierarchyCell cell = iter.next();
        cell.setY(rankValue, y);
      }
    }
  }
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

      {
        // Left-most node, can move anywhere
        return true;
      }

      mxGraphAbstractHierarchyCell leftCell = rankArray[rankIndex - 1];
      int leftLimit = leftCell.getGeneralPurposeVariable(rank);
      leftLimit = leftLimit + (int) leftCell.width / 2
          + (int) intraCellSpacing + (int) cell.width / 2;

      if (leftLimit <= position)
      {
        return true;
      }
      else
      {
        return false;
      }
    }
    else if (position > currentX)
    {
      // Trying to move node to the right.
      if (rankIndex == rankArray.length - 1)
      {
        // Right-most node, can move anywhere
        return true;
      }

      mxGraphAbstractHierarchyCell rightCell = rankArray[rankIndex + 1];
      int rightLimit = rightCell.getGeneralPurposeVariable(rank);
      rightLimit = rightLimit - (int) rightCell.width / 2
          - (int) intraCellSpacing - (int) cell.width / 2;

      if (rightLimit >= position)
      {
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

          Iterator<mxGraphAbstractHierarchyCell> iter = rank
              .iterator();

          for (int k = 0; k < rank.size(); k++)
          {
            mxGraphAbstractHierarchyCell cell = iter
                .next();
            nestedBestRanks[j][cell.getGeneralPurposeVariable(j)] = cell;
          }
        }
      }
      else
      {
        // Increase count of iterations where we haven't improved the
        // layout
        iterationsWithoutImprovement++;

        // Restore the best values to the cells
        for (int j = 0; j < nestedBestRanks.length; j++)
        {
          mxGraphHierarchyRank rank = model.ranks.get(new Integer(j));
          Iterator<mxGraphAbstractHierarchyCell> iter = rank
              .iterator();

          for (int k = 0; k < rank.size(); k++)
          {
            mxGraphAbstractHierarchyCell cell = iter
                .next();
            cell.setGeneralPurposeVariable(j, k);
          }
        }
      }

      if (currentBestCrossings == 0)
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

    // Iterate over the top rank and fill in the connection information
    Iterator<mxGraphAbstractHierarchyCell> iter = rank.iterator();

    while (iter.hasNext())
    {
      mxGraphAbstractHierarchyCell cell = iter.next();
      int rankPosition = cell.getGeneralPurposeVariable(i);
      Collection<mxGraphAbstractHierarchyCell> connectedCells = cell
          .getPreviousLayerConnectedCells(i);
      Iterator<mxGraphAbstractHierarchyCell> iter2 = connectedCells
          .iterator();

      while (iter2.hasNext())
      {
        mxGraphAbstractHierarchyCell connectedCell = iter2.next();
        int otherCellRankPosition = connectedCell
            .getGeneralPurposeVariable(i - 1);
        connections[rankPosition][otherCellRankPosition] = 201207;
      }
    }
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

            .size()];
        Iterator<mxGraphAbstractHierarchyCell> iter = rank.iterator();

        for (int j = 0; j < orderedCells.length; j++)
        {
          mxGraphAbstractHierarchyCell cell = iter
              .next();
          orderedCells[cell.getGeneralPurposeVariable(i)] = cell;
        }

        List<mxGraphAbstractHierarchyCell> leftCellAboveConnections = null;
        List<mxGraphAbstractHierarchyCell> leftCellBelowConnections = null;
        List<mxGraphAbstractHierarchyCell> rightCellAboveConnections = null;
        List<mxGraphAbstractHierarchyCell> rightCellBelowConnections = null;

        int[] leftAbovePositions = null;
        int[] leftBelowPositions = null;
        int[] rightAbovePositions = null;
        int[] rightBelowPositions = null;

        mxGraphAbstractHierarchyCell leftCell = null;
        mxGraphAbstractHierarchyCell rightCell = null;

        for (int j = 0; j < (rank.size() - 1); j++)
        {
          // For each intra-rank adjacent pair of cells
          // see if swapping them around would reduce the
          // number of edges crossing they cause in total
          // On every cell pair except the first on each rank, we
          // can save processing using the previous values for the
          // right cell on the new left cell
          if (j == 0)
          {
            leftCell = orderedCells[j];
            leftCellAboveConnections = leftCell
                .getNextLayerConnectedCells(i);
            leftCellBelowConnections = leftCell
                .getPreviousLayerConnectedCells(i);

            leftAbovePositions = new int[leftCellAboveConnections
                .size()];
            leftBelowPositions = new int[leftCellBelowConnections
                .size()];

            for (int k = 0; k < leftAbovePositions.length; k++)
            {
              leftAbovePositions[k] = leftCellAboveConnections
                  .get(k).getGeneralPurposeVariable(i + 1);
            }

            for (int k = 0; k < leftBelowPositions.length; k++)
            {
              leftBelowPositions[k] = (leftCellBelowConnections
                  .get(k)).getGeneralPurposeVariable(i - 1);
            }
          }
          else
          {
            leftCellAboveConnections = rightCellAboveConnections;
            leftCellBelowConnections = rightCellBelowConnections;
            leftAbovePositions = rightAbovePositions;
            leftBelowPositions = rightBelowPositions;
            leftCell = rightCell;
          }

          rightCell = orderedCells[j + 1];
          rightCellAboveConnections = rightCell
              .getNextLayerConnectedCells(i);
          rightCellBelowConnections = rightCell
              .getPreviousLayerConnectedCells(i);

          rightAbovePositions = new int[rightCellAboveConnections
              .size()];
          rightBelowPositions = new int[rightCellBelowConnections
              .size()];

          for (int k = 0; k < rightAbovePositions.length; k++)
          {
            rightAbovePositions[k] = (rightCellAboveConnections
                .get(k)).getGeneralPurposeVariable(i + 1);
          }

          for (int k = 0; k < rightBelowPositions.length; k++)
          {
            rightBelowPositions[k] = (rightCellBelowConnections
                .get(k)).getGeneralPurposeVariable(i - 1);
          }

          int totalCurrentCrossings = 0;
          int totalSwitchedCrossings = 0;

          for (int k = 0; k < leftAbovePositions.length; k++)
          {
            for (int ik = 0; ik < rightAbovePositions.length; ik++)
            {
              if (leftAbovePositions[k] > rightAbovePositions[ik])
              {
                totalCurrentCrossings++;
              }

              if (leftAbovePositions[k] < rightAbovePositions[ik])
              {
                totalSwitchedCrossings++;
              }
            }
          }

          for (int k = 0; k < leftBelowPositions.length; k++)
          {
            for (int ik = 0; ik < rightBelowPositions.length; ik++)
            {
              if (leftBelowPositions[k] > rightBelowPositions[ik])
              {
                totalCurrentCrossings++;
              }

              if (leftBelowPositions[k] < rightBelowPositions[ik])
              {
                totalSwitchedCrossings++;
              }
            }
          }

          if ((totalSwitchedCrossings < totalCurrentCrossings)
              || (totalSwitchedCrossings == totalCurrentCrossings && nudge))
          {
            int temp = leftCell.getGeneralPurposeVariable(i);
            leftCell.setGeneralPurposeVariable(i, rightCell
                .getGeneralPurposeVariable(i));
            rightCell.setGeneralPurposeVariable(i, temp);
            // With this pair exchanged we have to switch all of
            // values for the left cell to the right cell so the
            // next iteration for this rank uses it as the left
            // cell again
            rightCellAboveConnections = leftCellAboveConnections;
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

    int numCellsForRank = nestedBestRanks[rankValue].length;
    MedianCellSorter[] medianValues = new MedianCellSorter[numCellsForRank];

    for (int i = 0; i < numCellsForRank; i++)
    {
      mxGraphAbstractHierarchyCell cell = nestedBestRanks[rankValue][i];
      medianValues[i] = new MedianCellSorter();
      medianValues[i].cell = cell;

      // Flip whether or not equal medians are flipped on up and down
      // sweeps
      medianValues[i].nudge = !downwardSweep;
      Collection<mxGraphAbstractHierarchyCell> nextLevelConnectedCells;

      if (downwardSweep)
      {
        nextLevelConnectedCells = cell
            .getNextLayerConnectedCells(rankValue);
      }
      else
      {
        nextLevelConnectedCells = cell
            .getPreviousLayerConnectedCells(rankValue);
      }

      int nextRankValue;
View Full Code Here

Examples of com.mxgraph.layout.hierarchical.model.mxGraphAbstractHierarchyCell

            Iterator<mxGraphAbstractHierarchyCell> iter = rank
                .iterator();

            while (iter.hasNext())
            {
              mxGraphAbstractHierarchyCell cell = iter.next();
              cell.setX(j, cell.getGeneralPurposeVariable(j));
            }
          }

          bestXDelta = currentXDelta;
        }
        else
        {
          // Restore the best positions
          for (int j = 0; j < model.ranks.size(); j++)
          {
            mxGraphHierarchyRank rank = model.ranks
                .get(new Integer(j));
            Iterator<mxGraphAbstractHierarchyCell> iter = rank
                .iterator();

            while (iter.hasNext())
            {
              mxGraphAbstractHierarchyCell cell = iter.next();
              cell.setGeneralPurposeVariable(j,
                  (int) cell.getX(j));
            }
          }
        }
       
        minPath(model);
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.