コード例 #1
0
  protected DRDesignStyle transformStyle(
      DRIReportStyle style, boolean textStyle, DefaultStyleType defaultStyleType)
      throws DRException {
    if (style == null) {
      return getDefaultStyle(defaultStyleType);
    }
    String styleName = style.hashCode() + "_" + textStyle;
    if (designStyles.containsKey(styleName)) {
      return designStyles.get(styleName);
    }

    DRDesignStyle designStyle = style(getStyle(style), textStyle, defaultStyleType);
    if (textStyle) {
      if (StyleResolver.getFontName(designStyle) == null) {
        designStyle.getFont().setFontName(accessor.getTemplateTransform().getDefaultFontName());
      }
      if (StyleResolver.getFontSize(designStyle) == null) {
        designStyle.getFont().setFontSize(accessor.getTemplateTransform().getDefaultFontSize());
      }
      if (StyleResolver.getFontBold(designStyle) == null) {
        designStyle.getFont().setBold(accessor.getTemplateTransform().getDefaultFontBold());
      }
      if (StyleResolver.getFontItalic(designStyle) == null) {
        designStyle.getFont().setItalic(accessor.getTemplateTransform().getDefaultFontItalic());
      }
      if (StyleResolver.getFontUnderline(designStyle) == null) {
        designStyle
            .getFont()
            .setUnderline(accessor.getTemplateTransform().getDefaultFontUnderline());
      }
      if (StyleResolver.getFontStrikeThrough(designStyle) == null) {
        designStyle
            .getFont()
            .setStrikeThrough(accessor.getTemplateTransform().getDefaultFontStrikeThrough());
      }
      if (StyleResolver.getPdfFontName(designStyle) == null) {
        designStyle
            .getFont()
            .setPdfFontName(accessor.getTemplateTransform().getDefaultFontPdfFontName());
      }
      if (StyleResolver.getPdfEncoding(designStyle) == null) {
        designStyle
            .getFont()
            .setPdfEncoding(accessor.getTemplateTransform().getDefaultFontPdfEncoding());
      }
      if (StyleResolver.getPdfEmbedded(designStyle) == null) {
        designStyle
            .getFont()
            .setPdfEmbedded(accessor.getTemplateTransform().getDefaultFontPdfEmbedded());
      }
    }
    addStyle(styleName, designStyle);
    return designStyle;
  }
コード例 #2
0
 protected DRIStyle getStyle(DRIReportStyle reportStyle) {
   if (reportStyle == null) {
     return null;
   }
   if (reportStyle instanceof DRIStyle) {
     return (DRIStyle) reportStyle;
   }
   if (reportStyle instanceof DRITemplateStyle) {
     String name = ((DRITemplateStyle) reportStyle).getName();
     DRIStyle style = templateStyles.get(name);
     if (style == null) {
       throw new DRDesignReportException("Template style " + name + " not found");
     }
     return style;
   }
   throw new DRDesignReportException(
       "Style " + reportStyle.getClass().getName() + " not supported");
 }