/** * */ protected JRBaseBand getBand(JRBand band) { JRBaseBand baseBand = null; if (band != null) { baseBand = (JRBaseBand)get(band); if (baseBand == null) { baseBand = new JRBaseBand(band, this); } } return baseBand; }
/** * */ protected JRBaseBand(JRBand band, JRBaseObjectFactory factory) { super(band, factory); height = band.getHeight(); splitTypeValue = band.getSplitTypeValue(); printWhenExpression = factory.getExpression(band.getPrintWhenExpression()); this.propertiesMap = JRPropertiesMap.getPropertiesClone(band); List<ExpressionReturnValue> bandReturnValues = band.getReturnValues(); if (bandReturnValues != null && !bandReturnValues.isEmpty()) { this.returnValues = new ArrayList<ExpressionReturnValue>(bandReturnValues.size()); for (ExpressionReturnValue bandReturnValue : bandReturnValues) { BaseExpressionReturnValue returnValue = factory.getReturnValue(bandReturnValue); this.returnValues.add(returnValue); } } }
/** * */ protected void writeSection( JRSection section, String sectionName, String sectionBandListGetterName) { if (section != null) { JRBand[] bands = section.getBands(); if (bands != null && bands.length > 0) { write( "//" + sectionName + "\n\n"); for(int i = 0; i < bands.length; i++) { writeBand( bands[i], sectionName + i); write( sectionBandListGetterName + ".add(" + i + ", " + sectionName + i + ");\n\n"); } } flush(); } }
private static int getBreakHeight(JRBand band) { int breakHeight = 0; if (band != null) { breakHeight = band.getHeight(); JRElement[] elements = band.getElements(); if ( SplitTypeEnum.IMMEDIATE == band.getSplitTypeValue() && elements != null && elements.length > 0 ) { for(int i = 0; i < elements.length; i++) { JRElement element = elements[i]; int bottom = element.getY() + element.getHeight(); breakHeight = bottom < breakHeight ? bottom : breakHeight; } } } return breakHeight; }
/** * */ protected JRFillBand getBand(JRBand band) { JRFillBand fillBand = null; if (band == null) { fillBand = filler.missingFillBand; } else { fillBand = (JRFillBand)get(band); if (fillBand == null) { fillBand = new JRFillBand(filler, band, this); } } return fillBand; }
private void createBoundElemementMaps() { createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_MASTER); createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_REPORT); createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_PAGE); createBoundElementMaps(JREvaluationTime.EVALUATION_TIME_COLUMN); if (groups != null) { for (int i = 0; i < groups.length; i++) { createBoundElementMaps(JREvaluationTime.getGroupEvaluationTime(groups[i].getName())); } } for (Iterator<JRBand> i = bands.iterator(); i.hasNext();) { JRFillBand band = (JRFillBand) i.next(); createBoundElementMaps(JREvaluationTime.getBandEvaluationTime(band)); } }
protected boolean inScope(PropertyMetadata propertyMetadata, JRElementGroup container) { if (container instanceof JRFrame) { return inScope(propertyMetadata, (JRElement) container); } List<PropertyScope> scopes = propertyMetadata.getScopes(); if (container instanceof JRBand) { return scopes.contains(PropertyScope.BAND); } if (container instanceof Cell) { return scopes.contains(PropertyScope.TABLE_CELL); } if (container instanceof JRCellContents) { return scopes.contains(PropertyScope.CROSSTAB_CELL); } return false; }
protected JRBand createDetailBand(List<FillColumn> fillColumns) { final JRDesignBand detailBand = new JRDesignBand(); detailBand.setSplitType(SplitTypeEnum.PREVENT); ReportBandInfo bandInfo = new ReportBandInfo(detailBand, BandTypeEnum.DETAIL.getName()); int xOffset = 0; for (FillColumn subcolumn : fillColumns) { DetailBandCreator subVisitor = new DetailBandCreator( bandInfo, subcolumn, xOffset, 0, 0); subVisitor.visit(); xOffset = subVisitor.xOffset; } setPdfTags(bandInfo, false); return detailBand; }
protected JRBand createGroupHeader(String groupName, List<FillColumn> fillColumns) { JRDesignBand header = new JRDesignBand(); header.setSplitType(SplitTypeEnum.PREVENT); ReportBandInfo bandInfo = new ReportBandInfo(header, BandTypeEnum.GROUP_HEADER + "-" + groupName); int xOffset = 0; for (FillColumn subcolumn : fillColumns) { GroupHeaderCreator subVisitor = new GroupHeaderCreator(groupName, bandInfo, subcolumn, xOffset, 0, 0); subVisitor.visit(); xOffset = subVisitor.xOffset; } setPdfTags(bandInfo, false); if (header.getHeight() == 0) { header = null; } return header; }
protected JRBand createGroupFooter(String groupName, List<FillColumn> fillColumns) { JRDesignBand footer = new JRDesignBand(); footer.setSplitType(SplitTypeEnum.PREVENT); ReportBandInfo bandInfo = new ReportBandInfo(footer, BandTypeEnum.GROUP_FOOTER + "-" + groupName); int xOffset = 0; for (FillColumn subcolumn : fillColumns) { GroupFooterCreator subVisitor = new GroupFooterCreator(groupName, bandInfo, subcolumn, xOffset, 0, 0); subVisitor.visit(); xOffset = subVisitor.xOffset; } setPdfTags(bandInfo, false); if (footer.getHeight() == 0) { footer = null; } return footer; }
private void setGroupBands(List<FillColumn> fillColumns) { TableReportGroup[] groups = mainDataset.getTableGroups(); if (groups != null) { for (TableReportGroup group : groups) { JRBand header = createGroupHeader(group.getName(), fillColumns); if (header != null) { group.setGroupHeader(header); } JRBand footer = createGroupFooter(group.getName(), fillColumns); if (footer != null) { group.setGroupFooter(footer); } } } }
/** * Gets the band location. * * @param b * the b * @param jd * the jd * @return the band location */ public static int getBandLocation(JRBand b, JasperDesign jd) { int yLocation = jd.getTopMargin(); List<JRBand> bands = ModelUtils.getBands(jd); for (JRBand tmpBand : bands) { // Detached background... if (tmpBand instanceof JRDesignBand) { if (((JRDesignBand) tmpBand).getOrigin().getBandTypeValue().equals(BandTypeEnum.BACKGROUND)) { // if (IReportManager.getInstance().isBackgroundSeparated()) // { // yLocation += jd.getTopMargin(); // yLocation += jd.getBottomMargin(); // yLocation += 40; // } } } if (tmpBand == b) return yLocation; yLocation += tmpBand.getHeight(); } return yLocation; }
public MBandGroup(ANode parent, JRDesignGroup jrGroup, JRBand jrband, BandTypeEnum bandtype, int newIndex){ super(parent, jrband, bandtype, newIndex); this.jrGroup = jrGroup; mGroup = new MGroup(null, jrGroup, -1); setChildListener(mGroup); mGroupBand = new MGroupBand(jrGroup); // Fix missing jasper configuration if (parent != null) { JasperReportsConfiguration jconfig = parent.getJasperConfiguration(); if (jconfig != null) { mGroup.setJasperConfiguration(jconfig); mGroupBand.setJasperConfiguration(jconfig); } } bandIndex = -1; refreshIndex(); }
private void doExecute() { int newInd = 0; List<JRBand> bList = jrDesignSection.getBandsList(); int oldInd = bList.indexOf(jrBand); if (oldInd == 0) oldUpperBand = null; else oldUpperBand = bList.get(oldInd-1); bList.remove(jrBand); if (newUpperBand != null){ newInd = bList.indexOf(newUpperBand) + 1; } if (newInd >= 0 && newInd < bList.size()) bList.add(newInd, jrBand); else { bList.add(jrBand); newInd = bList.size() - 1; } //This event will not change the listener on the model, but only changes its position jrDesignSection.getEventSupport().fireIndexedPropertyChange(MReport.CHANGE_BAND_POSITION, newInd, oldInd, -1); }
@Override public void undo() { List<JRBand> bList = jrDesignSection.getBandsList(); int oldInd = bList.indexOf(jrBand); int newInd = 0; bList.remove(jrBand); if (oldUpperBand != null){ newInd = bList.indexOf(oldUpperBand) + 1; } if (newInd >= 0 && newInd < bList.size()) bList.add(newInd, jrBand); else { bList.add(jrBand); newInd = bList.size() - 1; } //This event will not change the listener on the model, but only changes its position jrDesignSection.getEventSupport().fireIndexedPropertyChange(MReport.CHANGE_BAND_POSITION, newInd, oldInd, -1); }
/** * Handle the change of the position of a band * * @param evt the event that changed the band position */ private void handleChangeOrder(PropertyChangeEvent evt) { if (evt instanceof IndexedPropertyChangeEvent && evt.getNewValue() instanceof Integer) { JRDesignSection source = (JRDesignSection) evt.getSource(); int newInd = ((IndexedPropertyChangeEvent) evt).getIndex(); JRBand b = source.getBandsList().get(newInd); MBand mb = null; for (INode n : getChildren()) { if (n.getValue() == b) { mb = (MBand) n; break; } } if (mb != null) { newInd = getChildren().indexOf(mb) + (newInd - (Integer) evt.getOldValue()); getChildren().remove(mb); getChildren().add(newInd, mb); } } }
/** * Setup page figure. * * @param jd * the jasper design * @param figure2 * the figure2 */ protected void setupPageFigure(APageFigure figure2) { JasperDesign jd = getJasperDesign(); List<JRBand> bands = ModelUtils.getAllBands(jd); int dh = ModelUtils.getDesignHeight(bands); int designHeight = dh + jd.getTopMargin() + jd.getBottomMargin(); int w = jd.getPageWidth() + 20; int h = designHeight + 10; ReportPageFigure rpFig = (ReportPageFigure) figure2; rpFig.setBandsHeight(designHeight); setupPagePreferences(figure2); figure2.setSize(w, h); }
public void updateRullers() { JasperDesign jd = getJasperDesign(); List<JRBand> bands = ModelUtils.getAllBands(jd); int dh = ModelUtils.getDesignHeight(bands); int tx = jd.getLeftMargin() + ReportPageFigure.PAGE_BORDER.left; int ty = jd.getTopMargin() + ReportPageFigure.PAGE_BORDER.top; getViewer().setProperty(ReportRuler.PROPERTY_HOFFSET, tx); getViewer().setProperty(ReportRuler.PROPERTY_VOFFSET, ty); getViewer().setProperty(ReportRuler.PROPERTY_HEND, jd.getPageWidth() - jd.getLeftMargin() - jd.getRightMargin()); getViewer().setProperty(ReportRuler.PROPERTY_VEND, dh); getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ORIGIN, new Point(tx, ReportPageFigure.PAGE_BORDER.top + jd.getTopMargin())); }
public static int getBandLocation(JRBand b, JasperDesign jd) { int yLocation = jd.getTopMargin(); List<JRBand> bands = ModelUtils.getBands(jd); for (JRBand tmpBand : bands) { // Detached background... if (tmpBand instanceof JRDesignBand) { if (((JRDesignBand)tmpBand).getOrigin().getBandTypeValue() == BandTypeEnum.BACKGROUND) { if (IReportManager.getInstance().isBackgroundSeparated()) { yLocation += jd.getTopMargin(); yLocation += jd.getBottomMargin(); yLocation += 40; } } } if (tmpBand == b) return yLocation; yLocation += tmpBand.getHeight(); } return yLocation; }
public static JRBand bandOfElement(JRElement element, JasperDesign jd) { if (element == null || jd == null) return null; List<JRBand> bands = ModelUtils.getBands(jd); for (JRBand tmpBand : bands) { JRElement[] elements = tmpBand.getElements(); for (int i=0; i<elements.length; ++i) { if (element == elements[i]) { return tmpBand; } } } return null; }
/** * Check if an element is orphan or not. * An element is orphan when his parent is null, or if is null one of his ancestor parents */ public static boolean isOrphan(JRDesignElement element, JasperDesign jd) { JRElementGroup group = getTopElementGroup(element); if (group == null) return true; // Check if it belongs to this jasperdesign... if (group instanceof JRBand && !ModelUtils.getBands(jd).contains(group)) return true; // We should check if it the parent belongs for real to this report... if (group instanceof JRDesignCellContents) { // TODO check if this cell contents belongs to a crosstab in this report... JRDesignCellContents cell = (JRDesignCellContents)group; } return false; }
public WidgetAction.State mousePressed(Widget widget, WidgetAction.WidgetMouseEvent event) { if ((event.getModifiersEx () & MouseEvent.CTRL_DOWN_MASK) != 0 && ((ReportObjectScene)widget.getScene()).getSelectedObjects().size() > 0) { return WidgetAction.State.CONSUMED; } if (event.getButton() == MouseEvent.BUTTON1 && widget instanceof ReportObjectScene) { // find the correct band... JasperDesign jd = ((ReportObjectScene)widget).getJasperDesign(); if (jd != null) { JRBand band = ModelUtils.getBandAt( jd , event.getPoint()); // If the band is null, the document root is selected. IReportManager.getInstance().setSelectedObject(band); } } return WidgetAction.State.REJECTED; // let someone use it... }
public void addBandSeparatorWidget(JRBand b, int yLocation) { if (b == null) return; if (b instanceof JRDesignBand && ((JRDesignBand)b).getOrigin().getBandTypeValue() == BandTypeEnum.BACKGROUND) { ((JRDesignBand)b).getEventSupport().removePropertyChangeListener(JRDesignBand.PROPERTY_HEIGHT, this); if (IReportManager.getInstance().isBackgroundSeparated() && b.getHeight() == 0) { ((JRDesignBand)b).getEventSupport().addPropertyChangeListener(JRDesignBand.PROPERTY_HEIGHT, this); return; } } BandSeparatorWidget bbw = new BandSeparatorWidget(this, b); bbw.getActions().addAction( new BandMoveAction(true, InputEvent.SHIFT_DOWN_MASK) ); bbw.getActions().addAction( new BandMoveAction() ); bbw.getActions().addAction( new BandDblClickResizeAction()); bandSeparatorsLayer.addChild(bbw); bandLayer.addChild(new BandWidget(this, b)); }
public BandWidget(ReportObjectScene scene, JRBand band) { super(scene, Orientation.HORIZONTAL); this.band = band; // We set a border to improve the sensible area.... // setBorder( BorderFactory.createEmptyBorder(0, 3) ); // setCursor( Cursor.getPredefinedCursor( Cursor.S_RESIZE_CURSOR) ); // setForeground(ReportObjectScene.DESIGN_LINE_COLOR); // Add a listener to the band changes... if (band instanceof JRDesignBand) { ((JRDesignBand)band).getEventSupport().addPropertyChangeListener(this); } setToolTipText(ModelUtils.nameOf(band, scene.getJasperDesign())); updateBounds(); }
public BandSeparatorWidget(ReportObjectScene scene, JRBand b) { super(scene, Orientation.HORIZONTAL); this.band=b; // We set a border to improve the sensible area.... setBorder( BorderFactory.createEmptyBorder(0, 3) ); setCursor( Cursor.getPredefinedCursor( Cursor.S_RESIZE_CURSOR) ); setForeground(ReportObjectScene.DESIGN_LINE_COLOR); // Add a listener to the band changes... if (b instanceof JRDesignBand) { ((JRDesignBand)b).getEventSupport().addPropertyChangeListener(this); if (((JRDesignBand)b).getOrigin().getGroupName() != null) { String gname = ((JRDesignBand)b).getOrigin().getGroupName(); JRDesignGroup group = (JRDesignGroup) scene.getJasperDesign().getGroupsMap().get(gname); if (group != null) { group.getEventSupport().addPropertyChangeListener(JRDesignGroup.PROPERTY_NAME , this ); } } } updateBounds(); }
public boolean isValidPosition(JRDesignElementWidget elementWidget) { Rectangle bounds = getParentBounds(getJasperDesign(), elementWidget.getElement(), elementWidget); if (elementWidget.getElement().getElementGroup() instanceof JRBand) { return bounds.height >= elementWidget.getElement().getY() + elementWidget.getElement().getHeight(); } else { // Check that the element is fully contained inside its parent... return bounds.height >= elementWidget.getElement().getY() + elementWidget.getElement().getHeight() && elementWidget.getElement().getX() >= 0 && elementWidget.getElement().getY() >= 0 && bounds.width >= elementWidget.getElement().getX() + elementWidget.getElement().getWidth(); } }
@Override public List<JRDesignCrosstab> getCrosstabs() { if (documentReference != null && documentReference.get() != null) { // collect all the crosstabs... List<JRDesignCrosstab> list = new ArrayList<JRDesignCrosstab>(); // collect all the crosstabs... List<JRBand> bands = ModelUtils.getBands(documentReference.get()); for (JRBand band : bands) { if (band != null) { findCrosstabs( band, list); } } return list; } return Collections.EMPTY_LIST; }
public JRBand createTitle(final ReportInfo report, final String title) throws Exception { final JRDesignBand retval = new JRDesignBand(); retval.setHeight(93); final JRDesignTextField headerLine1 = h1("$P{report}.getInstitution()").toTextField(); addDesignElementTo(retval, headerLine1, 0, 0, 356, 30); final JRDesignStaticText headerLine2 = h5(title + " for # ").toStaticText(); addDesignElementTo(retval, headerLine2, 0, 31, 426, 24); final JRDesignTextField headerLine3 = h5("$P{report}.getTripId()").toTextField(); addDesignElementTo(retval, headerLine3, 275, 31, 146, 24); final JRDesignStaticText headerLine4 = h5("Purpose: ").toStaticText(); addDesignElementTo(retval, headerLine4, 0, 52, 100, 20); final JRDesignStaticText headerLine5 = h5("Dates: ").toStaticText(); addDesignElementTo(retval, headerLine5, 0, 72, 100, 20); final JRDesignTextField headerLine4Field1 = h5("$P{report}.getPurpose()").toTextField(); addDesignElementTo(retval, headerLine4Field1, 65, 52, 472, 20); final JRDesignTextField headerLine5Field1 = h5("$P{report}.getBeginDate()").toTextField(java.util.Date.class); addDesignElementTo(retval, headerLine5Field1, 45, 72, 75, 20); final JRDesignTextField headerLine5Field2 = h5("$P{report}.getEndDate()").toTextField(java.util.Date.class); addDesignElementTo(retval, headerLine5Field2, 150, 72, 75, 20); return retval; }
/** * Create a detail section in a {@link JasperReport}. Checks the {@link JasperReport} fields for a * {@link Detail} annotation and processes that {@link Detail} field. */ public JRBand createDetail(final Field subReport) throws Exception { final JRDesignBand retval = new JRDesignBand(); retval.setHeight(SUBREPORT_HEIGHT - 25); LOG.debug("Subreport Detail band has height of "+ retval.getHeight()); // In this case, we are creating a subreport and subreports have either a crosstab or not LOG.debug("Checking if "+ subReport+ " is a crosstab "+ isCrosstab(subReport)); if (isCrosstab(subReport)) { final JRDesignCrosstab crosstab = createCrosstab(); LOG.debug("Got crosstab of height "+ crosstab.getHeight()+ " and width "+ crosstab.getWidth()+ " adding to design of height "+ retval.getHeight()); retval.addElement(crosstab); } return retval; }
/** * Create a summary section in a {@link JasperReport}. Checks the {@link JasperReport} fields for a * {@link Summary} annotation and processes that {@link Summary} field. * * @return subreport is the {@link SubReport} {@link Field} * @return {@link JRBand} of the summary that goes into a subreport */ public JRBand createSummary(final Field subReport) throws Exception { final JRDesignBand retval = new JRDesignBand(); retval.setHeight(SUBREPORT_HEIGHT); LOG.debug("Summary band has height of "+ retval.getHeight()); // In this case, we are creating a subreport and subreports have either a crosstab or not LOG.debug("Checking if "+ subReport+ " is a crosstab "+ isCrosstab(subReport)); if (isCrosstab(subReport)) { final JRDesignCrosstab crosstab = createCrosstab(); LOG.debug("Got crosstab of height "+ crosstab.getHeight()+ " and width "+ crosstab.getWidth()+ " adding to design of height "+ retval.getHeight()); retval.addElement(crosstab); } return retval; }
/** * Constructs a header for the {@link JRDesignGroup} * * @return {@link JRBand} instance that is your header */ protected JRBand createGroupHeader(final ReportInfo report) { final JRDesignBand retval = new JRDesignBand(); retval.setHeight(PAGEHEADER_HEIGHT * 4); final JRDesignTextField expenseType = h4("$F{expenseType}").toTextField(); addDesignElementTo(retval, expenseType, 0, PAGEHEADER_HEIGHT, CT_HEADER_WIDTH, CELL_HEIGHT + 10); final JRDesignStaticText nameField = h5("Expense").toStaticText(); addDesignElementTo(retval, nameField, (CELL_WIDTH * 3 + 5) * 0, PAGEHEADER_HEIGHT * 2 + CELL_HEIGHT, CELL_WIDTH * 3, CELL_HEIGHT); final JRDesignStaticText dateField = h5("Date").toStaticText(); addDesignElementTo(retval, dateField, (CELL_WIDTH * 3 + 5) * 1, PAGEHEADER_HEIGHT * 2 + CELL_HEIGHT, CELL_WIDTH * 3, CELL_HEIGHT); final JRDesignStaticText amountField = h5("Amount").toStaticText(); addDesignElementTo(retval, amountField, (CELL_WIDTH * 3 + 5) * 2, PAGEHEADER_HEIGHT * 2 + CELL_HEIGHT, CELL_WIDTH * 3, CELL_HEIGHT); return retval; }
/** * */ public JRBand[] getAllBands() { List<JRBand> bands = new ArrayList<JRBand>(); addBand(title, bands); addBand(pageHeader, bands); addBand(columnHeader, bands); JRGroup[] groups = mainDataset.getGroups(); if (groups != null) { for (JRGroup group : groups) { addBands(group.getGroupHeaderSection(), bands); addBands(group.getGroupFooterSection(), bands); } } addBands(detailSection, bands); addBand(columnFooter, bands); addBand(pageFooter, bands); addBand(lastPageFooter, bands); addBand(summary, bands); addBand(noData, bands); return bands.toArray(new JRBand[bands.size()]); }
/** * */ private void addBand(JRBand band, List<JRBand> bands) { if (band != null) { bands.add(band); } }
/** * */ private void addBands(JRSection section, List<JRBand> bands) { if (section != null) { JRBand[] sectionBands = section.getBands(); if (sectionBands != null) { for (JRBand band : sectionBands) { addBand(band, bands); } } } }
/** * */ protected JRBaseSection(JRSection section, JRBaseObjectFactory factory) { factory.put(section, this); /* */ JRBand[] jrBands = section.getBands(); if (jrBands != null && jrBands.length > 0) { bands = new JRBand[jrBands.length]; for(int i = 0; i < jrBands.length; i++) { bands[i] = factory.getBand(jrBands[i]); } } /* */ JRPart[] jrParts = section.getParts(); if (jrParts != null && jrParts.length > 0) { parts = new JRPart[jrParts.length]; for(int i = 0; i < jrParts.length; i++) { parts[i] = factory.getPart(jrParts[i]); } } }
/** * */ private void addSection(JRSection section, boolean isColumnSection) { if (section != null) { JRBand[] bands = section.getBands(); if (bands != null && bands.length > 0) { for(int i = 0; i< bands.length; i++) { addBand(bands[i], isColumnSection); } } } }
/** * */ private void addBand(JRBand band, boolean isColumnBand) { if (band != null) { JRBasePrintFrame frame = new JRBasePrintFrame(null); frame.setX( isColumnBand && report.getColumnDirection() == RunDirectionEnum.RTL ? report.getPageWidth() - report.getRightMargin() - report.getColumnWidth() : report.getLeftMargin() ); frame.setY(offsetY); frame.setWidth( isColumnBand ? report.getColumnWidth() : report.getPageWidth() - report.getLeftMargin() - report.getRightMargin() ); frame.setHeight(band.getHeight()); band.visit(new ConvertVisitor(this, frame)); pageElements.add(frame); offsetY += band.getHeight(); addBandSeparator(offsetY); } }
/** * */ protected void writeSection(JRSection section) throws IOException { if (section != null) { JRBand[] bands = section.getBands(); if (bands != null && bands.length > 0) { if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_2)) { for(int i = 0; i < bands.length; i++) { writeBand(bands[i]); } } else { writeBand(bands[0]); } } if (isNewerVersionOrEqual(JRConstants.VERSION_6_0_0)) { JRPart[] parts = section.getParts(); if (parts != null && parts.length > 0) { for(int i = 0; i < parts.length; i++) { writePart(parts[i]); } } } } }
/** * */ private void writeBand(JRBand band) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_band); writer.addAttributePositive(JRXmlConstants.ATTRIBUTE_height, band.getHeight()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_2)) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_splitType, band.getSplitTypeValue()); } else { writer.addAttribute(JRXmlConstants.ATTRIBUTE_isSplitAllowed, band.getSplitTypeValue() != SplitTypeEnum.PREVENT, true); } if(isNewerVersionOrEqual(JRConstants.VERSION_4_8_0)) { writeProperties(band); } writeExpression(JRXmlConstants.ELEMENT_printWhenExpression, band.getPrintWhenExpression(), false); writeChildElements(band); if (isNewerVersionOrEqual(JRConstants.VERSION_6_1_1)) { List<ExpressionReturnValue> returnValues = band.getReturnValues(); if (returnValues != null && !returnValues.isEmpty()) { for (ExpressionReturnValue returnValue : returnValues) { writeReturnValue(returnValue); } } } writer.closeElement(); }
/** * */ private void writeBand( JRBand band, String bandName) { if(band != null) { write( "//band name = " + bandName +"\n\n"); write( "JRDesignBand " + bandName + " = new JRDesignBand();\n"); write( bandName + ".setHeight({0, number, #});\n", band.getHeight()); write( bandName + ".setSplitType({0});\n", band.getSplitTypeValue()); writeExpression( band.getPrintWhenExpression(), bandName, "PrintWhenExpression"); writeChildElements( band, bandName); List<ExpressionReturnValue> returnValues = band.getReturnValues(); if (returnValues != null && !returnValues.isEmpty()) { for (ListIterator<ExpressionReturnValue> it = returnValues.listIterator(); it.hasNext();) { ExpressionReturnValue returnValue = it.next(); String returnValueVarName = bandName + "ReturnValue" + it.previousIndex(); writeReturnValue(returnValue, returnValueVarName); write(bandName + ".addReturnValue(" + returnValueVarName + ");\n"); } } flush(); } }