protected void updatePageDimension(PageArea page) { if (page != null && page.getRoot().getChildrenCount() > 0) { int maxWidth = context.getMaxWidth(); int maxHeight = context.getMaxHeight(); int prefWidth = context.getPreferenceWidth(); // 0 int prefHeight = page.getBody().getHeight(); Iterator iter = page.getBody().getChildren(); while (iter.hasNext()) { AbstractArea area = (AbstractArea) iter.next(); prefWidth = Math.max(prefWidth, area.getAllocatedX() + area.getAllocatedWidth()); } if (prefHeight > maxHeight) { ((ContainerArea) page.getBody()).setHeight(prefHeight); floatingFooter(page); int deltaHeight = prefHeight - maxHeight; ContainerArea pageRoot = (ContainerArea) page.getRoot(); pageRoot.setHeight(pageRoot.getHeight() + deltaHeight); page.setHeight(pageContentHeight + deltaHeight); } if (prefWidth > maxWidth) { ((ContainerArea) page.getBody()).setWidth(prefWidth); int deltaWidth = prefWidth - maxWidth; ContainerArea pageRoot = (ContainerArea) page.getRoot(); pageRoot.setWidth(pageRoot.getWidth() + deltaWidth); page.setWidth(pageContentWidth + deltaWidth); } } }
private float calculatePageScale(PageArea page) { float scale = 1.0f; if (page != null && page.getRoot().getChildrenCount() > 0) { int maxWidth = context.getMaxWidth(); int maxHeight = context.getMaxHeight(); int prefWidth = context.getPreferenceWidth(); int prefHeight = body.getHeight(); Iterator iter = page.getBody().getChildren(); while (iter.hasNext()) { AbstractArea area = (AbstractArea) iter.next(); prefWidth = Math.max(prefWidth, area.getAllocatedX() + area.getAllocatedWidth()); } if (prefHeight > maxHeight) { ((ContainerArea) page.getBody()).setHeight(prefHeight); floatingFooter(page); } if (prefWidth > maxWidth || prefHeight > maxHeight) { scale = Math.min(maxWidth / (float) prefWidth, maxHeight / (float) prefHeight); } } return scale; }