Package org.eclipse.zest.layouts.dataStructures

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


    double screenWidth = realBounds.width;
    double screenHeight = realBounds.height;
    DisplayIndependentRectangle layoutBounds = getLayoutBounds(entitiesToLayout, false);
    double localX = (x / screenWidth) * layoutBounds.width + layoutBounds.x;
    double localY = (y / screenHeight) * layoutBounds.height + layoutBounds.y;
    return new DisplayIndependentPoint(localX, localY);
  }
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++) {
      InternalRelationship rel = relationships[i];
      for (int j = 0; j < rel.getBendPoints().size(); j++) {
        BendPoint bp = (BendPoint) rel.getBendPoints().get(j);
        DisplayIndependentPoint toPercent = bp.convertToPercent(layoutBounds);
        bp.setX(toPercent.x);
        bp.setY(toPercent.y);
      }
    }
  }
View Full Code Here

    // 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++) {
      InternalRelationship rel = relationships[i];
      for (int j = 0; j < rel.getBendPoints().size(); j++) {
        BendPoint bp = (BendPoint) rel.getBendPoints().get(j);
        DisplayIndependentPoint fromPercent = bp.convertFromPercent(screenBounds);
        bp.setX(fromPercent.x);
        bp.setY(fromPercent.y);
      }
    }
  }
View Full Code Here

    double y = (layoutBounds.height == 0) ? 0 : (node.getInternalY() - layoutBounds.y) / layoutBounds.height;   
   
    x = screenBounds.x + x * screenBounds.width;
    y = screenBounds.y + y * screenBounds.height;
   
    return new DisplayIndependentPoint( x, y );
  }
View Full Code Here

   
   
    double x = (point.x/screenBounds.width) * layoutBounds.width + layoutBounds.x;
    double y = (point.y/screenBounds.height* layoutBounds.height + layoutBounds.y;
   
    return new DisplayIndependentPoint( x, y );
  }
View Full Code Here

   * The bounds can be determined either including the size of the nodes or not.  If the size
   * is not included, the bounds will only be guaranteed to include the center of each node.
   */
  protected DisplayIndependentRectangle getLayoutBounds (InternalNode[] entitiesToLayout, boolean includeNodeSize) {
    DisplayIndependentRectangle layoutBounds = super.getLayoutBounds(entitiesToLayout, includeNodeSize);
    DisplayIndependentPoint centerPoint = (roots != null) ? determineCenterPoint(roots) :
        new DisplayIndependentPoint (layoutBounds.x + layoutBounds.width / 2, layoutBounds.y + layoutBounds.height / 2);
    //  The center entity is determined in applyLayout
    double maxDistanceX = Math.max(
        Math.abs (layoutBounds.x + layoutBounds.width - centerPoint.x),
        Math.abs (centerPoint.x - layoutBounds.x));
    double maxDistanceY = Math.max(
View Full Code Here

    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

TOP

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

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.