protected boolean evaluateElement(final ReportElement e) {
    // only if needed ...
    configureDefaultBehaviour();

    if (ObjectUtilities.equal(e.getName(), getElement())) {
      final Color color = computeColor();
      if (defineBackground) {
        e.getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, color);
      } else {
        e.getStyle().setStyleProperty(ElementStyleKeys.PAINT, color);
      }
      return true;
    }
    return false;
  }
コード例 #2
0
  private static boolean isEmptyElement(
      final ReportElement band, final StyleSheet style, final OutputProcessorMetaData metaData) {
    if (isControlBand(style)) {
      return false;
    }

    if (metaData.isFeatureSupported(OutputProcessorFeature.STRICT_COMPATIBILITY)) {
      if (band instanceof Band) {
        final Band b = (Band) band;
        if (b.getElementCount() > 0) {
          return false;
        }
      }
    }

    if (BandStyleKeys.LAYOUT_AUTO.equals(style.getStyleProperty(BandStyleKeys.LAYOUT))) {
      // A auto-band is considered empty.
      return true;
    }

    // A band is not empty, if it has a defined minimum or preferred height
    if (isLengthDefined(ElementStyleKeys.HEIGHT, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.WIDTH, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.POS_Y, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.POS_X, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.MIN_HEIGHT, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.MIN_WIDTH, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_TOP, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_LEFT, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_BOTTOM, style)) {
      return false;
    }
    if (isLengthDefined(ElementStyleKeys.PADDING_RIGHT, style)) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_BOTTOM_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_TOP_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_LEFT_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (BorderStyle.NONE.equals(
            style.getStyleProperty(ElementStyleKeys.BORDER_RIGHT_STYLE, BorderStyle.NONE))
        == false) {
      return false;
    }
    if (style.getStyleProperty(ElementStyleKeys.BACKGROUND_COLOR) != null) {
      return false;
    }

    if (metaData.isExtraContentElement(band.getStyle(), band.getAttributes())) {
      return false;
    }
    return true;
  }