Package org.pentaho.reporting.engine.classic.core.style

Examples of org.pentaho.reporting.engine.classic.core.style.ElementStyleSheet


      if (rlb.getSubReportCount() > 0)
      {
        return false;
      }
    }
    final ElementStyleSheet styleSheet = band.getStyle();
    if (isStyleSheetEmpty(styleSheet))
    {
      return true;
    }
    return false;
View Full Code Here


    {
      return false;
    }

    boolean retval = false;
    final ElementStyleSheet style = e.getStyle();
    for (final Map.Entry<StyleKey, Expression> entry : styleExpressions.entrySet())
    {
      final StyleKey key = entry.getKey();
      final Expression ex = entry.getValue();
      if (ex == null)
      {
        continue;
      }
      retval = true;
      ex.setRuntime(getRuntime());
      try
      {
        final Object value = evaluate(ex);
        if (value == null)
        {
          style.setStyleProperty(key, null);
        }
        else if (key.getValueType().isInstance(value))
        {
          style.setStyleProperty(key, value);
        }
        else if (value instanceof ErrorValue)
        {
          if (failOnErrors)
          {
            throw new InvalidReportStateException(String.format
                ("Failed to evaluate style-expression for key %s on element [%s]",// NON-NLS
                    key.getName(),
                    FunctionUtilities.computeElementLocation(e)));
          }
          style.setStyleProperty(key, null);
        }
        else
        {
          final ValueConverter valueConverter = ConverterRegistry.getInstance().getValueConverter(key.getValueType());
          if (valueConverter != null)
          {
            // try to convert it ..
            final Object o = ConverterRegistry.toPropertyValue(String.valueOf(value), key.getValueType());
            style.setStyleProperty(key, o);
          }
          else
          {
            style.setStyleProperty(key, null);
          }
        }
      }
      catch (InvalidReportStateException exception)
      {
        throw exception;
      }
      catch (Exception exception)
      {
        if (logger.isDebugEnabled())
        {
          logger.debug(String.format
              ("Failed to evaluate style expression for element '%s', style-key %s", // NON-NLS
                  e, key), exception);
        }
        if (failOnErrors)
        {
          throw new InvalidReportStateException(String.format
              ("Failed to evaluate style-expression for key %s on element [%s]",// NON-NLS
                  key.getName(),
                  FunctionUtilities.computeElementLocation(e)), exception);
        }
        // ignored, but we clear the style as we have no valid value anymore.
        style.setStyleProperty(key, null);
      }
      finally
      {
        ex.setRuntime(null);
      }
View Full Code Here

  protected boolean evaluateElement(final ReportElement e)
  {
    final DataSource source = e.getElementType();
    if (source instanceof RawDataSource)
    {
      final ElementStyleSheet style = e.getStyle();
      final String oldFormat = (String)
          style.getStyleProperty(ElementStyleKeys.EXCEL_DATA_FORMAT_STRING);
      if (oldFormat != null && oldFormat.length() > 0)
      {
        final Object attribute = e.getAttribute
            (AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.EXCEL_CELL_FORMAT_AUTOCOMPUTE);
        if (Boolean.TRUE.equals(attribute) == false)
        {
          return false;
        }
      }
      final RawDataSource rds = (RawDataSource) source;
      if (formatSpecification != null)
      {
        formatSpecification.redefine(FormatSpecification.TYPE_UNDEFINED, null);
      }
      formatSpecification = rds.getFormatString(getRuntime(), e, formatSpecification);
      if (formatSpecification != null)
      {
        if (formatSpecification.getType() == FormatSpecification.TYPE_DATE_FORMAT ||
            formatSpecification.getType() == FormatSpecification.TYPE_DECIMAL_FORMAT)
        {
          style.setStyleProperty
              (ElementStyleKeys.EXCEL_DATA_FORMAT_STRING, formatSpecification.getFormatString());
          e.setAttribute
              (AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.EXCEL_CELL_FORMAT_AUTOCOMPUTE,
                  Boolean.TRUE);
          return true;
View Full Code Here

              ElementAlignment.class, context);
      final ElementAlignment vAlign = (ElementAlignment) attributes.getMetaAttribute
          (MetaAttributeNames.Style.NAMESPACE, MetaAttributeNames.Style.VERTICAL_ALIGNMENT, ElementAlignment.class,
              context);

      final ElementStyleSheet styleSheet = e.getStyle();
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_VALIGNMENT)))
      {
        styleSheet.setStyleProperty(ElementStyleKeys.VALIGNMENT, vAlign);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_ALIGNMENT)))
      {
        if (hAlign != null)
        {
          styleSheet.setStyleProperty(ElementStyleKeys.ALIGNMENT, hAlign);
        }
        else
        {
          if (LabelType.INSTANCE.getMetaData().getName().equals(typeName) == false &&
              ResourceLabelType.INSTANCE.getMetaData().getName().equals(typeName) == false)
          {
            styleSheet.setStyleProperty(ElementStyleKeys.ALIGNMENT, computeAlignment(attributes, context));
          }
        }
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_BACKGROUND_COLOR)))
      {
        styleSheet.setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, bgColor);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_COLOR)))
      {
        styleSheet.setStyleProperty(ElementStyleKeys.PAINT, textColor);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_FONTFAMILY)))
      {
        styleSheet.setStyleProperty(TextStyleKeys.FONT, font);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_FONTSIZE)))
      {
        styleSheet.setStyleProperty(TextStyleKeys.FONTSIZE, fontSize);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_UNDERLINE)))
      {
        styleSheet.setStyleProperty(TextStyleKeys.UNDERLINED, underline);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_BOLD)))
      {
        styleSheet.setStyleProperty(TextStyleKeys.BOLD, bold);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_STRIKETHROUGH)))
      {
        styleSheet.setStyleProperty(TextStyleKeys.STRIKETHROUGH, strikethrough);
      }
      if (isMetaStylingEnabled(e.getAttributes().getAttribute
          (AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE_STYLE_ITALICS)))
      {
        styleSheet.setStyleProperty(TextStyleKeys.ITALIC, italic);
      }
    }

    final boolean legacyMode = isLegacyMode();
    if (Boolean.TRUE.equals(allowAttributesFlag) &&
View Full Code Here

    {
      final HashMap<String, ElementStyleSheet> report = (HashMap<String, ElementStyleSheet>)
          getRootHandler().getHelperObject(ReportParserUtil.HELPER_OBJ_LEGACY_STYLES);
      if (report != null)
      {
        final ElementStyleSheet existingStyleSheet = report.get(styleClass);
        if (existingStyleSheet != null)
        {
          element.getStyle().addDefault(existingStyleSheet);
        }
      }
View Full Code Here

    {
      throw new ParseException
          ("Required attribute 'name' is missing.",
              getRootHandler().getDocumentLocator());
    }
    final ElementStyleSheet parent = styleSheetCollection.get(name);
    if (parent == null)
    {
      throw new ParseException
          ("Specified parent stylesheet is not defined.",
              getRootHandler().getDocumentLocator());
View Full Code Here

      if (name == null)
      {
        throw new ParseException
            ("Required attribute 'name' is missing.", getLocator());
      }
      styleSheet = new ElementStyleSheet();
      styleSheetCollection.put (name, styleSheet);
    }

    final ElementStyleSheetObjectDescription objectDescription =
        (ElementStyleSheetObjectDescription) getObjectDescription();
View Full Code Here

    }

    final int ruleCount = styleDefinition.getRuleCount();
    for (int r = 0; r < ruleCount; r += 1)
    {
      final ElementStyleSheet rule = styleDefinition.getRule(r);
      if (rule instanceof ElementStyleRule)
      {
        final ElementStyleRule styleRule = (ElementStyleRule) rule;
        writeStyleRule(writer, styleRule);
      }
View Full Code Here

    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource loaded = mgr.createDirectly(resource, ElementStyleDefinition.class);
    final ElementStyleDefinition style = (ElementStyleDefinition) loaded.getResource();
    assertEquals(1, style.getRuleCount());
    final ElementStyleSheet rule = style.getRule(0);
    assertNotNull(rule);

    assertEquals("Arial", rule.getStyleProperty(TextStyleKeys.FONT));
  }
View Full Code Here

    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource loaded = mgr.createDirectly(resource, ElementStyleDefinition.class);
    final ElementStyleDefinition style = (ElementStyleDefinition) loaded.getResource();
    assertEquals(1, style.getRuleCount());
    final ElementStyleSheet rule = style.getRule(0);
    assertNotNull(rule);

    rule.setStyleProperty(TextStyleKeys.ITALIC, Boolean.TRUE);

    final ByteArrayOutputStream bout = new ByteArrayOutputStream();

    final StyleDefinitionWriter writer = new StyleDefinitionWriter();
    writer.write(bout, style);

    Resource parsed = mgr.createDirectly(bout.toByteArray(), ElementStyleDefinition.class);
    final ElementStyleDefinition parsedStyle = (ElementStyleDefinition) parsed.getResource();

    assertEquals(1, parsedStyle.getRuleCount());
    final ElementStyleSheet parsedRule = parsedStyle.getRule(0);
    assertNotNull(parsedRule);
    assertEquals(Boolean.TRUE, rule.getStyleProperty(TextStyleKeys.ITALIC));
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.style.ElementStyleSheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.