/**
   * Creates a new instance of the element. Override this method to return a concrete subclass of
   * the element.
   *
   * @return the newly generated instance of the element.
   */
  public Element createElement() {
    final Element element = new Element();
    applyElementName(element);
    applyStyle(element.getStyle());

    element.setElementType(new LineSparklineType());
    if (getContent() != null) {
      element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getContent());
    }
    if (getFieldname() != null) {
      element.setAttribute(
          AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname());
    }
    if (getFormula() != null) {
      final FormulaExpression formulaExpression = new FormulaExpression();
      formulaExpression.setFormula(getFormula());
      element.setAttributeExpression(
          AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression);
    }
    if (spacing != null) {
      element.setAttribute(
          SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, spacing);
    }
    return element;
  }
  /**
   * Creates the text field element.
   *
   * @return the generated text field element
   * @see org.pentaho.reporting.engine.classic.core.elementfactory.ElementFactory#createElement()
   */
  public Element createElement() {
    final Element element = new Element();
    applyElementName(element);
    applyStyle(element.getStyle());
    element.setElementType(new TextFieldType());
    if (getFieldname() != null) {
      element.setAttribute(
          AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname());
    }
    if (getFormula() != null) {
      final FormulaExpression formulaExpression = new FormulaExpression();
      formulaExpression.setFormula(getFormula());
      element.setAttributeExpression(
          AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression);
    }

    element.setAttribute(
        AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, getNullString());
    return element;
  }
예제 #3
0
  public void copyInto(final Element target) {
    final ElementMetaData metaData = getMetaData();
    final String[] attributeNamespaces = getAttributeNamespaces();
    for (int i = 0; i < attributeNamespaces.length; i++) {
      final String namespace = attributeNamespaces[i];
      final String[] attributeNames = getAttributeNames(namespace);
      for (int j = 0; j < attributeNames.length; j++) {
        final String name = attributeNames[j];
        final AttributeMetaData attributeDescription =
            metaData.getAttributeDescription(namespace, name);
        if (attributeDescription == null) {
          continue;
        }
        if (attributeDescription.isTransient()) {
          continue;
        }
        if (attributeDescription.isComputed()) {
          continue;
        }
        if (AttributeNames.Core.ELEMENT_TYPE.equals(name)
            && AttributeNames.Core.NAMESPACE.equals(namespace)) {
          continue;
        }
        target.setAttribute(namespace, name, getAttribute(namespace, name), false);
      }
    }

    final String[] attrExprNamespaces = getAttributeExpressionNamespaces();
    for (int i = 0; i < attrExprNamespaces.length; i++) {
      final String namespace = attrExprNamespaces[i];
      final String[] attributeNames = getAttributeExpressionNames(namespace);
      for (int j = 0; j < attributeNames.length; j++) {
        final String name = attributeNames[j];

        final AttributeMetaData attributeDescription =
            metaData.getAttributeDescription(namespace, name);
        if (attributeDescription == null) {
          continue;
        }
        if (attributeDescription.isTransient()) {
          continue;
        }
        target.setAttributeExpression(namespace, name, getAttributeExpression(namespace, name));
      }
    }

    final ElementStyleSheet styleSheet = getStyle();
    final StyleKey[] styleKeys = styleSheet.getDefinedPropertyNamesArray();
    for (int i = 0; i < styleKeys.length; i++) {
      final StyleKey styleKey = styleKeys[i];
      if (styleKey != null) {
        target.getStyle().setStyleProperty(styleKey, styleSheet.getStyleProperty(styleKey));
      }
    }

    final Set<Map.Entry<StyleKey, Expression>> styleExpressionEntries =
        getStyleExpressions().entrySet();
    for (final Map.Entry<StyleKey, Expression> entry : styleExpressionEntries) {
      target.setStyleExpression(entry.getKey(), entry.getValue());
    }
  }