Пример #1
0
  public void initialize() throws BirtException {
    createRoot();
    Color backgroundColor =
        PropertyUtil.getColor(
            pageContent.getComputedStyle().getProperty(StyleConstants.STYLE_BACKGROUND_COLOR));
    ReportDesignHandle designHandle = pageContent.getReportContent().getDesign().getReportDesign();
    IStyle style = pageContent.getStyle();

    String imageUrl =
        EmitterUtil.getBackgroundImageUrl(
            style,
            designHandle,
            pageContent.getReportContent().getReportContext() == null
                ? null
                : pageContent.getReportContent().getReportContext().getAppContext());
    if (backgroundColor != null || imageUrl != null) {
      boxStyle = new BoxStyle();
      boxStyle.setBackgroundColor(backgroundColor);
      if (imageUrl != null) {
        boxStyle.setBackgroundImage(createBackgroundImage(imageUrl));
      }
    }
    context.setMaxHeight(root.getHeight());
    context.setMaxWidth(root.getWidth());
    context.setMaxBP(root.getHeight());
    layoutHeader();
    layoutFooter();
    updateBodySize();
    context.setMaxHeight(body.getHeight());
    context.setMaxWidth(body.getWidth());
    context.setMaxBP(body.getHeight());
    maxAvaWidth = context.getMaxWidth();
    context.resetUnresolvedRowHints();
  }
Пример #2
0
 public int getLineHeight() {
   if (content != null) {
     IStyle contentStyle = content.getComputedStyle();
     return PropertyUtil.getLineHeight(contentStyle.getLineHeight());
   }
   return 0;
 }
Пример #3
0
  public IReportItemExecutor nextInline() throws BirtException {
    if (executor.hasNextChild()) {
      IReportItemExecutor nextExecutor = (IReportItemExecutor) executor.getNextChild();
      IContent nextContent = nextExecutor.execute();

      if (PropertyUtil.isInlineElement(nextContent)) {
        return new ItemExecutorWrapper(nextExecutor, nextContent);
      } else {
        this.childContent = nextContent;
        this.childExecutor = nextExecutor;
      }
    }
    return null;
  }
Пример #4
0
 public IReportItemExecutor getNextChild() throws BirtException {
   IReportItemExecutor ret = null;
   if (childContent != null) {
     ret = new ItemExecutorWrapper(childExecutor, childContent);
     childContent = null;
     childExecutor = null;
   } else {
     IReportItemExecutor childExecutor = executor.getNextChild();
     if (childExecutor != null) {
       IContent childContent = childExecutor.execute();
       if (childContent != null) {
         if (PropertyUtil.isInlineElement(childContent)) {
           ret =
               new LineStackingExecutor(
                   new ItemExecutorWrapper(childExecutor, childContent), this);
         } else {
           ret = new ItemExecutorWrapper(childExecutor, childContent);
         }
       }
     }
   }
   needUpdate = true;
   return ret;
 }
Пример #5
0
  protected BackgroundImageInfo createBackgroundImage(String url) {
    ResourceLocatorWrapper rl = null;
    ExecutionContext exeContext =
        ((ReportContent) content.getReportContent()).getExecutionContext();
    if (exeContext != null) {
      rl = exeContext.getResourceLocator();
    }
    IStyle cs = pageContent.getComputedStyle();
    BackgroundImageInfo backgroundImage =
        new BackgroundImageInfo(
            url, cs.getProperty(IStyle.STYLE_BACKGROUND_REPEAT), 0, 0, 0, 0, rl);
    Image img = backgroundImage.getImageInstance();

    IStyle style = pageContent.getStyle();
    String widthStr = style.getBackgroundWidth();
    String heightStr = style.getBackgroundHeight();

    if (img != null) {
      int resolutionX = img.getDpiX();
      int resolutionY = img.getDpiY();
      if (0 == resolutionX || 0 == resolutionY) {
        resolutionX = 96;
        resolutionY = 96;
      }
      float imageWidth = img.getPlainWidth() / resolutionX * 72 * PDFConstants.LAYOUT_TO_PDF_RATIO;
      float imageHeight =
          img.getPlainHeight() / resolutionY * 72 * PDFConstants.LAYOUT_TO_PDF_RATIO;
      int actualWidth = (int) imageWidth;
      int actualHeight = (int) imageHeight;

      if (widthStr != null && widthStr.length() > 0
          || heightStr != null && heightStr.length() > 0) {
        if ("contain".equals(widthStr) || "contain".equals(heightStr)) {
          float rh = imageHeight / height;
          float rw = imageWidth / width;
          if (rh > rw) {
            actualHeight = height;
            actualWidth = (int) (imageWidth * height / imageHeight);
          } else {
            actualWidth = width;
            actualHeight = (int) (imageHeight * width / imageWidth);
          }

        } else if ("cover".equals(widthStr) || "cover".equals(heightStr)) {
          float rh = imageHeight / height;
          float rw = imageWidth / width;
          if (rh > rw) {
            actualWidth = width;
            actualHeight = (int) (imageHeight * width / imageWidth);
          } else {
            actualHeight = height;
            actualWidth = (int) (imageWidth * height / imageHeight);
          }
        } else {
          DimensionType widthDim = DimensionType.parserUnit(widthStr);
          DimensionType heightDim = DimensionType.parserUnit(heightStr);
          if (widthDim != null) {
            actualWidth = PropertyUtil.getDimensionValue(content, widthDim);
            if (heightDim == null) {
              actualHeight = (int) (imageHeight * actualWidth / imageWidth);
            } else {
              actualHeight = PropertyUtil.getDimensionValue(content, heightDim);
            }
          } else if (heightDim != null) {
            actualHeight = PropertyUtil.getDimensionValue(content, heightDim);
            if (widthDim == null) {
              actualWidth = (int) (imageWidth * actualHeight / imageHeight);
            } else {
              actualWidth = PropertyUtil.getDimensionValue(content, widthDim);
            }
          } else {
            actualHeight = (int) imageHeight;
            actualWidth = (int) imageWidth;
          }
        }
      }

      backgroundImage.setXOffset(
          getDimensionValue(
              cs.getProperty(IStyle.STYLE_BACKGROUND_POSITION_X), width - actualWidth));
      backgroundImage.setYOffset(
          getDimensionValue(
              cs.getProperty(IStyle.STYLE_BACKGROUND_POSITION_Y), height - actualHeight));
      backgroundImage.setHeight(actualHeight);
      backgroundImage.setWidth(actualWidth);
      return backgroundImage;
    }
    return null;
  }