Package org.eclipse.zest.layouts.dataStructures

Examples of org.eclipse.zest.layouts.dataStructures.InternalNode


     
    }   
  }
  class YComparator implements Comparator {
    public int compare(Object arg0, Object arg1) {
      InternalNode n1 = (InternalNode)arg0;
      InternalNode n2 = (InternalNode)arg1;
      if ( n1.getInternalY() > n2.getInternalY() ) return +1;
      else if ( n1.getInternalY() < n2.getInternalY() ) return -1;
      else {
        return n1.toString().compareTo( n2.toString() );
      }

    }   
View Full Code Here


      }

      // Also remove from _internalNodes
      ArrayList updatedEntities = new ArrayList(internalNodes.length - entitiesToRemove.size() + entitiesToAdd.size());
      for (int i = 0; i < internalNodes.length; i++) {
        InternalNode node = internalNodes[i];
        if (entitiesToRemove.contains(node.getLayoutEntity())) {
          entitiesToRemove.remove(node.getLayoutEntity());
        } else {
          updatedEntities.add(node);
        }
      }
      entitiesToRemove.clear();
View Full Code Here

      InternalRelationship relationship = relationshipsToConsider[i];
      List bendPoints = relationship.getBendPoints();
      if (bendPoints.size() > 0) {
        // We will assume that source/dest coordinates are for center of node
        BendPoint[] externalBendPoints = new BendPoint[bendPoints.size() + 2];
        InternalNode sourceNode = relationship.getSource();
        externalBendPoints[0] = new BendPoint(sourceNode.getInternalX(), sourceNode.getInternalY());
        InternalNode destNode = relationship.getDestination();
        externalBendPoints[externalBendPoints.length - 1] = new BendPoint(destNode.getInternalX(), destNode.getInternalY());

        for (int j = 0; j < bendPoints.size(); j++) {
          BendPoint bp = (BendPoint) bendPoints.get(j);
          externalBendPoints[j + 1] = new BendPoint(bp.x, bp.y, bp.getIsControlPoint());
        }
View Full Code Here

    InternalNode[] internalNodes = new InternalNode[nodes.length];
    BasicEntityConstraint basicEntityConstraint = new BasicEntityConstraint();
    for (int i = 0; i < nodes.length; i++) {
      basicEntityConstraint.clear();
      LayoutEntity externalNode = nodes[i];
      InternalNode internalNode = new InternalNode(externalNode);
      externalNode.populateLayoutConstraint(basicEntityConstraint);
      internalNode.setInternalLocation(externalNode.getXInLayout(), externalNode.getYInLayout());
      internalNodes[i] = internalNode;
    } // end of for
    return internalNodes;
  }
View Full Code Here

   */
  private InternalRelationship[] createInternalRelationships(LayoutRelationship[] rels) {
    ArrayList listOfInternalRelationships = new ArrayList(rels.length);
    for (int i = 0; i < rels.length; i++) {
      LayoutRelationship relation = rels[i];
      InternalNode src = (InternalNode) relation.getSourceInLayout().getLayoutInformation();
      InternalNode dest = (InternalNode) relation.getDestinationInLayout().getLayoutInformation();
      if ((src != null) && (dest != null)) {
        InternalRelationship internalRelationship = new InternalRelationship(relation, src, dest);
        listOfInternalRelationships.add(internalRelationship);
      } else {
        throw new RuntimeException("Error creating internal relationship, one of the nodes is null: src=" + src + ", dest=" + dest);
View Full Code Here

    double nodeSize = getNodeSize(entitiesToLayout);
    double halfNodeSize = nodeSize / 2;

    // Resize and shift nodes
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode node = entitiesToLayout[i];
      node.setInternalSize(nodeSize, nodeSize);
      node.setInternalLocation(node.getInternalX() + halfNodeSize, node.getInternalY() + halfNodeSize);
    }
  }
View Full Code Here

   */
  private void convertPositionsToPercentage(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle layoutBounds, boolean includeNodeSize) {

    // Adjust node positions and sizes
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode node = entitiesToLayout[i];
      DisplayIndependentPoint location = node.getInternalLocation().convertToPercent(layoutBounds);
      node.setInternalLocation(location.x, location.y);
      if (includeNodeSize) { // adjust node sizes
        double width = node.getInternalWidth() / layoutBounds.width;
        double height = node.getInternalHeight() / layoutBounds.height;
        node.setInternalSize(width, height);
      }
    }

    // Adjust bendpoint positions
    for (int i = 0; i < relationships.length; i++) {
View Full Code Here

   */
  private void convertPositionsToCoords(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle screenBounds) {

    // Adjust node positions and sizes
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode node = entitiesToLayout[i];
      double width = node.getInternalWidth() * screenBounds.width;
      double height = node.getInternalHeight() * screenBounds.height;
      DisplayIndependentPoint location = node.getInternalLocation().convertFromPercent(screenBounds);
      node.setInternalLocation(location.x - width / 2, location.y - height / 2);
      if (resizeEntitiesAfterLayout) {
        adjustNodeSizeAndPos(node, height, width);
      } else {
        node.setInternalSize(width, height);
      }
    }

    // Adjust bendpoint positions and shift based on source node size
    for (int i = 0; i < relationships.length; i++) {
View Full Code Here

    double rightSide = Double.MIN_VALUE;
    double bottomSide = Double.MIN_VALUE;
    double leftSide = Double.MAX_VALUE;
    double topSide = Double.MAX_VALUE;
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode entity = entitiesToLayout[i];
      if (entity.hasPreferredLocation()) {
        continue;
      }

      if (includeNodeSize) {
        leftSide = Math.min(entity.getInternalX() - entity.getInternalWidth() / 2, leftSide);
        topSide = Math.min(entity.getInternalY() - entity.getInternalHeight() / 2, topSide);
        rightSide = Math.max(entity.getInternalX() + entity.getInternalWidth() / 2, rightSide);
        bottomSide = Math.max(entity.getInternalY() + entity.getInternalHeight() / 2, bottomSide);
      } else {
        leftSide = Math.min(entity.getInternalX(), leftSide);
        topSide = Math.min(entity.getInternalY(), topSide);
        rightSide = Math.max(entity.getInternalX(), rightSide);
        bottomSide = Math.max(entity.getInternalY(), bottomSide);
      }
    }
    return new DisplayIndependentRectangle(leftSide, topSide, rightSide - leftSide, bottomSide - topSide);
  }
View Full Code Here

  private DisplayIndependentDimension getMinimumDistance(InternalNode[] entitiesToLayout) {
    DisplayIndependentDimension horAndVertdistance = new DisplayIndependentDimension(Double.MAX_VALUE, Double.MAX_VALUE);
    double minDistance = Double.MAX_VALUE; // the minimum distance between all the nodes
    //TODO: Very Slow!
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode layoutEntity1 = entitiesToLayout[i];
      double x1 = layoutEntity1.getInternalX();
      double y1 = layoutEntity1.getInternalY();
      for (int j = i + 1; j < entitiesToLayout.length; j++) {
        InternalNode layoutEntity2 = entitiesToLayout[j];
        double x2 = layoutEntity2.getInternalX();
        double y2 = layoutEntity2.getInternalY();
        double distanceX = Math.abs(x1 - x2);
        double distanceY = Math.abs(y1 - y2);
        double distance = Math.sqrt(Math.pow(distanceX, 2) + Math.pow(distanceY, 2));

        if (distance < minDistance) {
View Full Code Here

TOP

Related Classes of org.eclipse.zest.layouts.dataStructures.InternalNode

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.