Examples of WaitingImageObserver


Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

    catch (ResourceException e)
    {
      throw new IOException("The image could not be loaded.");
    }

    final WaitingImageObserver wob = new WaitingImageObserver(image);
    wob.waitImageLoaded();
    if (wob.isError())
    {
      throw new IOException("Failed to load the image. ImageObserver signaled an error.");
    }
    this.width = image.getWidth(null);
    this.height = image.getHeight(null);
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

    if (img == null)
    {
      throw new NullPointerException();
    }
    this.image = img;
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    if (obs.isError())
    {
      throw new IOException("Failed to load the image. ImageObserver signaled an error.");
    }
    this.width = image.getWidth(null);
    this.height = image.getHeight(null);
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

    {
      this.url = (URL) identifier;
    }
    this.resourceKey = resKey;
    this.image = (Image) o;
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    if (obs.isError())
    {
      throw new ResourceException("Failed to load the image. ImageObserver signaled an error.");
    }
    this.width = image.getWidth(null);
    this.height = image.getHeight(null);
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

        ("default", data));

    final URL imageURL = ObjectUtilities.getResourceRelative
        ("gorilla.jpg", OpenSourceXMLDemoHandler.class);
    final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    report.getParameterValues().put("logo", image);
    return report;
  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

      final Resource resource = mgr.createDirectly(templateURL, MasterReport.class);
      final MasterReport report = (MasterReport) resource.getResource();
      final URL imageURL = ObjectUtilities.getResource
          ("org/pentaho/reporting/engine/classic/demo/opensource/gorilla.jpg", StraightToPDF.class);
      final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
      final WaitingImageObserver obs = new WaitingImageObserver(image);
      obs.waitImageLoaded();
      report.getParameterValues().put("logo", image);

      return report;
    }
    catch (Exception e)
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

      // done. Usually such images get referenced from the XML itself without
      // using manual coding.
      final URL imageURL = ObjectUtilities.getResource
          ("org/pentaho/reporting/engine/classic/demo/opensource/gorilla.jpg", StraightToPNG.class);
      final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
      final WaitingImageObserver obs = new WaitingImageObserver(image);
      obs.waitImageLoaded();
      report.getParameterValues().put("logo", image);
      return report;
    }
    catch (Exception e)
    {
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

    if (image == null)
    {
      return null;
    }

    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();

    try
    {
      final byte[] data = RenderUtility.encodeImage(image);
      final Image itextimage = Image.getInstance(data);
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

    {
      LogicalPageDrawable.logger.debug("Error: Image area is empty: " + content);
      return false;
    }

    WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    final int imageWidth = image.getWidth(obs);
    final int imageHeight = image.getHeight(obs);
    if (imageWidth < 1 || imageHeight < 1)
    {
      return false;
    }

    final Rectangle2D.Double drawAreaBounds = new Rectangle2D.Double(x, y, width, height);
    final AffineTransform scaleTransform;

    final Graphics2D g2;
    if (shouldScale == false)
    {
      double deviceScaleFactor = 1;
      final double devResolution = metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
      if (metaData.isFeatureSupported(OutputProcessorFeature.IMAGE_RESOLUTION_MAPPING))
      {
        if (devResolution != 72.0 && devResolution > 0)
        {
          // Need to scale the device to its native resolution before attempting to draw the image..
          deviceScaleFactor = (72.0 / devResolution);
        }
      }

      final int clipWidth = Math.min(width, (int) Math.ceil(deviceScaleFactor * imageWidth));
      final int clipHeight = Math.min(height, (int) Math.ceil(deviceScaleFactor * imageHeight));
      final ElementAlignment horizontalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.ALIGNMENT);
      final ElementAlignment verticalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.VALIGNMENT);
      final int alignmentX = (int) RenderUtility.computeHorizontalAlignment(horizontalAlignment, width, clipWidth);
      final int alignmentY = (int) RenderUtility.computeVerticalAlignment(verticalAlignment, height, clipHeight);

      g2 = (Graphics2D) getGraphics().create();
      g2.clip(drawAreaBounds);
      g2.translate(x, y);
      g2.translate(alignmentX, alignmentY);
      g2.clip(new Rectangle2D.Float(0, 0, clipWidth, clipHeight));
      g2.scale(deviceScaleFactor, deviceScaleFactor);

      scaleTransform = null;
    }
    else
    {
      g2 = (Graphics2D) getGraphics().create();
      g2.clip(drawAreaBounds);
      g2.translate(x, y);
      g2.clip(new Rectangle2D.Float(0, 0, width, height));

      final double scaleX;
      final double scaleY;

      final boolean keepAspectRatio = layoutContext.getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO);
      if (keepAspectRatio)
      {
        final double scaleFactor = Math.min(width / (double) imageWidth, height / (double) imageHeight);
        scaleX = scaleFactor;
        scaleY = scaleFactor;
      }
      else
      {
        scaleX = width / (double) imageWidth;
        scaleY = height / (double) imageHeight;
      }

      final int clipWidth = (int) (scaleX * imageWidth);
      final int clipHeight = (int) (scaleY * imageHeight);

      final ElementAlignment horizontalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.ALIGNMENT);
      final ElementAlignment verticalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.VALIGNMENT);
      final int alignmentX = (int) RenderUtility.computeHorizontalAlignment(horizontalAlignment, width, clipWidth);
      final int alignmentY = (int) RenderUtility.computeVerticalAlignment(verticalAlignment, height, clipHeight);

      g2.translate(alignmentX, alignmentY);

      final Object contentCached = content.getContent().getContentCached();
      if (contentCached instanceof Image)
      {
        image = (Image) contentCached;
        scaleTransform = null;
      }
      else if (metaData.isFeatureSupported(OutputProcessorFeature.PREFER_NATIVE_SCALING) == false)
      {
        image = RenderUtility.scaleImage(image, clipWidth, clipHeight, RenderingHints.VALUE_INTERPOLATION_BICUBIC,
            true);
        content.getContent().setContentCached(image);
        obs = new WaitingImageObserver(image);
        obs.waitImageLoaded();
        scaleTransform = null;
      }
      else
      {
        scaleTransform = AffineTransform.getScaleInstance(scaleX, scaleY);
      }
    }

    while (g2.drawImage(image, scaleTransform, obs) == false)
    {
      obs.waitImageLoaded();
      if (obs.isError())
      {
        LogicalPageDrawable.logger.warn("Error while loading the image during the rendering.");
        break;
      }
    }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

        logger.debug("Failed to render the image. This should not happen for BufferedImages")// NON-NLS
      }
    }
    else
    {
      final WaitingImageObserver obs = new WaitingImageObserver(image);
      obs.waitImageLoaded();

      while (graphics.drawImage(image, null, obs) == false)
      {
        obs.waitImageLoaded();
        if (obs.isError())
        {
          logger.warn("Error while loading the image during the rendering.")// NON-NLS
          break;
        }
      }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.WaitingImageObserver

    {
      PdfLogicalPageDrawable.logger.debug("Error: Image area is empty: " + content);
      return false;
    }

    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    final int imageWidth = image.getWidth(obs);
    final int imageHeight = image.getHeight(obs);
    if (imageWidth < 1 || imageHeight < 1)
    {
      return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.