Example #1
0
  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);
      }
    }
  }
Example #2
0
 protected void close(boolean isLastLine) throws BirtException {
   // TODO support specified height/width/alignment
   int contentWidth = currentIP;
   if (lineCount == 1) {
     if (specifiedWidth > contentWidth) {
       contentWidth = specifiedWidth;
     }
   }
   setContentWidth(contentWidth);
   int height = 0;
   Iterator iter = getChildren();
   while (iter.hasNext()) {
     AbstractArea child = (AbstractArea) iter.next();
     height = Math.max(height, child.getAllocatedHeight());
   }
   setContentHeight(height);
   updateBackgroundImage();
   if (children.size() > 0) {
     verticalAlign();
   }
   checkDisplayNone();
   if (isLastLine) {
     checkPageBreak();
     parent.add(this);
     parent.update(this);
     this.finished = true;
   } else {
     checkPageBreak();
     InlineContainerArea area = cloneArea();
     addToExtension(area);
     area.context = context;
     area.children = children;
     // update the pareant of all children
     Iterator childIter = area.children.iterator();
     while (childIter.hasNext()) {
       AbstractArea childArea = (AbstractArea) childIter.next();
       childArea.setParent(area);
     }
     area.setParent(parent);
     children = new ArrayList();
     parent.addChild(area);
     parent.update(area);
     /*setPosition( parent.currentIP + parent.getOffsetX( ), parent
     .getOffsetY( )
     + parent.currentBP );*/
     area.finished = true;
     currentIP = 0;
     height = 0;
   }
 }
Example #3
0
  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;
  }