Examples of ElementStyleSheet


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

      }

      final Element data = (Element) data1[0];

      // copy all styles ..
      final ElementStyleSheet styleSheet = data.getStyle();
      final StyleKey[] definedPropertyNamesArray = styleSheet.getDefinedPropertyNamesArray();

      final String elementType = data.getElementTypeName();
      final Object formatString = data.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING);

      final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
      for (Element element : visualElements)
      {
        final ElementMetaData metaData = element.getMetaData();
        final ElementStyleSheet elementStyleSheet = element.getStyle();

        final Object[] oldStyleData = new Object[StyleKey.getDefinedStyleKeyCount()];
        final Object[] newStyleData = new Object[StyleKey.getDefinedStyleKeyCount()];
        for (int j = 0; j < definedPropertyNamesArray.length; j++)
        {
          final StyleKey styleKey = definedPropertyNamesArray[j];
          if (styleKey == null)
          {
            continue;
          }
          final StyleMetaData styleDescr = metaData.getStyleDescription(styleKey);
          if (styleDescr == null)
          {
            // skip if the target element does not have that style ..
            continue;
          }

          if (isFiltered(styleKey, styleDescr))
          {
            continue;
          }
          oldStyleData[styleKey.identifier] = elementStyleSheet.getStyleProperty(styleKey, null);
          final Object newValue = styleSheet.getStyleProperty(styleKey);
          newStyleData[styleKey.identifier] = newValue;
          elementStyleSheet.setStyleProperty(styleKey, newValue);
        }

        final ReportAttributeMap<Object> oldAttributes = new ReportAttributeMap<Object>();
        final ReportAttributeMap<Object> newAttributes = new ReportAttributeMap<Object>();
        if (ObjectUtilities.equal(elementType, element.getElementTypeName()))
View Full Code Here

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

        return;
      }

      final ReportDocumentContext context = dragContext.getRenderContext();
      final Element visualElement = createElement(elementMetaData, fieldName, context);
      final ElementStyleSheet styleSheet = visualElement.getStyle();

      final double parentX = getParentX(band);
      final double parentY = getParentY(band);

      styleSheet.setStyleProperty(ElementStyleKeys.POS_X, new Float(Math.max(0, point.getX() - parentX)));
      styleSheet.setStyleProperty(ElementStyleKeys.POS_Y, new Float(Math.max(0, point.getY() - parentY)));

      postProcessDrop (visualElement, band, dragContext, point);

      dragContext.getRenderContext().getSelectionModel().setSelectedElements(new Object[]{visualElement});
View Full Code Here

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

    public void undo(final ReportDocumentContext renderContext)
    {
      final Element target = (Element) ModelUtility.findElementById(renderContext.getReportDefinition(), element);

      final ElementStyleSheet styleSheet = target.getStyle();
      final StyleKey[] keys = StyleKey.getDefinedStyleKeys();
      for (int i = 0; i < oldStyleData.length; i++)
      {
        final Object o = oldStyleData[i];
        if (o != null)
        {
          styleSheet.setStyleProperty(keys[i], o);
        }
      }

      final String[] namespaces = oldAttributes.getNameSpaces();
      for (int i = 0; i < namespaces.length; i++)
View Full Code Here

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

    public void redo(final ReportDocumentContext renderContext)
    {
      final Element target = (Element) ModelUtility.findElementById(renderContext.getReportDefinition(), element);

      final ElementStyleSheet styleSheet = target.getStyle();
      final StyleKey[] keys = StyleKey.getDefinedStyleKeys();
      for (int i = 0; i < newStyleData.length; i++)
      {
        final Object o = newStyleData[i];
        if (o != null)
        {
          styleSheet.setStyleProperty(keys[i], o);
        }
      }

      final String[] namespaces = newAttributes.getNameSpaces();
      for (int i = 0; i < namespaces.length; i++)
View Full Code Here

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

    boolean changed = false;
    final Element[] elements = getDataBackend().getData();
    for (int i = 0; i < elements.length; i++)
    {
      final Element element = elements[i];
      final ElementStyleSheet styleSheet = element.getStyle();
      final Object attribute = styleSheet.getStyleProperty(metaData.getStyleKey());
      if ((ObjectUtilities.equal(attribute, value)) == false)
      {
        changed = true;
      }
    }

    if (changed)
    {
      final ReportDocumentContext reportRenderContext = getReportRenderContext();
      if (reportRenderContext == null)
      {
        throw new IllegalStateException("No report render context? Thats bad.");
      }
      final UndoManager undo = reportRenderContext.getUndo();
      final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();

      for (int i = 0; i < elements.length; i++)
      {
        final Element element = elements[i];
        final ElementStyleSheet styleSheet = element.getStyle();
        final Object attribute = styleSheet.getStyleProperty(metaData.getStyleKey());
        undos.add(new StyleEditUndoEntry
            (element.getObjectID(), metaData.getStyleKey(), attribute, value));
        styleSheet.setStyleProperty(metaData.getStyleKey(), value);
      }
      undo.addChange(Messages.getString("StyleChange"), new CompoundUndoEntry((UndoEntry[]) undos.toArray(new UndoEntry[undos.size()])));
    }
    return changed;
  }
View Full Code Here

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

    boolean allInheritedKeys = true;
    final Element[] elements = dataBackend1.getData();
    if (elements.length > 0)
    {
      final Element element = elements[0];
      final ElementStyleSheet styleSheet = element.getStyle();
      final boolean localKey = styleSheet.isLocalKey(metaData.getStyleKey());
      allLocalKeys = allLocalKeys & localKey;
      allInheritedKeys = (localKey == false);
    }
    final Object retval;
    if (allLocalKeys == true && allInheritedKeys == true)
View Full Code Here

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

    {
      // Resize the element.
      final CachedLayoutData cachedLayoutData = ModelUtility.getCachedLayoutData(element);

      final double elementWidth = StrictGeomUtility.toExternalValue(cachedLayoutData.getWidth());
      final ElementStyleSheet styleSheet = element.getStyle();
      styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH, new Float(elementWidth * scaleFactor));

      // Reposition the element.
      final double origin = StrictGeomUtility.toExternalValue(cachedLayoutData.getX());
      final double destination = scaleFactor * origin;
      final int theShift = (int) (destination - origin);
View Full Code Here

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

  }


  protected void applyBorder(final BorderSelection borderSelection)
  {
    final ElementStyleSheet styleSheet = borderEditorPanel.getElementStyleSheet();
    if (BorderSelection.TOP.equals(borderSelection))
    {
      final Color color = (Color) colorSelectorBox.getSelectedItem();
      final Number width = (Number) borderWidth.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_COLOR, color);
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_STYLE, styleList.getSelectedValue());
    }
    else if (BorderSelection.LEFT.equals(borderSelection))
    {
      final Color color = (Color) colorSelectorBox.getSelectedItem();
      final Number width = (Number) borderWidth.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_LEFT_COLOR, color);
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_LEFT_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_LEFT_STYLE, styleList.getSelectedValue());
    }
    else if (BorderSelection.BOTTOM.equals(borderSelection))
    {
      final Color color = (Color) colorSelectorBox.getSelectedItem();
      final Number width = (Number) borderWidth.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_COLOR, color);
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_STYLE, styleList.getSelectedValue());
    }
    else if (BorderSelection.RIGHT.equals(borderSelection))
    {
      final Color color = (Color) colorSelectorBox.getSelectedItem();
      final Number width = (Number) borderWidth.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_RIGHT_COLOR, color);
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_RIGHT_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_RIGHT_STYLE, styleList.getSelectedValue());
    }
    else if (BorderSelection.TOP_LEFT.equals(borderSelection))
    {
      final Number width = (Number) cornerWidth.getValue();
      final Number height = (Number) cornerHeight.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_LEFT_RADIUS_HEIGHT, new Float(height.floatValue()));
    }
    else if (BorderSelection.TOP_RIGHT.equals(borderSelection))
    {
      final Number width = (Number) cornerWidth.getValue();
      final Number height = (Number) cornerHeight.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_TOP_RIGHT_RADIUS_HEIGHT, new Float(height.floatValue()));
    }
    else if (BorderSelection.BOTTOM_LEFT.equals(borderSelection))
    {
      final Number width = (Number) cornerWidth.getValue();
      final Number height = (Number) cornerHeight.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_LEFT_RADIUS_HEIGHT, new Float(height.floatValue()));
    }
    else if (BorderSelection.BOTTOM_RIGHT.equals(borderSelection))
    {
      final Number width = (Number) cornerWidth.getValue();
      final Number height = (Number) cornerHeight.getValue();
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_WIDTH, new Float(width.floatValue()));
      styleSheet.setStyleProperty(ElementStyleKeys.BORDER_BOTTOM_RIGHT_RADIUS_HEIGHT, new Float(height.floatValue()));
    }

    borderEditorPanel.repaint();
  }
View Full Code Here

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

      final Element element = selectedVisualElements[i];
      if (element instanceof RootLevelBand)
      {
        continue;
      }
      final ElementStyleSheet styleSheet = element.getStyle();
      final double definedElementX = styleSheet.getDoubleStyleProperty(ElementStyleKeys.POS_X, 0);

      // this is where I want the element on a global scale...
      final long targetPositionX = elementX[i] + dx;
      final Element parent = element.getParentSection();
      final CachedLayoutData parentData = ModelUtility.getCachedLayoutData(parent);
      final long layoutedParentX = parentData.getX();

      if (targetPositionX < layoutedParentX)
      {
        continue;
      }
      // this is what we used to apply to POS_X
      final long computedPositionX;
      if (definedElementX >= 0)
      {
        // absolute position; resolving is easy here
        final long snapPosition = horizontalSnapModel.getNearestSnapPosition(targetPositionX, element.getObjectID());
        if (Math.abs(snapPosition - targetPositionX) > snapThreshold)
        {
          computedPositionX = targetPositionX;
          final long localXPosition = Math.max(0, targetPositionX - layoutedParentX);
          final float position = (float) StrictGeomUtility.toExternalValue(localXPosition);
          styleSheet.setStyleProperty(ElementStyleKeys.POS_X, new Float(position));
        }
        else
        {
          computedPositionX = snapPosition;
          final long localXPosition = Math.max(0, snapPosition - layoutedParentX);
          final float position = (float) StrictGeomUtility.toExternalValue(localXPosition);
          styleSheet.setStyleProperty(ElementStyleKeys.POS_X, new Float(position));
        }
      }
      else
      {
        final long parentBase = parentData.getWidth();
        if (parentBase > 0)
        {
          // relative position; resolve the percentage against the width of the parent.
          final long snapPosition = horizontalSnapModel.getNearestSnapPosition(targetPositionX, element.getObjectID());
          if (Math.abs(snapPosition - targetPositionX) > snapThreshold)
          {
            computedPositionX = targetPositionX;
            final long localXPosition = Math.max(0, targetPositionX - layoutedParentX);
            // strict geometry: all values are multiplied by 1000
            // percentages in the engine are represented by floats betwen 0 and 100.
            final long percentage = StrictGeomUtility.toInternalValue(localXPosition * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_X,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
          else
          {
            computedPositionX = snapPosition;
            final long localXPosition = Math.max(0, snapPosition - layoutedParentX);
            // strict geometry: all values are multiplied by 1000
            // percentages in the engine are represented by floats betwen 0 and 100.
            final long percentage = StrictGeomUtility.toInternalValue(localXPosition * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_X,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
        }
        else
        {
          // we cannot handle this element.
          continue;
        }
      }

      final double elementMinWidth = styleSheet.getDoubleStyleProperty(ElementStyleKeys.MIN_WIDTH, 0);
      final long targetX2 = elementX[i] + elementWidth[i];
      if (elementMinWidth >= 0)
      {
        final long localWidth = Math.max(0, targetX2 - computedPositionX);
        final float position = (float) StrictGeomUtility.toExternalValue(localWidth);
        styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH, new Float(position));
      }
      else
      {
        final long parentBase = parentData.getWidth();
        if (parentBase > 0)
        {
          final long localWidth = Math.max(0, targetX2 - computedPositionX);
          // strict geometry: all values are multiplied by 1000
          // percentages in the engine are represented by floats betwen 0 and 100.
          final long percentage = StrictGeomUtility.toInternalValue(localWidth* 100 / parentBase);
          styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH,
              new Float(StrictGeomUtility.toExternalValue(-percentage)));
        }
      }

      element.notifyNodePropertiesChanged();
View Full Code Here

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

      final Element element = selectedVisualElements[i];
      if (element instanceof RootLevelBand)
      {
        continue;
      }
      final ElementStyleSheet styleSheet = element.getStyle();
      final double elementMinHeight = styleSheet.getDoubleStyleProperty(ElementStyleKeys.MIN_HEIGHT, 0);

      // this is where I want the element on a global scale...
      final long targetheight = elementHeight[i] + dy;

      final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
      final long elementY = data.getY();
      final long targetY2 = elementY + targetheight;

      if (elementMinHeight >= 0)
      {
        // absolute position; resolving is easy here
        final long snapPosition = verticalSnapModel.getNearestSnapPosition(targetY2, element.getObjectID());
        if (Math.abs(snapPosition - targetY2) > snapThreshold)
        {
          final long localHeight = Math.max(0, targetY2 - elementY);
          final float position = (float) StrictGeomUtility.toExternalValue(localHeight);
          styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(position));
        }
        else
        {
          final long localHeight = Math.max(0, snapPosition - elementY);
          final float position = (float) StrictGeomUtility.toExternalValue(localHeight);
          styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(position));
        }
      }
      else
      {

        final Element parent = element.getParentSection();
        final CachedLayoutData parentData = ModelUtility.getCachedLayoutData(parent);
        final long parentBase;
        if (isCanvasElement(parent))
        {
          parentBase = parentData.getHeight();
        }
        else
        {
          parentBase = parentData.getWidth();
        }
        if (parentBase > 0)
        {
          // relative position; resolve the percentage against the height of the parent.
          final long snapPosition = verticalSnapModel.getNearestSnapPosition(targetY2, element.getObjectID());
          if (Math.abs(snapPosition - targetY2) > snapThreshold)
          {
            final long localHeight = Math.max(0, targetY2 - elementY);
            // strict geometry: all values are multiplied by 1000
            // percentages in the engine are represented by floats betwen 0 and 100.
            final long percentage = StrictGeomUtility.toInternalValue(localHeight * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
          else
          {
            final long localHeight = Math.max(0, snapPosition - elementY);
            // strict geometry: all values are multiplied by 1000
            // percentages in the engine are represented by floats betwen 0 and 100.
            final long percentage = StrictGeomUtility.toInternalValue(localHeight * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
        }
      }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.