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

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 elementX = styleSheet.getDoubleStyleProperty(ElementStyleKeys.POS_X, 0);
      final double elementY = styleSheet.getDoubleStyleProperty(ElementStyleKeys.POS_Y, 0);

      final Element parent = element.getParentSection();
      if (parent == null)
      {
        throw new IllegalStateException("Parent has been removed, but the drag operation was not finished: " + element);
      }
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(parent);
      final long layoutedParentX = data.getX() + data.getPaddingX();
      final long layoutedParentY = data.getY() + data.getPaddingY();

      // this is where I want the element on a global scale...
      final long targetPositionX = elementXCoords[i] + dx;
      final long targetPositionY = elementYCoords[i] + dy;

      if (elementX >= 0)
      {
        // absolute position; resolving is easy here
        final long snapPosition = horizontalSnapModel.getNearestSnapPosition
            (targetPositionX, element.getObjectID());
        if (Math.abs(snapPosition - targetPositionX) > snapThreshold)
        {
          final long targetPositionX2 = targetPositionX + elementWidth[i];
          final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition
              (targetPositionX2, element.getObjectID());
          if (Math.abs(snapPosition2 - targetPositionX2) < snapThreshold)
          {
            // snapping to the right border..
            final long snapX = snapPosition2 - elementWidth[i];
            final long localXPosition = Math.max(0, snapX - layoutedParentX);
            final float position = (float) StrictGeomUtility.toExternalValue(localXPosition);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_X, new Float(position));
          }
          else
          {
            // not snapping ...
            final long localXPosition = Math.max(0, targetPositionX - layoutedParentX);
            final float position = (float) StrictGeomUtility.toExternalValue(localXPosition);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_X, new Float(position));
          }
        }
        else
        {
          // snapping to the left border..
          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 = data.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)
          {
            final long targetPositionX2 = targetPositionX + elementWidth[i];
            final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition(targetPositionX2,
                element.getObjectID());
            if (Math.abs(snapPosition2 - targetPositionX2) < snapThreshold)
            {
              // snapping to the right
              final long snapX = snapPosition2 - elementWidth[i];
              final long localXPosition = Math.max(0, snapX - layoutedParentX);
              final long percentage = StrictGeomUtility.toInternalValue(localXPosition * 100 / parentBase);
              styleSheet.setStyleProperty(ElementStyleKeys.POS_X,
                  new Float(StrictGeomUtility.toExternalValue(-percentage)));
            }
            else
            {
              // not snapping
              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
          {
            // snapping to the left
            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)));
          }
        }
      }

      if (elementY >= 0)
      {
        // absolute position; resolving is easy here
        final long snapPosition = verticalSnapModel.getNearestSnapPosition(targetPositionY, element.getObjectID());
        if (Math.abs(snapPosition - targetPositionY) > snapThreshold)
        {
          final long targetPositionY2 = targetPositionY + elementHeight[i];
          final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition(targetPositionY2,
              element.getObjectID());
          if (Math.abs(snapPosition2 - targetPositionY2) < snapThreshold)
          {
            // snap to the bottom
            final long snapY = snapPosition2 - elementHeight[i];
            final long localYPosition = Math.max(0, snapY - layoutedParentY);
            final float position = (float) StrictGeomUtility.toExternalValue(localYPosition);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_Y, new Float(position));
          }
          else
          {
            // not snapping
            final long localYPosition = Math.max(0, targetPositionY - layoutedParentY);
            final float position = (float) StrictGeomUtility.toExternalValue(localYPosition);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_Y, new Float(position));
          }
        }
        else
        {
          // snap to the top
          final long localYPosition = Math.max(0, snapPosition - layoutedParentY);
          final float position = (float) StrictGeomUtility.toExternalValue(localYPosition);
          styleSheet.setStyleProperty(ElementStyleKeys.POS_Y, new Float(position));
        }
      }
      else
      {

        final long parentBase;
        if (isCanvasElement(parent))
        {
          parentBase = data.getHeight();
        }
        else
        {
          parentBase = data.getWidth();
        }
        if (parentBase > 0)
        {
          // relative position; resolve the percentage against the height of the parent.
          final long snapPosition = verticalSnapModel.getNearestSnapPosition(targetPositionY, element.getObjectID());
          if (Math.abs(snapPosition - targetPositionY) > snapThreshold)
          {
            final long targetPositionY2 = targetPositionY + elementHeight[i];
            final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition(targetPositionY2,
                element.getObjectID());
            if (Math.abs(snapPosition2 - targetPositionY2) < snapThreshold)
            {
              // snap to the bottom
              final long snapY = snapPosition2 - elementHeight[i];
              final long localYPosition = Math.max(0, snapY - layoutedParentY);
              final long percentage = StrictGeomUtility.toInternalValue(localYPosition * 100 / parentBase);
              styleSheet.setStyleProperty(ElementStyleKeys.POS_Y,
                  new Float(StrictGeomUtility.toExternalValue(-percentage)));
            }
            else
            {
              // not snapping at all
              final long localYPosition = Math.max(0, targetPositionY - layoutedParentY);
              // 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(localYPosition * 100 / parentBase);
              styleSheet.setStyleProperty(ElementStyleKeys.POS_Y,
                  new Float(StrictGeomUtility.toExternalValue(-percentage)));
            }
          }
          else
          {
            // snap to the top
            final long localYPosition = Math.max(0, snapPosition - layoutedParentY);
            // 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(localYPosition * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_Y,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
        }
      }

View Full Code Here


  }


  protected boolean isCanvasElement(final Element reportElement)
  {
    final ElementStyleSheet styleSheet = reportElement.getStyle();
    final Object o = styleSheet.getStyleProperty(BandStyleKeys.LAYOUT);

    if (BandStyleKeys.LAYOUT_CANVAS.equals(o))
    {
      return true;
    }
View Full Code Here

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

      // this is where I want the element on a global scale...
      final long targetWidth = elementWidth[i] + dx;
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
      final long elementX = data.getX();
      final long targetX2 = elementX + targetWidth;

      if (elementMinWidth >= 0)
      {
        // absolute position; resolving is easy here
        final long snapPosition = horizontalSnapModel.getNearestSnapPosition(targetX2, element.getObjectID());
        if (Math.abs(snapPosition - targetX2) > snapThreshold)
        {
          final long localWidth = Math.max(0, targetX2 - elementX);
          final float position = (float) StrictGeomUtility.toExternalValue(localWidth);
          styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH, new Float(position));
        }
        else
        {
          final long localWidth = Math.max(0, snapPosition - elementX);
          final float position = (float) StrictGeomUtility.toExternalValue(localWidth);
          styleSheet.setStyleProperty(ElementStyleKeys.MIN_WIDTH, new Float(position));
        }
      }
      else
      {
        final Element parent = element.getParentSection();
        final CachedLayoutData parentData = ModelUtility.getCachedLayoutData(parent);

        final long parentBase = parentData.getWidth();
        if (parentBase > 0)
        {
          // relative position; resolve the percentage against the height of the parent.
          final long snapPosition = horizontalSnapModel.getNearestSnapPosition(targetX2, element.getObjectID());
          if (Math.abs(snapPosition - targetX2) > snapThreshold)
          {
            final long localWidth = Math.max(0, targetX2 - elementX);
            // 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)));
          }
          else
          {
            final long localWidth = Math.max(0, snapPosition - elementX);
            // 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)));
          }
        }
      }

View Full Code Here

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

      // this is where I want the element on a global scale...
      final long targetPositionY = elementY[i] + dy;
      final Element parent = element.getParentSection();
      final CachedLayoutData parentData = ModelUtility.getCachedLayoutData(parent);
      final long layoutedParentY = parentData.getY();

      if (targetPositionY < layoutedParentY)
      {
        continue;
      }
      // this is what we used to apply to POS_Y
      final long computedPositionY;
      if (definedElementY >= 0)
      {
        // absolute position; resolving is easy here
        final long snapPosition = verticalSnapModel.getNearestSnapPosition(targetPositionY, element.getObjectID());
        if (Math.abs(snapPosition - targetPositionY) > snapThreshold)
        {
          computedPositionY = targetPositionY;
          final long localYPosition = Math.max(0, targetPositionY - layoutedParentY);
          final float position = (float) StrictGeomUtility.toExternalValue(localYPosition);
          styleSheet.setStyleProperty(ElementStyleKeys.POS_Y, new Float(position));
        }
        else
        {
          computedPositionY = snapPosition;
          final long localYPosition = Math.max(0, snapPosition - layoutedParentY);
          final float position = (float) StrictGeomUtility.toExternalValue(localYPosition);
          styleSheet.setStyleProperty(ElementStyleKeys.POS_Y, new Float(position));
        }
      }
      else
      {
        final long parentBase;
        if (isCanvasElement(parent))
        {
          parentBase = parentData.getHeight();
        }
        else
        {
          parentBase = parentData.getWidth();
        }
        if (parentBase > 0)
        {
          // relative position; resolve the percentage against the width of the parent.
          final long snapPosition = verticalSnapModel.getNearestSnapPosition(targetPositionY, element.getObjectID());
          if (Math.abs(snapPosition - targetPositionY) > snapThreshold)
          {
            computedPositionY = targetPositionY;
            final long localYPosition = Math.max(0, targetPositionY - layoutedParentY);
            // 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(localYPosition * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_Y,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
          else
          {
            computedPositionY = snapPosition;
            final long localYPosition = Math.max(0, snapPosition - layoutedParentY);
            // 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(localYPosition * 100 / parentBase);
            styleSheet.setStyleProperty(ElementStyleKeys.POS_Y,
                new Float(StrictGeomUtility.toExternalValue(-percentage)));
          }
        }
        else
        {
          // we cannot handle this element.
          continue;
        }
      }

      final double elementMinHeight = styleSheet.getDoubleStyleProperty(ElementStyleKeys.MIN_HEIGHT, 0);
      final long targetY2 = elementY[i] + elementHeight[i];
      if (elementMinHeight >= 0)
      {
        final long localHeight = Math.max(0, targetY2 - computedPositionY);
        final float position = (float) StrictGeomUtility.toExternalValue(localHeight);
        styleSheet.setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(position));
      }
      else
      {
        final long parentBase = parentData.getHeight();
        if (parentBase > 0)
        {
          final long localHeight = Math.max(0, targetY2 - computedPositionY);
          // 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)));
        }
      }

      element.notifyNodePropertiesChanged();
View Full Code Here

      setSelected(false);
      return;
    }

    final Element element = visualElements.get(0);
    final ElementStyleSheet styleSheet = element.getStyle();
    setSelected(styleSheet.getBooleanStyleProperty(ElementStyleKeys.SCALE));
  }
View Full Code Here

    final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();

    Boolean value = null;
    for (Element element : visualElements)
    {
      final ElementStyleSheet styleSheet = element.getStyle();
      if (value == null)
      {
        if (styleSheet.getBooleanStyleProperty(ElementStyleKeys.SCALE))
        {
          value = Boolean.FALSE;
        }
        else
        {
          value = Boolean.TRUE;
        }
      }
      undos.add(StyleEditUndoEntry.createConditional(element, ElementStyleKeys.SCALE, value));
      styleSheet.setStyleProperty(ElementStyleKeys.SCALE, value);
    }
    getActiveContext().getUndo().addChange(ActionMessages.getString("ScaleAction.UndoName"),
        new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
  }
View Full Code Here

      setSelected(false);
      return;
    }

    final Element element = visualElements.get(0);
    final ElementStyleSheet styleSheet = element.getStyle();
    setSelected(ElementAlignment.LEFT.equals(styleSheet.getStyleProperty(ElementStyleKeys.ALIGNMENT)));
  }
View Full Code Here

    }
    final List<Element> visualElements = model.getSelectedElementsOfType(Element.class);
    final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
    for (Element element : visualElements)
    {
      final ElementStyleSheet styleSheet = element.getStyle();
      undos.add(StyleEditUndoEntry.createConditional(element, ElementStyleKeys.ALIGNMENT, ElementAlignment.LEFT));
      styleSheet.setStyleProperty(ElementStyleKeys.ALIGNMENT, ElementAlignment.LEFT);
      element.notifyNodePropertiesChanged();
    }
    getActiveContext().getUndo().addChange(ActionMessages.getString("TextAlignmentLeftAction.UndoName"),
        new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
  }
View Full Code Here

    final List<Element> visualElements = model.getSelectedElementsOfType(Element.class);
    Boolean value = null;
    final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();
    for (Element element : visualElements)
    {
      final ElementStyleSheet styleSheet = element.getStyle();
      if (value == null)
      {
        if (styleSheet.getBooleanStyleProperty(TextStyleKeys.UNDERLINED))
        {
          value = Boolean.FALSE;
        }
        else
        {
          value = Boolean.TRUE;
        }
      }
      undos.add(StyleEditUndoEntry.createConditional(element, TextStyleKeys.UNDERLINED, value));
      styleSheet.setStyleProperty(TextStyleKeys.UNDERLINED, value);
      element.notifyNodePropertiesChanged();
    }
    getActiveContext().getUndo().addChange(ActionMessages.getString("UnderlineAction.UndoName"),
        new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
View Full Code Here

    final ArrayList<UndoEntry> undos = new ArrayList<UndoEntry>();

    Boolean value = null;
    for (Element element : visualElements)
    {
      final ElementStyleSheet styleSheet = element.getStyle();
      if (value == null)
      {
        if (styleSheet.getBooleanStyleProperty(TextStyleKeys.STRIKETHROUGH))
        {
          value = Boolean.FALSE;
        }
        else
        {
          value = Boolean.TRUE;
        }
      }
      undos.add(StyleEditUndoEntry.createConditional(element, TextStyleKeys.STRIKETHROUGH, value));
      styleSheet.setStyleProperty(TextStyleKeys.STRIKETHROUGH, value);
      element.notifyNodePropertiesChanged();
    }
    getActiveContext().getUndo().addChange(ActionMessages.getString("StrikethroughAction.UndoName"),
        new CompoundUndoEntry(undos.toArray(new UndoEntry[undos.size()])));
  }
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.