@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); styleResolver = StyleResolver.getInstance(); if (detail != null) { detailSection = new JRBaseSection(detail); detail = null; } if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { whenNoDataTypeValue = WhenNoDataTypeEnum.getByValue(whenNoDataType); printOrderValue = PrintOrderEnum.getByValue(printOrder); orientationValue = OrientationEnum.getByValue(orientation); } }
/** * */ protected WhenNoDataTypeEnum getWhenNoDataType() { WhenNoDataTypeEnum result = whenNoDataType; if (result == null) { result = WhenNoDataTypeEnum.getByName( propertiesUtil.getProperty(mainDataset, JRReport.CONFIG_PROPERTY_WHEN_NO_DATA_TYPE) ); } return result; }
static JasperDesign createEmpty(String tablename, int pageWidth, int pageHeight, boolean margins) { JasperDesign ret = new JasperDesign(); ret.setName(Strings.removeExportIllegalChars(AppConstants.ORG_NAME + " - " + tablename)); ret.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL); ret.setWhenResourceMissingType(WhenResourceMissingTypeEnum.EMPTY); ret.setOrientation(OrientationEnum.LANDSCAPE); ret.setPageWidth(pageWidth); ret.setPageHeight(pageHeight); if (!margins) { ret.setLeftMargin(0); ret.setRightMargin(0); ret.setTopMargin(0); ret.setBottomMargin(0); } ret.setColumnWidth(Math.min(getAvailableWidth(ret), ret.getColumnWidth())); return ret; }
@Override public void setWhenNoDataType(WhenNoDataTypeEnum whenNoDataTypeValue) { Object old = this.whenNoDataTypeValue; this.whenNoDataTypeValue = whenNoDataTypeValue; getEventSupport().firePropertyChange(PROPERTY_WHEN_NO_DATA_TYPE, old, whenNoDataTypeValue); }
@Override public WhenNoDataTypeEnum getWhenNoDataTypeValue() { WhenNoDataTypeTableEnum whenNoDataType = table.getWhenNoDataType(); if (whenNoDataType == null) { whenNoDataType = WhenNoDataTypeTableEnum.getByName( propertiesUtil.getProperty( fillContext.getFillDataset(), TableComponent.CONFIG_PROPERTY_WHEN_NO_DATA_TYPE ) ); } switch (whenNoDataType) { case ALL_SECTIONS_NO_DETAIL : { return WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL; } case BLANK : default : { return WhenNoDataTypeEnum.NO_PAGES; } } }
@Override public List getTagList() { List tags = new java.util.ArrayList(); tags.add(new Tag(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL, I18n.getString("WhenNoDataTypeProperty.Property.All"))); tags.add(new Tag(WhenNoDataTypeEnum.BLANK_PAGE, I18n.getString("WhenNoDataTypeProperty.Property.Blank"))); tags.add(new Tag(WhenNoDataTypeEnum.NO_DATA_SECTION, I18n.getString("WhenNoDataTypeProperty.Property.Section"))); tags.add(new Tag(WhenNoDataTypeEnum.NO_PAGES, I18n.getString("WhenNoDataTypeProperty.Property.Pages"))); return tags; }
public static JasperReport getJasper(String file) throws JRException { // Jasper 5.1.0+ JasperReport jr = (JasperReport) JRLoader.loadObjectFromFile(file); // default is WHEN_NO_DATA_TYPE_BLANK_PAGE // we want to show something even no data found jr.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL); return jr; // JasperReport jr = (JasperReport) JRLoader.loadObject(file); // // default is WHEN_NO_DATA_TYPE_BLANK_PAGE // // we want to show something even no data found // jr.setWhenNoDataType(JasperReport.WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL); // return jr; }
@Override public WhenNoDataTypeEnum getWhenNoDataTypeValue() { return whenNoDataTypeValue; }
@Override public void setWhenNoDataType(WhenNoDataTypeEnum whenNoDataType) { throw new UnsupportedOperationException(); }
@SuppressWarnings("unchecked") public WhenNoDataTypeProperty(JasperDesign jasperDesign) { super(WhenNoDataTypeEnum.class, jasperDesign); this.jasperDesign = jasperDesign; }
@Override public Object getDefaultValue() { return WhenNoDataTypeEnum.NO_PAGES; }
@Override public void setPropertyValue(Object type) { jasperDesign.setWhenNoDataType((WhenNoDataTypeEnum)type); }
/** * replaces the header, footer, nodata band and dynamically adds user * friendly report parameter display to the report. * * @param designFile * @param template * @throws JRException */ private void replaceHeader(JasperDesign designFile, JasperDesign template) throws JRException { JRBand title = template.getTitle(); JRDesignBand newTitle = new JRDesignBand(); int margin = 50; designFile.setLeftMargin(margin); designFile.setRightMargin(margin); designFile.setTopMargin(margin); designFile.setBottomMargin(margin); double pageWidth = designFile.getPageWidth() + (margin * 2); double ratio = 0.75; // landscape if (designFile.getPageHeight() / pageWidth >= 1) { ratio = 1.5; // portrait } int pageHeight = (int) (pageWidth * ratio); designFile.setPageWidth((int) pageWidth); designFile.setPageHeight(pageHeight); int maxY = determineSizeOfTemplateBandAndReplaceTitlePlaceHolder(designFile, title, newTitle, margin); maxY += 2; mergeExistingTitleWithTemplateTitle(designFile, newTitle, maxY); JRBand footer = replaceFooterWithTemplateFooter(designFile, template, margin); designFile.setPageFooter(footer); JRDesignBand noDataBand = new JRDesignBand(); int noDataHeight = determineSizeOfTemplateBandAndReplaceTitlePlaceHolder(designFile, template.getNoData(), noDataBand, margin); designFile.setNoData(noDataBand); noDataBand.setHeight(noDataHeight); designFile.setWhenNoDataType(WhenNoDataTypeEnum.NO_DATA_SECTION); }
/** * Specifies the report behavior in case of empty datasources. */ public WhenNoDataTypeEnum getWhenNoDataTypeValue();
/** * Sets the report behavior in case of empty datasources. */ public void setWhenNoDataType(WhenNoDataTypeEnum whenNoDataType);