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

Examples of org.pentaho.reporting.engine.classic.core.DefaultImageReference


    final ProcessingContext processingContext = new DefaultProcessingContext();
    final DebugExpressionRuntime runtime = new DebugExpressionRuntime(new DefaultTableModel(), 0, processingContext);

    final Element reportElement = (Element) report2.getPageHeader().getElement(4);
    final Object designValue = reportElement.getElementType().getDesignValue(runtime, reportElement);
    final DefaultImageReference image = (DefaultImageReference) designValue;
    assertEquals(456, image.getImageWidth());
    assertEquals(69, image.getImageHeight());

  }
View Full Code Here


  {
    if (value instanceof Image)
    {
      try
      {
        final ImageContainer imageContainer = new DefaultImageReference((Image) value);
        final StyleSheet rawSource = textExtractor.getRawSource().getStyleSheet();
        final StrictBounds contentBounds =
            new StrictBounds(content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight());
        createImageCell(rawSource, imageContainer, sheetLayout, rectangle, contentBounds);
      }
View Full Code Here

    if (value instanceof Image)
    {
      try
      {
        return new DefaultImageReference((Image) value);
      }
      catch (IOException e)
      {
        ContentType.logger.warn("Failed to load content using value " + value, e);
      }
      return null;
    }
    if (value instanceof Shape)
    {
      return value;
    }
    if (value instanceof ImageContainer)
    {
      return value;
    }
    if (value instanceof Component)
    {
      final Component c = (Component) value;
      return new DrawableWrapper(createComponentDrawable(runtime, c, element));
    }
    if (value instanceof DrawableWrapper)
    {
      return value;
    }
    if (DrawableWrapper.isDrawable(value))
    {
      return new DrawableWrapper(value);
    }

    final ContentTypeContext context = element.getElementContext(ContentTypeContext.class);
    if (context.failureCache != null)
    {
      final Object o = context.failureCache.get(value);
      if (Boolean.TRUE.equals(o))
      {
        return null;
      }
    }
    try
    {
      final ResourceKey contentBase = runtime.getProcessingContext().getContentBase();
      final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
      final Object contentBaseValue = element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.CONTENT_BASE);
      final ResourceKey key = resManager.createOrDeriveKey(contentBase, value, contentBaseValue);
      if (key == null)
      {
        return null;
      }

      final Resource resource = resManager.create(key, contentBase, ContentType.TARGETS);
      final Object resourceContent = resource.getResource();
      if (resourceContent instanceof DrawableWrapper)
      {
        return resourceContent;
      }
      else if (DrawableWrapper.isDrawable(resourceContent))
      {
        return new DrawableWrapper(resourceContent);
      }
      else if (resourceContent instanceof Image)
      {
        return new DefaultImageReference(resource);
      }
      else
      {
        return resourceContent;
      }
View Full Code Here

    if (rawObject instanceof DrawableWrapper)
    {
      final DrawableWrapper drawable = (DrawableWrapper) rawObject;
      // render it into an Buffered image and make it a PNG file.
      final StrictBounds cb = new StrictBounds(0, 0, width, height);
      final DefaultImageReference image =
          RenderUtility.createImageFromDrawable(drawable, cb, styleSheet, metaData);
      if (image == null)
      {
        //xmlWriter.writeComment("Drawable content [No image generated]:" + source);
        return null;
      }

      return image.getImage();
    }
    return null;
  }
View Full Code Here

      final Object o = content.getContent().getRawObject();
      if (o instanceof DrawableWrapper)
      {
        final DrawableWrapper drawableWrapper = (DrawableWrapper) o;
        final StrictBounds bounds = new StrictBounds(content.getX(), content.getY(), content.getWidth(), content.getHeight());
        DefaultImageReference imageContainer =
            RenderUtility.createImageFromDrawable(drawableWrapper, bounds, content.getStyleSheet(), metaData);
        return Image.getInstance(imageContainer.getImage(), Color.WHITE);
      }
      if (o instanceof java.awt.Image)
      {
        java.awt.Image img = (java.awt.Image) o;
        return Image.getInstance(img, Color.WHITE);
      }

      if (o instanceof URLImageContainer)
      {
        final URLImageContainer imageContainer = (URLImageContainer) o;
        final Image image = createImage(imageContainer);
        if (image != null)
        {
          return image;
        }
      }

      if (o instanceof LocalImageContainer)
      {
        final LocalImageContainer imageContainer = (LocalImageContainer) o;
        final java.awt.Image image = imageContainer.getImage();
        return Image.getInstance(image, Color.WHITE);
      }
      return null;
    }
    catch (IOException e)
View Full Code Here

    drawable.draw(g2, new Rectangle2D.Double(0, 0, imageWidth, imageHeight));
    g2.dispose();

    try
    {
      return new DefaultImageReference(image);
    }
    catch (final IOException e1)
    {
      logger.warn("Unable to fully load a given image. (It should not happen here.)", e1);
      return null;
View Full Code Here

    if (value instanceof Image)
    {
      try
      {
        final StrictBounds contentBounds = sheetLayout.getBounds(rectangle);
        final ImageContainer imageContainer = new DefaultImageReference((Image) value);
        createImageCell(rawSource, imageContainer, sheetLayout, rectangle, contentBounds);
      }
      catch (final IOException ioe)
      {
        // Should not happen.
View Full Code Here

      return null;
    }

    try
    {
      return new DefaultImageReference((Image) o);
    }
    catch (IOException e)
    {
      ImageRefFilter.logger.warn("Unable to fully load a given image.", e);
      return null;
View Full Code Here

    {
      try
      {
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(o, Image.class);
        return new DefaultImageReference(resource);
      }
      catch (ResourceException e)
      {
        if (ImageLoadFilter.logger.isDebugEnabled())
        {
          ImageLoadFilter.logger.debug("Error while loading the image from a blob", e);
        }
        else if (ImageLoadFilter.logger.isWarnEnabled())
        {
          ImageLoadFilter.logger.warn("Error while loading the image from a blob: " + e.getMessage());
        }
        return null;
      }
    }
    else if (o instanceof Blob)
    {
      try
      {
        final Blob b = (Blob) o;
        final byte[] data = IOUtils.getInstance().readBlob(b);
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(data, Image.class);
        return new DefaultImageReference(resource);
      }
      catch (Exception e)
      {
        if (ImageLoadFilter.logger.isDebugEnabled())
        {
          ImageLoadFilter.logger.debug("Error while loading the image from a blob", e);
        }
        else if (ImageLoadFilter.logger.isWarnEnabled())
        {
          ImageLoadFilter.logger.warn("Error while loading the image from a blob: " + e.getMessage());
        }
        return null;
      }
    }
    else if (o instanceof URL)
    {
      // a valid url is found, lookup the url in the cache, maybe the image is loaded and
      // still there.
      final URL url = (URL) o;
      final String urlText = String.valueOf(url);
      if (failureCache.contains(urlText))
      {
        return null;
      }
      try
      {
        final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
        final Resource resource = resManager.createDirectly(url, Image.class);
        return new DefaultImageReference(resource);
      }
      catch (ResourceException e)
      {
        if (ImageLoadFilter.logger.isDebugEnabled())
        {
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.DefaultImageReference

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.