/** * Triggers the visible state of the specified itemband element. If the named element was visible * at the last call, it gets now invisible and vice versa. This creates the effect, that an * element is printed every other line. * * @param event the current report event. */ private void triggerVisibleState(final ReportEvent event) { // avoid divide by zero exception if (numberOfElements == 0) { return; } if ((count % numberOfElements) == 0) { trigger = (!trigger); } count += 1; final ItemBand itemBand = event.getReport().getItemBand(); if (itemBand == null) { return; } if (element == null) { if (trigger) { itemBand.getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, visibleBackground); } else { itemBand .getStyle() .setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, invisibleBackground); } } else { final Element[] e = FunctionUtilities.findAllElements(itemBand, getElement()); if (e.length > 0) { for (int i = 0; i < e.length; i++) { if (trigger) { e[i].getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, visibleBackground); } else { e[i].getStyle() .setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, invisibleBackground); } } } else { if (warned == false) { RowBandingFunction.logger.warn( "The Band does not contain an element named " + getElement()); warned = true; } } } }
/** * Triggers the visible state of the specified itemband element. If the named element was visible * at the last call, it gets now invisible and vice versa. This creates the effect, that an * element is printed every other line. * * @param event the current report event. */ private void triggerVisibleStateCrosstab(final ReportEvent event) { if ((count % numberOfElements) == 0) { trigger = (!trigger); } count += 1; final CrosstabCellBody cellBody = event.getReport().getCrosstabCellBody(); if (cellBody == null) { return; } if (element == null) { final int elementCount = cellBody.getElementCount(); for (int i = 1; i < elementCount; i += 1) { final Element cell = cellBody.getElement(i); if (trigger) { cell.getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, visibleBackground); } else { cell.getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, invisibleBackground); } } } else { final Element[] e = FunctionUtilities.findAllElements(cellBody, getElement()); if (e.length > 0) { for (int i = 0; i < e.length; i++) { if (trigger) { e[i].getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, visibleBackground); } else { e[i].getStyle() .setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, invisibleBackground); } } } else { if (warned == false) { RowBandingFunction.logger.warn( "The cell-body does not contain an element named " + getElement()); warned = true; } } } }