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

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


    final int lastElementIdx = reportElements.length - 1;
    final Element lastElement = reportElements[lastElementIdx];
    final Element firstElement = reportElements[0];

    final CachedLayoutData firstLayoutData = ModelUtility.getCachedLayoutData(firstElement);
    final CachedLayoutData lastLayoutData = ModelUtility.getCachedLayoutData(lastElement);

    final long height = (lastLayoutData.getX() + lastLayoutData.getWidth()) -
        (firstLayoutData.getX() + firstLayoutData.getWidth());

    final long incr = height / lastElementIdx;
    long currentY = firstLayoutData.getX() + firstLayoutData.getWidth();
    currentY += incr;//start from second element

    for (int i = 1; i < lastElementIdx; i++)
    {
      final Element reportElement = reportElements[i];
      final CachedLayoutData layoutData = ModelUtility.getCachedLayoutData(reportElement);
      final long delta = currentY - layoutData.getWidth();
      if (delta == 0)
      {
        continue;
      }

      carrier[0] = reportElement;
      final Point2D.Double originPoint = new Point2D.Double(StrictGeomUtility.toExternalValue(layoutData.getX()), 0);
      final MoveDragOperation mop = new MoveDragOperation
          (carrier, originPoint, EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE);
      mop.update(new Point2D.Double(StrictGeomUtility.toExternalValue(delta), 0), 1);
      mop.finish();
View Full Code Here


{
  private static class ElementPositionComparator implements Comparator<Element>
  {
    public int compare(final Element o1, final Element o2)
    {
      final CachedLayoutData data1 = ModelUtility.getCachedLayoutData(o1);
      final long x1 = data1.getX() + data1.getWidth();
      final CachedLayoutData data2 = ModelUtility.getCachedLayoutData(o2);
      final long x2 = data2.getX() + data2.getWidth();
      if (x1 < x2)
      {
        return -1;
      }
      if (x1 > x2)
View Full Code Here

    final int lastElementIdx = reportElements.length - 1;
    final Element lastElement = reportElements[lastElementIdx];
    final Element firstElement = reportElements[0];

    final CachedLayoutData firstLayoutData = ModelUtility.getCachedLayoutData(firstElement);
    final CachedLayoutData lastLayoutData = ModelUtility.getCachedLayoutData(lastElement);

    final long height = (lastLayoutData.getX() + lastLayoutData.getWidth() / 2) -
        (firstLayoutData.getX() + firstLayoutData.getWidth() / 2);

    final long incr = height / lastElementIdx;
    long currentY = firstLayoutData.getX() + firstLayoutData.getWidth() / 2;
    currentY += incr;//start from second element

    for (int i = 1; i < lastElementIdx; i++)
    {
      final Element reportElement = reportElements[i];
      final CachedLayoutData layoutData = ModelUtility.getCachedLayoutData(reportElement);
      final long delta = currentY - layoutData.getWidth() / 2;
      if (delta == 0)
      {
        continue;
      }

      carrier[0] = reportElement;
      final Point2D.Double originPoint = new Point2D.Double(StrictGeomUtility.toExternalValue(layoutData.getX()), 0);
      final MoveDragOperation mop = new MoveDragOperation
          (carrier, originPoint, EmptySnapModel.INSTANCE, EmptySnapModel.INSTANCE);
      mop.update(new Point2D.Double(StrictGeomUtility.toExternalValue(delta), 0), 1);
      mop.finish();
View Full Code Here

{
  private static class ElementPositionComparator implements Comparator<Element>
  {
    public int compare(final Element o1, final Element o2)
    {
      final CachedLayoutData data1 = ModelUtility.getCachedLayoutData(o1);
      final long x1 = data1.getX() + data1.getWidth() / 2;
      final CachedLayoutData data2 = ModelUtility.getCachedLayoutData(o2);
      final long x2 = data2.getX() + data2.getWidth() / 2;
      if (x1 < x2)
      {
        return -1;
      }
      if (x1 > x2)
View Full Code Here

      {
        continue;
      }
      if (e instanceof RootLevelBand)
      {
        final CachedLayoutData layoutData = ModelUtility.getCachedLayoutData((Element) e);
        final double height = StrictGeomUtility.toExternalValue(layoutData.getHeight());
        e.setAttribute(ReportDesignerBoot.DESIGNER_NAMESPACE, "visual-height", new Double(height)); // NON-NLS
      }

      if (e instanceof Section)
      {
View Full Code Here

    if (element instanceof Element == false)
    {
      return;
    }

    final CachedLayoutData data = ModelUtility.getCachedLayoutData((Element) element);
    if (data.isConflictsInTableMode())
    {
      resultHandler.notifyInspectionResult(new InspectionResult(this, InspectionResult.Severity.WARNING,
          Messages.getString("OverlappingElementsInspection.ElementConflictsInTableMode", element.getName()),
          new LocationInfo(element)));
    }
View Full Code Here

        final Element element = id.get(instanceId);
        if (element == null || element instanceof RootLevelBand)
        {
          continue;
        }
        final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
        rect2.setRect(data.getX(), data.getY(), data.getWidth(), data.getHeight());
        if (StrictBounds.intersects(rect1, rect2))
        {
          if (selectionModel.add(element))
          {
            newlySelectedElements.add(element);
          }
        }
      }

      // second step, check which previously added elements are no longer selected by the rectangle.
      for (Iterator<Element> visualReportElementIterator = newlySelectedElements.iterator(); visualReportElementIterator.hasNext();)
      {
        final Element element = visualReportElementIterator.next();
        final CachedLayoutData data = ModelUtility.getCachedLayoutData(element);
        rect2.setRect(data.getX(), data.getY(), data.getWidth(), data.getHeight());
        if (StrictBounds.intersects(rect1, rect2) == false)
        {
          selectionModel.remove(element);
          visualReportElementIterator.remove();
        }
View Full Code Here

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

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

    draw(rootElement, graphics);
  }

  private void draw(final Element element, final Graphics2D graphics2D)
  {
    final CachedLayoutData layoutData = ModelUtility.getCachedLayoutData(element);
    if (layoutData.getLayoutAge() > -1 && layoutData.isConflictsInTableMode())
    {
      final double x = StrictGeomUtility.toExternalValue(layoutData.getX());
      final double y = StrictGeomUtility.toExternalValue(layoutData.getY());
      final double width = StrictGeomUtility.toExternalValue(layoutData.getWidth());
      final double height = StrictGeomUtility.toExternalValue(layoutData.getHeight());
      elementBounds.setFrame(x * zoomFactor, y * zoomFactor, width * zoomFactor, height * zoomFactor);
      graphics2D.setPaint(HIGHLIGHT);
      graphics2D.fill(elementBounds);
    }

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.