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

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


    if (value instanceof Image)
    {
      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);
      }
View Full Code Here


      image = createComponentImage();
    }

    try
    {
      final DefaultImageReference ref = new DefaultImageReference(image);
      ref.setScale(1.0f / getScale(), 1.0f / getScale());
      return ref;
    }
    catch (IOException e)
    {
      PaintDynamicComponentFunction.logger.warn("Unable to fully load a given image. (It should not happen here.)");
View Full Code Here

    g2.drawString("You are viewing a graphics of JFreeReport on index "
        + event.getState().getCurrentDataItem(), 10, 10);
    g2.dispose();
    try
    {
      functionValue = new DefaultImageReference(image);
    }
    catch (IOException e)
    {
      functionValue = 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

      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

    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
      {
        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));
    }
    if (value instanceof DrawableWrapper)
    {
      return value;
    }
    if (DrawableWrapper.isDrawable(value))
    {
      return new DrawableWrapper(value);
    }

    if (failureCache != null)
    {
      final Object o = failureCache.get(value);
      if (Boolean.TRUE.equals(o))
      {
        return null;
      }
    }
    try
    {
      final ResourceKey contentBase = runtime.getProcessingContext().getContentBase();
      final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
      final ResourceKey key;
      if (value instanceof ResourceKey)
      {
        key = (ResourceKey) value;
      }
      else if (value instanceof Blob)
      {
        final Blob b = (Blob) value;
        final byte[] data = IOUtils.getInstance().readBlob(b);
        key = resManager.createKey(data);
      }
      else if (value instanceof String)
      {
        final Object baseURL = element.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.CONTENT_BASE);
        if (baseURL instanceof String)
        {
          final ResourceKey baseKey = createKeyFromString(resManager, null, (String) baseURL);
          key = createKeyFromString(resManager, baseKey, (String) value);
        }
        else if (baseURL instanceof ResourceKey)
        {
          final ResourceKey baseKey = (ResourceKey) baseURL;
          key = createKeyFromString(resManager, baseKey, (String) value);
        }
        else if (baseURL != null)
        {
          // if a base-url object is given, we assume that it is indeed valid.
          final ResourceKey baseKey = resManager.createKey(baseURL);
          key = createKeyFromString(resManager, baseKey, (String) value);
        }
        else
        {
          key = createKeyFromString(resManager, contentBase, (String) value);
        }
      }
      else
      {
        key = resManager.createKey(value);
      }
      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

      return null;
    }
   
    try
    {
      final DefaultImageReference ref = new DefaultImageReference(image);
      ref.setScale(1.0f / getScale(), 1.0f / getScale());
      return ref;
    }
    catch (IOException e)
    {
      PaintDynamicComponentFunction.logger.warn("Unable to fully load a given image. (It should not happen here.)");
View Full Code Here

    g2.drawString("You are viewing a graphics of JFreeReport on index "
        + event.getState().getCurrentRow(), 10, 10);
    g2.dispose();
    try
    {
      functionValue = new DefaultImageReference(image);
    }
    catch (IOException e)
    {
      functionValue = null;
    }
View Full Code Here

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

    final Element reportElement = (Element) report2.getReportHeader().getElement(0);
    final Object designValue = reportElement.getElementType().getDesignValue(runtime, reportElement);
    final DefaultImageReference image = (DefaultImageReference) designValue;
    assertEquals(20, image.getImageWidth());
    assertEquals(20, image.getImageHeight());

  }
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.