Package org.eclipse.zest.layouts.dataStructures

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


        if (children.size() == 0) {
            numLeaves = 1;
        } else {
      //TODO: SLOW!
            for (Iterator iter = children.iterator(); iter.hasNext();) {
                InternalNode childEntity = (InternalNode) iter.next();
              if (!seen.contains(childEntity)) {
                seen.add (childEntity);
                    int childEntityIndex = indexOfInternalNode(entities, childEntity);
                numLeaves += getNumberOfLeavesRecursive(childEntity, childEntityIndex, seen, entities);
              } else {
View Full Code Here


        }
        seen.add(layoutEntity);
    List parents = parentLists[i];
    int maxParentLevel = 0;
    for (Iterator iter = parents.iterator(); iter.hasNext();) {
      InternalNode parentEntity = (InternalNode) iter.next();
            int parentEntityIndex = indexOfInternalNode(entities, parentEntity);
            int parentLevel = getLevelRecursive(parentEntity, parentEntityIndex, seen, entities) + 1;
            maxParentLevel = Math.max(maxParentLevel, parentLevel);
    }
        return maxParentLevel;
View Full Code Here

     * @param nodeToFind
     * @return
     */
    private int indexOfInternalNode (InternalNode [] nodes, InternalNode nodeToFind) {
        for (int i = 0; i < nodes.length; i++) {
            InternalNode node = nodes[i];
            if (node.equals(nodeToFind)) {
                return i;
            }
        }
        throw new RuntimeException("Couldn't find index of internal node: " + nodeToFind);
    }
View Full Code Here

  protected void computeRadialPositions (InternalNode[] entities, DisplayIndependentRectangle bounds2) { //TODO TODO TODO
    DisplayIndependentRectangle bounds = new DisplayIndependentRectangle(getLayoutBounds(entities, true));
    bounds.height = bounds2.height;
    bounds.y = bounds2.y;
        for (int i = 0; i < entities.length; i++) {
            InternalNode entity = entities[i];
      double percentTheta = (entity.getInternalX() - bounds.x) / bounds.width;
      double distance = (entity.getInternalY() - bounds.y) / bounds.height;
      double theta = startDegree + Math.abs(endDegree - startDegree) * percentTheta;
      double newX = distance * Math.cos (theta);
      double newY = distance * Math.sin (theta);
     
      entity.setInternalLocation( newX, newY );
    }
  }
View Full Code Here

   * Find the center point between the roots
   */
  private DisplayIndependentPoint determineCenterPoint (List roots) {
    double totalX = 0, totalY = 0;
    for ( Iterator iterator = roots.iterator(); iterator.hasNext(); ) {
      InternalNode entity = (InternalNode)iterator.next();
      totalX += entity.getInternalX();
      totalY += entity.getInternalY();
    }
    return new DisplayIndependentPoint (totalX / roots.size(), totalY / roots.size());
  }
View Full Code Here

    }
   
    protected void postLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider) {
        // swap x->y and width->height
        for (int i = 0; i < entitiesToLayout.length; i++) {
            InternalNode entity = entitiesToLayout[i];
      entity.setInternalLocation(entity.getInternalY(), entity.getInternalX() );
      entity.setInternalSize( entity.getInternalWidth(), entity.getInternalHeight() );
        }
      super.postLayoutAlgorithm(entitiesToLayout, relationshipsToConsider);
    }
View Full Code Here

  protected void applyLayoutInternal(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double boundsX, double boundsY, double boundsWidth, double boundsHeight) {
    HashMap mapping = new HashMap(entitiesToLayout.length);
    DirectedGraph graph = new DirectedGraph();
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode internalNode = entitiesToLayout[i];
      Node node = new Node(internalNode);
      node.setSize(new Dimension(10, 10));
      mapping.put(internalNode, node);
      graph.nodes.add(node);
    }
    for (int i = 0; i < relationshipsToConsider.length; i++) {
      InternalRelationship relationship = relationshipsToConsider[i];
      Node source = (Node) mapping.get(relationship.getSource());
      Node dest = (Node) mapping.get(relationship.getDestination());
      Edge edge = new Edge(relationship, source, dest);
      graph.edges.add(edge);
    }
    DirectedGraphLayout directedGraphLayout = new ExtendedDirectedGraphLayout();
    directedGraphLayout.visit(graph);

    for (Iterator iterator = graph.nodes.iterator(); iterator.hasNext();) {
      Node node = (Node) iterator.next();
      InternalNode internalNode = (InternalNode) node.data;
      internalNode.setInternalLocation(node.x, node.y);
    }
    updateLayoutLocations(entitiesToLayout);
  }
View Full Code Here

      int i = 0;
      int width = (int) ((boundsWidth / 2) - currentRow.size() * 75);

      heightSoFar += ((InternalNode) currentRow.get(0)).getLayoutEntity().getHeightInLayout() + VSPACING * 8;
      while (iterator2.hasNext()) {
        InternalNode currentNode = (InternalNode) iterator2.next();

        double location = width + 10 * ++i;
        currentNode.setLocation(location, heightSoFar);
        width += currentNode.getLayoutEntity().getWidthInLayout();
      }
    }
  }
View Full Code Here

  private void addToRowList(InternalNode node, ArrayList list) {
    double layoutY = node.getLayoutEntity().getYInLayout();

    for (int i = 0; i < list.size(); i++) {
      List currentRow = (List) list.get(i);
      InternalNode currentRowNode = (InternalNode) currentRow.get(0);
      double currentRowY = currentRowNode.getLayoutEntity().getYInLayout();
      //double currentRowHeight = currentRowNode.getLayoutEntity().getHeightInLayout();
      if (layoutY >= (currentRowY - DELTA) && layoutY <= currentRowY + DELTA) {
        currentRow.add(node);
        //list.add(i, currentRow);
        return;
View Full Code Here

    graph.setDirection(PositionConstants.SOUTH);
    graph.setMargin(new Insets(20, 60, 20, 60));
    graph.setDefaultPadding(new Insets(30, 50, 30, 50));
   
    for (int i = 0; i < entitiesToLayout.length; i++) {
      InternalNode internalNode = entitiesToLayout[i];
      Node node = new Node(internalNode);
      node.setSize(new Dimension(10, 10));
      mapping.put(internalNode, node);
      graph.nodes.add(node);
    }
    for (int i = 0; i < relationshipsToConsider.length; i++) {
      InternalRelationship relationship = relationshipsToConsider[i];
      Node source = (Node) mapping.get(relationship.getSource());
      Node dest = (Node) mapping.get(relationship.getDestination());
      Edge edge = new Edge(relationship, source, dest);
      graph.edges.add(edge);
    }
    DirectedGraphLayout directedGraphLayout = new DirectedGraphLayout();
    directedGraphLayout.visit(graph);

    for (Iterator iterator = graph.nodes.iterator(); iterator.hasNext();) {
      Node node = (Node) iterator.next();
      InternalNode internalNode = (InternalNode) node.data;
      // For horizontal layout transpose the x and y coordinates
      if ((layout_styles & SWT.HORIZONTAL) == SWT.HORIZONTAL) {
        internalNode.setInternalLocation(node.y, node.x);
      } else {
        internalNode.setInternalLocation(node.x, node.y);
      }
    }
    updateLayoutLocations(entitiesToLayout);
    adjustHorizontalSpaces(graph);
  }
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.