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(); }
private long computeFarRightPostion() { long theFarRightPostion = 0; for (int i = 0; i < visualElements.length; i++) { final CachedLayoutData theElementData = ModelUtility.getCachedLayoutData(visualElements[i]); final long theCurrentPosition = theElementData.getX() + theElementData.getWidth(); if (i == 0) { theFarRightPostion = theCurrentPosition; } else if (theCurrentPosition > theFarRightPostion) { theFarRightPostion = theCurrentPosition; } } return theFarRightPostion; }