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

Examples of org.pentaho.reporting.engine.classic.core.util.geom.StrictBounds


    {
      try
      {
        final ImageContainer imageContainer = new DefaultImageReference((Image) value);
        final RenderNode rawSource = textExtractor.getRawSource();
        final StrictBounds contentBounds =
            new StrictBounds(content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight());
        createImageCell(rawSource, imageContainer, sheetLayout, rectangle, contentBounds);
      }
      catch (IOException ioe)
      {
        // Should not happen.
        ExcelPrinter.logger.warn("Failed to process AWT-Image in Excel-Export", ioe);
      }
      return false;
    }
    else if (value instanceof ImageContainer)
    {
      final ImageContainer imageContainer = (ImageContainer) value;
      // todo: this is wrong ..
      final RenderNode rawSource = textExtractor.getRawSource();
      final StrictBounds contentBounds =
          new StrictBounds(content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight());
      createImageCell(rawSource, imageContainer, sheetLayout, rectangle, contentBounds);
      return false;
    }
    else if (value instanceof DrawableWrapper)
    {
      final DrawableWrapper drawable = (DrawableWrapper) value;
      final RenderNode rawSource = textExtractor.getRawSource();
      final StrictBounds contentBounds = new StrictBounds
          (rawSource.getX(), rawSource.getY() + contentOffset, rawSource.getWidth(), rawSource.getHeight());
      final ImageContainer imageFromDrawable =
          RenderUtility.createImageFromDrawable(drawable, contentBounds, content, metaData);
      createImageCell(rawSource, imageFromDrawable, sheetLayout, rectangle, contentBounds);
      return false;
View Full Code Here


      final long internalImageHeight = StrictGeomUtility.toInternalValue(scaleFactor * imageHeight);

      final long cellWidth = cellBounds.getWidth();
      final long cellHeight = cellBounds.getHeight();

      final StrictBounds cb;
      final int pictureId;
      try
      {
        if (shouldScale)
        {
          final double scaleX;
          final double scaleY;

          final boolean keepAspectRatio = layoutContext.getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO);
          if (keepAspectRatio)
          {
            final double imgScaleFactor = Math.min(cellWidth / (double) internalImageWidth,
                cellHeight / (double) internalImageHeight);
            scaleX = imgScaleFactor;
            scaleY = imgScaleFactor;
          }
          else
          {
            scaleX = cellWidth / (double) internalImageWidth;
            scaleY = cellHeight / (double) internalImageHeight;
          }

          final long clipWidth = (long) (scaleX * internalImageWidth);
          final long clipHeight = (long) (scaleY * internalImageHeight);

          final long alignmentX = RenderUtility.computeHorizontalAlignment(horizontalAlignment, cellWidth, clipWidth);
          final long alignmentY = RenderUtility.computeVerticalAlignment(verticalAlignment, cellHeight, clipHeight);

          cb = new StrictBounds(cellBounds.getX() + alignmentX,
              cellBounds.getY() + alignmentY,
              Math.min(clipWidth, cellWidth),
              Math.min(clipHeight, cellHeight));

          // Recompute the cells that this image will cover (now that it has been resized)
          rectangle = currentLayout.getTableBounds(cb, rectangle);

          pictureId = loadImage(workbook, image);
          if (pictureId <= 0)
          {
            return;
          }
        }
        else
        {
          // unscaled ..
          if (internalImageWidth <= cellWidth &&
              internalImageHeight <= cellHeight)
          {
            // No clipping needed.
            final long alignmentX = RenderUtility.computeHorizontalAlignment
                (horizontalAlignment, cellBounds.getWidth(), internalImageWidth);
            final long alignmentY = RenderUtility.computeVerticalAlignment
                (verticalAlignment, cellBounds.getHeight(), internalImageHeight);

            cb = new StrictBounds(cellBounds.getX() + alignmentX,
                cellBounds.getY() + alignmentY,
                internalImageWidth,
                internalImageHeight);

            // Recompute the cells that this image will cover (now that it has been resized)
            rectangle = currentLayout.getTableBounds(cb, rectangle);

            pictureId = loadImage(workbook, image);
            if (pictureId <= 0)
            {
              return;
            }
          }
          else
          {
            // at least somewhere there is clipping needed.
            final long clipWidth = Math.min(cellWidth, internalImageWidth);
            final long clipHeight = Math.min(cellHeight, internalImageHeight);
            final long alignmentX = RenderUtility.computeHorizontalAlignment
                (horizontalAlignment, cellBounds.getWidth(), clipWidth);
            final long alignmentY = RenderUtility.computeVerticalAlignment
                (verticalAlignment, cellBounds.getHeight(), clipHeight);
            cb = new StrictBounds(cellBounds.getX() + alignmentX,
                cellBounds.getY() + alignmentY,
                clipWidth,
                clipHeight);

            // Recompute the cells that this image will cover (now that it has been resized)
            rectangle = currentLayout.getTableBounds(cb, rectangle);


            pictureId = loadImageWithClipping(workbook, image, clipWidth, clipHeight, scaleFactor);
            if (pictureId <= 0)
            {
              return;
            }
          }
        }
      }
      catch (UnsupportedEncoderException uee)
      {
        // should not happen, as PNG is always supported.
        logger.warn("Assertation-Failure: PNG encoding failed.", uee);
        return;
      }


      final int cell1x = rectangle.getX1();
      final int cell1y = rectangle.getY1();
      final int cell2x = Math.max(cell1x, rectangle.getX2() - 1);
      final int cell2y = Math.max(cell1y, rectangle.getY2() - 1);

      final long cell1width = currentLayout.getCellWidth(cell1x);
      final long cell1height = currentLayout.getRowHeight(cell1y);
      final long cell2width = currentLayout.getCellWidth(cell2x);
      final long cell2height = currentLayout.getRowHeight(cell2y);

      final long cell1xPos = currentLayout.getXPosition(cell1x);
      final long cell1yPos = currentLayout.getYPosition(cell1y);
      final long cell2xPos = currentLayout.getXPosition(cell2x);
      final long cell2yPos = currentLayout.getYPosition(cell2y);

      final int dx1 = (int) (1023 * ((cb.getX() - cell1xPos) / (double) cell1width));
      final int dy1 = (int) (255 * ((cb.getY() - cell1yPos) / (double) cell1height));
      final int dx2 = (int) (1023 * ((cb.getX() + cb.getWidth() - cell2xPos) / (double) cell2width));
      final int dy2 = (int) (255 * ((cb.getY() + cb.getHeight() - cell2yPos) / (double) cell2height));

      final ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor();
      anchor.setDx1(dx1);
      anchor.setDy1(dy1);
      anchor.setDx2(dx2);
View Full Code Here

    xmlWriter.writeCloseTag();
  }

  protected void processPage(final LogicalPageBox rootBox)
  {
    final StrictBounds pageBounds = drawArea;
    startProcessing(rootBox.getWatermarkArea());

    final BlockRenderBox headerArea = rootBox.getHeaderArea();
    final BlockRenderBox footerArea = rootBox.getFooterArea();
    final StrictBounds headerBounds = new StrictBounds(headerArea.getX(), headerArea.getY(), headerArea.getWidth(),
        headerArea.getHeight());
    final StrictBounds footerBounds = new StrictBounds(footerArea.getX(), footerArea.getY(), footerArea.getWidth(),
        footerArea.getHeight());
    final StrictBounds contentBounds = new StrictBounds
        (rootBox.getX(), headerArea.getY() + headerArea.getHeight(),
            rootBox.getWidth(), footerArea.getY() - headerArea.getHeight());
    this.drawArea = headerBounds;
    startProcessing(headerArea);
    this.drawArea = contentBounds;
View Full Code Here

    }
  }

  protected void processOtherNode(final RenderNode node)
  {
    final StrictBounds paragraphBounds = getParagraphBounds();
    if (isTextLineOverflow() && node.isNodeVisible(paragraphBounds, isOverflowX(), isOverflowY()) == false)
    {
      return;
    }

    super.processOtherNode(node);
    if (node.getNodeType() == LayoutNodeTypes.TYPE_NODE_TEXT)
    {
      if (node.isVirtualNode())
      {
        return;
      }

      if ((node.getX() + node.getWidth()) > (paragraphBounds.getX() + paragraphBounds.getWidth()))
      {
        // This node will only be partially visible. The end-of-line marker will not apply.
        return;
      }
      final RenderableText text = (RenderableText) node;
View Full Code Here

        }
        currentContext.add(image);
      }
      else if (rawObject instanceof DrawableWrapper)
      {
        final StrictBounds rect = new StrictBounds
            (node.getX(), node.getY(), node.getWidth(), node.getHeight());
        final ImageContainer ic =
            RenderUtility.createImageFromDrawable((DrawableWrapper) rawObject, rect, node, metaData);
        if (ic == null)
        {
View Full Code Here

    pageAttributes.setAttribute(LAYOUT_OUTPUT_NAMESPACE, "margin-right", pointConverter.format(marginRight));

    xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "physical-page", pageAttributes, XmlWriter.OPEN);

    // and now process the box ..
    drawArea = new StrictBounds(page.getGlobalX(), page.getGlobalY(),
        page.getImageableWidth(), page.getImageableHeight());
    processPage(logicalPage);

    xmlWriter.writeCloseTag();
  }
View Full Code Here

    pageAttributes.setAttribute(LAYOUT_OUTPUT_NAMESPACE, "height", pointConverter.format(height));

    xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "logical-page", pageAttributes, XmlWriter.OPEN);

    // and now process the box ..
    drawArea = new StrictBounds(0, 0, logicalPage.getPageWidth(), logicalPage.getPageHeight());
    processPage(logicalPage);

    xmlWriter.writeCloseTag();
  }
View Full Code Here

    xmlWriter.writeCloseTag();
  }

  protected void processPage(final LogicalPageBox rootBox)
  {
    final StrictBounds pageBounds = drawArea;
    startProcessing(rootBox.getWatermarkArea());

    final BlockRenderBox headerArea = rootBox.getHeaderArea();
    final BlockRenderBox footerArea = rootBox.getFooterArea();
    final StrictBounds headerBounds = new StrictBounds(headerArea.getX(), headerArea.getY(), headerArea.getWidth(),
        headerArea.getHeight());
    final StrictBounds footerBounds = new StrictBounds(footerArea.getX(), footerArea.getY(), footerArea.getWidth(),
        footerArea.getHeight());
    final StrictBounds contentBounds = new StrictBounds
        (rootBox.getX(), headerArea.getY() + headerArea.getHeight(),
            rootBox.getWidth(), footerArea.getY() - headerArea.getHeight());
    this.drawArea = headerBounds;
    startProcessing(headerArea);
    this.drawArea = contentBounds;
View Full Code Here

*/
public class StrictBoundsTest extends TestCase
{
  public void testIntersection ()
  {
    final StrictBounds testArea = new StrictBounds(100, 100, 100, 100);

    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(0, 0, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(150, 0, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(210, 0, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(0, 150, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(210, 150, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(0, 210, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(150, 210, 10, 10)));
    assertFalse(StrictBounds.intersects(testArea, new StrictBounds(210, 210, 10, 10)));

    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(95, 95, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(95, 150, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(95, 195, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(150, 95, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(150, 150, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(150, 195, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(195, 95, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(195, 150, 10, 10)));
    assertTrue(StrictBounds.intersects(testArea, new StrictBounds(195, 195, 10, 10)));

  }
View Full Code Here

    if (this.bounds == null)
    {
      recurse(box, section.getParentSection());
      if (this.bounds == null)
      {
        return new StrictBounds();
      }
    }
    return this.bounds;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.util.geom.StrictBounds

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.