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

Examples of org.pentaho.reporting.engine.classic.core.ReportAttributeMap


  private RenderBox processTextEllipseNormal(final RenderBox box, final long x2, String reslit)
  {
    final StyleSheet style = box.getStyleSheet();

    final RenderBox textEllipse = (RenderBox) box.derive(false);
    final ReportAttributeMap map = box.getAttributes();
    final TextCache.Result result = textCache.get
        (style.getId(), style.getChangeTracker(), map.getChangeTracker(), reslit);
    if (result != null)
    {
      textEllipse.addGeneratedChilds(result.getText());
      textEllipse.addGeneratedChilds(result.getFinish());
      performTextEllipseLayout(textEllipse, x2);
      return textEllipse;
    }
    if (buffer != null)
    {
      buffer.setCursor(0);
    }

    buffer = Utf16LE.getInstance().decodeString(reslit, buffer);
    bufferArray = buffer.getBuffer(bufferArray);

    textFactory.startText();
    final RenderNode[] renderNodes = textFactory.createText
        (bufferArray, 0, buffer.getLength(), style, box.getElementType(), box.getInstanceId(), map);
    final RenderNode[] finishNodes = textFactory.finishText();

    textEllipse.addGeneratedChilds(renderNodes);
    textEllipse.addGeneratedChilds(finishNodes);
    textCache.store(style.getId(), style.getChangeTracker(),
        map.getChangeTracker(), reslit, style, map, renderNodes, finishNodes);
    performTextEllipseLayout(textEllipse, x2);
    return textEllipse;
  }
View Full Code Here


      throw new NullPointerException();
    }

    this.name = name;
    this.valueType = valueType;
    this.attributeMap = new ReportAttributeMap();
    setRole(ParameterAttributeNames.Core.ROLE_USER_PARAMETER);
  }
View Full Code Here

          final Object newValue = styleSheet.getStyleProperty(styleKey);
          newStyleData[styleKey.identifier] = newValue;
          elementStyleSheet.setStyleProperty(styleKey, newValue);
        }

        final ReportAttributeMap oldAttributes = new ReportAttributeMap();
        final ReportAttributeMap newAttributes = new ReportAttributeMap();
        if (ObjectUtilities.equal(elementType, element.getElementTypeName()))
        {
          final Object attribute =
              element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING);
          oldAttributes.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, attribute);
          newAttributes.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, formatString);

          element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, formatString);
        }

        final PasteFormatUndoEntry undoEntry =
View Full Code Here

      if (ObjectUtilities.equal(visualElement.getElementTypeName(), targetElementType.getMetaData().getName()))
      {
        continue;
      }

      final ReportAttributeMap oldAttributes = visualElement.getAttributes();

      final ElementMetaData data = visualElement.getMetaData();
      final AttributeMetaData[] datas = data.getAttributeDescriptions();
      for (int j = 0; j < datas.length; j++)
      {
        final AttributeMetaData metaData = datas[j];
        final AttributeMetaData attributeMetaData =
            targetMetaData.getAttributeDescription(metaData.getNameSpace(), metaData.getName());
        if (attributeMetaData == null)
        {
          visualElement.setAttribute(metaData.getNameSpace(), metaData.getName(), null);
          visualElement.setAttributeExpression(metaData.getNameSpace(), metaData.getName(), null);
        }
      }

      visualElement.setElementType(targetElementType);

      // -------------------- manipulate the value and field attributes so that we preserve as much as possible ---------------------  
      // get the source and destination types
      final ElementType srcType = (ElementType) oldAttributes.getAttribute(CORE_NAMESPACE, ELEMENT_TYPE_ATTRIBUE);
      // Check if the source-type is a message field. In that case, we have to map the pattern into a field and
      // format definition
      if (srcType instanceof MessageType)
      {
        final String message = (String) oldAttributes.getAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE);
        visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, null);
        try
        {

          final MessageFormatSupport fmt = new MessageFormatSupport();
          fmt.setFormatString(message);
          final String rawFormat = fmt.getCompiledFormat();
          final MessageFormat msg = new MessageFormat(rawFormat);
          final Format[] subFormats = msg.getFormats();

          if (targetElementType instanceof DateFieldType)
          {
            final int sdf = findFirstDateFormat(subFormats);
            if (sdf != -1)
            {
              final SimpleDateFormat df = (SimpleDateFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else if (targetElementType instanceof NumberFieldType)
          {
            final int sdf = findFirstNumberFormat(subFormats);
            if (sdf != -1)
            {
              final DecimalFormat df = (DecimalFormat) subFormats[sdf];

              final String[] fields = fmt.getFields();
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[sdf]);
              visualElement.setAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE, df.toPattern());
            }
          }
          else
          {
            final String[] fields = fmt.getFields();
            if (fields.length > 0)
            {
              visualElement.setAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE, fields[0]);
            }
            else
            {
              visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, message);
            }
          }
        }
        catch (Exception ex)
        {
          visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, message);
        }
      }
      else if (targetElementType instanceof MessageType)
      {
        // validate that these are the correct combination to use this enhanced morphing.
        // This stuff only applies if we're morphing TO a Message Type field
        final String srcField = (String) oldAttributes.getAttribute(CORE_NAMESPACE, FIELD_ATTRIBUTE); // and morphing FROM Number, Date, or Text Type field
        final String formatString = (String) oldAttributes.getAttribute(CORE_NAMESPACE, FORMAT_ATTRIBUTE);
        final StringBuffer buffer = new StringBuffer();
        buffer.append("$(").append(srcField); //$NON-NLS-1$
        if (srcType instanceof NumberFieldType)
        {
          buffer.append(", number"); //$NON-NLS-1$
          if (formatString != null && formatString.length() > 0)
          {
            buffer.append(", ").append(formatString); //$NON-NLS-1$
          }
        }
        else if (srcType instanceof DateFieldType)
        {
          buffer.append(", date"); //$NON-NLS-1$
          if (formatString != null && formatString.length() > 0)
          {
            buffer.append(", ").append(formatString); //$NON-NLS-1$
          }
        }
        buffer.append(")"); //$NON-NLS-1$
        visualElement.setAttribute(CORE_NAMESPACE, VALUE_ATTRIBUTE, buffer.toString());
      }

      final ReportAttributeMap newAttributes = visualElement.getAttributes();
      undos.add(new MorphUndoEntry(visualElement.getObjectID(), oldAttributes, newAttributes));
    }

    getActiveContext().getUndo().addChange(ActionMessages.getString("MorphAction.UndoName"),
        new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.ReportAttributeMap

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.