Package org.pentaho.reporting.designer.core.model

Examples of org.pentaho.reporting.designer.core.model.CachedLayoutData


    final MassElementStyleUndoEntryBuilder builder = new MassElementStyleUndoEntryBuilder(objects);

    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long y1 = data.getY();
      if (y1 < minY)
      {
        minY = y1;
      }
    }

    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);

      final long delta = minY - data.getY();
      if (delta == 0)
      {
        continue;
      }
View Full Code Here


    long minY = Long.MAX_VALUE;
    long maxY = Long.MIN_VALUE;
    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long y1 = data.getY();
      final long y2 = y1 + data.getHeight();
      if (y2 > maxY)
      {
        maxY = y2;
      }
      if (y1 < minY)
      {
        minY = y1;
      }
    }

    final long centerPoint = minY + (maxY - minY) / 2;

    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long elementCenter = data.getY() + data.getHeight() / 2;

      final long delta = centerPoint - elementCenter;
      if (delta == 0)
      {
        continue;
View Full Code Here

    long minX = Long.MAX_VALUE;
    long maxX = Long.MIN_VALUE;
    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long x1 = data.getX();
      final long x2 = x1 + data.getWidth();
      if (x2 > maxX)
      {
        maxX = x2;
      }
      if (x1 < minX)
      {
        minX = x1;
      }
    }

    final long centerPoint = minX + (maxX - minX) / 2;

    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long elementCenter = data.getX() + data.getWidth() / 2;
      final long delta = centerPoint - elementCenter;
      if (delta == 0)
      {
        continue;
      }
View Full Code Here

    final Element element = elementsById.get(id);
    if (element == null)
    {
      return true;
    }
    final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
    if (data.getLayoutAge() == age)
    {
      return true;
    }

    data.setX(box.getX());
    data.setY(box.getY());
    data.setWidth(box.getWidth());
    data.setHeight(box.getHeight());
    final BoxDefinition boxDefinition = box.getBoxDefinition();
    data.setPaddingX(boxDefinition.getPaddingLeft() + boxDefinition.getBorder().getLeft().getWidth());
    data.setPaddingY(boxDefinition.getPaddingTop() + boxDefinition.getBorder().getTop().getWidth());
    data.setLayoutAge(age);
    data.setElementType(box.getNodeType());
    data.setConflictsInTableMode(conflicts.containsKey(id));

    horizontalEdgePositions.add(box.getX(), box.getInstanceId());
    horizontalEdgePositions.add(box.getX() + box.getWidth(), box.getInstanceId());
    verticalEdgePositions.add(box.getY(), box.getInstanceId());
    verticalEdgePositions.add(box.getY() + box.getHeight(), box.getInstanceId());
View Full Code Here

    if (element == null)
    {
      return true;
    }

    final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
    if (data.getLayoutAge() == age)
    {
      data.addAdditionalBounds(new StrictBounds(box.getX(), box.getY(), box.getWidth(), box.getHeight()));
      return true;
    }

    horizontalEdgePositions.add(box.getX(), box.getInstanceId());
    horizontalEdgePositions.add(box.getX() + box.getWidth(), box.getInstanceId());
    verticalEdgePositions.add(box.getY(), box.getInstanceId());
    verticalEdgePositions.add(box.getY() + box.getHeight(), box.getInstanceId());

    data.setX(box.getX());
    data.setY(box.getY());
    data.setWidth(box.getWidth());
    data.setHeight(box.getHeight());
    final BoxDefinition boxDefinition = box.getBoxDefinition();
    data.setPaddingX(boxDefinition.getPaddingLeft() + boxDefinition.getBorder().getLeft().getWidth());
    data.setPaddingY(boxDefinition.getPaddingTop() + boxDefinition.getBorder().getTop().getWidth());
    data.clearAdditionalBounds();
    data.setLayoutAge(age);
    data.setElementType(box.getNodeType());
    return true;
  }
View Full Code Here

      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) > SNAP_THRESHOLD)
        {
          final long targetPositionX2 = targetPositionX + elementWidth[i];
          final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition
              (targetPositionX2, element.getObjectID());
          if (Math.abs(snapPosition2 - targetPositionX2) < SNAP_THRESHOLD)
          {
            // 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) > SNAP_THRESHOLD)
          {
            final long targetPositionX2 = targetPositionX + elementWidth[i];
            final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition(targetPositionX2,
                element.getObjectID());
            if (Math.abs(snapPosition2 - targetPositionX2) < SNAP_THRESHOLD)
            {
              // snapping to the right
              final long snapX = snapPosition2 - elementWidth[i];
              final long localXPosition = Math.max(0, snapX - layoutedParentX);
              final long percentage = localXPosition * (1000 * 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 = localXPosition * (1000 * 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 = localXPosition * (1000 * 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) > SNAP_THRESHOLD)
        {
          final long targetPositionY2 = targetPositionY + elementHeight[i];
          final long snapPosition2 = horizontalSnapModel.getNearestSnapPosition(targetPositionY2,
              element.getObjectID());
          if (Math.abs(snapPosition2 - targetPositionY2) < SNAP_THRESHOLD)
          {
            // 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());
View Full Code Here

    this.elementHeight = new long[this.selectedVisualElements.length];

    for (int i = 0; i < this.selectedVisualElements.length; i++)
    {
      final Element element = this.selectedVisualElements[i];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
      elementX[i] = data.getX();
      elementY[i] = data.getY();
      elementWidth[i] = data.getWidth();
      elementHeight[i] = data.getHeight();
    }
  }
View Full Code Here

      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) > SNAP_THRESHOLD)
        {
          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) > SNAP_THRESHOLD)
View Full Code Here

      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) > SNAP_THRESHOLD)
        {
          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) > SNAP_THRESHOLD)
          {
            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 = localYPosition * (1000 * 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 = localYPosition * (1000 * 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.
View Full Code Here

    long minX = Long.MAX_VALUE;
    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long x1 = data.getX();
      if (x1 < minX)
      {
        minX = x1;
      }
    }

    for (int j = 0; j < objects.length; j++)
    {
      final Element object = objects[j];
      final CachedLayoutData data = ModelUtility.getCachedLayoutData(object);
      final long elementCenter = data.getX();
      final long delta = minX - elementCenter;
      if (delta == 0)
      {
        continue;
      }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.designer.core.model.CachedLayoutData

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.