Package org.eclipse.zest.layouts.dataStructures

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


   * Child classes should set flag reresizeEntitiesAfterLayout to false if they
   * want to preserve node sizes.
   */
  protected void defaultFitWithinBounds(InternalNode[] entitiesToLayout, InternalRelationship[] relationships, DisplayIndependentRectangle realBounds) {

    DisplayIndependentRectangle layoutBounds;

    if (resizeEntitiesAfterLayout) {
      layoutBounds = getLayoutBounds(entitiesToLayout, false);

      // Convert node x,y to be in percent rather than absolute coords
      convertPositionsToPercentage(entitiesToLayout, relationships, layoutBounds, false /*do not update size*/);

      // Resize and shift nodes
      resizeAndShiftNodes(entitiesToLayout);
    }

    // Recalculate layout, allowing for the node width, which we now know
    layoutBounds = getLayoutBounds(entitiesToLayout, true);

    // adjust node positions again, to the new coordinate system (still as a percentage)
    convertPositionsToPercentage(entitiesToLayout, relationships, layoutBounds, true /*update node size*/);

    DisplayIndependentRectangle screenBounds = calcScreenBounds(realBounds, layoutBounds);

    // Now convert to real screen coordinates
    convertPositionsToCoords(entitiesToLayout, relationships, screenBounds);
  }
View Full Code Here


   * @return
   */
  private DisplayIndependentRectangle calcScreenBounds(DisplayIndependentRectangle realBounds, DisplayIndependentRectangle layoutBounds) {
    if (resizeEntitiesAfterLayout) { // OK to alter aspect ratio
      double borderWidth = Math.min(realBounds.width, realBounds.height) / 10.0; // use 10% for the border - 5% on each side
      return new DisplayIndependentRectangle(realBounds.x + borderWidth / 2.0, realBounds.y + borderWidth / 2.0, realBounds.width - borderWidth, realBounds.height - borderWidth);
    } else { // retain layout aspect ratio
      double heightAdjustment = realBounds.height / layoutBounds.height;
      double widthAdjustment = realBounds.width / layoutBounds.width;
      double ratio = Math.min(heightAdjustment, widthAdjustment);
      double adjustedHeight = layoutBounds.height * ratio;
      double adjustedWidth = layoutBounds.width * ratio;
      double adjustedX = realBounds.x + (realBounds.width - adjustedWidth) / 2.0;
      double adjustedY = realBounds.y + (realBounds.height - adjustedHeight) / 2.0;
      double borderWidth = Math.min(adjustedWidth, adjustedHeight) / 10.0; // use 10% for the border - 5% on each side
      return new DisplayIndependentRectangle(adjustedX + borderWidth / 2.0, adjustedY + borderWidth / 2.0, adjustedWidth - borderWidth, adjustedHeight - borderWidth);
    }
  }
View Full Code Here

        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

       
    this.boundsHeight = height;
    this.boundsWidth = width;
    this.boundsX = x;
    this.boundsY = y;
    layoutBounds = new DisplayIndependentRectangle(boundsX, boundsY, boundsWidth, boundsHeight);
 
  }
View Full Code Here

 

  DisplayIndependentRectangle layoutBounds = null;
  protected void preLayoutAlgorithm(InternalNode[] entitiesToLayout, InternalRelationship[] relationshipsToConsider, double x, double y, double width, double height) {
    // TODO Auto-generated method stub
    layoutBounds = new DisplayIndependentRectangle(x, y, width, height);
    super.preLayoutAlgorithm(entitiesToLayout, relationshipsToConsider, x, y,
        width, height);
  }
View Full Code Here

   * Take the tree and make it round.  This is done by determining the location of each entity in terms
   * of its percentage in the tree layout.  Then apply that percentage to the radius and distance from
   * the center.
   */
  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;
View Full Code Here

   * of the screen, the nodes can proportionally be placed within the real bounds.
   * 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(
        Math.abs (layoutBounds.y + layoutBounds.height - centerPoint.y),
        Math.abs (centerPoint.y - layoutBounds.y));
    layoutBounds = new DisplayIndependentRectangle (centerPoint.x - maxDistanceX, centerPoint.y - maxDistanceY, maxDistanceX * 2, maxDistanceY * 2);
    return layoutBounds;
  }
View Full Code Here

    this.setBounds(x, y, width, height);

  }

  public synchronized DisplayIndependentRectangle getBounds() {
    return new DisplayIndependentRectangle(this.x, this.y, this.widht, this.height);
  }
View Full Code Here

    while (continueRunning()) {
      // check for entities and relationships to add or remove
      entitiesToLayout = updateEntities(entitiesToLayout);
      relationshipsToConsider = updateRelationships(relationshipsToConsider);
      DisplayIndependentRectangle bounds = this.getBounds();
      double localX = bounds.x;
      double localY = bounds.y;
      double localWidth = bounds.width;
      double localHeight = bounds.height;
View Full Code Here

TOP

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

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.