public void resizeProportional() {
    final float originalPageWidth = originalPageDefinition.getWidth();
    final float currentPageWidth = currentPageDefinition.getWidth();
    final float scaleFactor = currentPageWidth / originalPageWidth;

    for (int i = 0; i < visualElements.length; i++) {

      // Resize the element.
      final CachedLayoutData cachedLayoutData = ModelUtility.getCachedLayoutData(visualElements[i]);

      final double elementWidth = StrictGeomUtility.toExternalValue(cachedLayoutData.getWidth());
      final Element theElement = visualElements[i];
      final ElementStyleSheet styleSheet = theElement.getStyle();
      styleSheet.setStyleProperty(
          ElementStyleKeys.MIN_WIDTH, new Float(elementWidth * scaleFactor));

      // Reposition the element.
      final double origin = StrictGeomUtility.toExternalValue(cachedLayoutData.getX());
      final double destination = scaleFactor * origin;
      final int theShift = (int) (destination - origin);

      final Element[] theElements = new Element[1];
      theElements[0] = theElement;
      align(theShift, theElements);
    }
    registerChanges();
  }
 public void alignRight() {
   final double theCurrentPageWidth = currentPageDefinition.getWidth();
   final int theShiftRight =
       (int) (theCurrentPageWidth - StrictGeomUtility.toExternalValue(computeFarRightPostion()));
   align(theShiftRight, visualElements);
   registerChanges();
 }
  public void alignCenter() {

    final long farLeftPostion = computeFarLeftPosition();
    final long farRightPostion = computeFarRightPostion();
    final long currentPageWidth =
        StrictGeomUtility.toInternalValue(currentPageDefinition.getWidth());
    final long remainingRightSpace = currentPageWidth - farRightPostion;
    final long normalizedSpace = (farLeftPostion + remainingRightSpace) / 2;

    long requiredShift = normalizedSpace - farLeftPostion;
    if (remainingRightSpace > farLeftPostion) {
      // move to the Right
      requiredShift = Math.abs(requiredShift);
    } else {
      // move to the Left
      requiredShift = 0 - Math.abs(requiredShift);
    }

    final int shiftInPoints = (int) StrictGeomUtility.toExternalValue(requiredShift);
    align(shiftInPoints, visualElements);
    registerChanges();
  }