Examples of InternalNode


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

    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

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

  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

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

  /**
   * Updates the layout locations so the external nodes know about the new locations
   */
  protected void updateLayoutLocations(InternalNode[] nodes) {
    for (int i = 0; i < nodes.length; i++) {
      InternalNode node = nodes[i];
      if (!node.hasPreferredLocation()) {
        node.setLocation(node.getInternalX(), node.getInternalY());

        if ((layout_styles & LayoutStyles.NO_LAYOUT_NODE_RESIZING) != 1) {
          // Only set the size if we are supposed to
          node.setSize(node.getInternalWidth(), node.getInternalHeight());
        }
      }
    }
  }
View Full Code Here

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

    public InternalComparator(Comparator externalComparator) {
      this.externalComparator = externalComparator;
    }

    public int compare(Object o1, Object o2) {
      InternalNode internalNode1 = (InternalNode) o1;
      InternalNode internalNode2 = (InternalNode) o2;

      return this.externalComparator.compare(internalNode1.getLayoutEntity(), internalNode2.getLayoutEntity());
    }
View Full Code Here

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

    if (unplacedEntities.size() == 0) {
      return; // no more entities to place
    }
   
    // get the first entity in the list of unplaced entities, find its root, and build this root's tree
    InternalNode layoutEntity = (InternalNode) unplacedEntities.get(0);
    InternalNode rootEntity = findRootObjectRecursive(layoutEntity, new HashSet(), relationships);
        int rootEntityIndex = indexOfInternalNode(entities, rootEntity);
    buildTreeRecursively(rootEntity, rootEntityIndex, 0, entities, relationships);
    roots.add(rootEntity);
   
    // now see which nodes are left to be placed in a tree somewhere
    List unmarkedCopy = new ArrayList(unplacedEntities);
    for (Iterator iter = unmarkedCopy.iterator(); iter.hasNext();) {
            InternalNode tmpEntity = (InternalNode) iter.next();
            int tmpEntityIndex = indexOfInternalNode(entities, tmpEntity);
            boolean isMarked = markedArr[tmpEntityIndex];
       if (isMarked) {
          unplacedEntities.remove(tmpEntity);
      }
View Full Code Here

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

  /**
   * Finds the root node that can be treated as the root of a tree.
   * The found root node should be one of the unmarked nodes.
   */
  private InternalNode findRootObjectRecursive(InternalNode currentEntity, Set seenAlready, InternalRelationship [] relationshipsToConsider) {
    InternalNode rootEntity = null;
    InternalRelationship rel = findRelationship(currentEntity, AS_DESTINATION, relationshipsToConsider);
    if (rel == null) {
      rootEntity = currentEntity;
    } else {
      InternalNode parentEntity = rel.getSource();
      if (!seenAlready.contains(parentEntity)) {
        seenAlready.add(parentEntity);
        rootEntity = findRootObjectRecursive(parentEntity, seenAlready, relationshipsToConsider);
      } else {
        rootEntity = currentEntity;
View Full Code Here

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

    // collect the children of this entity and put them in order
    Collection rels = findRelationships(layoutEntity, AS_SOURCE, relationships);
    List children = new ArrayList ();
    for (Iterator iter = rels.iterator(); iter.hasNext();) {
      InternalRelationship layoutRel = (InternalRelationship) iter.next();
      InternalNode childEntity = layoutRel.getDestination();
      children.add(childEntity);
    }
   
    if (comparator != null) {
      Collections.sort(children, comparator);
    } else {
            // sort the children by level, then by number of descendents, then by number of children
            // TODO: SLOW
        Collections.sort(children, new Comparator () {          
                public int compare(Object o1, Object o2) {
                    InternalNode node1 = (InternalNode) o1;
                    InternalNode node2 = (InternalNode) o2;
                    int [] numDescendentsAndLevel1 = new int [2];
                    int [] numDescendentsAndLevel2 = new int [2];
                    int level1 = numDescendentsAndLevel1[NUM_LEVELS_INDEX];
                    int level2 = numDescendentsAndLevel2[NUM_LEVELS_INDEX];
                    if (level1 == level2) {
                        getNumDescendentsAndLevel(node1, relationships, numDescendentsAndLevel1);
                        getNumDescendentsAndLevel(node2, relationships, numDescendentsAndLevel2);
                        int numDescendents1 = numDescendentsAndLevel1[NUM_DESCENDENTS_INDEX];
                        int numDescendents2 = numDescendentsAndLevel2[NUM_DESCENDENTS_INDEX];
                        if (numDescendents1 == numDescendents2) {
                            int numChildren1 = getNumChildren(node1, relationships);
                            int numChildren2 = getNumChildren(node1, relationships);
                            return numChildren2 - numChildren1;
                        } else {
                            return numDescendents2 - numDescendents1;
                        }
                    } else {
                        return level2 - level1;
                    }
                    //return getNumChildren(node2, relationships) - getNumChildren(node1, relationships);
                }          
            });
    }
   
    // map children to this parent, and vice versa
    for (Iterator iter = children.iterator(); iter.hasNext();) {
      InternalNode childEntity = (InternalNode) iter.next();
      int childEntityIndex = indexOfInternalNode(entities, childEntity);
      if (!childrenLists[i].contains(childEntity)) {
        childrenLists[i].add(childEntity);
      }
      if (!parentLists[childEntityIndex].contains(layoutEntity)) {
        parentLists[childEntityIndex].add(layoutEntity);
      }
    }
   
    for (Iterator iter = children.iterator(); iter.hasNext();) {
      InternalNode childEntity = (InternalNode) iter.next();
            int childEntityIndex = indexOfInternalNode(entities, childEntity);
      buildTreeRecursively(childEntity, childEntityIndex, weight + 1, entities, relationships);
    }
  }
View Full Code Here

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

        seenAlready.add(layoutEntity);
        numDescendentsAndLevel[NUM_LEVELS_INDEX] = Math.max(numDescendentsAndLevel[NUM_LEVELS_INDEX], currentLevel);
        Collection rels = findRelationships(layoutEntity, AS_SOURCE, relationships);
        for (Iterator iter = rels.iterator(); iter.hasNext();) {
            InternalRelationship layoutRel = (InternalRelationship) iter.next();
            InternalNode childEntity = layoutRel.getDestination();
            numDescendentsAndLevel[NUM_DESCENDENTS_INDEX]++;
            getNumDescendentsAndLevelRecursive(childEntity, relationships, seenAlready, numDescendentsAndLevel, currentLevel + 1);
           
        }
    }
View Full Code Here

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

    Collection rels = findRelationships(layoutEntity, AS_SOURCE, relationships);
   
   
    for (Iterator iter = rels.iterator(); iter.hasNext();) {
      InternalRelationship tmpRel = (InternalRelationship) iter.next();
      InternalNode tmpEntity = tmpRel.getDestination();
            int tmpEntityIndex = indexOfInternalNode(entities, tmpEntity);
      modifyWeightRecursively(tmpEntity, tmpEntityIndex, weight + 1, descendentsSeenSoFar, entities, relationships);
    }
  }
View Full Code Here

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

    if (children.isEmpty()) {
      result = weights[i];
    } else {
      //TODO: SLOW
            for (Iterator iter = children.iterator(); iter.hasNext();) {
                InternalNode childEntity = (InternalNode) iter.next();
                int childEntityIndex = indexOfInternalNode(entities, childEntity);
                result = Math.max(result, getMaxiumWeightRecursive(childEntity, childEntityIndex, seenAlready, entities));
      }
    }
    return result;
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.